aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java10
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java33
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/overlays/CraftingOverlay.java86
3 files changed, 112 insertions, 17 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java
index 6ebcc04f..d661c290 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java
@@ -19,10 +19,7 @@ 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.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.overlays.*;
import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer;
import io.github.moulberry.notenoughupdates.util.*;
import net.minecraft.client.Minecraft;
@@ -570,6 +567,8 @@ public class NEUEventListener {
AtomicBoolean missingRecipe = new AtomicBoolean(false);
@SubscribeEvent
public void onGuiOpen(GuiOpenEvent event) {
+ CraftingOverlay.shouldRender = false;
+
if((Minecraft.getMinecraft().currentScreen instanceof GuiScreenElementWrapper ||
Minecraft.getMinecraft().currentScreen instanceof GuiItemRecipe) &&
event.gui == null && !(Keyboard.getEventKeyState() && Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) &&
@@ -1060,6 +1059,9 @@ public class NEUEventListener {
GuiChest eventGui = (GuiChest) guiScreen;
ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText();
+ if (containerName.equals("Craft Item")) {
+ CraftingOverlay.render();
+ }
}
if(GuiCustomEnchant.getInstance().shouldOverride(containerName)) {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
index 967ef903..74c8b2d3 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
@@ -4,6 +4,7 @@ import com.google.common.collect.Lists;
import com.google.gson.*;
import io.github.moulberry.notenoughupdates.auction.APIManager;
import io.github.moulberry.notenoughupdates.miscgui.GuiItemRecipe;
+import io.github.moulberry.notenoughupdates.overlays.CraftingOverlay;
import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.HypixelApi;
import io.github.moulberry.notenoughupdates.util.SBInfo;
@@ -12,6 +13,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
+import net.minecraft.inventory.ContainerChest;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.*;
@@ -35,10 +37,10 @@ import java.util.zip.ZipInputStream;
public class NEUManager {
private final NotEnoughUpdates neu;
- public final Gson gson;
+ public static Gson gson;
public final APIManager auctionManager;
- private TreeMap<String, JsonObject> itemMap = new TreeMap<>();
+ private static 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<>();
@@ -60,7 +62,7 @@ public class NEUManager {
private String currentProfileBackup = "";
public final HypixelApi hypixelApi = new HypixelApi();
- private Map<String, ItemStack> itemstackCache = new HashMap<>();
+ private static Map<String, ItemStack> itemstackCache = new HashMap<>();
private ExecutorService repoLoaderES = Executors.newSingleThreadExecutor();
@@ -797,7 +799,12 @@ public class NEUManager {
}
public void showRecipe(JsonObject item) {
- if(item.has("useneucraft") && item.get("useneucraft").getAsBoolean()) {
+ 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);
+ }
+ } else if(item.has("useneucraft") && item.get("useneucraft").getAsBoolean()) {
displayGuiItemRecipe(item.get("internalname").getAsString(), "");
} else if(item.has("clickcommand")) {
String clickcommand = item.get("clickcommand").getAsString();
@@ -1181,11 +1188,11 @@ public class NEUManager {
writeJson(json, file);
}
- public TreeMap<String, JsonObject> getItemInformation() {
+ public static TreeMap<String, JsonObject> getItemInformation() {
return itemMap;
}
- public String removeUnusedDecimal(double num) {
+ public static String removeUnusedDecimal(double num) {
if(num % 1 == 0) {
return String.valueOf((int)num);
} else {
@@ -1193,7 +1200,7 @@ public class NEUManager {
}
}
- public HashMap<String, String> getLoreReplacements(String petname, String tier, int level) {
+ public static HashMap<String, String> getLoreReplacements(String petname, String tier, int level) {
JsonObject petnums = null;
if(petname != null && tier != null) {
petnums = Constants.PETNUMS;
@@ -1257,7 +1264,7 @@ public class NEUManager {
return replacements;
}
- public HashMap<String, String> getLoreReplacements(NBTTagCompound tag, int level) {
+ public static HashMap<String, String> getLoreReplacements(NBTTagCompound tag, int level) {
String petname = null;
String tier = null;
if(tag != null && tag.hasKey("ExtraAttributes")) {
@@ -1289,7 +1296,7 @@ public class NEUManager {
return getLoreReplacements(petname, tier, level);
}
- public NBTTagList processLore(JsonArray lore, HashMap<String, String> replacements) {
+ public static NBTTagList processLore(JsonArray lore, HashMap<String, String> replacements) {
NBTTagList nbtLore = new NBTTagList();
for(JsonElement line : lore) {
String lineStr = line.getAsString();
@@ -1304,19 +1311,19 @@ public class NEUManager {
return nbtLore;
}
- public ItemStack jsonToStack(JsonObject json) {
+ public static ItemStack jsonToStack(JsonObject json) {
return jsonToStack(json, true);
}
- public ItemStack jsonToStack(JsonObject json, boolean useCache) {
+ public static ItemStack jsonToStack(JsonObject json, boolean useCache) {
return jsonToStack(json, useCache, true);
}
- public ItemStack jsonToStack(JsonObject json, boolean useCache, boolean useReplacements) {
+ public static ItemStack jsonToStack(JsonObject json, boolean useCache, boolean useReplacements) {
return jsonToStack(json, useCache, useReplacements, true);
}
- public ItemStack jsonToStack(JsonObject json, boolean useCache, boolean useReplacements, boolean copyStack) {
+ public static 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
new file mode 100644
index 00000000..50fa9848
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/CraftingOverlay.java
@@ -0,0 +1,86 @@
+package io.github.moulberry.notenoughupdates.overlays;
+
+import com.google.gson.JsonObject;
+import io.github.moulberry.notenoughupdates.NEUManager;
+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;
+
+ public static void render() {
+ if (shouldRender) {
+ ContainerChest container = (ContainerChest) Minecraft.getMinecraft().thePlayer.openContainer;
+ GuiChest gc = (GuiChest) Minecraft.getMinecraft().currentScreen;
+ FontRenderer ft = Minecraft.getMinecraft().fontRendererObj;
+ int width = Utils.peekGuiScale().getScaledWidth();
+ int height = Utils.peekGuiScale().getScaledHeight();
+ int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
+ int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
+ List<String> tooltip = null;
+ for (int i = 0; i < 9; i++) {
+ if (items[i] != null) {
+ int slotIndex = (int) (10 + 9 * Math.floor(i / 3f) + (i % 3));
+ 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()) ||
+ slot.getStack().stackSize < items[i].stackSize)
+ Gui.drawRect(x, y,
+ x + 16, y + 16, 0x64ff0000);
+ if (!slot.getHasStack())
+ Utils.drawItemStack(items[i], x, y);
+ if (mouseX >= x && mouseX < x + 16 && mouseY >= y && mouseY < y + 16)
+ tooltip = items[i].getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ }
+ }
+ if (text != null)
+ ft.drawStringWithShadow(text,
+ Utils.peekGuiScale().getScaledWidth() / 2f - ft.getStringWidth(text) / 2f,
+ gc.guiTop - 15f, 0x808080);
+ if (tooltip != null)
+ Utils.drawHoveringText(tooltip, mouseX, mouseY, width, height, -1, ft);
+ }
+ }
+
+ public static void updateItem(JsonObject item) {
+ items = new ItemStack[9];
+ String[] x = {"1", "2", "3"};
+ String[] y = {"A", "B", "C"};
+ for (int i = 0; i < 9; i++) {
+ String name = y[i / 3] + x[i % 3];
+ String itemS = item.getAsJsonObject("recipe").get(name).getAsString();
+ if (itemS != null && !itemS.equals("")) {
+ int count = 1;
+ if (itemS.split(":").length == 2) {
+ count = Integer.parseInt(itemS.split(":")[1]);
+ itemS = itemS.split(":")[0];
+ }
+ JsonObject craft = NEUManager.getItemInformation().get(itemS);
+ if (craft != null) {
+ ItemStack stack = NEUManager.jsonToStack(craft);
+ stack.stackSize = count;
+ items[i] = stack;
+ }
+ }
+ }
+ if (item.has("crafttext")) {
+ text = item.get("crafttext").getAsString();
+ }
+ shouldRender = true;
+ }
+}