diff options
Diffstat (limited to 'src/main/java/io')
3 files changed, 34 insertions, 28 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java index d661c290..610d6931 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java @@ -15,11 +15,13 @@ import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; import io.github.moulberry.notenoughupdates.cosmetics.CapeManager; import io.github.moulberry.notenoughupdates.dungeons.DungeonBlocks; import io.github.moulberry.notenoughupdates.dungeons.DungeonWin; -import io.github.moulberry.notenoughupdates.gamemodes.SBGamemodes; import io.github.moulberry.notenoughupdates.miscfeatures.*; import io.github.moulberry.notenoughupdates.miscgui.*; import io.github.moulberry.notenoughupdates.options.NEUConfig; -import io.github.moulberry.notenoughupdates.overlays.*; +import io.github.moulberry.notenoughupdates.overlays.AuctionSearchOverlay; +import io.github.moulberry.notenoughupdates.overlays.OverlayManager; +import io.github.moulberry.notenoughupdates.overlays.RancherBootOverlay; +import io.github.moulberry.notenoughupdates.overlays.TextOverlay; import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer; import io.github.moulberry.notenoughupdates.util.*; import net.minecraft.client.Minecraft; @@ -567,7 +569,7 @@ public class NEUEventListener { AtomicBoolean missingRecipe = new AtomicBoolean(false); @SubscribeEvent public void onGuiOpen(GuiOpenEvent event) { - CraftingOverlay.shouldRender = false; + neu.manager.craftingOverlay.shouldRender = false; if((Minecraft.getMinecraft().currentScreen instanceof GuiScreenElementWrapper || Minecraft.getMinecraft().currentScreen instanceof GuiItemRecipe) && @@ -1060,7 +1062,7 @@ public class NEUEventListener { ContainerChest cc = (ContainerChest) eventGui.inventorySlots; containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText(); if (containerName.equals("Craft Item")) { - CraftingOverlay.render(); + neu.manager.craftingOverlay.render(); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java index 74c8b2d3..aff030d8 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java @@ -37,10 +37,10 @@ import java.util.zip.ZipInputStream; public class NEUManager { private final NotEnoughUpdates neu; - public static Gson gson; + public final Gson gson; public final APIManager auctionManager; - private static TreeMap<String, JsonObject> itemMap = new TreeMap<>(); + private TreeMap<String, JsonObject> itemMap = new TreeMap<>(); private TreeMap<String, HashMap<String, List<Integer>>> titleWordMap = new TreeMap<>(); private TreeMap<String, HashMap<String, List<Integer>>> loreWordMap = new TreeMap<>(); @@ -62,7 +62,7 @@ public class NEUManager { private String currentProfileBackup = ""; public final HypixelApi hypixelApi = new HypixelApi(); - private static Map<String, ItemStack> itemstackCache = new HashMap<>(); + private Map<String, ItemStack> itemstackCache = new HashMap<>(); private ExecutorService repoLoaderES = Executors.newSingleThreadExecutor(); @@ -76,6 +76,8 @@ public class NEUManager { public File repoLocation; public File configFile; + public CraftingOverlay craftingOverlay = new CraftingOverlay(this); + public NEUManager(NotEnoughUpdates neu, File configLocation) { this.neu = neu; this.configLocation = configLocation; @@ -802,7 +804,7 @@ public class NEUManager { if (item.has("recipe") && Minecraft.getMinecraft().thePlayer.openContainer instanceof ContainerChest) { ContainerChest container = (ContainerChest) Minecraft.getMinecraft().thePlayer.openContainer; if (container.getLowerChestInventory().getDisplayName().getUnformattedText().equals("Craft Item")) { - CraftingOverlay.updateItem(item); + craftingOverlay.updateItem(item); } } else if(item.has("useneucraft") && item.get("useneucraft").getAsBoolean()) { displayGuiItemRecipe(item.get("internalname").getAsString(), ""); @@ -1188,11 +1190,11 @@ public class NEUManager { writeJson(json, file); } - public static TreeMap<String, JsonObject> getItemInformation() { + public TreeMap<String, JsonObject> getItemInformation() { return itemMap; } - public static String removeUnusedDecimal(double num) { + public String removeUnusedDecimal(double num) { if(num % 1 == 0) { return String.valueOf((int)num); } else { @@ -1200,7 +1202,7 @@ public class NEUManager { } } - public static HashMap<String, String> getLoreReplacements(String petname, String tier, int level) { + public HashMap<String, String> getLoreReplacements(String petname, String tier, int level) { JsonObject petnums = null; if(petname != null && tier != null) { petnums = Constants.PETNUMS; @@ -1264,7 +1266,7 @@ public class NEUManager { return replacements; } - public static HashMap<String, String> getLoreReplacements(NBTTagCompound tag, int level) { + public HashMap<String, String> getLoreReplacements(NBTTagCompound tag, int level) { String petname = null; String tier = null; if(tag != null && tag.hasKey("ExtraAttributes")) { @@ -1296,7 +1298,7 @@ public class NEUManager { return getLoreReplacements(petname, tier, level); } - public static NBTTagList processLore(JsonArray lore, HashMap<String, String> replacements) { + public NBTTagList processLore(JsonArray lore, HashMap<String, String> replacements) { NBTTagList nbtLore = new NBTTagList(); for(JsonElement line : lore) { String lineStr = line.getAsString(); @@ -1311,19 +1313,19 @@ public class NEUManager { return nbtLore; } - public static ItemStack jsonToStack(JsonObject json) { + public ItemStack jsonToStack(JsonObject json) { return jsonToStack(json, true); } - public static ItemStack jsonToStack(JsonObject json, boolean useCache) { + public ItemStack jsonToStack(JsonObject json, boolean useCache) { return jsonToStack(json, useCache, true); } - public static ItemStack jsonToStack(JsonObject json, boolean useCache, boolean useReplacements) { + public ItemStack jsonToStack(JsonObject json, boolean useCache, boolean useReplacements) { return jsonToStack(json, useCache, useReplacements, true); } - public static ItemStack jsonToStack(JsonObject json, boolean useCache, boolean useReplacements, boolean copyStack) { + public ItemStack jsonToStack(JsonObject json, boolean useCache, boolean useReplacements, boolean copyStack) { if(json == null) return new ItemStack(Items.painting, 1, 10); String internalname = json.get("internalname").getAsString(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/CraftingOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/CraftingOverlay.java index 50fa9848..ecc88ccc 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/CraftingOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/CraftingOverlay.java @@ -6,23 +6,25 @@ import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.gui.inventory.GuiChest; -import net.minecraft.client.renderer.GlStateManager; import net.minecraft.inventory.ContainerChest; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import org.luaj.vm2.ast.Str; import org.lwjgl.input.Mouse; import java.util.List; public class CraftingOverlay { - private static ItemStack[] items = new ItemStack[9]; - public static boolean shouldRender = false; - private static String text = null; + private ItemStack[] items = new ItemStack[9]; + private final NEUManager manager; + public boolean shouldRender = false; + private String text = null; - public static void render() { + public CraftingOverlay(NEUManager manager) { + this.manager = manager; + } + + public void render() { if (shouldRender) { ContainerChest container = (ContainerChest) Minecraft.getMinecraft().thePlayer.openContainer; GuiChest gc = (GuiChest) Minecraft.getMinecraft().currentScreen; @@ -38,7 +40,7 @@ public class CraftingOverlay { Slot slot = container.inventorySlots.get(slotIndex); int x = slot.xDisplayPosition + gc.guiLeft; int y = slot.yDisplayPosition + gc.guiTop; - if (!slot.getHasStack() || !slot.getStack().getDisplayName().equals(items[i].getDisplayName()) || + if (!slot.getHasStack() || !manager.getInternalNameForItem(items[i]).equals(manager.getInternalNameForItem(slot.getStack())) || slot.getStack().stackSize < items[i].stackSize) Gui.drawRect(x, y, x + 16, y + 16, 0x64ff0000); @@ -57,7 +59,7 @@ public class CraftingOverlay { } } - public static void updateItem(JsonObject item) { + public void updateItem(JsonObject item) { items = new ItemStack[9]; String[] x = {"1", "2", "3"}; String[] y = {"A", "B", "C"}; @@ -70,9 +72,9 @@ public class CraftingOverlay { count = Integer.parseInt(itemS.split(":")[1]); itemS = itemS.split(":")[0]; } - JsonObject craft = NEUManager.getItemInformation().get(itemS); + JsonObject craft = manager.getItemInformation().get(itemS); if (craft != null) { - ItemStack stack = NEUManager.jsonToStack(craft); + ItemStack stack = manager.jsonToStack(craft); stack.stackSize = count; items[i] = stack; } |