aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/rosegoldaddons/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/rosegoldaddons/utils')
-rw-r--r--src/main/java/rosegoldaddons/utils/DiscordWebhook.java391
-rw-r--r--src/main/java/rosegoldaddons/utils/OpenSkyblockGui.java231
-rw-r--r--src/main/java/rosegoldaddons/utils/OutlineUtils.java152
-rw-r--r--src/main/java/rosegoldaddons/utils/PlayerUtils.java36
-rw-r--r--src/main/java/rosegoldaddons/utils/RenderUtils.java91
-rw-r--r--src/main/java/rosegoldaddons/utils/RotationUtils.java6
-rw-r--r--src/main/java/rosegoldaddons/utils/ScoreboardUtils.java63
7 files changed, 645 insertions, 325 deletions
diff --git a/src/main/java/rosegoldaddons/utils/DiscordWebhook.java b/src/main/java/rosegoldaddons/utils/DiscordWebhook.java
new file mode 100644
index 0000000..404df87
--- /dev/null
+++ b/src/main/java/rosegoldaddons/utils/DiscordWebhook.java
@@ -0,0 +1,391 @@
+package rosegoldaddons.utils;
+
+import javax.net.ssl.HttpsURLConnection;
+import java.awt.Color;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.lang.reflect.Array;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+//CREDIT: https://gist.github.com/k3kdude/fba6f6b37594eae3d6f9475330733bdb
+
+/**
+ * Class used to execute Discord Webhooks with low effort
+ */
+public class DiscordWebhook {
+ private final String url;
+ private String content;
+ private String username;
+ private String avatarUrl;
+ private boolean tts;
+ private List<EmbedObject> embeds = new ArrayList<>();
+
+ /**
+ * Constructs a new DiscordWebhook instance
+ *
+ * @param url The webhook URL obtained in Discord
+ */
+ public DiscordWebhook(String url) {
+ this.url = url;
+ }
+
+ public void setContent(String content) {
+ this.content = content;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public void setAvatarUrl(String avatarUrl) {
+ this.avatarUrl = avatarUrl;
+ }
+
+ public void setTts(boolean tts) {
+ this.tts = tts;
+ }
+
+ public void addEmbed(EmbedObject embed) {
+ this.embeds.add(embed);
+ }
+
+ public void execute() throws IOException {
+ if (this.content == null && this.embeds.isEmpty()) {
+ throw new IllegalArgumentException("Set content or add at least one EmbedObject");
+ }
+
+ JSONObject json = new JSONObject();
+
+ json.put("content", this.content);
+ json.put("username", this.username);
+ json.put("avatar_url", this.avatarUrl);
+ json.put("tts", this.tts);
+
+ if (!this.embeds.isEmpty()) {
+ List<JSONObject> embedObjects = new ArrayList<>();
+
+ for (EmbedObject embed : this.embeds) {
+ JSONObject jsonEmbed = new JSONObject();
+
+ jsonEmbed.put("title", embed.getTitle());
+ jsonEmbed.put("description", embed.getDescription());
+ jsonEmbed.put("url", embed.getUrl());
+
+ if (embed.getColor() != null) {
+ Color color = embed.getColor();
+ int rgb = color.getRed();
+ rgb = (rgb << 8) + color.getGreen();
+ rgb = (rgb << 8) + color.getBlue();
+
+ jsonEmbed.put("color", rgb);
+ }
+
+ EmbedObject.Footer footer = embed.getFooter();
+ EmbedObject.Image image = embed.getImage();
+ EmbedObject.Thumbnail thumbnail = embed.getThumbnail();
+ EmbedObject.Author author = embed.getAuthor();
+ List<EmbedObject.Field> fields = embed.getFields();
+
+ if (footer != null) {
+ JSONObject jsonFooter = new JSONObject();
+
+ jsonFooter.put("text", footer.getText());
+ jsonFooter.put("icon_url", footer.getIconUrl());
+ jsonEmbed.put("footer", jsonFooter);
+ }
+
+ if (image != null) {
+ JSONObject jsonImage = new JSONObject();
+
+ jsonImage.put("url", image.getUrl());
+ jsonEmbed.put("image", jsonImage);
+ }
+
+ if (thumbnail != null) {
+ JSONObject jsonThumbnail = new JSONObject();
+
+ jsonThumbnail.put("url", thumbnail.getUrl());
+ jsonEmbed.put("thumbnail", jsonThumbnail);
+ }
+
+ if (author != null) {
+ JSONObject jsonAuthor = new JSONObject();
+
+ jsonAuthor.put("name", author.getName());
+ jsonAuthor.put("url", author.getUrl());
+ jsonAuthor.put("icon_url", author.getIconUrl());
+ jsonEmbed.put("author", jsonAuthor);
+ }
+
+ List<JSONObject> jsonFields = new ArrayList<>();
+ for (EmbedObject.Field field : fields) {
+ JSONObject jsonField = new JSONObject();
+
+ jsonField.put("name", field.getName());
+ jsonField.put("value", field.getValue());
+ jsonField.put("inline", field.isInline());
+
+ jsonFields.add(jsonField);
+ }
+
+ jsonEmbed.put("fields", jsonFields.toArray());
+ embedObjects.add(jsonEmbed);
+ }
+
+ json.put("embeds", embedObjects.toArray());
+ }
+
+ URL url = new URL(this.url);
+ HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
+ connection.addRequestProperty("Content-Type", "application/json");
+ connection.addRequestProperty("User-Agent", "Java-DiscordWebhook-BY-Gelox_");
+ connection.setDoOutput(true);
+ connection.setRequestMethod("POST");
+
+ OutputStream stream = connection.getOutputStream();
+ stream.write(json.toString().getBytes());
+ stream.flush();
+ stream.close();
+
+ connection.getInputStream().close(); //I'm not sure why but it doesn't work without getting the InputStream
+ connection.disconnect();
+ }
+
+ public static class EmbedObject {
+ private String title;
+ private String description;
+ private String url;
+ private Color color;
+
+ private Footer footer;
+ private Thumbnail thumbnail;
+ private Image image;
+ private Author author;
+ private List<Field> fields = new ArrayList<>();
+
+ public String getTitle() {
+ return title;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public Color getColor() {
+ return color;
+ }
+
+ public Footer getFooter() {
+ return footer;
+ }
+
+ public Thumbnail getThumbnail() {
+ return thumbnail;
+ }
+
+ public Image getImage() {
+ return image;
+ }
+
+ public Author getAuthor() {
+ return author;
+ }
+
+ public List<Field> getFields() {
+ return fields;
+ }
+
+ public EmbedObject setTitle(String title) {
+ this.title = title;
+ return this;
+ }
+
+ public EmbedObject setDescription(String description) {
+ this.description = description;
+ return this;
+ }
+
+ public EmbedObject setUrl(String url) {
+ this.url = url;
+ return this;
+ }
+
+ public EmbedObject setColor(Color color) {
+ this.color = color;
+ return this;
+ }
+
+ public EmbedObject setFooter(String text, String icon) {
+ this.footer = new Footer(text, icon);
+ return this;
+ }
+
+ public EmbedObject setThumbnail(String url) {
+ this.thumbnail = new Thumbnail(url);
+ return this;
+ }
+
+ public EmbedObject setImage(String url) {
+ this.image = new Image(url);
+ return this;
+ }
+
+ public EmbedObject setAuthor(String name, String url, String icon) {
+ this.author = new Author(name, url, icon);
+ return this;
+ }
+
+ public EmbedObject addField(String name, String value, boolean inline) {
+ this.fields.add(new Field(name, value, inline));
+ return this;
+ }
+
+ private class Footer {
+ private String text;
+ private String iconUrl;
+
+ private Footer(String text, String iconUrl) {
+ this.text = text;
+ this.iconUrl = iconUrl;
+ }
+
+ private String getText() {
+ return text;
+ }
+
+ private String getIconUrl() {
+ return iconUrl;
+ }
+ }
+
+ private class Thumbnail {
+ private String url;
+
+ private Thumbnail(String url) {
+ this.url = url;
+ }
+
+ private String getUrl() {
+ return url;
+ }
+ }
+
+ private class Image {
+ private String url;
+
+ private Image(String url) {
+ this.url = url;
+ }
+
+ private String getUrl() {
+ return url;
+ }
+ }
+
+ private class Author {
+ private String name;
+ private String url;
+ private String iconUrl;
+
+ private Author(String name, String url, String iconUrl) {
+ this.name = name;
+ this.url = url;
+ this.iconUrl = iconUrl;
+ }
+
+ private String getName() {
+ return name;
+ }
+
+ private String getUrl() {
+ return url;
+ }
+
+ private String getIconUrl() {
+ return iconUrl;
+ }
+ }
+
+ private class Field {
+ private String name;
+ private String value;
+ private boolean inline;
+
+ private Field(String name, String value, boolean inline) {
+ this.name = name;
+ this.value = value;
+ this.inline = inline;
+ }
+
+ private String getName() {
+ return name;
+ }
+
+ private String getValue() {
+ return value;
+ }
+
+ private boolean isInline() {
+ return inline;
+ }
+ }
+ }
+
+ private class JSONObject {
+
+ private final HashMap<String, Object> map = new HashMap<>();
+
+ void put(String key, Object value) {
+ if (value != null) {
+ map.put(key, value);
+ }
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ Set<Map.Entry<String, Object>> entrySet = map.entrySet();
+ builder.append("{");
+
+ int i = 0;
+ for (Map.Entry<String, Object> entry : entrySet) {
+ Object val = entry.getValue();
+ builder.append(quote(entry.getKey())).append(":");
+
+ if (val instanceof String) {
+ builder.append(quote(String.valueOf(val)));
+ } else if (val instanceof Integer) {
+ builder.append(Integer.valueOf(String.valueOf(val)));
+ } else if (val instanceof Boolean) {
+ builder.append(val);
+ } else if (val instanceof JSONObject) {
+ builder.append(val.toString());
+ } else if (val.getClass().isArray()) {
+ builder.append("[");
+ int len = Array.getLength(val);
+ for (int j = 0; j < len; j++) {
+ builder.append(Array.get(val, j).toString()).append(j != len - 1 ? "," : "");
+ }
+ builder.append("]");
+ }
+
+ builder.append(++i == entrySet.size() ? "}" : ",");
+ }
+
+ return builder.toString();
+ }
+
+ private String quote(String string) {
+ return "\"" + string + "\"";
+ }
+ }
+}
diff --git a/src/main/java/rosegoldaddons/utils/OpenSkyblockGui.java b/src/main/java/rosegoldaddons/utils/OpenSkyblockGui.java
index 51ba356..b0760a0 100644
--- a/src/main/java/rosegoldaddons/utils/OpenSkyblockGui.java
+++ b/src/main/java/rosegoldaddons/utils/OpenSkyblockGui.java
@@ -2,198 +2,97 @@ package rosegoldaddons.utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiChest;
+import net.minecraft.init.Items;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ContainerChest;
import net.minecraft.inventory.Slot;
-import net.minecraft.util.ChatComponentText;
-import net.minecraft.util.StringUtils;
import net.minecraftforge.client.event.GuiScreenEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
-import rosegoldaddons.commands.Backpack;
-import rosegoldaddons.commands.LobbySwap;
+import rosegoldaddons.commands.Rosedrobe;
import rosegoldaddons.commands.Rosepet;
+import scala.Int;
+import tv.twitch.chat.Chat;
import java.util.List;
-import java.util.Locale;
public class OpenSkyblockGui {
- int windowId;
- int windowId2;
- int windowClicks = 0;
- boolean openingWardrobe = false;
- boolean lobbySwapping = false;
- boolean openingBP = false;
- boolean openingPets = false;
+ private static boolean openTrades = false;
@SubscribeEvent
public void guiDraw(GuiScreenEvent.BackgroundDrawnEvent event) {
- if (!rosegoldaddons.commands.Rosedrobe.openWardrobe || openingWardrobe) return;
- new Thread(() -> {
- try {
- openingWardrobe = true;
- if (event.gui instanceof GuiChest) {
- Container container = ((GuiChest) event.gui).inventorySlots;
- if (container instanceof ContainerChest) {
- String chestName = ((ContainerChest) container).getLowerChestInventory().getDisplayName().getUnformattedText();
- List<Slot> invSlots = container.inventorySlots;
- if (chestName.contains("Pets")) {
- int i;
- for (i = 0; i < invSlots.size(); i++) {
- if (!invSlots.get(i).getHasStack()) continue;
- String slotName = StringUtils.stripControlCodes(invSlots.get(i).getStack().getDisplayName());
- //Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(slotName));
- if (slotName.equals("Go Back")) {
- clickSlot(invSlots.get(i));
- }
- }
- } else if (chestName.contains("SkyBlock")) {
- int i;
- for (i = 0; i < invSlots.size(); i++) {
- if (!invSlots.get(i).getHasStack()) continue;
- if (StringUtils.stripControlCodes(invSlots.get(i).getStack().getDisplayName()).equals("Wardrobe")) {
- clickSlot(invSlots.get(i));
- if (rosegoldaddons.commands.Rosedrobe.slot == 0)
- rosegoldaddons.commands.Rosedrobe.openWardrobe = false;
- }
- }
- } else if (chestName.contains("Wardrobe")) {
- if (rosegoldaddons.commands.Rosedrobe.slot != 0) {
- int i;
- for (i = 0; i < invSlots.size(); i++) {
- if (!invSlots.get(i).getHasStack()) continue;
- String slotName = "Slot " + rosegoldaddons.commands.Rosedrobe.slot + ":";
- if (StringUtils.stripControlCodes(invSlots.get(i).getStack().getDisplayName()).contains(slotName)) {
- clickSlot(invSlots.get(i));
- Minecraft.getMinecraft().thePlayer.closeScreen();
- rosegoldaddons.commands.Rosedrobe.openWardrobe = false;
- }
- }
- }
+ if(!Rosedrobe.openWardrobe && !openTrades && !Rosepet.openPetS) return;
+ ChatUtils.sendMessage("OpenSkyblockGui");
+ if (event.gui instanceof GuiChest) {
+ Container container = ((GuiChest) event.gui).inventorySlots;
+ if (container instanceof ContainerChest) {
+ String chestName = ((ContainerChest) container).getLowerChestInventory().getDisplayName().getUnformattedText();
+ if (Rosedrobe.openWardrobe) {
+ if (chestName.contains("Pets")) {
+ clickSlot(48, 0, 0);
+ clickSlot(32, 0, 1);
+ if (Rosedrobe.slot > 0) {
+ clickSlot(Rosedrobe.slot + 35, 0, 2);
+ Minecraft.getMinecraft().thePlayer.closeScreen();
}
+ Rosedrobe.openWardrobe = false;
}
- }
- openingWardrobe = false;
- } catch (Exception e) {
- e.printStackTrace();
- }
- }).start();
- }
-
- @SubscribeEvent
- public void guiDraw2(GuiScreenEvent.BackgroundDrawnEvent event) {
- if (!LobbySwap.swapLobby || lobbySwapping) return;
- new Thread(() -> {
- try {
- lobbySwapping = true;
- if (event.gui instanceof GuiChest) {
- Container container = ((GuiChest) event.gui).inventorySlots;
- if (container instanceof ContainerChest) {
- String chestName = ((ContainerChest) container).getLowerChestInventory().getDisplayName().getUnformattedText();
- List<Slot> invSlots = container.inventorySlots;
- if (chestName.contains("SkyBlock")) {
- int i;
- for (i = 0; i < invSlots.size(); i++) {
- if (!invSlots.get(i).getHasStack()) continue;
- if (StringUtils.stripControlCodes(invSlots.get(i).getStack().getDisplayName()).equals("Enter the Crystal Hollows")) {
- clickSlot(invSlots.get(i));
- }
- }
- } else if (chestName.contains("Enter the")) {
- int i;
- for (i = 0; i < invSlots.size(); i++) {
- if (!invSlots.get(i).getHasStack()) continue;
- if (StringUtils.stripControlCodes(invSlots.get(i).getStack().getDisplayName()).equals("Confirm")) {
- clickSlot(invSlots.get(i));
- LobbySwap.swapLobby = false;
- }
- }
- Thread.sleep(2000);
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(Minecraft.getMinecraft().theWorld.getWorldTime() + " ticks"));
- }
+ } else if (openTrades) {
+ if (chestName.contains("Pets")) {
+ clickSlot(48, 0, 0);
+ clickSlot(22, 0, 1);
+ openTrades = false;
}
- }
- lobbySwapping = false;
- } catch (Exception e) {
- e.printStackTrace();
- }
- }).start();
- }
-
- @SubscribeEvent
- public void guiDraw3(GuiScreenEvent.BackgroundDrawnEvent event) {
- if (!Backpack.openBP || openingBP) return;
- new Thread(() -> {
- try {
- openingBP = true;
- if (event.gui instanceof GuiChest) {
- Container container = ((GuiChest) event.gui).inventorySlots;
- if (container instanceof ContainerChest) {
- String chestName = ((ContainerChest) container).getLowerChestInventory().getDisplayName().getUnformattedText();
- List<Slot> invSlots = container.inventorySlots;
- if (chestName.contains("Storage")) {
- if (Backpack.bpSlot != 0) {
- int i;
- for (i = 0; i < invSlots.size(); i++) {
- if (!invSlots.get(i).getHasStack()) continue;
- String slotName = "Slot " + Backpack.bpSlot;
- if (StringUtils.stripControlCodes(invSlots.get(i).getStack().getDisplayName()).contains(slotName)) {
- clickSlot(invSlots.get(i));
- Backpack.openBP = false;
- }
- }
- }
+ } else if (Rosepet.openPetS) {
+ if (chestName.contains("Pets")) {
+ int currPage = 1;
+ int lastPage = 1;
+ if(chestName.startsWith("(")) {
+ currPage = Integer.parseInt(chestName.substring(chestName.indexOf("(")+1, chestName.indexOf("/")));
+ lastPage = Integer.parseInt(chestName.substring(chestName.indexOf("/")+1, chestName.indexOf(")")));
}
- }
- }
- openingBP = false;
- } catch (Exception e) {
- e.printStackTrace();
- }
- }).start();
- }
-
- @SubscribeEvent
- public void guiDraw4(GuiScreenEvent.BackgroundDrawnEvent event) {
- if (!Rosepet.openPetS || openingPets) return;
- new Thread(() -> {
- try {
- openingPets = true;
- if (event.gui instanceof GuiChest) {
- Container container = ((GuiChest) event.gui).inventorySlots;
- if (container instanceof ContainerChest) {
- String chestName = ((ContainerChest) container).getLowerChestInventory().getDisplayName().getUnformattedText();
- List<Slot> invSlots = container.inventorySlots;
- if (chestName.contains("Pets")) {
- if (!Rosepet.name.equals("")) {
- int i;
- for (i = 0; i < invSlots.size(); i++) {
- if (!invSlots.get(i).getHasStack()) continue;
-
- if (StringUtils.stripControlCodes(invSlots.get(i).getStack().getDisplayName()).toLowerCase().contains(Rosepet.name.toLowerCase())) {
- clickSlot(invSlots.get(i));
- Rosepet.openPetS = false;
- }
+ String petName = Rosepet.name;
+ int petSlot = Rosepet.petSlot;
+ if(petSlot != 0) {
+ clickSlot(petSlot - 1, 0, 0);
+ Rosepet.petSlot = 0;
+ Rosepet.openPetS = false;
+ return;
+ }
+ if (!petName.equals("")) {
+ List<Slot> chestInventory = ((GuiChest) Minecraft.getMinecraft().currentScreen).inventorySlots.inventorySlots;
+ for (Slot slot : chestInventory) {
+ if (!slot.getHasStack()) continue;
+ if (slot.getStack().getDisplayName().contains(petName)) {
+ clickSlot(slot.slotNumber, 0, 0);
+ Minecraft.getMinecraft().thePlayer.closeScreen();
+ Rosepet.openPetS = false;
+ return;
}
}
+ if (currPage < lastPage) {
+ clickSlot(53, 0, 0);
+ } else {
+ Rosepet.openPetS = false;
+ Minecraft.getMinecraft().thePlayer.closeScreen();
+ ChatUtils.sendMessage("No pet named "+petName+" found.");
+ }
+ } else {
+ ChatUtils.sendMessage("Invalid Pet Name");
+ Rosepet.openPetS = false;
}
+
}
}
- openingPets = false;
- } catch (Exception e) {
- e.printStackTrace();
}
- }).start();
+ }
}
- private void clickSlot(Slot slot) {
- windowId = Minecraft.getMinecraft().thePlayer.openContainer.windowId;
- Minecraft.getMinecraft().playerController.windowClick(windowId, slot.slotNumber, 2, 0, Minecraft.getMinecraft().thePlayer);
+ public static void openTradesMenu() {
+ openTrades = true;
+ Minecraft.getMinecraft().thePlayer.sendChatMessage("/pets");
}
- private void clickSlot2(Slot slot) {
- if(windowClicks == 0)
- windowId2 = Minecraft.getMinecraft().thePlayer.openContainer.windowId;
- Minecraft.getMinecraft().playerController.windowClick(windowId + windowClicks, slot.slotNumber, 2, 0, Minecraft.getMinecraft().thePlayer);
- windowClicks++;
+ private void clickSlot(int slot, int type, int windowAdd) {
+ Minecraft.getMinecraft().playerController.windowClick(Minecraft.getMinecraft().thePlayer.openContainer.windowId + windowAdd, slot, type, 0, Minecraft.getMinecraft().thePlayer);
}
}
diff --git a/src/main/java/rosegoldaddons/utils/OutlineUtils.java b/src/main/java/rosegoldaddons/utils/OutlineUtils.java
deleted file mode 100644
index 0b1bde2..0000000
--- a/src/main/java/rosegoldaddons/utils/OutlineUtils.java
+++ /dev/null
@@ -1,152 +0,0 @@
-package rosegoldaddons.utils;
-
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.model.ModelBase;
-import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.client.renderer.OpenGlHelper;
-import net.minecraft.client.shader.Framebuffer;
-import net.minecraft.entity.EntityLivingBase;
-import org.lwjgl.opengl.EXTFramebufferObject;
-import org.lwjgl.opengl.EXTPackedDepthStencil;
-import rosegoldaddons.events.RenderLivingEntityEvent;
-
-import java.awt.*;
-
-import static org.lwjgl.opengl.GL11.*;
-
-public class OutlineUtils {
-
- public static void outlineESP(EntityLivingBase entity, float p_77036_2_, float p_77036_3_, float p_77036_4_, float p_77036_5_, float p_77036_6_, float scaleFactor, ModelBase modelBase, Color color) {
- Minecraft mc = Minecraft.getMinecraft();
- boolean fancyGraphics = mc.gameSettings.fancyGraphics;
- float gamma = mc.gameSettings.gammaSetting;
- mc.gameSettings.fancyGraphics = false;
- mc.gameSettings.gammaSetting = 100000F;
-
- GlStateManager.resetColor();
- setColor(color);
- renderOne(2);
- modelBase.render(entity, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, scaleFactor);
- setColor(color);
- renderTwo();
- modelBase.render(entity, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, scaleFactor);
- setColor(color);
- renderThree();
- modelBase.render(entity, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, scaleFactor);
- setColor(color);
- renderFour(color);
- modelBase.render(entity, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, scaleFactor);
- setColor(color);
- renderFive();
- setColor(Color.WHITE);
-
- mc.gameSettings.fancyGraphics = fancyGraphics;
- mc.gameSettings.gammaSetting = gamma;
- }
-
- public static void outlineESP(RenderLivingEntityEvent event, Color color) {
- Minecraft mc = Minecraft.getMinecraft();
- boolean fancyGraphics = mc.gameSettings.fancyGraphics;
- float gamma = mc.gameSettings.gammaSetting;
- mc.gameSettings.fancyGraphics = false;
- mc.gameSettings.gammaSetting = 100000F;
-
- GlStateManager.resetColor();
- setColor(color);
- renderOne(2);
- event.modelBase.render(event.entity, event.p_77036_2_, event.p_77036_3_, event.p_77036_4_, event.p_77036_5_, event.p_77036_6_, event.scaleFactor);
- setColor(color);
- renderTwo();
- event.modelBase.render(event.entity, event.p_77036_2_, event.p_77036_3_, event.p_77036_4_, event.p_77036_5_, event.p_77036_6_, event.scaleFactor);
- setColor(color);
- renderThree();
- event.modelBase.render(event.entity, event.p_77036_2_, event.p_77036_3_, event.p_77036_4_, event.p_77036_5_, event.p_77036_6_, event.scaleFactor);
- setColor(color);
- renderFour(color);
- event.modelBase.render(event.entity, event.p_77036_2_, event.p_77036_3_, event.p_77036_4_, event.p_77036_5_, event.p_77036_6_, event.scaleFactor);
- setColor(color);
- renderFive();
- setColor(Color.WHITE);
-
- mc.gameSettings.fancyGraphics = fancyGraphics;
- mc.gameSettings.gammaSetting = gamma;
- }
-
- public static void renderOne(final float lineWidth) {
- checkSetupFBO();
- glPushAttrib(GL_ALL_ATTRIB_BITS);
- glDisable(GL_ALPHA_TEST);
- glDisable(GL_TEXTURE_2D);
- glDisable(GL_LIGHTING);
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glLineWidth(lineWidth);
- glEnable(GL_LINE_SMOOTH);
- glEnable(GL_STENCIL_TEST);
- glClear(GL_STENCIL_BUFFER_BIT);
- glClearStencil(0xF);
- glStencilFunc(GL_NEVER, 1, 0xF);
- glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
- glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
- }
-
- public static void renderTwo() {
- glStencilFunc(GL_NEVER, 0, 0xF);
- glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
- glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
- }
-
- public static void renderThree() {
- glStencilFunc(GL_EQUAL, 1, 0xF);
- glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
- glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
- }
-
- public static void renderFour(final Color color) {
- setColor(color);
- glDepthMask(false);
- glDisable(GL_DEPTH_TEST);
- glEnable(GL_POLYGON_OFFSET_LINE);
- glPolygonOffset(1.0F, -2000000F);
- OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0F, 240.0F);
- }
-
- public static void renderFive() {
- glPolygonOffset(1.0F, 2000000F);
- glDisable(GL_POLYGON_OFFSET_LINE);
- glEnable(GL_DEPTH_TEST);
- glDepthMask(true);
- glDisable(GL_STENCIL_TEST);
- glDisable(GL_LINE_SMOOTH);
- glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE);
- glEnable(GL_BLEND);
- glEnable(GL_LIGHTING);
- glEnable(GL_TEXTURE_2D);
- glEnable(GL_ALPHA_TEST);
- glPopAttrib();
- }
-
- public static void setColor(final Color color) {
- glColor4d(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, color.getAlpha() / 255F);
- }
-
- public static void checkSetupFBO() {
- final Framebuffer fbo = Minecraft.getMinecraft().getFramebuffer();
- if (fbo != null) {
- if (fbo.depthBuffer > -1) {
- setupFBO(fbo);
- fbo.depthBuffer = -1;
- }
- }
- }
-
- private static void setupFBO(final Framebuffer fbo) {
- EXTFramebufferObject.glDeleteRenderbuffersEXT(fbo.depthBuffer);
- final int stencil_depth_buffer_ID = EXTFramebufferObject.glGenRenderbuffersEXT();
- EXTFramebufferObject.glBindRenderbufferEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, stencil_depth_buffer_ID);
- EXTFramebufferObject.glRenderbufferStorageEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, EXTPackedDepthStencil.GL_DEPTH_STENCIL_EXT, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight);
- EXTFramebufferObject.glFramebufferRenderbufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_STENCIL_ATTACHMENT_EXT, EXTFramebufferObject.GL_RENDERBUFFER_EXT, stencil_depth_buffer_ID);
- EXTFramebufferObject.glFramebufferRenderbufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_DEPTH_ATTACHMENT_EXT, EXTFramebufferObject.GL_RENDERBUFFER_EXT, stencil_depth_buffer_ID);
- }
-
-}
diff --git a/src/main/java/rosegoldaddons/utils/PlayerUtils.java b/src/main/java/rosegoldaddons/utils/PlayerUtils.java
new file mode 100644
index 0000000..b41d047
--- /dev/null
+++ b/src/main/java/rosegoldaddons/utils/PlayerUtils.java
@@ -0,0 +1,36 @@
+package rosegoldaddons.utils;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.util.MovingObjectPosition;
+import net.minecraft.util.StringUtils;
+import net.minecraftforge.client.event.ClientChatReceivedEvent;
+import net.minecraftforge.event.world.WorldEvent;
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+import rosegoldaddons.Main;
+
+public class PlayerUtils {
+ public static boolean pickaxeAbilityReady = false;
+
+ public static void swingItem() {
+ MovingObjectPosition movingObjectPosition = Minecraft.getMinecraft().objectMouseOver;
+ if (movingObjectPosition != null && movingObjectPosition.entityHit == null) {
+ Minecraft.getMinecraft().thePlayer.swingItem();
+ }
+ }
+
+ @SubscribeEvent
+ public void onWorldChange(WorldEvent.Load event) {
+ pickaxeAbilityReady = false;
+ }
+
+ @SubscribeEvent
+ public void chat(ClientChatReceivedEvent event) {
+ String message = StringUtils.stripControlCodes(event.message.getUnformattedText());
+ if (message.contains(":")) return;
+ if(message.contains("You used your")) {
+ pickaxeAbilityReady = false;
+ } else if(message.contains("is now available!")) {
+ pickaxeAbilityReady = true;
+ }
+ }
+}
diff --git a/src/main/java/rosegoldaddons/utils/RenderUtils.java b/src/main/java/rosegoldaddons/utils/RenderUtils.java
index cfd7d1d..37c6e98 100644
--- a/src/main/java/rosegoldaddons/utils/RenderUtils.java
+++ b/src/main/java/rosegoldaddons/utils/RenderUtils.java
@@ -2,6 +2,7 @@ package rosegoldaddons.utils;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
@@ -13,6 +14,7 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
+import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL14;
@@ -102,10 +104,10 @@ public class RenderUtils {
glDepthMask(false);
glColor(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha() != 255 ? color.getAlpha() : outline ? 26 : 35);
- drawFilledBox(axisAlignedBB);
+ //drawFilledBox(axisAlignedBB);
if (outline) {
- glLineWidth(1F);
+ glLineWidth(3F);
enableGlCap(GL_LINE_SMOOTH);
glColor(color);
@@ -176,14 +178,14 @@ public class RenderUtils {
);
if (outline) {
- glLineWidth(1F);
+ glLineWidth(3F);
enableGlCap(GL_LINE_SMOOTH);
glColor(color.getRed(), color.getGreen(), color.getBlue(), 95);
drawSelectionBoundingBox(axisAlignedBB);
}
glColor(color.getRed(), color.getGreen(), color.getBlue(), outline ? 26 : 35);
- drawFilledBox(axisAlignedBB);
+ //drawFilledBox(axisAlignedBB);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glDepthMask(true);
resetCaps();
@@ -627,6 +629,87 @@ public class RenderUtils {
}
/**
+ * Modified from NotEnoughUpdates under Creative Commons Attribution-NonCommercial 3.0
+ * https://github.com/Moulberry/NotEnoughUpdates/blob/master/LICENSE
+ */
+ public static void renderWaypointText(String str, double X, double Y, double Z, float partialTicks) {
+ GlStateManager.alphaFunc(516, 0.1F);
+
+ GlStateManager.pushMatrix();
+
+ Entity viewer = Minecraft.getMinecraft().getRenderViewEntity();
+ double viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * partialTicks;
+ double viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * partialTicks;
+ double viewerZ = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * partialTicks;
+
+ double x = X - viewerX;
+ double y = Y - viewerY - viewer.getEyeHeight();
+ double z = Z - viewerZ;
+
+ double distSq = x * x + y * y + z * z;
+ double dist = Math.sqrt(distSq);
+ if(distSq > 144) {
+ x *= 12 / dist;
+ y *= 12 / dist;
+ z *= 12 / dist;
+ }
+ GlStateManager.translate(x, y, z);
+ GlStateManager.translate(0, viewer.getEyeHeight(), 0);
+
+ drawNametag(str);
+
+ GlStateManager.rotate(-Minecraft.getMinecraft().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F);
+ GlStateManager.rotate(Minecraft.getMinecraft().getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F);
+ GlStateManager.translate(0, -0.25f, 0);
+ GlStateManager.rotate(-Minecraft.getMinecraft().getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F);
+ GlStateManager.rotate(Minecraft.getMinecraft().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F);
+
+ drawNametag(EnumChatFormatting.YELLOW.toString() + Math.round(dist) + " blocks");
+
+ GlStateManager.popMatrix();
+
+ GlStateManager.disableLighting();
+ }
+
+ public static void drawNametag(String str) {
+ FontRenderer fontrenderer = Minecraft.getMinecraft().fontRendererObj;
+ float f = 1.6F;
+ float f1 = 0.016666668F * f;
+ GlStateManager.pushMatrix();
+ GL11.glNormal3f(0.0F, 1.0F, 0.0F);
+ GlStateManager.rotate(-Minecraft.getMinecraft().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F);
+ GlStateManager.rotate(Minecraft.getMinecraft().getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F);
+ GlStateManager.scale(-f1, -f1, f1);
+ GlStateManager.disableLighting();
+ GlStateManager.depthMask(false);
+ GlStateManager.disableDepth();
+ GlStateManager.enableBlend();
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+ int i = 0;
+
+ int j = fontrenderer.getStringWidth(str) / 2;
+ GlStateManager.disableTexture2D();
+ worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
+ worldrenderer.pos(-j - 1, -1 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
+ worldrenderer.pos(-j - 1, 8 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
+ worldrenderer.pos(j + 1, 8 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
+ worldrenderer.pos(j + 1, -1 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
+ tessellator.draw();
+ GlStateManager.enableTexture2D();
+ fontrenderer.drawString(str, -fontrenderer.getStringWidth(str) / 2, i, 553648127);
+ GlStateManager.depthMask(true);
+
+ fontrenderer.drawString(str, -fontrenderer.getStringWidth(str) / 2, i, -1);
+
+ GlStateManager.enableDepth();
+ GlStateManager.enableBlend();
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ GlStateManager.popMatrix();
+ }
+
+ /**
* GL CAP MANAGER
* <p>
* TODO: Remove gl cap manager and replace by something better
diff --git a/src/main/java/rosegoldaddons/utils/RotationUtils.java b/src/main/java/rosegoldaddons/utils/RotationUtils.java
index bb899e5..fdb17ab 100644
--- a/src/main/java/rosegoldaddons/utils/RotationUtils.java
+++ b/src/main/java/rosegoldaddons/utils/RotationUtils.java
@@ -55,11 +55,11 @@ public class RotationUtils {
try {
snek = true;
KeyBinding.setKeyBindState(Minecraft.getMinecraft().gameSettings.keyBindSneak.getKeyCode(), true);
- Thread.sleep(100);
+ Thread.sleep(50);
KeyBinding.setKeyBindState(Minecraft.getMinecraft().gameSettings.keyBindSneak.getKeyCode(), false);
- Thread.sleep(100);
+ Thread.sleep(50);
KeyBinding.setKeyBindState(Minecraft.getMinecraft().gameSettings.keyBindSneak.getKeyCode(), true);
- Thread.sleep(100);
+ Thread.sleep(50);
KeyBinding.setKeyBindState(Minecraft.getMinecraft().gameSettings.keyBindSneak.getKeyCode(), false);
snek = false;
} catch (Exception e) {
diff --git a/src/main/java/rosegoldaddons/utils/ScoreboardUtils.java b/src/main/java/rosegoldaddons/utils/ScoreboardUtils.java
new file mode 100644
index 0000000..3dd677a
--- /dev/null
+++ b/src/main/java/rosegoldaddons/utils/ScoreboardUtils.java
@@ -0,0 +1,63 @@
+package rosegoldaddons.utils;
+
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import net.minecraft.client.Minecraft;
+import net.minecraft.scoreboard.Score;
+import net.minecraft.scoreboard.ScoreObjective;
+import net.minecraft.scoreboard.ScorePlayerTeam;
+import net.minecraft.scoreboard.Scoreboard;
+import net.minecraft.util.StringUtils;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/*
+* Stolen from Danker's Skyblock Mod: https://github.com/bowser0000/SkyblockMod
+ */
+
+public class ScoreboardUtils {
+ public static String cleanSB(String scoreboard) {
+ char[] nvString = StringUtils.stripControlCodes(scoreboard).toCharArray();
+ StringBuilder cleaned = new StringBuilder();
+
+ for (char c : nvString) {
+ if ((int) c > 20 && (int) c < 127) {
+ cleaned.append(c);
+ }
+ }
+
+ return cleaned.toString();
+ }
+
+ public static List<String> getSidebarLines() {
+ List<String> lines = new ArrayList<>();
+ if (Minecraft.getMinecraft().theWorld == null) return lines;
+ Scoreboard scoreboard = Minecraft.getMinecraft().theWorld.getScoreboard();
+ if (scoreboard == null) return lines;
+
+ ScoreObjective objective = scoreboard.getObjectiveInDisplaySlot(1);
+ if (objective == null) return lines;
+
+ Collection<Score> scores = scoreboard.getSortedScores(objective);
+ List<Score> list = scores.stream()
+ .filter(input -> input != null && input.getPlayerName() != null && !input.getPlayerName()
+ .startsWith("#"))
+ .collect(Collectors.toList());
+
+ if (list.size() > 15) {
+ scores = Lists.newArrayList(Iterables.skip(list, scores.size() - 15));
+ } else {
+ scores = list;
+ }
+
+ for (Score score : scores) {
+ ScorePlayerTeam team = scoreboard.getPlayersTeam(score.getPlayerName());
+ lines.add(ScorePlayerTeam.formatPlayerName(team, score.getPlayerName()));
+ }
+
+ return lines;
+ }
+}