diff options
| author | BuildTools <james.jenour@protonmail.com> | 2021-01-18 23:59:09 +0800 |
|---|---|---|
| committer | BuildTools <james.jenour@protonmail.com> | 2021-01-18 23:59:09 +0800 |
| commit | 3255cfce951367c9303297205f64577ef1eac650 (patch) | |
| tree | f43ceb889dc96aed62b378bdc4f5fe3fd3fd95ac /src | |
| parent | c9cc530adfb39085fe4b0f9a60e0ca6e4bbb8eb9 (diff) | |
| download | NotEnoughUpdates-3255cfce951367c9303297205f64577ef1eac650.tar.gz NotEnoughUpdates-3255cfce951367c9303297205f64577ef1eac650.tar.bz2 NotEnoughUpdates-3255cfce951367c9303297205f64577ef1eac650.zip | |
gravy
Diffstat (limited to 'src')
40 files changed, 1165 insertions, 132 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java b/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java index 8d71992e..cafbff05 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java @@ -2,6 +2,9 @@ package io.github.moulberry.notenoughupdates; import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.auction.APIManager; +import io.github.moulberry.notenoughupdates.util.Constants; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import org.lwjgl.input.Keyboard; @@ -11,7 +14,7 @@ import java.util.Locale; public class ItemPriceInformation { - public static boolean addToTooltip(List<String> tooltip, String internalname) { + public static boolean addToTooltip(List<String> tooltip, String internalname, ItemStack stack) { JsonObject auctionInfo = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfo(internalname); JsonObject bazaarInfo = NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarInfo(internalname); float lowestBinAvg = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAvgBin(internalname); @@ -106,6 +109,44 @@ public class ItemPriceInformation { EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(lowestBinAvg)+" coins"); } break; + case 6: + if(Constants.ESSENCECOSTS == null) break; + JsonObject essenceCosts = Constants.ESSENCECOSTS; + if(!essenceCosts.has(internalname)) { + break; + } + JsonObject itemCosts = essenceCosts.get(internalname).getAsJsonObject(); + String essenceType = itemCosts.get("type").getAsString(); + + int dungeonItemLevel = -1; + if(stack != null && stack.hasTagCompound() && + stack.getTagCompound().hasKey("ExtraAttributes", 10)) { + NBTTagCompound ea = stack.getTagCompound().getCompoundTag("ExtraAttributes"); + + if (ea.hasKey("dungeon_item_level", 99)) { + dungeonItemLevel = ea.getInteger("dungeon_item_level"); + } + } + if(dungeonItemLevel == -1) { + int dungeonizeCost = 0; + if(itemCosts.has("dungeonize")) { + dungeonizeCost = itemCosts.get("dungeonize").getAsInt(); + } + tooltip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Dungeonize Cost: " + + EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+dungeonizeCost+" "+essenceType); + } else if(dungeonItemLevel >= 0 && dungeonItemLevel <= 4) { + String costType = (dungeonItemLevel+1)+""; + + int upgradeCost = itemCosts.get(costType).getAsInt(); + StringBuilder star = new StringBuilder(); + for(int i=0; i<=dungeonItemLevel; i++) { + star.append('\u272A'); + } + tooltip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Upgrade to "+ + EnumChatFormatting.GOLD+star+EnumChatFormatting.YELLOW+EnumChatFormatting.BOLD+": " + + EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+upgradeCost+" "+essenceType); + } + break; } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java index 1111a580..e0a487b6 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java @@ -10,6 +10,7 @@ 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.BetterContainers; +import io.github.moulberry.notenoughupdates.miscfeatures.FairySouls; import io.github.moulberry.notenoughupdates.miscfeatures.StreamerMode; import io.github.moulberry.notenoughupdates.miscgui.*; import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer; @@ -134,6 +135,8 @@ public class NEUEventListener { private long notificationDisplayMillis = 0; private List<String> notificationLines = null; + private static Pattern BAD_ITEM_REGEX = Pattern.compile("x[0-9]{1,2}$"); + /** * 1)Will send the cached message from #sendChatMessage when at least 200ms has passed since the last message. * This is used in order to prevent the mod spamming messages. @@ -160,6 +163,37 @@ public class NEUEventListener { } DungeonWin.tick(); if(longUpdate) { + FairySouls.tick(); + if(TradeWindow.hypixelTradeWindowActive()) { + for(int i=0; i<16; i++) { + int x = i % 4; + int y = i / 4; + int containerIndex = y*9+x+5; + + GuiContainer chest = ((GuiContainer)Minecraft.getMinecraft().currentScreen); + + ItemStack stack = chest.inventorySlots.getInventory().get(containerIndex); + if(stack != null && BAD_ITEM_REGEX.matcher(Utils.cleanColour(stack.getDisplayName())).find()) { + Minecraft.getMinecraft().ingameGUI.displayTitle( + null, null, + 4, 200, 4); + Minecraft.getMinecraft().ingameGUI.displayTitle( + null, + EnumChatFormatting.RED+"WARNING: GLITCHED ITEM DETECTED IN TRADE WINDOW. CANCELLING TRADE", + -1, -1, -1); + Minecraft.getMinecraft().ingameGUI.displayTitle( + EnumChatFormatting.RED+"YOU ARE TRADING WITH A SCAMMER!", + null, + -1, -1, -1); + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED+ + "WARNING: The person you are trading with just tried to give you a glitched item.\n" + + "The item is NOT worth what they say it is worth.\n" + + "Report this scammer immediately and ignore them!")); + break; + } + } + } + NotEnoughUpdates.INSTANCE.overlay.redrawItems(); CapeManager.onTickSlow(); @@ -636,10 +670,16 @@ public class NEUEventListener { } if(focusInv) { try { - neu.overlay.render(hoverInv && focusInv); + neu.overlay.render(hoverInv); } catch(ConcurrentModificationException e) {e.printStackTrace();} GL11.glTranslatef(0, 0, 10); } + if(hoverInv) { + renderDungeonChestOverlay(event.gui); + if(neu.config.accessoryBag.enableOverlay) { + AccessoryBagOverlay.renderOverlay(); + } + } } } @@ -708,7 +748,7 @@ public class NEUEventListener { } } - if(shouldRenderOverlay(event.gui) && neu.isOnSkyblock()) { + if(shouldRenderOverlay(event.gui) && neu.isOnSkyblock() && !hoverInv) { renderDungeonChestOverlay(event.gui); if(neu.config.accessoryBag.enableOverlay) { AccessoryBagOverlay.renderOverlay(); @@ -943,6 +983,8 @@ public class NEUEventListener { ScheduledExecutorService ses = Executors.newScheduledThreadPool(1); + JsonObject essenceJson = new JsonObject(); + /** * Sends a kbd event to NEUOverlay, cancelling if NEUOverlay#keyboardInput returns true. * Also includes a dev function used for creating custom named json files with recipes. @@ -976,6 +1018,62 @@ public class NEUEventListener { } } if(neu.config.hidden.dev && neu.config.hidden.enableItemEditing && Minecraft.getMinecraft().theWorld != null && + Keyboard.getEventKey() == Keyboard.KEY_N && Keyboard.getEventKeyState()) { + GuiScreen gui = Minecraft.getMinecraft().currentScreen; + if(gui instanceof GuiChest) { + GuiChest eventGui = (GuiChest) event.gui; + ContainerChest cc = (ContainerChest) eventGui.inventorySlots; + IInventory lower = cc.getLowerChestInventory(); + + if(!lower.getDisplayName().getUnformattedText().endsWith("Essence")) return; + + for(int i=0; i<lower.getSizeInventory(); i++) { + ItemStack stack = lower.getStackInSlot(i); + + String internalname = neu.manager.getInternalNameForItem(stack); + if(internalname != null) { + String[] lore = neu.manager.getLoreFromNBT(stack.getTagCompound()); + + for(String line : lore) { + if(line.contains(":") && (line.startsWith("\u00A77Upgrade to") || + line.startsWith("\u00A77Convert to Dungeon Item"))) { + String[] split = line.split(":"); + String after = Utils.cleanColour(split[1]); + StringBuilder costS = new StringBuilder(); + for(char c : after.toCharArray()) { + if(c >= '0' && c <= '9') { + costS.append(c); + } + } + int cost = Integer.parseInt(costS.toString()); + String[] afterSplit = after.split(" "); + String type = afterSplit[afterSplit.length-2]; + + if(!essenceJson.has(internalname)) { + essenceJson.add(internalname, new JsonObject()); + } + JsonObject obj = essenceJson.get(internalname).getAsJsonObject(); + obj.addProperty("type", type); + + if(line.startsWith("\u00A77Convert to Dungeon Item")) { + obj.addProperty("dungeonize", cost); + } else if(line.startsWith("\u00A77Upgrade to")) { + int stars = 0; + for(char c : line.toCharArray()) { + if(c == '\u272A') stars++; + } + if(stars > 0) { + obj.addProperty(stars+"", cost); + } + } + } + } + } + } + System.out.println(essenceJson); + } + } + if(neu.config.hidden.dev && neu.config.hidden.enableItemEditing && Minecraft.getMinecraft().theWorld != null && Keyboard.getEventKey() == Keyboard.KEY_O && Keyboard.getEventKeyState()) { GuiScreen gui = Minecraft.getMinecraft().currentScreen; if(gui instanceof GuiChest) { @@ -1284,7 +1382,7 @@ public class NEUEventListener { newTooltip.add(""); newTooltip.add(EnumChatFormatting.GRAY+"[SHIFT for Price Info]"); } else { - ItemPriceInformation.addToTooltip(newTooltip, internalname); + ItemPriceInformation.addToTooltip(newTooltip, internalname, event.itemStack); } } } @@ -1443,7 +1541,7 @@ public class NEUEventListener { event.toolTip.addAll(newTooltip); if(neu.config.tooltipTweaks.showPriceInfoInvItem) { - ItemPriceInformation.addToTooltip(event.toolTip, internalname); + ItemPriceInformation.addToTooltip(event.toolTip, internalname, event.itemStack); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java index edaa8335..12a95484 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java @@ -264,6 +264,7 @@ public class NEUOverlay extends Gui { @Override public void mouseClick(float x, float y, int mouseX, int mouseY) { if(Mouse.getEventButtonState()) { + Minecraft.getMinecraft().thePlayer.closeScreen(); Minecraft.getMinecraft().displayGuiScreen(new GuiScreenElementWrapper(new NEUConfigEditor(NotEnoughUpdates.INSTANCE.config))); } } @@ -1930,11 +1931,12 @@ public class NEUOverlay extends Gui { //Render tooltip JsonObject json = tooltipToDisplay.get(); if(json != null) { - List<String> text = manager.jsonToStack(json).getTooltip(Minecraft.getMinecraft().thePlayer, false); + ItemStack stack = manager.jsonToStack(json); + List<String> text = stack.getTooltip(Minecraft.getMinecraft().thePlayer, false); String internalname = json.get("internalname").getAsString(); if(!NotEnoughUpdates.INSTANCE.config.tooltipTweaks.showPriceInfoInvItem) { - ItemPriceInformation.addToTooltip(text, internalname); + ItemPriceInformation.addToTooltip(text, internalname, stack); } boolean hasClick = false; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index d5e6b927..6b787964 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -17,9 +17,7 @@ import io.github.moulberry.notenoughupdates.dungeons.GuiDungeonMapEditor; import io.github.moulberry.notenoughupdates.gamemodes.GuiGamemodes; import io.github.moulberry.notenoughupdates.gamemodes.SBGamemodes; import io.github.moulberry.notenoughupdates.infopanes.CollectionLogInfoPane; -import io.github.moulberry.notenoughupdates.miscfeatures.CustomItemEffects; -import io.github.moulberry.notenoughupdates.miscfeatures.EnchantingSolvers; -import io.github.moulberry.notenoughupdates.miscfeatures.SunTzu; +import io.github.moulberry.notenoughupdates.miscfeatures.*; import io.github.moulberry.notenoughupdates.miscgui.CalendarOverlay; import io.github.moulberry.notenoughupdates.miscgui.GuiEnchantColour; import io.github.moulberry.notenoughupdates.miscgui.HelpGUI; @@ -160,7 +158,7 @@ public class NotEnoughUpdates { ChatStyle style = new ChatStyle(); style.setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(EnumChatFormatting.GRAY+"Click to copy to clipboard"))); - style.setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "neurename copyuuid")); + style.setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/neurename copyuuid")); ChatComponentText text = new ChatComponentText(EnumChatFormatting.YELLOW+"[NEU] The UUID of your currently held item is: " + EnumChatFormatting.GREEN + heldUUID); @@ -865,6 +863,7 @@ public class NotEnoughUpdates { }); private Gson gson = new GsonBuilder().setPrettyPrinting().excludeFieldsWithoutExposeAnnotation().create(); + private File neuDir; /** * Instantiates NEUIo, NEUManager and NEUOverlay instances. Registers keybinds and adds a shutdown hook to clear tmp folder. @@ -874,10 +873,10 @@ public class NotEnoughUpdates { public void preinit(FMLPreInitializationEvent event) { INSTANCE = this; - File f = new File(event.getModConfigurationDirectory(), "notenoughupdates"); - f.mkdirs(); + neuDir = new File(event.getModConfigurationDirectory(), "notenoughupdates"); + neuDir.mkdirs(); - configFile = new File(f, "configNew.json"); + configFile = new File(neuDir, "configNew.json"); if(configFile.exists()) { try(BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(configFile), StandardCharsets.UTF_8))) { @@ -885,6 +884,8 @@ public class NotEnoughUpdates { } catch(Exception e) { } } + FairySouls.load(new File(neuDir, "collected_fairy_souls.json"), gson); + if(config == null) { config = new NEUConfig(); saveConfig(); @@ -900,6 +901,8 @@ public class NotEnoughUpdates { MinecraftForge.EVENT_BUS.register(CustomItemEffects.INSTANCE); MinecraftForge.EVENT_BUS.register(new DungeonMap()); MinecraftForge.EVENT_BUS.register(new SunTzu()); + MinecraftForge.EVENT_BUS.register(new MiningStuff()); + MinecraftForge.EVENT_BUS.register(new FairySouls()); ClientCommandHandler.instance.registerCommand(collectionLogCommand); ClientCommandHandler.instance.registerCommand(cosmeticsCommand); @@ -924,10 +927,11 @@ public class NotEnoughUpdates { ClientCommandHandler.instance.registerCommand(settingsCommand3); ClientCommandHandler.instance.registerCommand(dungeonWinTest); ClientCommandHandler.instance.registerCommand(calendarCommand); + ClientCommandHandler.instance.registerCommand(new FairySouls.FairySoulsCommand()); BackgroundBlur.registerListener(); - manager = new NEUManager(this, f); + manager = new NEUManager(this, neuDir); manager.loadItemInformation(); overlay = new NEUOverlay(manager); profileViewer = new ProfileViewer(manager); @@ -937,14 +941,13 @@ public class NotEnoughUpdates { } Runtime.getRuntime().addShutdownHook(new Thread(() -> { - File tmp = new File(f, "tmp"); + File tmp = new File(neuDir, "tmp"); if(tmp.exists()) { for(File tmpFile : tmp.listFiles()) { tmpFile.delete(); } tmp.delete(); } - saveConfig(); })); } @@ -956,6 +959,8 @@ public class NotEnoughUpdates { try(BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(configFile), StandardCharsets.UTF_8))) { writer.write(gson.toJson(config)); } + + FairySouls.save(new File(neuDir, "collected_fairy_souls.json"), gson); } catch(IOException ignored) {} } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java b/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java index aad69686..70cb436b 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java @@ -348,7 +348,7 @@ public class CustomAH extends Gui { tooltip.add(""); tooltip.add(EnumChatFormatting.GRAY+"[SHIFT for Price Info]"); } else { - ItemPriceInformation.addToTooltip(tooltip, internalname); + ItemPriceInformation.addToTooltip(tooltip, internalname, auc.getStack()); } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementBoolean.java b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementBoolean.java index 97fc3dcc..85f88a9f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementBoolean.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementBoolean.java @@ -36,6 +36,9 @@ public class GuiElementBoolean extends GuiElement { this.previewValue = value; this.clickRadius = clickRadius; this.toggleCallback = toggleCallback; + this.lastMillis = System.currentTimeMillis(); + + if(value) animation = 36; } @Override diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditor.java index 5b9509a3..7ca8ddf2 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditor.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditor.java @@ -54,8 +54,9 @@ public abstract class GuiOptionEditor { public abstract boolean mouseInput(int x, int y, int width, int mouseX, int mouseY); public abstract boolean keyboardInput(); - public boolean mouseInputGlobal(int x, int y, int width, int mouseX, int mouseY) { + public boolean mouseInputOverlay(int x, int y, int width, |
