Compare commits
6 Commits
68dce6df85
...
a8bb2928aa
Author | SHA1 | Date |
---|---|---|
noil | a8bb2928aa | |
noil | d60a58daea | |
noil | 4cb74a14ae | |
noil | c3941045d8 | |
noil | 8c1cf70d2b | |
noil | 9736132998 |
|
@ -38,8 +38,8 @@ public class NotePlayer {
|
|||
this.sequencer.open();
|
||||
this.sequencer.setSequence(this.currentSequence);
|
||||
this.sequencer.start();
|
||||
this.sequencer.setMasterSyncMode(Sequencer.SyncMode.INTERNAL_CLOCK);
|
||||
this.sequencer.setTempoInBPM(120);
|
||||
this.sequencer.setMasterSyncMode(Sequencer.SyncMode.MIDI_SYNC);
|
||||
//this.sequencer.setTempoInBPM(100);
|
||||
|
||||
//int resolution = this.currentSequence.getResolution();
|
||||
}
|
||||
|
|
|
@ -10,11 +10,15 @@ import net.minecraft.util.ResourceLocation;
|
|||
import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Seth
|
||||
|
@ -22,104 +26,79 @@ import java.util.*;
|
|||
*/
|
||||
public final class CapeManager {
|
||||
|
||||
private List<CapeUser> capeUserList = new ArrayList<>();
|
||||
private final List<CapeUser> capeUserList = new ArrayList<>();
|
||||
|
||||
private HashMap<String, ResourceLocation> capesMap = new HashMap<>();
|
||||
private final HashMap<String, ResourceLocation> capesMap = new HashMap<>();
|
||||
|
||||
public CapeManager() {
|
||||
//this.downloadCapeUsers();
|
||||
//this.downloadCapes();
|
||||
this.downloadCapeUsers();
|
||||
this.downloadCapes();
|
||||
Seppuku.INSTANCE.getEventManager().addEventListener(this);
|
||||
}
|
||||
|
||||
@Listener
|
||||
public void displayCape(EventCapeLocation event) {
|
||||
if (Minecraft.getMinecraft().player != null && event.getPlayer() != Minecraft.getMinecraft().player) {
|
||||
String uuid = event.getPlayer().getUniqueID().toString().replace("-", "");
|
||||
if (this.hasCape(uuid)) {
|
||||
final ResourceLocation cape = this.getCape(event.getPlayer());
|
||||
if (cape != null) {
|
||||
event.setLocation(cape);
|
||||
if (event.getPlayer() != null) {
|
||||
if (Minecraft.getMinecraft().player != null && event.getPlayer() != Minecraft.getMinecraft().player) {
|
||||
if (this.getCape(event.getPlayer()) != null) {
|
||||
event.setLocation(this.getCape(event.getPlayer()));
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasCapeForUuid(String uuid) {
|
||||
for (CapeUser capeUser : this.capeUserList) {
|
||||
if (capeUser.getUuid().equals(uuid)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean findCape(String uuid) {
|
||||
if (this.hasCapeForUuid(uuid))
|
||||
return true;
|
||||
|
||||
public void downloadCapeUsers() {
|
||||
// Thread t = new Thread(new Runnable() {
|
||||
// public void run() {
|
||||
// }
|
||||
// });
|
||||
// t.start();
|
||||
try {
|
||||
URL url = new URL("https://seppuku.pw/cape/" + uuid);
|
||||
URL url = new URL("https://seppuku.pw/capes/");
|
||||
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
|
||||
httpURLConnection.addRequestProperty("User-Agent", "Mozilla/4.76");
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(httpURLConnection.getInputStream()));
|
||||
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
if (!line.toLowerCase().startsWith("no") && line.toLowerCase().endsWith("png")) {
|
||||
this.capeUserList.add(new CapeUser(uuid, line));
|
||||
} else {
|
||||
return false;
|
||||
if (!line.startsWith("<pre>") && !line.startsWith("</pre>") && line.length() > 1) {
|
||||
final String[] split = line.split(";");
|
||||
if (split[0] != null && split[1] != null) {
|
||||
if (split[1].toLowerCase().endsWith("png")) {
|
||||
this.capeUserList.add(new CapeUser(split[0], split[1]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
reader.close();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
//e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Download and cache each cape for each user
|
||||
* TODO thread this
|
||||
*/
|
||||
public void downloadCape(String uuid) {
|
||||
CapeUser existingUser = null;
|
||||
public void downloadCapes() {
|
||||
for (CapeUser capeUser : this.capeUserList) {
|
||||
if (capeUser.getUuid().equals(uuid)) {
|
||||
existingUser = capeUser;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (existingUser != null) {
|
||||
if (this.capesMap.containsKey(existingUser.getCape())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
Minecraft.getMinecraft().getTextureManager();
|
||||
for (CapeUser user : this.capeUserList) {
|
||||
if (user != null) {
|
||||
if (Objects.equals(user.getUuid(), uuid)) {
|
||||
final ResourceLocation cape = this.findResource(user.getCape());
|
||||
|
||||
if (cape == null) {
|
||||
URL url = new URL(user.getCape());
|
||||
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
|
||||
httpURLConnection.addRequestProperty("User-Agent", "Mozilla/4.76");
|
||||
final DynamicTexture texture = new DynamicTexture(ImageIO.read(httpURLConnection.getInputStream()));
|
||||
if (this.findResource(capeUser.getCape()) == null) {
|
||||
try {
|
||||
URL url = new URL(capeUser.getCape());
|
||||
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
|
||||
httpURLConnection.addRequestProperty("User-Agent", "Mozilla/4.76");
|
||||
final BufferedImage imageIO = ImageIO.read(httpURLConnection.getInputStream());
|
||||
if (imageIO != null) {
|
||||
if (imageIO.getWidth() <= 2048 && imageIO.getHeight() <= 1024) {
|
||||
final DynamicTexture texture = new DynamicTexture(imageIO);
|
||||
final ResourceLocation location = Minecraft.getMinecraft().getTextureManager().getDynamicTextureLocation("seppuku/capes", texture);
|
||||
this.capesMap.put(user.getCape(), location);
|
||||
this.capesMap.put(capeUser.getCape(), location);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,42 +109,7 @@ public final class CapeManager {
|
|||
* @return
|
||||
*/
|
||||
public ResourceLocation findResource(String key) {
|
||||
for (Map.Entry<String, ResourceLocation> entry : this.capesMap.entrySet()) {
|
||||
if (entry.getKey().equals(key)) {
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//this.capeUserList.add(new CapeUser(split[0], split[1]));
|
||||
// /**
|
||||
// * Read a list of UUIDS and their cape names
|
||||
// */
|
||||
// protected void downloadCapeUsers() {
|
||||
// try {
|
||||
// URL url = new URL("https://seppuku.pw/files/capes_new.txt");
|
||||
// HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
|
||||
// httpURLConnection.addRequestProperty("User-Agent", "Mozilla/4.76");
|
||||
// final BufferedReader reader = new BufferedReader(new InputStreamReader(httpURLConnection.getInputStream()));
|
||||
//
|
||||
// String line;
|
||||
// while ((line = reader.readLine()) != null) {
|
||||
// final String[] split = line.split(";");
|
||||
// this.capeUserList.add(new CapeUser(split[0], split[1]));
|
||||
// }
|
||||
//
|
||||
// reader.close();
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
|
||||
public boolean hasCape(String uuid) {
|
||||
if (this.findCape(uuid)) {
|
||||
this.downloadCape(uuid);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return this.capesMap.entrySet().stream().filter(entry -> entry.getKey().equals(key)).findFirst().map(Map.Entry::getValue).orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -175,11 +119,14 @@ public final class CapeManager {
|
|||
* @return
|
||||
*/
|
||||
public ResourceLocation getCape(AbstractClientPlayer player) {
|
||||
ResourceLocation result = null;
|
||||
final CapeUser user = this.find(player);
|
||||
|
||||
if (user != null) {
|
||||
return this.findResource(user.getCape());
|
||||
result = this.findResource(user.getCape());
|
||||
}
|
||||
return null;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -189,15 +136,21 @@ public final class CapeManager {
|
|||
* @return
|
||||
*/
|
||||
public CapeUser find(AbstractClientPlayer player) {
|
||||
if (this.capeUserList.isEmpty())
|
||||
return null;
|
||||
|
||||
for (CapeUser user : this.capeUserList) {
|
||||
if (user.getUuid().equals(player.getUniqueID().toString().replace("-", ""))) {
|
||||
return user;
|
||||
CapeUser result = null;
|
||||
if (!this.capeUserList.isEmpty()) {
|
||||
for (CapeUser user : this.capeUserList) {
|
||||
if (user.getUuid().equals(player.getUniqueID().toString().replace("-", ""))) {
|
||||
result = user;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean hasCape() {
|
||||
return this.capeUserList.stream().anyMatch(capeUser -> capeUser.getUuid().equals(Minecraft.getMinecraft().session.getProfile().getId().toString().replace("-", "")));
|
||||
}
|
||||
|
||||
public void unload() {
|
||||
|
@ -209,15 +162,7 @@ public final class CapeManager {
|
|||
return capeUserList;
|
||||
}
|
||||
|
||||
public void setCapeUserList(List<CapeUser> capeUserList) {
|
||||
this.capeUserList = capeUserList;
|
||||
}
|
||||
|
||||
public HashMap<String, ResourceLocation> getCapesMap() {
|
||||
return capesMap;
|
||||
}
|
||||
|
||||
public void setCapesMap(HashMap<String, ResourceLocation> capesMap) {
|
||||
this.capesMap = capesMap;
|
||||
}
|
||||
}
|
|
@ -179,7 +179,7 @@ public final class ModuleManager {
|
|||
add(new FastProjectile());
|
||||
// p2w experience
|
||||
|
||||
if (Seppuku.INSTANCE.getCapeManager().hasCape(Minecraft.getMinecraft().session.getProfile().getId().toString().replace("-", "")))
|
||||
if (Seppuku.INSTANCE.getCapeManager().hasCape())
|
||||
add(new CapeModule());
|
||||
|
||||
this.loadExternalModules();
|
||||
|
|
|
@ -19,12 +19,10 @@ public final class CapeModule extends Module {
|
|||
|
||||
@Listener
|
||||
public void displayCape(EventCapeLocation event) {
|
||||
if (Minecraft.getMinecraft().player != null && event.getPlayer() == Minecraft.getMinecraft().player) {
|
||||
String uuid = Minecraft.getMinecraft().player.getUniqueID().toString().replace("-", "");
|
||||
if (Seppuku.INSTANCE.getCapeManager().hasCape(uuid)) {
|
||||
final ResourceLocation cape = Seppuku.INSTANCE.getCapeManager().getCape(event.getPlayer());
|
||||
if (cape != null) {
|
||||
event.setLocation(cape);
|
||||
if (event.getPlayer() != null) {
|
||||
if (Minecraft.getMinecraft().player != null && event.getPlayer() == Minecraft.getMinecraft().player) {
|
||||
if (Seppuku.INSTANCE.getCapeManager().getCape(event.getPlayer()) != null) {
|
||||
event.setLocation(Seppuku.INSTANCE.getCapeManager().getCape(event.getPlayer()));
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -269,6 +269,13 @@ public final class NoteBotModule extends Module {
|
|||
//GlStateManager.color(color[0] / 255.0F, color[1] / 255.0F, color[2] / 255.0F, 0.6F);
|
||||
//RenderUtil.drawBoundingBox(bb, 1.0f);
|
||||
}
|
||||
if (this.currentBlock != null) {
|
||||
final AxisAlignedBB bb = new AxisAlignedBB(
|
||||
this.currentBlock.getX() - mc.getRenderManager().viewerPosX, this.currentBlock.getY() + 1.0f - mc.getRenderManager().viewerPosY, this.currentBlock.getZ() - mc.getRenderManager().viewerPosZ,
|
||||
this.currentBlock.getX() + 1.0f - mc.getRenderManager().viewerPosX, this.currentBlock.getY() + 1.0f - mc.getRenderManager().viewerPosY, this.currentBlock.getZ() + 1.0f - mc.getRenderManager().viewerPosZ);
|
||||
GlStateManager.color(1F, 1F, 1F, 0.2F);
|
||||
RenderUtil.drawFilledBox(bb);
|
||||
}
|
||||
RenderUtil.end3D();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue