diff options
Diffstat (limited to 'src/main/java/io')
165 files changed, 3676 insertions, 6422 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java index 5c3083a3..5eab77f9 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java @@ -37,7 +37,6 @@ import io.github.moulberry.notenoughupdates.recipes.NeuRecipe; import io.github.moulberry.notenoughupdates.recipes.RecipeHistory; import io.github.moulberry.notenoughupdates.util.ApiUtil; import io.github.moulberry.notenoughupdates.util.Constants; -import io.github.moulberry.notenoughupdates.util.HotmInformation; import io.github.moulberry.notenoughupdates.util.ItemResolutionQuery; import io.github.moulberry.notenoughupdates.util.ItemUtils; import io.github.moulberry.notenoughupdates.util.SBInfo; @@ -103,7 +102,7 @@ public class NEUManager { private final TreeMap<String, JsonObject> itemMap = new TreeMap<>(); private boolean hasBeenLoadedBefore = false; - private final TreeMap<String, HashMap<String, List<Integer>>> titleWordMap = new TreeMap<>(); + public final TreeMap<String, HashMap<String, List<Integer>>> titleWordMap = new TreeMap<>(); private final TreeMap<String, HashMap<String, List<Integer>>> loreWordMap = new TreeMap<>(); public final KeyBinding keybindGive = @@ -144,7 +143,6 @@ public class NEUManager { public File configLocation; public File repoLocation; public File configFile; - public HotmInformation hotm; public KatSitterOverlay katSitterOverlay; @@ -154,7 +152,6 @@ public class NEUManager { this.neu = neu; this.configLocation = configLocation; this.auctionManager = new APIManager(this); - this.hotm = new HotmInformation(neu); this.craftingOverlay = new CraftingOverlay(this); this.katSitterOverlay = new KatSitterOverlay(); @@ -323,7 +320,7 @@ public class NEUManager { synchronized (titleWordMap) { int wordIndex = 0; for (String str : json.get("displayname").getAsString().split(" ")) { - str = clean(str); + str = cleanForTitleMapSearch(str); if (!titleWordMap.containsKey(str)) { titleWordMap.put(str, new HashMap<>()); } @@ -341,7 +338,7 @@ public class NEUManager { int wordIndex = 0; for (JsonElement element : json.get("lore").getAsJsonArray()) { for (String str : element.getAsString().split(" ")) { - str = clean(str); + str = cleanForTitleMapSearch(str); if (!loreWordMap.containsKey(str)) { loreWordMap.put(str, new HashMap<>()); } @@ -469,8 +466,8 @@ public class NEUManager { int lastStringMatch = -1; ArrayList<DebugMatch> debugMatches = new ArrayList<>(); - toSearch = clean(toSearch).toLowerCase(); - query = clean(query).toLowerCase(); + toSearch = cleanForTitleMapSearch(toSearch).toLowerCase(); + query = cleanForTitleMapSearch(query).toLowerCase(); String[] splitToSearch = toSearch.split(" "); String[] queryArray = query.split(" "); @@ -687,7 +684,7 @@ public class NEUManager { public Set<String> search(String query, TreeMap<String, HashMap<String, List<Integer>>> wordMap) { HashMap<String, List<Integer>> matches = null; - query = clean(query).toLowerCase(); + query = cleanForTitleMapSearch(query).toLowerCase(); for (String queryWord : query.split(" ")) { HashMap<String, List<Integer>> matchesToKeep = new HashMap<>(); for (HashMap<String, List<Integer>> wordMatches : subMapWithKeysThatAreSuffixes(queryWord, wordMap).values()) { @@ -862,7 +859,7 @@ public class NEUManager { return item; } - private String clean(String str) { + public static String cleanForTitleMapSearch(String str) { return str.replaceAll("(\u00a7.)|[^0-9a-zA-Z ]", "").toLowerCase().trim(); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java index 7159ef89..ce7b21b2 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java @@ -1500,7 +1500,14 @@ public class NEUOverlay extends Gui { int actualIndex = index + getSlotsXSize() * getSlotsYSize() * page; List<JsonObject> searchedItems = getSearchedItems(); if (0 <= actualIndex && actualIndex < searchedItems.size()) { - return searchedItems.get(actualIndex); + try { + return searchedItems.get(actualIndex); + } catch (IndexOutOfBoundsException e) { + System.out.println("searchedItems size: " + searchedItems.size()); + System.out.println("actualIndex: " + actualIndex); + e.printStackTrace(); + return null; + } } else { return null; } @@ -1658,7 +1665,7 @@ public class NEUOverlay extends Gui { buttonXSize, ySize, 1 - leftPressed, leftPressed, 1 - leftPressed, leftPressed ); GlStateManager.bindTexture(0); - Utils.drawStringCenteredScaled(EnumChatFormatting.BOLD + "Prev", fr, + Utils.drawStringCenteredScaled(EnumChatFormatting.BOLD + "Prev", leftSide - 1 + buttonXSize * 300 / 480f + leftPressed, top + ySize / 2f + leftPressed, false, (int) (buttonXSize * 240 / 480f), Color.BLACK.getRGB() @@ -1677,7 +1684,7 @@ public class NEUOverlay extends Gui { buttonXSize, ySize, 1 - rightPressed, rightPressed, 1 - rightPressed, rightPressed ); GlStateManager.bindTexture(0); - Utils.drawStringCenteredScaled(EnumChatFormatting.BOLD + "Next", fr, + Utils.drawStringCenteredScaled(EnumChatFormatting.BOLD + "Next", rightSide + 1 - buttonXSize * 300 / 480f + rightPressed, top + ySize / 2f + rightPressed, false, (int) (buttonXSize * 240 / 480f), Color.BLACK.getRGB() @@ -1692,7 +1699,7 @@ public class NEUOverlay extends Gui { new Color(50, 50, 50).getRGB() ); drawRect(leftSide + buttonXSize + 3, top + 1, rightSide - buttonXSize - 3, top + ySize - 1, fg.getRGB()); - Utils.drawStringCenteredScaledMaxWidth(pageText, fr, (leftSide + rightSide) / 2, + Utils.drawStringCenteredScaledMaxWidth(pageText, (leftSide + rightSide) / 2, top + ySize / 2f, false, strMaxLen, Color.BLACK.getRGB() ); } @@ -1838,8 +1845,6 @@ public class NEUOverlay extends Gui { } GlStateManager.enableDepth(); - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - Utils.resetGuiScale(); Utils.pushGuiScale(NotEnoughUpdates.INSTANCE.config.itemlist.paneGuiScale); @@ -2231,7 +2236,7 @@ public class NEUOverlay extends Gui { textToDisplay = text; } if (textToDisplay != null) { - Utils.drawHoveringText(textToDisplay, mouseX, mouseY, width, height, -1, fr); + Utils.drawHoveringText(textToDisplay, mouseX, mouseY, width, height, -1); textToDisplay = null; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index 25d1002a..8b6c2255 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -25,7 +25,6 @@ import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.autosubscribe.AutoLoad; import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe; -import io.github.moulberry.notenoughupdates.commands.Commands; import io.github.moulberry.notenoughupdates.core.BackgroundBlur; import io.github.moulberry.notenoughupdates.cosmetics.ShaderManager; import io.github.moulberry.notenoughupdates.listener.ChatListener; @@ -44,6 +43,8 @@ import io.github.moulberry.notenoughupdates.miscfeatures.PetInfoOverlay; import io.github.moulberry.notenoughupdates.miscfeatures.SlotLocking; import io.github.moulberry.notenoughupdates.miscfeatures.StorageManager; import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.CustomBlockSounds; +import io.github.moulberry.notenoughupdates.miscfeatures.inventory.MuseumCheapestItemOverlay; +import io.github.moulberry.notenoughupdates.miscfeatures.inventory.MuseumItemHighlighter; import io.github.moulberry.notenoughupdates.miscfeatures.updater.AutoUpdater; import io.github.moulberry.notenoughupdates.mixins.AccessorMinecraft; import io.github.moulberry.notenoughupdates.oneconfig.IOneConfigCompat; @@ -52,6 +53,7 @@ import io.github.moulberry.notenoughupdates.overlays.OverlayManager; import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer; import io.github.moulberry.notenoughupdates.recipes.RecipeGenerator; import io.github.moulberry.notenoughupdates.util.Utils; +import io.github.moulberry.notenoughupdates.util.brigadier.BrigadierRoot; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiScreen; @@ -158,7 +160,6 @@ public class NotEnoughUpdates { public Navigation navigation = new Navigation(this); public GuiScreen openGui = null; public long lastOpenedGui = 0; - public Commands commands; public boolean packDevEnabled = false; public Color[][] colourMap = null; public AutoUpdater autoUpdater = new AutoUpdater(this); @@ -169,6 +170,13 @@ public class NotEnoughUpdates { private File neuDir; private boolean hasSkyblockScoreboard; + public NotEnoughUpdates() { + // Budget Construction Event + ((AccessorMinecraft) FMLClientHandler.instance().getClient()) + .onGetDefaultResourcePacks() + .add(new NEURepoResourcePack(null, "neurepo")); + } + public File getConfigFile() { return this.configFile; } @@ -181,13 +189,6 @@ public class NotEnoughUpdates { return this.neuDir; } - public NotEnoughUpdates() { - // Budget Construction Event - ((AccessorMinecraft) FMLClientHandler.instance().getClient()) - .onGetDefaultResourcePacks() - .add(new NEURepoResourcePack(null, "neurepo")); - } - /** * Instantiates NEUIo, NEUManager and NEUOverlay instances. Registers keybinds and adds a shutdown hook to clear tmp folder. */ @@ -271,6 +272,8 @@ public class NotEnoughUpdates { MinecraftForge.EVENT_BUS.register(navigation); MinecraftForge.EVENT_BUS.register(new WorldListener(this)); AutoLoad.INSTANCE.provide(supplier -> MinecraftForge.EVENT_BUS.register(supplier.get())); + MinecraftForge.EVENT_BUS.register(MuseumItemHighlighter.INSTANCE); + MinecraftForge.EVENT_BUS.register(MuseumCheapestItemOverlay.INSTANCE); if (Minecraft.getMinecraft().getResourceManager() instanceof IReloadableResourceManager) { IReloadableResourceManager manager = (IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager(); @@ -281,7 +284,7 @@ public class NotEnoughUpdates { manager.registerReloadListener(new CustomBlockSounds.ReloaderListener()); } - this.commands = new Commands(); + BrigadierRoot.INSTANCE.updateHooks(); BackgroundBlur.registerListener(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java index 5ec3724a..ac60ffd9 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java @@ -292,7 +292,7 @@ public class APIManager { .newMoulberryRequest("lowestbin.json.gz") .gunzip() .requestJson() - .thenAccept(jsonObject -> { + .thenAcceptAsync(jsonObject -> { if (lowestBins == null) { lowestBins = new JsonObject(); } @@ -465,12 +465,12 @@ public class APIManager { }; manager.apiUtils.newMoulberryRequest("auctionLast.json.gz") - .gunzip().requestJson().thenAccept(process); + .gunzip().requestJson().thenAcceptAsync(process); manager.apiUtils .newMoulberryRequest("auction.json.gz") .gunzip().requestJson() - .thenAccept(jsonObject -> { + .thenAcceptAsync(jsonObject -> { if (jsonObject.get("success").getAsBoolean()) { long apiUpdate = (long) jsonObject.get("time").getAsFloat(); if (lastApiUpdate == apiUpdate) { @@ -683,7 +683,7 @@ public class APIManager { manager.apiUtils .newAnonymousHypixelApiRequest("skyblock/auctions") .requestJson() - .thenAccept(jsonObject -> { + .thenAcceptAsync(jsonObject -> { if (jsonObject == null) return; if (jsonObject.get("success").getAsBoolean()) { @@ -733,7 +733,7 @@ public class APIManager { manager.apiUtils .newAnonymousHypixelApiRequest("skyblock/bazaar") .requestJson() - .thenAccept(jsonObject -> { + .thenAcceptAsync(jsonObject -> { if (!jsonObject.get("success").getAsBoolean()) return; craftCost.clear(); @@ -789,7 +789,7 @@ public class APIManager { public void updateAvgPrices() { manager.apiUtils .newMoulberryRequest("auction_averages/3day.json.gz") - .gunzip().requestJson().thenAccept((jsonObject) -> { + .gunzip().requestJson().thenAcceptAsync((jsonObject) -> { craftCost.clear(); auctionPricesJson = jsonObject; lastAuctionAvgUpdate = System.currentTimeMillis(); @@ -797,7 +797,7 @@ public class APIManager { manager.apiUtils .newMoulberryRequest("auction_averages_lbin/1day.json.gz") .gunzip().requestJson() - .thenAccept((jsonObject) -> { + .thenAcceptAsync((jsonObject) -> { auctionPricesAvgLowestBinJson = jsonObject; }); } 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 07ec4a59..e1ccdef7 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java @@ -580,6 +580,7 @@ public class CustomAH extends Gui { } List<String> tooltipToRender = null; + int black = Color.BLACK.getRGB(); if (Minecraft.getMinecraft().currentScreen instanceof GuiChest) { resetCurrAucIdTimer = System.currentTimeMillis(); GuiChest auctionView = (GuiChest) Minecraft.getMinecraft().currentScreen; @@ -620,9 +621,7 @@ public class CustomAH extends Gui { endsInStr = EnumChatFormatting.DARK_PURPLE + prettyTime( auctionViewEndsIn + lastGuiScreenSwitch - System.currentTimeMillis()); } - Utils.drawStringCenteredScaledMaxWidth(endsInStr, Minecraft.getMinecraft().fontRendererObj, - auctionViewLeft + 39, guiTop + 20, false, 70, 4210752 - ); + Utils.drawStringCenteredScaledMaxWidth(endsInStr, auctionViewLeft + 39, guiTop + 20, false, 70, 4210752); } Utils.drawItemStack(leftStack, auctionViewLeft + 31, guiTop + 100); @@ -790,9 +789,7 @@ public class CustomAH extends Gui { } } - Utils.drawStringCenteredScaledMaxWidth(containerName, Minecraft.getMinecraft().fontRendererObj, - auctionViewLeft + 39, guiTop + 10, false, 70, 4210752 - ); + Utils.drawStringCenteredScaledMaxWidth(containerName, auctionViewLeft + 39, guiTop + 10, false, 70, 4210752); } else if (isEditingPrice()) { hasPopup = true; resetCurrAucIdTimer = System.currentTimeMillis(); @@ -810,9 +807,7 @@ public class CustomAH extends Gui { this.drawTexturedModalRect(auctionViewLeft, guiTop, 0, 0, 96, 99); priceField.drawTextBox(); - Utils.drawStringCenteredScaledMaxWidth("Bid Amount", Minecraft.getMinecraft().fontRendererObj, - auctionViewLeft + 39, guiTop + 10, false, 70, 4210752 - ); + Utils.drawStringCenteredScaledMaxWidth("Bid Amount", auctionViewLeft + 39, guiTop + 10, false, 70, 4210752); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); Minecraft.getMinecraft().getTextureManager().bindTexture(auction_view_buttons); @@ -822,22 +817,11 @@ public class CustomAH extends Gui { this.drawTexturedModalRect(auctionViewLeft + 16 + 34, guiTop + 50, 0, 16, 30, 16); this.drawTexturedModalRect(auctionViewLeft + 16, guiTop + 68, 0, 32, 64, 16); - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - Utils.drawStringCentered("x2", fr, auctionViewLeft + 16 + 15, guiTop + 32 + 8, false, - Color.BLACK.getRGB() - ); - Utils.drawStringCentered("+50%", fr, auctionViewLeft + 16 + 34 + 15, guiTop + 32 + 8, false, - Color.BLACK.getRGB() - ); - Utils.drawStringCentered("+25%", fr, auctionViewLeft + 16 + 15, guiTop + 50 + 8, false, - Color.BLACK.getRGB() - ); - Utils.drawStringCentered("+10%", fr, auctionViewLeft + 16 + 34 + 15, guiTop + 50 + 8, false, - Color.BLACK.getRGB() - ); - Utils.drawStringCentered("Set Amount", fr, auctionViewLeft + 16 + 32, guiTop + 68 + 8, false, - Color.BLACK.getRGB() - ); + Utils.drawStringCentered("x2", auctionViewLeft + 16 + 15, guiTop + 32 + 8, false, black); + Utils.drawStringCentered("+50%", auctionViewLeft + 16 + 34 + 15, guiTop + 32 + 8, false, black); + Utils.drawStringCentered("+25%", auctionViewLeft + 16 + 15, guiTop + 50 + 8, false, black); + Utils.drawStringCentered("+10%", auctionViewLeft + 16 + 34 + 15, guiTop + 50 + 8, false, black); + Utils.drawStringCentered("Set Amount", auctionViewLeft + 16 + 32, guiTop + 68 + 8, false, black); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GuiEditSign editSign = (GuiEditSign) Minecraft.getMinecraft().currentScreen; @@ -907,7 +891,7 @@ public class CustomAH extends Gui { this.drawTexturedModalRect(guiLeft, y, 0, ySplit, getXSize(), 136 - ySplit); //GUI Name - Utils.drawStringCenteredScaledMaxWidth("Auction House", Minecraft.getMinecraft().fontRendererObj, guiLeft + 42, + Utils.drawStringCenteredScaledMaxWidth("Auction House", guiLeft + 42, guiTop + 10, false, 68, 4210752 ); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); @@ -1000,7 +984,7 @@ public class CustomAH extends Gui { if (!NotEnoughUpdates.INSTANCE.config.neuAuctionHouse.enableNeuAuctionHouse) { Utils.drawStringCentered(EnumChatFormatting.RED + "NEUAH is DISABLED! Enable in /neu.", - Minecraft.getMinecraft().fontRendererObj, guiLeft + getXSize() / 2, guiTop + getYSize() / 2 - 5, true, 0 + guiLeft + getXSize() / 2, guiTop + getYSize() / 2 - 5, true, 0 ); } @@ -1009,9 +993,7 @@ public class CustomAH extends Gui { for (String line : tooltipToRender) { tooltipGray.add(EnumChatFormatting.GRAY + line); } - Utils.drawHoveringText(tooltipGray, mouseX, mouseY, width, - height, -1, Minecraft.getMinecraft().fontRendererObj - ); + Utils.drawHoveringText(tooltipGray, mouseX, mouseY, width, height, -1); } float slideAmount = 1 - Math.max(0, Math.min(1, (System.currentTimeMillis() - lastGuiScreenSwitch) / 200f)); int auctionViewLeft = guiLeft + getXSize() + 4 - (int) (slideAmount * (78 + 4)); @@ -1032,9 +1014,7 @@ public class CustomAH extends Gui { } priceFilterField.drawTextBox(); - Utils.drawStringCenteredScaledMaxWidth("Price Filter", Minecraft.getMinecraft().fontRendererObj, - auctionViewLeft + 39, guiTop + 10, false, 70, 4210752 - ); + Utils.drawStringCenteredScaledMaxWidth("Price Filter", auctionViewLeft + 39, guiTop + 10, false, 70, 421052); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); Minecraft.getMinecraft().getTextureManager().bindTexture(auction_view_buttons); @@ -1054,16 +1034,9 @@ public class CustomAH extends Gui { this.drawTexturedModalRect(auctionViewLeft + 16, guiTop + 50, 0, 32, 64, 16); } - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - Utils.drawStringCentered("<=", fr, auctionViewLeft + 16 + 15, guiTop + 32 + 8, false, - Color.BLACK.getRGB() - ); - Utils.drawStringCentered(">=", fr, auctionViewLeft + 16 + 34 + 15, guiTop + 32 + 8, false, - Color.BLACK.getRGB() - ); - Utils.drawStringCentered("==", fr, auctionViewLeft + 16 + 32, guiTop + 50 + 8, false, - Color.BLACK.getRGB() - ); + Utils.drawStringCentered("<=", auctionViewLeft + 16 + 15, guiTop + 32 + 8, false, black); + Utils.drawStringCentered(">=", auctionViewLeft + 16 + 34 + 15, guiTop + 32 + 8, false, black); + Utils.drawStringCentered("==", auctionViewLeft + 16 + 32, guiTop + 50 + 8, false, black); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); // Bin average price filter @@ -1079,9 +1052,7 @@ public class CustomAH extends Gui { } binPriceFilterField.drawTextBox(); - Utils.drawStringCenteredScaledMaxWidth("BIN Average Filter", Minecraft.getMinecraft().fontRendererObj, - auctionViewLeft + 39, guiTop + 10 + binPriceFilterYOffset, false, 70, 4210752 - ); + Utils.drawStringCenteredScaledMaxWidth("BIN Average Filter", auctionViewLeft + 39, guiTop + 10 + binPriceFilterYOffset, false, 70, 4210752); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); Minecraft.getMinecraft().getTextureManager().bindTexture(auction_view_buttons); @@ -1101,15 +1072,9 @@ public class CustomAH extends Gui { this.drawTexturedModalRect(auctionViewLeft + 16, guiTop + 50 + binPriceFilterYOffset, 0, 32, 64, 16); } - Utils.drawStringCentered("<=", fr, auctionViewLeft + 16 + 15, guiTop + 32 + 8 + binPriceFilterYOffset, false, - Color.BLACK.getRGB() - ); - Utils.drawStringCentered(">=", fr, auctionViewLeft + 16 + 34 + 15, guiTop + 32 + 8 + binPriceFilterYOffset, false, - Color.BLACK.getRGB() - ); - Utils.drawStringCentered("==", fr, auctionViewLeft + 16 + 32, guiTop + 50 + 8 + binPriceFilterYOffset, false, - Color.BLACK.getRGB() - ); + Utils.drawStringCentered("<=", auctionViewLeft + 16 + 15, guiTop + 32 + 8 + binPriceFilterYOffset, false, black); + Utils.drawStringCentered(">=", auctionViewLeft + 16 + 34 + 15, guiTop + 32 + 8 + binPriceFilterYOffset, false, black); + Utils.drawStringCentered("==", auctionViewLeft + 16 + 32, guiTop + 50 + 8 + binPriceFilterYOffset, false, black); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/Commands.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/Commands.java deleted file mode 100644 index 91365cd1..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/Commands.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.commands; - -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.commands.dev.DevTestCommand; -import io.github.moulberry.notenoughupdates.commands.dev.DiagCommand; -import io.github.moulberry.notenoughupdates.commands.dev.DungeonWinTestCommand; -import io.github.moulberry.notenoughupdates.commands.dev.EnableStorageCommand; -import io.github.moulberry.notenoughupdates.commands.dev.NullzeeSphereCommand; -import io.github.moulberry.notenoughupdates.commands.dev.PackDevCommand; -import io.github.moulberry.notenoughupdates.commands.dev.ReloadRepoCommand; -import io.github.moulberry.notenoughupdates.commands.dev.ResetRepoCommand; -import io.github.moulberry.notenoughupdates.commands.dev.StatsCommand; -import io.github.moulberry.notenoughupdates.commands.dungeon.DhCommand; -import io.github.moulberry.notenoughupdates.commands.dungeon.DnCommand; -import io.github.moulberry.notenoughupdates.commands.dungeon.JoinDungeonCommand; -import io.github.moulberry.notenoughupdates.commands.dungeon.MapCommand; -import io.github.moulberry.notenoughupdates.commands.help.FeaturesCommand; -import io.github.moulberry.notenoughupdates.commands.help.HelpCommand; -import io.github.moulberry.notenoughupdates.commands.help.LinksCommand; -import io.github.moulberry.notenoughupdates.commands.help.SettingsCommand; -import io.github.moulberry.notenoughupdates.commands.help.StorageViewerWhyCommand; -import io.github.moulberry.notenoughupdates.commands.misc.AhCommand; -import io.github.moulberry.notenoughupdates.commands.misc.CalculatorCommand; -import io.github.moulberry.notenoughupdates.commands.misc.CalendarCommand; -import io.github.moulberry.notenoughupdates.commands.misc.CosmeticsCommand; -import io.github.moulberry.notenoughupdates.commands.misc.CustomizeCommand; -import io.github.moulberry.notenoughupdates.commands.misc.PronounsCommand; -import io.github.moulberry.notenoughupdates.commands.misc.UpdateCommand; -import io.github.moulberry.notenoughupdates.commands.profile.CataCommand; -import io.github.moulberry.notenoughupdates.commands.profile.PeekCommand; -import io.github.moulberry.notenoughupdates.commands.profile.PvCommand; -import io.github.moulberry.notenoughupdates.commands.profile.ViewProfileCommand; -import io.github.moulberry.notenoughupdates.miscfeatures.FairySouls; -import io.github.moulberry.notenoughupdates.miscgui.GuiEnchantColour; -import io.github.moulberry.notenoughupdates.miscgui.GuiInvButtonEditor; -import io.github.moulberry.notenoughupdates.miscgui.NEUOverlayPlacements; -import net.minecraftforge.client.ClientCommandHandler; -import net.minecraftforge.fml.common.Loader; - -public class Commands { - public Commands() { - - // Help Commands - ClientCommandHandler.instance.registerCommand(new LinksCommand()); - ClientCommandHandler.instance.registerCommand(new HelpCommand()); - ClientCommandHandler.instance.registerCommand(new StorageViewerWhyCommand()); - ClientCommandHandler.instance.registerCommand(new FeaturesCommand()); - ClientCommandHandler.instance.registerCommand(new SettingsCommand()); - - // Dev Commands - ClientCommandHandler.instance.registerCommand(new PackDevCommand()); - ClientCommandHandler.instance.registerCommand(new DungeonWinTestCommand()); - ClientCommandHandler.instance.registerCommand(new StatsCommand()); - ClientCommandHandler.instance.registerCommand(new DevTestCommand()); - ClientCommandHandler.instance.registerCommand(new NullzeeSphereCommand()); - ClientCommandHandler.instance.registerCommand(new DiagCommand()); - ClientCommandHandler.instance.registerCommand(new ReloadRepoCommand()); - ClientCommandHandler.instance.registerCommand(new ResetRepoCommand()); - ClientCommandHandler.instance.registerCommand(new EnableStorageCommand()); - - // Profile Commands - ClientCommandHandler.instance.registerCommand(new PeekCommand()); - ClientCommandHandler.instance.registerCommand(new ViewProfileCommand()); - ClientCommandHandler.instance.registerCommand(new PvCommand()); - if (!Loader.isModLoaded("skyblockextras")) ClientCommandHandler.instance.registerCommand(new CataCommand()); - - // Dungeon Commands - ClientCommandHandler.instance.registerCommand(new MapCommand()); - ClientCommandHandler.instance.registerCommand(new JoinDungeonCommand()); - ClientCommandHandler.instance.registerCommand(new DnCommand()); - ClientCommandHandler.instance.registerCommand(new DhCommand()); - - // Misc Commands - ClientCommandHandler.instance.registerCommand(new CosmeticsCommand()); - ClientCommandHandler.instance.registerCommand(new CustomizeCommand()); - ClientCommandHandler.instance.registerCommand(new ScreenCommand("neubuttons", GuiInvButtonEditor::new)); - ClientCommandHandler.instance.registerCommand(new ScreenCommand("neuec", GuiEnchantColour::new)); - ClientCommandHandler.instance.registerCommand(new ScreenCommand("neuoverlay", NEUOverlayPlacements::new)); - ClientCommandHandler.instance.registerCommand(new AhCommand()); - ClientCommandHandler.instance.registerCommand(new CalculatorCommand()); - ClientCommandHandler.instance.registerCommand(new CalendarCommand()); - ClientCommandHandler.instance.registerCommand(new UpdateCommand(NotEnoughUpdates.INSTANCE)); - ClientCommandHandler.instance.registerCommand(new PronounsCommand()); - - // Fairy Soul Commands - ClientCommandHandler.instance.registerCommand(new FairySouls.FairySoulsCommand()); - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/EntityViewerCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/EntityViewerCommand.java deleted file mode 100644 index e3738661..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/EntityViewerCommand.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.commands; - -import com.google.common.collect.Lists; -import io.github.moulberry.notenoughupdates.miscfeatures.entityviewer.EntityViewer; -import net.minecraft.client.Minecraft; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.event.ClickEvent; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.ChatStyle; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; - -import java.util.Arrays; -import java.util.List; -import java.util.Queue; -import java.util.concurrent.ConcurrentLinkedDeque; - -public class EntityViewerCommand extends ClientCommandBase { - public EntityViewerCommand() { - super("neushowentity"); - MinecraftForge.EVENT_BUS.register(this); - } - - @Override - public List<String> getCommandAliases() { - return Lists.newArrayList("neuentityviewer"); - } - - @Override - public String getCommandUsage(ICommandSender sender) { - return EnumChatFormatting.RED + "Use /neushowentity list"; - } - - public void showUsage(ICommandSender sender) { - sender.addChatMessage(new ChatComponentText(getCommandUsage(sender))); - } - - private final Queue<EntityViewer> queuedGUIS = new ConcurrentLinkedDeque<>(); - - @SubscribeEvent - public void onTick(TickEvent event) { - if (Minecraft.getMinecraft().currentScreen == null) { - EntityViewer poll = queuedGUIS.poll(); - if (poll == null) return; - Minecraft.getMinecraft().displayGuiScreen(poll); - } - } - - @Override - public void processCommand(ICommandSender sender, String[] strings) throws CommandException { - if (strings.length == 0) { - showUsage(sender); - return; - } - if (strings[0].equals("list")) { - for (String label : EntityViewer.validEntities.keySet()) { - sender.addChatMessage(new ChatComponentText(EnumChatFormatting.BLUE + " " + label) - .setChatStyle(new ChatStyle().setChatClickEvent( - new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/neuentityviewer " + label)))); - } - return; - } - EntityLivingBase entityLivingBase; - if (strings[0].startsWith("@")) { - ResourceLocation resourceLocation = new ResourceLocation(strings[0].substring(1)); - entityLivingBase = EntityViewer.constructEntity(resourceLocation); - } else { - entityLivingBase = EntityViewer.constructEntity(strings[0], Arrays.copyOfRange(strings, 1, strings.length)); - } - if (entityLivingBase == null) { - sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Could not create that entity")); - return; - } - queuedGUIS.add(new EntityViewer(strings[0], entityLivingBase)); - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/ScreenCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/ScreenCommand.java deleted file mode 100644 index 1b90e5df..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/ScreenCommand.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.commands; - -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; - -public class ScreenCommand extends ClientCommandBase { - - private final ScreenOpener opener; - - protected ScreenCommand(String name, ScreenOpener opener) { - super(name); - this.opener = opener; - } - - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - NotEnoughUpdates.INSTANCE.openGui = opener.open(); - } - - @FunctionalInterface - public interface ScreenOpener { - GuiScreen open(); - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java deleted file mode 100644 index 35474ff3..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java +++ /dev/null @@ -1,263 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.commands.dev; - -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import io.github.moulberry.notenoughupdates.BuildFlags; -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; -import io.github.moulberry.notenoughupdates.core.config.GuiPositionEditor; -import io.github.moulberry.notenoughupdates.core.util.MiscUtils; -import io.github.moulberry.notenoughupdates.miscfeatures.FishingHelper; -import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.CustomBiomes; -import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.LocationChangeEvent; -import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.SpecialBlockZone; -import io.github.moulberry.notenoughupdates.miscgui.GuiPriceGraph; -import io.github.moulberry.notenoughupdates.miscgui.minionhelper.MinionHelperManager; -import io.github.moulberry.notenoughupdates.util.PronounDB; -import io.github.moulberry.notenoughupdates.util.SBInfo; -import io.github.moulberry.notenoughupdates.util.TabListUtils; -import io.github.moulberry.notenoughupdates.util.Utils; -import io.github.moulberry.notenoughupdates.util.hypixelapi.ProfileCollectionInfo; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; -import net.minecraft.launchwrapper.Launch; -import net.minecraft.util.BlockPos; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.EnumParticleTypes; -import net.minecraftforge.common.MinecraftForge; - -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -public class DevTestCommand extends ClientCommandBase { - - private static final List<String> DEV_TESTERS = - Arrays.asList( - "d0e05de7-6067-454d-beae-c6d19d886191", // moulberry - "66502b40-6ac1-4d33-950d-3df110297aab", // lucycoconut - "a5761ff3-c710-4cab-b4f4-3e7f017a8dbf", // ironm00n - "5d5c548a-790c-4fc8-bd8f-d25b04857f44", // ariyio - "53924f1a-87e6-4709-8e53-f1c7d13dc239", // throwpo - "d3cb85e2-3075-48a1-b213-a9bfb62360c1", // lrg89 - "0b4d470f-f2fb-4874-9334-1eaef8ba4804", // dediamondpro - "ebb28704-ed85-43a6-9e24-2fe9883df9c2", // lulonaut - "698e199d-6bd1-4b10-ab0c-52fedd1460dc", // craftyoldminer - "8a9f1841-48e9-48ed-b14f-76a124e6c9df", // eisengolem - "a7d6b3f1-8425-48e5-8acc-9a38ab9b86f7", // whalker - "0ce87d5a-fa5f-4619-ae78-872d9c5e07fe", // ascynx - "a049a538-4dd8-43f8-87d5-03f09d48b4dc", // egirlefe - "7a9dc802-d401-4d7d-93c0-8dd1bc98c70d", // efefury - "bb855349-dfd8-4125-a750-5fc2cf543ad5" // hannibal2 - ); - - private static final String[] DEV_FAIL_STRINGS = { - "No.", - "I said no.", - "You aren't allowed to use this.", - "Are you sure you want to use this? Type 'Yes' in chat.", - "Are you sure you want to use this? Type 'Yes' in chat.", - "Lmao you thought", - "Ok please stop", - "What do you want from me?", - "This command almost certainly does nothing useful for you", - "Ok, this is the last message, after this it will repeat", - "No.", - "I said no.", - "Dammit. I thought that would work. Uhh...", - "\u00a7dFrom \u00a7c[ADMIN] Minikloon\u00a77: If you use that command again, I'll have to ban you", - "", - "Ok, this is actually the last message, use the command again and you'll crash I promise" - }; - private int devFailIndex = 0; - - public DevTestCommand() { - super("neudevtest"); - } - - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - if (!DEV_TESTERS.contains(Minecraft.getMinecraft().thePlayer.getUniqueID().toString()) - && !(boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment")) { - if (devFailIndex >= DEV_FAIL_STRINGS.length) { - throw new Error("L") { - @Override - public void printStackTrace() { - throw new Error("L"); - } - }; - } - if (devFailIndex == DEV_FAIL_STRINGS.length - 2) { - devFailIndex++; - - ChatComponentText component = new ChatComponentText("\u00a7cYou are permanently banned from this server!"); - component.appendText("\n"); - component.appendText("\n\u00a77Reason: \u00a7rI told you not to run the command - Moulberry"); - component.appendText("\n\u00a77Find out more: \u00a7b\u00a7nhttps://www.hypixel.net/appeal"); - component.appendText("\n"); - component.appendText("\n\u00a77Ban ID: \u00a7r#49871982"); - component.appendText("\n\u00a77Sharing your Ban ID may affect the processing of your appeal!"); - Minecraft.getMinecraft().getNetHandler().getNetworkManager().closeChannel(component); - return; - } - Utils.addChatMessage(EnumChatFormatting.RED + DEV_FAIL_STRINGS[devFailIndex++]); - return; - } - if (args.length == 1 && args[0].equalsIgnoreCase("testprofile")) { - NotEnoughUpdates.INSTANCE.manager.apiUtils.newHypixelApiRequest("skyblock/profiles") - .queryArgument( - "uuid", - "" + Minecraft.getMinecraft().thePlayer.getUniqueID() - ) - .requestJson() - .thenApply(jsonObject -> { - JsonArray profiles = jsonObject.get("profiles").getAsJsonArray(); - JsonObject cp = null; - for (JsonElement profile : profiles) { - JsonObject asJsonObject = profile.getAsJsonObject(); - if ((asJsonObject.has("selected") && - asJsonObject.get("selected").getAsBoolean()) || cp == null) { - cp = asJsonObject; - } - } - return cp; - }) - .thenCompose(obj -> ProfileCollectionInfo.getCollectionData( - obj, - Minecraft.getMinecraft().thePlayer.getUniqueID().toString() - )) - .thenAccept(it -> - Utils.addChatMessage("Response: " + it)); - } - if (args.length >= 1 && args[0].equalsIgnoreCase("profileinfo")) { - String currentProfile = SBInfo.getInstance().currentProfile; - SBInfo.Gamemode gamemode = SBInfo.getInstance().getGamemodeForProfile(currentProfile); - sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GOLD + - "You are on Profile " + - currentProfile + - " with the mode " + - gamemode)); - } - if (args.length >= 1 && args[0].equalsIgnoreCase("buildflags")) { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( - "BuildFlags: \n" + - BuildFlags.getAllFlags().entrySet().stream() - .map(it -> " + " + it.getKey() + " - " + it.getValue()) - .collect(Collectors.joining("\n")))); - return; - } - if (args.length >= 1 && args[0].equalsIgnoreCase("exteditor")) { - if (args.length > 1) { - NotEnoughUpdates.INSTANCE.config.hidden.externalEditor = String.join( - " ", - Arrays.copyOfRange(args, 1, args.length) - ); - } - Utils.addChatMessage( - "§e[NEU] §fYour external editor is: §Z" + NotEnoughUpdates.INSTANCE.config.hidden.externalEditor); - return; - } - if (args.length >= 1 && args[0].equalsIgnoreCase("pricetest")) { - if (args.length == 1) { - NotEnoughUpdates.INSTANCE.manager.auctionManager.updateBazaar(); - } else { - NotEnoughUpdates.INSTANCE.openGui = new GuiPriceGraph(args[1]); - } - } - if (args.length == 1 && args[0].equalsIgnoreCase("zone")) { - BlockPos target = Minecraft.getMinecraft().objectMouseOver.getBlockPos(); - if (target == null) target = Minecraft.getMinecraft().thePlayer.getPosition(); - SpecialBlockZone zone = CustomBiomes.INSTANCE.getSpecialZone(target); - Arrays.asList( - new ChatComponentText("Showing Zone Info for: " + target), - new ChatComponentText("Zone: " + (zone != null ? zone.name() : "null")), - new ChatComponentText("Location: " + SBInfo.getInstance().getLocation()), - new ChatComponentText("Biome: " + CustomBiomes.INSTANCE.getCustomBiome(target)) - ).forEach(Minecraft.getMinecraft().thePlayer::addChatMessage); - MinecraftForge.EVENT_BUS.post(new LocationChangeEvent(SBInfo.getInstance().getLocation(), SBInfo - .getInstance() - .getLocation())); - } - if (args.length == 1 && args[0].equalsIgnoreCase("positiontest")) { - NotEnoughUpdates.INSTANCE.openGui = new GuiPositionEditor(); - return; - } - - if (args.length == 2 && args[0].equalsIgnoreCase("pt")) { - FishingHelper.type = EnumParticleTypes.valueOf(args[1]); - return; - } - if (args.length == 1 && args[0].equalsIgnoreCase("dev")) { - NotEnoughUpdates.INSTANCE.config.hidden.dev = !NotEnoughUpdates.INSTANCE.config.hidden.dev; - Utils.addChatMessage( - "§e[NEU] Dev mode " + (NotEnoughUpdates.INSTANCE.config.hidden.dev ? "§aenabled" : "§cdisabled")); - return; - } - if (args.length == 1 && args[0].equalsIgnoreCase("saveconfig")) { - NotEnoughUpdates.INSTANCE.saveConfig(); - return; - } - if (args.length == 1 && args[0].equalsIgnoreCase("searchmode")) { - NotEnoughUpdates.INSTANCE.config.hidden.firstTimeSearchFocus = true; - Utils.addChatMessage(EnumChatFormatting.AQUA + "I would never search"); - return; - } - if (args.length == 1 && args[0].equalsIgnoreCase("bluehair")) { - PronounDB.test(); - return; - } - if (args.length == 2 && args[0].equalsIgnoreCase("openGui")) { - try { - NotEnoughUpdates.INSTANCE.openGui = (GuiScreen) Class.forName(args[1]).newInstance(); - Utils.addChatMessage("Opening gui: " + NotEnoughUpdates.INSTANCE.openGui); - } catch (InstantiationException | IllegalAccessException | ClassNotFoundException | ClassCastException e) { - e.printStackTrace(); - Utils.addChatMessage("Failed to open this GUI."); - } - } - if (args.length == 1 && args[0].equalsIgnoreCase("center")) { - double x = Math.floor(Minecraft.getMinecraft().thePlayer.posX) + 0.5f; - double z = Math.floor(Minecraft.getMinecraft().thePlayer.posZ) + 0.5f; - Minecraft.getMinecraft().thePlayer.setPosition(x, Minecraft.getMinecraft().thePlayer.posY, z); - } - if (args.length >= 1 && args[0].equalsIgnoreCase("minion")) { - MinionHelperManager.getInstance().handleCommand(args); - } - if (args.length == 1 && args[0].equalsIgnoreCase("copytablist")) { - StringBuilder builder = new StringBuilder(); - for (String name : TabListUtils.getTabList()) { - builder.append(name).append("\n"); - } - MiscUtils.copyToClipboard(builder.toString()); - Utils.addChatMessage("§e[NEU] Copied tablist to clipboard!"); - } - if (args.length >= 1 && args[0].equalsIgnoreCase("useragent")) { - String newUserAgent = args.length == 1 ? null : String.join(" ", Arrays.copyOfRange(args, 1, args.length)); - Utils.addChatMessage("§e[NEU] Changed user agent override to: " + newUserAgent); - NotEnoughUpdates.INSTANCE.config.hidden.customUserAgent = newUserAgent; - } - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DiagCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DiagCommand.java deleted file mode 100644 index fb546efb..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DiagCommand.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.commands.dev; - -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; -import io.github.moulberry.notenoughupdates.miscfeatures.CrystalMetalDetectorSolver; -import io.github.moulberry.notenoughupdates.miscfeatures.CrystalWishingCompassSolver; -import io.github.moulberry.notenoughupdates.options.customtypes.NEUDebugFlag; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.EnumChatFormatting; - -public class DiagCommand extends ClientCommandBase { - public DiagCommand() { - super("neudiag"); - } - - private static final String USAGE_TEXT = EnumChatFormatting.WHITE + - "Usage: /neudiag <metal | wishing | debug>\n\n" + - "/neudiag metal Metal Detector Solver diagnostics\n" + - " <no sub-command> Show current solution diags\n" + - " center=<off | on> Disable / enable using center\n" + - "/neudiag wishing Wishing Compass Solver diagnostics\n" + - "/neudiag debug\n" + - " <no sub-command> Show all enabled flags\n" + - " <list> Show all flags\n"+ - " <enable | disable> <flag> Enable/disable flag\n"; - - private void showUsage(ICommandSender sender) { - sender.addChatMessage(new ChatComponentText(USAGE_TEXT)); - } - - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - if (args.length == 0) { - showUsage(sender); - return; - } - - String command = args[0].toLowerCase(); - switch (command) { - case "metal": - if (args.length == 1) { - CrystalMetalDetectorSolver.logDiagnosticData(true); - return; - } - - String subCommand = args[1].toLowerCase(); - if (subCommand.equals("center=off")) { - CrystalMetalDetectorSolver.setDebugDoNotUseCenter(true); - sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + - "Center coordinates-based solutions disabled")); - } else if (subCommand.equals("center=on")) { - CrystalMetalDetectorSolver.setDebugDoNotUseCenter(false); - sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + - "Center coordinates-based solutions enabled")); - } else { - showUsage(sender); - return; - } - - break; - case "wishing": - CrystalWishingCompassSolver.getInstance().logDiagnosticData(true); - break; - case "debug": - if (args.length > 1) { - boolean enablingFlag = true; - String action = args[1]; - switch (action) { - case "list": - sender.addChatMessage(new ChatComponentText( - EnumChatFormatting.YELLOW + "Here are all flags:\n" + NEUDebugFlag.getFlagList())); - return; - case "disable": - enablingFlag = false; - // falls through - case "enable": - if (args.length != 3) { - sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + - "You must specify a flag:\n" + - NEUDebugFlag.getFlagList())); - return; - } - - String flagName = args[2].toUpperCase(); - try { - NEUDebugFlag debugFlag = NEUDebugFlag.valueOf(flagName); - if (enablingFlag) { - NotEnoughUpdates.INSTANCE.config.hidden.debugFlags.add(debugFlag); - } else { - NotEnoughUpdates.INSTANCE.config.hidden.debugFlags.remove(debugFlag); - } - } catch (IllegalArgumentException e) { - sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + - flagName + " is invalid. Valid flags are:\n" + - NEUDebugFlag.getFlagList())); - return; - } - break; - default: - showUsage(sender); - return; - } - } - - sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Effective debug flags: \n" + - NEUDebugFlag.getEnabledFlags())); - break; - default: - showUsage(sender); - return; - } - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DungeonWinTestCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DungeonWinTestCommand.java deleted file mode 100644 index be25e697..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DungeonWinTestCommand.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.commands.dev; - -import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; -import io.github.moulberry.notenoughupdates.dungeons.DungeonWin; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; -import net.minecraft.util.ResourceLocation; - -public class DungeonWinTestCommand extends ClientCommandBase { - - public DungeonWinTestCommand() { - super("neudungeonwintest"); - } - - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - if (args.length > 0) { - DungeonWin.TEAM_SCORE = new ResourceLocation("notenoughupdates:dungeon_win/" + args[0].toLowerCase() + ".png"); - } - - DungeonWin.displayWin(); - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/EnableStorageCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/EnableStorageCommand.java deleted file mode 100644 index 3415b030..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/EnableStorageCommand.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.commands.dev; - -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; - -public class EnableStorageCommand extends ClientCommandBase { - - public EnableStorageCommand() { - super("neuenablestorage"); - } - - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - NotEnoughUpdates.INSTANCE.config.storageGUI.enableStorageGUI3 = true; - NotEnoughUpdates.INSTANCE.saveConfig(); - } - -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/NullzeeSphereCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/NullzeeSphereCommand.java deleted file mode 100644 index 3a9ce90f..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/NullzeeSphereCommand.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.commands.dev; - -import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; -import io.github.moulberry.notenoughupdates.miscfeatures.NullzeeSphere; -import net.minecraft.client.entity.EntityPlayerSP; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; -import net.minecraft.util.BlockPos; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.EnumChatFormatting; - -public class NullzeeSphereCommand extends ClientCommandBase { - - public NullzeeSphereCommand() { - super("neuzeesphere"); - } - - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - if (args.length != 1) { - sender.addChatMessage(new ChatComponentText( - EnumChatFormatting.RED + "Usage: /neuzeesphere [on/off] or /neuzeesphere (radius) or /neuzeesphere setCenter")); - return; - } - if (args[0].equalsIgnoreCase("on")) { - NullzeeSphere.enabled = true; - } else if (args[0].equalsIgnoreCase("off")) { - NullzeeSphere.enabled = false; - } else if (args[0].equalsIgnoreCase("setCenter")) { - EntityPlayerSP p = ((EntityPlayerSP) sender); - NullzeeSphere.centerPos = new BlockPos(p.posX, p.posY, p.posZ); - NullzeeSphere.overlayVBO = null; - } else { - try { - NullzeeSphere.size = Float.parseFloat(args[0]); - NullzeeSphere.overlayVBO = null; - } catch (Exception e) { - sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Can't parse radius: " + args[0])); - } - } - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/PackDevCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/PackDevCommand.java deleted file mode 100644 index 1d30a15f..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/PackDevCommand.java +++ /dev/null @@ -1,304 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.commands.dev; - -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; -import io.github.moulberry.notenoughupdates.core.util.MiscUtils; -import io.github.moulberry.notenoughupdates.util.Utils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.AbstractClientPlayer; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLiving; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.item.EntityArmorStand; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTBase; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.BlockPos; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.EnumChatFormatting; - -import java.util.HashMap; -import java.util.List; -import java.util.function.Supplier; - -public class PackDevCommand extends ClientCommandBase { - static Minecraft mc = Minecraft.getMinecraft(); - - public PackDevCommand() { - super("neupackdev"); - } - - private static final HashMap<String, Command<?, ?>> commands = new HashMap<String, Command<?, ?>>() {{ - put( - "getnpc", - new Command<>( - "NPC", - () -> mc.theWorld.playerEntities, - true, - AbstractClientPlayer.class - ) - ); - put( - "getnpcs", - new Command<>( - "NPC", - () -> mc.theWorld.playerEntities, - false, - AbstractClientPlayer.class - ) - ); - put( - "getmob", - new Command<>( - "mob", - () -> mc.theWorld.loadedEntityList, - true, - EntityLiving.class - ) - ); - put( - "getmobs", - new Command<>( - "mob", - () -> mc.theWorld.loadedEntityList, - false, - EntityLiving.class - ) - ); - put( - "getarmorstand", - new Command<>( - "armor stand", - () -> mc.theWorld.loadedEntityList, - true, - EntityArmorStand.class - ) - ); - put( - "getarmorstands", - new Command<>( - "armor stand", - () -> mc.theWorld.loadedEntityList, - false, - EntityArmorStand.class - ) - ); - }}; - - @Override - public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) { - return args.length == 1 ? getListOfStringsMatchingLastWord(args, commands.keySet()) : null; - } - - public static void togglePackDeveloperMode(ICommandSender sender) { - NotEnoughUpdates.INSTANCE.packDevEnabled = !NotEnoughUpdates.INSTANCE.packDevEnabled; - if (NotEnoughUpdates.INSTANCE.packDevEnabled) { - sender.addChatMessage(new ChatComponentText( - EnumChatFormatting.GREEN + "Enabled pack developer mode.")); - } else { - sender.addChatMessage(new ChatComponentText( - EnumChatFormatting.RED + "Disabled pack developer mode.")); - } - } - - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - if (args.length == 0) { - togglePackDeveloperMode(sender); - return; - } - - double dist = 5.0; - if (args.length >= 2) { - try { - dist = Double.parseDouble(args[1]); - } catch (NumberFormatException e) { - sender.addChatMessage(new ChatComponentText( - EnumChatFormatting.RED + "Invalid distance! Must be a number, defaulting to a radius of 5.")); - } - } - - StringBuilder output; - String subCommand = args[0].toLowerCase(); - if (commands.containsKey(subCommand)) { - Command<?, ?> command = commands.get(subCommand); - output = command.getData(dist); - } else if (subCommand.equals("getall")) { - output = getAll(dist); - } else if (subCommand.equals("getallclose")) { - output = getAllClose(dist); - } else { - sender.addChatMessage(new ChatComponentText( - EnumChatFormatting.RED + "Invalid sub-command.")); - return; - } - - if (output.length() != 0) { - MiscUtils.copyToClipboard(output.toString()); - } - } - - private static StringBuilder getAllClose(Double dist) { - StringBuilder sb = new StringBuilder(); - sb.append(commands.get("getmob").getData(dist)); - sb.append(commands.get("getarmorstand").getData(dist)); - sb.append(commands.get("getnpc").getData(dist)); - return sb; - } - - private static StringBuilder getAll(Double dist) { - StringBuilder sb = new StringBuilder(); - sb.append(commands.get("getmobs").getData(dist)); - sb.append(commands.get("getarmorstands").getData(dist)); - sb.append(commands.get("getnpcs").getData(dist)); - return sb; - } - - public static <T extends EntityLivingBase> StringBuilder livingBaseDataBuilder(T entity, Class<T> clazz) { - StringBuilder entityData = new StringBuilder(); - if (EntityPlayer.class.isAssignableFrom(entity.getClass())) { - EntityPlayer entityPlayer = (EntityPlayer) entity; - - // NPC Information - String skinResourcePath = ((AbstractClientPlayer) entityPlayer).getLocationSkin().getResourcePath(); - entityData - .append("Player Id: ") - .append(entityPlayer.getUniqueID() != null ? entityPlayer.getUniqueID().toString() : "null") - .append(entityPlayer.getCustomNameTag() != null ? entityPlayer.getCustomNameTag() : "null") - .append("\nEntity Texture Id: ") - .append(skinResourcePath != null ? skinResourcePath.replace("skins/", "") : "null"); - } - - if (!clazz.isAssignableFrom(entity.getClass())) { - return entityData; - } - - //Entity Information - entityData - .append("Entity Id: ") - .append(entity.getEntityId()) - .append("\nMob: ") - .append(entity.getName() != null ? entity.getName() : "null") - .append("\nCustom Name: ") - .append(entity.getCustomNameTag() != null ? entity.getCustomNameTag() : "null"); - - //Held Item - if (entity.getHeldItem() != null) { - entityData - .append("\nItem: ") - .append(entity.getHeldItem()) - .append("\nItem Display Name: ") - .append(entity.getHeldItem().getDisplayName() != null - ? entity.getHeldItem().getDisplayName() - : "null") - .append("\nItem Tag Compound: "); - NBTTagCompound heldItemTagCompound = entity.getHeldItem().getTagCompound(); - if (heldItemTagCompound != null) { - String heldItemString = heldItemTagCompound.toString(); - NBTBase extraAttrTag = heldItemTagCompound.getTag("ExtraAttributes"); - entityData - .append(heldItemString != null ? heldItemString : "null") - .append("\nItem Tag Compound Extra Attributes: ") - .append(extraAttrTag != null ? extraAttrTag : "null"); - } else { - entityData.append("null"); - } - - } else { - entityData.append("\nItem: null"); - } - - entityData.append(armorDataBuilder(entity)).append("\n\n"); - - return entityData; - } - - private static final String[] armorPieceTypes = {"Boots", "Leggings", "Chestplate", "Helmet"}; - - public static <T extends EntityLivingBase> StringBuilder armorDataBuilder(T entity) { - StringBuilder armorData = new StringBuilder(); - for (int i = 0; i < 4; i++) { - ItemStack currentArmor = entity.getCurrentArmor(0); - armorData.append(String.format("\n%s: ", armorPieceTypes[i])); - if (currentArmor == null) { - armorData.append("null"); - } else { - armorData.append(currentArmor.getTagCompound() != null ? currentArmor.getTagCompound().toString() : "null"); - } - } - return armorData; - } - - static class Command<T extends EntityLivingBase, U extends Entity> { - String typeFriendlyName; - Supplier<List<U>> entitySupplier; - Class<T> clazz; - boolean single; - - Command( - String typeFriendlyName, - Supplier<List<U>> entitySupplier, - boolean single, - Class<T> clazz - ) { - this.typeFriendlyName = typeFriendlyName; - this.entitySupplier = entitySupplier; - this.single = single; - this.clazz = clazz; - } - - @SuppressWarnings("unchecked") - public StringBuilder getData(double dist) { - StringBuilder result = new StringBuilder(); - double distSq = dist * dist; - T closest = null; - for (Entity entity : entitySupplier.get()) { - if (!clazz.isAssignableFrom(entity.getClass()) || entity == mc.thePlayer) { - continue; - } - T entityT = (T) entity; - double entityDistanceSq = entity.getDistanceSq(mc.thePlayer.posX, mc.thePlayer.posY, mc.thePlayer.posZ); - if (entityDistanceSq < distSq) { - if (single) { - distSq = entityDistanceSq; - closest = entityT; - } else { - result.append(livingBaseDataBuilder(entityT, clazz)); - } - } - } - - if ((single && closest == null) || (!single && result.length() == 0)) { - Utils.addChatMessage(EnumChatFormatting.RED + "No " + typeFriendlyName + "s found within " + dist + " blocks."); - } else { - Utils.addChatMessage( - EnumChatFormatting.GREEN + "Copied " + typeFriendlyName + " data to clipboard"); - return single ? livingBaseDataBuilder(closest, clazz) : result; - } - - return result; - } - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/ReloadRepoCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/ReloadRepoCommand.java deleted file mode 100644 index 0bf57594..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/ReloadRepoCommand.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.commands.dev; - -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; -import net.minecraft.util.ChatComponentText; - -public class ReloadRepoCommand extends ClientCommandBase { - - public ReloadRepoCommand() { - super("neureloadrepo"); - } - - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - NotEnoughUpdates.INSTANCE.manager.reloadRepository(); - sender.addChatMessage(new ChatComponentText("§e[NEU] Reloaded repository.")); - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/ResetRepoCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/ResetRepoCommand.java deleted file mode 100644 index 3f693898..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/ResetRepoCommand.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.commands.dev; - -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; -import net.minecraft.util.ChatComponentText; - -public class ResetRepoCommand extends ClientCommandBase { - - public ResetRepoCommand() { - super("neuresetrepo"); - } - - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - NotEnoughUpdates.INSTANCE.manager - .userFacingRepositoryReload() - .thenAccept(strings -> - strings.forEach(line -> - sender.addChatMessage(new ChatComponentText("§e[NEU] " + line)))); - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/StatsCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/StatsCommand.java deleted file mode 100644 index ea417977..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/StatsCommand.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.commands.dev; - -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; -import io.github.moulberry.notenoughupdates.util.DiscordMarkdownBuilder; -import io.github.moulberry.notenoughupdates.util.HastebinUploader; -import io.github.moulberry.notenoughupdates.util.SBInfo; -import io.github.moulberry.notenoughupdates.util.Utils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.OpenGlHelper; -import net.minecraft.command.ICommandSender; -import net.minecraft.util.BlockPos; -import net.minecraft.util.EnumChatFormatting; -import net.minecraftforge.common.ForgeVersion; -import net.minecraftforge.fml.client.FMLClientHandler; -import net.minecraftforge.fml.common.Loader; -import org.lwjgl.opengl.Display; -import org.lwjgl.opengl.GL11; - -import javax.management.JMX; -import javax.management.MBeanServer; -import javax.management.ObjectName; -import java.awt.*; -import java.awt.datatransfer.StringSelection; -import java.lang.management.ManagementFactory; -import java.util.List; -import java.util.Locale; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -public class StatsCommand extends ClientCommandBase { - private final ExecutorService threadPool = Executors.newFixedThreadPool(1); - - public StatsCommand() { - super("neustats"); - } - - private static final int activeModCount = Loader.instance().getActiveModList().size(); - - @Override - public void processCommand(ICommandSender sender, String[] args) { - if (args.length > 0) { - switch (args[0].toLowerCase(Locale.ROOT)) { - case "modlist": - if (activeModCount > 15) { - clipboardAndSendMessage(createModList(new DiscordMarkdownBuilder()).toString()); - } else { - clipboardAndSendMessage(createStats()); - } - break; - case "dump": - modPrefixedMessage(EnumChatFormatting.GREEN + - "This will upload a dump of the java classes your game has loaded how big they are and how many there are. This can take a few seconds as it is uploading to HasteBin."); - threadPool.submit(() -> { - try { - final MBeanServer server = ManagementFactory.getPlatformMBeanServer(); - final ObjectName objectName = ObjectName.getInstance("com.sun.management:type=DiagnosticCommand"); - final DiagnosticCommandMXBean proxy = JMX.newMXBeanProxy( - server, - objectName, - DiagnosticCommandMXBean.class - ); - clipboardAndSendMessage(HastebinUploader.upload( - proxy.gcClassHistogram(new String[0]).replace("[", "[]"), - HastebinUploader.Mode.NORMAL - )); - } catch (Exception e) { - clipboardAndSendMessage(null); - } - }); - break; - } - } else { - clipboardAndSendMessage(createStats()); - } - - } - - @Override - public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) { - return args.length == 1 ? getListOfStringsMatchingLastWord(args, "modlist", "dump") : null; - } - - public interface DiagnosticCommandMXBean { - String gcClassHistogram(String[] array); - } - - private static void clipboardAndSendMessage(String data) { - if (data == null) { - modPrefixedMessage(EnumChatFormatting.DARK_RED + "Error occurred trying to perform command."); - return; - } - try { - StringSelection clipboard = new StringSelection(data); - Toolkit.getDefaultToolkit().getSystemClipboard().setContents(clipboard, clipboard); - modPrefixedMessage(EnumChatFormatting.GREEN + "Dev info copied to clipboard."); - } catch (Exception ignored) { - modPrefixedMessage(EnumChatFormatting.DARK_RED + "Could not copy to clipboard."); - } - } - - private static void modPrefixedMessage(String message) { - Utils.addChatMessage( - EnumChatFormatting.GOLD + "[" + EnumChatFormatting.RED + "NotEnoughUpdates" + EnumChatFormatting.GOLD + "]: " + message); - } - - private static String createStats() { - DiscordMarkdownBuilder builder = new DiscordMarkdownBuilder(); - long maxMemory = Runtime.getRuntime().maxMemory(); - long totalMemory = Runtime.getRuntime().totalMemory(); - long freeMemory = Runtime.getRuntime().freeMemory(); - long currentMemory = totalMemory - freeMemory; - - builder.category("System Stats"); - builder.append("OS", System.getProperty("os.name")); - builder.append("CPU", OpenGlHelper.getCpu()); - builder.append( - "Display", - String.format("%dx%d (%s)", Display.getWidth(), Display.getHeight(), GL11.glGetString(GL11.GL_VENDOR)) - ); - builder.append("GPU", GL11.glGetString(GL11.GL_RENDERER)); - builder.append("GPU Driver", GL11.glGetString(GL11.GL_VERSION)); - if (getMemorySize() > 0) builder.append("Maximum Memory", (getMemorySize() / 1024L / 1024L) + "MB"); - builder.append("Shaders", ("" + OpenGlHelper.isFramebufferEnabled()).toUpperCase()); - builder.category("Java Stats"); - builder.append( - "Java", - String.format("%s %dbit", System.getProperty("java.version"), Minecraft.getMinecraft().isJava64bit() ? 64 : 32) - ); - builder.append( - "Memory", - String.format( - "% 2d%% %03d/%03dMB", - currentMemory * 100L / maxMemory, - currentMemory / 1024L / 1024L, - maxMemory / 1024L / 1024L - ) - ); - builder.append( - "Memory Allocated", - String.format("% 2d%% %03dMB", totalMemory * 100L / maxMemory, totalMemory / 1024L / 1024L) - ); - builder.category("Game Stats"); - builder.append("FPS", String.valueOf(Minecraft.getDebugFPS())); - builder.append("Loaded Mods", String.valueOf(activeModCount)); - builder.append("Forge", ForgeVersion.getVersion()); - builder.append("Optifine", FMLClientHandler.instance().hasOptifine() ? "TRUE" : "FALSE"); - builder.category("Neu Settings"); - builder.append("API Key", NotEnoughUpdates.INSTANCE.config.apiData.apiKey.isEmpty() ? "FALSE" : "TRUE"); - builder.append("On SkyBlock", NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() ? "TRUE" : "FALSE"); - builder.append( - "Mod Version", - Loader.instance().getIndexedModList().get(NotEnoughUpdates.MODID).getDisplayVersion() - ); - builder.append("SB Profile", SBInfo.getInstance().currentProfile); - builder.append("Has Advanced Tab", SBInfo.getInstance().hasNewTab ? "TRUE" : "FALSE"); - builder.category("Repo Stats"); - builder.append("Last Commit", NotEnoughUpdates.INSTANCE.manager.latestRepoCommit); - builder.append("Loaded Items", String.valueOf(NotEnoughUpdates.INSTANCE.manager.getItemInformation().size())); - if (activeModCount <= 15) createModList(builder); - - return builder.toString(); - } - - private static DiscordMarkdownBuilder createModList(DiscordMarkdownBuilder builder) { - builder.category("Mods Loaded"); - Loader.instance().getActiveModList().forEach(mod -> builder.append(mod.getName(), mod.getSource().getName())); - return builder; - } - - private static long getMemorySize() { - try { - return ((com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean()).getTotalPhysicalMemorySize(); - } catch (Exception e) { - try { - return ((com.sun.management.UnixOperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean()).getTotalPhysicalMemorySize(); - } catch (Exception ignored) {/*IGNORE*/} - } - return -1; - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/DhCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/DhCommand.java deleted file mode 100644 index 222862f9..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/DhCommand.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.commands.dungeon; - -import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; -import net.minecraft.client.Minecraft; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; - -public class DhCommand extends ClientCommandBase { - - public DhCommand() { - super("dh"); - } - - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - Minecraft.getMinecraft().thePlayer.sendChatMessage("/warp dungeon_hub"); - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/DnCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/DnCommand.java deleted file mode 100644 index 3b697905..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/DnCommand.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.commands.dungeon; - -import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; -import io.github.moulberry.notenoughupdates.util.Utils; -import net.minecraft.client.Minecraft; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; -import net.minecraft.util.EnumChatFormatting; - -public class DnCommand extends ClientCommandBase { - - public DnCommand() { - super("dn"); - } - - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - Minecraft.getMinecraft().thePlayer.sendChatMessage("/warp dungeon_hub"); - Utils.addChatMessage(EnumChatFormatting.AQUA + "Warping to:" + EnumChatFormatting.YELLOW + " Deez Nuts lmao"); - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/JoinDungeonCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/JoinDungeonCommand.java deleted file mode 100644 index 58bfbef2..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/JoinDungeonCommand.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.commands.dungeon; - -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; -import io.github.moulberry.notenoughupdates.util.Utils; -import net.minecraft.client.Minecraft; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; -import net.minecraft.util.EnumChatFormatting; -import org.apache.commons.lang3.StringUtils; - -public class JoinDungeonCommand extends ClientCommandBase { - - public JoinDungeonCommand() { - super("join"); - } - - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) { - Minecraft.getMinecraft().thePlayer.sendChatMessage("/join " + StringUtils.join(args, " ")); - } else { - if (args.length != 1) { - Utils.addChatMessage(EnumChatFormatting.RED + "Example Usage: /join f7, /join m6 or /join 7"); - } else { - String cataPrefix = "catacombs"; - if (args[0].toLowerCase().startsWith("m")) { - cataPrefix = "master_catacombs"; - } - String cmd = "/joindungeon " + cataPrefix + " " + args[0].charAt(args[0].length() - 1); - Utils.addChatMessage(EnumChatFormatting.YELLOW + "Running command: " + cmd); - Utils.addChatMessage(EnumChatFormatting.YELLOW + - "The dungeon should start soon. If it doesn't, make sure you have a party of 5 people"); - Minecraft.getMinecraft().thePlayer.sendChatMessage(cmd); - } - } - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/MapCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/MapCommand.java deleted file mode 100644 index d52ed196..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/MapCommand.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.commands.dungeon; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; -import io.github.moulberry.notenoughupdates.dungeons.GuiDungeonMapEditor; -import io.github.moulberry.notenoughupdates.util.Utils; -import net.minecraft.block.material.MapColor; -import net.minecraft.client.Minecraft; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; -import net.minecraft.item.ItemMap; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.world.storage.MapData; - -import java.awt.*; -import java.io.File; -import java.util.Map; - -public class MapCommand extends ClientCommandBase { - - public MapCommand() { - super("neumap"); - } - - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - - if (!NotEnoughUpdates.INSTANCE.config.hidden.dev) { - NotEnoughUpdates.INSTANCE.openGui = new GuiDungeonMapEditor(null); - return; - } - - if (args.length == 1 && args[0].equals("reset")) { - NotEnoughUpdates.INSTANCE.colourMap = null; - return; - } - - if (args.length != 2) { - NotEnoughUpdates.INSTANCE.openGui = new GuiDungeonMapEditor(null); - return; - } - - if (args[0].equals("save")) { - ItemStack stack = Minecraft.getMinecraft().thePlayer.getHeldItem(); - if (stack != null && stack.getItem() instanceof ItemMap) { - ItemMap map = (ItemMap) stack.getItem(); - MapData mapData = map.getMapData(stack, Minecraft.getMinecraft().theWorld); - - if (mapData == null) return; - - JsonObject json = new JsonObject(); - for (int i = 0; i < 16384; ++i) { - int x = i % 128; - int y = i / 128; - - int j = mapData.colors[i] & 255; - - Color c; - if (j / 4 == 0) { - c = new Color((i + i / 128 & 1) * 8 + 16 << 24, true); - } else { - c = new Color(MapColor.mapColorArray[j / 4].getMapColor(j & 3), true); - } - - json.addProperty(x + ":" + y, c.getRGB()); - } - - try { - new File(NotEnoughUpdates.INSTANCE.manager.configLocation, "maps").mkdirs(); - NotEnoughUpdates.INSTANCE.manager.writeJson( - json, - new File(NotEnoughUpdates.INSTANCE.manager.configLocation, "maps/" + args[1] + ".json") - ); - } catch (Exception e) { - e.printStackTrace(); - } - - Utils.addChatMessage(EnumChatFormatting.GREEN + "Saved to file."); - } - - return; - } - - if (args[0].equals("load")) { - JsonObject json = NotEnoughUpdates.INSTANCE.manager.getJsonFromFile(new File( - NotEnoughUpdates.INSTANCE.manager.configLocation, - "maps/" + args[1] + ".json" - )); - - NotEnoughUpdates.INSTANCE.colourMap = new Color[128][128]; - for (int x = 0; x < 128; x++) { - for (int y = 0; y < 128; y++) { - NotEnoughUpdates.INSTANCE.colourMap[x][y] = new Color(0, 0, 0, 0); - } - } - for (Map.Entry<String, JsonElement> entry : json.entrySet()) { - int x = Integer.parseInt(entry.getKey().split(":")[0]); - int y = Integer.parseInt(entry.getKey().split(":")[1]); - - NotEnoughUpdates.INSTANCE.colourMap[x][y] = new Color(entry.getValue().getAsInt(), true); - } - - return; - } - - NotEnoughUpdates.INSTANCE.openGui = new GuiDungeonMapEditor(null); - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/help/FeaturesCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/help/FeaturesCommand.java deleted file mode 100644 index bbabc172..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/help/FeaturesCommand.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.commands.help; - -import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; -import io.github.moulberry.notenoughupdates.util.Constants; -import io.github.moulberry.notenoughupdates.util.Utils; -import net.minecraft.client.Minecraft; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; -import net.minecraft.event.ClickEvent; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.EnumChatFormatting; - -public class FeaturesCommand extends ClientCommandBase { - public FeaturesCommand() { - super("neufeatures"); - } - - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - Utils.addChatMessage(""); - if (Constants.MISC == null || !Constants.MISC.has("featureslist")) { - Utils.showOutdatedRepoNotification(); - return; - } - String url = Constants.MISC.get("featureslist").getAsString(); - - if (Utils.openUrl(url)) { - Utils.addChatMessage( - EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.BOLD + "NEU" + EnumChatFormatting.RESET + - EnumChatFormatting.GOLD + "> Opening Feature List in browser."); - } else { - ChatComponentText clickTextFeatures = new ChatComponentText( - EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.BOLD + "NEU" + EnumChatFormatting.RESET + - EnumChatFormatting.GOLD + "> Click here to open the Feature List in your browser."); - clickTextFeatures.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, url)); - Minecraft.getMinecraft().thePlayer.addChatMessage(clickTextFeatures); - - } - Utils.addChatMessage(""); - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/help/HelpCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/help/HelpCommand.java deleted file mode 100644 index 3a47509d..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/help/HelpCommand.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.commands.help; - -import com.google.common.collect.Lists; -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; -import io.github.moulberry.notenoughupdates.util.Utils; -import net.minecraft.command.ICommandSender; - -import java.util.ArrayList; - -public class HelpCommand extends ClientCommandBase { - - public HelpCommand() { - super("neuhelp"); - } - - @Override - public void processCommand(ICommandSender sender, String[] args) { - ArrayList<String> neuHelpMessages = Lists.newArrayList( - "\u00a75\u00a7lNotEnoughUpdates commands", - "\u00a76/neu \u00a77- Opens the main NEU GUI.", - "\u00a76/pv \u00a7b?{name} \u00a72\u2D35 \u00a7r\u00a77- Opens the profile viewer", - "\u00a76/neusouls {on/off/clear/unclear} \u00a7r\u00a77- Shows waypoints to fairy souls.", - "\u00a76/neubuttons \u00a7r\u00a77- Opens a GUI which allows you to customize inventory buttons.", - "\u00a76/neuec \u00a7r\u00a77- Opens the enchant colour GUI.", - "\u00a76/join {floor} \u00a7r\u00a77- Short Command to join a Dungeon. \u00a7lNeed a Party of 5 People\u00a7r\u00a77 {4/f7/m5}.", - "\u00a76/neucosmetics \u00a7r\u00a77- Opens the cosmetic GUI.", - "\u00a76/neurename \u00a7r\u00a77- Opens the NEU Item Customizer.", - "\u00a76/cata \u00a7b?{name} \u00a72\u2D35 \u00a7r\u00a77- Opens the profile viewer's Catacombs page.", - "\u00a76/neulinks \u00a7r\u00a77- Shows links to NEU/Moulberry.", - "\u00a76/neuoverlay \u00a7r\u00a77- Opens GUI Editor for quickcommands and searchbar.", - "\u00a76/neuah \u00a7r\u00a77- Opens NEU's custom auction house GUI.", - "\u00a76/neucalendar \u00a7r\u00a77- Opens NEU's custom calendar GUI.", - "\u00a76/neucalc \u00a7r\u00a77- Run calculations.", - "", - "\u00a76\u00a7lOld commands:", - "\u00a76/peek \u00a7b?{user} \u00a72\u2D35 \u00a7r\u00a77- Shows quick stats for a user.", - "", - "\u00a76\u00a7lDebug commands:", - "\u00a76/neustats \u00a7r\u00a77- Copies helpful info to the clipboard.", - "\u00a76/neustats modlist \u00a7r\u00a77- Copies mod list info to clipboard.", - "\u00a76/neuresetrepo \u00a7r\u00a77- Deletes all repo files.", - "\u00a76/neureloadrepo \u00a7r\u00a77- Debug command with repo.", - "", - "\u00a76\u00a7lDev commands:", - "\u00a76/neupackdev \u00a7r\u00a77- pack creator command - getnpc, getmob(s), getarmorstand(s), getall. Optional radius argument for all." - ); - for (String neuHelpMessage : neuHelpMessages) { - Utils.addChatMessage(neuHelpMessage); - } - if (NotEnoughUpdates.INSTANCE.config.hidden.dev) { - ArrayList<String> neuDevHelpMessages = Lists.newArrayList( - "\u00a76/neudevtest \u00a7r\u00a77- dev test command", - "\u00a76/neuzeephere \u00a7r\u00a77- sphere", - "\u00a76/neudungeonwintest \u00a7r\u00a77- displays the dungeon win screen" - ); - - for (String neuDevHelpMessage : neuDevHelpMessages) { - Utils.addChatMessage(neuDevHelpMessage); - } - } - String[] helpInfo = { - "", - "\u00a77Commands marked with a \u00a72\"\u2D35\"\u00a77 require an api key. You can set your api key via \"/api new\" or by manually putting it in the api field in \"/neu\"", - "", - "\u00a77Arguments marked with a \u00a7b\"?\"\u00a77 are optional.", - "", - "\u00a76\u00a7lScroll up to see everything" - }; - - for (String message : helpInfo) { - Utils.addChatMessage(message); - } - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/help/LinksCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/help/LinksCommand.java deleted file mode 100644 index 793e652e..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/help/LinksCommand.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.commands.help; - -import com.google.gson.JsonObject; -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; -import io.github.moulberry.notenoughupdates.util.Utils; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; - -import java.io.File; - -public class LinksCommand extends ClientCommandBase { - - public LinksCommand() { - super("neulinks"); - } - - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - File repo = NotEnoughUpdates.INSTANCE.manager.repoLocation; - if (repo.exists()) { - File updateJson = new File(repo, "update.json"); - try { - JsonObject update = NotEnoughUpdates.INSTANCE.manager.getJsonFromFile(updateJson); - - Utils.addChatMessage(""); - NotEnoughUpdates.INSTANCE.displayLinks(update,0 ); - Utils.addChatMessage(""); - } catch (Exception ignored) { - } - } - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/help/SettingsCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/help/SettingsCommand.java deleted file mode 100644 index 1855a2b5..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/help/SettingsCommand.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.commands.help; - -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; -import io.github.moulberry.notenoughupdates.core.GuiScreenElementWrapper; -import io.github.moulberry.notenoughupdates.options.NEUConfigEditor; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; -import org.apache.commons.lang3.StringUtils; - -import java.util.Arrays; -import java.util.List; - -public class SettingsCommand extends ClientCommandBase { - - public SettingsCommand() { - super("neu"); - } - - @Override - public List<String> getCommandAliases() { - return Arrays.asList("neusettings", "neuconfig"); - } - - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - if (args.length > 0) { - NotEnoughUpdates.INSTANCE.openGui = - new GuiScreenElementWrapper(new NEUConfigEditor(NotEnoughUpdates.INSTANCE.config, StringUtils.join(args, " "))); - } else { - NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper(new NEUConfigEditor(NotEnoughUpdates.INSTANCE.config)); - } - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/help/StorageViewerWhyCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/help/StorageViewerWhyCommand.java deleted file mode 100644 index 820c6f2a..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/help/StorageViewerWhyCommand.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.commands.help; - -import com.google.common.collect.Lists; -import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; -import io.github.moulberry.notenoughupdates.util.NotificationHandler; -import net.minecraft.command.ICommandSender; - -public class StorageViewerWhyCommand extends ClientCommandBase { - - public StorageViewerWhyCommand() { - super("neustwhy"); - } - - @Override - public void processCommand(ICommandSender sender, String[] args) { - NotificationHandler.displayNotification(Lists.newArrayList( - "\u00a7eStorage Viewer", - "\u00a77Currently, the storage viewer requires you to click twice", - "\u00a77in order to switch between pages. This is because Hypixel", - "\u00a77has not yet added a shortcut command to go to any enderchest/", - "\u00a77storage page.", - "\u00a77While it is possible to send the second click", - "\u00a77automatically, doing so violates Hypixel's new mod rules." - ), true); - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/AhCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/AhCommand.java deleted file mode 100644 index 1ca398ef..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/AhCommand.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.commands.misc; - -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.auction.CustomAHGui; -import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; -import io.github.moulberry.notenoughupdates.util.Utils; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; -import net.minecraft.util.EnumChatFormatting; -import org.apache.commons.lang3.StringUtils; - -public class AhCommand extends ClientCommandBase { - - public AhCommand() { - super("neuah"); - } - - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) { - Utils.addChatMessage(EnumChatFormatting.RED + "You must be on SkyBlock to use this feature."); - } else if (NotEnoughUpdates.INSTANCE.config.apiData.apiKey == null || - NotEnoughUpdates.INSTANCE.config.apiData.apiKey.trim().isEmpty()) { - Utils.addChatMessage( - EnumChatFormatting.RED + "Can't open NEU AH: an api key is not set. Run /api new and put the result in settings."); - } else { - NotEnoughUpdates.INSTANCE.openGui = new CustomAHGui(); - NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.lastOpen = System.currentTimeMillis(); - NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.clearSearch(); - NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.updateSearch(); - - if (args.length > 0) { - NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.setSearch(StringUtils.join(args, " ")); - } else { - if (NotEnoughUpdates.INSTANCE.config.neuAuctionHouse.saveLastSearch) { - NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.setSearch(null); - } - } - } - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/CalculatorCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/CalculatorCommand.java deleted file mode 100644 index b01f106b..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/CalculatorCommand.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.commands.misc; - -import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; -import io.github.moulberry.notenoughupdates.util.Calculator; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.EnumChatFormatting; - -import java.math.BigDecimal; -import java.text.DecimalFormat; -import java.util.Arrays; -import java.util.List; -import java.util.Objects; - -public class CalculatorCommand extends ClientCommandBase { - public CalculatorCommand() { - super("neucalc"); - } - - @Override - public List<String> getCommandAliases() { - return Arrays.asList("neucalculator"); - } - - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - if ((args.length == 1 && Objects.equals(args[0], "help")) || args.length == 0) { - sender.addChatMessage(new ChatComponentText( - "\n§e[NEU] §5It's a calculator.\n" + - "§eFor Example §b/neucalc 3m*7k§e.\n" + - "§eYou can also use suffixes (k, m, b, t, s)§e.\n" + - "§eThe \"s\" suffix acts as 64.\n" + - "§eTurn on Sign Calculator in /neu misc to also support this in sign popups and the neu search bar.\n")); - return; - } - String source = String.join(" ", args); - try { - BigDecimal calculate = Calculator.calculate(source); - DecimalFormat formatter = new DecimalFormat("#,##0.##"); - String format = formatter.format(calculate); - sender.addChatMessage(new ChatComponentText( - EnumChatFormatting.YELLOW + "[NEU] " + EnumChatFormatting.WHITE + source + " " + EnumChatFormatting.YELLOW + - "= " + EnumChatFormatting.GREEN + format - )); - } catch (Calculator.CalculatorException e) { - sender.addChatMessage(new ChatComponentText( - EnumChatFormatting.YELLOW + "[NEU] " + EnumChatFormatting.RED + "Error during calculation: " + - e.getMessage() + "\n" + - EnumChatFormatting.WHITE + source.substring(0, e.getOffset()) + EnumChatFormatting.DARK_RED + - source.substring(e.getOffset(), e.getLength() + e.getOffset()) + EnumChatFormatting.GRAY + - source.substring(e.getLength() + e.getOffset()) - )); - } - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/CalendarCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/CalendarCommand.java deleted file mode 100644 index 58c13474..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/CalendarCommand.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.commands.misc; - -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; -import io.github.moulberry.notenoughupdates.miscgui.CalendarOverlay; -import net.minecraft.client.Minecraft; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; - -public class CalendarCommand extends ClientCommandBase { - - public CalendarCommand() { - super("neucalendar"); - } - - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - Minecraft.getMinecraft().thePlayer.closeScreen(); - CalendarOverlay.setEnabled(true); - NotEnoughUpdates.INSTANCE.sendChatMessage("/calendar"); - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/CosmeticsCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/CosmeticsCommand.java deleted file mode 100644 index bbab316e..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/CosmeticsCommand.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.commands.misc; - -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; -import io.github.moulberry.notenoughupdates.cosmetics.GuiCosmetics; -import io.github.moulberry.notenoughupdates.util.Utils; -import net.minecraft.client.renderer.OpenGlHelper; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; -import net.minecraft.util.EnumChatFormatting; - -public class CosmeticsCommand extends ClientCommandBase { - - public CosmeticsCommand() { - super("neucosmetics"); - } - - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - if (!OpenGlHelper.isFramebufferEnabled() && NotEnoughUpdates.INSTANCE.config.notifications.doFastRenderNotif) { - Utils.addChatMessage(EnumChatFormatting.RED + - "NEU Cosmetics do not work with OptiFine Fast Render. Go to ESC > Options > Video Settings > Performance > Fast Render to disable it."); - - } - - NotEnoughUpdates.INSTANCE.openGui = new GuiCosmetics(); - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/CustomizeCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/CustomizeCommand.java deleted file mode 100644 index 28c2893d..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/CustomizeCommand.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.commands.misc; - -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; -import io.github.moulberry.notenoughupdates.miscgui.GuiItemCustomize; -import net.minecraft.client.Minecraft; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ChatComponentText; - -import java.util.Collections; -import java.util.List; - -public class CustomizeCommand extends ClientCommandBase { - - public CustomizeCommand() { - super("neucustomize"); - } - - @Override - public List<String> getCommandAliases() { - return Collections.singletonList("neurename"); - } - - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem(); - - if (held == null) { - sender.addChatMessage(new ChatComponentText("\u00a7cYou can't customize your hand...")); - return; - } - - String heldUUID = NotEnoughUpdates.INSTANCE.manager.getUUIDForItem(held); - - if (heldUUID == null) { - sender.addChatMessage(new ChatComponentText("\u00a7cHeld item does not have a UUID, so it cannot be customized")); - return; - } - - NotEnoughUpdates.INSTANCE.openGui = new GuiItemCustomize(held, heldUUID); - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/PronounsCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/PronounsCommand.java deleted file mode 100644 index 5a4f1400..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/PronounsCommand.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.commands.misc; - -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; -import io.github.moulberry.notenoughupdates.util.MinecraftExecutor; -import io.github.moulberry.notenoughupdates.util.PronounDB; -import io.github.moulberry.notenoughupdates.util.Utils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiNewChat; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; -import net.minecraft.util.ChatComponentText; - -import java.util.Optional; -import java.util.Random; -import java.util.UUID; -import java.util.concurrent.CompletableFuture; - -public class PronounsCommand extends ClientCommandBase { - public PronounsCommand() { - super("neupronouns"); - } - - @Override - public String getCommandUsage(ICommandSender sender) { - return "/neupronouns <username> [platform]"; - } - - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - switch (args.length) { - case 1: - fetchPronouns("minecraft", args[0]); - break; - case 2: - fetchPronouns(args[1], args[0]); - break; - default: - sender.addChatMessage(new ChatComponentText("§4" + getCommandUsage(sender))); - } - } - - private void fetchPronouns(String platform, String user) { - GuiNewChat nc = Minecraft.getMinecraft().ingameGUI.getChatGUI(); - int id = new Random().nextInt(); - nc.printChatMessageWithOptionalDeletion(new ChatComponentText("§e[NEU] Fetching Pronouns..."), id); - - CompletableFuture<Optional<PronounDB.PronounChoice>> pronouns; - if ("minecraft".equals(platform)) { - CompletableFuture<UUID> c = new CompletableFuture<>(); - NotEnoughUpdates.profileViewer.getPlayerUUID(user, uuidString -> { - if (uuidString == null) { - c.completeExceptionally(new NullPointerException()); - } else { - c.complete(Utils.parseDashlessUUID(uuidString)); - } - }); - pronouns = c.thenCompose(PronounDB::getPronounsFor); - } else { - pronouns = PronounDB.getPronounsFor(platform, user); - } - pronouns.handleAsync((pronounChoice, throwable) -> { - if (throwable != null || !pronounChoice.isPresent()) { - nc.printChatMessageWithOptionalDeletion(new ChatComponentText("§e[NEU] §4Failed to fetch pronouns."), id); - return null; - } - PronounDB.PronounChoice betterPronounChoice = pronounChoice.get(); - nc.printChatMessageWithOptionalDeletion(new ChatComponentText( - "§e[NEU] Pronouns for §b" + user + " §eon §b" + platform + "§e:"), id); - betterPronounChoice.render().forEach(it -> nc.printChatMessage(new ChatComponentText("§e[NEU] §a" + it))); - return null; - }, MinecraftExecutor.INSTANCE); - - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/UpdateCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/UpdateCommand.java deleted file mode 100644 index 1aeebda5..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/UpdateCommand.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.commands.misc; - -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; -import net.minecraft.util.ChatComponentText; - -import java.util.Arrays; -import java.util.List; -import java.util.Objects; - -public class UpdateCommand extends ClientCommandBase { - NotEnoughUpdates neu; - - public UpdateCommand(NotEnoughUpdates neu) { - super("neuupdate"); - this.neu = neu; - } - - @Override - public List<String> getCommandAliases() { - return Arrays.asList("neuupdates", "enoughupdates"); - } - - public void displayHelp(ICommandSender sender) { - sender.addChatMessage(new ChatComponentText( - "" + - "§e[NEU] §b/neuupdate help - View help.\n" + - "§e[NEU] §b/neuupdate check - Check for updates.\n" + - "" - )); - - } - - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - if ((args.length == 1 && Objects.equals(args[0], "help")) || args.length == 0) { - displayHelp(sender); - return; - } - switch (args[0].toLowerCase().intern()) { - case "check": - neu.autoUpdater.displayUpdateMessageIfOutOfDate(); - break; - case "scheduledownload": - neu.autoUpdater.scheduleDownload(); - break; - case "updatemodes": - sender.addChatMessage(new ChatComponentText("§e[NEU] §bTo ensure we do not accidentally corrupt your mod folder, we can only offer support for auto-updates on system with certain capabilities for file deletions (specifically unix systems). You can still manually update your files")); - break; - default: - displayHelp(sender); - - } - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/profile/PeekCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/profile/PeekCommand.java deleted file mode 100644 index 23852ab6..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/profile/PeekCommand.java +++ /dev/null @@ -1,343 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.commands.profile; - -import com.google.gson.JsonObject; -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; -import io.github.moulberry.notenoughupdates.profileviewer.PlayerStats; -import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer; -import io.github.moulberry.notenoughupdates.util.Utils; -import net.minecraft.client.Minecraft; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.BlockPos; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.EnumChatFormatting; -import org.apache.commons.lang3.text.WordUtils; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.Random; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.TimeUnit; - -public class PeekCommand extends ClientCommandBase { - - private ScheduledExecutorService peekCommandExecutorService = null; - private ScheduledFuture<?> peekScheduledFuture = null; - - public PeekCommand() { - super("peek"); - } - - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - String name; - if (args.length == 0) { - name = Minecraft.getMinecraft().thePlayer.getName(); - } else { - name = args[0]; - } - int id = new Random().nextInt(Integer.MAX_VALUE / 2) + Integer.MAX_VALUE / 2; - - Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(new ChatComponentText( - EnumChatFormatting.YELLOW + "[PEEK] Getting player information..."), id); - NotEnoughUpdates.profileViewer.getProfileByName(name, profile -> { - if (profile == null) { - Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(new ChatComponentText( - EnumChatFormatting.RED + "[PEEK] Unknown player or the Hypixel API is down."), id); - } else { - profile.resetCache(); - - if (peekCommandExecutorService == null || peekCommandExecutorService.isTerminated()) { - peekCommandExecutorService = Executors.newSingleThreadScheduledExecutor(); - } - - if (peekScheduledFuture != null && !peekScheduledFuture.isDone()) { - Utils.addChatMessage( - EnumChatFormatting.RED + "[PEEK] New peek command was run, cancelling old one."); - peekScheduledFuture.cancel(true); - } - - Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(new ChatComponentText( - EnumChatFormatting.YELLOW + "[PEEK] Getting the player's SkyBlock profile(s)..."), id); - - long startTime = System.currentTimeMillis(); - peekScheduledFuture = peekCommandExecutorService.schedule(new Runnable() { - public void run() { - if (System.currentTimeMillis() - startTime > 10 * 1000) { - Minecraft.getMinecraft().ingameGUI - .getChatGUI() - .printChatMessageWithOptionalDeletion(new ChatComponentText( - EnumChatFormatting.RED + "[PEEK] Getting profile info took too long, aborting."), id); - return; - } - - String g = EnumChatFormatting.GRAY.toString(); - - JsonObject profileInfo = profile.getProfileInformation(null); - if (profileInfo != null) { - float overallScore = 0; - - boolean isMe = name.equalsIgnoreCase("moulberry"); - - PlayerStats.Stats stats = profile.getStats(null); - if (stats == null) { - peekScheduledFuture = peekCommandExecutorService.schedule(this, 200, TimeUnit.MILLISECONDS); - return; - } - Map<String, ProfileViewer.Level> skyblockInfo = profile.getSkyblockInfo(null); - - if (NotEnoughUpdates.INSTANCE.config.profileViewer.useSoopyNetworth) { - Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(new ChatComponentText( - EnumChatFormatting.YELLOW + "[PEEK] Getting the player's Skyblock networth..."), id); - - CountDownLatch countDownLatch = new CountDownLatch(1); - - profile.getSoopyNetworth(null, () -> countDownLatch.countDown()); - - try { //Wait for async network request - countDownLatch.await(10, TimeUnit.SECONDS); - } catch (InterruptedException e) {} - - //Now it's waited for network request the data should be cached (accessed in nw section) - } - - Minecraft.getMinecraft().ingameGUI - .getChatGUI() - .printChatMessageWithOptionalDeletion(new ChatComponentText(EnumChatFormatting.GREEN + " " + - EnumChatFormatting.STRIKETHROUGH + "-=-" + EnumChatFormatting.RESET + EnumChatFormatting.GREEN + - " " + - Utils.getElementAsString(profile.getHypixelProfile().get("displayname"), name) + "'s Info " + - EnumChatFormatting.STRIKETHROUGH + "-=-"), id); - - if (skyblockInfo == null) { - Utils.addChatMessage(EnumChatFormatting.YELLOW + "Skills API disabled!"); - } else { - float totalSkillLVL = 0; - float totalSkillCount = 0; - - List<String> skills = Arrays.asList("taming", "mining", "foraging", "enchanting", "farming", "combat", "fishing", "alchemy", "carpentry"); - for (String skillName : skills) { - totalSkillLVL += skyblockInfo.get(skillName).level; - totalSkillCount++; - } - - float combat = skyblockInfo.get("combat").level; - float zombie = skyblockInfo.get("zombie").level; - float spider = skyblockInfo.get("spider").level; - float wolf = skyblockInfo.get("wolf").level; - float enderman = skyblockInfo.get("enderman").level; - float blaze = skyblockInfo.get("blaze").level; - - float avgSkillLVL = totalSkillLVL / totalSkillCount; - - if (isMe) { - avgSkillLVL = 6; - combat = 4; - zombie = 2; - spider = 1; - wolf = 2; - enderman = 0; - blaze = 0; - } - - EnumChatFormatting combatPrefix = combat > 20 - ? (combat > 35 ? EnumChatFormatting.GREEN : EnumChatFormatting.YELLOW) - : EnumChatFormatting.RED; - EnumChatFormatting zombiePrefix = zombie > 3 - ? (zombie > 6 ? EnumChatFormatting.GREEN : EnumChatFormatting.YELLOW) - : EnumChatFormatting.RED; - EnumChatFormatting spiderPrefix = spider > 3 - ? (spider > 6 ? EnumChatFormatting.GREEN : EnumChatFormatting.YELLOW) - : EnumChatFormatting.RED; - EnumChatFormatting wolfPrefix = - wolf > 3 ? (wolf > 6 ? EnumChatFormatting.GREEN : EnumChatFormatting.YELLOW) : EnumChatFormatting.RED; - EnumChatFormatting endermanPrefix = enderman > 3 - ? (enderman > 6 - ? EnumChatFormatting.GREEN - : EnumChatFormatting.YELLOW) - : EnumChatFormatting.RED; - EnumChatFormatting blazePrefix = blaze > 3 - ? (blaze > 6 - ? EnumChatFormatting.GREEN - : EnumChatFormatting.YELLOW) - : EnumChatFormatting.RED; - EnumChatFormatting avgPrefix = avgSkillLVL > 20 - ? (avgSkillLVL > 35 - ? EnumChatFormatting.GREEN - : EnumChatFormatting.YELLOW) - : EnumChatFormatting.RED; - - overallScore += zombie * zombie / 81f; - overallScore += spider * spider / 81f; - overallScore += wolf * wolf / 81f; - overallScore += enderman * enderman / 81f; - overallScore += blaze * blaze / 81f; - overallScore += avgSkillLVL / 20f; - - int cata = (int) skyblockInfo.get("catacombs").level; - EnumChatFormatting cataPrefix = cata > 15 - ? (cata > 25 ? EnumChatFormatting.GREEN : EnumChatFormatting.YELLOW) - : EnumChatFormatting.RED; - - overallScore += cata * cata / 2000f; - - Utils.addChatMessage(g + "Combat: " + combatPrefix + (int) Math.floor(combat) + - (cata > 0 ? g + " - Cata: " + cataPrefix + cata : "") + - g + " - AVG: " + avgPrefix + (int) Math.floor(avgSkillLVL)); - Utils.addChatMessage(g + "Slayer: " + zombiePrefix + (int) Math.floor(zombie) + g + "-" + - spiderPrefix + (int) Math.floor(spider) + g + "-" + - wolfPrefix + (int) Math.floor(wolf) + g + "-" + - endermanPrefix + (int) Math.floor(enderman) + g + "-" + - blazePrefix + (int) Math.floor(blaze)); - } - if (stats == null) { - Utils.addChatMessage(EnumChatFormatting.YELLOW + "Skills, collection and/or inventory apis disabled!"); - } else { - int health = (int) stats.get("health"); - int defence = (int) stats.get("defence"); - int strength = (int) stats.get("strength"); - int intelligence = (int) stats.get("intelligence"); - - EnumChatFormatting healthPrefix = health > 800 - ? (health > 1600 - ? EnumChatFormatting.GREEN - : EnumChatFormatting.YELLOW) - : EnumChatFormatting.RED; - EnumChatFormatting defencePrefix = defence > 200 - ? (defence > 600 - ? EnumChatFormatting.GREEN - : EnumChatFormatting.YELLOW) - : EnumChatFormatting.RED; - EnumChatFormatting strengthPrefix = strength > 100 - ? (strength > 300 - ? EnumChatFormatting.GREEN - : EnumChatFormatting.YELLOW) - : EnumChatFormatting.RED; - EnumChatFormatting intelligencePrefix = intelligence > 300 - ? (intelligence > 900 - ? EnumChatFormatting.GREEN - : EnumChatFormatting.YELLOW) - : EnumChatFormatting.RED; - - Utils.addChatMessage( g + "Stats : " + healthPrefix + health + EnumChatFormatting.RED + "\u2764 " + - defencePrefix + defence + EnumChatFormatting.GREEN + "\u2748 " + - strengthPrefix + strength + EnumChatFormatting.RED + "\u2741 " + - intelligencePrefix + intelligence + EnumChatFormatting.AQUA + "\u270e "); - } - float bankBalance = Utils.getElementAsFloat(Utils.getElement(profileInfo, "banking.balance"), -1); - float purseBalance = Utils.getElementAsFloat(Utils.getElement(profileInfo, "coin_purse"), 0); - - long networth; - if (NotEnoughUpdates.INSTANCE.config.profileViewer.useSoopyNetworth) { - ProfileViewer.Profile.SoopyNetworthData nwData = profile.getSoopyNetworth(null, () -> {}); - if (nwData == null) { - networth = -2l; - } else { - networth = nwData.getTotal(); - } - } else { - networth = profile.getNetWorth(null); - } - - float money = Math.max(bankBalance + purseBalance, networth); - EnumChatFormatting moneyPrefix = money > 50 * 1000 * 1000 ? - (money > 200 * 1000 * 1000 - ? EnumChatFormatting.GREEN - : EnumChatFormatting.YELLOW) : EnumChatFormatting.RED; - Utils.addChatMessage( g + "Purse: " + moneyPrefix + Utils.shortNumberFormat(purseBalance, 0) + g + " - Bank: " + - (bankBalance == -1 ? EnumChatFormatting.YELLOW + "N/A" : moneyPrefix + - (isMe ? "4.8b" : Utils.shortNumberFormat(bankBalance, 0))) + - (networth > 0 ? g + " - Net: " + moneyPrefix + Utils.shortNumberFormat(networth, 0) : "")); - - overallScore += Math.min(2, money / (100f * 1000 * 1000)); - - String activePet = Utils.getElementAsString( - Utils.getElement(profile.getPetsInfo(null), "active_pet.type"), - "None Active" - ); - String activePetTier = Utils.getElementAsString(Utils.getElement( - profile.getPetsInfo(null), - "active_pet.tier" - ), "UNKNOWN"); - - String col = NotEnoughUpdates.petRarityToColourMap.get(activePetTier); - if (col == null) col = EnumChatFormatting.LIGHT_PURPLE.toString(); - - Utils.addChatMessage(g + "Pet : " + col + WordUtils.capitalizeFully(activePet.replace("_", " "))); - - String overall = "Skywars Main"; - if (isMe) { - overall = Utils.chromaString("Literally the best player to exist"); // ego much - } else if (overallScore < 5 && (bankBalance + purseBalance) > 500 * 1000 * 1000) { - overall = EnumChatFormatting.GOLD + "Bill Gates"; - } else if (overallScore > 9) { - overall = Utils.chromaString("Didn't even think this score was possible"); - } else if (overallScore > 8) { - overall = Utils.chromaString("Mentally unstable"); - } else if (overallScore > 7) { - overall = EnumChatFormatting.GOLD + "Why though 0.0"; - } else if (overallScore > 5.5) { - overall = EnumChatFormatting.GOLD + "Bro stop playing"; - } else if (overallScore > 4) { - overall = EnumChatFormatting.GREEN + "Kinda sweaty"; - } else if (overallScore > 3) { - overall = EnumChatFormatting.YELLOW + "Alright I guess"; - } else if (overallScore > 2) { - overall = EnumChatFormatting.YELLOW + "Ender Non"; - } else if (overallScore > 1) { - overall = EnumChatFormatting.RED + "Played SkyBlock"; - } - - Utils.addChatMessage(g + "Overall score: " + overall + g + " (" + Math.round(overallScore * 10) / 10f + ")"); - - peekCommandExecutorService.shutdownNow(); - } else { - peekScheduledFuture = peekCommandExecutorService.schedule(this, 200, TimeUnit.MILLISECONDS); - } - } - }, 200, TimeUnit.MILLISECONDS); - } - }); - } - - @Override - public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) { - if (args.length != 1) return null; - - String lastArg = args[args.length - 1]; - List<String> playerMatches = new ArrayList<>(); - for (EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) { - String playerName = player.getName(); - if (playerName.toLowerCase().startsWith(lastArg.toLowerCase())) { - playerMatches.add(playerName); - } - } - return playerMatches; - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/profile/PvCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/profile/PvCommand.java deleted file mode 100644 index 2d5c05f4..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/profile/PvCommand.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.commands.profile; - -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import net.minecraft.client.Minecraft; -import net.minecraft.command.ICommandSender; -import org.apache.commons.lang3.StringUtils; - -public class PvCommand extends ViewProfileCommand { - - public PvCommand() { - super("pv"); - } - - @Override - public void processCommand(ICommandSender sender, String[] args) { - if (!NotEnoughUpdates.INSTANCE.isOnSkyblock()) { - Minecraft.getMinecraft().thePlayer.sendChatMessage("/pv " + StringUtils.join(args, " ")); - } else { - super.processCommand(sender, args); - } - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/profile/ViewProfileCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/profile/ViewProfileCommand.java deleted file mode 100644 index 26468e39..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/profile/ViewProfileCommand.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.commands.profile; - -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; -import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer; -import io.github.moulberry.notenoughupdates.util.Utils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.OpenGlHelper; -import net.minecraft.command.ICommandSender; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.BlockPos; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.EnumChatFormatting; - -import java.util.ArrayList; -import java.util.List; -import java.util.function.Consumer; - -public class ViewProfileCommand extends ClientCommandBase { - - public static final Consumer<String[]> RUNNABLE = (args) -> { - if (!OpenGlHelper.isFramebufferEnabled()) { - Utils.addChatMessage(EnumChatFormatting.RED + - "Some parts of the profile viewer do not work with OptiFine Fast Render. Go to ESC > Options > Video Settings > Performance > Fast Render to disable it."); - - } - if (NotEnoughUpdates.INSTANCE.config.apiData.apiKey == null || - NotEnoughUpdates.INSTANCE.config.apiData.apiKey.trim().isEmpty()) { - Utils.addChatMessage(EnumChatFormatting.RED + - "Can't view profile, an API key is not set. Run /api new and put the result in settings."); - } else if (args.length == 0) { - NotEnoughUpdates.profileViewer.getProfileByName(Minecraft.getMinecraft().thePlayer.getName(), profile -> { - if (profile == null) { - Utils.addChatMessage(EnumChatFormatting.RED + - "Invalid player name/API key. Maybe the API is down? Try /api new."); - } else { - profile.resetCache(); - NotEnoughUpdates.INSTANCE.openGui = new GuiProfileViewer(profile); - } - }); - } else if (args.length > 1) { - Utils.addChatMessage(EnumChatFormatting.RED + - "Too many arguments. Usage: /neuprofile [name]"); - } else { - NotEnoughUpdates.profileViewer.getProfileByName(args[0], profile -> { - if (profile == null) { - Utils.addChatMessage(EnumChatFormatting.RED + "Invalid player name/api key. Maybe the API is down? Try /api new."); - } else { - profile.resetCache(); - NotEnoughUpdates.INSTANCE.openGui = new GuiProfileViewer(profile); - } - }); - } - }; - - public ViewProfileCommand() { - this("neuprofile"); - } - - public ViewProfileCommand(String name) { - super(name); - } - - @Override - public void processCommand(ICommandSender sender, String[] args) { - RUNNABLE.accept(args); - } - - @Override - public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) { - if (args.length != 1) return null; - - String lastArg = args[args.length - 1]; - List<String> playerMatches = new ArrayList<>(); - for (EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) { - String playerName = player.getName(); - if (playerName.toLowerCase().startsWith(lastArg.toLowerCase())) { - playerMatches.add(playerName); - } - } - return playerMatches; - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementColour.java b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementColour.java index 1802a1a4..405b18fc 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementColour.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementColour.java @@ -254,13 +254,11 @@ public class GuiElementColour extends GuiElement { RenderUtils.drawTexturedRect(x + 5 + 32 + selx - 4, y + 5 + 32 + sely - 4, 8, 8, GL11.GL_NEAREST); TextRenderUtils.drawStringCenteredScaledMaxWidth(EnumChatFormatting.GRAY.toString() + Math.round(hsv[2] * 100) + "", - Minecraft.getMinecraft().fontRendererObj, x + 5 + 64 + 5 + 5 - (Math.round(hsv[2] * 100) == 100 ? 1 : 0), y + 5 + 64 + 5 + 5, true, 13, -1 ); if (opacitySlider) { TextRenderUtils.drawStringCenteredScaledMaxWidth( EnumChatFormatting.GRAY.toString() + Math.round(c.getAlpha() / 255f * 100) + "", - Minecraft.getMinecraft().fontRendererObj, x + 5 + 64 + 5 + valueOffset + 5, y + 5 + 64 + 5 + 5, true, @@ -271,7 +269,6 @@ public class GuiElementColour extends GuiElement { if (chromaSpeed > 0) { TextRenderUtils.drawStringCenteredScaledMaxWidth(EnumChatFormatting.GRAY.toString() + (int) ChromaColour.getSecondsForSpeed(chromaSpeed) + "s", - Minecraft.getMinecraft().fontRendererObj, x + 5 + 64 + 5 + valueOffset + opacityOffset + 6, y + 5 + 64 + 5 + 5, true, 13, -1 ); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementTextField.java b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementTextField.java index 45dc58cc..5ab62d2a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementTextField.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementTextField.java @@ -550,7 +550,6 @@ public class GuiElementTextField { TextRenderUtils.drawStringCenteredScaledMaxWidth( Utils.chromaStringByColourCode(texts[yOffI]), - Minecraft.getMinecraft().fontRendererObj, x + searchBarXSize / 2f, y + searchBarYSize / 2f + yOff, false, @@ -665,12 +664,12 @@ public class GuiElementTextField { y + (searchBarYSize - 8) / 2 + 9 + texY, Color.LIGHT_GRAY.getRGB() ); - TextRenderUtils.drawStringScaled(String.valueOf(c), Minecraft.getMinecraft().fontRendererObj, + TextRenderUtils.drawStringScaled(String.valueOf(c), x + xStartOffset + texX, y + searchBarYSize / 2f - scale * 8 / 2f + texY, false, Color.BLACK.getRGB(), scale ); if (bold) { - TextRenderUtils.drawStringScaled(String.valueOf(c), Minecraft.getMinecraft().fontRendererObj, + TextRenderUtils.drawStringScaled(String.valueOf(c), x + xStartOffset + texX + 1, y + searchBarYSize / 2f - scale * 8 / 2f + texY, false, Color.BLACK.getRGB(), scale ); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigOption.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigOption.java index 920cb326..ddd1e71f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigOption.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigOption.java @@ -30,6 +30,7 @@ public @interface ConfigOption { String name(); String desc(); + String[] searchTags() default ""; int subcategoryId() default -1; 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 9edad918..fd0946c9 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 @@ -39,8 +39,9 @@ public abstract class GuiOptionEditor { FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; RenderUtils.drawFloatingRectDark(x, y, width, height, true); - TextRenderUtils.drawStringCenteredScaledMaxWidth(option.name, - fr, x + width / 6, y + 13, true, width / 3 - 10, 0xc0c0c0 + TextRenderUtils.drawStringCenteredScaledMaxWidth( + option.name, + x + width / 6, y + 13, true, width / 3 - 10, 0xc0c0c0 ); int maxLines = 5; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorAccordion.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorAccordion.java index 91515259..a422a8ec 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorAccordion.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorAccordion.java @@ -22,7 +22,6 @@ package io.github.moulberry.notenoughupdates.core.config.gui; import io.github.moulberry.notenoughupdates.core.config.struct.ConfigProcessor; import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; import io.github.moulberry.notenoughupdates.core.util.render.TextRenderUtils; -import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.WorldRenderer; @@ -76,9 +75,7 @@ public class GuiOptionEditorAccordion extends GuiOptionEditor { GlStateManager.enableTexture2D(); GlStateManager.disableBlend(); - TextRenderUtils.drawStringScaledMaxWidth(option.name, Minecraft.getMinecraft().fontRendererObj, - x + 18, y + 6, false, width - 10, 0xc0c0c0 - ); + TextRenderUtils.drawStringScaledMaxWidth(option.name, x + 18, y + 6, false, width - 10, 0xc0c0c0); } @Override diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorButton.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorButton.java index aef6318c..fb5b58f3 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorButton.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorButton.java @@ -59,9 +59,9 @@ public class GuiOptionEditorButton extends GuiOptionEditor { RenderUtils.drawTexturedRect(x + width / 6 - 24, y + height - 7 - 14, 48, 16); if (buttonText != null) { - TextRenderUtils.drawStringCenteredScaledMaxWidth(buttonText, Minecraft.getMinecraft().fontRendererObj, - x + width / 6, y + height - 7 - 6, - false, 44, 0xFF303030 + TextRenderUtils.drawStringCenteredScaledMaxWidth( + buttonText, + x + width / 6, y + height - 7 - 6, false, 44, 0xFF303030 ); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDraggableList.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDraggableList.java index ef2a52bb..e080bb28 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDraggableList.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDraggableList.java @@ -25,7 +25,6 @@ import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; import io.github.moulberry.notenoughupdates.core.util.render.TextRenderUtils; 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.renderer.GlStateManager; @@ -93,10 +92,7 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor { Minecraft.getMinecraft().getTextureManager().bindTexture(button_tex); RenderUtils.drawTexturedRect(x + width / 6 - 24, y + 45 - 7 - 14, 48, 16); - TextRenderUtils.drawStringCenteredScaledMaxWidth("Add", Minecraft.getMinecraft().fontRendererObj, - x + width / 6, y + 45 - 7 - 6, - false, 44, 0xFF303030 - ); + TextRenderUtils.drawStringCenteredScaledMaxWidth("Add", x + width / 6, y + 45 - 7 - 6, false, 44, 0xFF303030); long currentTime = System.currentTimeMillis(); if (trashHoverTime < 0) { @@ -128,7 +124,8 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor { if (i++ != dragStartIndex) { for (int multilineIndex = 0; multilineIndex < multilines.length; multilineIndex++) { String line = multilines[multilineIndex]; - Utils.drawStringScaledMaxWidth(line + EnumChatFormatting.RESET, Minecraft.getMinecraft().fontRendererObj, + Utils.drawStringScaledMaxWidth( + line + EnumChatFormatting.RESET, x + 20, y + 50 + yOff + multilineIndex * 10, true, width - 20, 0xffffffff ); } @@ -156,7 +153,6 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor { } remaining.removeAll(activeText); - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; int dropdownWidth = Math.min(width / 2 - 10, 150); int left = dragOffsetX; int top = dragOffsetY; @@ -184,7 +180,7 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor { str = "<NONE>"; } TextRenderUtils.drawStringScaledMaxWidth(str.replaceAll("(\n.*)+", " ..."), - fr, left + 3, top + 3 + dropdownY, false, dropdownWidth - 6, 0xffa0a0a0 + left + 3, top + 3 + dropdownY, false, dropdownWidth - 6, 0xffa0a0a0 ); dropdownY += 12; } @@ -215,7 +211,6 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor { String line = multilines[multilineIndex]; Utils.drawStringScaledMaxWidth( line + EnumChatFormatting.RESET, - Minecraft.getMinecraft().fontRendererObj, dragOffsetX + mouseX + 10, dragOffsetY + mouseY + multilineIndex * 10, true, diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDropdown.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDropdown.java index af6af277..115b502e 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDropdown.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDropdown.java @@ -22,8 +22,6 @@ package io.github.moulberry.notenoughupdates.core.config.gui; import io.github.moulberry.notenoughupdates.core.config.struct.ConfigProcessor; import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; import io.github.moulberry.notenoughupdates.core.util.render.TextRenderUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.Gui; import net.minecraft.client.renderer.GlStateManager; import org.lwjgl.input.Mouse; @@ -54,7 +52,6 @@ public class GuiOptionEditorDropdown extends GuiOptionEditor { if (!open) { int height = getHeight(); - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; int dropdownWidth = Math.min(width / 3 - 10, 80); int left = x + width / 6 - dropdownWidth / 2; int top = y + height - 7 - 14; @@ -67,7 +64,6 @@ public class GuiOptionEditorDropdown extends GuiOptionEditor { RenderUtils.drawFloatingRectDark(left, top, dropdownWidth, 14, false); TextRenderUtils.drawStringScaled( "\u25BC", - fr, left + dropdownWidth - 10, y + height - 7 - 15, false, @@ -75,9 +71,9 @@ public class GuiOptionEditorDropdown extends GuiOptionEditor { 2 ); - TextRenderUtils.drawStringScaledMaxWidth(selectedString, fr, left + 3, top + 3, false, - dropdownWidth - 16, 0xffa0a0a0 - ); + TextRenderUtils.drawStringScaledMaxWidth( + selectedString, + left + 3, top + 3, false, dropdownWidth - 16, 0xffa0a0a0); } } @@ -91,7 +87,6 @@ public class GuiOptionEditorDropdown extends GuiOptionEditor { int height = getHeight(); - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; int dropdownWidth = Math.min(width / 3 - 10, 80); int left = x + width / 6 - dropdownWidth / 2; int top = y + height - 7 - 14; @@ -117,28 +112,16 @@ public class GuiOptionEditorDropdown extends GuiOptionEditor { } TextRenderUtils.drawStringScaledMaxWidth( option, - fr, - left + 3, - top + 3 + dropdownY, - false, - dropdownWidth - 6, - 0xffa0a0a0 + left + 3, top + 3 + dropdownY, false, dropdownWidth - 6, 0xffa0a0a0 ); dropdownY += 12; } - TextRenderUtils.drawStringScaled( - "\u25B2", - fr, - left + dropdownWidth - 10, - y + height - 7 - 15, - false, - 0xffa0a0a0, - 2 - ); + TextRenderUtils.drawStringScaled("\u25B2", left + dropdownWidth - 10, y + height - 7 - 15, false, 0xffa0a0a0, 2); - TextRenderUtils.drawStringScaledMaxWidth(selectedString, fr, left + 3, top + 3, false, - dropdownWidth - 16, 0xffa0a0a0 + TextRenderUtils.drawStringScaledMaxWidth( + selectedString, + left + 3, top + 3, false, dropdownWidth - 16, 0xffa0a0a0 ); GlStateManager.popMatrix(); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorFSR.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorFSR.java index 048e261e..db788b95 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorFSR.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorFSR.java @@ -54,9 +54,9 @@ public class GuiOptionEditorFSR extends GuiOptionEditor { RenderUtils.drawTexturedRect(x + width / 6 - 24, y + height - 7 - 14, 48, 16); if (buttonText != null) { - TextRenderUtils.drawStringCenteredScaledMaxWidth(buttonText, Minecraft.getMinecraft().fontRendererObj, - x + width / 6, y + height - 7 - 6, - false, 44, 0xFF303030 + TextRenderUtils.drawStringCenteredScaledMaxWidth( + buttonText, + x + width / 6, y + height - 7 - 6, false, 44, 0xFF303030 ); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorKeybind.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorKeybind.java index b7d70db8..ffad3bc0 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorKeybind.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorKeybind.java @@ -59,11 +59,7 @@ public class GuiOptionEditorKeybind extends GuiOptionEditor { String keyName = KeybindHelper.getKeyName(getKeyCode()); String text = editingKeycode ? "> " + keyName + " <" : keyName; - TextRenderUtils.drawStringCenteredScaledMaxWidth(text, - Minecraft.getMinecraft().fontRendererObj, - x + width / 6, y + height - 7 - 6, - false, 40, 0xFF303030 - ); + TextRenderUtils.drawStringCenteredScaledMaxWidth(text, x + width / 6, y + height - 7 - 6, false, 40, 0xFF303030); Minecraft.getMinecraft().getTextureManager().bindTexture(RESET); GlStateManager.color(1, 1, 1, 1); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java index 1b71e3ce..c7dced22 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java @@ -135,10 +135,9 @@ public class GuiPositionEditor extends GuiScreen { if (position.isCenterY()) y -= elementHeight / 2; Gui.drawRect(x, y, x + elementWidth, y + elementHeight, 0x80404040); - Utils.drawStringCentered("Position Editor", Minecraft.getMinecraft().fontRendererObj, - scaledResolution.getScaledWidth() / 2, 8, true, 0xffffff - ); - Utils.drawStringCentered("R to Reset - Arrow keys/mouse to move", Minecraft.getMinecraft().fontRendererObj, + Utils.drawStringCentered("Position Editor", scaledResolution.getScaledWidth() / 2, 8, true, 0xffffff); + Utils.drawStringCentered( + "R to Reset - Arrow keys/mouse to move", scaledResolution.getScaledWidth() / 2, 18, true, 0xffffff ); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditorButForTheDungeonMap.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditorButForTheDungeonMap.java index b334418c..9f2088ed 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditorButForTheDungeonMap.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditorButForTheDungeonMap.java @@ -106,12 +106,10 @@ public class GuiPositionEditorButForTheDungeonMap extends GuiScreen { // nea is } scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - Utils.drawStringCentered("Position Editor", Minecraft.getMinecraft().fontRendererObj, - scaledResolution.getScaledWidth() / 2, 8, true, 0xffffff - ); - Utils.drawStringCentered("R to Reset - Arrow keys/mouse to move", Minecraft.getMinecraft().fontRendererObj, - scaledResolution.getScaledWidth() / 2, 18, true, 0xffffff - ); + Utils.drawStringCentered("Position Editor", scaledResolution.getScaledWidth() / 2, 8, true, 0xffffff); + Utils.drawStringCentered( + "R to Reset - Arrow keys/mouse to move", + scaledResolution.getScaledWidth() / 2, 18, true, 0xffffff); } @Override diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/struct/GuiOptionEditorBlocked.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/struct/GuiOptionEditorBlocked.java index 8415cf72..11112782 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/struct/GuiOptionEditorBlocked.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/struct/GuiOptionEditorBlocked.java @@ -56,7 +56,6 @@ public class GuiOptionEditorBlocked extends GuiOptionEditor { TextRenderUtils.drawStringScaledMaxWidth( "This option is currently not available.", - mc.fontRendererObj, x + iconWidth,y + getHeight() / 2F - mc.fontRendererObj.FONT_HEIGHT / 2F, true, (int) (width - iconWidth), 0xFFFF4444 ); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/util/ArrowPagesUtils.java b/src/main/java/io/github/moulberry/notenoughupdates/core/util/ArrowPagesUtils.java index 1e70db7f..e9bff8f6 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/util/ArrowPagesUtils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/util/ArrowPagesUtils.java @@ -21,7 +21,6 @@ package io.github.moulberry.notenoughupdates.core.util; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; @@ -92,9 +91,8 @@ public class ArrowPagesUtils { String selectedPage = (currentPage + 1) + "/" + totalPages; - FontRenderer fontRendererObj = Minecraft.getMinecraft().fontRendererObj; - Utils.drawStringCenteredScaledMaxWidth(selectedPage, fontRendererObj, - guiLeft + pageStringX, guiTop + pageStringY, false, 28, Color.BLACK.getRGB() + Utils.drawStringCenteredScaledMaxWidth( + selectedPage, guiLeft + pageStringX, guiTop + pageStringY, false, 28, Color.BLACK.getRGB() ); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/TextRenderUtils.java b/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/TextRenderUtils.java index cee38cea..336dcb67 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/TextRenderUtils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/TextRenderUtils.java @@ -67,6 +67,18 @@ public class TextRenderUtils { public static void drawStringScaledMaxWidth( String str, + float x, + float y, + boolean shadow, + int len, + int colour + ) { + drawStringScaledMaxWidth(str, Minecraft.getMinecraft().fontRendererObj, x, y, shadow, len, colour); + } + + @Deprecated + public static void drawStringScaledMaxWidth( + String str, FontRenderer fr, float x, float y, @@ -78,7 +90,7 @@ public class TextRenderUtils { float factor = len / (float) strLen; factor = Math.min(1, factor); - drawStringScaled(str, fr, x, y, shadow, colour, factor); + drawStringScaled(str, x, y, shadow, colour, factor); } public static void drawStringCentered(String str, FontRenderer fr, float x, float y, boolean shadow, int colour) { @@ -94,7 +106,19 @@ public class TextRenderUtils { public static void drawStringScaled( String str, - FontRenderer fr, + float x, + float y, + boolean shadow, + int colour, + float factor + ) { + drawStringScaled(str, Minecraft.getMinecraft().fontRendererObj, x, y, shadow, colour, factor); + } + + @Deprecated + public static void drawStringScaled( + String str, + FontRenderer fr, float x, float y, boolean shadow, @@ -108,6 +132,18 @@ public class TextRenderUtils { public static void drawStringCenteredScaledMaxWidth( String str, + float x, + float y, + boolean shadow, + int len, + int colour + ) { + drawStringCenteredScaledMaxWidth(str, Minecraft.getMinecraft().fontRendererObj, x, y, shadow, len, colour); + } + + @Deprecated + public static void drawStringCenteredScaledMaxWidth( + String str, FontRenderer fr, float x, float y, @@ -122,7 +158,7 @@ public class TextRenderUtils { float fontHeight = 8 * factor; - drawStringScaled(str, fr, x - newLen / 2, y - fontHeight / 2, shadow, colour, factor); + drawStringScaled(str, x - newLen / 2, y - fontHeight / 2, shadow, colour, factor); } public static void renderToolTip( diff --git a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java index 4a7c1939..984a7931 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java @@ -150,7 +150,7 @@ public class CapeManager { NotEnoughUpdates.INSTANCE.manager.apiUtils .newMoulberryRequest("activecapes.json") .requestJson() - .thenAccept(jsonObject -> { + .thenAcceptAsync(jsonObject -> { if (jsonObject.get("success").getAsBoolean()) { lastJsonSync = jsonObject; @@ -171,7 +171,7 @@ public class CapeManager { NotEnoughUpdates.INSTANCE.manager.apiUtils .newMoulberryRequest("permscapes.json") .requestJson() - .thenAccept(jsonObject -> { + .thenAcceptAsync(jsonObject -> { if (!jsonObject.get("success").getAsBoolean()) return; permSyncTries = 0; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/GuiCosmetics.java b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/GuiCosmetics.java index 12d8c92d..cacae83b 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/GuiCosmetics.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/GuiCosmetics.java @@ -134,17 +134,7 @@ public class GuiCosmetics extends GuiScreen { for (String line : cosmeticsInfoTooltip) { grayTooltip.add(EnumChatFormatting.GRAY + line); } - Utils.drawHoveringText( - grayTooltip, - mouseX, - mouseY, - width, - height, - -1, - Minecraft.getMinecraft().fontRendererObj - ); - - } + Utils.drawHoveringText(grayTooltip, mouseX, mouseY, width, height, -1);} } StringBuilder statusMsg = new StringBuilder("Last Sync: "); @@ -193,9 +183,7 @@ public class GuiCosmetics extends GuiScreen { equipMsg += " - " + (20 - (System.currentTimeMillis() - lastCapeEquip) / 1000) + "s"; } - Utils.drawStringCenteredScaledMaxWidth(equipMsg, Minecraft.getMinecraft().fontRendererObj, - guiLeft + sizeX / 2f, guiTop + sizeY + 5 + 10, false, 90, 0 - ); + Utils.drawStringCenteredScaledMaxWidth(equipMsg, guiLeft + sizeX / 2f, guiTop + sizeY + 5 + 10, false, 90, 0); } if (unlockTextField.getFocus() || !unlockTextField.getText().isEmpty()) { @@ -529,7 +517,6 @@ public class GuiCosmetics extends GuiScreen { Utils.drawStringCenteredScaledMaxWidth( "Try it out", - Minecraft.getMinecraft().fontRendererObj, guiLeft + 20 + 91 * displayIndex + 81 / 2f - xOffset, guiTop + 123 + 10, false, @@ -539,7 +526,6 @@ public class GuiCosmetics extends GuiScreen { if (equipable) { Utils.drawStringCenteredScaledMaxWidth( "Equip", - Minecraft.getMinecraft().fontRendererObj, guiLeft + 20 + 91 * displayIndex + 81 / 2f - xOffset, guiTop + 149 + 10, false, @@ -549,7 +535,6 @@ public class GuiCosmetics extends GuiScreen { } else { Utils.drawStringCenteredScaledMaxWidth( "Not Unlocked", - Minecraft.getMinecraft().fontRendererObj, guiLeft + 20 + 91 * displayIndex + 81 / 2f - xOffset, guiTop + 149 + 10, false, diff --git a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonWin.java b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonWin.java index a56a5679..5b476c93 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonWin.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonWin.java @@ -218,8 +218,8 @@ public class DungeonWin { if (hideChat) { if (text.size() > 50) text.clear(); - e.setCanceled(true); if (unformatted.contains("\u25AC")) { + e.setCanceled(true); hideChat = false; displayWin(); } else { @@ -229,12 +229,15 @@ public class DungeonWin { "Total Damage") || unformatted.contains("Ally Healing") || unformatted.contains("Enemies Killed") || unformatted.contains( "Deaths") || unformatted.contains("Secrets Found")) { + e.setCanceled(true); text.add(e.message.getFormattedText().substring(6).trim()); - } else { + } else if (unformatted.trim().length() > 6) { System.out.println( "These messages would of showed on neu dungeon overlay but didnt, They are either bugged or i missed them: \"" + e.message.getFormattedText().substring(6).trim() + "\""); } + } else { + e.setCanceled(true); } } } else { @@ -281,7 +284,6 @@ public class DungeonWin { if (Math.abs(xOff) != Math.abs(yOff)) { Utils.drawStringCentered( Utils.cleanColourNotModifiers(line), - Minecraft.getMinecraft().fontRendererObj, sr.getScaledWidth() / 2 + xOff / 2f, textCenterY + yOff / 2f, false, @@ -292,9 +294,7 @@ public class DungeonWin { } } - Utils.drawStringCentered(line, Minecraft.getMinecraft().fontRendererObj, - sr.getScaledWidth() / 2, textCenterY, false, (textAlpha << 24) | 0x00FFFFFF - ); + Utils.drawStringCentered(line, sr.getScaledWidth() / 2, textCenterY, false, (textAlpha << 24) | 0x00FFFFFF); } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java index 025e11b2..dfd0405b 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java @@ -145,7 +145,6 @@ public class GuiDungeonMapEditor extends GuiScreen { if (text.length() > 0) { Utils.drawStringCenteredScaledMaxWidth( text, - Minecraft.getMinecraft().fontRendererObj, guiLeft + x + 24, guiTop + y + 8, false, @@ -379,64 +378,30 @@ public class GuiDungeonMapEditor extends GuiScreen { Minecraft.getMinecraft().fontRendererObj.drawString("NEU Dungeon Map Editor", guiLeft + 8, guiTop + 6, 0xFFB4B4B4); - Utils.drawStringCenteredScaledMaxWidth("Border Size", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 76, guiTop + 30, false, 137, 0xFFB4B4B4 - ); - Utils.drawStringCenteredScaledMaxWidth("Rooms Size", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 76, guiTop + 60, false, 137, 0xFFB4B4B4 - ); - Utils.drawStringCenteredScaledMaxWidth("Icon Scale", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 76, guiTop + 90, false, 137, 0xFFB4B4B4 - ); - Utils.drawStringCenteredScaledMaxWidth("Border Style", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 76, guiTop + 120, false, 137, 0xFFB4B4B4 - ); + Utils.drawStringCenteredScaledMaxWidth("Border Size", guiLeft + 76, guiTop + 30, false, 137, 0xFFB4B4B4); + Utils.drawStringCenteredScaledMaxWidth("Rooms Size", guiLeft + 76, guiTop + 60, false, 137, 0xFFB4B4B4); + Utils.drawStringCenteredScaledMaxWidth("Icon Scale", guiLeft + 76, guiTop + 90, false, 137, 0xFFB4B4B4); + Utils.drawStringCenteredScaledMaxWidth("Border Style", guiLeft + 76, guiTop + 120, false, 137, 0xFFB4B4B4); - Utils.drawStringCenteredScaledMaxWidth("Dungeon Map", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 44 + 139, guiTop + 30, false, 60, 0xFFB4B4B4 - ); - Utils.drawStringCenteredScaledMaxWidth("Center", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 108 + 139, guiTop + 30, false, 60, 0xFFB4B4B4 - ); + Utils.drawStringCenteredScaledMaxWidth("Dungeon Map", guiLeft + 44 + 139, guiTop + 30, false, 60, 0xFFB4B4B4); + Utils.drawStringCenteredScaledMaxWidth("Center", guiLeft + 108 + 139, guiTop + 30, false, 60, 0xFFB4B4B4); - Utils.drawStringCenteredScaledMaxWidth("Rotate", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 44 + 139, guiTop + 59, false, 60, 0xFFB4B4B4 - ); - Utils.drawStringCenteredScaledMaxWidth("Icon Style", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 108 + 139, guiTop + 59, false, 60, 0xFFB4B4B4 - ); + Utils.drawStringCenteredScaledMaxWidth("Rotate", guiLeft + 44 + 139, guiTop + 59, false, 60, 0xFFB4B4B4); + Utils.drawStringCenteredScaledMaxWidth("Icon Style", guiLeft + 108 + 139, guiTop + 59, false, 60, 0xFFB4B4B4); - Utils.drawStringCenteredScaledMaxWidth("Check Orient", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 44 + 139, guiTop + 88, false, 60, 0xFFB4B4B4 - ); - Utils.drawStringCenteredScaledMaxWidth("Check Center", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 108 + 139, guiTop + 88, false, 60, 0xFFB4B4B4 - ); + Utils.drawStringCenteredScaledMaxWidth("Check Orient", guiLeft + 44 + 139, guiTop + 88, false, 60, 0xFFB4B4B4); + Utils.drawStringCenteredScaledMaxWidth("Check Center", guiLeft + 108 + 139, guiTop + 88, false, 60, 0xFFB4B4B4); - Utils.drawStringCenteredScaledMaxWidth("Interpolation", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 44 + 139, guiTop + 117, false, 60, 0xFFB4B4B4 - ); - Utils.drawStringCenteredScaledMaxWidth("Compatibility", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 108 + 139, guiTop + 117, false, 60, 0xFFB4B4B4 - ); + Utils.drawStringCenteredScaledMaxWidth("Interpolation", guiLeft + 44 + 139, guiTop + 117, false, 60, 0xFFB4B4B4); + Utils.drawStringCenteredScaledMaxWidth("Compatibility", guiLeft + 108 + 139, guiTop + 117, false, 60, 0xFFB4B4B4); - Utils.drawStringCenteredScaledMaxWidth("Background", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 44 + 139, guiTop + 146, false, 60, 0xFFB4B4B4 - ); - Utils.drawStringCenteredScaledMaxWidth("Border", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 108 + 139, guiTop + 146, false, 60, 0xFFB4B4B4 - ); + Utils.drawStringCenteredScaledMaxWidth("Background", guiLeft + 44 + 139, guiTop + 146, false, 60, 0xFFB4B4B4); + Utils.drawStringCenteredScaledMaxWidth("Border", guiLeft + 108 + 139, guiTop + 146, false, 60, 0xFFB4B4B4); - Utils.drawStringCenteredScaledMaxWidth("BG Blur", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 44 + 139, guiTop + 175, false, 60, 0xFFB4B4B4 - ); - Utils.drawStringCenteredScaledMaxWidth("Chroma Type", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 108 + 139, guiTop + 175, false, 60, 0xFFB4B4B4 - ); + Utils.drawStringCenteredScaledMaxWidth("BG Blur", guiLeft + 44 + 139, guiTop + 175, false, 60, 0xFFB4B4B4); + Utils.drawStringCenteredScaledMaxWidth("Chroma Type", guiLeft + 108 + 139, guiTop + 175, false, 60, 0xFFB4B4B4); - Utils.drawStringCenteredScaledMaxWidth("Edit Map Position", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 76, guiTop + 209, false, 200, 0xFFB4B4B4 - ); + Utils.drawStringCenteredScaledMaxWidth("Edit Map Position", guiLeft + 76, guiTop + 209, false, 200, 0xFFB4B4B4); try { drawSlider(DungeonMapConfig.class.getDeclaredField("dmBorderSize"), guiLeft + 76, guiTop + 45); @@ -468,9 +433,7 @@ public class GuiDungeonMapEditor extends GuiScreen { GlStateManager.color(1, 1, 1, 1); Minecraft.getMinecraft().getTextureManager().bindTexture(button_tex); RenderUtils.drawTexturedRect(guiLeft + 52, guiTop + 215, 48, 16); - TextRenderUtils.drawStringCenteredScaledMaxWidth("Edit", fontRendererObj, guiLeft + 76, guiTop + 223, - false, 48, 0xFF303030 - ); + TextRenderUtils.drawStringCenteredScaledMaxWidth("Edit", guiLeft + 76, guiTop + 223, false, 48, 0xFF303030); Map<String, Vec4b> decorations = new HashMap<>(); Vec4b vec4b = new Vec4b((byte) 3, (byte) (((50) - 64) * 2), (byte) (((40) - 64) * 2), (byte) ((60) * 16 / 360)); @@ -495,8 +458,7 @@ public class GuiDungeonMapEditor extends GuiScreen { mouseY, width, height, - 200, - Minecraft.getMinecraft().fontRendererObj + 200 ); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/envcheck/NEUMixinConfigPlugin.java b/src/main/java/io/github/moulberry/notenoughupdates/envcheck/NEUMixinConfigPlugin.java index 44e24ff4..1d12813c 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/envcheck/NEUMixinConfigPlugin.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/envcheck/NEUMixinConfigPlugin.java @@ -1,5 +1,6 @@ package io.github.moulberry.notenoughupdates.envcheck; +import io.github.moulberry.notenoughupdates.miscgui.DynamicLightItemsEditor; import org.spongepowered.asm.lib.tree.ClassNode; import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; import org.spongepowered.asm.mixin.extensibility.IMixinInfo; @@ -42,5 +43,8 @@ public class NEUMixinConfigPlugin implements IMixinConfigPlugin { @Override public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + if ("io.github.moulberry.notenoughupdates.mixins.MixinOFDynamicLights".equals(mixinClassName)) { + DynamicLightItemsEditor.setDidApplyMixin(true); + } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/MinecraftExecutor.java b/src/main/java/io/github/moulberry/notenoughupdates/events/GuiContainerBackgroundDrawnEvent.java index bf973b76..bdb6d1a1 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/MinecraftExecutor.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/events/GuiContainerBackgroundDrawnEvent.java @@ -17,21 +17,13 @@ * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. */ -package io.github.moulberry.notenoughupdates.util; +package io.github.moulberry.notenoughupdates.events; -import net.minecraft.client.Minecraft; -import org.jetbrains.annotations.NotNull; +import lombok.Value; +import net.minecraft.client.gui.inventory.GuiContainer; -import java.util.concurrent.Executor; - -public class MinecraftExecutor implements Executor { - - public static MinecraftExecutor INSTANCE = new MinecraftExecutor(); - - private MinecraftExecutor() {} - - @Override - public void execute(@NotNull Runnable runnable) { - Minecraft.getMinecraft().addScheduledTask(runnable); - } +@Value +public class GuiContainerBackgroundDrawnEvent extends NEUEvent { + public GuiContainer container; + public float partialTicks; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/FlipperInfoPane.java b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/FlipperInfoPane.java index 4b6c73f4..a8df8d1f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/FlipperInfoPane.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/FlipperInfoPane.java @@ -121,7 +121,6 @@ public class FlipperInfoPane extends InfoPane { } private int renderParagraph(int width, int height, int startY, String text, Color bg) { - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; int paneWidth = (int) (width / 3 * overlay.getWidthMult()); int rightSide = (int) (width * overlay.getInfoPaneOffsetFactor()); @@ -129,7 +128,7 @@ public class FlipperInfoPane extends InfoPane { int yOff = 0; for (String line : text.split("\n")) { - yOff += Utils.renderStringTrimWidth(line, fr, false, leftSide + overlay.getBoxPadding() + 5, + yOff += Utils.renderStringTrimWidth(line, false, leftSide + overlay.getBoxPadding() + 5, startY + overlay.getBoxPadding() + 10 + yOff, width * 1 / 3 - overlay.getBoxPadding() * 2 - 10, Color.WHITE.getRGB(), -1 ); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/TextInfoPane.java b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/TextInfoPane.java index 90bed1fa..37e9e4d7 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/TextInfoPane.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/TextInfoPane.java @@ -61,7 +61,7 @@ public class TextInfoPane extends ScrollableInfoPane { int yOff = 20; for (String line : text.split("\n")) { - yOff += Utils.renderStringTrimWidth(line, fr, false, leftSide + overlay.getBoxPadding() + 5, + yOff += Utils.renderStringTrimWidth(line, false, leftSide + overlay.getBoxPadding() + 5, yScroll + overlay.getBoxPadding() + 10 + yOff, width * 1 / 3 - overlay.getBoxPadding() * 2 - 10, Color.WHITE.getRGB(), -1 ); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementTextField.java b/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementTextField.java index 7cc96d42..cf4edb76 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementTextField.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementTextField.java @@ -123,7 +123,7 @@ public class GuiElementTextField extends GuiElement { } private float getScaleFactor(String str) { - return Math.min(1, (searchBarXSize - 2) / (float) Minecraft.getMinecraft().fontRendererObj.getStringWidth(str)); + return Math.min(1, (searchBarXSize - 2) / (float) getStringWidth0(str)); } private boolean isScaling() { @@ -132,12 +132,16 @@ public class GuiElementTextField extends GuiElement { private float getStringWidth(String str) { if (isScaling()) { - return Minecraft.getMinecraft().fontRendererObj.getStringWidth(str) * getScaleFactor(str); + return getStringWidth0(str) * getScaleFactor(str); } else { - return Minecraft.getMinecraft().fontRendererObj.getStringWidth(str); + return getStringWidth0(str); } } + private static int getStringWidth0(String str) { + return Minecraft.getMinecraft().fontRendererObj.getStringWidth(str); + } + public int getCursorPos(int mouseX, int mouseY) { int xComp = mouseX - x; int yComp = mouseY - y; @@ -188,7 +192,7 @@ public class GuiElementTextField extends GuiElement { int linePos = strLenNoColor(trimmed); if (linePos != strLenNoColor(line)) { char after = line.charAt(linePos); - int trimmedWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(trimmed); + int trimmedWidth = getStringWidth0(trimmed); int charWidth = Minecraft.getMinecraft().fontRendererObj.getCharWidth(after); if (trimmedWidth + charWidth / 2 < xComp - padding) { linePos++; @@ -304,7 +308,7 @@ public class GuiElementTextField extends GuiElement { } else if (split.length > 1) { thisLineBeforeCursor = split[split.length - 1]; lineBefore = split[split.length - 2]; - textBeforeCursorWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(thisLineBeforeCursor); + textBeforeCursorWidth = getStringWidth0(thisLineBeforeCursor); } else { return; } @@ -313,7 +317,7 @@ public class GuiElementTextField extends GuiElement { int linePos = strLenNoColor(trimmed); if (linePos != strLenNoColor(lineBefore)) { char after = lineBefore.charAt(linePos); - int trimmedWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(trimmed); + int trimmedWidth = getStringWidth0(trimmed); int charWidth = Minecraft.getMinecraft().fontRendererObj.getCharWidth(after); if (trimmedWidth + charWidth / 2 < textBeforeCursorWidth) { linePos++; @@ -342,7 +346,7 @@ public class GuiElementTextField extends GuiElement { textBeforeCursorWidth = 0; } else if (split.length > 0) { thisLineBeforeCursor = split[split.length - 1]; - textBeforeCursorWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(thisLineBeforeCursor); + textBeforeCursorWidth = getStringWidth0(thisLineBeforeCursor); } else { return; } @@ -355,7 +359,7 @@ public class GuiElementTextField extends GuiElement { int linePos = strLenNoColor(trimmed); if (linePos != strLenNoColor(lineAfter)) { char after = lineAfter.charAt(linePos); - int trimmedWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(trimmed); + int trimmedWidth = getStringWidth0(trimmed); int charWidth = Minecraft.getMinecraft().fontRendererObj.getCharWidth(after); if (trimmedWidth + charWidth / 2 < textBeforeCursorWidth) { linePos++; @@ -468,15 +472,14 @@ public class GuiElementTextField extends GuiElement { for (int yOffI = 0; yOffI < texts.length; yOffI++) { int yOff = yOffI * extraSize; - if (isScaling() && Minecraft.getMinecraft().fontRendererObj.getStringWidth(texts[yOffI]) > searchBarXSize - 10) { - scale = (searchBarXSize - 2) / (float) Minecraft.getMinecraft().fontRendererObj.getStringWidth(texts[yOffI]); + if (isScaling() && getStringWidth0(texts[yOffI]) > searchBarXSize - 10) { + scale = (searchBarXSize - 2) / (float) getStringWidth0(texts[yOffI]); if (scale > 1) scale = 1; - float newLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(texts[yOffI]) * scale; + float newLen = getStringWidth0(texts[yOffI]) * scale; xStartOffset = (int) ((searchBarXSize - newLen) / 2f); Utils.drawStringCenteredScaledMaxWidth( texts[yOffI], - Minecraft.getMinecraft().fontRendererObj, x + searchBarXSize / 2f, y + searchBarYSize / 2f + yOff, false, @@ -506,7 +509,7 @@ public class GuiElementTextField extends GuiElement { if (split.length <= numLinesBeforeCursor || split.length == 0) { textBeforeCursorWidth = 0; } else { - textBeforeCursorWidth = (int) (Minecraft.getMinecraft().fontRendererObj.getStringWidth(split[split.length - + textBeforeCursorWidth = (int) (getStringWidth0(split[split.length - 1]) * scale); } drawRect(x + xStartOffset + textBeforeCursorWidth, @@ -557,7 +560,7 @@ public class GuiElementTextField extends GuiElement { continue; } - int len = Minecraft.getMinecraft().fontRendererObj.getStringWidth(String.valueOf(c)); + int len = getStringWidth0(String.valueOf(c)); if (bold) len++; if (i >= leftIndex && i < rightIndex) { drawRect(x + xStartOffset + (int) texX, @@ -566,12 +569,12 @@ public class GuiElementTextField extends GuiElement { y + (searchBarYSize - 8) / 2 + 9 + texY, Color.LIGHT_GRAY.getRGB() ); - Utils.drawStringScaled(String.valueOf(c), Minecraft.getMinecraft().fontRendererObj, + Utils.drawStringScaled(String.valueOf(c), x + xStartOffset + texX, y + searchBarYSize / 2f - scale * 8 / 2f + texY, false, Color.BLACK.getRGB(), scale ); if (bold) { - Utils.drawStringScaled(String.valueOf(c), Minecraft.getMinecraft().fontRendererObj, + Utils.drawStringScaled(String.valueOf(c), x + xStartOffset + texX + 1, y + searchBarYSize / 2f - scale * 8 / 2f + texY, false, Color.BLACK.getRGB(), scale ); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/NEUItemEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/NEUItemEditor.java index e08e5369..041843ae 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/NEUItemEditor.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/NEUItemEditor.java @@ -370,9 +370,7 @@ public class NEUItemEditor extends GuiScreen { text.add(displayName.get()); text.addAll(Arrays.asList(lore.get().split("\n"))); - Utils.drawHoveringText(text, itemX - 20, itemY + itemSize + 28, width, height, -1, - Minecraft.getMinecraft().fontRendererObj - ); + Utils.drawHoveringText(text, itemX - 20, itemY + itemSize + 28, width, height, -1); GlStateManager.disableLighting(); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java index f15a26a7..5e39aa45 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java @@ -26,16 +26,15 @@ import io.github.moulberry.notenoughupdates.NEUApi; import io.github.moulberry.notenoughupdates.NEUOverlay; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.auction.CustomAHGui; -import io.github.moulberry.notenoughupdates.commands.profile.ViewProfileCommand; import io.github.moulberry.notenoughupdates.core.GuiScreenElementWrapper; import io.github.moulberry.notenoughupdates.dungeons.DungeonWin; +import io.github.moulberry.notenoughupdates.events.ButtonExclusionZoneEvent; import io.github.moulberry.notenoughupdates.miscfeatures.AbiphoneWarning; import io.github.moulberry.notenoughupdates.miscfeatures.AuctionBINWarning; -import io.github.moulberry.notenoughupdates.miscfeatures.AuctionProfit; import io.github.moulberry.notenoughupdates.miscfeatures.BetterContainers; import io.github.moulberry.notenoughupdates.miscfeatures.CrystalMetalDetectorSolver; -import io.github.moulberry.notenoughupdates.miscfeatures.DungeonNpcProfitOverlay; import io.github.moulberry.notenoughupdates.miscfeatures.EnchantingSolvers; +import io.github.moulberry.notenoughupdates.miscfeatures.PresetWarning; import io.github.moulberry.notenoughupdates.miscfeatures.StorageManager; import io.github.moulberry.notenoughupdates.miscfeatures.dev.RepoExporters; import io.github.moulberry.notenoughupdates.miscgui.AccessoryBagOverlay; @@ -45,20 +44,18 @@ import io.github.moulberry.notenoughupdates.miscgui.GuiInvButtonEditor; import io.github.moulberry.notenoughupdates.miscgui.GuiItemRecipe; import io.github.moulberry.notenoughupdates.miscgui.StorageOverlay; import io.github.moulberry.notenoughupdates.miscgui.TradeWindow; -import io.github.moulberry.notenoughupdates.miscgui.TrophyRewardOverlay; import io.github.moulberry.notenoughupdates.miscgui.hex.GuiCustomHex; -import io.github.moulberry.notenoughupdates.miscgui.minionhelper.MinionHelperManager; import io.github.moulberry.notenoughupdates.mixins.AccessorGuiContainer; import io.github.moulberry.notenoughupdates.options.NEUConfig; import io.github.moulberry.notenoughupdates.overlays.AuctionSearchOverlay; import io.github.moulberry.notenoughupdates.overlays.BazaarSearchOverlay; -import io.github.moulberry.notenoughupdates.overlays.EquipmentOverlay; 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.ItemUtils; import io.github.moulberry.notenoughupdates.util.NotificationHandler; +import io.github.moulberry.notenoughupdates.util.Rectangle; import io.github.moulberry.notenoughupdates.util.SBInfo; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; @@ -105,6 +102,7 @@ import java.util.Map; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; +import java.util.function.BiConsumer; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -484,96 +482,68 @@ public class RenderListener { if (CalendarOverlay.isEnabled() || event.isCanceled()) return; if (NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && NotificationHandler.shouldRenderOverlay(event.gui) && event.gui instanceof GuiContainer) { - doInventoryButtons = true; - - int zOffset = 50; - - GlStateManager.translate(0, 0, zOffset); - - int xSize = ((AccessorGuiContainer) event.gui).getXSize(); - int ySize = ((AccessorGuiContainer) event.gui).getYSize(); - int guiLeft = ((AccessorGuiContainer) event.gui).getGuiLeft(); - int guiTop = ((AccessorGuiContainer) event.gui).getGuiTop(); + renderButtons((GuiContainer) event.gui); + } + } - if (!NEUApi.disableInventoryButtons) { - if (!EnchantingSolvers.disableButtons()) { - for (NEUConfig.InventoryButton button : NotEnoughUpdates.INSTANCE.config.hidden.inventoryButtons) { - if (!button.isActive()) continue; - if (button.playerInvOnly && !(event.gui instanceof GuiInventory)) continue; + public void iterateButtons(GuiContainer gui, BiConsumer<NEUConfig.InventoryButton, Rectangle> acceptButton) { + if (NEUApi.disableInventoryButtons || EnchantingSolvers.disableButtons()) { + return; + } - int x = guiLeft + button.x; - int y = guiTop + button.y; - if (button.anchorRight) { - x += xSize; - } - if (button.anchorBottom) { - y += ySize; - } - if (AccessoryBagOverlay.isInAccessoryBag()) { - if (x > guiLeft + xSize && x < guiLeft + xSize + 80 + 28 + 5 && y > guiTop - 18 && y < guiTop + 150) { - x += 80 + 28; - } - } - if (TrophyRewardOverlay.inTrophyFishingInventory()) { - int diffX = 162; - if (x > guiLeft + xSize && x < guiLeft + xSize + diffX + 5 && y > guiTop - 18 && y < guiTop + 120) { - x += diffX; - } - } - if (MinionHelperManager.getInstance().inCraftedMinionsInventory()) { - int diffX = 172; - if (x > guiLeft + xSize && x < guiLeft + xSize + diffX + 5 && y > guiTop - 18 && y < guiTop + 128) { - x += diffX; - } - } - if (AuctionProfit.inAuctionPage()) { - if (x + 18 > guiLeft + xSize && x + 18 < guiLeft + xSize + 4 + 28 + 20 && y > guiTop - 180 && - y < guiTop + 56) { - x -= 68 - 200; - } - } - if (EquipmentOverlay.isRenderingArmorHud()) { - if (x < guiLeft + xSize - 150 && x > guiLeft + xSize - 200 && y > guiTop && y < guiTop + 84) { - x -= 25; - } - } - if (EquipmentOverlay.isRenderingPetHud()) { - if (x < guiLeft + xSize - 150 && x > guiLeft + xSize - 200 && y > guiTop + 60 && y < guiTop + 120) { - x -= 25; - } - } - if (inDungeonPage || DungeonNpcProfitOverlay.isRendering()) { - if (x + 10 > guiLeft + xSize && x + 18 < guiLeft + xSize + 4 + 28 + 20 && y > guiTop - 180 && - y < guiTop + 100) { - x += 185; - } - } + AccessorGuiContainer accessor = (AccessorGuiContainer) gui; + Rectangle guiRectangle = new Rectangle( + accessor.getGuiLeft(), + accessor.getGuiTop(), + accessor.getXSize(), + accessor.getYSize() + ); + + ButtonExclusionZoneEvent buttonExclusionZoneEvent = new ButtonExclusionZoneEvent(gui, guiRectangle); + buttonExclusionZoneEvent.post(); + for (NEUConfig.InventoryButton button : NotEnoughUpdates.INSTANCE.config.hidden.inventoryButtons) { + if (!button.isActive()) continue; + if (button.playerInvOnly && !(gui instanceof GuiInventory)) continue; + + Rectangle buttonPosition = buttonExclusionZoneEvent.findButtonPosition(new Rectangle( + accessor.getGuiLeft() + button.x + (button.anchorRight ? accessor.getXSize() : 0), + accessor.getGuiTop() + button.y + (button.anchorBottom ? accessor.getYSize() : 0), + 18, 18 + ) + ); + acceptButton.accept(button, buttonPosition); + } + } - GlStateManager.color(1, 1, 1, 1f); - - GlStateManager.enableDepth(); - GlStateManager.enableAlpha(); - Minecraft.getMinecraft().getTextureManager().bindTexture(EDITOR); - Utils.drawTexturedRect( - x, - y, - 18, - 18, - button.backgroundIndex * 18 / 256f, - (button.backgroundIndex * 18 + 18) / 256f, - 18 / 256f, - 36 / 256f, - GL11.GL_NEAREST - ); + public void renderButtons(GuiContainer gui) { + doInventoryButtons = true; - if (button.icon != null && !button.icon.trim().isEmpty()) { - GuiInvButtonEditor.renderIcon(button.icon, x + 1, y + 1); - } - } - } + int zOffset = 50; + GlStateManager.pushMatrix(); + GlStateManager.translate(0, 0, zOffset); + iterateButtons(gui, (button, buttonPosition) -> { + GlStateManager.color(1, 1, 1, 1f); + GlStateManager.enableDepth(); + GlStateManager.enableAlpha(); + + Minecraft.getMinecraft().getTextureManager().bindTexture(EDITOR); + Utils.drawTexturedRect( + buttonPosition.getX(), + buttonPosition.getY(), + 18, + 18, + button.backgroundIndex * 18 / 256f, + (button.backgroundIndex * 18 + 18) / 256f, + 18 / 256f, + 36 / 256f, + GL11.GL_NEAREST + ); + + if (button.icon != null && !button.icon.trim().isEmpty()) { + GuiInvButtonEditor.renderIcon(button.icon, buttonPosition.getX() + 1, buttonPosition.getY() + 1); } - GlStateManager.translate(0, 0, -zOffset); - } + }); + GlStateManager.popMatrix(); } /** @@ -620,105 +590,50 @@ public class RenderListener { } } - boolean hoveringButton = false; + final boolean[] hoveringButton = {false}; if (!doInventoryButtons) return; if (NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && NotificationHandler.shouldRenderOverlay(event.gui) && event.gui instanceof GuiContainer) { - int xSize = ((AccessorGuiContainer) event.gui).getXSize(); - int ySize = ((AccessorGuiContainer) event.gui).getYSize(); - int guiLeft = ((AccessorGuiContainer) event.gui).getGuiLeft(); - int guiTop = ((AccessorGuiContainer) event.gui).getGuiTop(); - - if (!NEUApi.disableInventoryButtons) { - if (!EnchantingSolvers.disableButtons()) { - for (NEUConfig.InventoryButton button : NotEnoughUpdates.INSTANCE.config.hidden.inventoryButtons) { - if (!button.isActive()) continue; - if (button.playerInvOnly && !(event.gui instanceof GuiInventory)) continue; - - int x = guiLeft + button.x; - int y = guiTop + button.y; - if (button.anchorRight) { - x += xSize; - } - if (button.anchorBottom) { - y += ySize; - } - if (AccessoryBagOverlay.isInAccessoryBag()) { - if (x > guiLeft + xSize && x < guiLeft + xSize + 80 + 28 + 5 && y > guiTop - 18 && y < guiTop + 150) { - x += 80 + 28; - } - } - if (TrophyRewardOverlay.inTrophyFishingInventory()) { - int diffX = 162; - if (x > guiLeft + xSize && x < guiLeft + xSize + diffX + 5 && y > guiTop - 18 && y < guiTop + 120) { - x += diffX; - } - } - if (MinionHelperManager.getInstance().inCraftedMinionsInventory()) { - int diffX = 172; - if (x > guiLeft + xSize && x < guiLeft + xSize + diffX + 5 && y > guiTop - 18 && y < guiTop + 128) { - x += diffX; - } - } - if (AuctionProfit.inAuctionPage()) { - if (x + 18 > guiLeft + xSize && x + 18 < guiLeft + xSize + 4 + 28 + 20 && y > guiTop - 180 && - y < guiTop + 56) { - x -= 68 - 200; - } - } - if (EquipmentOverlay.isRenderingArmorHud()) { - if (x < guiLeft + xSize - 150 && x > guiLeft + xSize - 200 && y > guiTop && y < guiTop + 84) { - x -= 25; - } - } - if (EquipmentOverlay.isRenderingPetHud()) { - if (x < guiLeft + xSize - 150 && x > guiLeft + xSize - 200 && y > guiTop + 60 && y < guiTop + 120) { - x -= 25; - } - } + AccessorGuiContainer acc = (AccessorGuiContainer) event.gui; + Rectangle mousePosition = new Rectangle(event.mouseX, event.mouseY, 0, 0); + Rectangle craftingTextRectangle = new Rectangle(acc.getGuiLeft() + 85, acc.getGuiTop() + 4, 30, 21); + iterateButtons((GuiContainer) guiScreen, (button, buttonPosition) -> { - if (inDungeonPage || DungeonNpcProfitOverlay.isRendering()) { - if (x + 10 > guiLeft + xSize && x + 18 < guiLeft + xSize + 4 + 28 + 20 && y > guiTop - 180 && - y < guiTop + 100) { - x += 185; - } - } + if (buttonPosition.intersects(craftingTextRectangle)) { + disableCraftingText = true; + } - if (x - guiLeft >= 85 && x - guiLeft <= 115 && y - guiTop >= 4 && y - guiTop <= 25) { - disableCraftingText = true; - } + if (!buttonPosition.intersects(mousePosition)) { + return; + } + hoveringButton[0] = true; + long currentTime = System.currentTimeMillis(); - if (event.mouseX >= x && event.mouseX <= x + 18 && event.mouseY >= y && event.mouseY <= y + 18) { - hoveringButton = true; - long currentTime = System.currentTimeMillis(); + if (buttonHovered != button) { + buttonHoveredMillis = currentTime; + buttonHovered = button; + } - if (buttonHovered != button) { - buttonHoveredMillis = currentTime; - buttonHovered = button; - } + if (currentTime - buttonHoveredMillis <= NotEnoughUpdates.INSTANCE.config.inventoryButtons.tooltipDelay) { + return; + } + String command = button.command.trim(); + if (!command.startsWith("/")) { + command = "/" + command; + } - if (currentTime - buttonHoveredMillis > NotEnoughUpdates.INSTANCE.config.inventoryButtons.tooltipDelay) { - String command = button.command.trim(); - if (!command.startsWith("/")) { - command = "/" + command; - } + Utils.drawHoveringText( + Lists.newArrayList("\u00a77" + command), + event.mouseX, + event.mouseY, + event.gui.width, + event.gui.height, + -1 + ); - Utils.drawHoveringText( - Lists.newArrayList("\u00a77" + command), - event.mouseX, - event.mouseY, - event.gui.width, - event.gui.height, - -1, - Minecraft.getMinecraft().fontRendererObj - ); - } - } - } - } - } + }); } - if (!hoveringButton) buttonHovered = null; + if (!hoveringButton[0]) buttonHovered = null; if (AuctionBINWarning.getInstance().shouldShow()) { AuctionBINWarning.getInstance().render(); @@ -727,6 +642,10 @@ public class RenderListener { if (AbiphoneWarning.getInstance().shouldShow()) { AbiphoneWarning.getInstance().render(); } + + if (PresetWarning.getInstance().shouldShow()) { + PresetWarning.getInstance().render(); + } } private void renderDungKuudraChestOverlay(GuiScreen gui) { @@ -966,7 +885,6 @@ public class RenderListener { && NotEnoughUpdates.INSTANCE.config.dungeons.shouldWarningDerpy) { Utils.drawStringScaled( EnumChatFormatting.RED + EnumChatFormatting.BOLD.toString() + "Mayor Derpy active!", - Minecraft.getMinecraft().fontRendererObj, guiLeft + xSize + 4 + 10, guiTop + 85, true, @@ -1012,6 +930,11 @@ public class RenderListener { event.setCanceled(true); return; } + if (PresetWarning.getInstance().shouldShow()) { + PresetWarning.getInstance().mouseInput(mouseX, mouseY); + event.setCanceled(true); + return; + } if (!event.isCanceled()) { Utils.scrollTooltip(Mouse.getEventDWheel()); @@ -1052,7 +975,14 @@ public class RenderListener { if (tag.hasKey("SkullOwner") && tag.getCompoundTag("SkullOwner").hasKey("Name")) { String username = tag.getCompoundTag("SkullOwner").getString("Name"); Utils.playPressSound(); - ViewProfileCommand.RUNNABLE.accept(new String[]{username}); + NotEnoughUpdates.profileViewer.getProfileByName(username, profile -> { + if (profile == null) { + Utils.addChatMessage("${RED}Invalid player name/API key. Maybe the API is down? Try /api new."); + } else { + profile.resetCache(); + NotEnoughUpdates.INSTANCE.openGui = new GuiProfileViewer(profile); + } + }); } } } @@ -1107,85 +1037,28 @@ public class RenderListener { if (!doInventoryButtons) return; if (NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && NotificationHandler.shouldRenderOverlay(event.gui) && Mouse.getEventButton() >= 0 && event.gui instanceof GuiContainer) { - int xSize = ((AccessorGuiContainer) event.gui).getXSize(); - int ySize = ((AccessorGuiContainer) event.gui).getYSize(); - int guiLeft = ((AccessorGuiContainer) event.gui).getGuiLeft(); - int guiTop = ((AccessorGuiContainer) event.gui).getGuiTop(); - if (!NEUApi.disableInventoryButtons) { - if (!EnchantingSolvers.disableButtons()) { - for (NEUConfig.InventoryButton button : NotEnoughUpdates.INSTANCE.config.hidden.inventoryButtons) { - if (!button.isActive()) continue; - if (button.playerInvOnly && !(event.gui instanceof GuiInventory)) continue; - - int x = guiLeft + button.x; - int y = guiTop + button.y; - if (button.anchorRight) { - x += xSize; - } - if (button.anchorBottom) { - y += ySize; - } - if (AccessoryBagOverlay.isInAccessoryBag()) { - if (x > guiLeft + xSize && x < guiLeft + xSize + 80 + 28 + 5 && y > guiTop - 18 && y < guiTop + 150) { - x += 80 + 28; - } - } - if (TrophyRewardOverlay.inTrophyFishingInventory()) { - int diffX = 162; - if (x > guiLeft + xSize && x < guiLeft + xSize + diffX + 5 && y > guiTop - 18 && y < guiTop + 120) { - x += diffX; - } - } - if (MinionHelperManager.getInstance().inCraftedMinionsInventory()) { - int diffX = 172; - if (x > guiLeft + xSize && x < guiLeft + xSize + diffX + 5 && y > guiTop - 18 && y < guiTop + 128) { - x += diffX; - } - } - if (AuctionProfit.inAuctionPage()) { - if (x + 18 > guiLeft + xSize && x + 18 < guiLeft + xSize + 4 + 28 + 20 && y > guiTop - 180 && - y < guiTop + 56) { - x -= 68 - 200; - } - } - if (EquipmentOverlay.isRenderingArmorHud()) { - if (x < guiLeft + xSize - 150 && x > guiLeft + xSize - 200 && y > guiTop && y < guiTop + 84) { - x -= 25; - } - } - if (EquipmentOverlay.isRenderingPetHud()) { - if (x < guiLeft + xSize - 150 && x > guiLeft + xSize - 200 && y > guiTop + 60 && y < guiTop + 120) { - x -= 25; - } - } - if (inDungeonPage || DungeonNpcProfitOverlay.isRendering()) { - if (x + 10 > guiLeft + xSize && x + 18 < guiLeft + xSize + 4 + 28 + 20 && y > guiTop - 180 && - y < guiTop + 100) { - x += 185; - } + Rectangle mouseRect = new Rectangle(mouseX, mouseY, 0, 0); + iterateButtons((GuiContainer) event.gui, (button, buttonPositon) -> { + if (!buttonPositon.intersects(mouseRect)) { + return; + } + if (Minecraft.getMinecraft().thePlayer.inventory.getItemStack() == null) { + int clickType = NotEnoughUpdates.INSTANCE.config.inventoryButtons.clickType; + if ((clickType == 0 && Mouse.getEventButtonState()) || + (clickType == 1 && !Mouse.getEventButtonState())) { + String command = button.command.trim(); + if (!command.startsWith("/")) { + command = "/" + command; } - - if (mouseX >= x && mouseX <= x + 18 && mouseY >= y && mouseY <= y + 18) { - if (Minecraft.getMinecraft().thePlayer.inventory.getItemStack() == null) { - int clickType = NotEnoughUpdates.INSTANCE.config.inventoryButtons.clickType; - if ((clickType == 0 && Mouse.getEventButtonState()) || - (clickType == 1 && !Mouse.getEventButtonState())) { - String command = button.command.trim(); - if (!command.startsWith("/")) { - command = "/" + command; - } - if (ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, command) == 0) { - NotEnoughUpdates.INSTANCE.sendChatMessage(command); - } - } - } else { - event.setCanceled(true); - } - return; + if (ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, command) == 0) { + NotEnoughUpdates.INSTANCE.sendChatMessage(command); } } + } else { + event.setCanceled(true); } - } + + }); } } @@ -1246,6 +1119,11 @@ public class RenderListener { event.setCanceled(true); return; } + if (PresetWarning.getInstance().shouldShow()) { + PresetWarning.getInstance().keyboardInput(); + event.setCanceled(true); + return; + } if (AuctionSearchOverlay.shouldReplace()) { AuctionSearchOverlay.keyEvent(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AbiphoneFavourites.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AbiphoneFavourites.java index 3366fd1e..750e674d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AbiphoneFavourites.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AbiphoneFavourites.java @@ -24,6 +24,7 @@ import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe; import io.github.moulberry.notenoughupdates.core.config.KeybindHelper; import io.github.moulberry.notenoughupdates.core.util.StringUtils; import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; +import io.github.moulberry.notenoughupdates.events.GuiContainerBackgroundDrawnEvent; import io.github.moulberry.notenoughupdates.events.ReplaceItemEvent; import io.github.moulberry.notenoughupdates.events.SlotClickEvent; import io.github.moulberry.notenoughupdates.options.NEUConfig; @@ -202,10 +203,11 @@ public class AbiphoneFavourites { return isAbiphoneShowOnlyFavourites() && !getFavouriteContacts().contains(name); } - public void onDrawBackground(GuiScreen screen) { + @SubscribeEvent + public void onDrawBackground(GuiContainerBackgroundDrawnEvent event) { if (isWrongInventory()) return; - GuiContainer container = (GuiContainer) screen; + GuiContainer container = event.getContainer(); for (Slot slot : container.inventorySlots.inventorySlots) { if (slot == null) continue; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AbiphoneWarning.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AbiphoneWarning.java index 2c28bcd1..69b0a1b6 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AbiphoneWarning.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AbiphoneWarning.java @@ -120,29 +120,24 @@ public class AbiphoneWarning extends GuiElement { int neuLength = Minecraft.getMinecraft().fontRendererObj.getStringWidth("\u00a7lNEU"); Minecraft.getMinecraft().fontRendererObj.drawString( "\u00a7lNEU", - width / 2 + 90 - neuLength - 3, - height / 2 - 45 + 4, - 0xff000000 + width / 2 + 90 - neuLength - 3, height / 2 - 45 + 4, 0xff000000 ); - TextRenderUtils.drawStringCenteredScaledMaxWidth("Are you SURE?", Minecraft.getMinecraft().fontRendererObj, + TextRenderUtils.drawStringCenteredScaledMaxWidth( + "Are you SURE?", width / 2, height / 2 - 45 + 10, false, 170, 0xffff4040 ); String sellLine = "\u00a77[ \u00a7r" + contactName + "\u00a77 ]"; - TextRenderUtils.drawStringCenteredScaledMaxWidth(sellLine, Minecraft.getMinecraft().fontRendererObj, + TextRenderUtils.drawStringCenteredScaledMaxWidth( + sellLine, width / 2, height / 2 - 45 + 25, false, 170, 0xffffffff ); TextRenderUtils.drawStringCenteredScaledMaxWidth( "Continue removing this contact?", - Minecraft.getMinecraft().fontRendererObj, - width / 2, - height / 2 - 45 + 50, - false, - 170, - 0xffa0a0a0 + width / 2, height / 2 - 45 + 50, false, 170, 0xffa0a0a0 ); RenderUtils.drawFloatingRectDark(width / 2 - 43, height / 2 + 23, 40, 16, false); @@ -150,21 +145,11 @@ public class AbiphoneWarning extends GuiElement { TextRenderUtils.drawStringCenteredScaledMaxWidth( EnumChatFormatting.GREEN + "[Y]es", - Minecraft.getMinecraft().fontRendererObj, - width / 2 - 23, - height / 2 + 31, - true, - 36, - 0xff00ff00 + width / 2 - 23, height / 2 + 31, true, 36, 0xff00ff00 ); TextRenderUtils.drawStringCenteredScaledMaxWidth( EnumChatFormatting.RED + "[N]o", - Minecraft.getMinecraft().fontRendererObj, - width / 2 + 23, - height / 2 + 31, - true, - 36, - 0xffff0000 + width / 2 + 23, height / 2 + 31, true, 36, 0xffff0000 ); GlStateManager.popMatrix(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionBINWarning.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionBINWarning.java index 7282aad7..2b292aec 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionBINWarning.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionBINWarning.java @@ -183,7 +183,7 @@ public class AuctionBINWarning extends GuiElement { 0xff000000 ); - TextRenderUtils.drawStringCenteredScaledMaxWidth("Are you SURE?", Minecraft.getMinecraft().fontRendererObj, + TextRenderUtils.drawStringCenteredScaledMaxWidth("Are you SURE?", width / 2, height / 2 - 45 + 10, false, 170, 0xffff4040 ); @@ -203,19 +203,14 @@ public class AuctionBINWarning extends GuiElement { String sellLine = "\u00a77[ \u00a7r" + sellingName + "\u00a77 ]"; - TextRenderUtils.drawStringCenteredScaledMaxWidth(sellLine, Minecraft.getMinecraft().fontRendererObj, + TextRenderUtils.drawStringCenteredScaledMaxWidth(sellLine, width / 2, height / 2 - 45 + 25, false, 170, 0xffffffff ); TextRenderUtils.drawStringCenteredScaledMaxWidth( (lowestPrice > 0 ? "has a lowest BIN of \u00a76" + lowestPriceStr + "\u00a7r coins" : "\u00a7cWarning: No lowest BIN found!"), - Minecraft.getMinecraft().fontRendererObj, - width / 2, - height / 2 - 45 + 34, - false, - 170, - 0xffa0a0a0 + width / 2, height / 2 - 45 + 34, false, 170, 0xffa0a0a0 ); if (sellingPrice > lowestPrice * sellStackAmount) { @@ -229,22 +224,12 @@ public class AuctionBINWarning extends GuiElement { TextRenderUtils.drawStringCenteredScaledMaxWidth( "Continue selling it for", - Minecraft.getMinecraft().fontRendererObj, - width / 2, - height / 2 - 45 + 50, - false, - 170, - 0xffa0a0a0 + width / 2, height / 2 - 45 + 50, false, 170, 0xffa0a0a0 ); TextRenderUtils.drawStringCenteredScaledMaxWidth( "\u00a76" + sellingPriceStr + "\u00a7r coins?" + (lowestPrice > 0 ? "(\u00a7" + (isALoss ? "c-" : "a+") + (buyPercentage >= 100 ? buyPercentage - 100 : buyPercentage) + "%\u00a7r)" : ""), - Minecraft.getMinecraft().fontRendererObj, - width / 2, - height / 2 - 45 + 59, - false, - 170, - 0xffa0a0a0 + width / 2, height / 2 - 45 + 59, false, 170, 0xffa0a0a0 ); RenderUtils.drawFloatingRectDark(width / 2 - 43, height / 2 + 23, 40, 16, false); @@ -252,21 +237,11 @@ public class AuctionBINWarning extends GuiElement { TextRenderUtils.drawStringCenteredScaledMaxWidth( EnumChatFormatting.GREEN + "[Y]es", - Minecraft.getMinecraft().fontRendererObj, - width / 2 - 23, - height / 2 + 31, - true, - 36, - 0xff00ff00 + width / 2 - 23, height / 2 + 31, true, 36, 0xff00ff00 ); TextRenderUtils.drawStringCenteredScaledMaxWidth( EnumChatFormatting.RED + "[N]o", - Minecraft.getMinecraft().fontRendererObj, - width / 2 + 23, - height / 2 + 31, - true, - 36, - 0xffff0000 + width / 2 + 23, height / 2 + 31, true, 36, 0xffff0000 ); if (sellingTooltip != null) { @@ -277,15 +252,7 @@ public class AuctionBINWarning extends GuiElement { if (mouseX >= width / 2 - sellLineLength / 2 && mouseX <= width / 2 + sellLineLength / 2 && mouseY >= height / 2 - 45 + 20 && mouseY <= height / 2 - 45 + 30) { - Utils.drawHoveringText( - sellingTooltip, - mouseX, - mouseY, - width, - height, - -1, - Minecraft.getMinecraft().fontRendererObj - ); + Utils.drawHoveringText(sellingTooltip, mouseX, mouseY, width, height, -1); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionProfit.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionProfit.java index c0e40ec9..c761f847 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionProfit.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionProfit.java @@ -22,7 +22,9 @@ package io.github.moulberry.notenoughupdates.miscfeatures; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe; import io.github.moulberry.notenoughupdates.core.util.StringUtils; +import io.github.moulberry.notenoughupdates.events.ButtonExclusionZoneEvent; import io.github.moulberry.notenoughupdates.mixins.AccessorGuiContainer; +import io.github.moulberry.notenoughupdates.util.Rectangle; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; @@ -47,6 +49,20 @@ public class AuctionProfit { new ResourceLocation("notenoughupdates:auction_profit.png"); @SubscribeEvent + public void onButtonExclusionZones(ButtonExclusionZoneEvent event) { + if (inAuctionPage()) { + event.blockArea( + new Rectangle( + event.getGuiBaseRect().getRight(), + event.getGuiBaseRect().getTop(), + 128 /*width*/ + 4 /*space*/, 56 + ), + ButtonExclusionZoneEvent.PushDirection.TOWARDS_RIGHT + ); + } + } + + @SubscribeEvent public void onDrawBackground(GuiScreenEvent.BackgroundDrawnEvent event) { if (!inAuctionPage()) return; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionSortModeWarning.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionSortModeWarning.java index ed05ee79..e840acdf 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionSortModeWarning.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionSortModeWarning.java @@ -82,9 +82,7 @@ public class AuctionSortModeWarning { RenderUtils.drawFloatingRectDark(centerX - warningLength / 2 - 4, centerY - 6, warningLength + 8, 12, false ); - TextRenderUtils.drawStringCenteredScaledMaxWidth(warningText, Minecraft.getMinecraft().fontRendererObj, - centerX, centerY, true, chest.width / 2, 0xffffffff - ); + TextRenderUtils.drawStringCenteredScaledMaxWidth(warningText, centerX, centerY, true, chest.width / 2, 0xffffffff); GlStateManager.popMatrix(); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CookieWarning.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CookieWarning.java index 80751371..f130a993 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CookieWarning.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CookieWarning.java @@ -31,9 +31,13 @@ public class CookieWarning { private static boolean hasNotified; private static boolean hasErrorMessage; + private static long cookieEndTime = 0; + private static boolean hasCookie = true; + private static long lastChecked = 0; public static void resetNotification() { hasNotified = false; + hasCookie = true; NotificationHandler.cancelNotification(); } @@ -41,96 +45,135 @@ public class CookieWarning { * Checks the tab list for a cookie timer, and sends a notification if the timer is within the tolerance */ public static void checkCookie() { - if (NotEnoughUpdates.INSTANCE.config.notifications.doBoosterNotif && - NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) { - String[] lines; - try { - lines = ((AccessorGuiPlayerTabOverlay) Minecraft.getMinecraft().ingameGUI.getTabList()) - .getFooter() - .getUnformattedText() - .split("\n"); - } catch (NullPointerException e) { - return; // if the footer is null or somehow doesn't exist, stop + if (!NotEnoughUpdates.INSTANCE.config.notifications.doBoosterNotif || + !NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) { + return; + } + String timeLine = getTimeLine(); + if (!hasCookie) { + if (!hasNotified) { + NotificationHandler.displayNotification(Lists.newArrayList( + "§cBooster Cookie Ran Out!", + "§7Your Booster Cookie expired!", + "§7", + "§7Press X on your keyboard to close this notification" + ), true, true); + hasNotified = true; } - boolean hasCookie = true; - String timeLine = null; // the line that contains the cookie timer - for (int i = 0; i < lines.length; i++) { - if (lines[i].startsWith("Cookie Buff")) { - timeLine = lines[i + 1]; // the line after the "Cookie Buff" line - } - if (lines[i].startsWith("Not active! Obtain booster cookies from the")) { - hasCookie = false; - } + return; + } + if (timeLine == null) return; + + int minutes = getMinutesRemaining(timeLine); + if (minutes < NotEnoughUpdates.INSTANCE.config.notifications.boosterCookieWarningMins && !hasNotified) { + NotificationHandler.displayNotification(Lists.newArrayList( + "§cBooster Cookie Running Low!", + "§7Your Booster Cookie will expire in " + timeLine, + "§7", + "§7Press X on your keyboard to close this notification" + ), true, true); + hasNotified = true; + } + } + + private static int getMinutesRemaining(String timeLine) { + String clean = timeLine.replaceAll("(§.)", ""); + clean = clean.replaceAll("(\\d)([smhdy])", "$1 $2"); + String[] digits = clean.split(" "); + int minutes = 0; + try { + for (int i = 0; i < digits.length; i++) { + if (i % 2 == 1) continue; + + String number = digits[i]; + String unit = digits[i + 1]; + long val = Integer.parseInt(number); + switch (unit) { + case "Years": + case "Year": + minutes += val * 525600; + break; + case "Months": + case "Month": + minutes += val * 43200; + break; + case "Days": + case "Day": + minutes += val * 1440; + break; + case "Hours": + case "Hour": + case "h": + minutes += val * 60; + break; + case "Minutes": + case "Minute": + case "m": + minutes += val; + break; + } // ignore seconds } - if (!hasCookie) { - if (!hasNotified) { - NotificationHandler.displayNotification(Lists.newArrayList( - "\u00a7cBooster Cookie Ran Out!", - "\u00a77Your Booster Cookie expired!", - "\u00a77", - "\u00a77Press X on your keyboard to close this notification" - ), true, true); - hasNotified = true; - } - return; + } catch (NumberFormatException e) { + if (!hasErrorMessage) { + e.printStackTrace(); + Utils.addChatMessage(EnumChatFormatting.RED + + "NEU ran into an issue when retrieving the Booster Cookie Timer. Check the logs for details."); + hasErrorMessage = true; } - if (timeLine != null) { - String clean = timeLine.replaceAll("(\u00a7.)", ""); - clean = clean.replaceAll("(\\d)([smhdy])", "$1 $2"); - String[] digits = clean.split(" "); - int minutes = 0; - try { - for (int i = 0; i < digits.length; i++) { - if (i % 2 == 1) continue; + hasNotified = true; + } + return minutes; + } - String number = digits[i]; - String unit = digits[i + 1]; - long val = Integer.parseInt(number); - switch (unit) { - case "Years": - case "Year": - minutes += val * 525600; - break; - case "Months": - case "Month": - minutes += val * 43200; - break; - case "Days": - case "Day": - minutes += val * 1440; - break; - case "Hours": - case "Hour": - case "h": - minutes += val * 60; - break; - case "Minutes": - case "Minute": - case "m": - minutes += val; - break; - } // ignore seconds - } - } catch (NumberFormatException e) { - if (!hasErrorMessage) { - e.printStackTrace(); - Utils.addChatMessage(EnumChatFormatting.RED + - "NEU ran into an issue when retrieving the Booster Cookie Timer. Check the logs for details."); - hasErrorMessage = true; - } - hasNotified = true; - } - if (minutes < NotEnoughUpdates.INSTANCE.config.notifications.boosterCookieWarningMins && !hasNotified) { - NotificationHandler.displayNotification(Lists.newArrayList( - "\u00a7cBooster Cookie Running Low!", - "\u00a77Your Booster Cookie will expire in " + timeLine, - "\u00a77", - "\u00a77Press X on your keyboard to close this notification" - ), true, true); - hasNotified = true; - } + private static String getTimeLine() { + String[] lines; + try { + lines = ((AccessorGuiPlayerTabOverlay) Minecraft.getMinecraft().ingameGUI.getTabList()) + .getFooter() + .getUnformattedText() + .split("\n"); + } catch (NullPointerException ignored) { + return null; + } + String timeLine = null; // the line that contains the cookie timer + for (int i = 0; i < lines.length; i++) { + if (lines[i].startsWith("Cookie Buff")) { + timeLine = lines[i + 1]; // the line after the "Cookie Buff" line + } + if (lines[i].startsWith("Not active! Obtain booster cookies from the")) { + hasCookie = false; } } + return timeLine; + } + + public static boolean hasActiveBoosterCookie() { + long cookieEndTime = getCookieEndTime(); + return cookieEndTime > System.currentTimeMillis(); + } + + private static long getCookieEndTime() { + // Only updating every 10 seconds +// if (System.currentTimeMillis() > lastChecked + 10_000) return cookieEndTime; + if (lastChecked + 3_000 > System.currentTimeMillis()) return cookieEndTime; + + String timeLine = getTimeLine(); + if (hasCookie && timeLine != null) { + int minutes = getMinutesRemaining(timeLine); + cookieEndTime = System.currentTimeMillis() + (long) minutes * 60 * 1000; + } else { + cookieEndTime = 0; + } + + lastChecked = System.currentTimeMillis(); + return cookieEndTime; + } + public static void onProfileSwitch() { + resetNotification(); + hasErrorMessage = false; + cookieEndTime = 0; + hasCookie = true; + lastChecked = 0; } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java index e959c761..c8c7a3da 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java @@ -44,6 +44,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; @@ -67,6 +68,7 @@ import org.lwjgl.util.vector.Vector3f; import java.awt.*; import java.io.ByteArrayInputStream; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; @@ -333,8 +335,7 @@ public class CustomItemEffects { } } - boolean onPrivateIsland = SBInfo.getInstance().getLocation() == null || SBInfo.getInstance().getLocation().equals( - "dynamic"); + boolean onPrivateIsland = Arrays.asList("dynamic","garden").contains(SBInfo.getInstance().getLocation()); if (NotEnoughUpdates.INSTANCE.config.itemOverlays.enableWandOverlay && Minecraft.getMinecraft().objectMouseOver != null && @@ -346,103 +347,210 @@ public class CustomItemEffects { Minecraft.getMinecraft().objectMouseOver.sideHit, 1)); if (hover.getBlock() == Blocks.air) { - if (heldInternal != null && heldInternal.equals("BUILDERS_WAND")) { - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + if (heldInternal != null && (heldInternal.equals("BUILDERS_WAND"))) buildersWandText(event, world); + else if (heldInternal != null && (heldInternal.equals("BUILDERS_RULER"))) buildersRulerText(event, world); - HashSet<BlockPos> candidatesOld = new HashSet<>(); - TreeMap<Float, Set<BlockPos>> candidatesOldSorted = new TreeMap<>(); - - IBlockState match = - world.getBlockState(Minecraft.getMinecraft().objectMouseOver.getBlockPos()); - Item matchItem = Item.getItemFromBlock(match.getBlock()); - if (matchItem != null) { - ItemStack matchStack = new ItemStack(matchItem, 1, - match - .getBlock() - .getDamageValue( - world, - Minecraft.getMinecraft().objectMouseOver.getBlockPos() - ) - ); - - getBuildersWandCandidates( - Minecraft.getMinecraft().thePlayer, - Minecraft.getMinecraft().objectMouseOver, - event.partialTicks, - candidatesOld, - candidatesOldSorted, - 999 - MAX_BUILDERS_BLOCKS - ); - - boolean usingDirtWand = false; - int itemCount; - if (match.getBlock() == Blocks.dirt && matchStack.getItemDamage() == 0 && hasDirtWand()) { - itemCount = candidatesOld.size(); - usingDirtWand = true; - } else { - itemCount = countItemsInInventoryAndStorage(matchStack); - } + } + } + } + } - if (candidatesOld.size() > MAX_BUILDERS_BLOCKS) { - Utils.drawStringCentered( - EnumChatFormatting.RED.toString() + candidatesOld.size() + "/" + MAX_BUILDERS_BLOCKS, - Minecraft.getMinecraft().fontRendererObj, - scaledResolution.getScaledWidth() / 2f, - scaledResolution.getScaledHeight() / 2f + 10, - true, - 0 - ); - } else { - String pre = EnumChatFormatting.GREEN.toString(); - if (itemCount < candidatesOld.size()) { - pre = EnumChatFormatting.RED.toString(); - } - Utils.drawStringCentered(pre + Math.min(candidatesOld.size(), itemCount) + "/" + - Math.min(candidatesOld.size(), MAX_BUILDERS_BLOCKS), - Minecraft.getMinecraft().fontRendererObj, - scaledResolution.getScaledWidth() / 2f, scaledResolution.getScaledHeight() / 2f + 10, true, 0 - ); - } + public void buildersWandText(RenderGameOverlayEvent.Post event, WorldClient world) { + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + + HashSet<BlockPos> candidatesOld = new HashSet<>(); + TreeMap<Float, Set<BlockPos>> candidatesOldSorted = new TreeMap<>(); + + IBlockState match = + world.getBlockState(Minecraft.getMinecraft().objectMouseOver.getBlockPos()); + Item matchItem = Item.getItemFromBlock(match.getBlock()); + if (matchItem == null) return; + ItemStack matchStack; + + matchStack = new ItemStack(matchItem, 1, + match + .getBlock() + .getDamageValue( + world, + Minecraft.getMinecraft().objectMouseOver.getBlockPos() + ) + ); - String itemCountS = EnumChatFormatting.DARK_GRAY + "x" + EnumChatFormatting.RESET + itemCount; - int itemCountLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(itemCountS); + getBuildersWandCandidates( + Minecraft.getMinecraft().thePlayer, + Minecraft.getMinecraft().objectMouseOver, + event.partialTicks, + candidatesOld, + candidatesOldSorted, + 999 - MAX_BUILDERS_BLOCKS + ); - if (NotEnoughUpdates.INSTANCE.config.itemOverlays.wandBlockCount) { - if (usingDirtWand) { - Utils.drawItemStack( - new ItemStack(Items.gold_nugget), - scaledResolution.getScaledWidth() / 2 - (itemCountLen + 16) / 2, - scaledResolution.getScaledHeight() / 2 + 10 + 4 - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - itemCountS, - scaledResolution.getScaledWidth() / 2f - (itemCountLen + 16) / 2f + 11, - scaledResolution.getScaledHeight() / 2f + 10 + 8, - -1, - true - ); - } else { - Utils.drawItemStack(matchStack, scaledResolution.getScaledWidth() / 2 - (itemCountLen + 16) / 2, - scaledResolution.getScaledHeight() / 2 + 10 + 4 - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - itemCountS, - scaledResolution.getScaledWidth() / 2f - (itemCountLen + 16) / 2f + 16, - scaledResolution.getScaledHeight() / 2f + 10 + 8, - -1, - true - ); - } + boolean usingDirtWand = false; + int itemCount; + if (match.getBlock() == Blocks.dirt && matchStack.getItemDamage() == 0 && hasDirtWand()) { + itemCount = candidatesOld.size(); + usingDirtWand = true; + } else { + itemCount = countItemsInInventoryAndStorage(matchStack); + } + if (candidatesOld.size() == 0) return; + + if (candidatesOld.size() > MAX_BUILDERS_BLOCKS) { + Utils.drawStringCentered( + EnumChatFormatting.RED.toString() + candidatesOld.size() + "/" + MAX_BUILDERS_BLOCKS, + Minecraft.getMinecraft().fontRendererObj, + scaledResolution.getScaledWidth() / 2f, + scaledResolution.getScaledHeight() / 2f + 10, + true, + 0 + ); + } else { + String pre = EnumChatFormatting.GREEN.toString(); + if (itemCount < candidatesOld.size()) { + pre = EnumChatFormatting.RED.toString(); + } + Utils.drawStringCentered(pre + Math.min(candidatesOld.size(), itemCount) + "/" + + Math.min(candidatesOld.size(), MAX_BUILDERS_BLOCKS), + Minecraft.getMinecraft().fontRendererObj, + scaledResolution.getScaledWidth() / 2f, scaledResolution.getScaledHeight() / 2f + 10, true, 0 + ); + } - } + String itemCountS = EnumChatFormatting.DARK_GRAY + "x" + EnumChatFormatting.RESET + itemCount; + int itemCountLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(itemCountS); + + if (NotEnoughUpdates.INSTANCE.config.itemOverlays.wandBlockCount) { + if (usingDirtWand) { + Utils.drawItemStack( + new ItemStack(Items.gold_nugget), + scaledResolution.getScaledWidth() / 2 - (itemCountLen + 16) / 2, + scaledResolution.getScaledHeight() / 2 + 10 + 4 + ); + Minecraft.getMinecraft().fontRendererObj.drawString( + itemCountS, + scaledResolution.getScaledWidth() / 2f - (itemCountLen + 16) / 2f + 11, + scaledResolution.getScaledHeight() / 2f + 10 + 8, + -1, + true + ); + } else { + Utils.drawItemStack(matchStack, scaledResolution.getScaledWidth() / 2 - (itemCountLen + 16) / 2, + scaledResolution.getScaledHeight() / 2 + 10 + 4 + ); + Minecraft.getMinecraft().fontRendererObj.drawString( + itemCountS, + scaledResolution.getScaledWidth() / 2f - (itemCountLen + 16) / 2f + 16, + scaledResolution.getScaledHeight() / 2f + 10 + 8, + -1, + true + ); + } - GlStateManager.color(1, 1, 1, 1); - } + } - } - } + GlStateManager.color(1, 1, 1, 1); + } + + public void buildersRulerText(RenderGameOverlayEvent.Post event, WorldClient world) { + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + + HashSet<BlockPos> candidatesOld = new HashSet<>(); + TreeMap<Float, Set<BlockPos>> candidatesOldSorted = new TreeMap<>(); + + IBlockState match = + world.getBlockState(Minecraft.getMinecraft().objectMouseOver.getBlockPos()); + Item matchItem = Item.getItemFromBlock(match.getBlock()); + if (matchItem == null) return; + ItemStack matchStack; + + matchStack = new ItemStack(matchItem, 1, + match + .getBlock() + .getDamageValue( + world, + Minecraft.getMinecraft().objectMouseOver.getBlockPos() + ) + ); + if (!Minecraft.getMinecraft().thePlayer.isSneaking()) matchStack = getFirstItemInRuler(); + match = Blocks.dirt.getDefaultState(); + if (matchStack == null) return; + + getBuildersRulerCandidates( + Minecraft.getMinecraft().thePlayer, + Minecraft.getMinecraft().objectMouseOver, + event.partialTicks, + candidatesOld, + candidatesOldSorted, + 499 - MAX_BUILDERS_BLOCKS + ); + + boolean usingDirtWand = false; + int itemCount; + if (Minecraft.getMinecraft().thePlayer.isSneaking()) { + itemCount = candidatesOld.size(); + } else { + if (match.getBlock() == Blocks.dirt && matchStack.getItemDamage() == 0 && hasDirtWand()) { + itemCount = candidatesOld.size(); + usingDirtWand = true; + } else { + itemCount = countItemsInInventoryAndStorage(matchStack); + } + } + if (candidatesOld.size() == 0) return; + + if (!Minecraft.getMinecraft().thePlayer.isSneaking()) { + if (candidatesOld.size() > MAX_BUILDERS_BLOCKS) { + Utils.drawStringCentered( + EnumChatFormatting.RED.toString() + candidatesOld.size() + "/" + MAX_BUILDERS_BLOCKS, + Minecraft.getMinecraft().fontRendererObj, + scaledResolution.getScaledWidth() / 2f, + scaledResolution.getScaledHeight() / 2f + 10, + true, + 0 + ); + } else { + String pre = EnumChatFormatting.GREEN.toString(); + Utils.drawStringCentered(pre + Math.min(candidatesOld.size(), itemCount) + "/" + + Math.min(candidatesOld.size(), MAX_BUILDERS_BLOCKS), + Minecraft.getMinecraft().fontRendererObj, + scaledResolution.getScaledWidth() / 2f, scaledResolution.getScaledHeight() / 2f + 10, true, 0 + ); + } + } + + String itemCountS = EnumChatFormatting.DARK_GRAY + "x" + EnumChatFormatting.RESET + itemCount; + int itemCountLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(itemCountS); + + if (NotEnoughUpdates.INSTANCE.config.itemOverlays.wandBlockCount) { + if (usingDirtWand) { + Utils.drawItemStack( + new ItemStack(Items.gold_nugget), + scaledResolution.getScaledWidth() / 2 - (itemCountLen + 16) / 2, + scaledResolution.getScaledHeight() / 2 + 10 + 4 + ); + Minecraft.getMinecraft().fontRendererObj.drawString( + itemCountS, + scaledResolution.getScaledWidth() / 2f - (itemCountLen + 16) / 2f + 11, + scaledResolution.getScaledHeight() / 2f + 10 + 8, + -1, + true + ); + } else { + Utils.drawItemStack(matchStack, scaledResolution.getScaledWidth() / 2 - (itemCountLen + 16) / 2, + scaledResolution.getScaledHeight() / 2 + 10 + 4 + ); + Minecraft.getMinecraft().fontRendererObj.drawString( + itemCountS, + scaledResolution.getScaledWidth() / 2f - (itemCountLen + 16) / 2f + 16, + scaledResolution.getScaledHeight() / 2f + 10 + 8, + -1, + true + ); } + } + + GlStateManager.color(1, 1, 1, 1); } //ethermerge @@ -496,7 +604,28 @@ public class CustomItemEffects { return null; } + public NBTTagCompound getBuildersNbt(boolean isWand) { + ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem(); + if (held == null) return null; + + if (held.hasTagCompound() && held.getTagCompound().hasKey("ExtraAttributes", 10) && + held.getTagCompound().getCompoundTag("ExtraAttributes").hasKey(isWand + ? "builder's_wand_data" + : "builder's_ruler_data", 7)) { + byte[] bytes = held.getTagCompound().getCompoundTag("ExtraAttributes").getByteArray(isWand + ? "builder's_wand_data" + : "builder's_ruler_data"); + try { + return CompressedStreamTools.readCompressed(new ByteArrayInputStream(bytes)); + } catch (Exception e) { + return null; + } + } + return null; + } + public int countItemsInInventoryAndStorage(ItemStack match) { + if (match == null) return 0; int count = 0; for (ItemStack stack : Minecraft.getMinecraft().thePlayer.inventory.mainInventory) { @@ -508,24 +637,19 @@ public class CustomItemEffects { ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem(); String heldInternal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held); - if (heldInternal != null && heldInternal.equals("BUILDERS_WAND")) { - if (held.hasTagCompound() && held.getTagCompound().hasKey("ExtraAttributes", 10) && - held.getTagCompound().getCompoundTag("ExtraAttributes").hasKey("builder's_wand_data", 7)) { - byte[] bytes = held.getTagCompound().getCompoundTag("ExtraAttributes").getByteArray("builder's_wand_data"); - try { - NBTTagCompound contents_nbt = CompressedStreamTools.readCompressed(new ByteArrayInputStream(bytes)); - NBTTagList items = contents_nbt.getTagList("i", 10); - for (int j = 0; j < items.tagCount(); j++) { - NBTTagCompound buildersItem = items.getCompoundTagAt(j); - if (buildersItem.getKeySet().size() > 0) { - if (buildersItem.getInteger("id") == Item.getIdFromItem(match.getItem()) && - buildersItem.getInteger("Damage") == match.getItemDamage()) { - count += items.getCompoundTagAt(j).getByte("Count"); - } - } - } - } catch (Exception e) { - return count; + boolean isWand = heldInternal != null && heldInternal.equals("BUILDERS_WAND"); + if (heldInternal == null || !heldInternal.equals(isWand ? "BUILDERS_WAND" : "BUILDERS_RULER")) return count; + + NBTTagCompound contents_nbt = getBuildersNbt(isWand); + if (contents_nbt == null) return count; + + NBTTagList items = contents_nbt.getTagList("i", 10); + for (int j = 0; j < items.tagCount(); j++) { + NBTTagCompound buildersItem = items.getCompoundTagAt(j); + if (buildersItem.getKeySet().size() > 0) { + if (buildersItem.getInteger("id") == Item.getIdFromItem(match.getItem()) && + buildersItem.getInteger("Damage") == match.getItemDamage()) { + count += items.getCompoundTagAt(j).getByte("Count"); } } } @@ -533,6 +657,36 @@ public class CustomItemEffects { return count; } + public ItemStack getFirstItemInRuler() { + + ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem(); + String heldInternal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held); + + if (heldInternal == null || !heldInternal.equals("BUILDERS_RULER")) return null; + + NBTTagCompound contents_nbt = getBuildersNbt(false); + if (contents_nbt == null) return null; + + NBTTagList items = contents_nbt.getTagList("i", 10); + for (int j = 0; j < items.tagCount(); j++) { + NBTTagCompound buildersItem = items.getCompoundTagAt(j); + if (buildersItem.getKeySet().size() > 0) { + ItemStack newStack = new ItemStack( + Item.getItemById(buildersItem.getInteger("id")), + 1, + buildersItem.getInteger("Damage") + ); + return newStack; + } + } + + //the ruler says it uses ur inv but it doesnt + /*for (ItemStack stack : Minecraft.getMinecraft().thePlayer.inventory.mainInventory) { + if (stack != null && stack.getItem() instanceof ItemBlock) return stack; + }*/ + return null; + } + public boolean hasDirtWand() { for (ItemStack stack : Minecraft.getMinecraft().thePlayer.inventory.mainInventory) { String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack); @@ -543,11 +697,15 @@ public class CustomItemEffects { ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem(); String heldInternal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held); - - if (heldInternal != null && heldInternal.equals("BUILDERS_WAND")) { + boolean isWand = heldInternal != null && heldInternal.equals("BUILDERS_WAND"); + if (heldInternal != null && heldInternal.equals(isWand ? "BUILDERS_WAND" : "BUILDERS_RULER")) { if (held.hasTagCompound() && held.getTagCompound().hasKey("ExtraAttributes", 10) && - held.getTagCompound().getCompoundTag("ExtraAttributes").hasKey("builder's_wand_data", 7)) { - byte[] bytes = held.getTagCompound().getCompoundTag("ExtraAttributes").getByteArray("builder's_wand_data"); + held.getTagCompound().getCompoundTag("ExtraAttributes").hasKey(isWand + ? "builder's_wand_data" + : "builder's_ruler_data", 7)) { + byte[] bytes = held.getTagCompound().getCompoundTag("ExtraAttributes").getByteArray(isWand + ? "builder's_wand_data" + : "builder's_ruler_data"); try { NBTTagCompound contents_nbt = CompressedStreamTools.readCompressed(new ByteArrayInputStream(bytes)); NBTTagList items = contents_nbt.getTagList("i", 10); @@ -597,6 +755,10 @@ public class CustomItemEffects { add(Blocks.farmland); }}; + + List<Block> scytheBlocks = Arrays.asList( + Blocks.leaves, Blocks.leaves2, Blocks.red_flower, Blocks.yellow_flower, Blocks.tallgrass, Blocks.double_plant); + @SubscribeEvent public void renderBlockOverlay(DrawBlockHighlightEvent event) { if (aoteTeleportationCurr != null && aoteTeleportationMillis > 0) { @@ -611,8 +773,7 @@ public class CustomItemEffects { ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem(); String heldInternal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held); if (heldInternal != null) { - boolean onPrivateIsland = SBInfo.getInstance().getLocation() == null || SBInfo.getInstance().getLocation().equals( - "dynamic"); + boolean onPrivateIsland = Arrays.asList("dynamic","garden").contains(SBInfo.getInstance().getLocation()); EntityPlayer player = event.player; double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double) event.partialTicks; double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double) event.partialTicks; @@ -835,89 +996,10 @@ public class CustomItemEffects { } } else if (NotEnoughUpdates.INSTANCE.config.itemOverlays.enableWandOverlay) { if (heldInternal.equals("BUILDERS_WAND") && onPrivateIsland) { - int maxBlocks = MAX_BUILDERS_BLOCKS; - if (event.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { - IBlockState hover = Minecraft.getMinecraft().theWorld.getBlockState(event.target - .getBlockPos() - .offset(event.target.sideHit, 1)); - if (hover.getBlock() == Blocks.air) { - IBlockState match = Minecraft.getMinecraft().theWorld.getBlockState(event.target.getBlockPos()); - Item matchItem = Item.getItemFromBlock(match.getBlock()); - if (matchItem != null) { - GlStateManager.enableBlend(); - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); - GlStateManager.disableTexture2D(); - GlStateManager.depthMask(false); - - HashSet<BlockPos> candidatesOld = new HashSet<>(); - TreeMap<Float, Set<BlockPos>> candidatesOldSorted = new TreeMap<>(); - - getBuildersWandCandidates( - player, - event.target, - event.partialTicks, - candidatesOld, - candidatesOldSorted, - 10 - ); - - ItemStack matchStack = new ItemStack(matchItem, 1, - match.getBlock().getDamageValue(Minecraft.getMinecraft().theWorld, event.target.getBlockPos()) - ); - int itemCount; - if (match.getBlock() == Blocks.dirt && matchStack.getItemDamage() == 0 && hasDirtWand()) { - itemCount = candidatesOld.size(); - } else { - itemCount = countItemsInInventoryAndStorage(matchStack); - } - - String special = (candidatesOld.size() <= itemCount) - ? NotEnoughUpdates.INSTANCE.config.itemOverlays.wandOverlayColour - : - "0:255:255:0:0"; - - if (candidatesOld.size() <= maxBlocks) { - for (Set<BlockPos> candidatesSorted : candidatesOldSorted.values()) { - for (BlockPos candidate : candidatesSorted) { - match.getBlock().setBlockBoundsBasedOnState(Minecraft.getMinecraft().theWorld, candidate); - AxisAlignedBB bb = match.getBlock().getSelectedBoundingBox( - Minecraft.getMinecraft().theWorld, - candidate - ) - .offset( - event.target.sideHit.getFrontOffsetX(), - event.target.sideHit.getFrontOffsetY(), - event.target.sideHit.getFrontOffsetZ() - ); - - drawBlock((int) bb.minX, (int) bb.minY, (int) bb.minZ + 1, match, event.partialTicks, 0.75f); - } - } - - for (BlockPos candidate : candidatesOld) { - match.getBlock().setBlockBoundsBasedOnState(Minecraft.getMinecraft().theWorld, candidate); - AxisAlignedBB bb = match.getBlock().getSelectedBoundingBox( - Minecraft.getMinecraft().theWorld, - candidate - ) - .expand(0.001D, 0.001D, 0.001D).offset(-d0, -d1, -d2) - .offset( - event.target.sideHit.getFrontOffsetX(), - event.target.sideHit.getFrontOffsetY(), - event.target.sideHit.getFrontOffsetZ() - ); - - drawOutlineBoundingBox(bb, 1f, special); - } - } - - GlStateManager.depthMask(true); - GlStateManager.enableTexture2D(); - GlStateManager.disableBlend(); - } - } - } - } else if (heldInternal.equals("INFINIDIRT_WAND") && + buildersWandOverlay(event, d0, d1, d2); + } else if (heldInternal.equals("BUILDERS_RULER") && onPrivateIsland) { + buildersRulerOverlay(event, d0, d1, d2); + }else if (heldInternal.equals("INFINIDIRT_WAND") && event.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && NotEnoughUpdates.INSTANCE.config.itemOverlays.enableDirtWandOverlay) { BlockPos hover = event.target.getBlockPos().offset(event.target.sideHit, 1); @@ -1054,8 +1136,10 @@ public class CustomItemEffects { for (int xOff = -radius; xOff <= radius; xOff++) { for (int zOff = -radius; zOff <= radius; zOff++) { BlockPos renderPos = target.add(xOff, 0, zOff); + BlockPos airPos = renderPos.add(0, 1, 0); IBlockState renderState = Minecraft.getMinecraft().theWorld.getBlockState(renderPos); - if (renderState.getBlock() == Blocks.dirt || renderState.getBlock() == Blocks.grass) { + IBlockState airState = Minecraft.getMinecraft().theWorld.getBlockState(airPos); + if (renderState.getBlock() == Blocks.dirt || renderState.getBlock() == Blocks.grass && airState.getBlock() == Blocks.air) { AxisAlignedBB bbExpanded = Blocks.dirt.getSelectedBoundingBox( Minecraft.getMinecraft().theWorld, renderPos @@ -1071,8 +1155,291 @@ public class CustomItemEffects { GlStateManager.enableTexture2D(); GlStateManager.disableBlend(); } + } else if ((heldInternal.equals("HOE_OF_GREATEST_TILLING") && + NotEnoughUpdates.INSTANCE.config.itemOverlays.enableHoeOverlay && onPrivateIsland) && + event.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + BlockPos target = event.target.getBlockPos(); + IBlockState targetState = Minecraft.getMinecraft().theWorld.getBlockState(target); + + if (targetState.getBlock() == Blocks.dirt || targetState.getBlock() == Blocks.grass) { + GlStateManager.enableDepth(); + GlStateManager.enableBlend(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.disableTexture2D(); + GlStateManager.depthMask(true); + + LinkedList<BlockPos> candidates = new LinkedList<>(); + LinkedList<BlockPos> candidatesOld = new LinkedList<>(); + LinkedList<BlockPos> candidatesNew = new LinkedList<>(); + candidatesNew.add(target); + + while (candidatesOld.size() <= 100) { + if (candidatesNew.isEmpty()) { + break; + } + + candidates.addAll(candidatesNew); + candidatesNew.clear(); + + while (!candidates.isEmpty()) { + + BlockPos candidate = candidates.pop(); + candidatesOld.add(candidate); + + float yaw = Minecraft.getMinecraft().thePlayer.getRotationYawHead(); + Facing facing = Facing.forDirection(yaw); + int xOff = facing == Facing.WEST ? -1 : facing == Facing.EAST ? 1 : 0; + int zOff = facing == Facing.NORTH ? -1 : facing == Facing.SOUTH ? 1 : 0; + + BlockPos renderPos = candidate.add(xOff, 0, zOff); + BlockPos airPos = renderPos.add(0, 1, 0); + IBlockState renderState = Minecraft.getMinecraft().theWorld.getBlockState(renderPos); + IBlockState airState = Minecraft.getMinecraft().theWorld.getBlockState(airPos); + if (!candidatesOld.contains(renderPos) && !candidates.contains(renderPos) && !candidatesNew.contains( + renderPos)) { + if (renderState.getBlock() == Blocks.dirt || renderState.getBlock() == Blocks.grass && airState.getBlock() == Blocks.air) { + candidatesNew.add(renderPos); + } else { + break; + } + } + } + + for (BlockPos renderPos : candidatesNew) { + AxisAlignedBB bbExpanded = Blocks.dirt.getSelectedBoundingBox( + Minecraft.getMinecraft().theWorld, + renderPos + ) + .expand(0.001D, 0.001D, 0.001D) + .offset(-d0, -d1, -d2); + drawFilledBoundingBox(bbExpanded, 1f, "0:100:178:34:34"); + } + } + + AxisAlignedBB bbExpanded = Blocks.dirt.getSelectedBoundingBox( + Minecraft.getMinecraft().theWorld, + target + ) + .expand(0.001D, 0.001D, 0.001D) + .offset(-d0, -d1, -d2); + drawFilledBoundingBox(bbExpanded, 1f, "0:100:178:34:34"); + + GlStateManager.depthMask(true); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + } else if ((heldInternal.equals("SAM_SCYTHE") || heldInternal.equals("GARDEN_SCYTHE") && + NotEnoughUpdates.INSTANCE.config.itemOverlays.enableScytheOverlay && onPrivateIsland) && + event.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + BlockPos target = event.target.getBlockPos(); + IBlockState targetState = Minecraft.getMinecraft().theWorld.getBlockState(target); + + int radius = heldInternal.equals("SAM_SCYTHE") ? 1 : 2; + + if (scytheBlocks.contains(targetState.getBlock())) { + GlStateManager.enableDepth(); + GlStateManager.enableBlend(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.disableTexture2D(); + GlStateManager.depthMask(true); + + for (int xOff = -radius; xOff <= radius; xOff++) { + for (int yOff = -radius; yOff <= radius; yOff++) { + for (int zOff = -radius; zOff <= radius; zOff++) { + BlockPos renderPos = target.add(xOff, yOff, zOff); + IBlockState renderState = Minecraft.getMinecraft().theWorld.getBlockState(renderPos); + if (scytheBlocks.contains(renderState.getBlock())) { + AxisAlignedBB bbExpanded = renderState.getBlock().getSelectedBoundingBox( + Minecraft.getMinecraft().theWorld, + renderPos + ) + .expand(0.001D, 0.001D, 0.001D) + .offset(-d0, -d1, -d2); + drawFilledBoundingBox(bbExpanded, 1f, "0:100:178:34:34"); + } + } + } + } + + GlStateManager.depthMask(true); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + } + } + } + } + + public void buildersWandOverlay(DrawBlockHighlightEvent event, double d0, double d1, double d2) { + if (event.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + IBlockState hover = Minecraft.getMinecraft().theWorld.getBlockState(event.target + .getBlockPos() + .offset(event.target.sideHit, 1)); + if (hover.getBlock() != Blocks.air) return; + IBlockState match = Minecraft.getMinecraft().theWorld.getBlockState(event.target.getBlockPos()); + Item matchItem = Item.getItemFromBlock(match.getBlock()); + if (matchItem == null) return; + GlStateManager.enableBlend(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.disableTexture2D(); + GlStateManager.depthMask(false); + + HashSet<BlockPos> candidatesOld = new HashSet<>(); + TreeMap<Float, Set<BlockPos>> candidatesOldSorted = new TreeMap<>(); + + getBuildersWandCandidates(Minecraft.getMinecraft().thePlayer, + event.target, + event.partialTicks, + candidatesOld, + candidatesOldSorted, + 10 + ); + + ItemStack matchStack; + + matchStack = new ItemStack(matchItem, + 1, + match.getBlock().getDamageValue(Minecraft.getMinecraft().theWorld, event.target.getBlockPos()) + ); + + int itemCount; + if (match.getBlock() == Blocks.dirt && matchStack.getItemDamage() == 0 && hasDirtWand()) { + itemCount = candidatesOld.size(); + } else { + itemCount = countItemsInInventoryAndStorage(matchStack); + } + + String special = (candidatesOld.size() <= itemCount) + ? NotEnoughUpdates.INSTANCE.config.itemOverlays.wandOverlayColour + : "0:255:255:0:0"; + + if (candidatesOld.size() <= MAX_BUILDERS_BLOCKS) { + for (Set<BlockPos> candidatesSorted : candidatesOldSorted.values()) { + for (BlockPos candidate : candidatesSorted) { + match.getBlock().setBlockBoundsBasedOnState(Minecraft.getMinecraft().theWorld, candidate); + Minecraft.getMinecraft().thePlayer.isSneaking(); + AxisAlignedBB bb = match.getBlock().getSelectedBoundingBox(Minecraft.getMinecraft().theWorld, + candidate.add(0, 0, 0) + ).offset(event.target.sideHit.getFrontOffsetX(), + event.target.sideHit.getFrontOffsetY(), + event.target.sideHit.getFrontOffsetZ() + ); + + drawBlock((int) bb.minX, (int) bb.minY, (int) bb.minZ + 1, match, event.partialTicks, 0.75f); + } + } + + for (BlockPos candidate : candidatesOld) { + match.getBlock().setBlockBoundsBasedOnState(Minecraft.getMinecraft().theWorld, candidate); + Minecraft.getMinecraft().thePlayer.isSneaking(); + AxisAlignedBB bb = match.getBlock().getSelectedBoundingBox(Minecraft.getMinecraft().theWorld, + candidate.add(0, 0, 0) + ).expand(0.001D, 0.001D, 0.001D).offset(-d0, -d1, -d2).offset(event.target.sideHit.getFrontOffsetX(), + event.target.sideHit.getFrontOffsetY(), + event.target.sideHit.getFrontOffsetZ() + ); + + drawOutlineBoundingBox(bb, 1f, special); } } + + GlStateManager.depthMask(true); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + } + + public void buildersRulerOverlay(DrawBlockHighlightEvent event, double d0, double d1, double d2) { + if (event.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + IBlockState hover = Minecraft.getMinecraft().theWorld.getBlockState(event.target + .getBlockPos() + .offset(event.target.sideHit, 1)); + + if (hover.getBlock() != Blocks.air) return; + + IBlockState match = Minecraft.getMinecraft().theWorld.getBlockState(event.target.getBlockPos()); + Item matchItem = Item.getItemFromBlock(match.getBlock()); + if (matchItem == null) return; + GlStateManager.enableBlend(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.disableTexture2D(); + GlStateManager.depthMask(false); + + HashSet<BlockPos> candidatesOld = new HashSet<>(); + TreeMap<Float, Set<BlockPos>> candidatesOldSorted = new TreeMap<>(); + + getBuildersRulerCandidates(Minecraft.getMinecraft().thePlayer, + event.target, + event.partialTicks, + candidatesOld, + candidatesOldSorted, + 10 + ); + ItemStack firstItemInRuler = getFirstItemInRuler(); + if (!Minecraft.getMinecraft().thePlayer.isSneaking()) { + Item item = firstItemInRuler == null ? null : firstItemInRuler.getItem(); + if (item != null) { + if (item instanceof ItemBlock) + match = ((ItemBlock) item).getBlock().getStateFromMeta(firstItemInRuler.getItemDamage()); + else match = Blocks.dirt.getDefaultState(); + } + } + + ItemStack matchStack; + if (Minecraft.getMinecraft().thePlayer.isSneaking()) { + matchStack = new ItemStack(Minecraft.getMinecraft().theWorld + .getBlockState(event.target.getBlockPos()) + .getBlock()); + } else { + matchStack = firstItemInRuler; + } + int itemCount; + if (matchStack != null) { + if (match.getBlock() == Blocks.dirt && matchStack.getItemDamage() == 0 && hasDirtWand()) { + itemCount = candidatesOld.size(); + } else { + itemCount = countItemsInInventoryAndStorage(matchStack); + } + } else { + return; + } + + String special = (candidatesOld.size() <= itemCount) + ? NotEnoughUpdates.INSTANCE.config.itemOverlays.wandOverlayColour + : "0:255:255:0:0"; + + for (Set<BlockPos> candidatesSorted : candidatesOldSorted.values()) { + for (BlockPos candidate : candidatesSorted) { + AxisAlignedBB bb = match.getBlock().getSelectedBoundingBox(Minecraft.getMinecraft().theWorld, + candidate.add(0, Minecraft.getMinecraft().thePlayer.isSneaking() ? -1 : 0, 0) + ).offset(event.target.sideHit.getFrontOffsetX(), + event.target.sideHit.getFrontOffsetY(), + event.target.sideHit.getFrontOffsetZ() + ); + + drawBlock((int) bb.minX, (int) bb.minY, (int) bb.minZ + 1, match, event.partialTicks, 0.75f); + } + } + + for (BlockPos candidate : candidatesOld) { + AxisAlignedBB bb = match.getBlock().getSelectedBoundingBox(Minecraft.getMinecraft().theWorld, + candidate.add(0, Minecraft.getMinecraft().thePlayer.isSneaking() ? -1 : 0, 0) + ).expand(0.001D, 0.001D, 0.001D).offset(-d0, -d1, -d2).offset(event.target.sideHit.getFrontOffsetX(), + event.target.sideHit.getFrontOffsetY(), + event.target.sideHit.getFrontOffsetZ() + ); + + drawOutlineBoundingBox(bb, + 1f, + (Minecraft.getMinecraft().thePlayer.isSneaking()) + ? NotEnoughUpdates.INSTANCE.config.itemOverlays.wandOverlayColour + : special + ); + } + + GlStateManager.depthMask(true); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); } } @@ -1144,6 +1511,113 @@ public class CustomItemEffects { } } + public enum Facing { + NORTH, + EAST, + SOUTH, + WEST; + + public static Facing forDirection(float direction) { + double rotation = (direction - 90) % 360; + if (rotation < 0) { + rotation += 360.0; + } + + if ((0.0D <= rotation) && (rotation < 45.0D)) + return WEST; + if ((45.0D <= rotation) && (rotation < 135.0D)) + return NORTH; + if ((135.0D <= rotation) && (rotation < 225.0D)) + return EAST; + if ((225.0D <= rotation) && (rotation < 315.0D)) + return SOUTH; + if ((315.0D <= rotation) && (rotation < 360.0D)) { + return WEST; + } else { + return NORTH; // it uhhh shouldnt do this tho right + } + } + } + + public void getBuildersRulerCandidates( + EntityPlayer player, + MovingObjectPosition target, + float partialTicks, + HashSet<BlockPos> candidatesOld, + TreeMap<Float, Set<BlockPos>> candidatesOldSorted, + int extraMax + ) { + if (target.sideHit != EnumFacing.UP) return; + boolean sneaking = Minecraft.getMinecraft().thePlayer.isSneaking(); + candidatesOld.clear(); + candidatesOldSorted.clear(); + LinkedList<BlockPos> candidates = new LinkedList<>(); + LinkedList<BlockPos> candidatesNew = new LinkedList<>(); + + candidatesNew.add(target.getBlockPos()); + + double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double) partialTicks; + double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double) partialTicks; + double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double) partialTicks; + + while (candidatesOld.size() <= MAX_BUILDERS_BLOCKS + extraMax) { + if (candidatesNew.isEmpty()) { + break; + } + + candidates.addAll(candidatesNew); + candidatesNew.clear(); + + while (!candidates.isEmpty()) { + if (candidatesOld.size() > MAX_BUILDERS_BLOCKS + extraMax) break; + + BlockPos candidate = candidates.pop(); + + float distSq = (float) ((candidate.getX() + 0.5f - d0) * (candidate.getX() + 0.5f - d0) + + (candidate.getY() + 0.5f - d1 - player.getEyeHeight()) * + (candidate.getY() + 0.5f - d1 - player.getEyeHeight()) + + (candidate.getZ() + 0.5f - d2) * (candidate.getZ() + 0.5f - d2)); + candidatesOldSorted.computeIfAbsent(distSq, k -> new HashSet<>()).add(candidate); + + candidatesOld.add(candidate); + + float yaw = Minecraft.getMinecraft().thePlayer.getRotationYawHead(); + Facing facing = Facing.forDirection(yaw); + int xOff = facing == Facing.WEST ? -1 : facing == Facing.EAST ? 1 : 0; + int zOff = facing == Facing.NORTH ? -1 : facing == Facing.SOUTH ? 1 : 0; + if (!sneaking) { + if (Minecraft.getMinecraft().theWorld.getBlockState(candidate.add(xOff, 1, zOff)).getBlock() == Blocks.air) { + + BlockPos posNew = candidate.add(xOff, 0, zOff); + if (!candidatesOld.contains(posNew) && !candidates.contains(posNew) && !candidatesNew.contains(posNew)) { + IBlockState blockNew = Minecraft.getMinecraft().theWorld.getBlockState(posNew.add(0, 1, 0)); + if (blockNew.getBlock() == Blocks.air) { + candidatesNew.add(posNew); + } + } + } else { + break; + } + } else { + if (Minecraft.getMinecraft().theWorld.getBlockState(candidate.add(xOff, 0, zOff)).getBlock() + == Minecraft.getMinecraft().theWorld.getBlockState(target.getBlockPos()).getBlock()) { + BlockPos posNew = candidate.add(xOff, 0, zOff); + if (!candidatesOld.contains(posNew) && !candidates.contains(posNew) && !candidatesNew.contains(posNew)) { + IBlockState blockNew = Minecraft.getMinecraft().theWorld.getBlockState(posNew.add(0, 0, 0)); + if (blockNew.getBlock() == + Minecraft.getMinecraft().theWorld.getBlockState(target.getBlockPos()).getBlock()) { + candidatesNew.add(posNew); + } + } + } else { + break; + } + } + + } + } + } + public static void drawBlock(int x, int y, int z, IBlockState state, float partialTicks, float brightness) { EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double) partialTicks; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DungeonNpcProfitOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DungeonNpcProfitOverlay.java index 711d5235..c06563c2 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DungeonNpcProfitOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DungeonNpcProfitOverlay.java @@ -24,8 +24,10 @@ import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe; import io.github.moulberry.notenoughupdates.core.util.StringUtils; +import io.github.moulberry.notenoughupdates.events.ButtonExclusionZoneEvent; import io.github.moulberry.notenoughupdates.mixins.AccessorGuiContainer; import io.github.moulberry.notenoughupdates.util.ItemUtils; +import io.github.moulberry.notenoughupdates.util.Rectangle; import io.github.moulberry.notenoughupdates.util.SBInfo; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; @@ -100,6 +102,19 @@ public class DungeonNpcProfitOverlay { } @SubscribeEvent + public void onButtonExclusionZones(ButtonExclusionZoneEvent event) { + if (isRendering()) + event.blockArea( + new Rectangle( + event.getGuiBaseRect().getRight(), + event.getGuiBaseRect().getTop(), + 180 /*width*/ + 4 /*space*/, 101 + ), + ButtonExclusionZoneEvent.PushDirection.TOWARDS_RIGHT + ); + } + + @SubscribeEvent public void onDrawBackground(GuiScreenEvent.BackgroundDrawnEvent event) { if (!NotEnoughUpdates.INSTANCE.config.dungeons.croesusProfitOverlay || !(event.gui instanceof GuiChest)) { chestProfits = null; @@ -221,15 +236,7 @@ public class DungeonNpcProfitOverlay { int mouseY = Utils.getMouseY(); if (Utils.isWithinRect(mouseX, mouseY, x, y, 160, 10)) - Utils.drawHoveringText( - chestProfit.lore, - mouseX, - mouseY, - width, - height, - -1, - Minecraft.getMinecraft().fontRendererObj - ); + Utils.drawHoveringText(chestProfit.lore, mouseX, mouseY, width, height, -1); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/EnchantingSolvers.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/EnchantingSolvers.java index 695c9851..a5c96e4a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/EnchantingSolvers.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/EnchantingSolvers.java @@ -277,7 +277,7 @@ public class EnchantingSolvers { GlStateManager.disableDepth(); GlStateManager.enableBlend(); GlStateManager.disableLighting(); - Utils.drawStringScaled((solveIndex + 1) + "", Minecraft.getMinecraft().fontRendererObj, + Utils.drawStringScaled((solveIndex + 1) + "", x + 8.5f - w / 2f, y + 8.5f - 4, true, 0xffc0c0c0, 1f ); return true; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java index 5a611178..97aa25d4 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java @@ -26,7 +26,6 @@ import com.google.gson.JsonObject; import com.google.gson.JsonSyntaxException; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe; -import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; import io.github.moulberry.notenoughupdates.core.util.StringUtils; import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; import io.github.moulberry.notenoughupdates.util.Constants; @@ -34,8 +33,6 @@ import io.github.moulberry.notenoughupdates.util.SBInfo; import io.github.moulberry.notenoughupdates.util.Utils; import lombok.var; import net.minecraft.client.Minecraft; -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.client.event.ClientChatReceivedEvent; @@ -56,7 +53,6 @@ import java.io.OutputStreamWriter; import java.lang.reflect.Type; import java.nio.charset.StandardCharsets; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -87,6 +83,14 @@ public class FairySouls { return instance; } + public boolean isTrackSouls() { + return trackSouls; + } + + public boolean isShowSouls() { + return showSouls; + } + @SubscribeEvent public void onWorldLoad(WorldEvent.Load event) { currentLocation = null; @@ -379,25 +383,6 @@ public class FairySouls { Utils.addChatMessage(s); } - private static void printHelp() { - print(""); - print(EnumChatFormatting.DARK_PURPLE.toString() + EnumChatFormatting.BOLD + " NEU Fairy Soul Waypoint Guide"); - print(EnumChatFormatting.LIGHT_PURPLE + "Shows waypoints for every fairy soul in your world"); - print(EnumChatFormatting.LIGHT_PURPLE + "Clicking a fairy soul automatically removes it from the list"); - if (!NotEnoughUpdates.INSTANCE.config.hidden.dev) { - print(EnumChatFormatting.DARK_RED + "" + EnumChatFormatting.OBFUSCATED + "Ab" + EnumChatFormatting.RESET + - EnumChatFormatting.DARK_RED + "!" + EnumChatFormatting.RESET + EnumChatFormatting.RED + - " This feature cannot and will not work in Dungeons. " + EnumChatFormatting.DARK_RED + "!" + - EnumChatFormatting.OBFUSCATED + "Ab"); - } - print(EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + " Commands:"); - print(EnumChatFormatting.YELLOW + "/neusouls help - Display this message"); - print(EnumChatFormatting.YELLOW + "/neusouls on/off - Enable/disable showing waypoint markers"); - print(EnumChatFormatting.YELLOW + - "/neusouls clear/unclear - Marks every waypoint in your current world as completed/uncompleted"); - print(""); - } - @SubscribeEvent(priority = EventPriority.HIGHEST, receiveCanceled = true) public void onChatReceived(ClientChatReceivedEvent event) { if (!trackSouls || event.type == 2) return; @@ -407,53 +392,4 @@ public class FairySouls { markClosestSoulFound(); } } - - public static class FairySoulsCommand extends ClientCommandBase { - public FairySoulsCommand() { - super("neusouls"); - } - - @Override - public List<String> getCommandAliases() { - return Collections.singletonList("fairysouls"); - } - - @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException { - if (args.length != 1) { - printHelp(); - return; - } - - String subcommand = args[0].toLowerCase(); - switch (subcommand) { - case "help": - printHelp(); - break; - case "on": - case "enable": - if (!FairySouls.instance.trackSouls) { - print( - EnumChatFormatting.RED + "Fairy soul tracking is off, enable it using /neu before using this command"); - return; - } - print(EnumChatFormatting.DARK_PURPLE + "Enabled fairy soul waypoints"); - FairySouls.getInstance().setShowFairySouls(true); - break; - case "off": - case "disable": - FairySouls.getInstance().setShowFairySouls(false); - print(EnumChatFormatting.DARK_PURPLE + "Disabled fairy soul waypoints"); - break; - case "clear": - FairySouls.getInstance().markAllAsFound(); - break; - case "unclear": - FairySouls.getInstance().markAllAsMissing(); - break; - default: - print(EnumChatFormatting.RED + "Unknown subcommand: " + subcommand); - } - } - } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java index 800e25b1..b43b0e78 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java @@ -174,11 +174,7 @@ public class FishingHelper { Utils.drawStringCentered( String.format("%.02fs", seconds), - Minecraft.getMinecraft().fontRendererObj, - 0, - -baseHeight - Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT, - false, - color + 0, -baseHeight - Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT, false, color ); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/GardenNpcPrices.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/GardenNpcPrices.java new file mode 100644 index 00000000..294194b9 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/GardenNpcPrices.java @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2023 NotEnoughUpdates contributors + * + * This file is part of NotEnoughUpdates. + * + * NotEnoughUpdates is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * NotEnoughUpdates is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. + */ + +package io.github.moulberry.notenoughupdates.miscfeatures; + +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe; +import io.github.moulberry.notenoughupdates.util.ItemResolutionQuery; +import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraftforge.event.entity.player.ItemTooltipEvent; +import net.minecraftforge.event.world.WorldEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +@NEUAutoSubscribe +public class GardenNpcPrices { + + private final Pattern itemRegex = Pattern.compile("§5§o §.([a-zA-Z \\-]+)(?:§8x(\\d+))?"); + //§5§o §aEnchanted Cactus Green §8x421 + //§5§o §aEnchanted Hay Bale §8x62 + //§5§o §9Enchanted Cookie §8x4 + //§5§o §9Tightly-Tied Hay Bale + + private Map<List<String>, List<String>> prices = new HashMap<>(); + + @SubscribeEvent + public void onGardenNpcPrices(ItemTooltipEvent event) { + if (!NotEnoughUpdates.INSTANCE.config.tooltipTweaks.gardenNpcPrice) return; + if (event.toolTip.size() <= 2 || event.itemStack.getItem() != Item.getItemFromBlock(Blocks.stained_hardened_clay)) return; + + List<String> tooltipCopy = new ArrayList<>(event.toolTip); + if (prices.get(tooltipCopy) == null) { + for (int i = 2; i < event.toolTip.size(); i++) { + Matcher matcher = itemRegex.matcher(event.toolTip.get(i)); + + if (matcher.matches()) { + int amount = 1; + if (matcher.group(2) != null) amount = Integer.parseInt(matcher.group(2)); + + double cost = calculateCost(ItemResolutionQuery.findInternalNameByDisplayName(matcher.group(1).trim(), false), amount); + event.toolTip.set(i, event.toolTip.get(i) + " §7(§6" + (cost == 0 ? "?" : Utils.shortNumberFormat(cost, 0)) + "§7 coins)"); + } else { + prices.put(tooltipCopy, event.toolTip); + } + } + } else { + event.toolTip.clear(); + event.toolTip.addAll(prices.get(tooltipCopy)); + } + } + public double calculateCost(String internalName, int amount) { + double price = NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarOrBin(internalName, false); + if (price != -1) { + return price * amount; + } + return 0d; + } + + @SubscribeEvent + public void onWorldLoad(WorldEvent.Load event) { + prices.clear(); + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCustomizeManager.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCustomizeManager.java index dad801ec..ecab042c 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCustomizeManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCustomizeManager.java @@ -22,16 +22,23 @@ package io.github.moulberry.notenoughupdates.miscfeatures; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import io.github.moulberry.notenoughupdates.NEUManager; -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe; import io.github.moulberry.notenoughupdates.core.ChromaColour; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.entity.layers.LayerArmorBase; import net.minecraft.client.renderer.texture.DynamicTexture; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.resources.IResourceManager; import net.minecraft.client.resources.IResourceManagerReloadListener; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.event.world.WorldEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL14; @@ -46,9 +53,12 @@ import java.io.FileOutputStream; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.nio.charset.StandardCharsets; +import java.util.ArrayList; import java.util.HashMap; +import java.util.Random; import java.util.function.Consumer; +@NEUAutoSubscribe public class ItemCustomizeManager { public static class ReloadListener implements IResourceManagerReloadListener { @Override @@ -81,6 +91,9 @@ public class ItemCustomizeManager { public String customGlintColour = DEFAULT_GLINT_COLOR; public String customLeatherColour = null; + + public String defaultItem = null; + public String customItem = null; } public static void putItemData(String uuid, ItemData data) { @@ -313,4 +326,104 @@ public class ItemCustomizeManager { } catch (Exception ignored) { } } + + public static Item getCustomItem(ItemStack stack) { + ItemData data = getDataForItem(stack); + if (data == null || data.customItem == null || data.customItem.length() == 0) return stack.getItem(); + Item newItem = Item.getByNameOrId(data.customItem.split(":")[0]); + if (newItem == null) return stack.getItem(); + return newItem; + } + + public static Item getCustomItem(ItemStack stack, String newItemString) { + Item newItem = Item.getByNameOrId(newItemString.split(":")[0]); + if (newItem == null) return stack.getItem(); + return newItem; + } + + static Random random = new Random(); + static HashMap<Integer, Long> lastUpdate = new HashMap<>(); + static HashMap<Integer, Integer> damageMap = new HashMap<>(); + + public static int getCustomItemDamage(ItemStack stack) { + ItemData data = getDataForItem(stack); + if (data == null || data.customItem == null || data.customItem.length() == 0) return stack.getMetadata(); + try { + String damageString = data.customItem.split(":")[1]; + if (damageString.equals("?")) { + ArrayList<ItemStack> list = new ArrayList<>(); + getCustomItem(stack).getSubItems(getCustomItem(stack), null, list); + if (damageMap.get(stack.getTagCompound().hashCode()) == null || System.currentTimeMillis() - lastUpdate.get(stack.getTagCompound().hashCode()) > 250) { + damageMap.put(stack.getTagCompound().hashCode(), random.nextInt(list.size())); + + lastUpdate.put(stack.getTagCompound().hashCode(), System.currentTimeMillis()); + } + return damageMap.get(stack.getTagCompound().hashCode()); + } + return Integer.parseInt(data.customItem.split(":")[1]); + } catch (Exception e) { + if (Item.getByNameOrId(data.defaultItem) == Items.skull && getCustomItem(stack) != Items.skull) return 0; + return stack.getMetadata(); + } + } + + @SubscribeEvent + public void onWorldUnload(WorldEvent.Unload event) { + damageMap.clear(); + lastUpdate.clear(); + } + + public static boolean shouldRenderLeatherColour(ItemStack stack) { + ItemData data = getDataForItem(stack); + if (data == null || data.customItem == null || data.customItem.length() == 0) return stack.getItem() instanceof ItemArmor && + ((ItemArmor) stack.getItem()).getArmorMaterial() == ItemArmor.ArmorMaterial.LEATHER; + Item item = Item.getByNameOrId(data.customItem); + if (item == null) return stack.getItem() instanceof ItemArmor && + ((ItemArmor) stack.getItem()).getArmorMaterial() == ItemArmor.ArmorMaterial.LEATHER; + return item instanceof ItemArmor && + ((ItemArmor) item).getArmorMaterial() == ItemArmor.ArmorMaterial.LEATHER; + } + + public static boolean hasCustomItem(ItemStack stack) { + ItemData data = getDataForItem(stack); + if (data == null || data.customItem == null || data.customItem.length() == 0 || data.defaultItem == null || data.customItem.equals(data.defaultItem)) return false; + Item item = Item.getByNameOrId(data.customItem.split(":")[0]); + Item defaultItem = Item.getByNameOrId(data.defaultItem); + if (item == null) { + data.customItem = null; + return false; + } + return defaultItem != item; + } + + public static ItemStack useCustomArmour(LayerArmorBase<?> instance, EntityLivingBase entitylivingbaseIn, int armorSlot) { + ItemStack stack = instance.getCurrentArmor(entitylivingbaseIn, armorSlot); + if (stack == null) return stack; + ItemStack newStack = stack.copy(); + newStack.setItem(ItemCustomizeManager.getCustomItem(newStack)); + newStack.setItemDamage(ItemCustomizeManager.getCustomItemDamage(newStack)); + if (armorSlot != 4) { + if (newStack.getItem() instanceof ItemArmor) return newStack; + else return stack; + } + return newStack; + } + + public static ItemStack useCustomItem(ItemStack stack) { + if (stack == null) return stack; + if (!ItemCustomizeManager.hasCustomItem(stack)) return stack; + ItemStack newStack = stack.copy(); + newStack.setItem(ItemCustomizeManager.getCustomItem(newStack)); + newStack.setItemDamage(ItemCustomizeManager.getCustomItemDamage(newStack)); + return newStack; + } + + public static ItemStack setHeadArmour(EntityLivingBase instance, int i) { + if (instance.getCurrentArmor(3) == null) return null; + ItemStack stack = instance.getCurrentArmor(3).copy(); + stack.setItem(ItemCustomizeManager.getCustomItem(stack)); + stack.setItemDamage(ItemCustomizeManager.getCustomItemDamage(stack)); + return stack; + } + } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/MiningStuff.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/MiningStuff.java index 2cbd3125..9217dcae 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/MiningStuff.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/MiningStuff.java @@ -152,12 +152,7 @@ public class MiningStuff { if (alpha > 10) { TextRenderUtils.drawStringCenteredScaledMaxWidth( "Titanium has spawned nearby!", - Minecraft.getMinecraft().fontRendererObj, - 0, - 0, - true, - width / 4 - 20, - colour | (colour << 8) | (colour << 16) | (alpha << 24) + 0, 0, true, width / 4 - 20, colour | (colour << 8) | (colour << 16) | (alpha << 24) ); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/MutingComposter.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/MutingComposter.java new file mode 100644 index 00000000..e2aa8cf2 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/MutingComposter.java @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2023 NotEnoughUpdates contributors + * + * This file is part of NotEnoughUpdates. + * + * NotEnoughUpdates is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * NotEnoughUpdates is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. + */ + +package io.github.moulberry.notenoughupdates.miscfeatures; + +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe; +import io.github.moulberry.notenoughupdates.util.SBInfo; +import net.minecraftforge.client.event.sound.PlaySoundEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +import java.util.Arrays; +import java.util.List; + +@NEUAutoSubscribe +public class MutingComposter { + + private static final MutingComposter INSTANCE = new MutingComposter(); + private final List<String> mutableSounds = Arrays.asList( + "mob.wolf.growl", + "tile.piston.out", + "liquid.water", + "mob.chicken.plop" + ); + + public static MutingComposter getInstance() { + return INSTANCE; + } + + protected boolean isEnabled() { + return "garden".equals(SBInfo.getInstance().getLocation()) + && NotEnoughUpdates.INSTANCE.config.garden.muteComposterSounds; + } + + @SubscribeEvent + public void onSoundPlay(PlaySoundEvent event) { + if (mutableSounds.contains(event.name) && isEnabled() && event.sound.getXPosF() == -11.5 && event.sound.getYPosF() == 72.5 && event.sound.getZPosF() == -26.5) { + event.result = null; + } + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java index 716fb37d..ceae782b 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java @@ -473,29 +473,44 @@ public class PetInfoOverlay extends TextOverlay { } } JsonObject pets = Constants.PETS; - if (pets != null && pets.has("custom_pet_leveling") && pets.get("custom_pet_leveling").getAsJsonObject().has(pet.petType.toUpperCase()) && - pets.get("custom_pet_leveling").getAsJsonObject().get(pet.petType.toUpperCase()).getAsJsonObject().has("xp_multiplier")) { - xp *= pets.get("custom_pet_leveling").getAsJsonObject().get(pet.petType.toUpperCase()).getAsJsonObject().get("xp_multiplier").getAsFloat(); + if (pets != null && pets.has("custom_pet_leveling") && + pets.get("custom_pet_leveling").getAsJsonObject().has(pet.petType.toUpperCase()) && + pets.get("custom_pet_leveling").getAsJsonObject().get(pet.petType.toUpperCase()).getAsJsonObject().has( + "xp_multiplier")) { + xp *= pets.get("custom_pet_leveling").getAsJsonObject().get(pet.petType.toUpperCase()).getAsJsonObject().get( + "xp_multiplier").getAsFloat(); } return xp; } + private int firstPetLines = 0; + private int secondPetLines = 0; + @Override public void updateFrequent() { Pet currentPet = getCurrentPet(); if (!NotEnoughUpdates.INSTANCE.config.petOverlay.enablePetInfo || currentPet == null) { overlayStrings = null; } else { + firstPetLines = 0; + secondPetLines = 0; overlayStrings = new ArrayList<>(); overlayStrings.addAll(createStringsForPet(currentPet, false)); + firstPetLines = overlayStrings.size(); Pet currentPet2 = getCurrentPet2(); if (currentPet2 != null) { overlayStrings.add(""); + if (firstPetLines == 1) { + overlayStrings.add(""); + } overlayStrings.addAll(createStringsForPet(currentPet2, true)); + secondPetLines = overlayStrings.size() - firstPetLines - 1; + if (firstPetLines == 1) { + secondPetLines--; + } } - } } @@ -519,14 +534,20 @@ public class PetInfoOverlay extends TextOverlay { currentPet.rarity.chatFormatting + WordUtils.capitalizeFully(currentPet.petType.replace("_", " ")); - String lvlStringShort = EnumChatFormatting.AQUA + "" + roundFloat(levelXp) + "/" + - roundFloat(currentPet.petLevel.getExpRequiredForNextLevel()) - + EnumChatFormatting.YELLOW + " (" + getLevelPercent(currentPet) + "%)"; + float levelPercent = getLevelPercent(currentPet); + String lvlStringShort = null; + String lvlString = null; + + if (levelPercent != 100 || !NotEnoughUpdates.INSTANCE.config.petOverlay.hidePetLevelProgress) { + lvlStringShort = EnumChatFormatting.AQUA + "" + roundFloat(levelXp) + "/" + + roundFloat(currentPet.petLevel.getExpRequiredForNextLevel()) + + EnumChatFormatting.YELLOW + " (" + levelPercent + "%)"; - String lvlString = EnumChatFormatting.AQUA + "" + - Utils.shortNumberFormat(Math.min(levelXp, currentPet.petLevel.getExpRequiredForNextLevel()), 0) + "/" + - Utils.shortNumberFormat(currentPet.petLevel.getExpRequiredForNextLevel(), 0) - + EnumChatFormatting.YELLOW + " (" + getLevelPercent(currentPet) + "%)"; + lvlString = EnumChatFormatting.AQUA + "" + + Utils.shortNumberFormat(Math.min(levelXp, currentPet.petLevel.getExpRequiredForNextLevel()), 0) + "/" + + Utils.shortNumberFormat(currentPet.petLevel.getExpRequiredForNextLevel(), 0) + + EnumChatFormatting.YELLOW + " (" + levelPercent + "%)"; + } float xpGain; if (!secondPet) { @@ -593,6 +614,8 @@ public class PetInfoOverlay extends TextOverlay { String finalEtaMaxStr = etaMaxStr; String finalXpGainString = xpGainString; String finalPetItemStr = petItemStr; + String finalLvlString = lvlString; + String finalLvlStringShort = lvlStringShort; return new ArrayList<String>() {{ for (int index : NotEnoughUpdates.INSTANCE.config.petOverlay.petOverlayText) { switch (index) { @@ -600,10 +623,10 @@ public class PetInfoOverlay extends TextOverlay { add(petName); break; case 1: - add(lvlStringShort); + if (finalLvlStringShort != null) add(finalLvlStringShort); break; case 2: - add(lvlString); + if (finalLvlString != null) add(finalLvlString); break; case 3: add(finalXpGainString); @@ -716,6 +739,10 @@ public class PetInfoOverlay extends TextOverlay { GlStateManager.enableDepth(); GlStateManager.pushMatrix(); Utils.pushGuiScale(NotEnoughUpdates.INSTANCE.config.locationedit.guiScale); + + if (firstPetLines == 1) y -= 9; + if (firstPetLines == 2) y -= 3; + GlStateManager.translate(x - 2, y - 2, 0); GlStateManager.scale(2, 2, 1); Utils.drawItemStack(stack, 0, 0); @@ -730,12 +757,16 @@ public class PetInfoOverlay extends TextOverlay { if (petItem2 != null) { Vector2f position = getPosition(overlayWidth, overlayHeight, true); int x = (int) position.x; - int y = (int) position.y + NotEnoughUpdates.INSTANCE.config.petOverlay.petOverlayText.size() * 10; + int y = (int) position.y + (overlayStrings.size() - secondPetLines) * 10; ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(petItem2); GlStateManager.enableDepth(); GlStateManager.pushMatrix(); Utils.pushGuiScale(NotEnoughUpdates.INSTANCE.config.locationedit.guiScale); + + if (secondPetLines == 1) y -= 9; + if (secondPetLines == 2) y -= 3; + GlStateManager.translate(x - 2, y - 2, 0); GlStateManager.scale(2, 2, 1); Utils.drawItemStack(stack, 0, 0); @@ -1114,7 +1145,7 @@ public class PetInfoOverlay extends TextOverlay { PetInfoOverlay.config.selectedPet = -1; Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( EnumChatFormatting.RED + "[NEU] Can't find pet \u00a7" + petStringMatch + - EnumChatFormatting.RED + " try revisiting all pages of /pets.")); + EnumChatFormatting.RED + " try revisiting all pages of /pets.")); } } } else if ((chatMessage.toLowerCase().startsWith("you despawned your")) || (chatMessage.toLowerCase().contains( diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PresetWarning.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PresetWarning.java new file mode 100644 index 00000000..5e57744b --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PresetWarning.java @@ -0,0 +1,217 @@ +/* + * Copyright (C) 2023 NotEnoughUpdates contributors + * + * This file is part of NotEnoughUpdates. + * + * NotEnoughUpdates is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * NotEnoughUpdates is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. + */ + +package io.github.moulberry.notenoughupdates.miscfeatures; + +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe; +import io.github.moulberry.notenoughupdates.core.GuiElement; +import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; +import io.github.moulberry.notenoughupdates.core.util.render.TextRenderUtils; +import io.github.moulberry.notenoughupdates.events.SlotClickEvent; +import io.github.moulberry.notenoughupdates.util.ItemUtils; +import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.client.Minecraft; +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.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.util.List; + +@NEUAutoSubscribe +public class PresetWarning extends GuiElement { + private static final PresetWarning INSTANCE = new PresetWarning(); + + private boolean showWarning = false; + private String presetName = null; + private int presetSlot = -1; + + public static PresetWarning getInstance() { + return INSTANCE; + } + + private boolean shouldPerformCheck() { + if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) { + showWarning = false; + return false; + } + + if (Utils.getOpenChestName().startsWith("Plot Modification: ")) { + return true; + } else { + showWarning = false; + return false; + } + } + + public boolean shouldShow() { + return shouldPerformCheck() && showWarning; + } + + @SubscribeEvent + public void onMouseClick(SlotClickEvent event) { + if (!shouldPerformCheck()) return; + if (!NotEnoughUpdates.INSTANCE.config.garden.presetDeleteWarning) return; + if (event.slotId == -999) return; + if (event.clickedButton == 0) return; + + GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen; + + ItemStack clickedPreset = chest.inventorySlots.getSlot(event.slotId).getStack(); + if (clickedPreset == null) return; + + List<String> list = ItemUtils.getLore(clickedPreset); + if (list.isEmpty()) return; + + String last = list.get(list.size() - 1); + if (last.contains("Right-Click to delete!")) { + showWarning = true; + presetName = clickedPreset.getDisplayName(); + presetSlot = event.slotId; + event.setCanceled(true); + } + } + + public void overrideIsMouseOverSlot(Slot slot, int mouseX, int mouseY, CallbackInfoReturnable<Boolean> cir) { + if (shouldShow()) { + cir.setReturnValue(false); + } + } + + @Override + public void render() { + final ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + final int width = scaledResolution.getScaledWidth(); + final int height = scaledResolution.getScaledHeight(); + + GlStateManager.disableLighting(); + + GlStateManager.pushMatrix(); + GlStateManager.translate(0, 0, 500); + + Gui.drawRect(0, 0, width, height, 0x80000000); + + RenderUtils.drawFloatingRectDark(width / 2 - 90, height / 2 - 45, 180, 90); + + int neuLength = Minecraft.getMinecraft().fontRendererObj.getStringWidth("\u00a7lNEU"); + Minecraft.getMinecraft().fontRendererObj.drawString( + "\u00a7lNEU", + width / 2 + 90 - neuLength - 3, + height / 2 - 45 + 4, + 0xff000000 + ); + + TextRenderUtils.drawStringCenteredScaledMaxWidth("Are you SURE?", Minecraft.getMinecraft().fontRendererObj, + width / 2, height / 2 - 45 + 10, false, 170, 0xffff4040 + ); + + String sellLine = "\u00a77[ \u00a7r" + presetName + "\u00a77 ]"; + + TextRenderUtils.drawStringCenteredScaledMaxWidth(sellLine, Minecraft.getMinecraft().fontRendererObj, + width / 2, height / 2 - 45 + 25, false, 170, 0xffffffff + ); + + TextRenderUtils.drawStringCenteredScaledMaxWidth( + "Continue removing this preset?", + Minecraft.getMinecraft().fontRendererObj, + width / 2, + height / 2 - 45 + 50, + false, + 170, + 0xffa0a0a0 + ); + + RenderUtils.drawFloatingRectDark(width / 2 - 43, height / 2 + 23, 40, 16, false); + RenderUtils.drawFloatingRectDark(width / 2 + 3, height / 2 + 23, 40, 16, false); + + TextRenderUtils.drawStringCenteredScaledMaxWidth( + EnumChatFormatting.GREEN + "[Y]es", + Minecraft.getMinecraft().fontRendererObj, + width / 2 - 23, + height / 2 + 31, + true, + 36, + 0xff00ff00 + ); + TextRenderUtils.drawStringCenteredScaledMaxWidth( + EnumChatFormatting.RED + "[N]o", + Minecraft.getMinecraft().fontRendererObj, + width / 2 + 23, + height / 2 + 31, + true, + 36, + 0xffff0000 + ); + + GlStateManager.popMatrix(); + } + + @Override + public boolean mouseInput(int mouseX, int mouseY) { + final ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + final int width = scaledResolution.getScaledWidth(); + final int height = scaledResolution.getScaledHeight(); + + if (Mouse.getEventButtonState()) { + if (mouseY >= height / 2 + 23 && mouseY <= height / 2 + 23 + 16) { + if (mouseX >= width / 2 - 43 && mouseX <= width / 2 - 3) { + makeClick(); + } + showWarning = false; + } + + if (mouseX < width / 2 - 90 || mouseX > width / 2 + 90 || + mouseY < height / 2 - 45 || mouseY > height / 2 + 45) { + showWarning = false; + } + } + + return false; + } + + @Override + public boolean keyboardInput() { + if (!Keyboard.getEventKeyState()) { + if (Keyboard.getEventKey() == Keyboard.KEY_Y || Keyboard.getEventKey() == Keyboard.KEY_RETURN) { + makeClick(); + } + showWarning = false; + } + + return false; + } + + private void makeClick() { + if (presetSlot != -1) { + GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen; + Minecraft.getMinecraft().playerController.windowClick(chest.inventorySlots.windowId, + presetSlot, 1, 0, Minecraft.getMinecraft().thePlayer + ); + presetSlot = -1; + } + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SunTzu.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SunTzu.java index 736d5058..8d1c06f3 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SunTzu.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SunTzu.java @@ -96,7 +96,6 @@ public class SunTzu { int height = Utils.renderStringTrimWidth( EnumChatFormatting.YELLOW + getQuote(), - Minecraft.getMinecraft().fontRendererObj, true, sr.getScaledWidth() / 2 - 100, 5, diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EntityViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EntityViewer.java index 2f091304..1e7dc319 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EntityViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EntityViewer.java @@ -25,7 +25,6 @@ import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.OpenGlHelper; @@ -208,7 +207,6 @@ public class EntityViewer extends GuiScreen { @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { drawDefaultBackground(); - FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj; this.guiLeft = (width - this.xSize) / 2; this.guiTop = (height - this.ySize) / 2; @@ -216,7 +214,7 @@ public class EntityViewer extends GuiScreen { Minecraft.getMinecraft().getTextureManager().bindTexture(BACKGROUND); drawTexturedModalRect(guiLeft, guiTop, 0, 0, this.xSize, this.ySize); - Utils.drawStringScaledMaxWidth(label, fontRenderer, guiLeft + 10, guiTop + 10, false, 100, 0xFF00FF); + Utils.drawStringScaledMaxWidth(label, guiLeft + 10, guiTop + 10, false, 100, 0xFF00FF); renderEntity(entity, guiLeft + 90, guiTop + 75, mouseX, mouseY); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java index 530dcfd1..908ae307 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java @@ -25,9 +25,11 @@ import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.auction.APIManager; import io.github.moulberry.notenoughupdates.core.util.StringUtils; +import io.github.moulberry.notenoughupdates.events.ButtonExclusionZoneEvent; import io.github.moulberry.notenoughupdates.listener.RenderListener; import io.github.moulberry.notenoughupdates.profileviewer.PlayerStats; import io.github.moulberry.notenoughupdates.util.Constants; +import io.github.moulberry.notenoughupdates.util.Rectangle; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; @@ -45,6 +47,7 @@ import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL14; @@ -73,6 +76,22 @@ public class AccessoryBagOverlay { private static final int TAB_MISSING = 4; private static final int TAB_OPTIMIZER = 5; + public static final AccessoryBagOverlay INSTANCE = new AccessoryBagOverlay(); + + @SubscribeEvent + public void onButtonExclusionZones(ButtonExclusionZoneEvent event) { + if (isInAccessoryBag()) { + event.blockArea( + new Rectangle( + event.getGuiBaseRect().getRight(), + event.getGuiBaseRect().getTop(), + 80 /*pane*/ + 24 /*tabs*/ + 4 /*space*/, 150 + ), + ButtonExclusionZoneEvent.PushDirection.TOWARDS_RIGHT + ); + } + } + private static final ItemStack[] TAB_STACKS = new ItemStack[]{ Utils.createItemStack(Items.dye, EnumChatFormatting.DARK_AQUA + "Basic Information", 10, EnumChatFormatting.GREEN + "- Talis count by rarity" @@ -204,24 +223,8 @@ public class AccessoryBagOverlay { private static Set<Integer> pagesVisited = new HashSet<>(); public static void renderVisitOverlay(int x, int y) { - Utils.drawStringCenteredScaledMaxWidth( - "Please visit all", - Minecraft.getMinecraft().fontRendererObj, - x + 40, - y + 78, - true, - 70, - -1 - ); - Utils.drawStringCenteredScaledMaxWidth( - "pages of the bag", - Minecraft.getMinecraft().fontRendererObj, - x + 40, - y + 86, - true, - 70, - -1 - ); + Utils.drawStringCenteredScaledMaxWidth("Please visit all", x + 40, y + 78, true, 70, -1); + Utils.drawStringCenteredScaledMaxWidth("pages of the bag", x + 40, y + 86, true, 70, -1); } private static TreeMap<Integer, Integer> talismanCountRarity = null; @@ -237,15 +240,7 @@ public class AccessoryBagOverlay { } } - Utils.drawStringCenteredScaledMaxWidth( - "# By Rarity", - Minecraft.getMinecraft().fontRendererObj, - x + 40, - y + 12, - false, - 70, - new Color(80, 80, 80).getRGB() - ); + drawString(x, y, "# By Rarity"); int yIndex = 0; for (Map.Entry<Integer, Integer> entry : talismanCountRarity.descendingMap().entrySet()) { @@ -271,15 +266,7 @@ public class AccessoryBagOverlay { } } - Utils.drawStringCenteredScaledMaxWidth( - "Total Stats", - Minecraft.getMinecraft().fontRendererObj, - x + 40, - y + 12, - false, - 70, - new Color(80, 80, 80).getRGB() - ); + drawString(x, y, "Total Stats"); int yIndex = 0; for (int i = 0; i < PlayerStats.defaultStatNames.length; i++) { String statName = PlayerStats.defaultStatNames[i]; @@ -319,15 +306,7 @@ public class AccessoryBagOverlay { } } - Utils.drawStringCenteredScaledMaxWidth( - "Reforge Stats", - Minecraft.getMinecraft().fontRendererObj, - x + 40, - y + 12, - false, - 70, - new Color(80, 80, 80).getRGB() - ); + drawString(x, y, "Reforge Stats"); int yIndex = 0; for (int i = 0; i < PlayerStats.defaultStatNames.length; i++) { String statName = PlayerStats.defaultStatNames[i]; @@ -363,28 +342,12 @@ public class AccessoryBagOverlay { if (duplicates == null) { JsonObject misc = Constants.MISC; if (misc == null) { - Utils.drawStringCenteredScaledMaxWidth( - "Duplicates: ERROR", - Minecraft.getMinecraft().fontRendererObj, - x + 40, - y + 12, - false, - 70, - new Color(80, 80, 80).getRGB() - ); + drawString(x, y, "Duplicates: ERROR"); return; } JsonElement talisman_upgrades_element = misc.get("talisman_upgrades"); if (talisman_upgrades_element == null) { - Utils.drawStringCenteredScaledMaxWidth( - "Duplicates: ERROR", - Minecraft.getMinecraft().fontRendererObj, - x + 40, - y + 12, - false, - 70, - new Color(80, 80, 80).getRGB() - ); + drawString(x, y, "Duplicates: ERROR"); return; } JsonObject talisman_upgrades = talisman_upgrades_element.getAsJsonObject(); @@ -419,25 +382,9 @@ public class AccessoryBagOverlay { } } if (duplicates.isEmpty()) { - Utils.drawStringCenteredScaledMaxWidth( - "No Duplicates", - Minecraft.getMinecraft().fontRendererObj, - x + 40, - y + 12, - false, - 70, - new Color(80, 80, 80).getRGB() - ); + drawString(x, y, "No Duplicates"); } else { - Utils.drawStringCenteredScaledMaxWidth( - "Duplicates: " + duplicates.size(), - Minecraft.getMinecraft().fontRendererObj, - x + 40, - y + 12, - false, - 70, - new Color(80, 80, 80).getRGB() - ); + drawString(x, y, "Duplicates: " + duplicates.size()); int yIndex = 0; for (ItemStack duplicate : duplicates) { @@ -451,9 +398,12 @@ public class AccessoryBagOverlay { } if (duplicates.size() > 11) { - Utils.drawStringCenteredScaledMaxWidth("+" + (duplicates.size() - 10) + " More", - Minecraft.getMinecraft().fontRendererObj, x + 40, y + 16 + 121, false, 70, - new Color(80, 80, 80).getRGB() + Utils.drawStringCenteredScaledMaxWidth( + "+" + (duplicates.size() - 10) + " More", + x + 40, y + 16 + 121, + false, + 70, + gray() ); } } @@ -465,28 +415,12 @@ public class AccessoryBagOverlay { if (missing == null) { JsonObject misc = Constants.MISC; if (misc == null) { - Utils.drawStringCenteredScaledMaxWidth( - "Duplicates: ERROR", - Minecraft.getMinecraft().fontRendererObj, - x + 40, - y + 12, - false, - 70, - new Color(80, 80, 80).getRGB() - ); + drawString(x, y, "Duplicates: ERROR"); return; } JsonElement talisman_upgrades_element = misc.get("talisman_upgrades"); if (talisman_upgrades_element == null) { - Utils.drawStringCenteredScaledMaxWidth( - "Duplicates: ERROR", - Minecraft.getMinecraft().fontRendererObj, - x + 40, - y + 12, - false, - 70, - new Color(80, 80, 80).getRGB() - ); + drawString(x, y, "Duplicates: ERROR"); return; } JsonObject talisman_upgrades = talisman_upgrades_element.getAsJsonObject(); @@ -554,37 +488,15 @@ public class AccessoryBagOverlay { } } if (missing.isEmpty()) { - Utils.drawStringCenteredScaledMaxWidth( - "No Missing", - Minecraft.getMinecraft().fontRendererObj, - x + 40, - y + 12, - false, - 70, - new Color(80, 80, 80).getRGB() - ); + drawString(x, y, "No Missing"); } else { - Utils.drawStringCenteredScaledMaxWidth( - "Missing: " + missing.size(), - Minecraft.getMinecraft().fontRendererObj, - x + 40, - y + 12, - false, - 70, - new Color(80, 80, 80).getRGB() - ); + drawString(x, y, "Missing: " + missing.size()); int yIndex = 0; long currentTime = System.currentTimeMillis(); - int marqueeOffset = (int) (currentTime / 500 % 100); for (ItemStack missingStack : missing) { String s = missingStack.getDisplayName(); - //int marueeOffset - //if(s.length()) { - - //} - s = Minecraft.getMinecraft().fontRendererObj.trimStringToWidth(s, 70); String clean = StringUtils.cleanColourNotModifiers(s); @@ -610,10 +522,7 @@ public class AccessoryBagOverlay { } if (missing.size() > 11) { - Utils.drawStringCenteredScaledMaxWidth("Show All", - Minecraft.getMinecraft().fontRendererObj, x + 40, y + 16 + 121, false, 70, - new Color(80, 80, 80).getRGB() - ); + Utils.drawStringCenteredScaledMaxWidth("Show All", x + 40, y + 16 + 121, false, 70, gray()); final ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft()); final int scaledWidth = scaledresolution.getScaledWidth(); @@ -675,7 +584,7 @@ public class AccessoryBagOverlay { mouseX * scaledresolution.getScaleFactor() / 2, mouseY * scaledresolution.getScaleFactor() / 2, scaledWidth * scaledresolution.getScaleFactor() / 2, - scaledHeight * scaledresolution.getScaleFactor() / 2, -1, Minecraft.getMinecraft().fontRendererObj + scaledHeight * scaledresolution.getScaleFactor() / 2, -1 ); GlStateManager.popMatrix(); } @@ -683,6 +592,10 @@ public class AccessoryBagOverlay { } } + private static void drawString(int x, int y, String abc) { + Utils.drawStringCenteredScaledMaxWidth(abc, x + 40, y + 12, false, 70, gray()); + } + private static boolean forceCC = false; private static boolean forceAS = false; private static boolean useGodPot = true; @@ -690,15 +603,7 @@ public class AccessoryBagOverlay { private static int mainWeapon = 1; public static void renderOptimizerOverlay(int x, int y) { - Utils.drawStringCenteredScaledMaxWidth( - "Optimizer", - Minecraft.getMinecraft().fontRendererObj, - x + 40, - y + 12, - false, - 70, - new Color(80, 80, 80).getRGB() - ); + Utils.drawStringCenteredScaledMaxWidth("Optimizer", x + 40, y + 12, false, 70, gray()); int light = new Color(220, 220, 220).getRGB(); int dark = new Color(170, 170, 170).getRGB(); @@ -724,116 +629,50 @@ public class AccessoryBagOverlay { dark ); + Utils.drawStringCenteredScaledMaxWidth("Force 100% CC", x + 40, y + 27, false, 70, gray()); Utils.drawStringCenteredScaledMaxWidth( - "Force 100% CC", - Minecraft.getMinecraft().fontRendererObj, - x + 40, - y + 27, - false, - 70, - new Color(80, 80, 80).getRGB() - ); - Utils.drawStringCenteredScaledMaxWidth((forceCC ? EnumChatFormatting.GREEN : EnumChatFormatting.GRAY) + "YES", - Minecraft.getMinecraft().fontRendererObj, x + 20, y + 37, - true, 30, new Color(80, 80, 80).getRGB() + (forceCC ? EnumChatFormatting.GREEN : EnumChatFormatting.GRAY) + "YES", x + 20, y + 37, true, 30, gray() ); Utils.drawStringCenteredScaledMaxWidth( (forceCC ? EnumChatFormatting.GRAY : EnumChatFormatting.RED) + "NO", - Minecraft.getMinecraft().fontRendererObj, - x + 60, - y + 37, - true, - 30, - new Color(80, 80, 80).getRGB() + x + 60, y + 37, true, 30, gray() ); - Utils.drawStringCenteredScaledMaxWidth( - "Force 100% ATKSPEED", - Minecraft.getMinecraft().fontRendererObj, - x + 40, - y + 47, - false, - 70, - new Color(80, 80, 80).getRGB() - ); + Utils.drawStringCenteredScaledMaxWidth("Force 100% ATKSPEED", x + 40, y + 47, false, 70, gray()); Utils.drawStringCenteredScaledMaxWidth( (forceAS ? EnumChatFormatting.GREEN : EnumChatFormatting.GRAY) + "YES", - Minecraft.getMinecraft().fontRendererObj, - x + 20, - y + 57, - true, - 30, - new Color(80, 80, 80).getRGB() + x + 20, y + 57, true, 30, gray() ); Utils.drawStringCenteredScaledMaxWidth( (forceAS ? EnumChatFormatting.GRAY : EnumChatFormatting.RED) + "NO", - Minecraft.getMinecraft().fontRendererObj, - x + 60, - y + 57, - true, - 30, - new Color(80, 80, 80).getRGB() + x + 60, y + 57, true, 30, gray() ); - Utils.drawStringCenteredScaledMaxWidth( - "Use God Potion", - Minecraft.getMinecraft().fontRendererObj, - x + 40, - y + 67, - false, - 70, - new Color(80, 80, 80).getRGB() - ); + Utils.drawStringCenteredScaledMaxWidth("Use God Potion", x + 40, y + 67, false, 70, gray()); Utils.drawStringCenteredScaledMaxWidth( (useGodPot ? EnumChatFormatting.GREEN : EnumChatFormatting.GRAY) + "YES", - Minecraft.getMinecraft().fontRendererObj, - x + 20, - y + 77, - true, - 30, - new Color(80, 80, 80).getRGB() + x + 20, y + 77, true, 30, gray() ); Utils.drawStringCenteredScaledMaxWidth( (useGodPot ? EnumChatFormatting.GRAY : EnumChatFormatting.RED) + "NO", - Minecraft.getMinecraft().fontRendererObj, - x + 60, - y + 77, - true, - 30, - new Color(80, 80, 80).getRGB() + x + 60, y + 77, true, 30, gray() ); - Utils.drawStringCenteredScaledMaxWidth( - "Use God Potion", - Minecraft.getMinecraft().fontRendererObj, - x + 40, - y + 87, - false, - 70, - new Color(80, 80, 80).getRGB() - ); + Utils.drawStringCenteredScaledMaxWidth("Use God Potion", x + 40, y + 87, false, 70, gray()); Utils.drawStringCenteredScaledMaxWidth((allowShaded ? EnumChatFormatting.GREEN : EnumChatFormatting.GRAY) + "YES", - Minecraft.getMinecraft().fontRendererObj, x + 20, y + 97, - true, 30, new Color(80, 80, 80).getRGB() + x + 20, y + 97, true, 30, gray() ); Utils.drawStringCenteredScaledMaxWidth((allowShaded ? EnumChatFormatting.GRAY : EnumChatFormatting.RED) + "NO", - Minecraft.getMinecraft().fontRendererObj, x + 60, y + 97, - true, 30, new Color(80, 80, 80).getRGB() + x + 60, y + 97, + true, 30, gray() ); - Utils.drawStringCenteredScaledMaxWidth( - "Main Weapon", - Minecraft.getMinecraft().fontRendererObj, - x + 40, - y + 107, - false, - 70, - new Color(80, 80, 80).getRGB() - ); - Utils.drawStringCenteredScaled("1 2 3 4 5 6 7 8 9", - Minecraft.getMinecraft().fontRendererObj, x + 40, y + 117, - true, 70, new Color(80, 80, 80).getRGB() - ); + Utils.drawStringCenteredScaledMaxWidth("Main Weapon", x + 40, y + 107, false, 70, gray()); + Utils.drawStringCenteredScaled("1 2 3 4 5 6 7 8 9", x + 40, y + 117, true, 70, gray()); + } + + private static int gray() { + return new Color(80, 80, 80).getRGB(); } private static Comparator<String> getItemComparator() { @@ -1018,51 +857,8 @@ public class AccessoryBagOverlay { } } - /*private static void renderAlignedString(String first, String second, float x, float y, int length) { - FontRenderer fontRendererObj = Minecraft.getMinecraft().fontRendererObj; - - if(fontRendererObj.getStringWidth(first + " " + second) >= length) { - for(int xOff=-2; xOff<=2; xOff++) { - for(int yOff=-2; yOff<=2; yOff++) { - if(Math.abs(xOff) != Math.abs(yOff)) { - Utils.drawStringCenteredScaledMaxWidth(Utils.cleanColourNotModifiers(first + " " + second), Minecraft.getMinecraft().fontRendererObj, - x+length/2f+xOff/2f, y+4+yOff/2f, false, length, - new Color(0, 0, 0, 200/Math.max(Math.abs(xOff), Math.abs(yOff))).getRGB()); - } - } - } - - GlStateManager.color(1, 1, 1, 1); - Utils.drawStringCenteredScaledMaxWidth(first + " " + second, Minecraft.getMinecraft().fontRendererObj, - x+length/2f, y+4, false, length, 4210752); - } else { - for(int xOff=-2; xOff<=2; xOff++) { - for(int yOff=-2; yOff<=2; yOff++) { - if(Math.abs(xOff) != Math.abs(yOff)) { - fontRendererObj.drawString(Utils.cleanColourNotModifiers(first), - x+xOff/2f, y+yOff/2f, - new Color(0, 0, 0, 200/Math.max(Math.abs(xOff), Math.abs(yOff))).getRGB(), false); - } - } - } - - int secondLen = fontRendererObj.getStringWidth(second); - GlStateManager.color(1, 1, 1, 1); - fontRendererObj.drawString(first, x, y, 4210752, false); - for(int xOff=-2; xOff<=2; xOff++) { - for(int yOff=-2; yOff<=2; yOff++) { - if(Math.abs(xOff) != Math.abs(yOff)) { - fontRendererObj.drawString(Utils.cleanColourNotModifiers(second), - x+length-secondLen+xOff/2f, y+yOff/2f, - new Color(0, 0, 0, 200/Math.max(Math.abs(xOff), Math.abs(yOff))).getRGB(), false); - } - } - } - - GlStateManager.color(1, 1, 1, 1); - fontRendererObj.drawString(second, x+length-secondLen, y, 4210752, false); - } - }*/ + + private static final HashMap<String, Pattern> STAT_PATTERN_MAP_BONUS = new HashMap<String, Pattern>() {{ String STAT_PATTERN_BONUS_END = ": (?:\\+|-)[0-9]+(?:\\.[0-9]+)?\\%? \\(((?:\\+|-)[0-9]+)%?"; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java index 87691631..3bd90db8 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java @@ -129,11 +129,11 @@ public class CalendarOverlay { private static final long HOUR = MINUTE * 60; private static final long DAY = HOUR * 24; - private static final long DA_OFFSET = 1000 * 60 * 55; - private static final long JF_OFFSET = 1000 * 60 * 15; + private static final long DA_OFFSET = 1000 * 60 * 55; // Dark Auction + private static final long JF_OFFSET = 1000 * 60 * 15; // Jacob's Farming Contest - private static final ItemStack DA_STACK; - private static final ItemStack JF_STACK; + private static final ItemStack DA_STACK; // Dark Auction + private static final ItemStack JF_STACK; // Jacob's Farming Contest static { NBTTagCompound tag = new NBTTagCompound(); @@ -555,11 +555,11 @@ public class CalendarOverlay { if (mouseX >= guiLeft + 151 && mouseX <= guiLeft + 151 + 14) { if (mouseY <= guiTop + 26 + 70) { Minecraft.getMinecraft().playerController.windowClick(cc.windowId, - 50, 2, 3, Minecraft.getMinecraft().thePlayer + 41, 2, 3, Minecraft.getMinecraft().thePlayer ); } else { Minecraft.getMinecraft().playerController.windowClick(cc.windowId, - 45, 2, 3, Minecraft.getMinecraft().thePlayer + 36, 2, 3, Minecraft.getMinecraft().thePlayer ); } } @@ -653,7 +653,7 @@ public class CalendarOverlay { } //Special Events - for (int i = 0; i < 21; i++) { + for (int i = 0; i < 14; i++) { int itemIndex = 10 + i + (i / 7) * 2; ItemStack item = cc.getLowerChestInventory().getStackInSlot(itemIndex); if (item == null) continue; @@ -822,7 +822,7 @@ public class CalendarOverlay { int startingWidth = fr.getStringWidth(starting); fr.drawString(starting, Math.max(guiLeft + 23, width / 2f - startingWidth / 2f), y + 7, -1, false); } else { - Utils.drawStringCentered(EnumChatFormatting.YELLOW + "Event Starting Now!", fr, width / 2, y + 11, false, -1); + Utils.drawStringCentered(EnumChatFormatting.YELLOW + "Event Starting Now!", width / 2, y + 11, false, -1); } int displayWidth = fr.getStringWidth(event.display); @@ -981,7 +981,7 @@ public class CalendarOverlay { GL11.glDisable(GL11.GL_SCISSOR_TEST); } else { if (guiLeft + xSize - 8 - untilLen > (width + displayWidth) / 2) { - Utils.drawStringCentered(nextEvent.display, fr, width / 2f, guiTop + 10, false, -1); + Utils.drawStringCentered(nextEvent.display, width / 2f, guiTop + 10, false, -1); } else { fr.drawString(nextEvent.display, guiLeft + 8 + nextSLen, guiTop + 6, -1, false); } @@ -1026,7 +1026,7 @@ public class CalendarOverlay { if (tooltipToDisplay != null) { drawTimerForeground = true; GlStateManager.translate(0, 0, 100); - Utils.drawHoveringText(tooltipToDisplay, mouseX, Math.max(17, mouseY), width, height, -1, fr); + Utils.drawHoveringText(tooltipToDisplay, mouseX, Math.max(17, mouseY), width, height, -1); GlStateManager.translate(0, 0, -100); } } @@ -1117,24 +1117,24 @@ public class CalendarOverlay { int specialLen = fr.getStringWidth("Special"); fr.drawString("Special", guiLeft + 139 - specialLen, guiTop + 30, 0xffffaa00); - ItemStack mayorStack = cc.getLowerChestInventory().getStackInSlot(46); + ItemStack mayorStack = cc.getLowerChestInventory().getStackInSlot(37); if (mayorStack != null) { String mayor = mayorStack.getDisplayName(); float verticalHeight = Utils.getVerticalHeight(mayor); - Utils.drawStringVertical(mayor, fr, guiLeft + 8, guiTop + 96 - verticalHeight / 2, + Utils.drawStringVertical(mayor, guiLeft + 8, guiTop + 96 - verticalHeight / 2, false, -1 ); } String calendar = EnumChatFormatting.GREEN + "Calendar"; float calendarHeight = Utils.getVerticalHeight(calendar); - Utils.drawStringVertical(calendar, fr, guiLeft + xSize - 12, guiTop + 60 - calendarHeight / 2, + Utils.drawStringVertical(calendar, guiLeft + xSize - 12, guiTop + 60 - calendarHeight / 2, false, -1 ); String rewards = EnumChatFormatting.GOLD + "Rewards"; float rewardsHeight = Utils.getVerticalHeight(rewards); - Utils.drawStringVertical(rewards, fr, guiLeft + xSize - 12, guiTop + 132 - rewardsHeight / 2, + Utils.drawStringVertical(rewards, guiLeft + xSize - 12, guiTop + 132 - rewardsHeight / 2, false, -1 ); @@ -1144,11 +1144,11 @@ public class CalendarOverlay { tooltipToDisplay = mayorStack.getTooltip(Minecraft.getMinecraft().thePlayer, false); } else if (mouseX >= guiLeft + 151 && mouseX <= guiLeft + 151 + 14) { if (mouseY <= guiTop + 26 + 70) { - ItemStack calendarStack = cc.getLowerChestInventory().getStackInSlot(50); + ItemStack calendarStack = cc.getLowerChestInventory().getStackInSlot(41); if (calendarStack != null) tooltipToDisplay = calendarStack.getTooltip(Minecraft.getMinecraft().thePlayer, false); } else { - ItemStack rewardsStack = cc.getLowerChestInventory().getStackInSlot(45); + ItemStack rewardsStack = cc.getLowerChestInventory().getStackInSlot(36); if (rewardsStack != null) tooltipToDisplay = rewardsStack.getTooltip(Minecraft.getMinecraft().thePlayer, false); } @@ -1244,7 +1244,7 @@ public class CalendarOverlay { } //Special Events - for (int i = 0; i < 21; i++) { + for (int i = 0; i < 14; i++) { int itemIndex = 10 + i + (i / 7) * 2; ItemStack item = cc.getLowerChestInventory().getStackInSlot(itemIndex); if (item == null) continue; @@ -1349,7 +1349,7 @@ public class CalendarOverlay { tooltipToDisplay.add(EnumChatFormatting.DARK_GRAY + "In order to show crop types for Jacob's Farming"); tooltipToDisplay.add(EnumChatFormatting.DARK_GRAY + "contest, visit the full SkyBlock calendar and go all"); tooltipToDisplay.add(EnumChatFormatting.DARK_GRAY + "the way to the end of the SkyBlock year"); - Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, fr); + Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1); tooltipToDisplay = null; } } @@ -1415,7 +1415,7 @@ public class CalendarOverlay { } GlStateManager.translate(0, 0, -20); } else if (tooltipToDisplay != null) { - Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, fr); + Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1); } GlStateManager.translate(0, 0, -10); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java index 6f190ada..6d219999 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java @@ -36,6 +36,7 @@ import io.github.moulberry.notenoughupdates.util.ItemUtils; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.gui.inventory.GuiContainer; @@ -146,7 +147,8 @@ public class GuiCustomEnchant extends Gui { if (costs.size() >= 1) { if (useMaxLevelForCost) { - int cost = (maxLevel != null && maxLevel.has(this.enchId) ? maxLevel.get(this.enchId).getAsInt() : costs.size()); + int cost = + (maxLevel != null && maxLevel.has(this.enchId) ? maxLevel.get(this.enchId).getAsInt() : costs.size()); this.xpCost = costs.get(cost - 1).getAsInt(); } else if (level - 1 < costs.size()) { this.xpCost = costs.get(level - 1).getAsInt(); @@ -600,16 +602,15 @@ public class GuiCustomEnchant extends Gui { 0, X_SIZE / 512f, 0, Y_SIZE / 512f, GL11.GL_NEAREST ); - Minecraft.getMinecraft().fontRendererObj.drawString("Applicable", guiLeft + 7, guiTop + 7, 0x404040, false); - Minecraft.getMinecraft().fontRendererObj.drawString("Removable", guiLeft + 247, guiTop + 7, 0x404040, false); + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + fr.drawString("Applicable", guiLeft + 7, guiTop + 7, 0x404040, false); + fr.drawString("Removable", guiLeft + 247, guiTop + 7, 0x404040, false); //Page Text if (currentState == EnchantState.HAS_ITEM || currentState == EnchantState.ADDING_ENCHANT) { String pageStr = "Page: " + currentPage + "/" + expectedMaxPage; - int pageStrLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(pageStr); - Utils.drawStringCentered(pageStr, Minecraft.getMinecraft().fontRendererObj, - guiLeft + X_SIZE / 2, guiTop + 14, false, 0x404040 - ); + int pageStrLen = fr.getStringWidth(pageStr); + Utils.drawStringCentered(pageStr, guiLeft + X_SIZE / 2, guiTop + 14, false, 0x404040); //Page Arrows Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE); @@ -727,12 +728,8 @@ public class GuiCustomEnchant extends Gui { //Can't be enchanted text if (currentState == EnchantState.INVALID_ITEM) { GlStateManager.disableDepth(); - Utils.drawStringCentered("This item can't", Minecraft.getMinecraft().fontRendererObj, - guiLeft + X_SIZE / 2, guiTop + 88, true, 0xffff5555 - ); - Utils.drawStringCentered("be enchanted", Minecraft.getMinecraft().fontRendererObj, - guiLeft + X_SIZE / 2, guiTop + 98, true, 0xffff5555 - ); + Utils.drawStringCentered("This item can't", guiLeft + X_SIZE / 2, guiTop + 88, true, 0xffff5555); + Utils.drawStringCentered("be enchanted", guiLeft + X_SIZE / 2, guiTop + 98, true, 0xffff5555); GlStateManager.enableDepth(); } @@ -755,52 +752,24 @@ public class GuiCustomEnchant extends Gui { //Text if no enchants appear if (currentState == EnchantState.HAS_ITEM || currentState == EnchantState.ADDING_ENCHANT) { if (applicable.isEmpty() && removable.isEmpty() && searchRemovedFromApplicable) { - Utils.drawStringCentered("Can't find that", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 8 + 48, guiTop + 28, true, 0xffff5555 - ); - Utils.drawStringCentered("enchant, perhaps", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 8 + 48, guiTop + 38, true, 0xffff5555 - ); - Utils.drawStringCentered("it is on", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 8 + 48, guiTop + 48, true, 0xffff5555 - ); - Utils.drawStringCentered("another page?", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 8 + 48, guiTop + 58, true, 0xffff5555 - ); + Utils.drawStringCentered("Can't find that", guiLeft + 8 + 48, guiTop + 28, true, 0xffff5555); + Utils.drawStringCentered("enchant, perhaps", guiLeft + 8 + 48, guiTop + 38, true, 0xffff5555); + Utils.drawStringCentered("it is on", guiLeft + 8 + 48, guiTop + 48, true, 0xffff5555); + Utils.drawStringCentered("another page?", guiLeft + 8 + 48, guiTop + 58, true, 0xffff5555); } else if (applicable.isEmpty() && !searchRemovedFromApplicable) { - Utils.drawStringCentered("No applicable", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 8 + 48, guiTop + 28, true, 0xffff5555 - ); - Utils.drawStringCentered("enchants on", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 8 + 48, guiTop + 38, true, 0xffff5555 - ); - Utils.drawStringCentered("this page...", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 8 + 48, guiTop + 48, true, 0xffff5555 - ); + Utils.drawStringCentered("No applicable", guiLeft + 8 + 48, guiTop + 28, true, 0xffff5555); + Utils.drawStringCentered("enchants on", guiLeft + 8 + 48, guiTop + 38, true, 0xffff5555); + Utils.drawStringCentered("this page...", guiLeft + 8 + 48, guiTop + 48, true, 0xffff5555); } if (applicable.isEmpty() && removable.isEmpty() && searchRemovedFromRemovable) { - Utils.drawStringCentered("Can't find that", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 248 + 48, guiTop + 28, true, 0xffff5555 - ); - Utils.drawStringCentered("enchant, perhaps", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 248 + 48, guiTop + 38, true, 0xffff5555 - ); - Utils.drawStringCentered("it is on", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 248 + 48, guiTop + 48, true, 0xffff5555 - ); - Utils.drawStringCentered("another page?", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 248 + 48, guiTop + 58, true, 0xffff5555 - ); + Utils.drawStringCentered("Can't find that", guiLeft + 248 + 48, guiTop + 28, true, 0xffff5555); + Utils.drawStringCentered("enchant, perhaps", guiLeft + 248 + 48, guiTop + 38, true, 0xffff5555); + Utils.drawStringCentered("it is on", guiLeft + 248 + 48, guiTop + 48, true, 0xffff5555); + Utils.drawStringCentered("another page?", guiLeft + 248 + 48, guiTop + 58, true, 0xffff5555); } else if (removable.isEmpty() && !searchRemovedFromRemovable) { - Utils.drawStringCentered("No removable", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 248 + 48, guiTop + 28, true, 0xffff5555 - ); - Utils.drawStringCentered("enchants on", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 248 + 48, guiTop + 38, true, 0xffff5555 - ); - Utils.drawStringCentered("this page...", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 248 + 48, guiTop + 48, true, 0xffff5555 - ); + Utils.drawStringCentered("No removable", guiLeft + 248 + 48, guiTop + 28, true, 0xffff5555); + Utils.drawStringCentered("enchants on", guiLeft + 248 + 48, guiTop + 38, true, 0xffff5555); + Utils.drawStringCentered("this page...", guiLeft + 248 + 48, guiTop + 48, true, 0xffff5555); } } //Available enchants (left) @@ -836,50 +805,14 @@ public class GuiCustomEnchant extends Gui { colour = 0xff5555; } - int levelWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(levelStr); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 16 - levelWidth / 2 - 1, - top + 4, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 16 - levelWidth / 2 + 1, - top + 4, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 16 - levelWidth / 2, - top + 4 - 1, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 16 - levelWidth / 2, - top + 4 + 1, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 16 - levelWidth / 2, - top + 4, - colour, - false - ); + int levelWidth = fr.getStringWidth(levelStr); + fr.drawString(levelStr, guiLeft + 16 - levelWidth / 2 - 1, top + 4, 0x2d2102, false); + fr.drawString(levelStr, guiLeft + 16 - levelWidth / 2 + 1, top + 4, 0x2d2102, false); + fr.drawString(levelStr, guiLeft + 16 - levelWidth / 2, top + 4 - 1, 0x2d2102, false); + fr.drawString(levelStr, guiLeft + 16 - levelWidth / 2, top + 4 + 1, 0x2d2102, false); + fr.drawString(levelStr, guiLeft + 16 - levelWidth / 2, top + 4, colour, false); - Minecraft.getMinecraft().fontRendererObj.drawString( - ench.enchantName, - guiLeft + 8 + 16 + 2 + textOffset, - top + 4 + textOffset, - 0xffffffdd, - true - ); + fr.drawString(ench.enchantName, guiLeft + 8 + 16 + 2 + textOffset, top + 4 + textOffset, 0xffffffdd, true); } GlScissorStack.pop(scaledResolution); @@ -916,53 +849,26 @@ public class GuiCustomEnchant extends Gui { colour = 0xff5555; } - int levelWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(levelStr); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 256 - levelWidth / 2 - 1, - top + 4, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( + int levelWidth = fr.getStringWidth(levelStr); + fr.drawString(levelStr, guiLeft + 256 - levelWidth / 2 - 1, top + 4, 0x2d2102, false); + fr.drawString( levelStr, guiLeft + 256 - levelWidth / 2 + 1, top + 4, 0x2d2102, false ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 256 - levelWidth / 2, - top + 4 - 1, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 256 - levelWidth / 2, - top + 4 + 1, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 256 - levelWidth / 2, - top + 4, - colour, - false - ); + fr.drawString(levelStr, guiLeft + 256 - levelWidth / 2, top + 4 - 1, 0x2d2102, false); + fr.drawString(levelStr, guiLeft + 256 - levelWidth / 2, top + 4 + 1, 0x2d2102, false); + fr.drawString(levelStr, guiLeft + 256 - levelWidth / 2, top + 4, colour, false); - Minecraft.getMinecraft().fontRendererObj.drawString(ench.enchantName, - guiLeft + 248 + 16 + 2 + textOffset, top + 4 + textOffset, 0xffffffdd, true - ); + fr.drawString(ench.enchantName, guiLeft + 248 + 16 + 2 + textOffset, top + 4 + textOffset, 0xffffffdd, true); } GlScissorStack.pop(scaledResolution); //Player Inventory Items - Minecraft.getMinecraft().fontRendererObj.drawString(Minecraft.getMinecraft().thePlayer.inventory - .getDisplayName() - .getUnformattedText(), + fr.drawString( + Minecraft.getMinecraft().thePlayer.inventory.getDisplayName().getUnformattedText(), guiLeft + 102, guiTop + Y_SIZE - 96 + 2, 0x404040 ); int inventoryStartIndex = cc.getLowerChestInventory().getSizeInventory(); @@ -1003,7 +909,7 @@ public class GuiCustomEnchant extends Gui { searchField.setPrependText("\u00a77Search..."); } else { if (searchField.getFocus()) { - int len = Minecraft.getMinecraft().fontRendererObj.getStringWidth(searchField.getTextDisplay()) + 10; + int len = fr.getStringWidth(searchField.getTextDisplay()) + 10; searchField.setSize(Math.max(90, len), 14); } else { searchField.setSize(90, 14); @@ -1041,36 +947,12 @@ public class GuiCustomEnchant extends Gui { colour = 0xff5555; } - int levelWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(levelStr); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - left + 8 - levelWidth / 2 - 1, - top + 4, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - left + 8 - levelWidth / 2 + 1, - top + 4, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - left + 8 - levelWidth / 2, - top + 4 - 1, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - left + 8 - levelWidth / 2, - top + 4 + 1, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, left + 8 - levelWidth / 2, top + 4, colour, false); + int levelWidth = fr.getStringWidth(levelStr); + fr.drawString(levelStr, left + 8 - levelWidth / 2 - 1, top + 4, 0x2d2102, false); + fr.drawString(levelStr, left + 8 - levelWidth / 2 + 1, top + 4, 0x2d2102, false); + fr.drawString(levelStr, left + 8 - levelWidth / 2, top + 4 - 1, 0x2d2102, false); + fr.drawString(levelStr, left + 8 - levelWidth / 2, top + 4 + 1, 0x2d2102, false); + fr.drawString(levelStr, left + 8 - levelWidth / 2, top + 4, colour, false); //Enchant name String name = WordUtils.capitalizeFully(ItemUtils @@ -1085,14 +967,7 @@ public class GuiCustomEnchant extends Gui { } else if (name.equalsIgnoreCase("Luck of the Sea")) { name = "Luck of Sea"; } - Utils.drawStringCentered( - name, - Minecraft.getMinecraft().fontRendererObj, - guiLeft + X_SIZE / 2, - top + 8, - true, - 0xffffffdd - ); + Utils.drawStringCentered(name, guiLeft + X_SIZE / 2, top + 8, true, 0xffffffdd); if (isChangingEnchLevel) { Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE); @@ -1105,42 +980,12 @@ public class GuiCustomEnchant extends Gui { //Enchant level levelStr = "" + enchanterCurrentEnch.level; if (enchanterCurrentEnch.xpCost < 0) levelStr = "?"; - levelWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(levelStr); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - left + 96 + 8 - levelWidth / 2 - 1, - top + 4, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - left + 96 + 8 - levelWidth / 2 + 1, - top + 4, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - left + 96 + 8 - levelWidth / 2, - top + 4 - 1, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - left + 96 + 8 - levelWidth / 2, - top + 4 + 1, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - left + 96 + 8 - levelWidth / 2, - top + 4, - 0xea82ff, - false - ); + levelWidth = fr.getStringWidth(levelStr); + fr.drawString(levelStr, left + 96 + 8 - levelWidth / 2 - 1, top + 4, 0x2d2102, false); + fr.drawString(levelStr, left + 96 + 8 - levelWidth / 2 + 1, top + 4, 0x2d2102, false); + fr.drawString(levelStr, left + 96 + 8 - levelWidth / 2, top + 4 - 1, 0x2d2102, false); + fr.drawString(levelStr, left + 96 + 8 - levelWidth / 2, top + 4 + 1, 0x2d2102, false); + fr.drawString(levelStr, left + 96 + 8 - levelWidth / 2, top + 4, 0xea82ff, false); //Confirm button @@ -1160,18 +1005,14 @@ public class GuiCustomEnchant extends Gui { Utils.drawTexturedRect(guiLeft + X_SIZE / 2 - 1 - 48, top + 18, 48, 14, 0, 48 / 512f, 342 / 512f, (342 + 14) / 512f, GL11.GL_NEAREST ); - Utils.drawStringCentered(confirmText, Minecraft.getMinecraft().fontRendererObj, - guiLeft + X_SIZE / 2 - 1 - 23, top + 18 + 9, false, 0x408040 - ); + Utils.drawStringCentered(confirmText, guiLeft + X_SIZE / 2 - 1 - 23, top + 18 + 9, false, 0x408040); } else { Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE); GlStateManager.color(1, 1, 1, 1); Utils.drawTexturedRect(guiLeft + X_SIZE / 2 - 1 - 48, top + 18, 48, 14, 0, 48 / 512f, 328 / 512f, (328 + 14) / 512f, GL11.GL_NEAREST ); - Utils.drawStringCentered(confirmText, Minecraft.getMinecraft().fontRendererObj, - guiLeft + X_SIZE / 2 - 1 - 24, top + 18 + 8, false, 0x408040 - ); + Utils.drawStringCentered(confirmText, guiLeft + X_SIZE / 2 - 1 - 24, top + 18 + 8, false, 0x408040); if (playerXpLevel < enchanterCurrentEnch.xpCost) { Gui.drawRect(guiLeft + X_SIZE / 2 - 1 - 48, top + 18, guiLeft + X_SIZE / 2 - 1, top + 18 + 14, 0x80000000); @@ -1185,18 +1026,14 @@ public class GuiCustomEnchant extends Gui { Utils.drawTexturedRect(guiLeft + X_SIZE / 2 + 1, top + 18, 48, 14, 0, 48 / 512f, 342 / 512f, (342 + 14) / 512f, GL11.GL_NEAREST ); - Utils.drawStringCentered("Cancel", Minecraft.getMinecraft().fontRendererObj, - guiLeft + X_SIZE / 2 + 1 + 25, top + 18 + 9, false, 0xa04040 - ); + Utils.drawStringCentered("Cancel", guiLeft + X_SIZE / 2 + 1 + 25, top + 18 + 9, false, 0xa04040); } else { Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE); GlStateManager.color(1, 1, 1, 1); Utils.drawTexturedRect(guiLeft + X_SIZE / 2 + 1, top + 18, 48, 14, 0, 48 / 512f, 328 / 512f, (328 + 14) / 512f, GL11.GL_NEAREST ); - Utils.drawStringCentered("Cancel", Minecraft.getMinecraft().fontRendererObj, - guiLeft + X_SIZE / 2 + 1 + 24, top + 18 + 8, false, 0xa04040 - ); + Utils.drawStringCentered("Cancel", guiLeft + X_SIZE / 2 + 1 + 24, top + 18 + 8, false, 0xa04040); } if (mouseY > top + 18 && mouseY <= top + 18 + 16) { @@ -1269,42 +1106,12 @@ public class GuiCustomEnchant extends Gui { ); levelStr = "" + ench.level; - levelWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(levelStr); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - left + 96 + 8 - levelWidth / 2 - 1, - top + 16 * yIndex + 4, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - left + 96 + 8 - levelWidth / 2 + 1, - top + 16 * yIndex + 4, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - left + 96 + 8 - levelWidth / 2, - top + 16 * yIndex + 4 - 1, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - left + 96 + 8 - levelWidth / 2, - top + 16 * yIndex + 4 + 1, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - left + 96 + 8 - levelWidth / 2, - top + 16 * yIndex + 4, - 0xea82ff, - false - ); + levelWidth = fr.getStringWidth(levelStr); + fr.drawString(levelStr, left + 96 + 8 - levelWidth / 2 - 1, top + 16 * yIndex + 4, 0x2d2102, false); + fr.drawString(levelStr, left + 96 + 8 - levelWidth / 2 + 1, top + 16 * yIndex + 4, 0x2d2102, false); + fr.drawString(levelStr, left + 96 + 8 - levelWidth / 2, top + 16 * yIndex + 4 - 1, 0x2d2102, false); + fr.drawString(levelStr, left + 96 + 8 - levelWidth / 2, top + 16 * yIndex + 4 + 1, 0x2d2102, false); + fr.drawString(levelStr, left + 96 + 8 - levelWidth / 2, top + 16 * yIndex + 4, 0xea82ff, false); } GlStateManager.enableDepth(); } @@ -1380,9 +1187,7 @@ public class GuiCustomEnchant extends Gui { Utils.drawItemStack(stackOnMouse, mouseX - 8, mouseY - 8); } } else if (tooltipToDisplay != null) { - Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, - Minecraft.getMinecraft().fontRendererObj - ); + Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1); } GlStateManager.translate(0, 0, -300); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java index 5053ae70..41208681 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java @@ -31,7 +31,6 @@ import io.github.moulberry.notenoughupdates.itemeditor.GuiElementTextField; import io.github.moulberry.notenoughupdates.options.NEUConfig; 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.GuiScreen; import net.minecraft.client.renderer.GlStateManager; @@ -132,7 +131,6 @@ public class GuiEnchantColour extends GuiScreen { Utils.drawStringCentered( "Add Ench Colour", - fontRendererObj, guiLeft + xSize / 2 + 1, guiTop + ySize - 20, false, @@ -156,7 +154,7 @@ public class GuiEnchantColour extends GuiScreen { if (colourCode.length() > 1) colourCode = String.valueOf(colourCode.toLowerCase().charAt(0)); if (comparator.length() > 1) comparator = String.valueOf(comparator.toLowerCase().charAt(0)); - Utils.drawStringCentered(comparator, fontRendererObj, guiLeft + 96, guiTop + 33 + 25 * yIndex, false, 4210752); + Utils.drawStringCentered(comparator, guiLeft + 96, guiTop + 33 + 25 * yIndex, false, 4210752); if (guiElementTextFields.size() <= yIndex) { guiElementTextFields.add(new GuiElementTextField[3]); @@ -226,7 +224,6 @@ public class GuiEnchantColour extends GuiScreen { yIndex++; } renderSideBar(mouseX, mouseY, partialTicks); - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; List<String> tooltipToDisplay = null; GlStateManager.color(1, 1, 1, 1); Minecraft.getMinecraft().getTextureManager().bindTexture(help); @@ -275,13 +272,13 @@ public class GuiEnchantColour extends GuiScreen { if (mouseY >= guiTopSidebar - 34 && mouseY <= guiTopSidebar - 18 && maxedBookFound == 1) { tooltipToDisplay = maxedBook.getTooltip(Minecraft.getMinecraft().thePlayer, false); - Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, fr); + Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1); tooltipToDisplay = null; renderingTooltip = true; } if (mouseY >= guiTopSidebar - 52 && mouseY <= guiTopSidebar - 34 && maxedAttBookFound == 1 && !renderingTooltip) { tooltipToDisplay = maxedAttBook.getTooltip(Minecraft.getMinecraft().thePlayer, false); - Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, fr); + Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1); tooltipToDisplay = null; renderingTooltip = true; } @@ -326,7 +323,7 @@ public class GuiEnchantColour extends GuiScreen { EnumChatFormatting.GRAY + "" + EnumChatFormatting.ITALIC + "I" + EnumChatFormatting.RESET + EnumChatFormatting.GRAY + " = " + EnumChatFormatting.ITALIC + "Italic" ); - Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, fr); + Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1); tooltipToDisplay = null; } } @@ -390,7 +387,6 @@ public class GuiEnchantColour extends GuiScreen { ); Utils.drawStringCenteredScaledMaxWidth( "Load preset", - fontRendererObj, guiLeft + xSize + 4 + 44, guiTopSidebar + 8, false, @@ -399,7 +395,6 @@ public class GuiEnchantColour extends GuiScreen { ); Utils.drawStringCenteredScaledMaxWidth( "from Clipboard", - fontRendererObj, guiLeft + xSize + 4 + 44, guiTopSidebar + 16, false, @@ -408,7 +403,6 @@ public class GuiEnchantColour extends GuiScreen { ); Utils.drawStringCenteredScaledMaxWidth( "Save preset", - fontRendererObj, guiLeft + xSize + 4 + 44, guiTopSidebar + 8 + 24, false, @@ -417,7 +411,6 @@ public class GuiEnchantColour extends GuiScreen { ); Utils.drawStringCenteredScaledMaxWidth( "to Clipboard", - fontRendererObj, guiLeft + xSize + 4 + 44, guiTopSidebar + 16 + 24, false, @@ -426,7 +419,6 @@ public class GuiEnchantColour extends GuiScreen { ); Utils.drawStringCenteredScaledMaxWidth( "Reset Config", - fontRendererObj, guiLeft + xSize + 4 + 44, guiTopSidebar + 12 + 24 * 2, false, diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiInvButtonEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiInvButtonEditor.java index d97227cf..147bf567 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiInvButtonEditor.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiInvButtonEditor.java @@ -411,7 +411,6 @@ public class GuiInvButtonEditor extends GuiScreen { ); Utils.drawStringCenteredScaledMaxWidth( "Load preset", - fontRendererObj, guiLeft - 44 - 2 - 22 - (NotEnoughUpdates.INSTANCE.config.customArmour.enableArmourHud ? 25 : 0), guiTop + 8, false, @@ -420,7 +419,6 @@ public class GuiInvButtonEditor extends GuiScreen { ); Utils.drawStringCenteredScaledMaxWidth( "from Clipboard", - fontRendererObj, guiLeft - 44 - 2 - 22 - (NotEnoughUpdates.INSTANCE.config.customArmour.enableArmourHud ? 25 : 0), guiTop + 16, false, @@ -429,7 +427,6 @@ public class GuiInvButtonEditor extends GuiScreen { ); Utils.drawStringCenteredScaledMaxWidth( "Save preset", - fontRendererObj, guiLeft - 44 - 2 - 22 - (NotEnoughUpdates.INSTANCE.config.customArmour.enableArmourHud ? 25 : 0), guiTop + 8 + 24, false, @@ -438,7 +435,6 @@ public class GuiInvButtonEditor extends GuiScreen { ); Utils.drawStringCenteredScaledMaxWidth( "to Clipboard", - fontRendererObj, guiLeft - 44 - 2 - 22 - (NotEnoughUpdates.INSTANCE.config.customArmour.enableArmourHud ? 25 : 0), guiTop + 16 + 24, false, @@ -459,7 +455,6 @@ public class GuiInvButtonEditor extends GuiScreen { ); Utils.drawStringCenteredScaledMaxWidth( "\u00a7nPresets", - fontRendererObj, guiLeft + xSize + 22 + 40, guiTop + 10, false, @@ -471,7 +466,6 @@ public class GuiInvButtonEditor extends GuiScreen { for (String presetName : presets.keySet()) { Utils.drawStringCenteredScaledMaxWidth( presetName, - fontRendererObj, guiLeft + xSize + 22 + 40, guiTop + 25 + 10 * (index++), false, diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemCustomize.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemCustomize.java index 129699da..d9b24895 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemCustomize.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemCustomize.java @@ -53,8 +53,10 @@ public class GuiItemCustomize extends GuiScreen { private static final ResourceLocation RESET = new ResourceLocation("notenoughupdates:itemcustomize/reset.png"); private final ItemStack stack; + private ItemStack customItemStack; private final String itemUUID; private final GuiElementTextField textFieldRename = new GuiElementTextField("", 158, 20, GuiElementTextField.COLOUR); + private final GuiElementTextField textFieldCustomItem = new GuiElementTextField("", 180, 20, GuiElementTextField.COLOUR); private final GuiElementBoolean enchantGlintButton; private int renderHeight = 0; @@ -65,13 +67,15 @@ public class GuiItemCustomize extends GuiScreen { private String customGlintColour = null; private String customLeatherColour = null; - private final boolean supportCustomLeatherColour; + private boolean supportCustomLeatherColour; + private String lastCustomItem = ""; private GuiElement editor = null; public GuiItemCustomize(ItemStack stack, String itemUUID) { this.stack = stack; this.itemUUID = itemUUID; + this.customItemStack = copy(stack); IBakedModel model = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getItemModel(stack); boolean stackHasEffect = stack.hasEffect() && !model.isBuiltInRenderer(); @@ -82,14 +86,20 @@ public class GuiItemCustomize extends GuiScreen { if (data.customName != null) { textFieldRename.setText(data.customName); } + if (data.customItem != null && data.customItem.length() > 0) { + textFieldCustomItem.setText(data.customItem); + } else { + textFieldCustomItem.setText(stack.getItem().getRegistryName().replace("minecraft:", "")); + } this.customGlintColour = data.customGlintColour; this.customLeatherColour = data.customLeatherColour; } else { this.enchantGlint = stackHasEffect; + textFieldCustomItem.setText(stack.getItem().getRegistryName().replace("minecraft:", "")); } - supportCustomLeatherColour = stack.getItem() instanceof ItemArmor && - ((ItemArmor) stack.getItem()).getArmorMaterial() == ItemArmor.ArmorMaterial.LEATHER; + supportCustomLeatherColour = customItemStack.getItem() instanceof ItemArmor && + ((ItemArmor) customItemStack.getItem()).getArmorMaterial() == ItemArmor.ArmorMaterial.LEATHER; enchantGlintCustomColourAnimation.setValue(enchantGlint ? 17 : 0); this.enchantGlintButton = new GuiElementBoolean(0, 0, () -> enchantGlint, (bool) -> { @@ -105,7 +115,7 @@ public class GuiItemCustomize extends GuiScreen { } public String getChromaStrFromLeatherColour() { - return ChromaColour.special(0, 0xff, ((ItemArmor) stack.getItem()).getColor(stack)); + return ChromaColour.special(0, 0xff, ((ItemArmor) customItemStack.getItem()).getColor(customItemStack)); } public void updateData() { @@ -114,6 +124,9 @@ public class GuiItemCustomize extends GuiScreen { IBakedModel model = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getItemModel(stack); boolean stackHasEffect = stack.hasEffect() && !model.isBuiltInRenderer(); + this.customItemStack = copy(stack); + data.defaultItem = stack.getItem().getRegistryName(); + if (this.enchantGlint != stackHasEffect) { data.overrideEnchantGlint = true; data.enchantGlintValue = this.enchantGlint; @@ -127,8 +140,8 @@ public class GuiItemCustomize extends GuiScreen { data.customGlintColour = null; } - if (supportCustomLeatherColour && this.customLeatherColour != null && !this.customLeatherColour.equals( - getChromaStrFromLeatherColour())) { + if (this.customLeatherColour != null && (!(customItemStack.getItem() instanceof ItemArmor) || !this.customLeatherColour.equals( + getChromaStrFromLeatherColour()))) { data.customLeatherColour = this.customLeatherColour; } else { data.customLeatherColour = null; @@ -157,9 +170,22 @@ public class GuiItemCustomize extends GuiScreen { } } + if (!this.textFieldCustomItem.getText().isEmpty()) { + data.customItem = this.textFieldCustomItem.getText(); + } + ItemCustomizeManager.putItemData(itemUUID, data); } + private ItemStack copy(ItemStack stack) { + ItemStack customStack = stack.copy(); + if (!this.textFieldCustomItem.getText().isEmpty()) { + customStack.setItem(ItemCustomizeManager.getCustomItem(stack, this.textFieldCustomItem.getText().trim())); + customStack.setItemDamage(ItemCustomizeManager.getCustomItemDamage(stack)); + } + return customStack; + } + private int getGlintColour() { int col = customGlintColour == null ? ChromaColour.specialToChromaRGB(ItemCustomizeManager.DEFAULT_GLINT_COLOR) @@ -171,7 +197,7 @@ public class GuiItemCustomize extends GuiScreen { if (!supportCustomLeatherColour) return 0xff000000; int col = - customLeatherColour == null ? ((ItemArmor) stack.getItem()).getColor(stack) : ChromaColour.specialToChromaRGB( + customLeatherColour == null ? ((ItemArmor) customItemStack.getItem()).getColor(customItemStack) : ChromaColour.specialToChromaRGB( customLeatherColour); return 0xff000000 | col; } @@ -188,7 +214,7 @@ public class GuiItemCustomize extends GuiScreen { int yTopStart = (scaledResolution.getScaledHeight() - renderHeight) / 2; int yTop = yTopStart; - RenderUtils.drawFloatingRectDark(xCenter - 100, yTop - 9, 200, renderHeight + 11); + RenderUtils.drawFloatingRectDark(xCenter - 100, yTop - 9, 200, renderHeight + 33); RenderUtils.drawFloatingRectDark(xCenter - 90, yTop - 5, 180, 14); Utils.renderShadowedString("\u00a75\u00a7lNEU Item Customizer", xCenter, yTop - 1, 180); @@ -211,6 +237,7 @@ public class GuiItemCustomize extends GuiScreen { } textFieldRename.render(xCenter - textFieldRename.getWidth() / 2 - 10, yTop); + int yTopText = yTop; Minecraft.getMinecraft().getTextureManager().bindTexture(GuiTextures.help); GlStateManager.color(1, 1, 1, 1); @@ -260,7 +287,8 @@ public class GuiItemCustomize extends GuiScreen { GlStateManager.pushMatrix(); GlStateManager.translate(xCenter - 48, yTop + 7, 0); GlStateManager.scale(6, 6, 1); - Utils.drawItemStack(stack, 0, 0); + this.customItemStack = copy(stack); + Utils.drawItemStack(customItemStack, 0, 0); GlStateManager.popMatrix(); yTop += 115; @@ -308,6 +336,9 @@ public class GuiItemCustomize extends GuiScreen { yTop += enchantGlintCustomColourAnimation.getValue() + 3; } + supportCustomLeatherColour = customItemStack.getItem() instanceof ItemArmor && + ((ItemArmor) customItemStack.getItem()).getArmorMaterial() == ItemArmor.ArmorMaterial.LEATHER; + if (supportCustomLeatherColour) { int leatherColour = getLeatherColour(); @@ -348,6 +379,32 @@ public class GuiItemCustomize extends GuiScreen { }*/ + if (!lastCustomItem.equals(textFieldCustomItem.getText())) { + updateData(); + } + lastCustomItem = textFieldCustomItem.getText(); + + if (!textFieldCustomItem.getFocus() && textFieldCustomItem.getText().isEmpty()) { + textFieldCustomItem.setOptions(GuiElementTextField.SCISSOR_TEXT); + textFieldCustomItem.setPrependText("\u00a77Enter Custom Item ID..."); + } else { + textFieldCustomItem.setOptions(GuiElementTextField.COLOUR | GuiElementTextField.SCISSOR_TEXT); + textFieldCustomItem.setPrependText(""); + } + + if (!textFieldCustomItem.getFocus()) { + textFieldCustomItem.setSize(180, 20); + } else { + int textSize = fontRendererObj.getStringWidth(textFieldCustomItem.getTextDisplay()) + 10; + textFieldCustomItem.setSize(Math.max(textSize, 180), 20); + } + + int offset = 200; + if (!supportCustomLeatherColour) offset -= 20; + if (!enchantGlint) offset -= 16; + + textFieldCustomItem.render(xCenter - textFieldCustomItem.getWidth() / 2 - 10 + 11, yTopText + offset); + renderHeight = yTop - yTopStart; if (editor != null) { @@ -355,7 +412,7 @@ public class GuiItemCustomize extends GuiScreen { } if (tooltipToDisplay != null) { - Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, fontRendererObj); + Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1); } super.drawScreen(mouseX, mouseY, partialTicks); @@ -389,6 +446,16 @@ public class GuiItemCustomize extends GuiScreen { } } + if (textFieldCustomItem.getFocus()) { + updateData(); + if (keyCode == Keyboard.KEY_ESCAPE) { + textFieldCustomItem.setFocus(false); + return; + } else { + textFieldCustomItem.keyTyped(typedChar, keyCode); + } + } + super.keyTyped(typedChar, keyCode); } @@ -417,6 +484,7 @@ public class GuiItemCustomize extends GuiScreen { @Override protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) { textFieldRename.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick); + textFieldCustomItem.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick); } @Override @@ -433,6 +501,18 @@ public class GuiItemCustomize extends GuiScreen { textFieldRename.unfocus(); } + int offset = 200; + if (!supportCustomLeatherColour) offset -= 20; + if (!enchantGlint) offset -= 18; + + if (mouseX >= xCenter - textFieldCustomItem.getWidth() / 2 - 10 + 11 && + mouseX <= xCenter + textFieldCustomItem.getWidth() / 2 - 10 + 11 && + mouseY >= yTop + offset + 14 && mouseY <= yTop + offset + 14 + textFieldCustomItem.getHeight()) { + textFieldCustomItem.mouseClicked(mouseX, mouseY, mouseButton); + } else { + textFieldCustomItem.unfocus(); + } + if (enchantGlint && mouseX >= xCenter - 90 && mouseX <= xCenter + 90 && mouseY >= yTop + 174 && mouseY <= yTop + 174 + enchantGlintCustomColourAnimation.getValue()) { if (mouseX >= xCenter + 90 - 12) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemRecipe.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemRecipe.java index e81834d3..3627a94e 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemRecipe.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemRecipe.java @@ -29,7 +29,6 @@ import io.github.moulberry.notenoughupdates.recipes.RecipeSlot; import io.github.moulberry.notenoughupdates.recipes.RecipeType; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.ScaledResolution; @@ -127,7 +126,6 @@ public class GuiItemRecipe extends GuiScreen { @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { drawDefaultBackground(); - FontRenderer fontRendererObj = Minecraft.getMinecraft().fontRendererObj; GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); @@ -150,7 +148,6 @@ public class GuiItemRecipe extends GuiScreen { Utils.drawStringScaledMaxWidth( currentRecipe.getTitle(), - fontRendererObj, guiLeft + TITLE_X, guiTop + TITLE_Y, false, @@ -165,12 +162,7 @@ public class GuiItemRecipe extends GuiScreen { if (slot.getItemStack() == null) continue; Utils.drawHoveringText( slot.getItemStack().getTooltip(Minecraft.getMinecraft().thePlayer, false), - mouseX, - mouseY, - width, - height, - -1, - fontRendererObj + mouseX, mouseY, width, height, -1 ); } } @@ -195,7 +187,7 @@ public class GuiItemRecipe extends GuiScreen { "" + EnumChatFormatting.RESET + EnumChatFormatting.GREEN + type.getLabel(), "" + EnumChatFormatting.RESET + EnumChatFormatting.GRAY + craftingRecipes.get(type).size() + " Recipes" ), - mouseX, mouseY, width, height, -1, Minecraft.getMinecraft().fontRendererObj + mouseX, mouseY, width, height, -1 ); return; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiNavigation.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiNavigation.java index 35c80579..ba3f95df 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiNavigation.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiNavigation.java @@ -104,7 +104,6 @@ public class GuiNavigation extends GuiScreen { ); Utils.drawStringF( json.get("displayname").getAsString(), - Minecraft.getMinecraft().fontRendererObj, baseX + TEXT_OFFSET_X, baseY + LIST_OFFSET_Y / 2F - Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT / 2F, false, diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiPriceGraph.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiPriceGraph.java index eb6aa956..c03a72a6 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiPriceGraph.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiPriceGraph.java @@ -139,20 +139,16 @@ public class GuiPriceGraph extends GuiScreen { if (itemName != null && itemStack != null) { Utils.drawItemStack(itemStack, guiLeft + 16, guiTop + 11); - Utils.drawStringScaledMax(itemName, Minecraft.getMinecraft().fontRendererObj, guiLeft + 35, guiTop + 13, false, + Utils.drawStringScaledMax(itemName, guiLeft + 35, guiTop + 13, false, 0xffffff, 1.77f, 208 ); } if (!loaded) - Utils.drawStringCentered("Loading...", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 166, guiTop + 116, false, 0xffffff00 - ); + Utils.drawStringCentered("Loading...", guiLeft + 166, guiTop + 116, false, 0xffffff00); else if ( itemData == null || itemData.get() == null || itemData.get().size() <= 1) - Utils.drawStringCentered("No data found.", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 166, guiTop + 116, false, 0xffff0000 - ); + Utils.drawStringCentered("No data found.", guiLeft + 166, guiTop + 116, false, 0xffff0000); else { int graphColor = SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.ahGraph.graphColor); int graphColor2 = SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.ahGraph.graphColor2); @@ -226,9 +222,7 @@ public class GuiPriceGraph extends GuiScreen { if (num != prevNum) { int xPos = (int) map(time, firstTime, lastTime, guiLeft + 17, guiLeft + 315); if (Math.abs(prevXPos - xPos) > 30) { - Utils.drawStringCentered(String.valueOf(num), Minecraft.getMinecraft().fontRendererObj, - xPos, guiTop + 206, false, 0x8b8b8b - ); + Utils.drawStringCentered(String.valueOf(num), xPos, guiTop + 206, false, 0x8b8b8b); prevXPos = xPos; } prevNum = num; @@ -237,10 +231,9 @@ public class GuiPriceGraph extends GuiScreen { for (int i = 0; i <= 6; i++) { long price = (long) map(i, 0, 6, highestValue, lowestValue); String formattedPrice = formatPrice(price); - Utils.drawStringF(formattedPrice, Minecraft.getMinecraft().fontRendererObj, guiLeft + 320, + Utils.drawStringF(formattedPrice, guiLeft + 320, (float) map(i, 0, 6, guiTop + 35, guiTop + 198) - - Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT / 2f, - false, 0x8b8b8b + - Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT / 2f, false, 0x8b8b8b ); } if (customSelecting) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/InventoryStorageSelector.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/InventoryStorageSelector.java index 8ee68457..648345bf 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/InventoryStorageSelector.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/InventoryStorageSelector.java @@ -25,7 +25,6 @@ import io.github.moulberry.notenoughupdates.core.config.KeybindHelper; import io.github.moulberry.notenoughupdates.miscfeatures.StorageManager; 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.renderer.GlStateManager; @@ -40,6 +39,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.InputEvent; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; + @NEUAutoSubscribe public class InventoryStorageSelector { private static final InventoryStorageSelector INSTANCE = new InventoryStorageSelector(); @@ -266,7 +266,6 @@ public class InventoryStorageSelector { int width = scaledResolution.getScaledWidth(); int height = scaledResolution.getScaledHeight(); - FontRenderer fontRendererObj = Minecraft.getMinecraft().fontRendererObj; int centerX = width / 2; int offset = 91 + 10 + 12; @@ -439,32 +438,18 @@ public class InventoryStorageSelector { Utils.drawItemStack(held, centerX - 8, startY - 8); GlStateManager.translate(0, 0, 100); - Utils.drawStringCentered(pageTitle, fontRendererObj, centerX, height - 76, true, 0xffff0000); + Utils.drawStringCentered(pageTitle, centerX, height - 76, true, 0xffff0000); int keyCode = NotEnoughUpdates.INSTANCE.config.storageGUI.backpackScrollKey; if (KeybindHelper.isKeyValid(keyCode) && !KeybindHelper.isKeyDown(keyCode)) { String keyName = KeybindHelper.getKeyName(keyCode); - Utils.drawStringCentered( - "[" + keyName + "] Scroll Backpacks", - fontRendererObj, - centerX, - startY - 10, - true, - 0xff32CD32 - ); + Utils.drawStringCentered("[" + keyName + "] Scroll Backpacks", centerX, startY - 10, true, 0xff32CD32); } GlStateManager.translate(0, 0, -200); } else if (page == null) { - Utils.drawStringCentered( - "Run /storage to enable this feature!", - fontRendererObj, - centerX, - height - 80, - true, - 0xffff0000 - ); + Utils.drawStringCentered("Run /storage to enable this feature!", centerX, height - 80, true, 0xffff0000); } else { - Utils.drawStringCentered("Right-click to load items", fontRendererObj, centerX, height - 80, true, 0xffff0000); + Utils.drawStringCentered("Right-click to load items", centerX, height - 80, true, 0xffff0000); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/KatSitterOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/KatSitterOverlay.java index 288c3926..c2908807 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/KatSitterOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/KatSitterOverlay.java @@ -95,11 +95,10 @@ public class KatSitterOverlay { ) : currentWidth); GlStateManager.disableLighting(); GlStateManager.color(1F, 1F, 1F, 1F); - Utils.drawStringScaled(currentText, font, left, ((AccessorGuiContainer) gui).getGuiTop() + 25, false, 0xFFD700, 1F); + Utils.drawStringScaled(currentText, left, ((AccessorGuiContainer) gui).getGuiTop() + 25, false, 0xFFD700, 1F); if (upgradedLevel != null) Utils.drawStringScaled( upgradedText, - font, left, ((AccessorGuiContainer) gui).getGuiTop() + 45, false, diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/NEUOverlayPlacements.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/NEUOverlayPlacements.java index ac96f527..30907836 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/NEUOverlayPlacements.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/NEUOverlayPlacements.java @@ -74,14 +74,7 @@ public class NEUOverlayPlacements extends GuiScreen { drawRect((width - 176) / 2, (height - 166) / 2, (width + 176) / 2, (height + 166) / 2, new Color(100, 100, 100, 200).getRGB() ); - Utils.drawStringCentered( - GOLD + "Inventory", - Minecraft.getMinecraft().fontRendererObj, - width / 2f, - height / 2f, - false, - 0 - ); + Utils.drawStringCentered(GOLD + "Inventory", width / 2f, height / 2f, false, 0); MBGuiGroupFloating mainGroup = NotEnoughUpdates.INSTANCE.overlay.guiGroup; mainGroup.render(0, 0); @@ -145,7 +138,8 @@ public class NEUOverlayPlacements extends GuiScreen { } if (anchorPoint.inventoryRelative) { - Utils.drawStringCentered(GOLD + "Inv-Relative", Minecraft.getMinecraft().fontRendererObj, + Utils.drawStringCentered( + GOLD + "Inv-Relative", position.x + element.getWidth() * 0.5f, position.y + element.getHeight() * 0.5f, false, 0 ); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/SignCalculator.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/SignCalculator.java index 4f01e551..31331ab3 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/SignCalculator.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/SignCalculator.java @@ -32,8 +32,8 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.client.event.GuiScreenEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import java.text.DecimalFormat; import java.math.BigDecimal; +import java.text.DecimalFormat; import java.util.Objects; @NEUAutoSubscribe @@ -62,14 +62,7 @@ public class SignCalculator { int calculationMode = NotEnoughUpdates.INSTANCE.config.misc.calculationMode; if ((calculationMode == 1 && !source.startsWith("!"))) return; - Utils.drawStringCentered( - getRenderedString(), - Minecraft.getMinecraft().fontRendererObj, - guiEditSign.width / 2F, - 58, - false, - 0x808080FF - ); + Utils.drawStringCentered(getRenderedString(), guiEditSign.width / 2F, 58, false, 0x808080FF); } @SubscribeEvent diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java index 5dd8bd9c..ff1d8687 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java @@ -862,11 +862,11 @@ public class StorageOverlay extends GuiElement { Gui.drawRect(storageX, storageY, storageX + 162, storageY + h, 0x80000000); if (storageId < 9) { - Utils.drawStringCenteredScaledMaxWidth("Locked Page", fontRendererObj, + Utils.drawStringCenteredScaledMaxWidth("Locked Page", storageX + 81, storageY + h / 2, true, 150, 0xd94c00 ); } else { - Utils.drawStringCenteredScaledMaxWidth("Empty Backpack Slot", fontRendererObj, + Utils.drawStringCenteredScaledMaxWidth("Empty Backpack Slot", storageX + 81, storageY + h / 2, true, 150, 0xd94c00 ); } @@ -889,7 +889,7 @@ public class StorageOverlay extends GuiElement { Gui.drawRect(storageX, storageY, storageX + 162, storageY + h, 0x80000000); - Utils.drawStringCenteredScaledMaxWidth("Click to load items", fontRendererObj, + Utils.drawStringCenteredScaledMaxWidth("Click to load items", storageX + 81, storageY + h / 2, true, 150, 0xffdf00 ); } else { @@ -1233,35 +1233,35 @@ public class StorageOverlay extends GuiElement { if (StorageManager.getInstance().desiredStoragePage == storageId && StorageManager.getInstance().onStorageMenu) { - Utils.drawStringCenteredScaledMaxWidth("Please click again to load...", fontRendererObj, + Utils.drawStringCenteredScaledMaxWidth("Please click again to load...", storageX + 81 - 1, storageY + storageH / 2 - 5, false, 150, 0x111111 ); - Utils.drawStringCenteredScaledMaxWidth("Please click again to load...", fontRendererObj, + Utils.drawStringCenteredScaledMaxWidth("Please click again to load...", storageX + 81 + 1, storageY + storageH / 2 - 5, false, 150, 0x111111 ); - Utils.drawStringCenteredScaledMaxWidth("Please click again to load...", fontRendererObj, + Utils.drawStringCenteredScaledMaxWidth("Please click again to load...", storageX + 81, storageY + storageH / 2 - 5 - 1, false, 150, 0x111111 ); - Utils.drawStringCenteredScaledMaxWidth("Please click again to load...", fontRendererObj, + Utils.drawStringCenteredScaledMaxWidth("Please click again to load...", storageX + 81, storageY + storageH / 2 - 5 + 1, false, 150, 0x111111 ); - Utils.drawStringCenteredScaledMaxWidth("Please click again to load...", fontRendererObj, + Utils.drawStringCenteredScaledMaxWidth("Please click again to load...", storageX + 81, storageY + storageH / 2 - 5, false, 150, 0xffdf00 ); - Utils.drawStringCenteredScaledMaxWidth("Use /neustwhy for more info", fontRendererObj, + Utils.drawStringCenteredScaledMaxWidth("Use /neustwhy for more info", storageX + 81 - 1, storageY + storageH / 2 + 5, false, 150, 0x111111 ); - Utils.drawStringCenteredScaledMaxWidth("Use /neustwhy for more info", fontRendererObj, + Utils.drawStringCenteredScaledMaxWidth("Use /neustwhy for more info", storageX + 81 + 1, storageY + storageH / 2 + 5, false, 150, 0x111111 ); - Utils.drawStringCenteredScaledMaxWidth("Use /neustwhy for more info", fontRendererObj, + Utils.drawStringCenteredScaledMaxWidth("Use /neustwhy for more info", storageX + 81, storageY + storageH / 2 + 5 - 1, false, 150, 0x111111 ); - Utils.drawStringCenteredScaledMaxWidth("Use /neustwhy for more info", fontRendererObj, + Utils.drawStringCenteredScaledMaxWidth("Use /neustwhy for more info", storageX + 81, storageY + storageH / 2 + 5 + 1, false, 150, 0x111111 ); - Utils.drawStringCenteredScaledMaxWidth("Use /neustwhy for more info", fontRendererObj, + Utils.drawStringCenteredScaledMaxWidth("Use /neustwhy for more info", storageX + 81, storageY + storageH / 2 + 5, false, 150, 0xffdf00 ); } @@ -1685,26 +1685,10 @@ public class StorageOverlay extends GuiElement { } GlStateManager.translate(0, 0, -100); } else { - Utils.drawHoveringText( - tooltipToDisplay, - mouseX, - mouseY, - width, - height, - -1, - Minecraft.getMinecraft().fontRendererObj - ); + Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1); } } else if (tooltipToDisplay != null) { - Utils.drawHoveringText( - tooltipToDisplay, - mouseX, - mouseY, - width, - height, - -1, - Minecraft.getMinecraft().fontRendererObj - ); + Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1); } else { allowTypingInSearchBar = true; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java index 16b5015b..6d565bb3 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java @@ -107,7 +107,6 @@ public class TradeWindow { for (int yOff = -2; yOff <= 2; yOff++) { if (Math.abs(xOff) != Math.abs(yOff)) { Utils.drawStringCenteredScaledMaxWidth(Utils.cleanColourNotModifiers(str), - Minecraft.getMinecraft().fontRendererObj, x + xOff / 2f, y + yOff / 2f, false, len, new Color(20, 20, 20, 100 / Math.max(Math.abs(xOff), Math.abs(yOff))).getRGB() ); @@ -115,11 +114,7 @@ public class TradeWindow { } } - Utils.drawStringCenteredScaledMaxWidth(str, - Minecraft.getMinecraft().fontRendererObj, - x, y, false, len, - new Color(64, 64, 64, 255).getRGB() - ); + Utils.drawStringCenteredScaledMaxWidth(str, x, y, false, len, new Color(64, 64, 64, 255).getRGB()); } private static long getPrice(String internalName) { @@ -567,14 +562,12 @@ public class TradeWindow { Utils.drawTexturedRect(guiLeft, guiTop, xSize, ySize, 0, 176 / 256f, 0, 204 / 256f, GL11.GL_NEAREST); Utils.drawStringF(new ChatComponentTranslation("container.inventory").getUnformattedText(), - Minecraft.getMinecraft().fontRendererObj, guiLeft + 8, guiTop + 111, false, 4210752 - ); - Utils.drawStringF("You", Minecraft.getMinecraft().fontRendererObj, guiLeft + 8, - guiTop + 5, false, 4210752 + guiLeft + 8, guiTop + 111, false, 4210752 ); + Utils.drawStringF("You", guiLeft + 8, guiTop + 5, false, 421752); String[] split = containerName.split(" "); if (split.length >= 1) { - Utils.drawStringF(split[split.length - 1], Minecraft.getMinecraft().fontRendererObj, + Utils.drawStringF(split[split.length - 1], guiLeft + 167 - Minecraft.getMinecraft().fontRendererObj.getStringWidth(split[split.length - 1]), guiTop + 5, false, 4210752 ); @@ -692,31 +685,19 @@ public class TradeWindow { Utils.drawStringCentered( EnumChatFormatting.DARK_RED + "Check " + EnumChatFormatting.BOLD + (char) (9311 + num), - Minecraft.getMinecraft().fontRendererObj, - guiLeft + 56, - guiTop + 99, + guiLeft + 56, guiTop + 99, false, 4210752 ); } else if (confirmDisplay.equals(EnumChatFormatting.AQUA + "Gift!")) { - Utils.drawStringCentered( - EnumChatFormatting.GREEN + "Accept", - Minecraft.getMinecraft().fontRendererObj, - guiLeft + 56, - guiTop + 99, - true, - 4210752 - ); + Utils.drawStringCentered(EnumChatFormatting.GREEN + "Accept", guiLeft + 56, guiTop + 99, true, 4210752); } else if (confirmDisplay.equals(EnumChatFormatting.GREEN + "Deal accepted!")) { - Utils.drawStringCentered(EnumChatFormatting.GREEN + "Accepted", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 56, guiTop + 99, true, 4210752 - ); + Utils.drawStringCentered(EnumChatFormatting.GREEN + "Accepted", guiLeft + 56, guiTop + 99, true, 4210752); } else if (lastTradeMillis > 0) { long delta = System.currentTimeMillis() - lastTradeMillis; if (delta > 2000) { Utils.drawStringCentered( EnumChatFormatting.GREEN + "Accept", - Minecraft.getMinecraft().fontRendererObj, guiLeft + 56, guiTop + 99, true, @@ -725,7 +706,6 @@ public class TradeWindow { } else { Utils.drawStringCentered( EnumChatFormatting.YELLOW + "Trade " + EnumChatFormatting.BOLD + (char) (9312 + (2000 - delta) / 1000), - Minecraft.getMinecraft().fontRendererObj, guiLeft + 56, guiTop + 99, true, @@ -735,7 +715,6 @@ public class TradeWindow { } else { Utils.drawStringCentered( EnumChatFormatting.YELLOW + "Trade " + EnumChatFormatting.BOLD + (char) (9314), - Minecraft.getMinecraft().fontRendererObj, guiLeft + 56, guiTop + 99, true, @@ -764,32 +743,11 @@ public class TradeWindow { ); if (confirmDisplay.equals(EnumChatFormatting.YELLOW + "Pending their confirm")) { - Utils.drawStringCentered( - EnumChatFormatting.YELLOW + "Pending", - Minecraft.getMinecraft().fontRendererObj, - guiLeft + 120, - guiTop + 99, - true, - 4210752 - ); + Utils.drawStringCentered(EnumChatFormatting.YELLOW + "Pending", guiLeft + 120, guiTop + 99, true, 4210752); } else if (confirmDisplay.equals(EnumChatFormatting.YELLOW + "Deal timer...")) { - Utils.drawStringCentered( - EnumChatFormatting.YELLOW + "Pending", - Minecraft.getMinecraft().fontRendererObj, - guiLeft + 120, - guiTop + 99, - true, - 4210752 - ); + Utils.drawStringCentered(EnumChatFormatting.YELLOW + "Pending", guiLeft + 120, guiTop + 99, true, 4210752); } else if (confirmDisplay.equals(EnumChatFormatting.GREEN + "Other player confirmed!")) { - Utils.drawStringCentered( - EnumChatFormatting.GREEN + "Accepted", - Minecraft.getMinecraft().fontRendererObj, - guiLeft + 120, - guiTop + 99, - true, - 4210752 - ); + Utils.drawStringCentered(EnumChatFormatting.GREEN + "Accepted", guiLeft + 120, guiTop + 99, true, 4210752); } } @@ -1041,8 +999,7 @@ public class TradeWindow { mouseY, scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), - tooltipLen, - Minecraft.getMinecraft().fontRendererObj + tooltipLen ); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TrophyRewardOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TrophyRewardOverlay.java index e13934e1..e8653d53 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TrophyRewardOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TrophyRewardOverlay.java @@ -23,9 +23,11 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe; +import io.github.moulberry.notenoughupdates.events.ButtonExclusionZoneEvent; import io.github.moulberry.notenoughupdates.events.RepositoryReloadEvent; import io.github.moulberry.notenoughupdates.mixins.AccessorGuiContainer; import io.github.moulberry.notenoughupdates.util.Constants; +import io.github.moulberry.notenoughupdates.util.Rectangle; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; @@ -97,6 +99,21 @@ public class TrophyRewardOverlay { return line.get(1); } + @SubscribeEvent + public void onButtonExclusionZones(ButtonExclusionZoneEvent event) { + if (inTrophyFishingInventory()) { + event.blockArea( + new Rectangle( + event.getGuiBaseRect().getRight(), + event.getGuiBaseRect().getTop(), + 168 /*width*/ + 4 /*space*/, + 128 + ), + ButtonExclusionZoneEvent.PushDirection.TOWARDS_RIGHT + ); + } + } + @SubscribeEvent(priority = EventPriority.LOWEST) public void onDrawBackground(GuiScreenEvent.BackgroundDrawnEvent event) { if (!inTrophyFishingInventory()) return; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/hex/GuiCustomHex.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/hex/GuiCustomHex.java index 4dbe7f94..deef7bdc 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/hex/GuiCustomHex.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/hex/GuiCustomHex.java @@ -37,6 +37,7 @@ import io.github.moulberry.notenoughupdates.util.ItemUtils; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.gui.inventory.GuiContainer; @@ -539,7 +540,8 @@ public class GuiCustomHex extends Gui { if (enchanterCurrentEnch == null) { enchanterCurrentEnch = enchantment; } else if (updateLevel) { - if (removingEnchantPlayerLevel < 0 && enchantment.level > enchanterCurrentEnch.level && !aboveMaxLevelFromEt) { + if (removingEnchantPlayerLevel < 0 && enchantment.level > enchanterCurrentEnch.level && + !aboveMaxLevelFromEt) { enchanterCurrentEnch = enchantment; } else if (removingEnchantPlayerLevel >= 0 && enchantment.level < enchanterCurrentEnch.level) { enchanterCurrentEnch = enchantment; @@ -1286,14 +1288,15 @@ public class GuiCustomHex extends Gui { renderBaseTexture(); - Minecraft.getMinecraft().fontRendererObj.drawString("Applicable", guiLeft + 7, guiTop + 7, 0x404040, false); - Minecraft.getMinecraft().fontRendererObj.drawString("Removable", guiLeft + 247, guiTop + 7, 0x404040, false); + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + fr.drawString("Applicable", guiLeft + 7, guiTop + 7, 0x404040, false); + fr.drawString("Removable", guiLeft + 247, guiTop + 7, 0x404040, false); //Page Text if (currentState == EnchantState.HAS_ITEM || currentState == EnchantState.ADDING_ENCHANT) { String pageStr = "Page: " + currentPage + "/" + expectedMaxPage; - int pageStrLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(pageStr); - Utils.drawStringCentered(pageStr, Minecraft.getMinecraft().fontRendererObj, + int pageStrLen = fr.getStringWidth(pageStr); + Utils.drawStringCentered(pageStr, guiLeft + X_SIZE / 2, guiTop + 14, false, 0x404040 ); @@ -1318,10 +1321,10 @@ public class GuiCustomHex extends Gui { //Can't be enchanted text if (currentState == EnchantState.INVALID_ITEM) { GlStateManager.disableDepth(); - Utils.drawStringCentered("This item can't", Minecraft.getMinecraft().fontRendererObj, + Utils.drawStringCentered("This item can't", guiLeft + X_SIZE / 2, guiTop + 88, true, 0xffff5555 ); - Utils.drawStringCentered("be enchanted", Minecraft.getMinecraft().fontRendererObj, + Utils.drawStringCentered("be enchanted", guiLeft + X_SIZE / 2, guiTop + 98, true, 0xffff5555 ); GlStateManager.enableDepth(); @@ -1332,52 +1335,24 @@ public class GuiCustomHex extends Gui { //Text if no enchants appear if (currentState == EnchantState.HAS_ITEM || currentState == EnchantState.ADDING_ENCHANT) { if (applicable.isEmpty() && removable.isEmpty() && searchRemovedFromApplicable) { - Utils.drawStringCentered("Can't find that", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 8 + 48, guiTop + 28, true, 0xffff5555 - ); - Utils.drawStringCentered("enchant, perhaps", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 8 + 48, guiTop + 38, true, 0xffff5555 - ); - Utils.drawStringCentered("it is on", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 8 + 48, guiTop + 48, true, 0xffff5555 - ); - Utils.drawStringCentered("another page?", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 8 + 48, guiTop + 58, true, 0xffff5555 - ); + Utils.drawStringCentered("Can't find that", guiLeft + 8 + 48, guiTop + 28, true, 0xffff5555); + Utils.drawStringCentered("enchant, perhaps", guiLeft + 8 + 48, guiTop + 38, true, 0xffff5555); + Utils.drawStringCentered("it is on", guiLeft + 8 + 48, guiTop + 48, true, 0xffff5555); + Utils.drawStringCentered("another page?", guiLeft + 8 + 48, guiTop + 58, true, 0xffff5555); } else if (applicable.isEmpty() && !searchRemovedFromApplicable) { - Utils.drawStringCentered("No applicable", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 8 + 48, guiTop + 28, true, 0xffff5555 - ); - Utils.drawStringCentered("enchants on", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 8 + 48, guiTop + 38, true, 0xffff5555 - ); - Utils.drawStringCentered("this page...", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 8 + 48, guiTop + 48, true, 0xffff5555 - ); + Utils.drawStringCentered("No applicable", guiLeft + 8 + 48, guiTop + 28, true, 0xffff5555); + Utils.drawStringCentered("enchants on", guiLeft + 8 + 48, guiTop + 38, true, 0xffff5555); + Utils.drawStringCentered("this page...", guiLeft + 8 + 48, guiTop + 48, true, 0xffff5555); } if (applicable.isEmpty() && removable.isEmpty() && searchRemovedFromRemovable) { - Utils.drawStringCentered("Can't find that", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 248 + 48, guiTop + 28, true, 0xffff5555 - ); - Utils.drawStringCentered("enchant, perhaps", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 248 + 48, guiTop + 38, true, 0xffff5555 - ); - Utils.drawStringCentered("it is on", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 248 + 48, guiTop + 48, true, 0xffff5555 - ); - Utils.drawStringCentered("another page?", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 248 + 48, guiTop + 58, true, 0xffff5555 - ); + Utils.drawStringCentered("Can't find that", guiLeft + 248 + 48, guiTop + 28, true, 0xffff5555); + Utils.drawStringCentered("enchant, perhaps", guiLeft + 248 + 48, guiTop + 38, true, 0xffff5555); + Utils.drawStringCentered("it is on", guiLeft + 248 + 48, guiTop + 48, true, 0xffff5555); + Utils.drawStringCentered("another page?", guiLeft + 248 + 48, guiTop + 58, true, 0xffff5555); } else if (removable.isEmpty() && !searchRemovedFromRemovable) { - Utils.drawStringCentered("No removable", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 248 + 48, guiTop + 28, true, 0xffff5555 - ); - Utils.drawStringCentered("enchants on", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 248 + 48, guiTop + 38, true, 0xffff5555 - ); - Utils.drawStringCentered("this page...", Minecraft.getMinecraft().fontRendererObj, - guiLeft + 248 + 48, guiTop + 48, true, 0xffff5555 - ); + Utils.drawStringCentered("No removable", guiLeft + 248 + 48, guiTop + 28, true, 0xffff5555); + Utils.drawStringCentered("enchants on", guiLeft + 248 + 48, guiTop + 38, true, 0xffff5555); + Utils.drawStringCentered("this page...", guiLeft + 248 + 48, guiTop + 48, true, 0xffff5555); } } //Available enchants (left) @@ -1413,50 +1388,14 @@ public class GuiCustomHex extends Gui { colour = 0xff5555; } - int levelWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(levelStr); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 16 - levelWidth / 2 - 1, - top + 4, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 16 - levelWidth / 2 + 1, - top + 4, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 16 - levelWidth / 2, - top + 4 - 1, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 16 - levelWidth / 2, - top + 4 + 1, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 16 - levelWidth / 2, - top + 4, - colour, - false - ); + int levelWidth = fr.getStringWidth(levelStr); + fr.drawString(levelStr, guiLeft + 16 - levelWidth / 2 - 1, top + 4, 0x2d2102, false); + fr.drawString(levelStr, guiLeft + 16 - levelWidth / 2 + 1, top + 4, 0x2d2102, false); + fr.drawString(levelStr, guiLeft + 16 - levelWidth / 2, top + 4 - 1, 0x2d2102, false); + fr.drawString(levelStr, guiLeft + 16 - levelWidth / 2, top + 4 + 1, 0x2d2102, false); + fr.drawString(levelStr, guiLeft + 16 - levelWidth / 2, top + 4, colour, false); - Minecraft.getMinecraft().fontRendererObj.drawString( - ench.enchantName, - guiLeft + 8 + 16 + 2 + textOffset, - top + 4 + textOffset, - 0xffffffdd, - true - ); + fr.drawString(ench.enchantName, guiLeft + 8 + 16 + 2 + textOffset, top + 4 + textOffset, 0xffffffdd, true); } GlScissorStack.pop(scaledResolution); @@ -1493,51 +1432,19 @@ public class GuiCustomHex extends Gui { colour = 0xff5555; } - int levelWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(levelStr); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 256 - levelWidth / 2 - 1, - top + 4, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 256 - levelWidth / 2 + 1, - top + 4, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 256 - levelWidth / 2, - top + 4 - 1, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 256 - levelWidth / 2, - top + 4 + 1, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 256 - levelWidth / 2, - top + 4, - colour, - false - ); + int levelWidth = fr.getStringWidth(levelStr); + fr.drawString(levelStr, guiLeft + 256 - levelWidth / 2 - 1, top + 4, 0x2d2102, false); + fr.drawString(levelStr, guiLeft + 256 - levelWidth / 2 + 1, top + 4, 0x2d2102, false); + fr.drawString(levelStr, guiLeft + 256 - levelWidth / 2, top + 4 - 1, 0x2d2102, false); + fr.drawString(levelStr, guiLeft + 256 - levelWidth / 2, top + 4 + 1, 0x2d2102, false); + fr.drawString(levelStr, guiLeft + 256 - levelWidth / 2, top + 4, colour, false); - Minecraft.getMinecraft().fontRendererObj.drawString(ench.enchantName, - guiLeft + 248 + 16 + 2 + textOffset, top + 4 + textOffset, 0xffffffdd, true - ); + fr.drawString(ench.enchantName, guiLeft + 248 + 16 + 2 + textOffset, top + 4 + textOffset, 0xffffffdd, true); } GlScissorStack.pop(scaledResolution); //Player Inventory Items - Minecraft.getMinecraft().fontRendererObj.drawString(Minecraft.getMinecraft().thePlayer.inventory + fr.drawString(Minecraft.getMinecraft().thePlayer.inventory .getDisplayName() .getUnformattedText(), guiLeft + 102, guiTop + Y_SIZE - 96 + 2, 0x404040 @@ -1580,7 +1487,7 @@ public class GuiCustomHex extends Gui { searchField.setPrependText("\u00a77Search..."); } else { if (searchField.getFocus()) { - int len = Minecraft.getMinecraft().fontRendererObj.getStringWidth(searchField.getTextDisplay()) + 10; + int len = fr.getStringWidth(searchField.getTextDisplay()) + 10; searchField.setSize(Math.max(90, len), 14); } else { searchField.setSize(90, 14); @@ -1618,78 +1525,24 @@ public class GuiCustomHex extends Gui { colour = 0xff5555; } - int levelWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(levelStr); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - left + 8 - levelWidth / 2 - 1, - top + 4, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - left + 8 - levelWidth / 2 + 1, - top + 4, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - left + 8 - levelWidth / 2, - top + 4 - 1, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - left + 8 - levelWidth / 2, - top + 4 + 1, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, left + 8 - levelWidth / 2, top + 4, colour, false); + int levelWidth = fr.getStringWidth(levelStr); + fr.drawString(levelStr, left + 8 - levelWidth / 2 - 1, top + 4, 0x2d2102, false); + fr.drawString(levelStr, left + 8 - levelWidth / 2 + 1, top + 4, 0x2d2102, false); + fr.drawString(levelStr, left + 8 - levelWidth / 2, top + 4 - 1, 0x2d2102, false); + fr.drawString(levelStr, left + 8 - levelWidth / 2, top + 4 + 1, 0x2d2102, false); + fr.drawString(levelStr, left + 8 - levelWidth / 2, top + 4, colour, false); String priceStr = "" + numberFormat.format(enchanterCurrentEnch.price) + " Coins"; if (enchanterCurrentEnch.price < 0) priceStr = ""; - int priceWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(priceStr); + int priceWidth = fr.getStringWidth(priceStr); int priceTop = guiTop + 16; int x = 180; int color = 0x2d2102; - Minecraft.getMinecraft().fontRendererObj.drawString( - priceStr, - guiLeft + x - priceWidth / 2 - 1, - priceTop + 4, - color, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - priceStr, - guiLeft + x - priceWidth / 2 + 1, - priceTop + 4, - color, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - priceStr, - guiLeft + x - priceWidth / 2, - priceTop + 4 - 1, - color, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - priceStr, - guiLeft + x - priceWidth / 2, - priceTop + 4 + 1, - color, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - priceStr, - guiLeft + x - priceWidth / 2, - priceTop + 4, - 0xfcba03, - false - ); + fr.drawString(priceStr, guiLeft + x - priceWidth / 2 - 1, priceTop + 4, color, false); + fr.drawString(priceStr, guiLeft + x - priceWidth / 2 + 1, priceTop + 4, color, false); + fr.drawString(priceStr, guiLeft + x - priceWidth / 2, priceTop + 4 - 1, color, false); + fr.drawString(priceStr, guiLeft + x - priceWidth / 2, priceTop + 4 + 1, color, false); + fr.drawString(priceStr, guiLeft + x - priceWidth / 2, priceTop + 4, 0xfcba03, false); //Enchant name String name = WordUtils.capitalizeFully(ItemUtils @@ -1706,14 +1559,7 @@ public class GuiCustomHex extends Gui { } else if (name.equalsIgnoreCase("Turbo Mushrooms")) { name = "Turbo-Mush"; } - Utils.drawStringCentered( - name, - Minecraft.getMinecraft().fontRendererObj, - guiLeft + X_SIZE / 2, - top + 8, - true, - 0xffffffdd - ); + Utils.drawStringCentered(name, guiLeft + X_SIZE / 2, top + 8, true, 0xffffffdd); if (isChangingEnchLevel) { Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE); @@ -1726,42 +1572,12 @@ public class GuiCustomHex extends Gui { //Enchant level levelStr = "" + enchanterCurrentEnch.level; if (enchanterCurrentEnch.xpCost < 0) levelStr = "?"; - levelWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(levelStr); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - left + 96 + 8 - levelWidth / 2 - 1, - top + 4, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - left + 96 + 8 - levelWidth / 2 + 1, - top + 4, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - left + 96 + 8 - levelWidth / 2, - top + 4 - 1, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - left + 96 + 8 - levelWidth / 2, - top + 4 + 1, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - left + 96 + 8 - levelWidth / 2, - top + 4, - 0xea82ff, - false - ); + levelWidth = fr.getStringWidth(levelStr); + fr.drawString(levelStr, left + 96 + 8 - levelWidth / 2 - 1, top + 4, 0x2d2102, false); + fr.drawString(levelStr, left + 96 + 8 - levelWidth / 2 + 1, top + 4, 0x2d2102, false); + fr.drawString(levelStr, left + 96 + 8 - levelWidth / 2, top + 4 - 1, 0x2d2102, false); + fr.drawString(levelStr, left + 96 + 8 - levelWidth / 2, top + 4 + 1, 0x2d2102, false); + fr.drawString(levelStr, left + 96 + 8 - levelWidth / 2, top + 4, 0xea82ff, false); //Confirm button @@ -1781,7 +1597,7 @@ public class GuiCustomHex extends Gui { Utils.drawTexturedRect(guiLeft + X_SIZE / 2 - 1 - 48, top + 18, 48, 14, 0, 48 / 512f, 342 / 512f, (342 + 14) / 512f, GL11.GL_NEAREST ); - Utils.drawStringCentered(confirmText, Minecraft.getMinecraft().fontRendererObj, + Utils.drawStringCentered(confirmText, guiLeft + X_SIZE / 2 - 1 - 23, top + 18 + 9, false, 0x408040 ); } else { @@ -1790,7 +1606,7 @@ public class GuiCustomHex extends Gui { Utils.drawTexturedRect(guiLeft + X_SIZE / 2 - 1 - 48, top + 18, 48, 14, 0, 48 / 512f, 328 / 512f, (328 + 14) / 512f, GL11.GL_NEAREST ); - Utils.drawStringCentered(confirmText, Minecraft.getMinecraft().fontRendererObj, + Utils.drawStringCentered(confirmText, guiLeft + X_SIZE / 2 - 1 - 24, top + 18 + 8, false, 0x408040 ); @@ -1806,7 +1622,7 @@ public class GuiCustomHex extends Gui { Utils.drawTexturedRect(guiLeft + X_SIZE / 2 + 1, top + 18, 48, 14, 0, 48 / 512f, 342 / 512f, (342 + 14) / 512f, GL11.GL_NEAREST ); - Utils.drawStringCentered("Cancel", Minecraft.getMinecraft().fontRendererObj, + Utils.drawStringCentered("Cancel", guiLeft + X_SIZE / 2 + 1 + 25, top + 18 + 9, false, 0xa04040 ); } else { @@ -1815,7 +1631,7 @@ public class GuiCustomHex extends Gui { Utils.drawTexturedRect(guiLeft + X_SIZE / 2 + 1, top + 18, 48, 14, 0, 48 / 512f, 328 / 512f, (328 + 14) / 512f, GL11.GL_NEAREST ); - Utils.drawStringCentered("Cancel", Minecraft.getMinecraft().fontRendererObj, + Utils.drawStringCentered("Cancel", guiLeft + X_SIZE / 2 + 1 + 24, top + 18 + 8, false, 0xa04040 ); } @@ -1890,42 +1706,12 @@ public class GuiCustomHex extends Gui { ); levelStr = "" + ench.level; - levelWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(levelStr); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - left + 96 + 8 - levelWidth / 2 - 1, - top + 16 * yIndex + 4, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - left + 96 + 8 - levelWidth / 2 + 1, - top + 16 * yIndex + 4, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - left + 96 + 8 - levelWidth / 2, - top + 16 * yIndex + 4 - 1, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - left + 96 + 8 - levelWidth / 2, - top + 16 * yIndex + 4 + 1, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - left + 96 + 8 - levelWidth / 2, - top + 16 * yIndex + 4, - 0xea82ff, - false - ); + levelWidth = fr.getStringWidth(levelStr); + fr.drawString(levelStr, left + 96 + 8 - levelWidth / 2 - 1, top + 16 * yIndex + 4, 0x2d2102, false); + fr.drawString(levelStr, left + 96 + 8 - levelWidth / 2 + 1, top + 16 * yIndex + 4, 0x2d2102, false); + fr.drawString(levelStr, left + 96 + 8 - levelWidth / 2, top + 16 * yIndex + 4 - 1, 0x2d2102, false); + fr.drawString(levelStr, left + 96 + 8 - levelWidth / 2, top + 16 * yIndex + 4 + 1, 0x2d2102, false); + fr.drawString(levelStr, left + 96 + 8 - levelWidth / 2, top + 16 * yIndex + 4, 0xea82ff, false); } GlStateManager.enableDepth(); } @@ -2034,14 +1820,15 @@ public class GuiCustomHex extends Gui { renderBaseTexture(); - Minecraft.getMinecraft().fontRendererObj.drawString("Applicable", guiLeft + 7, guiTop + 7, 0x404040, false); - Minecraft.getMinecraft().fontRendererObj.drawString("Applied", guiLeft + 247, guiTop + 7, 0x404040, false); + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + fr.drawString("Applicable", guiLeft + 7, guiTop + 7, 0x404040, false); + fr.drawString("Applied", guiLeft + 247, guiTop + 7, 0x404040, false); //Page Text /*if (currentState == EnchantState.HAS_ITEM || currentState == EnchantState.ADDING_ENCHANT) { String pageStr = "Page: " + currentPage + "/" + expectedMaxPage; int pageStrLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(pageStr); - Utils.drawStringCentered(pageStr, Minecraft.getMinecraft().fontRendererObj, + Utils.drawStringCentered(pageStr, guiLeft + X_SIZE / 2, guiTop + 14, false, 0x404040 ); @@ -2066,10 +1853,10 @@ public class GuiCustomHex extends Gui { //Can't be enchanted text /*if (currentState == EnchantState.INVALID_ITEM) { GlStateManager.disableDepth(); - Utils.drawStringCentered("This item can't", Minecraft.getMinecraft().fontRendererObj, + Utils.drawStringCentered("This item can't", guiLeft + X_SIZE / 2, guiTop + 88, true, 0xffff5555 ); - Utils.drawStringCentered("be enchanted", Minecraft.getMinecraft().fontRendererObj, + Utils.drawStringCentered("be enchanted", guiLeft + X_SIZE / 2, guiTop + 98, true, 0xffff5555 ); GlStateManager.enableDepth(); @@ -2081,50 +1868,50 @@ public class GuiCustomHex extends Gui { if (currentState == EnchantState.HAS_ITEM || currentState == EnchantState.ADDING_ENCHANT || currentState == EnchantState.HAS_ITEM_IN_BOOKS || currentState == EnchantState.ADDING_BOOK) { if (applicableItem.isEmpty() && removableItem.isEmpty() && searchRemovedFromApplicable) { - Utils.drawStringCentered("Can't find that", Minecraft.getMinecraft().fontRendererObj, + Utils.drawStringCentered("Can't find that", guiLeft + 8 + 48, guiTop + 28, true, 0xffff5555 ); - Utils.drawStringCentered("enchant, perhaps", Minecraft.getMinecraft().fontRendererObj, + Utils.drawStringCentered("enchant, perhaps", guiLeft + 8 + 48, guiTop + 38, true, 0xffff5555 ); - Utils.drawStringCentered("it is on", Minecraft.getMinecraft().fontRendererObj, + Utils.drawStringCentered("it is on", guiLeft + 8 + 48, guiTop + 48, true, 0xffff5555 ); - Utils.drawStringCentered("another page?", Minecraft.getMinecraft().fontRendererObj, + Utils.drawStringCentered("another page?", guiLeft + 8 + 48, guiTop + 58, true, 0xffff5555 ); } else if (applicableItem.isEmpty() && !searchRemovedFromApplicable) { - Utils.drawStringCentered("No applicable", Minecraft.getMinecraft().fontRendererObj, + Utils.drawStringCentered("No applicable", guiLeft + 8 + 48, guiTop + 28, true, 0xffff5555 ); - Utils.drawStringCentered("enchants on", Minecraft.getMinecraft().fontRendererObj, + Utils.drawStringCentered("enchants on", guiLeft + 8 + 48, guiTop + 38, true, 0xffff5555 ); - Utils.drawStringCentered("this page...", Minecraft.getMinecraft().fontRendererObj, + Utils.drawStringCentered("this page...", guiLeft + 8 + 48, guiTop + 48, true, 0xffff5555 ); } if (applicableItem.isEmpty() && removableItem.isEmpty() && searchRemovedFromRemovable) { - Utils.drawStringCentered("Can't find that", Minecraft.getMinecraft().fontRendererObj, + Utils.drawStringCentered("Can't find that", guiLeft + 248 + 48, guiTop + 28, true, 0xffff5555 ); - Utils.drawStringCentered("enchant, perhaps", Minecraft.getMinecraft().fontRendererObj, + Utils.drawStringCentered("enchant, perhaps", guiLeft + 248 + 48, guiTop + 38, true, 0xffff5555 ); - Utils.drawStringCentered("it is on", Minecraft.getMinecraft().fontRendererObj, + Utils.drawStringCentered("it is on", guiLeft + 248 + 48, guiTop + 48, true, 0xffff5555 ); - Utils.drawStringCentered("another page?", Minecraft.getMinecraft().fontRendererObj, + Utils.drawStringCentered("another page?", guiLeft + 248 + 48, guiTop + 58, true, 0xffff5555 ); } else if (removableItem.isEmpty() && !searchRemovedFromRemovable) { - Utils.drawStringCentered("No removable", Minecraft.getMinecraft().fontRendererObj, + Utils.drawStringCentered("No removable", guiLeft + 248 + 48, guiTop + 28, true, 0xffff5555 ); - Utils.drawStringCentered("enchants on", Minecraft.getMinecraft().fontRendererObj, + Utils.drawStringCentered("enchants on", guiLeft + 248 + 48, guiTop + 38, true, 0xffff5555 ); - Utils.drawStringCentered("this page...", Minecraft.getMinecraft().fontRendererObj, + Utils.drawStringCentered("this page...", guiLeft + 248 + 48, guiTop + 48, true, 0xffff5555 ); } @@ -2162,50 +1949,14 @@ public class GuiCustomHex extends Gui { colour = 0xff5555; } - int levelWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(levelStr); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 16 - levelWidth / 2 - 1, - top + 4, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 16 - levelWidth / 2 + 1, - top + 4, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 16 - levelWidth / 2, - top + 4 - 1, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 16 - levelWidth / 2, - top + 4 + 1, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 16 - levelWidth / 2, - top + 4, - colour, - false - ); + int levelWidth = fr.getStringWidth(levelStr); + fr.drawString(levelStr, guiLeft + 16 - levelWidth / 2 - 1, top + 4, 0x2d2102, false); + fr.drawString(levelStr, guiLeft + 16 - levelWidth / 2 + 1, top + 4, 0x2d2102, false); + fr.drawString(levelStr, guiLeft + 16 - levelWidth / 2, top + 4 - 1, 0x2d2102, false); + fr.drawString(levelStr, guiLeft + 16 - levelWidth / 2, top + 4 + 1, 0x2d2102, false); + fr.drawString(levelStr, guiLeft + 16 - levelWidth / 2, top + 4, colour, false); - Minecraft.getMinecraft().fontRendererObj.drawString( - item.itemName, - guiLeft + 8 + 16 + 2 + textOffset, - top + 4 + textOffset, - 0xffffffdd, - true - ); + fr.drawString(item.itemName, guiLeft + 8 + 16 + 2 + textOffset, top + 4 + textOffset, 0xffffffdd, true); } GlScissorStack.pop(scaledResolution); @@ -2241,51 +1992,19 @@ public class GuiCustomHex extends Gui { colour = 0xff5555; }*/ - int levelWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(levelStr); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 256 - levelWidth / 2 - 1, - top + 4, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 256 - levelWidth / 2 + 1, - top + 4, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 256 - levelWidth / 2, - top + 4 - 1, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 256 - levelWidth / 2, - top + 4 + 1, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 256 - levelWidth / 2, - top + 4, - colour, - false - ); + int levelWidth = fr.getStringWidth(levelStr); + fr.drawString(levelStr, guiLeft + 256 - levelWidth / 2 - 1, top + 4, 0x2d2102, false); + fr.drawString(levelStr, guiLeft + 256 - levelWidth / 2 + 1, top + 4, 0x2d2102, false); + fr.drawString(levelStr, guiLeft + 256 - levelWidth / 2, top + 4 - 1, 0x2d2102, false); + fr.drawString(levelStr, guiLeft + 256 - levelWidth / 2, top + 4 + 1, 0x2d2102, false); + fr.drawString(levelStr, guiLeft + 256 - levelWidth / 2, top + 4, colour, false); - Minecraft.getMinecraft().fontRendererObj.drawString(item.itemName, - guiLeft + 248 + 16 + 2 + textOffset, top + 4 + textOffset, 0xffffffdd, true - ); + fr.drawString(item.itemName, guiLeft + 248 + 16 + 2 + textOffset, top + 4 + textOffset, 0xffffffdd, true); } GlScissorStack.pop(scaledResolution); //Player Inventory Items - Minecraft.getMinecraft().fontRendererObj.drawString(Minecraft.getMinecraft().thePlayer.inventory + fr.drawString(Minecraft.getMinecraft().thePlayer.inventory .getDisplayName() .getUnformattedText(), guiLeft + 102, guiTop + Y_SIZE - 96 + 2, 0x404040 @@ -2328,7 +2047,7 @@ public class GuiCustomHex extends Gui { searchField.setPrependText("\u00a77Search..."); } else { if (searchField.getFocus()) { - int len = Minecraft.getMinecraft().fontRendererObj.getStringWidth(searchField.getTextDisplay()) + 10; + int len = fr.getStringWidth(searchField.getTextDisplay()) + 10; searchField.setSize(Math.max(90, len), 14); } else { searchField.setSize(90, 14); @@ -2359,57 +2078,20 @@ public class GuiCustomHex extends Gui { String priceStr = "" + numberFormat.format(enchanterCurrentItem.getPrice()) + " Coins"; if (enchanterCurrentItem.price < 0) priceStr = ""; - int priceWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(priceStr); + int priceWidth = fr.getStringWidth(priceStr); int priceTop = guiTop + 10; int x = 180; int color = 0x2d2102; - Minecraft.getMinecraft().fontRendererObj.drawString( - priceStr, - guiLeft + x - priceWidth / 2 - 1, - priceTop + 4, - color, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - priceStr, - guiLeft + x - priceWidth / 2 + 1, - priceTop + 4, - color, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - priceStr, - guiLeft + x - priceWidth / 2, - priceTop + 4 - 1, - color, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - priceStr, - guiLeft + x - priceWidth / 2, - priceTop + 4 + 1, - color, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - priceStr, - guiLeft + x - priceWidth / 2, - priceTop + 4, - 0xfcba03, - false - ); + fr.drawString(priceStr, guiLeft + x - priceWidth / 2 - 1, priceTop + 4, color, false); + fr.drawString(priceStr, guiLeft + x - priceWidth / 2 + 1, priceTop + 4, color, false); + fr.drawString(priceStr, guiLeft + x - priceWidth / 2, priceTop + 4 - 1, color, false); + fr.drawString(priceStr, guiLeft + x - priceWidth / 2, priceTop + 4 + 1, color, false); + fr.drawString(priceStr, guiLeft + x - priceWidth / 2, priceTop + 4, 0xfcba03, false); //Enchant name String name = WordUtils.capitalizeFully(enchanterCurrentItem.itemId.replace("_", " ")); name = fixName(name); - Utils.drawStringCentered( - name, - Minecraft.getMinecraft().fontRendererObj, - guiLeft + X_SIZE / 2, - top + 8, - true, - 0xffffffdd - ); + Utils.drawStringCentered(name, guiLeft + X_SIZE / 2, top + 8, true, 0xffffffdd); //Confirm button String confirmText = "Apply"; @@ -2428,7 +2110,7 @@ public class GuiCustomHex extends Gui { Utils.drawTexturedRect(guiLeft + X_SIZE / 2 - 1 - 48, top + 18, 48, 14, 0, 48 / 512f, 342 / 512f, (342 + 14) / 512f, GL11.GL_NEAREST ); - Utils.drawStringCentered(confirmText, Minecraft.getMinecraft().fontRendererObj, + Utils.drawStringCentered(confirmText, guiLeft + X_SIZE / 2 - 1 - 23, top + 18 + 9, false, 0x408040 ); } else { @@ -2437,7 +2119,7 @@ public class GuiCustomHex extends Gui { Utils.drawTexturedRect(guiLeft + X_SIZE / 2 - 1 - 48, top + 18, 48, 14, 0, 48 / 512f, 328 / 512f, (328 + 14) / 512f, GL11.GL_NEAREST ); - Utils.drawStringCentered(confirmText, Minecraft.getMinecraft().fontRendererObj, + Utils.drawStringCentered(confirmText, guiLeft + X_SIZE / 2 - 1 - 24, top + 18 + 8, false, 0x408040 ); @@ -2453,7 +2135,7 @@ public class GuiCustomHex extends Gui { Utils.drawTexturedRect(guiLeft + X_SIZE / 2 + 1, top + 18, 48, 14, 0, 48 / 512f, 342 / 512f, (342 + 14) / 512f, GL11.GL_NEAREST ); - Utils.drawStringCentered("Cancel", Minecraft.getMinecraft().fontRendererObj, + Utils.drawStringCentered("Cancel", guiLeft + X_SIZE / 2 + 1 + 25, top + 18 + 9, false, 0xa04040 ); } else { @@ -2462,7 +2144,7 @@ public class GuiCustomHex extends Gui { Utils.drawTexturedRect(guiLeft + X_SIZE / 2 + 1, top + 18, 48, 14, 0, 48 / 512f, 328 / 512f, (328 + 14) / 512f, GL11.GL_NEAREST ); - Utils.drawStringCentered("Cancel", Minecraft.getMinecraft().fontRendererObj, + Utils.drawStringCentered("Cancel", guiLeft + X_SIZE / 2 + 1 + 24, top + 18 + 8, false, 0xa04040 ); } @@ -2574,7 +2256,8 @@ public class GuiCustomHex extends Gui { renderBaseTexture(); - Minecraft.getMinecraft().fontRendererObj.drawString("The Hex", guiLeft + 7, guiTop + 7, 0x404040, false); + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + fr.drawString("The Hex", guiLeft + 7, guiTop + 7, 0x404040, false); //Minecraft.getMinecraft().fontRendererObj.drawString("Applied", guiLeft + 247, guiTop + 7, 0x404040, false); tooltipToDisplay = renderSettings(mouseX, mouseY, tooltipToDisplay); @@ -2587,10 +2270,10 @@ public class GuiCustomHex extends Gui { //Can't be enchanted text if (currentState == EnchantState.INVALID_ITEM_HEX) { GlStateManager.disableDepth(); - Utils.drawStringCentered("This item can't", Minecraft.getMinecraft().fontRendererObj, + Utils.drawStringCentered("This item can't", guiLeft + X_SIZE / 2, guiTop + 88, true, 0xffff5555 ); - Utils.drawStringCentered("be enchanted", Minecraft.getMinecraft().fontRendererObj, + Utils.drawStringCentered("be enchanted", guiLeft + X_SIZE / 2, guiTop + 98, true, 0xffff5555 ); GlStateManager.enableDepth(); @@ -2631,50 +2314,14 @@ public class GuiCustomHex extends Gui { colour = 0xff5555; } - int levelWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(levelStr); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 16 - levelWidth / 2 - 1, - top + 4, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 16 - levelWidth / 2 + 1, - top + 4, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 16 - levelWidth / 2, - top + 4 - 1, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 16 - levelWidth / 2, - top + 4 + 1, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 16 - levelWidth / 2, - top + 4, - colour, - false - ); + int levelWidth = fr.getStringWidth(levelStr); + fr.drawString(levelStr, guiLeft + 16 - levelWidth / 2 - 1, top + 4, 0x2d2102, false); + fr.drawString(levelStr, guiLeft + 16 - levelWidth / 2 + 1, top + 4, 0x2d2102, false); + fr.drawString(levelStr, guiLeft + 16 - levelWidth / 2, top + 4 - 1, 0x2d2102, false); + fr.drawString(levelStr, guiLeft + 16 - levelWidth / 2, top + 4 + 1, 0x2d2102, false); + fr.drawString(levelStr, guiLeft + 16 - levelWidth / 2, top + 4, colour, false); - Minecraft.getMinecraft().fontRendererObj.drawString( - item.itemName, - guiLeft + 8 + 16 + 2 + textOffset, - top + 4 + textOffset, - 0xffffffdd, - true - ); + fr.drawString(item.itemName, guiLeft + 8 + 16 + 2 + textOffset, top + 4 + textOffset, 0xffffffdd, true); } GlScissorStack.pop(scaledResolution); @@ -2710,53 +2357,20 @@ public class GuiCustomHex extends Gui { colour = 0xff5555; } - int levelWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(levelStr); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 256 - levelWidth / 2 - 1, - top + 4, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 256 - levelWidth / 2 + 1, - top + 4, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 256 - levelWidth / 2, - top + 4 - 1, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 256 - levelWidth / 2, - top + 4 + 1, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 256 - levelWidth / 2, - top + 4, - colour, - false - ); + int levelWidth = fr.getStringWidth(levelStr); + fr.drawString(levelStr, guiLeft + 256 - levelWidth / 2 - 1, top + 4, 0x2d2102, false); + fr.drawString(levelStr, guiLeft + 256 - levelWidth / 2 + 1, top + 4, 0x2d2102, false); + fr.drawString(levelStr, guiLeft + 256 - levelWidth / 2, top + 4 - 1, 0x2d2102, false); + fr.drawString(levelStr, guiLeft + 256 - levelWidth / 2, top + 4 + 1, 0x2d2102, false); + fr.drawString(levelStr, guiLeft + 256 - levelWidth / 2, top + 4, colour, false); - Minecraft.getMinecraft().fontRendererObj.drawString(item.itemName, - guiLeft + 248 + 16 + 2 + textOffset, top + 4 + textOffset, 0xffffffdd, true - ); + fr.drawString(item.itemName, guiLeft + 248 + 16 + 2 + textOffset, top + 4 + textOffset, 0xffffffdd, true); } GlScissorStack.pop(scaledResolution); //Player Inventory Items - Minecraft.getMinecraft().fontRendererObj.drawString(Minecraft.getMinecraft().thePlayer.inventory - .getDisplayName() - .getUnformattedText(), + fr.drawString( + Minecraft.getMinecraft().thePlayer.inventory.getDisplayName().getUnformattedText(), guiLeft + 102, guiTop + Y_SIZE - 96 + 2, 0x404040 ); int inventoryStartIndex = cc.getLowerChestInventory().getSizeInventory(); @@ -2918,14 +2532,15 @@ public class GuiCustomHex extends Gui { renderBaseTexture(); - Minecraft.getMinecraft().fontRendererObj.drawString("Applicable", guiLeft + 7, guiTop + 7, 0x404040, false); - Minecraft.getMinecraft().fontRendererObj.drawString("Applied", guiLeft + 247, guiTop + 7, 0x404040, false); + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + fr.drawString("Applicable", guiLeft + 7, guiTop + 7, 0x404040, false); + fr.drawString("Applied", guiLeft + 247, guiTop + 7, 0x404040, false); //Page Text if (currentState == EnchantState.ADDING_GEMSTONE || currentState == EnchantState.APPLYING_GEMSTONE) { String pageStr = "Page: " + currentPage + "/" + expectedMaxPage; - int pageStrLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(pageStr); - Utils.drawStringCentered(pageStr, Minecraft.getMinecraft().fontRendererObj, + int pageStrLen = fr.getStringWidth(pageStr); + Utils.drawStringCentered(pageStr, guiLeft + X_SIZE / 2, guiTop + 14, false, 0x404040 ); @@ -2960,7 +2575,7 @@ public class GuiCustomHex extends Gui { Utils.drawTexturedRect(guiLeft + X_SIZE / 2 - 1 - 48, top + 18, 48, 14, 0, 48 / 512f, 342 / 512f, (342 + 14) / 512f, GL11.GL_NEAREST ); - Utils.drawStringCentered(confirmText, Minecraft.getMinecraft().fontRendererObj, + Utils.drawStringCentered(confirmText, guiLeft + X_SIZE / 2 - 1 - 23, top + 18 + 9, false, 0x408040 ); } else { @@ -2969,7 +2584,7 @@ public class GuiCustomHex extends Gui { Utils.drawTexturedRect(guiLeft + X_SIZE / 2 - 1 - 48, top + 18, 48, 14, 0, 48 / 512f, 328 / 512f, (328 + 14) / 512f, GL11.GL_NEAREST ); - Utils.drawStringCentered(confirmText, Minecraft.getMinecraft().fontRendererObj, + Utils.drawStringCentered(confirmText, guiLeft + X_SIZE / 2 - 1 - 24, top + 18 + 8, false, 0x408040 ); } @@ -2983,7 +2598,7 @@ public class GuiCustomHex extends Gui { Utils.drawTexturedRect(guiLeft + X_SIZE / 2 + 1, top + 18, 48, 14, 0, 48 / 512f, 342 / 512f, (342 + 14) / 512f, GL11.GL_NEAREST ); - Utils.drawStringCentered("Cancel", Minecraft.getMinecraft().fontRendererObj, + Utils.drawStringCentered("Cancel", guiLeft + X_SIZE / 2 + 1 + 25, top + 18 + 9, false, 0xa04040 ); } else { @@ -2992,7 +2607,7 @@ public class GuiCustomHex extends Gui { Utils.drawTexturedRect(guiLeft + X_SIZE / 2 + 1, top + 18, 48, 14, 0, 48 / 512f, 328 / 512f, (328 + 14) / 512f, GL11.GL_NEAREST ); - Utils.drawStringCentered("Cancel", Minecraft.getMinecraft().fontRendererObj, + Utils.drawStringCentered("Cancel", guiLeft + X_SIZE / 2 + 1 + 24, top + 18 + 8, false, 0xa04040 ); } @@ -3040,50 +2655,14 @@ public class GuiCustomHex extends Gui { colour = 0xff5555; } - int levelWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(levelStr); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 16 - levelWidth / 2 - 1, - top + 4, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 16 - levelWidth / 2 + 1, - top + 4, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 16 - levelWidth / 2, - top + 4 - 1, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 16 - levelWidth / 2, - top + 4 + 1, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 16 - levelWidth / 2, - top + 4, - colour, - false - ); + int levelWidth = fr.getStringWidth(levelStr); + fr.drawString(levelStr, guiLeft + 16 - levelWidth / 2 - 1, top + 4, 0x2d2102, false); + fr.drawString(levelStr, guiLeft + 16 - levelWidth / 2 + 1, top + 4, 0x2d2102, false); + fr.drawString(levelStr, guiLeft + 16 - levelWidth / 2, top + 4 - 1, 0x2d2102, false); + fr.drawString(levelStr, guiLeft + 16 - levelWidth / 2, top + 4 + 1, 0x2d2102, false); + fr.drawString(levelStr, guiLeft + 16 - levelWidth / 2, top + 4, colour, false); - Minecraft.getMinecraft().fontRendererObj.drawString( - item.itemName, - guiLeft + 8 + 16 + 2 + textOffset, - top + 4 + textOffset, - 0xffffffdd, - true - ); + fr.drawString(item.itemName, guiLeft + 8 + 16 + 2 + textOffset, top + 4 + textOffset, 0xffffffdd, true); } GlScissorStack.pop(scaledResolution); @@ -3119,51 +2698,19 @@ public class GuiCustomHex extends Gui { colour = 0xff5555; } - int levelWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(levelStr); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 256 - levelWidth / 2 - 1, - top + 4, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 256 - levelWidth / 2 + 1, - top + 4, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 256 - levelWidth / 2, - top + 4 - 1, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 256 - levelWidth / 2, - top + 4 + 1, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - guiLeft + 256 - levelWidth / 2, - top + 4, - colour, - false - ); + int levelWidth = fr.getStringWidth(levelStr); + fr.drawString(levelStr, guiLeft + 256 - levelWidth / 2 - 1, top + 4, 0x2d2102, false); + fr.drawString(levelStr, guiLeft + 256 - levelWidth / 2 + 1, top + 4, 0x2d2102, false); + fr.drawString(levelStr, guiLeft + 256 - levelWidth / 2, top + 4 - 1, 0x2d2102, false); + fr.drawString(levelStr, guiLeft + 256 - levelWidth / 2, top + 4 + 1, 0x2d2102, false); + fr.drawString(levelStr, guiLeft + 256 - levelWidth / 2, top + 4, colour, false); - Minecraft.getMinecraft().fontRendererObj.drawString(item.itemName, - guiLeft + 248 + 16 + 2 + textOffset, top + 4 + textOffset, 0xffffffdd, true - ); + fr.drawString(item.itemName, guiLeft + 248 + 16 + 2 + textOffset, top + 4 + textOffset, 0xffffffdd, true); } GlScissorStack.pop(scaledResolution); //Player Inventory Items - Minecraft.getMinecraft().fontRendererObj.drawString(Minecraft.getMinecraft().thePlayer.inventory + fr.drawString(Minecraft.getMinecraft().thePlayer.inventory .getDisplayName() .getUnformattedText(), guiLeft + 102, guiTop + Y_SIZE - 96 + 2, 0x404040 @@ -3286,36 +2833,12 @@ public class GuiCustomHex extends Gui { colour = 0xff5555; } - int levelWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(levelStr); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - left + 8 - levelWidth / 2 - 1, - top + 4, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - left + 8 - levelWidth / 2 + 1, - top + 4, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - left + 8 - levelWidth / 2, - top + 4 - 1, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - left + 8 - levelWidth / 2, - top + 4 + 1, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, left + 8 - levelWidth / 2, top + 4, colour, false); + int levelWidth = fr.getStringWidth(levelStr); + fr.drawString(levelStr, left + 8 - levelWidth / 2 - 1, top + 4, 0x2d2102, false); + fr.drawString(levelStr, left + 8 - levelWidth / 2 + 1, top + 4, 0x2d2102, false); + fr.drawString(levelStr, left + 8 - levelWidth / 2, top + 4 - 1, 0x2d2102, false); + fr.drawString(levelStr, left + 8 - levelWidth / 2, top + 4 + 1, 0x2d2102, false); + fr.drawString(levelStr, left + 8 - levelWidth / 2, top + 4, colour, false); //Enchant name String name = WordUtils.capitalizeFully(enchanterCurrentItem.itemName); @@ -3330,14 +2853,7 @@ public class GuiCustomHex extends Gui { } else if (name.equalsIgnoreCase("Turbo Mushrooms")) { name = "Turbo-Mush"; } - Utils.drawStringCentered( - name, - Minecraft.getMinecraft().fontRendererObj, - guiLeft + X_SIZE / 2, - top + 8, - true, - 0xffffffdd - ); + Utils.drawStringCentered(name, guiLeft + X_SIZE / 2, top + 8, true, 0xffffffdd); if (isChangingEnchLevel) { Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE); @@ -3349,42 +2865,12 @@ public class GuiCustomHex extends Gui { //Enchant level levelStr = ""; - levelWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(levelStr); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - left + 96 + 8 - levelWidth / 2 - 1, - top + 4, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - left + 96 + 8 - levelWidth / 2 + 1, - top + 4, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - left + 96 + 8 - levelWidth / 2, - top + 4 - 1, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - left + 96 + 8 - levelWidth / 2, - top + 4 + 1, - 0x2d2102, - false - ); - Minecraft.getMinecraft().fontRendererObj.drawString( - levelStr, - left + 96 + 8 - levelWidth / 2, - top + 4, - 0xea82ff, - false - ); + levelWidth = fr.getStringWidth(levelStr); + fr.drawString(levelStr, left + 96 + 8 - levelWidth / 2 - 1, top + 4, 0x2d2102, false); + fr.drawString(levelStr, left + 96 + 8 - levelWidth / 2 + 1, top + 4, 0x2d2102, false); + fr.drawString(levelStr, left + 96 + 8 - levelWidth / 2, top + 4 - 1, 0x2d2102, false); + fr.drawString(levelStr, left + 96 + 8 - levelWidth / 2, top + 4 + 1, 0x2d2102, false); + fr.drawString(levelStr, left + 96 + 8 - levelWidth / 2, top + 4, 0xea82ff, false); } if (!isChangingEnchLevel && itemHoverX >= 0 && itemHoverY >= 0) { @@ -3604,7 +3090,8 @@ public class GuiCustomHex extends Gui { Gui.drawRect(guiLeft + 295 + 18, guiTop + 147, guiLeft + 295 + 16 + 18, guiTop + 147 + 16, 0x80ffffff); tooltipToDisplay = createTooltip("Max Level", (NotEnoughUpdates.INSTANCE.config.enchantingSolvers.maxEnchLevel ? 0 : 1), - "Enabled", "Disabled"); + "Enabled", "Disabled" + ); tooltipToDisplay.add(1, EnumChatFormatting.GRAY + "Show max level of enchant"); tooltipToDisplay.add(2, EnumChatFormatting.GRAY + "from either hex or enchantment table"); tooltipToDisplay.add(3, EnumChatFormatting.GRAY + "max level"); @@ -3700,18 +3187,14 @@ public class GuiCustomHex extends Gui { Utils.drawTexturedRect(guiLeft + X_SIZE / 2 + 1, top + 18, 48, 14, 0, 48 / 512f, 342 / 512f, (342 + 14) / 512f, GL11.GL_NEAREST ); - Utils.drawStringCentered("Cancel", Minecraft.getMinecraft().fontRendererObj, - guiLeft + X_SIZE / 2 + 1 + 25, top + 18 + 9, false, 0xa04040 - ); + Utils.drawStringCentered("Cancel", guiLeft + X_SIZE / 2 + 1 + 25, top + 18 + 9, false, 0xa04040); } else { Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE); GlStateManager.color(1, 1, 1, 1); Utils.drawTexturedRect(guiLeft + X_SIZE / 2 + 1, top + 18, 48, 14, 0, 48 / 512f, 328 / 512f, (328 + 14) / 512f, GL11.GL_NEAREST ); - Utils.drawStringCentered("Cancel", Minecraft.getMinecraft().fontRendererObj, - guiLeft + X_SIZE / 2 + 1 + 24, top + 18 + 8, false, 0xa04040 - ); + Utils.drawStringCentered("Cancel", guiLeft + X_SIZE / 2 + 1 + 24, top + 18 + 8, false, 0xa04040); } } @@ -3735,9 +3218,7 @@ public class GuiCustomHex extends Gui { Utils.drawItemStack(stackOnMouse, mouseX - 8, mouseY - 8); } } else if (tooltipToDisplay != null) { - Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, - Minecraft.getMinecraft().fontRendererObj - ); + Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1); } } @@ -4380,7 +3861,8 @@ public class GuiCustomHex extends Gui { break; } case 1: { - NotEnoughUpdates.INSTANCE.config.enchantingSolvers.maxEnchLevel = !NotEnoughUpdates.INSTANCE.config.enchantingSolvers.maxEnchLevel; + NotEnoughUpdates.INSTANCE.config.enchantingSolvers.maxEnchLevel = + !NotEnoughUpdates.INSTANCE.config.enchantingSolvers.maxEnchLevel; break; } case 2: { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperApiLoader.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperApiLoader.java index aaa398f4..ecf02236 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperApiLoader.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperApiLoader.java @@ -47,7 +47,6 @@ import java.util.Map; public class MinionHelperApiLoader { private final MinionHelperManager manager; private boolean dirty = true; - private int ticks = 0; private boolean collectionApiEnabled = true; private boolean ignoreWorldSwitches = false; private boolean readyToUse = false; @@ -72,11 +71,7 @@ public class MinionHelperApiLoader { if (Minecraft.getMinecraft().thePlayer == null) return; if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return; if (!NotEnoughUpdates.INSTANCE.config.minionHelper.gui) return; - ticks++; - - if (ticks % 20 != 0) return; - - if (dirty) { + if (dirty && "Crafted Minions".equals(Utils.getOpenChestName())) { load(); } else { if (System.currentTimeMillis() > lastLoaded + 60_000 * 3) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlay.java index 1a625794..93a39ec0 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlay.java @@ -24,6 +24,7 @@ import com.google.common.collect.Lists; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.util.ArrowPagesUtils; import io.github.moulberry.notenoughupdates.core.util.StringUtils; +import io.github.moulberry.notenoughupdates.events.ButtonExclusionZoneEvent; import io.github.moulberry.notenoughupdates.miscgui.TrophyRewardOverlay; import io.github.moulberry.notenoughupdates.miscgui.minionhelper.Minion; import io.github.moulberry.notenoughupdates.miscgui.minionhelper.MinionHelperManager; @@ -34,6 +35,7 @@ import io.github.moulberry.notenoughupdates.miscgui.minionhelper.sources.NpcSour import io.github.moulberry.notenoughupdates.mixins.AccessorGuiContainer; import io.github.moulberry.notenoughupdates.util.ItemUtils; import io.github.moulberry.notenoughupdates.util.NotificationHandler; +import io.github.moulberry.notenoughupdates.util.Rectangle; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; @@ -94,6 +96,20 @@ public class MinionHelperOverlay { } @SubscribeEvent + public void onButtonExclusionZones(ButtonExclusionZoneEvent event) { + if (manager.inCraftedMinionsInventory() && NotEnoughUpdates.INSTANCE.config.minionHelper.gui) { + event.blockArea( + new Rectangle( + event.getGuiBaseRect().getRight(), + event.getGuiBaseRect().getTop(), + 168 /*width*/ + 4 /*space*/, 128 + ), + ButtonExclusionZoneEvent.PushDirection.TOWARDS_RIGHT + ); + } + } + + @SubscribeEvent public void onDrawBackground(GuiScreenEvent.BackgroundDrawnEvent event) { if (!manager.inCraftedMinionsInventory()) return; if (!NotEnoughUpdates.INSTANCE.config.minionHelper.gui) return; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlayHover.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlayHover.java index 84678c0c..a3549d51 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlayHover.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlayHover.java @@ -68,9 +68,7 @@ public class MinionHelperOverlayHover { OverviewLine mouseObject = overlay.getObjectOverMouse(renderMap); if (mouseObject != null) { - Utils.drawHoveringText(getTooltip(mouseObject), mouseX, mouseY, - scaledWidth, scaledHeight, -1, Minecraft.getMinecraft().fontRendererObj - ); + Utils.drawHoveringText(getTooltip(mouseObject), mouseX, mouseY, scaledWidth, scaledHeight, -1); } renderButtons(); @@ -90,7 +88,6 @@ public class MinionHelperOverlayHover { int mouseX = Mouse.getX() * scaledWidth / Minecraft.getMinecraft().displayWidth; int mouseY = scaledHeight - Mouse.getY() * scaledHeight / Minecraft.getMinecraft().displayHeight - 1; - int x = guiLeft + xSize + 4 + 149 - 3; int y = guiTop + 109 - 3; if (mouseX > x && mouseX < x + 16 && @@ -122,9 +119,7 @@ public class MinionHelperOverlayHover { list.add(""); list.add("§eClick to toggle!"); - Utils.drawHoveringText(list, mouseX, mouseY, scaledWidth, scaledHeight, -1, - Minecraft.getMinecraft().fontRendererObj - ); + Utils.drawHoveringText(list, mouseX, mouseY, scaledWidth, scaledHeight, -1); } private void renderBuyPriceButton(int scaledWidth, int scaledHeight, int mouseX, int mouseY) { @@ -145,9 +140,7 @@ public class MinionHelperOverlayHover { list.add(""); list.add("§eClick to toggle!"); - Utils.drawHoveringText(list, mouseX, mouseY, scaledWidth, scaledHeight, -1, - Minecraft.getMinecraft().fontRendererObj - ); + Utils.drawHoveringText(list, mouseX, mouseY, scaledWidth, scaledHeight, -1); } private List<String> getTooltip(OverviewLine overviewLine) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/profile/CataCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/AccessorCommandHandler.java index afc47418..73d31196 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/profile/CataCommand.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/AccessorCommandHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 NotEnoughUpdates contributors + * Copyright (C) 2023 NotEnoughUpdates contributors * * This file is part of NotEnoughUpdates. * @@ -17,20 +17,17 @@ * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. */ -package io.github.moulberry.notenoughupdates.commands.profile; +package io.github.moulberry.notenoughupdates.mixins; -import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer; -import net.minecraft.command.ICommandSender; +import net.minecraft.command.CommandHandler; +import net.minecraft.command.ICommand; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; -public class CataCommand extends ViewProfileCommand { +import java.util.Set; - public CataCommand() { - super("cata"); - } - - @Override - public void processCommand(ICommandSender sender, String[] args) { - GuiProfileViewer.currentPage = GuiProfileViewer.ProfileViewerPage.DUNGEON; - super.processCommand(sender, args); - } +@Mixin(CommandHandler.class) +public interface AccessorCommandHandler { + @Accessor("commandSet") + Set<ICommand> neuGetClientCommands(); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java index a5bb99b8..adae04f8 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java @@ -21,6 +21,7 @@ package io.github.moulberry.notenoughupdates.mixins; import io.github.moulberry.notenoughupdates.NEUOverlay; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.events.GuiContainerBackgroundDrawnEvent; import io.github.moulberry.notenoughupdates.events.SlotClickEvent; import io.github.moulberry.notenoughupdates.listener.RenderListener; import io.github.moulberry.notenoughupdates.miscfeatures.AbiphoneFavourites; @@ -30,6 +31,8 @@ import io.github.moulberry.notenoughupdates.miscfeatures.AuctionSortModeWarning; import io.github.moulberry.notenoughupdates.miscfeatures.BetterContainers; import io.github.moulberry.notenoughupdates.miscfeatures.DungeonNpcProfitOverlay; import io.github.moulberry.notenoughupdates.miscfeatures.EnchantingSolvers; +import io.github.moulberry.notenoughupdates.miscfeatures.ItemCustomizeManager; +import io.github.moulberry.notenoughupdates.miscfeatures.PresetWarning; import io.github.moulberry.notenoughupdates.miscfeatures.SlotLocking; import io.github.moulberry.notenoughupdates.miscgui.GuiCustomEnchant; import io.github.moulberry.notenoughupdates.miscgui.StorageOverlay; @@ -55,6 +58,7 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyArg; import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @@ -201,6 +205,7 @@ public abstract class MixinGuiContainer extends GuiScreen { GuiCustomHex.getInstance().overrideIsMouseOverSlot(slotIn, mouseX, mouseY, cir); AuctionBINWarning.getInstance().overrideIsMouseOverSlot(slotIn, mouseX, mouseY, cir); AbiphoneWarning.getInstance().overrideIsMouseOverSlot(slotIn, mouseX, mouseY, cir); + PresetWarning.getInstance().overrideIsMouseOverSlot(slotIn, mouseX, mouseY, cir); } @Redirect(method = "drawScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/inventory/GuiContainer;drawGradientRect(IIIIII)V")) @@ -330,6 +335,16 @@ public abstract class MixinGuiContainer extends GuiScreen { @Inject(method = "drawScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GlStateManager;color(FFFF)V", ordinal = 1)) private void drawBackground(int mouseX, int mouseY, float partialTicks, CallbackInfo ci) { - AbiphoneFavourites.getInstance().onDrawBackground(this); + new GuiContainerBackgroundDrawnEvent(((GuiContainer) (Object) this), partialTicks).post(); + } + + @ModifyArg(method = "drawSlot", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/RenderItem;renderItemAndEffectIntoGUI(Lnet/minecraft/item/ItemStack;II)V", ordinal = 0)) + public ItemStack drawSlot_renderItemAndEffectIntoGUI(ItemStack stack) { + return ItemCustomizeManager.useCustomItem(stack); + } + + @ModifyArg(method = "drawSlot", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/RenderItem;renderItemOverlayIntoGUI(Lnet/minecraft/client/gui/FontRenderer;Lnet/minecraft/item/ItemStack;IILjava/lang/String;)V")) + public ItemStack drawSlot_renderItemOverlays(ItemStack stack) { + return ItemCustomizeManager.useCustomItem(stack); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiIngame.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiIngame.java index 381f5934..285163ab 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiIngame.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiIngame.java @@ -20,24 +20,36 @@ package io.github.moulberry.notenoughupdates.mixins; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.miscfeatures.ItemCustomizeManager; import io.github.moulberry.notenoughupdates.miscfeatures.StreamerMode; import io.github.moulberry.notenoughupdates.miscgui.InventoryStorageSelector; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiIngame; import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.scoreboard.ScorePlayerTeam; import net.minecraft.scoreboard.Team; +import org.spongepowered.asm.lib.Opcodes; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyArg; import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin({GuiIngame.class}) public class MixinGuiIngame { + @Shadow + @Final + protected RenderItem itemRenderer; + @Shadow + @Final + protected Minecraft mc; private static final String TARGET = "Lnet/minecraft/scoreboard/ScorePlayerTeam;" + "formatPlayerName(Lnet/minecraft/scoreboard/Team;Ljava/lang/String;)Ljava/lang/String;"; @@ -80,4 +92,19 @@ public class MixinGuiIngame { } return inventory.getCurrentItem(); } + + @Redirect(method = "renderHotbarItem", at = @At(value = "FIELD", target = "Lnet/minecraft/item/ItemStack;animationsToGo:I", opcode = Opcodes.GETFIELD)) + public int renderHotbarItem_animationsToGo(ItemStack stack) { + return ItemCustomizeManager.useCustomItem(stack).animationsToGo; + } + + @ModifyArg(method = "renderHotbarItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/RenderItem;renderItemAndEffectIntoGUI(Lnet/minecraft/item/ItemStack;II)V", ordinal = 0)) + public ItemStack renderHotbarItem_renderItemAndEffectIntoGUI(ItemStack stack) { + return ItemCustomizeManager.useCustomItem(stack); + } + + @ModifyArg(method = "renderHotbarItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/RenderItem;renderItemOverlays(Lnet/minecraft/client/gui/FontRenderer;Lnet/minecraft/item/ItemStack;II)V", ordinal = 0)) + public ItemStack renderHotbarItem_renderItemOverlays(ItemStack stack) { + return ItemCustomizeManager.useCustomItem(stack); + } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiIngameForge.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiIngameForge.java new file mode 100644 index 00000000..b263cf31 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiIngameForge.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2023 NotEnoughUpdates contributors + * + * This file is part of NotEnoughUpdates. + * + * NotEnoughUpdates is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * NotEnoughUpdates is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. + */ + +package io.github.moulberry.notenoughupdates.mixins; + +import io.github.moulberry.notenoughupdates.miscfeatures.ItemCustomizeManager; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.client.GuiIngameForge; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(GuiIngameForge.class) +public class MixinGuiIngameForge { + + @Redirect(method = "renderHelmet", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;getItem()Lnet/minecraft/item/Item;", ordinal = 1)) + public Item renderHelmet(ItemStack stack) { + return ItemCustomizeManager.useCustomItem(stack).getItem(); + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemRenderer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemRenderer.java index c2739ad8..eb32ed70 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemRenderer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemRenderer.java @@ -19,16 +19,20 @@ package io.github.moulberry.notenoughupdates.mixins; +import io.github.moulberry.notenoughupdates.miscfeatures.ItemCustomizeManager; import io.github.moulberry.notenoughupdates.miscgui.InventoryStorageSelector; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyArg; import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(ItemRenderer.class) public abstract class MixinItemRenderer { + @Redirect(method = "updateEquippedItem", at = @At( value = "INVOKE", target = "Lnet/minecraft/entity/player/InventoryPlayer;getCurrentItem()Lnet/minecraft/item/ItemStack;" @@ -39,4 +43,19 @@ public abstract class MixinItemRenderer { } return player.getCurrentItem(); } + + @Redirect(method = "renderItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;getItem()Lnet/minecraft/item/Item;")) + public Item renderItem_getItem(ItemStack stack) { + return ItemCustomizeManager.useCustomItem(stack).getItem(); + } + + @ModifyArg(method = "renderItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/RenderItem;shouldRenderItemIn3D(Lnet/minecraft/item/ItemStack;)Z")) + public ItemStack renderItem_shouldRenderItemIn3D(ItemStack stack) { + return ItemCustomizeManager.useCustomItem(stack); + } + + @ModifyArg(method = "renderItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/RenderItem;renderItemModelForEntity(Lnet/minecraft/item/ItemStack;Lnet/minecraft/entity/EntityLivingBase;Lnet/minecraft/client/renderer/block/model/ItemCameraTransforms$TransformType;)V", ordinal = 0)) + public ItemStack renderItem_renderItemModelForEntity(ItemStack stack) { + return ItemCustomizeManager.useCustomItem(stack); + } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemStack.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemStack.java index 83379a18..127e4216 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemStack.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemStack.java @@ -19,6 +19,7 @@ package io.github.moulberry.notenoughupdates.mixins; +import io.github.moulberry.notenoughupdates.core.ChromaColour; import io.github.moulberry.notenoughupdates.miscfeatures.ItemCustomizeManager; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.item.ItemStack; @@ -27,8 +28,11 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import java.awt.*; + @Mixin({ItemStack.class}) public class MixinItemStack { @Inject(method = "hasEffect", at = @At("HEAD"), cancellable = true) @@ -66,4 +70,32 @@ public class MixinItemStack { } catch (Exception ignored) { } } + + @Redirect(method = "getTooltip", at = @At(value = "INVOKE", target = "Lnet/minecraft/nbt/NBTTagCompound;hasKey(Ljava/lang/String;I)Z", ordinal = 2)) + public boolean getTooltip_hasKey2(NBTTagCompound nbttagcompound, String key, int type) { + ItemStack stack = (ItemStack) (Object) this; + ItemCustomizeManager.ItemData data = ItemCustomizeManager.getDataForItem(stack); + if (data != null && data.customLeatherColour != null && ItemCustomizeManager.shouldRenderLeatherColour(stack)) { + return true; + } else if (data != null && !ItemCustomizeManager.shouldRenderLeatherColour(stack)) { + return false; + } + return nbttagcompound.hasKey("color", 3); + } + + @Redirect(method = "getTooltip", at = @At(value = "INVOKE", target = "Ljava/lang/Integer;toHexString(I)Ljava/lang/String;")) + public String getTooltip_toHexString(int colour) { + ItemStack stack = (ItemStack) (Object) this; + ItemCustomizeManager.ItemData data = ItemCustomizeManager.getDataForItem(stack); + if (data != null && data.customLeatherColour != null && ItemCustomizeManager.shouldRenderLeatherColour(stack)) { + int currentColour = ChromaColour.specialToChromaRGB(data.customLeatherColour); + Color c = new Color(currentColour, false); + String hex = Integer.toHexString(c.getRGB() & 0xFFFFFF); + if (hex.length() < 6) { + hex = hex + "000000".substring(0, 6 - hex.length()); + } + return hex.length() < 6 ? "0" + hex : hex; + } + return Integer.toHexString(colour); + } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLayerArmorBase.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLayerArmorBase.java index 773e7ebe..0a5acedf 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLayerArmorBase.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLayerArmorBase.java @@ -76,10 +76,20 @@ public abstract class MixinLayerArmorBase<T extends ModelBase> { ) public int renderItem_getColor(ItemArmor item, ItemStack stack) { ItemCustomizeManager.ItemData data = ItemCustomizeManager.getDataForItem(stack); - if (data != null && data.customLeatherColour != null) { + if (data != null && data.customLeatherColour != null && ItemCustomizeManager.shouldRenderLeatherColour(stack)) { return ChromaColour.specialToChromaRGB(data.customLeatherColour); } return item.getColor(stack); } + + @Redirect(method = "renderLayer", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/renderer/entity/layers/LayerArmorBase;getCurrentArmor(Lnet/minecraft/entity/EntityLivingBase;I)Lnet/minecraft/item/ItemStack;" + ) + ) + public ItemStack renderItem_getCurrentArmor(LayerArmorBase<?> instance, EntityLivingBase entitylivingbaseIn, int armorSlot) { + return ItemCustomizeManager.useCustomArmour(instance, entitylivingbaseIn, armorSlot); + } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLayerCustomHead.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLayerCustomHead.java index 90101696..c3d92ab7 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLayerCustomHead.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLayerCustomHead.java @@ -53,6 +53,11 @@ public class MixinLayerCustomHead { } } + @Redirect(method = "doRenderLayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/EntityLivingBase;getCurrentArmor(I)Lnet/minecraft/item/ItemStack;")) + public ItemStack doRenderLayer_getCurrentArmor(EntityLivingBase instance, int i) { + return ItemCustomizeManager.setHeadArmour(instance, i); + } + @Redirect(method = "doRenderLayer", at = @At( value = "INVOKE", diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinOFDynamicLights.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinOFDynamicLights.java new file mode 100644 index 00000000..68f75d49 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinOFDynamicLights.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2023 NotEnoughUpdates contributors + * + * This file is part of NotEnoughUpdates. + * + * NotEnoughUpdates is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * NotEnoughUpdates is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. + */ + +package io.github.moulberry.notenoughupdates.mixins; + +import io.github.moulberry.notenoughupdates.miscgui.DynamicLightItemsEditor; +import net.minecraft.item.ItemStack; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Pseudo +@Mixin(targets = "net.optifine.DynamicLights", remap = false) +public class MixinOFDynamicLights { + + @Inject(method = "getLightLevel(Lnet/minecraft/item/ItemStack;)I", at = @At("TAIL"), cancellable = true) + private static void getLightLevel(ItemStack itemStack, CallbackInfoReturnable<Integer> cir) { + int lightLevel = DynamicLightItemsEditor.findDynamicLightItems(itemStack); + if (lightLevel != 0) cir.setReturnValue(lightLevel); + } + +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderItem.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderItem.java index 7c2cfcbf..633a82a2 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderItem.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderItem.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 NotEnoughUpdates contributors + * Copyright (C) 2022-2023 NotEnoughUpdates contributors * * This file is part of NotEnoughUpdates. * @@ -131,7 +131,7 @@ public abstract class MixinRenderItem { public int renderItem_renderByItem(Item item, ItemStack stack, int renderPass) { if (renderPass == 0) { ItemCustomizeManager.ItemData data = ItemCustomizeManager.getDataForItem(stack); - if (data != null && data.customLeatherColour != null) { + if (data != null && data.customLeatherColour != null && ItemCustomizeManager.shouldRenderLeatherColour(stack)) { return ChromaColour.specialToChromaRGB(data.customLeatherColour); } } @@ -148,51 +148,6 @@ public abstract class MixinRenderItem { @Shadow abstract void renderModel(IBakedModel model, int color); - /*@Redirect(method="renderEffect", - at=@At( - value = "INVOKE", - target = "Lnet/minecraft/client/renderer/entity/RenderItem;renderModel(Lnet/minecraft/client/resources/model/IBakedModel;I)V" - ) - ) - public void renderEffect_renderModel(RenderItem renderItem, IBakedModel model, int colour) { - if(customEnchGlint != null) { - renderModel(model, ChromaColour.specialToChromaRGB(customEnchGlint)); - } else { - renderModel(model, colour); - } - } - - @Redirect(method="renderEffect", - at=@At( - value = "INVOKE", - target = "Lnet/minecraft/client/renderer/texture/TextureManager;bindTexture(Lnet/minecraft/util/ResourceLocation;)V" - ) - ) - public void renderEffect_bindTexture(TextureManager textureManager, ResourceLocation location) { - if(customEnchGlint != null) { - textureManager.bindTexture(GlintManager.getCustomGlintTexture()); - GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); - GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); - } else { - textureManager.bindTexture(location); - } - } - - @Redirect(method="renderEffect", - at=@At( - value = "INVOKE", - target = "Lnet/minecraft/client/renderer/GlStateManager;blendFunc(II)V" - ) - ) - public void renderEffect_blendFunc(int src, int dst) { - if(dst != 1) { - GlStateManager.blendFunc(src, dst); - } else if(customEnchGlint != null) { - GlintManager.setCustomBlendFunc(customEnchGlint); - } else { - GlStateManager.blendFunc(GL11.GL_SRC_COLOR, 1); - } - }*/ @Inject(method = "renderItemIntoGUI", at = @At("HEAD")) public void renderItemHead(ItemStack stack, int x, int y, CallbackInfo ci) { @@ -301,4 +256,12 @@ public abstract class MixinRenderItem { GlStateManager.enableDepth(); } } + + @Redirect(method = "renderItemOverlayIntoGUI", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/Item;showDurabilityBar(Lnet/minecraft/item/ItemStack;)Z")) + public boolean renderItemOverlayIntoGUI_showDurabilityBar( + Item instance, ItemStack stack + ) { + if (ItemCustomizeManager.hasCustomItem(stack)) return false; + return stack.getItem().showDurabilityBar(stack); + } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java index a289ca51..53906cd8 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java @@ -34,6 +34,8 @@ import io.github.moulberry.notenoughupdates.miscgui.GuiEnchantColour; import io.github.moulberry.notenoughupdates.miscgui.GuiInvButtonEditor; import io.github.moulberry.notenoughupdates.miscgui.NEUOverlayPlacements; import io.github.moulberry.notenoughupdates.options.customtypes.NEUDebugFlag; +import io.github.moulberry.notenoughupdates.options.seperateSections.Garden; +import io.github.moulberry.notenoughupdates.options.seperateSections.WorldConfig; import io.github.moulberry.notenoughupdates.options.seperateSections.AHGraph; import io.github.moulberry.notenoughupdates.options.seperateSections.AHTweaks; import io.github.moulberry.notenoughupdates.options.seperateSections.AccessoryBag; @@ -54,6 +56,7 @@ import io.github.moulberry.notenoughupdates.options.seperateSections.Mining; import io.github.moulberry.notenoughupdates.options.seperateSections.MinionHelper; import io.github.moulberry.notenoughupdates.options.seperateSections.Misc; import io.github.moulberry.notenoughupdates.options.seperateSections.MiscOverlays; +import io.github.moulberry.notenoughupdates.options.seperateSections.Museum; import io.github.moulberry.notenoughupdates.options.seperateSections.NeuAuctionHouse; import io.github.moulberry.notenoughupdates.options.seperateSections.Notifications; import io.github.moulberry.notenoughupdates.options.seperateSections.PetOverlay; @@ -73,16 +76,17 @@ import io.github.moulberry.notenoughupdates.overlays.TextOverlay; import io.github.moulberry.notenoughupdates.util.NotificationHandler; import io.github.moulberry.notenoughupdates.util.SBInfo; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiScreen; import net.minecraftforge.client.ClientCommandHandler; import java.util.ArrayList; import java.util.EnumSet; import java.util.HashMap; +import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Set; public class NEUConfig extends Config { public void editOverlay() { @@ -246,8 +250,8 @@ public class NEUConfig extends Config { @Expose @Category( - name = "Todo Overlay", - desc = "Todo Overlay" + name = "Todo Overlays", + desc = "Todo Overlays" ) public MiscOverlays miscOverlays = new MiscOverlays(); @@ -295,6 +299,13 @@ public class NEUConfig extends Config { @Expose @Category( + name = "Garden", + desc = "Garden" + ) + public Garden garden = new Garden(); + + @Expose + @Category( name = "NEU Auction House", desc = "NEU Auction House" ) @@ -379,6 +390,13 @@ public class NEUConfig extends Config { @Expose @Category( + name = "Museum", + desc = "Museum overlays" + ) + public Museum museum = new Museum(); + + @Expose + @Category( name = "Profile Viewer", desc = "Profile Viewer" ) @@ -455,6 +473,8 @@ public class NEUConfig extends Config { public ArrayList<String> quickCommands = createDefaultQuickCommands(); @Expose public ArrayList<String> enchantColours = createDefaultEnchantColours(); + @Expose + public Set<String> dynamicLightItems = new HashSet<>(); @Expose public boolean firstTimeSearchFocus = true; @@ -573,6 +593,8 @@ public class NEUConfig extends Config { @Expose public long questBoardCompleted = 0L; @Expose + public long dailyShopLimitCompleted = 0L; + @Expose public HashMap<Integer, JsonObject> savedEquipment = new HashMap<>(); @Expose public int magicalPower = 0; @@ -594,6 +616,9 @@ public class NEUConfig extends Config { @Expose public boolean abiphoneShowOnlyFavourites = false; + + @Expose + public Map<String, Integer> hotmTree = new HashMap<>(); } public HiddenLocationSpecific getLocationSpecific() { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java index fe1f0af4..677e5822 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java @@ -34,7 +34,6 @@ import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; import io.github.moulberry.notenoughupdates.core.util.render.TextRenderUtils; 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.renderer.GlStateManager; @@ -289,15 +288,9 @@ public class NEUConfigEditor extends GuiElement { RenderUtils.drawFloatingRectDark(x + 5, y + 5, xSize - 10, 20, false); - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; TextRenderUtils.drawStringCenteredScaledMaxWidth( "NotEnoughUpdates by " + EnumChatFormatting.DARK_PURPLE + "Moulberry", - fr, - x + xSize / 2, - y + 15, - false, - 200, - 0xa0a0a0 + x + xSize / 2, y + 15, false, 200, 0xa0a0a0 ); RenderUtils.drawFloatingRectDark(x + 4, y + 49 - 20, @@ -334,9 +327,7 @@ public class NEUConfigEditor extends GuiElement { } else { catName = EnumChatFormatting.GRAY + catName; } - TextRenderUtils.drawStringCenteredScaledMaxWidth(catName, - fr, x + 75, y + 70 + catY, false, 100, -1 - ); + TextRenderUtils.drawStringCenteredScaledMaxWidth(catName, x + 75, y + 70 + catY, false, 100, -1); catY += 15; if (catY > 0) { catBarSize = @@ -366,9 +357,7 @@ public class NEUConfigEditor extends GuiElement { GlScissorStack.pop(scaledResolution); - TextRenderUtils.drawStringCenteredScaledMaxWidth("Categories", - fr, x + 75, y + 44, false, 120, 0xa368ef - ); + TextRenderUtils.drawStringCenteredScaledMaxWidth("Categories", x + 75, y + 44, false, 120, 0xa368ef); RenderUtils.drawFloatingRectDark(x + 149, y + 29, xSize - 154, ySize - 34, false); @@ -405,8 +394,9 @@ public class NEUConfigEditor extends GuiElement { if (getSelectedCategory() != null && currentConfigEditing.containsKey(getSelectedCategory())) { ConfigProcessor.ProcessedCategory cat = currentConfigEditing.get(getSelectedCategory()); - TextRenderUtils.drawStringScaledMaxWidth(cat.desc, - fr, innerLeft + 5, y + 40, true, innerRight - innerLeft - rightStuffLen - 10, 0xb0b0b0 + TextRenderUtils.drawStringScaledMaxWidth( + cat.desc, + innerLeft + 5, y + 40, true, innerRight - innerLeft - rightStuffLen - 10, 0xb0b0b0 ); } @@ -552,7 +542,9 @@ public class NEUConfigEditor extends GuiElement { GlScissorStack.clear(); if (tooltipToDisplay != null) { - TextRenderUtils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, fr); + TextRenderUtils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, + Minecraft.getMinecraft().fontRendererObj + ); } GlStateManager.translate(0, 0, -2); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/customtypes/NEUDebugFlag.java b/src/main/java/io/github/moulberry/notenoughupdates/options/customtypes/NEUDebugFlag.java index 50f459c0..90ef93bb 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/customtypes/NEUDebugFlag.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/customtypes/NEUDebugFlag.java @@ -31,6 +31,7 @@ public enum NEUDebugFlag { WISHING("Wishing Compass Solver"), MAP("Dungeon Map Player Information"), SEARCH("SearchString Matches"), + API_CACHE("Api Cache"), ; private final String description; @@ -43,6 +44,10 @@ public enum NEUDebugFlag { return description; } + public void log(String message) { + NEUDebugLogger.log(this, message); + } + public boolean isSet() { return NEUDebugLogger.isFlagEnabled(this); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/ClientCommandBase.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Garden.java index e0ae7a1a..b5f11906 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/ClientCommandBase.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Garden.java @@ -17,30 +17,26 @@ * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. */ -package io.github.moulberry.notenoughupdates.commands; +package io.github.moulberry.notenoughupdates.options.seperateSections; -import net.minecraft.command.CommandBase; -import net.minecraft.command.ICommandSender; +import com.google.gson.annotations.Expose; +import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; +import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; -public abstract class ClientCommandBase extends CommandBase { - private final String name; +public class Garden { + @Expose + @ConfigOption( + name = "Mute Composter", + desc = "Mute sounds of composting" + ) + @ConfigEditorBoolean + public boolean muteComposterSounds = false; - protected ClientCommandBase(String name) { - this.name = name; - } - - @Override - public String getCommandName() { - return name; - } - - @Override - public String getCommandUsage(ICommandSender sender) { - return "/" + name; - } - - @Override - public boolean canCommandSenderUseCommand(ICommandSender sender) { - return true; - } + @Expose + @ConfigOption( + name = "Enable Preset Delete Warning", + desc = "Asks for confirmation when deleting a preset" + ) + @ConfigEditorBoolean + public boolean presetDeleteWarning = true; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ItemOverlays.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ItemOverlays.java index 081fd4b3..96ce838a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ItemOverlays.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ItemOverlays.java @@ -377,6 +377,15 @@ public class ItemOverlays { @ConfigAccordionId(id = 7) public boolean enableDirtWandOverlay = true; + @Expose + @ConfigOption( + name = "Enable Scythe Overlay", + desc = "Show a block overlay for the effected blocks of scythe's ability." + ) + @ConfigEditorBoolean + @ConfigAccordionId(id = 7) + public boolean enableScytheOverlay = true; + @ConfigOption( name="Custom Wither Cloak", desc = "" diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java index 74400f59..e1b2662a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java @@ -152,16 +152,17 @@ public class Mining { ) @ConfigEditorDraggableList( exampleText = { - "\u00a73Goblin Slayer: \u00a7626.5%\n\u00a73Lucky Raffle: \u00a7c0.0%", - "\u00a73Mithril Powder: \u00a726,243", - "\u00a73Gemstone Powder: \u00a7d6,243", - "\u00a73Forge 1) \u00a79Diamonite\u00a77: \u00a7aReady!", - "\u00a73Pickaxe CD: \u00a7a78s", - "\u00a73Star Cult: \u00a7a78s" + "§3Goblin Slayer: §626.5%\n§3Lucky Raffle: §c0.0%", + "§3Mithril Powder: §26,243", + "§3Gemstone Powder: §d6,243", + "§3Forge 1) §9Diamonite§7: §aReady!", + "§3Pickaxe CD: §a78s", + "§3Star Cult: §a78s", + "§3Sky Mall: §a5x Titanium (78s)" } ) @ConfigAccordionId(id = 2) - public List<Integer> dwarvenText2 = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4, 5)); + public List<Integer> dwarvenText2 = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4, 5, 6)); @Expose public Position overlayPosition = new Position(10, 100); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java index 47e51eec..02630df9 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java @@ -311,4 +311,12 @@ public class Misc { @ConfigEditorBoolean public boolean dungeonGroupsPV = true; + @Expose + @ConfigOption( + name = "Old SkyBlock Menu", + desc = "Show old buttons in the SkyBlock Menu: Trade, Accessories, Potions, Quiver, Fishing and Sacks. " + + "§cOnly works with the booster cookie effect active." + ) + @ConfigEditorBoolean + public boolean oldSkyBlockMenu = false; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MiscOverlays.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MiscOverlays.java index 5634a4b7..97b11d27 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MiscOverlays.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MiscOverlays.java @@ -86,10 +86,11 @@ public class MiscOverlays { "\u00a73Gemstone Powder: \u00a7e3h38m", "\u00a73Heavy Pearls: \u00a7e3h38m", "\u00a73Crimson Isle Quests: \u00a7e3h38m", + "\u00a73NPC Buy Daily Limit: \u00a7e3h38m", } ) @ConfigAccordionId(id = 0) - public List<Integer> todoText2 = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); + public List<Integer> todoText2 = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)); @ConfigOption( name = "Show Only If Soon", @@ -232,6 +233,18 @@ public class MiscOverlays { ) public int questBoardDisplay = 0; + @Expose + @ConfigOption( + name = "NPC Buy Daily Limit Display", + desc = "Change the way the NPC shop limit displays\n" + + "Only when ready, When very Soon, When soon, When kinda soon or always." + ) + @ConfigAccordionId(id = 1) + @ConfigEditorDropdown( + values = {"Only when ready", "When very Soon", "When soon", "When Kinda Soon", "Always"} + ) + public int shopLimitDisplay = 0; + @ConfigOption( name = "Colours", desc = "", diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Museum.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Museum.java new file mode 100644 index 00000000..6f03c2bb --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Museum.java @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2023 NotEnoughUpdates contributors + * + * This file is part of NotEnoughUpdates. + * + * NotEnoughUpdates is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * NotEnoughUpdates is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. + */ + +package io.github.moulberry.notenoughupdates.options.seperateSections; + +import com.google.gson.annotations.Expose; +import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; +import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorColour; +import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDropdown; +import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; + +public class Museum { + + @Expose + @ConfigOption( + name = "Show Museum Items", + desc = "Show real items instead of green dye in the museum" + ) + @ConfigEditorBoolean + public boolean museumItemShow = false; + + @Expose + @ConfigOption( + name = "Highlight virtual museum items", + desc = "Highlight virtual museum items with a background color" + ) + @ConfigEditorColour + public String museumItemColor = "0:255:0:255:0"; + + @Expose + @ConfigOption( + name = "Show Items to donate", + desc = "Show the cheapest items you have not yet donated to the Museum" + ) + @ConfigEditorBoolean + public boolean museumCheapestItemOverlay = true; + + @Expose + @ConfigOption( + name = "Value calculation", + desc = "Choose the source for the value calculation" + ) + @ConfigEditorDropdown( + values = {"Lowest BIN", "Craft cost"} + ) + public int museumCheapestItemOverlayValueSource = 0; + +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/PetOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/PetOverlay.java index fce1f9af..9d88e8f1 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/PetOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/PetOverlay.java @@ -22,7 +22,6 @@ package io.github.moulberry.notenoughupdates.options.seperateSections; import com.google.gson.annotations.Expose; import io.github.moulberry.notenoughupdates.core.config.Position; import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorButton; import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDraggableList; import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDropdown; import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; @@ -131,4 +130,12 @@ public class PetOverlay { ) @ConfigEditorBoolean public boolean showKatSitting = true; + + @Expose + @ConfigOption( + name = "Hide Pet Level Progress", + desc = "Hide the pet level progress information for maxed out pets." + ) + @ConfigEditorBoolean + public boolean hidePetLevelProgress = false; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TooltipTweaks.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TooltipTweaks.java index 29fc24c1..d3ebe1a9 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TooltipTweaks.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TooltipTweaks.java @@ -267,4 +267,12 @@ public class TooltipTweaks { ) @ConfigEditorBoolean public boolean essencePriceInEssenceShop = true; + + @Expose + @ConfigOption( + name = "Item Cost in Garden NPC", + desc = "Show the item cost in garden NPC shop" + ) + @ConfigEditorBoolean + public boolean gardenNpcPrice = true; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java index fcea79dd..942eee8b 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java @@ -274,15 +274,7 @@ public class AuctionSearchOverlay { } if (tooltipToDisplay != null) { - Utils.drawHoveringText( - tooltipToDisplay, - mouseX, - mouseY, - width, - height, - -1, - Minecraft.getMinecraft().fontRendererObj - ); + Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/BazaarSearchOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/BazaarSearchOverlay.java index 66dacda3..dab9156e 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/BazaarSearchOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/BazaarSearchOverlay.java @@ -225,15 +225,7 @@ public class BazaarSearchOverlay { } if (tooltipToDisplay != null) { - Utils.drawHoveringText( - tooltipToDisplay, - mouseX, - mouseY, - width, - height, - -1, - Minecraft.getMinecraft().fontRendererObj - ); + Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/CombatSkillOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/CombatSkillOverlay.java index 45ce0098..3bd5150f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/CombatSkillOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/CombatSkillOverlay.java @@ -245,7 +245,7 @@ public class CombatSkillOverlay lineMap.put(0, EnumChatFormatting.AQUA + "Kills: " + EnumChatFormatting.YELLOW + format.format(counterInterp)); } - if (championTier <= 9) { + if (championTier <= 9 && championXp >= 0) { int counterInterp = (int) interp(championXp, championXpLast); lineMap.put( 6, diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/EquipmentOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/EquipmentOverlay.java index db81bfa4..4d14e47f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/EquipmentOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/EquipmentOverlay.java @@ -25,16 +25,17 @@ import com.google.gson.JsonPrimitive; import io.github.moulberry.notenoughupdates.NEUManager; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe; +import io.github.moulberry.notenoughupdates.events.ButtonExclusionZoneEvent; import io.github.moulberry.notenoughupdates.events.GuiInventoryBackgroundDrawnEvent; import io.github.moulberry.notenoughupdates.miscfeatures.PetInfoOverlay; import io.github.moulberry.notenoughupdates.miscgui.GuiInvButtonEditor; import io.github.moulberry.notenoughupdates.mixins.AccessorGuiContainer; import io.github.moulberry.notenoughupdates.options.NEUConfig; import io.github.moulberry.notenoughupdates.util.ItemUtils; +import io.github.moulberry.notenoughupdates.util.Rectangle; import io.github.moulberry.notenoughupdates.util.SBInfo; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.inventory.GuiChest; import net.minecraft.client.gui.inventory.GuiInventory; @@ -108,7 +109,9 @@ public class EquipmentOverlay { case 2: return ARMOR_DISPLAY_DARK; case 3: - return NotEnoughUpdates.INSTANCE.config.petOverlay.colourStyle == 3 && isPetRendering ? ARMOR_DISPLAY_TRANSPARENT_PET : ARMOR_DISPLAY_TRANSPARENT; + return NotEnoughUpdates.INSTANCE.config.petOverlay.colourStyle == 3 && isPetRendering + ? ARMOR_DISPLAY_TRANSPARENT_PET + : ARMOR_DISPLAY_TRANSPARENT; case 4: return ARMOR_DISPLAY_FSR; } @@ -142,13 +145,35 @@ public class EquipmentOverlay { public static final int PET_OVERLAY_OFFSET_Y = ARMOR_OVERLAY_HEIGHT - 14 /* overlaying pixels */; //</editor-fold> - public boolean shouldRenderPets; public boolean shouldRenderArmorHud; public ItemStack petStack; //<editor-fold desc="events"> + @SubscribeEvent + public void onButtonExclusionZones(ButtonExclusionZoneEvent event) { + if (isRenderingArmorHud()) { + event.blockArea( + new Rectangle( + event.getGuiBaseRect().getRight() - 200, + event.getGuiBaseRect().getTop(), + 50, 84 + ), + ButtonExclusionZoneEvent.PushDirection.TOWARDS_LEFT + ); + } + if (isRenderingPetHud()) { + event.blockArea( + new Rectangle( + event.getGuiBaseRect().getRight() - 200, + event.getGuiBaseRect().getTop() + 60, + 50, 60 + ), + ButtonExclusionZoneEvent.PushDirection.TOWARDS_LEFT + ); + } + } @SubscribeEvent public void onGuiTick(TickEvent.ClientTickEvent event) { @@ -229,12 +254,7 @@ public class EquipmentOverlay { )) { Utils.drawHoveringText( tooltipToDisplay, - mouseX - calculateTooltipXOffset(tooltipToDisplay, Minecraft.getMinecraft().fontRendererObj), - mouseY, - width, - height, - -1, - Minecraft.getMinecraft().fontRendererObj + mouseX - calculateTooltipXOffset(tooltipToDisplay), mouseY, width, height, -1 ); } @@ -263,7 +283,8 @@ public class EquipmentOverlay { slot4 = getWardrobeSlot(37); } - if ((screen instanceof GuiChest || screen instanceof GuiInventory) && NotEnoughUpdates.INSTANCE.config.petOverlay.petInvDisplay){ + if ((screen instanceof GuiChest || screen instanceof GuiInventory) && + NotEnoughUpdates.INSTANCE.config.petOverlay.petInvDisplay) { petStack = getRepoPetStack(); } if ((!(screen instanceof GuiInventory) && !(screen instanceof GuiInvButtonEditor)) @@ -321,12 +342,8 @@ public class EquipmentOverlay { tooltipToDisplay = petInfo.getTooltip(Minecraft.getMinecraft().thePlayer, false); Utils.drawHoveringText( tooltipToDisplay, - mouseX - calculateTooltipXOffset(tooltipToDisplay, Minecraft.getMinecraft().fontRendererObj), - mouseY, - width, - height, - -1, - Minecraft.getMinecraft().fontRendererObj + mouseX - calculateTooltipXOffset(tooltipToDisplay), + mouseY, width, height, -1 ); } } @@ -413,14 +430,13 @@ public class EquipmentOverlay { * Calculates the width of the longest String in the tooltip, which can be used to offset the entire tooltip to the left more precisely * * @param tooltipToDisplay tooltip - * @param fr FontRenderer object * @return offset to apply */ - private int calculateTooltipXOffset(List<String> tooltipToDisplay, FontRenderer fr) { + private int calculateTooltipXOffset(List<String> tooltipToDisplay) { int offset = 0; if (tooltipToDisplay != null) { for (String line : tooltipToDisplay) { - int lineWidth = fr.getStringWidth(line); + int lineWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(line); if (lineWidth > offset) { offset = lineWidth; } @@ -430,7 +446,8 @@ public class EquipmentOverlay { } public void renderPreviewArmorHud() { - if (!NotEnoughUpdates.INSTANCE.config.customArmour.enableArmourHud || !(Minecraft.getMinecraft().currentScreen instanceof GuiInvButtonEditor)) return; + if (!NotEnoughUpdates.INSTANCE.config.customArmour.enableArmourHud || + !(Minecraft.getMinecraft().currentScreen instanceof GuiInvButtonEditor)) return; GuiInvButtonEditor container = (GuiInvButtonEditor) Minecraft.getMinecraft().currentScreen; int overlayLeft = container.getGuiLeft() - ARMOR_OVERLAY_OVERHAND_WIDTH; @@ -443,7 +460,8 @@ public class EquipmentOverlay { } public void renderPreviewPetInvHud() { - if (!NotEnoughUpdates.INSTANCE.config.petOverlay.petInvDisplay || !(Minecraft.getMinecraft().currentScreen instanceof GuiInvButtonEditor)) return; + if (!NotEnoughUpdates.INSTANCE.config.petOverlay.petInvDisplay || + !(Minecraft.getMinecraft().currentScreen instanceof GuiInvButtonEditor)) return; GuiInvButtonEditor container = (GuiInvButtonEditor) Minecraft.getMinecraft().currentScreen; int overlayLeft = container.getGuiLeft() - ARMOR_OVERLAY_OVERHAND_WIDTH; int overlayTop = container.getGuiTop() + PET_OVERLAY_OFFSET_Y; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java index ea253e94..db1a7755 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java @@ -24,6 +24,7 @@ import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.config.Position; import io.github.moulberry.notenoughupdates.core.util.StringUtils; import io.github.moulberry.notenoughupdates.core.util.lerp.LerpUtils; +import io.github.moulberry.notenoughupdates.guifeatures.SkyMallDisplay; import io.github.moulberry.notenoughupdates.miscfeatures.ItemCooldowns; import io.github.moulberry.notenoughupdates.options.NEUConfig; import io.github.moulberry.notenoughupdates.util.SBInfo; @@ -45,6 +46,7 @@ import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.function.Supplier; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -439,6 +441,12 @@ public class MiningOverlay extends TextTabOverlay { DARK_AQUA + "Star Cult: " + GREEN + StarCultCalculator.getNextStarCult()); break; + case 6: + + if (Objects.equals(SBInfo.getInstance().getLocation(), "mining_3")) { + overlayStrings.add("§3Sky Mall: §a" + SkyMallDisplay.Companion.getDisplayText()); + } + break; } } } else { @@ -714,17 +722,17 @@ public class MiningOverlay extends TextTabOverlay { String cleaned = Utils.cleanColour(line); String beforeColon = cleaned.split(":")[0]; - if (miningOverlayCommisionItems == null) { - setupMiningOverlayCommisionItems(); + if (miningOverlayCommissionItems == null) { + setupMiningOverlayCommissionItems(); } - if (miningOverlayCommisionItems.containsKey(beforeColon)) { - icon = miningOverlayCommisionItems.get(beforeColon); + if (miningOverlayCommissionItems.containsKey(beforeColon)) { + icon = miningOverlayCommissionItems.get(beforeColon); } else { if (beforeColon.startsWith("Forge")) { - icon = miningOverlayCommisionItems.get("Forge"); + icon = miningOverlayCommissionItems.get("Forge"); } else if (beforeColon.contains("Mithril")) { - icon = miningOverlayCommisionItems.get("Mithril"); + icon = miningOverlayCommissionItems.get("Mithril"); } else if (beforeColon.endsWith(" Gemstone Collector")) { String gemName = "ROUGH_" + beforeColon.replace(" Gemstone Collector", "").toUpperCase() + "_GEM"; @@ -748,7 +756,11 @@ public class MiningOverlay extends TextTabOverlay { miningOverlayPerfectGems.put(gemName, icon); } } else if (beforeColon.contains("Titanium")) { - icon = miningOverlayCommisionItems.get("Titanium"); + icon = miningOverlayCommissionItems.get("Titanium"); + } else if (beforeColon.contains("Sky Mall")) { + if (Objects.equals(SBInfo.getInstance().getLocation(), "mining_3")) { + icon = SkyMallDisplay.Companion.getDisplayItem(); + } } } @@ -768,10 +780,10 @@ public class MiningOverlay extends TextTabOverlay { private static final HashMap<String, ItemStack> miningOverlayRoughGems = new HashMap<String, ItemStack>() {}; private static final HashMap<String, ItemStack> miningOverlayPerfectGems = new HashMap<String, ItemStack>() {}; - private static HashMap<String, ItemStack> miningOverlayCommisionItems; + private static HashMap<String, ItemStack> miningOverlayCommissionItems; - private static void setupMiningOverlayCommisionItems() { - miningOverlayCommisionItems = new HashMap<String, ItemStack>() {{ + private static void setupMiningOverlayCommissionItems() { + miningOverlayCommissionItems = new HashMap<String, ItemStack>() {{ put( "Mithril Powder", NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/OverlayManager.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/OverlayManager.java index a8b7112f..99e8b1e4 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/OverlayManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/OverlayManager.java @@ -63,7 +63,8 @@ public class OverlayManager { "\u00a73Experiments: \u00a7e3h38m", "\u00a73Mithril Powder: \u00a7e3h38m", "\u00a73Gemstone Powder: \u00a7e3h38m", - "\u00a73Crimson Isle Quests: \u00a7e3h38m" + "\u00a73Crimson Isle Quests: \u00a7e3h38m", + "\u00a73NPC Buy Daily Limit: \u00a7e3h38m" ); textOverlays.add( timersOverlay = new TimersOverlay(NotEnoughUpdates.INSTANCE.config.miscOverlays.todoPosition, () -> { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/PowderGrindingOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/PowderGrindingOverlay.java index ad8755e3..68a0e1f0 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/PowderGrindingOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/PowderGrindingOverlay.java @@ -19,12 +19,13 @@ package io.github.moulberry.notenoughupdates.overlays; -import com.google.gson.JsonParser; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.config.Position; import io.github.moulberry.notenoughupdates.core.util.lerp.LerpUtils; import io.github.moulberry.notenoughupdates.options.NEUConfig; import io.github.moulberry.notenoughupdates.util.SBInfo; +import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.entity.boss.BossStatus; import java.text.NumberFormat; import java.util.ArrayList; @@ -35,10 +36,9 @@ import java.util.regex.Pattern; public class PowderGrindingOverlay extends TextTabOverlay { - private final static JsonParser PARSER = new JsonParser(); - - private final static Pattern pattern = + private final static Pattern POWDER_PATTERN = Pattern.compile("You received \\+([0-9]+(?:,\\d+)*) (Mithril|Gemstone) Powder\\."); + private final static Pattern EVENT_PATTERN = Pattern.compile("PASSIVE EVENT (.+) RUNNING FOR \\d{2}:\\d{2}"); public int chestCount = 0; public int openedChestCount = 0; @@ -48,6 +48,7 @@ public class PowderGrindingOverlay extends TextTabOverlay { public int gemstonePowderFound = 0; public float lastGemstonePowderFound = 0; public float lastGemstonePowderAverage = 0; + public MiningEvent miningEvent = MiningEvent.UNKNOWN; private long lastUpdate = -1; public PowderGrindingOverlay( @@ -58,6 +59,13 @@ public class PowderGrindingOverlay extends TextTabOverlay { super(position, dummyStrings, styleSupplier); } + public enum MiningEvent { + UNKNOWN, + DOUBLE_POWDER, + BETTER_TOGETHER, + GONE_WITH_THE_WIND; + } + private float interp(float now, float last) { float interp = now; if (last >= 0 && last != now) { @@ -80,6 +88,23 @@ public class PowderGrindingOverlay extends TextTabOverlay { lastGemstonePowderAverage = this.openedChestCount > 0 ? 1f * this.gemstonePowderFound / this.openedChestCount : 0; + + Matcher matcher = EVENT_PATTERN.matcher(BossStatus.bossName == null ? "" : Utils.cleanColour(BossStatus.bossName)); + if (matcher.matches()) { + switch (matcher.group(1)) { + case "2X POWDER": + miningEvent = MiningEvent.DOUBLE_POWDER; + break; + case "BETTER TOGETHER": + miningEvent = MiningEvent.BETTER_TOGETHER; + break; + case "GONE WITH THE WIND": + miningEvent = MiningEvent.GONE_WITH_THE_WIND; + break; + default: + miningEvent = MiningEvent.UNKNOWN; + } + } } else overlayStrings = null; } @@ -139,16 +164,16 @@ public class PowderGrindingOverlay extends TextTabOverlay { } else if (message.equals("You have successfully picked the lock on this chest!")) { this.openedChestCount++; } else { - Matcher matcher = pattern.matcher(message); + Matcher matcher = POWDER_PATTERN.matcher(message); if (matcher.matches()) { String rawNumber = matcher.group(1).replace(",", ""); try { int amount = Integer.parseInt(rawNumber); String type = matcher.group(2); if (type.equals("Mithril")) { - this.mithrilPowderFound += amount; + this.mithrilPowderFound += miningEvent == MiningEvent.DOUBLE_POWDER ? amount * 2 : amount; } else if (type.equals("Gemstone")) { - this.gemstonePowderFound += amount; + this.gemstonePowderFound += miningEvent == MiningEvent.DOUBLE_POWDER ? amount * 2 : amount; } } catch (NumberFormatException e) { e.printStackTrace(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/RancherBootOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/RancherBootOverlay.java index 2a30f6f1..22f6eb96 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/RancherBootOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/RancherBootOverlay.java @@ -92,14 +92,7 @@ public class RancherBootOverlay { selectedIndex == i ? 0xff0000ff : 0xff808080 ); Utils.drawItemStack(new ItemStack(Items.carrot), iconsLeft + i * 25 + 2, topY + 25 + 2); - Utils.drawStringCentered( - "" + currentSpeeds.get(i), - Minecraft.getMinecraft().fontRendererObj, - iconsLeft + i * 25 + 10, - topY + 52, - true, - 0xffffffff - ); + Utils.drawStringCentered("" + currentSpeeds.get(i), iconsLeft + i * 25 + 10, topY + 52, true, 0xffffffff); //Minecraft.getMinecraft().fontRendererObj.drawString("\u2710", iconsLeft+i*25+15, topY+40, 0xffffff, false); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java index 90aa2984..1d7126a2 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java @@ -42,6 +42,7 @@ import org.lwjgl.util.vector.Vector2f; import java.time.ZoneId; import java.time.ZonedDateTime; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.function.Supplier; @@ -51,9 +52,6 @@ import java.util.regex.Pattern; import static net.minecraft.util.EnumChatFormatting.DARK_AQUA; public class TimersOverlay extends TextTabOverlay { - private static final Pattern PATTERN_ACTIVE_EFFECTS = Pattern.compile( - "\u00a7r\u00a7r\u00a77You have a \u00a7r\u00a7cGod Potion \u00a7r\u00a77active! \u00a7r\u00a7d([1-5][0-9]|[0-9])[\\s|^\\S]?(Seconds|Second|Minutes|Minute|Hours|Hour|Day|Days|h|m|s) ?([1-5][0-9]|[0-9])?(m|s)?\u00a7r"); - public TimersOverlay( Position position, Supplier<List<String>> dummyStrings, @@ -62,6 +60,8 @@ public class TimersOverlay extends TextTabOverlay { super(position, dummyStrings, styleSupplier); } + private static final Pattern PATTERN_ACTIVE_EFFECTS = Pattern.compile( + "\u00a7r\u00a7r\u00a77You have a \u00a7r\u00a7cGod Potion \u00a7r\u00a77active! \u00a7r\u00a7d([1-5][0-9]|[0-9])[\\s|^\\S]?(Seconds|Second|Minutes|Minute|Hours|Hour|Day|Days|h|m|s) ?([1-5][0-9]|[0-9])?([ms])?\u00a7r"); private static final Pattern CAKE_PATTERN = Pattern.compile( "\u00a7r\u00a7d\u00a7lYum! \u00a7r\u00a7eYou gain .+ \u00a7r\u00a7efor \u00a7r\u00a7a48 \u00a7r\u00a7ehours!\u00a7r"); private static final Pattern PUZZLER_PATTERN = @@ -74,6 +74,8 @@ public class TimersOverlay extends TextTabOverlay { "\u00a7r\u00a79\u1805 \u00a7r\u00a7fYou've earned \u00a7r\u00a72.+ Mithril Powder \u00a7r\u00a7ffrom mining your first Mithril Ore of the day!\u00a7r"); private static final Pattern DAILY_GEMSTONE_POWDER = Pattern.compile( "\u00a7r\u00a79\u1805 \u00a7r\u00a7fYou've earned \u00a7r\u00a7d.+ Gemstone Powder \u00a7r\u00a7ffrom mining your first Gemstone of the day!\u00a7r"); + private static final Pattern DAILY_SHOP_LIMIT = Pattern.compile( + "\u00a7r\u00a7cYou may only buy up to (640|6400) of this item each day!\u00a7r"); @SubscribeEvent(priority = EventPriority.HIGHEST, receiveCanceled = true) public void onChatMessageReceived(ClientChatReceivedEvent event) { @@ -112,6 +114,11 @@ public class TimersOverlay extends TextTabOverlay { Matcher dailyMithrilPowder = DAILY_MITHRIL_POWDER.matcher(event.message.getFormattedText()); if (dailyMithrilPowder.matches()) { hidden.dailyMithrilPowerCompleted = currentTime; + return; + } + Matcher dailyShopLimit = DAILY_SHOP_LIMIT.matcher(event.message.getFormattedText()); + if (dailyShopLimit.matches()) { + hidden.dailyShopLimitCompleted = currentTime; } } } @@ -130,6 +137,7 @@ public class TimersOverlay extends TextTabOverlay { private static final ItemStack EXPERIMENTS_ICON = new ItemStack(Items.enchanted_book); private static final ItemStack COOKIE_ICON = new ItemStack(Items.cookie); private static final ItemStack QUEST_ICON = new ItemStack(Items.sign); + private static final ItemStack SHOP_ICON = new ItemStack(Blocks.hopper); @Override protected void renderLine(String line, Vector2f position, boolean dummy) { @@ -215,6 +223,9 @@ public class TimersOverlay extends TextTabOverlay { case "Crimson Isle Quests": icon = QUEST_ICON; break; + case "NPC Buy Daily Limit": + icon = SHOP_ICON; + break; } if (icon != null) { @@ -251,55 +262,141 @@ public class TimersOverlay extends TextTabOverlay { ContainerChest container = (ContainerChest) chest.inventorySlots; IInventory lower = container.getLowerChestInventory(); String containerName = lower.getDisplayName().getUnformattedText(); - - if (containerName.equals("Commissions") && lower.getSizeInventory() >= 18) { - if (hidden.commissionsCompleted == 0) { - hidden.commissionsCompleted = currentTime; - } - for (int i = 9; i < 18; i++) { - ItemStack stack = lower.getStackInSlot(i); - if (stack != null && stack.hasTagCompound()) { - String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stack.getTagCompound()); - for (String line : lore) { - if (line.contains("(Daily")) { - hidden.commissionsCompleted = 0; - break; + ItemStack stack = lower.getStackInSlot(0); + switch (containerName.intern()) { + case "Commissions": + if (lower.getSizeInventory() < 18) { + break; + } + if (hidden.commissionsCompleted == 0) { + hidden.commissionsCompleted = currentTime + TimeEnums.DAY.time; + } + for (int i = 9; i < 18; i++) { + stack = lower.getStackInSlot(i); + if (stack != null && stack.hasTagCompound()) { + String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stack.getTagCompound()); + for (String line : lore) { + if (line.contains("(Daily")) { + hidden.commissionsCompleted = 0; + break; + } } } } - } - } else if (containerName.equals("Experimentation Table") && lower.getSizeInventory() >= 36) { - ItemStack stack = lower.getStackInSlot(31); - if (stack != null) { - if (stack.getItem() == Items.blaze_powder) { - if (hidden.experimentsCompleted == 0) { + break; + case "Experimentation Table": + if (lower.getSizeInventory() < 36) { + break; + } + stack = lower.getStackInSlot(31); + if (stack != null) { + if (stack.getItem() == Items.blaze_powder) { + if (hidden.experimentsCompleted == 0) { + hidden.experimentsCompleted = currentTime; + return; + } + } + } + ItemStack stackSuperPairs = lower.getStackInSlot(22); + if (stackSuperPairs != null && stackSuperPairs.getItem() == Items.skull && + stackSuperPairs.getTagCompound() != null) { + String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stackSuperPairs.getTagCompound()); + String text = lore[lore.length - 1]; + String cleanText = Utils.cleanColour(text); + if (cleanText.equals("Experiments on cooldown!")) { hidden.experimentsCompleted = currentTime; return; } } - } - ItemStack stackSuperPairs = lower.getStackInSlot(22); - if (stackSuperPairs != null && stackSuperPairs.getItem() == Items.skull && - stackSuperPairs.getTagCompound() != null) { - String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stackSuperPairs.getTagCompound()); - String text = lore[lore.length - 1]; - String cleanText = Utils.cleanColour(text); - if (cleanText.equals("Experiments on cooldown!")) { + hidden.experimentsCompleted = 0; + break; + case "Superpairs Rewards": + if (lower.getSizeInventory() < 27) { + break; + } + stack = lower.getStackInSlot(13); + if (stack != null && Utils.cleanColour(stack.getDisplayName()).equals("Superpairs")) { hidden.experimentsCompleted = currentTime; - return; } - } - hidden.experimentsCompleted = 0; - return; - } else if (containerName.equals("Superpairs Rewards") && lower.getSizeInventory() >= 27) { - ItemStack stack = lower.getStackInSlot(13); - if (stack != null && Utils.cleanColour(stack.getDisplayName()).equals("Superpairs")) { - hidden.experimentsCompleted = currentTime; - } + case "SkyBlock Menu": + if (lower.getSizeInventory() < 54) { + break; + } + stack = lower.getStackInSlot(51); + case "Booster Cookie": + if (lower.getSizeInventory() < 54) { + break; + } + if (stack != lower.getStackInSlot(51)) {//if we didn't go into this case from the skyblock menu + stack = lower.getStackInSlot(13); + } + + if (stack != null && Utils.cleanColour(stack.getDisplayName()).equals("Booster Cookie") && + stack.getTagCompound() != null) { + String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stack.getTagCompound()); + for (String line : lore) { + if (line.contains("Duration: ")) { + String clean = line.replaceAll("(\u00a7.)", ""); + clean = clean.replaceAll("(\\d)([smhdy])", "$1 $2"); + String[] cleanSplit = clean.split(" "); + String[] removeDuration = Arrays.copyOfRange(cleanSplit, 1, cleanSplit.length); + hidden.cookieBuffRemaining = currentTime; + for (int i = 0; i + 1 < removeDuration.length; i++) { + if (i % 2 == 1) continue; + + String number = removeDuration[i]; + String unit = removeDuration[i + 1]; + try { + long val = Integer.parseInt(number); + switch (unit) { + case "Years": + case "Year": + hidden.cookieBuffRemaining += val * 365 * 24 * 60 * 60 * 1000; + break; + case "Months": + case "Month": + hidden.cookieBuffRemaining += val * 30 * 24 * 60 * 60 * 1000; + break; + case "Days": + case "Day": + case "d": + hidden.cookieBuffRemaining += val * 24 * 60 * 60 * 1000; + break; + case "Hours": + case "Hour": + case "h": + hidden.cookieBuffRemaining += val * 60 * 60 * 1000; + break; + case "Minutes": + case "Minute": + case "m": + hidden.cookieBuffRemaining += val * 60 * 1000; + break; + case "Seconds": + case "Second": + case "s": + hidden.cookieBuffRemaining += val * 1000; + break; + } + } catch (NumberFormatException e) { + e.printStackTrace(); + hidden.cookieBuffRemaining = 0; + if (!hasErrorMessage) { + Utils.addChatMessage( + EnumChatFormatting.YELLOW + "[NEU] Unable to work out your cookie buff timer"); + hasErrorMessage = true; + } + break; + } + } + break; + } + } + } + break; } } - boolean foundCookieBuffText = false; boolean foundGodPotText = false; boolean foundEffectsText = false; if (SBInfo.getInstance().getLocation() != null && !SBInfo.getInstance().getLocation().equals("dungeon") && @@ -354,63 +451,6 @@ public class TimersOverlay extends TextTabOverlay { hidden.godPotionDuration = godPotDuration; - } else if (line.contains("\u00a7d\u00a7lCookie Buff")) { - foundCookieBuffText = true; - } else if (foundCookieBuffText) { - String clean = line.replaceAll("(\u00a7.)", ""); - clean = clean.replaceAll("(\\d)([smhdy])", "$1 $2"); - String[] cleanSplit = clean.split(" "); - hidden.cookieBuffRemaining = 0; - if (line.contains("Not")) break; - - for (int i = 0; i + 1 < cleanSplit.length; i++) { - if (i % 2 == 1) continue; - - String number = cleanSplit[i]; - String unit = cleanSplit[i + 1]; - try { - long val = Integer.parseInt(number); - switch (unit) { - case "Years": - case "Year": - hidden.cookieBuffRemaining += val * 365 * 24 * 60 * 60 * 1000; - break; - case "Months": - case "Month": - hidden.cookieBuffRemaining += val * 30 * 24 * 60 * 60 * 1000; - break; - case "Days": - case "Day": - hidden.cookieBuffRemaining += val * 24 * 60 * 60 * 1000; - break; - case "Hours": - case "Hour": - case "h": - hidden.cookieBuffRemaining += val * 60 * 60 * 1000; - break; - case "Minutes": - case "Minute": - case "m": - hidden.cookieBuffRemaining += val * 60 * 1000; - break; - case "Seconds": - case "Second": - case "s": - hidden.cookieBuffRemaining += val * 1000; - break; - } - } catch (NumberFormatException e) { - e.printStackTrace(); - hidden.cookieBuffRemaining = 0; - if (!hasErrorMessage) { - Utils.addChatMessage(EnumChatFormatting.YELLOW + "[NEU] Unable to work out your cookie buff timer"); - hasErrorMessage = true; - } - break; - } - } - - break; } } } @@ -484,7 +524,7 @@ public class TimersOverlay extends TextTabOverlay { 1, DARK_AQUA + "Cookie Buff: " + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.verySoonColour] + - Utils.prettyTime(hidden.cookieBuffRemaining) + Utils.prettyTime(hidden.cookieBuffRemaining - currentTime) ); } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.cookieBuffDisplay >= DISPLAYTYPE.SOON.ordinal() && hidden.cookieBuffRemaining < TimeEnums.HALFDAY.time) { @@ -492,7 +532,7 @@ public class TimersOverlay extends TextTabOverlay { 1, DARK_AQUA + "Cookie Buff: " + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.soonColour] + - Utils.prettyTime(hidden.cookieBuffRemaining) + Utils.prettyTime(hidden.cookieBuffRemaining - currentTime) ); } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.cookieBuffDisplay >= DISPLAYTYPE.KINDASOON.ordinal() && hidden.cookieBuffRemaining < TimeEnums.DAY.time) { @@ -500,14 +540,14 @@ public class TimersOverlay extends TextTabOverlay { 1, DARK_AQUA + "Cookie Buff: " + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.kindaSoonColour] + - Utils.prettyTime(hidden.cookieBuffRemaining) + Utils.prettyTime(hidden.cookieBuffRemaining - currentTime) ); } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.cookieBuffDisplay >= DISPLAYTYPE.ALWAYS.ordinal()) { map.put( 1, DARK_AQUA + "Cookie Buff: " + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.defaultColour] + - Utils.prettyTime(hidden.cookieBuffRemaining) + Utils.prettyTime(hidden.cookieBuffRemaining - currentTime) ); } @@ -595,11 +635,11 @@ public class TimersOverlay extends TextTabOverlay { ); } - long midnightReset = (currentTime - 18000000) / 86400000 * 86400000 + 18000000; // 12am est + long midnightReset = (currentTime - 18000000) / TimeEnums.DAY.time * TimeEnums.DAY.time + 18000000; // 12am est long pearlsReset = midnightReset - 18000000; //8pm est - long catacombsReset = currentTime / 86400000 * 86400000; // 7pm est - long timeDiffMidnightNow = midnightReset + 86400000 - currentTime; - long catacombsDiffNow = catacombsReset + 86400000 - currentTime; + long catacombsReset = currentTime / TimeEnums.DAY.time * TimeEnums.DAY.time; // 7pm est + long timeDiffMidnightNow = midnightReset + TimeEnums.DAY.time - currentTime; + long catacombsDiffNow = catacombsReset + TimeEnums.DAY.time - currentTime; long fetchurComplete = hidden.fetchurCompleted; //Fetchur Display @@ -647,7 +687,7 @@ public class TimersOverlay extends TextTabOverlay { map.put( 5, DARK_AQUA + "Commissions: " + - EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.readyColour] + "Ready!" + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.readyColour] + "Ready! " ); } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.commissionDisplay >= DISPLAYTYPE.VERYSOON.ordinal() && (hidden.commissionsCompleted < (midnightReset - TimeEnums.HALFANHOUR.time))) { @@ -683,49 +723,47 @@ public class TimersOverlay extends TextTabOverlay { } //Experiment Display - if (hidden.experimentsCompleted < midnightReset) { + if (hidden.experimentsCompleted < catacombsReset) { map.put( 6, DARK_AQUA + "Experiments: " + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.readyColour] + "Ready!" ); } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.experimentationDisplay >= DISPLAYTYPE.VERYSOON.ordinal() && - (hidden.experimentsCompleted < (midnightReset - TimeEnums.HALFANHOUR.time))) { + (hidden.experimentsCompleted < (catacombsReset - TimeEnums.HALFANHOUR.time))) { map.put( 6, DARK_AQUA + "Experiments: " + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.verySoonColour] + - Utils.prettyTime(catacombsReset + 86400000 - currentTime) + Utils.prettyTime(catacombsDiffNow) ); } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.experimentationDisplay >= DISPLAYTYPE.SOON.ordinal() && - (hidden.experimentsCompleted < (midnightReset - TimeEnums.HOUR.time))) { + (hidden.experimentsCompleted < (catacombsReset - TimeEnums.HOUR.time))) { map.put( 6, DARK_AQUA + "Experiments: " + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.soonColour] + - Utils.prettyTime(catacombsReset + 86400000 - currentTime) + Utils.prettyTime(catacombsDiffNow) ); } else if ( NotEnoughUpdates.INSTANCE.config.miscOverlays.experimentationDisplay >= DISPLAYTYPE.KINDASOON.ordinal() && - (hidden.experimentsCompleted < (midnightReset - (TimeEnums.HOUR.time * 3)))) { + (hidden.experimentsCompleted < (catacombsReset - (TimeEnums.HOUR.time * 3)))) { map.put( 6, DARK_AQUA + "Experiments: " + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.kindaSoonColour] + - Utils.prettyTime(catacombsReset + 86400000 - currentTime) + Utils.prettyTime(catacombsDiffNow) ); } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.experimentationDisplay >= DISPLAYTYPE.ALWAYS.ordinal()) { map.put( 6, DARK_AQUA + "Experiments: " + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.defaultColour] + - Utils.prettyTime(catacombsReset + 86400000 - currentTime) + Utils.prettyTime(catacombsDiffNow) ); } // Daily Mithril Powder display - long mithrilPowderCompleted = hidden.dailyMithrilPowerCompleted + 1000 * 60 * 60 * 24 - currentTime; - if (hidden.dailyMithrilPowerCompleted < catacombsReset) { map.put( 7, @@ -853,12 +891,13 @@ public class TimersOverlay extends TextTabOverlay { Utils.prettyTime(pearlsReset + 86400000 - currentTime) ); } - + //Daily Crimson Isle Quests if (hidden.questBoardCompleted < midnightReset) { map.put( 10, DARK_AQUA + "Crimson Isle Quests: " + - EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.readyColour] + "Ready!" + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.readyColour] + + (5 - SBInfo.getInstance().completedQuests.size()) + " left!" ); } else if ( NotEnoughUpdates.INSTANCE.config.miscOverlays.questBoardDisplay >= DISPLAYTYPE.VERYSOON.ordinal() && @@ -895,6 +934,48 @@ public class TimersOverlay extends TextTabOverlay { ); } + //Daily Shop Limit + if (hidden.dailyShopLimitCompleted < catacombsReset) { + map.put( + 11, + DARK_AQUA + "NPC Buy Daily Limit: " + + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.readyColour] + "Ready!" + ); + } else if ( + NotEnoughUpdates.INSTANCE.config.miscOverlays.shopLimitDisplay >= DISPLAYTYPE.VERYSOON.ordinal() && + (hidden.dailyShopLimitCompleted < (catacombsReset - TimeEnums.HALFANHOUR.time))) { + map.put( + 11, + DARK_AQUA + "NPC Buy Daily Limit: " + + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.verySoonColour] + + Utils.prettyTime(catacombsDiffNow) + ); + } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.shopLimitDisplay >= DISPLAYTYPE.SOON.ordinal() && + (hidden.dailyShopLimitCompleted < (catacombsReset - TimeEnums.HOUR.time))) { + map.put( + 11, + DARK_AQUA + "NPC Buy Daily Limit: " + + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.soonColour] + + Utils.prettyTime(catacombsDiffNow) + ); + } else if ( + NotEnoughUpdates.INSTANCE.config.miscOverlays.shopLimitDisplay >= DISPLAYTYPE.KINDASOON.ordinal() && + (hidden.dailyShopLimitCompleted < (catacombsReset - (TimeEnums.HOUR.time * 3)))) { + map.put( + 11, + DARK_AQUA + "NPC Buy Daily Limit: " + + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.kindaSoonColour] + + Utils.prettyTime(catacombsDiffNow) + ); + } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.shopLimitDisplay >= DISPLAYTYPE.ALWAYS.ordinal()) { + map.put( + 11, + DARK_AQUA + "NPC Buy Daily Limit: " + + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.defaultColour] + + Utils.prettyTime(catacombsDiffNow) + ); + } + overlayStrings = new ArrayList<>(); for (int index : NotEnoughUpdates.INSTANCE.config.miscOverlays.todoText2) { if (map.containsKey(index)) { @@ -944,7 +1025,7 @@ public class TimersOverlay extends TextTabOverlay { } public static void processActionBar(String msg) { - if (SBInfo.getInstance().location.equals("Belly of the Beast")) { + if (SBInfo.getInstance().location.equals("Belly of the Beast") && msg.contains("Pearls Collected")) { try { msg = Utils.cleanColour(msg); msg = msg.substring(msg.indexOf("Pearls Collected: ") + 18); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java index 265177fc..266722e5 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BasicPage.java @@ -313,17 +313,19 @@ public class BasicPage extends GuiProfileViewerPage { } else if (networth == -1) { networth = profile.getNetWorth(profileId); } - + int fontWidth = fr.getStringWidth("Net Worth: " + GuiProfileViewer.numberFormat.format(networth)); + int offset = (fontWidth >= 117 ? 63 + (fontWidth - 117) : 63); if (networth > 0) { - Utils.drawStringCentered( - EnumChatFormatting.GREEN + "Net Worth: " + EnumChatFormatting.GOLD + - GuiProfileViewer.numberFormat.format(networth), - fr, - guiLeft + 165, - guiTop + 38, - true, - 0 - ); + if (fontWidth >= 117) { + fr.drawString(EnumChatFormatting.GREEN + "Net Worth: " + EnumChatFormatting.GOLD + + GuiProfileViewer.numberFormat.format(networth), guiLeft + 8, guiTop + 38 - fr.FONT_HEIGHT / 2f, 0, true); + } else { + Utils.drawStringCentered( + EnumChatFormatting.GREEN + "Net Worth: " + EnumChatFormatting.GOLD + + GuiProfileViewer.numberFormat.format(networth), + guiLeft + 68, guiTop + 38, true, 0 + ); + } if (NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarInfo("BOOSTER_COOKIE") != null && NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarInfo("BOOSTER_COOKIE").has("avg_buy")) { double networthInCookies = @@ -337,8 +339,8 @@ public class BasicPage extends GuiProfileViewerPage { String networthIRLMoney = GuiProfileViewer.numberFormat.format(Math.round( ((networthInCookies * 325) / 675) * 4.99)); - int fontWidth = fr.getStringWidth("Net Worth: " + GuiProfileViewer.numberFormat.format(networth)); - if (mouseX > guiLeft + 165 - fontWidth / 2 && mouseX < guiLeft + 165 + fontWidth / 2) { + + if (mouseX > guiLeft + offset - fontWidth / 2 && mouseX < guiLeft + offset + fontWidth / 2) { if (mouseY > guiTop + 32 && mouseY < guiTop + 38 + fr.FONT_HEIGHT) { getInstance().tooltipToDisplay = new ArrayList<>(); getInstance() @@ -384,14 +386,17 @@ public class BasicPage extends GuiProfileViewerPage { } } } else { - Utils.drawStringCentered( - EnumChatFormatting.GREEN + "Net Worth: " + stateStr, - fr, - guiLeft + 165, - guiTop + 38, - true, - 0 - ); + int errFontWidth = fr.getStringWidth("Net Worth: " + stateStr); + if (errFontWidth >= 117) { + fr.drawString(EnumChatFormatting.GREEN + "Net Worth: " + stateStr, + guiLeft + 8, guiTop + 38 - fr.FONT_HEIGHT / 2f, 0, true + ); + } else { + Utils.drawStringCentered( + EnumChatFormatting.GREEN + "Net Worth: " + stateStr, + guiLeft + 63, guiTop + 38, true, 0 + ); + } } if (status != null) { @@ -425,7 +430,7 @@ public class BasicPage extends GuiProfileViewerPage { statusStr += EnumChatFormatting.GRAY + " - " + EnumChatFormatting.GREEN + locationStr; } - Utils.drawStringCentered(statusStr, fr, guiLeft + 63, guiTop + 160, true, 0); + Utils.drawStringCentered(statusStr, guiLeft + 63, guiTop + 160, true, 0); } if (entityPlayer == null) { @@ -585,14 +590,14 @@ public class BasicPage extends GuiProfileViewerPage { GlStateManager.scale(1.5f, 1.5f, 1); Utils.drawItemStack(skull, 0, 0); GlStateManager.popMatrix(); - Utils.drawStringCenteredScaled(skyblockLevelColour.toString() + (int) skyblockLevel, fr, + Utils.drawStringCenteredScaled(skyblockLevelColour.toString() + (int) skyblockLevel, sbLevelX + 9, sbLevelY - 12, true, 1.5f ); float progress = (float) (skyblockLevel - (long) skyblockLevel); getInstance().renderBar(sbLevelX - 30, sbLevelY + 30, 80, progress); - Utils.drawStringScaled(EnumChatFormatting.YELLOW.toString() + (int) (progress * 100) + "/100", fr, + Utils.drawStringScaled(EnumChatFormatting.YELLOW.toString() + (int) (progress * 100) + "/100", sbLevelX - 30, sbLevelY + 20, true, 0, 0.9f ); @@ -708,11 +713,7 @@ public class BasicPage extends GuiProfileViewerPage { } else { Utils.drawStringCentered( EnumChatFormatting.RED + "Skills API not enabled!", - Minecraft.getMinecraft().fontRendererObj, - guiLeft + 322, - guiTop + 101, - true, - 0 + guiLeft + 322, guiTop + 101, true, 0 ); } @@ -793,18 +794,14 @@ public class BasicPage extends GuiProfileViewerPage { "Senither Weight: " + EnumChatFormatting.GOLD + GuiProfileViewer.numberFormat.format(roundToNearestInt(senitherWeight.getTotalWeight().getRaw())), - fr, - guiLeft + 165, - guiTop + 18, - true, - 0 + guiLeft + 63, guiTop + 18, true, 0 ); int textWidth = fr.getStringWidth( "Senither Weight: " + GuiProfileViewer.numberFormat.format(roundToNearestInt(senitherWeight.getTotalWeight().getRaw())) ); - if (mouseX > guiLeft + 165 - textWidth / 2 && mouseX < guiLeft + 165 + textWidth / 2) { + if (mouseX > guiLeft + 63 - textWidth / 2 && mouseX < guiLeft + 63 + textWidth / 2) { if (mouseY > guiTop + 12 && mouseY < guiTop + 12 + fr.FONT_HEIGHT) { getInstance().tooltipToDisplay = new ArrayList<>(); getInstance() @@ -858,20 +855,15 @@ public class BasicPage extends GuiProfileViewerPage { Utils.drawStringCentered( EnumChatFormatting.GREEN + - "Lily Weight: " + - EnumChatFormatting.GOLD + + "Lily Weight: " + EnumChatFormatting.GOLD + GuiProfileViewer.numberFormat.format(roundToNearestInt(lilyWeight.getTotalWeight().getRaw())), - fr, - guiLeft + 165, - guiTop + 28, - true, - 0 + guiLeft + 63, guiTop + 28, true, 0 ); int fontWidth = fr.getStringWidth( "Lily Weight: " + GuiProfileViewer.numberFormat.format(roundToNearestInt(lilyWeight.getTotalWeight().getRaw())) ); - if (mouseX > guiLeft + 165 - fontWidth / 2 && mouseX < guiLeft + 165 + fontWidth / 2) { + if (mouseX > guiLeft + 63 - fontWidth / 2 && mouseX < guiLeft + 63 + fontWidth / 2) { if (mouseY > guiTop + 22 && mouseY < guiTop + 22 + fr.FONT_HEIGHT) { getInstance().tooltipToDisplay = new ArrayList<>(); getInstance() diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BingoPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BingoPage.java index ab80afab..cc5fc92f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BingoPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BingoPage.java @@ -126,15 +126,7 @@ public class BingoPage extends GuiProfileViewerPage { y = communityGoal ? y - 1 : y; if (mouseX >= x && mouseX < x + 24) { if (mouseY >= y && mouseY <= y + 24) { - Utils.drawHoveringText( - getTooltip(bingoGoal, completed, communityGoal), - mouseX, - mouseY, - width, - height, - -1, - Minecraft.getMinecraft().fontRendererObj - ); + Utils.drawHoveringText(getTooltip(bingoGoal, completed, communityGoal), mouseX, mouseY, width, height, -1); } } col++; @@ -161,15 +153,8 @@ public class BingoPage extends GuiProfileViewerPage { EnumChatFormatting.WHITE + 20; } - Utils.drawStringF(totalPointsString, Minecraft.getMinecraft().fontRendererObj, guiLeft + 22, guiTop + 19, true, 0); - Utils.drawStringF( - personalGoalsString, - Minecraft.getMinecraft().fontRendererObj, - guiLeft + 22, - guiTop + 31, - true, - 0 - ); + Utils.drawStringF(totalPointsString, guiLeft + 22, guiTop + 19, true, 0); + Utils.drawStringF(personalGoalsString, guiLeft + 22, guiTop + 31, true, 0); GlStateManager.enableLighting(); } @@ -299,14 +284,7 @@ public class BingoPage extends GuiProfileViewerPage { private void showMissingDataMessage(int guiLeft, int guiTop) { String message = EnumChatFormatting.RED + "No Bingo data for current event!"; - Utils.drawStringCentered( - message, - Minecraft.getMinecraft().fontRendererObj, - guiLeft + 431 / 2f, - guiTop + 101, - true, - 0 - ); + Utils.drawStringCentered(message, guiLeft + 431 / 2f, guiTop + 101, true, 0); } private List<String> jsonArrayToStringList(JsonArray completedGoals) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/CollectionsPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/CollectionsPage.java index 45d9370b..03be7cf1 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/CollectionsPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/CollectionsPage.java @@ -36,9 +36,7 @@ import org.lwjgl.opengl.GL11; import java.awt.*; import java.io.IOException; -import java.math.BigDecimal; import java.math.BigInteger; -import java.math.RoundingMode; import java.text.NumberFormat; import java.util.ArrayList; import java.util.Iterator; @@ -96,11 +94,7 @@ public class CollectionsPage extends GuiProfileViewerPage { if (collectionInfo == null) { Utils.drawStringCentered( EnumChatFormatting.RED + "Collection API not enabled!", - Minecraft.getMinecraft().fontRendererObj, - guiLeft + 134, - guiTop + 101, - true, - 0 + guiLeft + 134, guiTop + 101, true, 0 ); return; } @@ -195,11 +189,7 @@ public class CollectionsPage extends GuiProfileViewerPage { Utils.drawStringCentered( selectedCollectionCategory.getDisplayName() + " Collections", - Minecraft.getMinecraft().fontRendererObj, - guiLeft + 134, - guiTop + 14, - true, - 4210752 + guiLeft + 134, guiTop + 14, true, 4210752 ); if (collections != null) { @@ -292,35 +282,16 @@ public class CollectionsPage extends GuiProfileViewerPage { GlStateManager.color(1, 1, 1, 1); if (tier >= 0) { - Utils.drawStringCentered( - tierString, - Minecraft.getMinecraft().fontRendererObj, - guiLeft + x + 10, - guiTop + y - 4, - true, - tierStringColour - ); + Utils.drawStringCentered(tierString, guiLeft + x + 10, guiTop + y - 4, true, tierStringColour); } Utils.drawStringCentered( - StringUtils.shortNumberFormat(amount) + "", - Minecraft.getMinecraft().fontRendererObj, - guiLeft + x + 10, - guiTop + y + 26, - true, - color.getRGB() - ); + StringUtils.shortNumberFormat(amount) + "", guiLeft + x + 10, guiTop + y + 26, true, color.getRGB()); } } Utils.drawStringCentered( - selectedCollectionCategory.getDisplayName() + " Minions", - Minecraft.getMinecraft().fontRendererObj, - guiLeft + 326, - guiTop + 14, - true, - 4210752 - ); + selectedCollectionCategory.getDisplayName() + " Minions", guiLeft + 326, guiTop + 14, true, 4210752); if (minions != null) { for (int i = page * 20, j = 0; i < Math.min((page + 1) * 20, minions.size()); i++, j++) { @@ -409,14 +380,7 @@ public class CollectionsPage extends GuiProfileViewerPage { GlStateManager.color(1, 1, 1, 1); if (tier >= 0) { - Utils.drawStringCentered( - tierString, - Minecraft.getMinecraft().fontRendererObj, - guiLeft + x + 10, - guiTop + y - 4, - true, - tierStringColour - ); + Utils.drawStringCentered(tierString, guiLeft + x + 10, guiTop + y - 4, true, tierStringColour); } } } @@ -426,15 +390,7 @@ public class CollectionsPage extends GuiProfileViewerPage { for (String line : tooltipToDisplay) { grayTooltip.add(EnumChatFormatting.GRAY + line); } - Utils.drawHoveringText( - grayTooltip, - mouseX, - mouseY, - getInstance().width, - getInstance().height, - -1, - Minecraft.getMinecraft().fontRendererObj - ); + Utils.drawHoveringText(grayTooltip, mouseX, mouseY, getInstance().width, getInstance().height, -1); tooltipToDisplay = null; } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/CrimsonIslePage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/CrimsonIslePage.java index 6460003a..454ad989 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/CrimsonIslePage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/CrimsonIslePage.java @@ -109,11 +109,7 @@ public class CrimsonIslePage extends GuiProfileViewerPage { if (profileInfo == null || !profileInfo.has("nether_island_player_data")) { Utils.drawStringCentered( EnumChatFormatting.RED + "No data found for the Crimson Isles", - Minecraft.getMinecraft().fontRendererObj, - guiLeft + 431 / 2f, - guiTop + 101, - true, - 0 + guiLeft + 431 / 2f, guiTop + 101, true, 0 ); return; } @@ -137,14 +133,7 @@ public class CrimsonIslePage extends GuiProfileViewerPage { } public void drawKuudraStats(JsonObject data, int guiLeft, int guiTop, int mouseX, int mouseY) { - Utils.drawStringCentered( - EnumChatFormatting.RED + "Kuudra Stats", - Minecraft.getMinecraft().fontRendererObj, - guiLeft + (431 * 0.18f), - guiTop + 14, - true, - 0 - ); + Utils.drawStringCentered(EnumChatFormatting.RED + "Kuudra Stats", guiLeft + (431 * 0.18f), guiTop + 14, true, 0); JsonObject kuudraCompletedTiers = data.getAsJsonObject("kuudra_completed_tiers"); @@ -213,14 +202,7 @@ public class CrimsonIslePage extends GuiProfileViewerPage { } public void drawDojoStats(JsonObject data, int guiLeft, int guiTop) { - Utils.drawStringCentered( - EnumChatFormatting.YELLOW + "Dojo Stats", - Minecraft.getMinecraft().fontRendererObj, - guiLeft + (431 * 0.49f), - guiTop + 14, - true, - 0 - ); + Utils.drawStringCentered(EnumChatFormatting.YELLOW + "Dojo Stats", guiLeft + (431 * 0.49f), guiTop + 14, true, 0); JsonObject dojoStats = data.getAsJsonObject("dojo"); int[] dojoScores = {0, 0, 0, 0, 0, 0, 0}; @@ -298,11 +280,7 @@ public class CrimsonIslePage extends GuiProfileViewerPage { public void drawLastMatriarchAttempt(JsonObject data, int guiLeft, int guiTop) { Utils.drawStringCentered( EnumChatFormatting.GOLD + "Last Matriarch Attempt", - Minecraft.getMinecraft().fontRendererObj, - guiLeft + (431 * 0.82f), - guiTop + 104, - true, - 0 + guiLeft + (431 * 0.82f), guiTop + 104, true, 0 ); JsonObject lastMatriarchAttempt = data.getAsJsonObject("matriarch"); @@ -351,11 +329,7 @@ public class CrimsonIslePage extends GuiProfileViewerPage { public void drawFactionReputation(JsonObject data, int guiLeft, int guiTop) { Utils.drawStringCentered( EnumChatFormatting.DARK_PURPLE + "Faction Reputation", - Minecraft.getMinecraft().fontRendererObj, - guiLeft + (431 * 0.82f), - guiTop + 14, - true, - 0 + guiLeft + (431 * 0.82f), guiTop + 14, true, 0 ); String selectedFaction = data.has("selected_faction") ? data.get("selected_faction").getAsString() : "N/A"; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java index c379c7eb..a5229acb 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java @@ -329,7 +329,6 @@ public class GuiProfileViewer extends GuiScreen { Utils.drawTexturedRect(guiLeft, guiTop + sizeY + 3, 100, 20, 0, 100 / 200f, 0, 20 / 185f, GL11.GL_NEAREST); Utils.drawStringCenteredScaledMaxWidth( profileId, - Minecraft.getMinecraft().fontRendererObj, guiLeft + 50, guiTop + sizeY + 3 + 10, true, @@ -394,7 +393,6 @@ public class GuiProfileViewer extends GuiScreen { ); Utils.drawStringCenteredScaledMaxWidth( "Open in SkyCrypt", - Minecraft.getMinecraft().fontRendererObj, guiLeft + 50 + 100 + 6, guiTop + sizeY + 3 + 10, true, @@ -437,7 +435,6 @@ public class GuiProfileViewer extends GuiScreen { String otherProfileId = profile.getProfileNames().get(yIndex); Utils.drawStringCenteredScaledMaxWidth( otherProfileId, - Minecraft.getMinecraft().fontRendererObj, guiLeft + 50, guiTop + sizeY + 23 + dropdownOptionSize / 2f + dropdownOptionSize * yIndex, true, @@ -529,14 +526,7 @@ public class GuiProfileViewer extends GuiScreen { } } - Utils.drawStringCentered( - str, - Minecraft.getMinecraft().fontRendererObj, - guiLeft + sizeX / 2f, - guiTop + 101, - true, - 0 - ); + Utils.drawStringCentered(str, guiLeft + sizeX / 2f, guiTop + 101, true, 0); //This is just here to inform the player what to do //like typing /api new or telling them to go find a psychotherapist @@ -545,37 +535,21 @@ public class GuiProfileViewer extends GuiScreen { if (timeDiff > 20000) { Utils.drawStringCentered( EnumChatFormatting.YELLOW + "Its taking a while...", - Minecraft.getMinecraft().fontRendererObj, - guiLeft + sizeX / 2f, - guiTop + 111, - true, - 0 + guiLeft + sizeX / 2f, guiTop + 111, true, 0 ); Utils.drawStringCentered( EnumChatFormatting.YELLOW + "Try \"/api new\".", - Minecraft.getMinecraft().fontRendererObj, - guiLeft + sizeX / 2f, - guiTop + 121, - true, - 0 + guiLeft + sizeX / 2f, guiTop + 121, true, 0 ); if (timeDiff > 60000) { Utils.drawStringCentered( EnumChatFormatting.YELLOW + "Might be hypixel's fault.", - Minecraft.getMinecraft().fontRendererObj, - guiLeft + sizeX / 2f, - guiTop + 131, - true, - 0 + guiLeft + sizeX / 2f, guiTop + 131, true, 0 ); if (timeDiff > 180000) { Utils.drawStringCentered( EnumChatFormatting.YELLOW + "Wow you're still here?", - Minecraft.getMinecraft().fontRendererObj, - guiLeft + sizeX / 2f, - guiTop + 141, - true, - 0 + guiLeft + sizeX / 2f, guiTop + 141, true, 0 ); if (timeDiff > 360000) { long second = (timeDiff / 1000) % 60; @@ -585,58 +559,32 @@ public class GuiProfileViewer extends GuiScreen { String time = String.format("%02d:%02d:%02d", hour, minute, second); Utils.drawStringCentered( EnumChatFormatting.YELLOW + "You've wasted your time here for: " + time, - Minecraft.getMinecraft().fontRendererObj, - guiLeft + sizeX / 2f, - guiTop + 151, - true, - 0 + guiLeft + sizeX / 2f, guiTop + 151, true, 0 ); Utils.drawStringCentered( EnumChatFormatting.YELLOW + "" + EnumChatFormatting.BOLD + "What are you doing with your life?", - Minecraft.getMinecraft().fontRendererObj, - guiLeft + sizeX / 2f, - guiTop + 161, - true, - 0 + guiLeft + sizeX / 2f, guiTop + 161, true, 0 ); if (timeDiff > 600000) { Utils.drawStringCentered( EnumChatFormatting.RED + "" + EnumChatFormatting.BOLD + "Maniac", - Minecraft.getMinecraft().fontRendererObj, - guiLeft + sizeX / 2f, - guiTop + 171, - true, - 0 + guiLeft + sizeX / 2f, guiTop + 171, true, 0 ); if (timeDiff > 1200000) { Utils.drawStringCentered( EnumChatFormatting.RED + "" + EnumChatFormatting.BOLD + "You're a menace to society", - Minecraft.getMinecraft().fontRendererObj, - guiLeft + sizeX / 2f, - guiTop + 181, - true, - 0 + guiLeft + sizeX / 2f, guiTop + 181, true, 0 ); if (timeDiff > 1800000) { Utils.drawStringCentered( - EnumChatFormatting.RED + - "" + - EnumChatFormatting.BOLD + + EnumChatFormatting.RED + "" + EnumChatFormatting.BOLD + "You don't know what's gonna happen to you", - Minecraft.getMinecraft().fontRendererObj, - guiLeft + sizeX / 2f, - guiTop + 191, - true, - 0 + guiLeft + sizeX / 2f, guiTop + 191, true, 0 ); if (timeDiff > 3000000) { Utils.drawStringCentered( EnumChatFormatting.RED + "" + EnumChatFormatting.BOLD + "You really want this?", - Minecraft.getMinecraft().fontRendererObj, - guiLeft + sizeX / 2f, - guiTop + 91, - true, - 0 + guiLeft + sizeX / 2f, guiTop + 91, true, 0 ); if (timeDiff > 3300000) { Utils.drawStringCentered( @@ -644,11 +592,7 @@ public class GuiProfileViewer extends GuiScreen { "" + EnumChatFormatting.BOLD + "OW LORD FORGIVE ME FOR THIS", - Minecraft.getMinecraft().fontRendererObj, - guiLeft + sizeX / 2f, - guiTop + 71, - true, - 0 + guiLeft + sizeX / 2f, guiTop + 71, true, 0 ); if (timeDiff > 3600000) { throw new Error("Go do something productive") { @@ -672,21 +616,13 @@ public class GuiProfileViewer extends GuiScreen { case INVALID_NAME: Utils.drawStringCentered( EnumChatFormatting.RED + "Invalid name or API is down!", - Minecraft.getMinecraft().fontRendererObj, - guiLeft + sizeX / 2f, - guiTop + 101, - true, - 0 + guiLeft + sizeX / 2f, guiTop + 101, true, 0 ); break; case NO_SKYBLOCK: Utils.drawStringCentered( EnumChatFormatting.RED + "No SkyBlock data found!", - Minecraft.getMinecraft().fontRendererObj, - guiLeft + sizeX / 2f, - guiTop + 101, - true, - 0 + guiLeft + sizeX / 2f, guiTop + 101, true, 0 ); break; } @@ -727,7 +663,7 @@ public class GuiProfileViewer extends GuiScreen { for (String line : tooltipToDisplay) { grayTooltip.add(EnumChatFormatting.GRAY + line); } - Utils.drawHoveringText(grayTooltip, mouseX, mouseY, width, height, -1, Minecraft.getMinecraft().fontRendererObj); + Utils.drawHoveringText(grayTooltip, mouseX, mouseY, width, height, -1); tooltipToDisplay = null; } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/InventoriesPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/InventoriesPage.java index 164f5d78..29f84a5b 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/InventoriesPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/InventoriesPage.java @@ -350,21 +350,10 @@ public class InventoriesPage extends GuiProfileViewerPage { strToRender = "Inventory API not enabled"; Utils.drawStringCentered( EnumChatFormatting.RED + "Or has no backpacks!", - Minecraft.getMinecraft().fontRendererObj, - guiLeft + 317, - guiTop + 112, - true, - 0 + guiLeft + 317, guiTop + 112, true, 0 ); } - Utils.drawStringCentered( - EnumChatFormatting.RED + strToRender, - Minecraft.getMinecraft().fontRendererObj, - guiLeft + 317, - guiTop + 101, - true, - 0 - ); + Utils.drawStringCentered(EnumChatFormatting.RED + strToRender, guiLeft + 317, guiTop + 101, true, 0); return; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/MiningPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/MiningPage.java index c8ec09d3..a9dade6a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/MiningPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/MiningPage.java @@ -1453,15 +1453,7 @@ public class MiningPage extends GuiProfileViewerPage { GlStateManager.enableLighting(); if (mouseX >= xPosition && mouseX < xPosition + 16) { if (mouseY >= yPosition && mouseY <= yPosition + 16) { - Utils.drawHoveringText( - tooltip, - mouseX, - mouseY, - getInstance().width, - getInstance().height, - -1, - Minecraft.getMinecraft().fontRendererObj - ); + Utils.drawHoveringText(tooltip, mouseX, mouseY, getInstance().width, getInstance().height, -1); } } } @@ -1519,15 +1511,7 @@ public class MiningPage extends GuiProfileViewerPage { GlStateManager.enableLighting(); if (mouseX >= xPosition && mouseX < xPosition + 16) { if (mouseY >= yPosition && mouseY <= yPosition + 16) { - Utils.drawHoveringText( - tooltip, - mouseX, - mouseY, - getInstance().width, - getInstance().height, - -1, - Minecraft.getMinecraft().fontRendererObj - ); + Utils.drawHoveringText(tooltip, mouseX,mouseY, getInstance().width, getInstance().height, -1); } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PetsPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PetsPage.java index 098c252e..a56662e7 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PetsPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PetsPage.java @@ -148,14 +148,7 @@ public class PetsPage extends GuiProfileViewerPage { Minecraft.getMinecraft().getTextureManager().bindTexture(pv_pets); Utils.drawTexturedRect(guiLeft, guiTop, getInstance().sizeX, getInstance().sizeY, GL11.GL_NEAREST); - Utils.drawStringCentered( - EnumChatFormatting.DARK_PURPLE + "Pets", - Minecraft.getMinecraft().fontRendererObj, - guiLeft + 100, - guiTop + 14, - true, - 4210752 - ); + Utils.drawStringCentered(EnumChatFormatting.DARK_PURPLE + "Pets", guiLeft + 100, guiTop + 14, true, 4210752); GlStateManager.color(1, 1, 1, 1); JsonElement activePetElement = petsInfo.get("active_pet"); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java index 17a14d1f..62f55fd7 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java @@ -42,6 +42,7 @@ import net.minecraft.util.EnumChatFormatting; import javax.annotation.Nullable; import java.io.ByteArrayInputStream; import java.io.IOException; +import java.time.Duration; import java.util.ArrayList; import java.util.Arrays; import java.util.Base64; @@ -537,6 +538,7 @@ public class ProfileViewer { manager.apiUtils .newHypixelApiRequest("player") .queryArgument("name", nameF) + .maxCacheAge(Duration.ofSeconds(30)) .requestJson() .thenAccept(jsonObject -> { if ( @@ -961,30 +963,29 @@ public class ProfileViewer { } double skyblockLevel = getSkyblockLevel(profileName); + EnumChatFormatting levelColour = EnumChatFormatting.WHITE; - EnumChatFormatting previousColor = EnumChatFormatting.WHITE; if (Constants.SBLEVELS == null || !Constants.SBLEVELS.has("sblevel_colours")) { Utils.showOutdatedRepoNotification(); return EnumChatFormatting.WHITE; } + JsonObject sblevelColours = Constants.SBLEVELS.getAsJsonObject("sblevel_colours"); try { for (Map.Entry<String, JsonElement> stringJsonElementEntry : sblevelColours.entrySet()) { - int key = Integer.parseInt(stringJsonElementEntry.getKey()); + int nextLevelBracket = Integer.parseInt(stringJsonElementEntry.getKey()); EnumChatFormatting valueByName = EnumChatFormatting.getValueByName(stringJsonElementEntry .getValue() .getAsString()); - if (skyblockLevel <= key) { - skyBlockExperienceColour.put(profileName, previousColor); - return previousColor; + if (skyblockLevel >= nextLevelBracket) { + levelColour = valueByName; } - previousColor = valueByName; } } catch (RuntimeException ignored) { // catch both numberformat and getValueByName being wrong } - skyBlockExperienceColour.put(profileName, EnumChatFormatting.WHITE); - return EnumChatFormatting.WHITE; + skyBlockExperienceColour.put(profileName, levelColour); + return levelColour; } public double getSkyblockLevel(String profileName) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/bestiary/BestiaryPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/bestiary/BestiaryPage.java index 7da6c627..81b99948 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/bestiary/BestiaryPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/bestiary/BestiaryPage.java @@ -219,18 +219,14 @@ public class BestiaryPage extends GuiProfileViewerPage { GlStateManager.color(1, 1, 1, 1); // if (tier >= 0) { - // Utils.drawStringCentered(tierString, Minecraft.getMinecraft().fontRendererObj, + // Utils.drawStringCentered(tierString, // guiLeft + x + 10, guiTop + y - 4, true, // tierStringColour // ); // } Utils.drawStringCentered( (int) Math.floor(levelNum) + "", - Minecraft.getMinecraft().fontRendererObj, - guiLeft + x + 10, - guiTop + y + 26, - true, - color.getRGB() + guiLeft + x + 10, guiTop + y + 26, true, color.getRGB() ); } } @@ -241,7 +237,7 @@ public class BestiaryPage extends GuiProfileViewerPage { for (String line : tooltipToDisplay) { grayTooltip.add(EnumChatFormatting.GRAY + line); } - Utils.drawHoveringText(grayTooltip, mouseX, mouseY, width, height, -1, Minecraft.getMinecraft().fontRendererObj); + Utils.drawHoveringText(grayTooltip, mouseX, mouseY, width, height, -1); tooltipToDisplay = null; } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/LevelPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/LevelPage.java index 16abf251..770b295a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/LevelPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/LevelPage.java @@ -26,6 +26,7 @@ import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer; import io.github.moulberry.notenoughupdates.profileviewer.level.task.CoreTaskLevel; import io.github.moulberry.notenoughupdates.profileviewer.level.task.DungeonTaskLevel; import io.github.moulberry.notenoughupdates.profileviewer.level.task.EssenceTaskLevel; +import io.github.moulberry.notenoughupdates.profileviewer.level.task.EventTaskLevel; import io.github.moulberry.notenoughupdates.profileviewer.level.task.MiscTaskLevel; import io.github.moulberry.notenoughupdates.profileviewer.level.task.SkillRelatedTaskLevel; import io.github.moulberry.notenoughupdates.profileviewer.level.task.SlayingTaskLevel; @@ -61,6 +62,8 @@ public class LevelPage { private final SlayingTaskLevel slayingTaskLevel; private final StoryTaskLevel storyTaskLevel; + private final EventTaskLevel eventTaskLevel; + private static final ResourceLocation pv_levels = new ResourceLocation("notenoughupdates:pv_levels.png"); public LevelPage(GuiProfileViewer instance, BasicPage basicPage) { @@ -75,6 +78,7 @@ public class LevelPage { skillRelatedTaskLevel = new SkillRelatedTaskLevel(this); slayingTaskLevel = new SlayingTaskLevel(this); storyTaskLevel = new StoryTaskLevel(this); + eventTaskLevel = new EventTaskLevel(this); } public void drawPage(int mouseX, int mouseY) { @@ -97,13 +101,14 @@ public class LevelPage { JsonObject profileInfo = profile.getProfileInformation(profileId); drawMainBar(skyblockLevel, mouseX, mouseY, guiLeft, guiTop); - coreTaskLevel.drawTask(profileInfo, mouseX, mouseY, guiLeft, guiTop); dungeonTaskLevel.drawTask(profileInfo, mouseX, mouseY, guiLeft, guiTop); essenceTaskLevel.drawTask(profileInfo, mouseX, mouseY, guiLeft, guiTop); miscTaskLevel.drawTask(profileInfo, mouseX, mouseY, guiLeft, guiTop); skillRelatedTaskLevel.drawTask(profileInfo, mouseX, mouseY, guiLeft, guiTop); slayingTaskLevel.drawTask(profileInfo, mouseX, mouseY, guiLeft, guiTop); storyTaskLevel.drawTask(profileInfo, mouseX, mouseY, guiLeft, guiTop); + eventTaskLevel.drawTask(profileInfo, mouseX, mouseY, guiLeft, guiTop); + coreTaskLevel.drawTask(profileInfo, mouseX, mouseY, guiLeft, guiTop); } public void renderLevelBar( @@ -175,14 +180,12 @@ public class LevelPage { renderLevelBar( "Level", BasicPage.skull, - guiLeft + 163, - guiTop + 30, + guiLeft + 163, guiTop + 30, 110, skyblockLevel, - (skyblockLevel - (long) skyblockLevel) * 100, + Math.round((skyblockLevel - (long) skyblockLevel) * 100), 100, - mouseX, - mouseY, + mouseX, mouseY, false, Collections.emptyList() ); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/CoreTaskLevel.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/CoreTaskLevel.java index be333359..8eb577d2 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/CoreTaskLevel.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/CoreTaskLevel.java @@ -19,8 +19,9 @@ package io.github.moulberry.notenoughupdates.profileviewer.level.task; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import io.github.moulberry.notenoughupdates.profileviewer.PlayerStats; import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer; import io.github.moulberry.notenoughupdates.profileviewer.level.LevelPage; import io.github.moulberry.notenoughupdates.util.Constants; @@ -80,11 +81,20 @@ public class CoreTaskLevel { } // mp acc - int sbXpGainedMp = levelPage.getProfile().getMagicalPower(levelPage.getProfileId()); + int sbXpGainedMp = 0; + if (object.has("accessory_bag_storage") && + object.getAsJsonObject("accessory_bag_storage").has("highest_magical_power")) { + sbXpGainedMp = object.getAsJsonObject("accessory_bag_storage").get("highest_magical_power").getAsInt(); + } // pets - int petScore = PlayerStats.getPetScore(object); + int petScore = 0; + if (object.has("leveling") && + object.getAsJsonObject("leveling").has("highest_pet_score")) { + petScore = object.getAsJsonObject("leveling").get("highest_pet_score").getAsInt(); + + } int sbXpPetScore = petScore * coreTask.get("pet_score_xp").getAsInt(); // museum is not possible @@ -116,13 +126,33 @@ public class CoreTaskLevel { } } } + + int sbXpBankUpgrades = 0; + if (object.has("leveling") && object.getAsJsonObject("leveling").has("completed_tasks")) { + JsonArray completedTasks = object.getAsJsonObject("leveling").get("completed_tasks").getAsJsonArray(); + JsonObject bankUpgradesXp = coreTask.getAsJsonObject("bank_upgrades_xp"); + for (JsonElement completedTask : completedTasks) { + String name = completedTask.getAsString(); + if (bankUpgradesXp.has(name)) { + sbXpBankUpgrades += bankUpgradesXp.get(name).getAsInt(); + } + } + } + List<String> lore = new ArrayList<>(); lore.add(levelPage.buildLore("Skill Level Up", sbXpGainedSkillLVL, coreTask.get("skill_level_up").getAsInt(), false )); - lore.add(levelPage.buildLore("Museum Progression", - 0, 0, false + + int totalXp = sbXpGainedSkillLVL + sbXpGainedFairy + + sbXpCollection + sbXpMinionTier + sbXpBankUpgrades; + + lore.add(levelPage.buildLore( + "Museum Progression", + 0, + 0, + false )); lore.add(levelPage.buildLore( "Fairy Soul", @@ -141,21 +171,18 @@ public class CoreTaskLevel { sbXpMinionTier, coreTask.get("craft_minions").getAsInt(), false )); lore.add(levelPage.buildLore("Bank Upgrade", - 0, 0, false + sbXpBankUpgrades, coreTask.get("bank_upgrades").getAsInt(), false )); levelPage.renderLevelBar( "Core Task", new ItemStack(Items.nether_star), - guiLeft + 23, - guiTop + 25, + guiLeft + 23, guiTop + 25, 110, 0, - sbXpGainedSkillLVL + sbXpGainedFairy + - sbXpCollection + sbXpMinionTier, + totalXp, levelPage.getConstant().getAsJsonObject("category_xp").get("core_task").getAsInt(), - mouseX, - mouseY, + mouseX, mouseY, true, lore ); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/DungeonTaskLevel.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/DungeonTaskLevel.java index 6f0a029f..6900cdf3 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/DungeonTaskLevel.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/DungeonTaskLevel.java @@ -44,9 +44,9 @@ public class DungeonTaskLevel { Map<String, ProfileViewer.Level> skyblockInfo = levelPage.getProfile().getSkyblockInfo(levelPage.getProfileId()); - double sbLevelGainedFloor = 0; - double sbXpGainedClass = 0; - double sbXpGainedLvl = 0; + int sbLevelGainedFloor = 0; + int sbXpGainedClass = 0; + int sbXpGainedLvl = 0; int catacombsLvl = 0; if (skyblockInfo != null && skyblockInfo.containsKey("catacombs")) { ProfileViewer.Level catacombs = skyblockInfo.get("catacombs"); @@ -105,20 +105,20 @@ public class DungeonTaskLevel { lore.add(levelPage.buildLore("Class Level Up", sbXpGainedClass, classLevelUp, false)); lore.add(levelPage.buildLore("Complete Dungeons", sbLevelGainedFloor, completeDungeon, false)); + int totalSbXpGain = sbXpGainedLvl + sbXpGainedClass + sbLevelGainedFloor; + levelPage.renderLevelBar( "Dungeon Task", NotEnoughUpdates.INSTANCE.manager .createItemResolutionQuery() .withKnownInternalName("WITHER_RELIC") .resolveToItemStack(), - guiLeft + 23, - guiTop + 55, + guiLeft + 23, guiTop + 55, 110, catacombsLvl, totalXp, totalGainful, - mouseX, - mouseY, + mouseX, mouseY, true, lore ); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/EssenceTaskLevel.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/EssenceTaskLevel.java index 11e291b0..c6df6fc1 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/EssenceTaskLevel.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/EssenceTaskLevel.java @@ -25,6 +25,7 @@ import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.profileviewer.level.LevelPage; import io.github.moulberry.notenoughupdates.util.Constants; +import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.util.EnumChatFormatting; import java.util.ArrayList; @@ -88,10 +89,15 @@ public class EssenceTaskLevel { for (Map.Entry<String, EssenceShop> stringEssenceShopEntry : loreMap.entrySet()) { String key = stringEssenceShopEntry.getKey(); EssenceShop value = stringEssenceShopEntry.getValue(); - value.name = NotEnoughUpdates.INSTANCE.manager + JsonObject jsonObject = NotEnoughUpdates.INSTANCE.manager .createItemResolutionQuery() .withKnownInternalName(key) - .resolveToItemListJson() + .resolveToItemListJson(); + if (jsonObject == null){ + Utils.showOutdatedRepoNotification(); + continue; + } + value.name = jsonObject .get("displayname") .getAsString(); String name = key.toLowerCase() + "_shop"; @@ -111,14 +117,12 @@ public class EssenceTaskLevel { NotEnoughUpdates.INSTANCE.manager.createItemResolutionQuery() .withKnownInternalName("ESSENCE_WITHER") .resolveToItemStack(), - guiLeft + 299, - guiTop + 25, + guiLeft + 299, guiTop + 25, 110, total, total, categoryXp.get("essence_shop_task").getAsInt(), - mouseX, - mouseY, + mouseX, mouseY, true, lore ); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/EventTaskLevel.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/EventTaskLevel.java new file mode 100644 index 00000000..a5dc994a --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/EventTaskLevel.java @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2023 NotEnoughUpdates contributors + * + * This file is part of NotEnoughUpdates. + * + * NotEnoughUpdates is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * NotEnoughUpdates is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. + */ + +package io.github.moulberry.notenoughupdates.profileviewer.level.task; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import io.github.moulberry.notenoughupdates.profileviewer.level.LevelPage; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; + +import java.util.ArrayList; +import java.util.List; + +public class EventTaskLevel { + + private final LevelPage levelPage; + + public EventTaskLevel(LevelPage levelPage) {this.levelPage = levelPage;} + + public void drawTask(JsonObject object, int mouseX, int mouseY, int guiLeft, int guiTop) { + List<String> lore = new ArrayList<>(); + + int sbXpMiningFiesta = 0; + int sbXpFishingFestival = 0; + int sbXpSpookyFestival = 0; + JsonObject constant = levelPage.getConstant(); + JsonObject eventTask = constant.getAsJsonObject("event_task"); + + if (object.has("leveling")) { + JsonObject leveling = object.getAsJsonObject("leveling"); + int miningFiestaOresMined = 0; + int fishingFestivalSharksKilled = 0; + if (leveling.has("mining_fiesta_ores_mined")) + miningFiestaOresMined = leveling.get("mining_fiesta_ores_mined").getAsInt(); + if (leveling.has("fishing_festival_sharks_killed")) fishingFestivalSharksKilled = leveling.get( + "fishing_festival_sharks_killed").getAsInt(); + + sbXpMiningFiesta = getCapOrAmount(miningFiestaOresMined, 1_000_000, 5_000); + sbXpFishingFestival = getCapOrAmount(fishingFestivalSharksKilled, 5_000, 50); + + if (leveling.has("completed_tasks")) { + JsonArray completedTasks = leveling.get("completed_tasks").getAsJsonArray(); + JsonObject spookyFestivalXp = eventTask.getAsJsonObject("spooky_festival_xp"); + for (JsonElement completedTask : completedTasks) { + String name = completedTask.getAsString(); + if (spookyFestivalXp.has(name)) { + sbXpSpookyFestival += spookyFestivalXp.get(name).getAsInt(); + } + } + } + } + + lore.add(levelPage.buildLore("Mining Fiesta", sbXpMiningFiesta, eventTask.get("mining_fiesta").getAsInt(), false)); + lore.add(levelPage.buildLore( + "Fishing Festival", + sbXpFishingFestival, + eventTask.get("fishing_festival").getAsInt(), + false + )); + lore.add(levelPage.buildLore( + "Spooky Festival", + sbXpSpookyFestival, + eventTask.get("spooky_festival").getAsInt(), + false + )); + + int totalXp = sbXpMiningFiesta + sbXpSpookyFestival + + sbXpFishingFestival; + levelPage.renderLevelBar( + "Event Task", + new ItemStack(Items.clock), + guiLeft + 299, guiTop + 115, + 110, + 0, + totalXp, + levelPage.getConstant().getAsJsonObject("category_xp").get("event_task").getAsInt(), + mouseX, mouseY, + true, + lore + ); + } + + private int getCapOrAmount(int miningFiestaOresMined, int cap, int per) { + if (miningFiestaOresMined == 0) return 0; + if (miningFiestaOresMined > cap) { + return cap / per; + } + return miningFiestaOresMined / per; + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/MiscTaskLevel.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/MiscTaskLevel.java index e0ea89b3..f78052f5 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/MiscTaskLevel.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/MiscTaskLevel.java @@ -27,12 +27,13 @@ import io.github.moulberry.notenoughupdates.profileviewer.level.LevelPage; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; public class MiscTaskLevel { @@ -86,24 +87,29 @@ public class MiscTaskLevel { } // abiphone - if (netherIslandPlayerData.has("abiphone")) { + JsonObject leveling = object.getAsJsonObject("leveling"); + if (leveling != null && leveling.has("completed_tasks")) { + JsonArray completedTask = leveling.get("completed_tasks").getAsJsonArray(); + Stream<JsonElement> stream = StreamSupport.stream(completedTask.spliterator(), true); + long activeContacts = stream.map(JsonElement::getAsString).filter(s -> s.startsWith("ABIPHONE_")).count(); JsonObject abiphone = netherIslandPlayerData.getAsJsonObject("abiphone"); - if (abiphone.has("active_contacts")) sbXpAbiphone = - abiphone.getAsJsonArray("active_contacts").size() * miscellaneousTask.get("abiphone_contacts_xp").getAsInt(); + if (abiphone.has("active_contacts")) { + sbXpAbiphone = (int) activeContacts * miscellaneousTask.get("abiphone_contacts_xp").getAsInt(); + } } } // harp int sbXpGainedHarp = 0; JsonObject harpSongsNames = miscellaneousTask.get("harp_songs_names").getAsJsonObject(); - if (object.has("harp_quest")) { - JsonObject harpQuest = object.get("harp_quest").getAsJsonObject(); - for (Map.Entry<String, JsonElement> stringJsonElementEntry : harpSongsNames.entrySet()) { - String key = stringJsonElementEntry.getKey(); - int value = stringJsonElementEntry.getValue().getAsInt(); - if (harpQuest.has(key)) { - sbXpGainedHarp += value; - } + + JsonObject leveling = object.getAsJsonObject("leveling"); + if (leveling != null && leveling.has("completed_tasks")) { + JsonArray completedTasks = leveling.get("completed_tasks").getAsJsonArray(); + for (JsonElement completedTask : completedTasks) { + String name = completedTask.getAsString(); + String harpName = name.substring(0, name.lastIndexOf("_")); + if(harpSongsNames.has(harpName))sbXpGainedHarp += harpSongsNames.get(harpName).getAsInt() / 4; } } @@ -158,10 +164,10 @@ public class MiscTaskLevel { sbXpDojo, miscellaneousTask.get("the_dojo").getAsInt(), false )); lore.add(levelPage.buildLore( - EnumChatFormatting.ITALIC + "Harp Songs", + "Harp Songs", sbXpGainedHarp, miscellaneousTask.get("harp_songs").getAsInt(), false )); - lore.add(levelPage.buildLore(EnumChatFormatting.ITALIC + "Abiphone Contacts", + lore.add(levelPage.buildLore("Abiphone Contacts", sbXpAbiphone, miscellaneousTask.get("abiphone_contacts").getAsInt(), false )); lore.add(levelPage.buildLore("Community Shop Upgrades", @@ -171,22 +177,22 @@ public class MiscTaskLevel { sbXpPersonalBank, miscellaneousTask.get("personal_bank_upgrades").getAsInt(), false )); + int totalXp = sbXpReaperPeppers + sbXpDojo + sbXpGainedHarp + sbXpAbiphone + + sbXpCommunityUpgrade + sbXpPersonalBank; levelPage.renderLevelBar( "Misc. Task", new ItemStack(Items.map), - guiLeft + 299, - guiTop + 55, + guiLeft + 299, guiTop + 55, 110, 0, - sbXpReaperPeppers + sbXpDojo + sbXpGainedHarp + sbXpAbiphone + - sbXpCommunityUpgrade + sbXpPersonalBank, + totalXp, levelPage.getConstant().getAsJsonObject("category_xp").get("miscellaneous_task").getAsInt(), - mouseX, - mouseY, + mouseX, mouseY, true, lore ); + totalXp += sbXpAccessoryUpgrade + sbXpUnlockedPowers; } private int getRankIndex(int pointsTotal) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/SkillRelatedTaskLevel.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/SkillRelatedTaskLevel.java index 4ba7951c..176fc899 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/SkillRelatedTaskLevel.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/SkillRelatedTaskLevel.java @@ -43,13 +43,6 @@ public class SkillRelatedTaskLevel { JsonObject skillRelatedTask = levelPage.getConstant().get("skill_related_task").getAsJsonObject(); JsonObject miningObj = skillRelatedTask.get("mining").getAsJsonObject(); - float mithrilPowder = Utils.getElementAsFloat(Utils.getElement(object, "mining_core.powder_mithril"), 0); - float gemstonePowder = Utils.getElementAsFloat(Utils.getElement(object, "mining_core.powder_gemstone"), 0); - float mithril = Utils.getElementAsFloat(Utils.getElement(object, "mining_core.powder_spent_mithril"), 0) + - mithrilPowder; - float gemstone = (Utils.getElementAsFloat(Utils.getElement(object, "mining_core.powder_spent_gemstone"), 0)) + - gemstonePowder; - float hotmXp = Utils.getElementAsFloat(Utils.getElement(object, "mining_core.experience"), 0); ProfileViewer.Level levelObjHotm = ProfileViewer.getLevel( @@ -66,29 +59,31 @@ public class SkillRelatedTaskLevel { hotmXP += hotmXpArray.get(i - 1).getAsInt(); } - int gainByFirstMithrilThing; - if (mithril >= 350_000) { - gainByFirstMithrilThing = (int) (350000 / 2400d); - mithril -= 350_000; - } else { - gainByFirstMithrilThing = (int) (mithril / 2400d); - mithril = 0; - } + float mithrilPowder = Utils.getElementAsFloat(Utils.getElement(object, "mining_core.powder_mithril"), 0); + float gemstonePowder = Utils.getElementAsFloat(Utils.getElement(object, "mining_core.powder_gemstone"), 0); + float mithril = Utils.getElementAsFloat(Utils.getElement(object, "mining_core.powder_spent_mithril"), 0) + + mithrilPowder; + float gemstone = (Utils.getElementAsFloat(Utils.getElement(object, "mining_core.powder_spent_gemstone"), 0)) + + gemstonePowder; - int gainByFirstGemstoneThing; - if (gemstone >= 350_000) { - gainByFirstGemstoneThing = (int) (350_000 / 2500d); - gemstone -= 350_000; - } else { - gainByFirstGemstoneThing = (int) (gemstone / 2500d); - gemstone = 0; - } + // PUNKT NULL + + double totalMithril = mithril + mithrilPowder; + double totalGemstone = gemstone + gemstonePowder; + double mithrilUnder = Math.min(350000.0, totalMithril); + double mithrilOver = Math.max(0, Math.min(totalMithril, 12_500_000.0) - 350000.0); + double gemstoneUnder = Math.min(350000.0, totalGemstone); + double gemstoneOver = Math.max(0, Math.min(totalGemstone, 20_000_000.0) - 350000.0); - int sbXpMithrilPowder = (int) powder(3.75, mithril, 12_500_000); - int sbXpGemstonePowder = (int) powder(4.25, gemstone, 20_000_000); + double mithrilXP = Math.floor(mithrilUnder / 2400.0); + double gemstoneXP = Math.floor(gemstoneUnder / 2500.0); + double mithrilExcess = Math.floor( + 3.75 * (Math.sqrt(1 + 8 * Math.sqrt((1758267.0 / 12_500_000.0) * mithrilOver + 9)) - 3)); + double gemstoneExcess = Math.floor( + 4.25 * (Math.sqrt(1 + 8 * Math.sqrt((1758267.0 / 20_000_000.0) * gemstoneOver + 9)) - 3)); double sbXpHotmTier = - (sbXpMithrilPowder + gainByFirstMithrilThing) + (sbXpGemstonePowder + gainByFirstGemstoneThing) + (mithrilXP + mithrilExcess) + (gemstoneXP + gemstoneExcess) + hotmXP; int sbXpPotmTier = 0; @@ -171,6 +166,18 @@ public class SkillRelatedTaskLevel { } } + int sbXpNucleus = 0; + JsonObject leveling = object.getAsJsonObject("leveling"); + if (leveling != null && leveling.has("completions") && leveling.getAsJsonObject("completions").has("NUCLEUS_RUNS")) { + int nucleusRuns = leveling.getAsJsonObject("completions").get("NUCLEUS_RUNS").getAsInt(); + JsonElement nucleusXp = miningObj.get("crystal_nucleus_xp"); + if (nucleusXp == null) { + Utils.showOutdatedRepoNotification(); + } else { + sbXpNucleus += nucleusRuns * nucleusXp.getAsInt(); + } + } + List<String> lore = new ArrayList<>(); lore.add(levelPage.buildLore("Heart of the Mountain", sbXpHotmTier, miningObj.get("hotm").getAsInt(), false)); lore.add(levelPage.buildLore( @@ -179,7 +186,7 @@ public class SkillRelatedTaskLevel { miningObj.get("commission_milestone").getAsInt(), false )); - lore.add(levelPage.buildLore("Crystal Nucleus", 0, 0, false)); + lore.add(levelPage.buildLore("Crystal Nucleus", sbXpNucleus, miningObj.get("crystal_nucleus").getAsInt(), false)); lore.add(levelPage.buildLore( "Anita's Shop Upgrade", sbXpGainedByAnita, @@ -189,37 +196,22 @@ public class SkillRelatedTaskLevel { lore.add(levelPage.buildLore("Peak of the Mountain", sbXpPotmTier, miningObj.get("potm").getAsInt(), false)); lore.add(levelPage.buildLore("Trophy Fish", sbXpTrophyFish, fishingObj.get("trophy_fish").getAsInt(), false)); lore.add(levelPage.buildLore("Rock Milestone", sbXpRockPet, miningObj.get("rock_milestone").getAsInt(), false)); - lore.add(levelPage.buildLore( - "Dolphin Milestone", - sbXpDolphinPet, - fishingObj.get("dolphin_milestone").getAsInt(), - false - )); + lore.add(levelPage.buildLore("Dolphin Milestone", sbXpDolphinPet, fishingObj.get("dolphin_milestone").getAsInt(), false)); + int totalXp = + (int) (sbXpHotmTier + sbXpCommissionMilestone + sbXpGainedByAnita + sbXpPotmTier + sbXpTrophyFish + sbXpRockPet + + sbXpDolphinPet + sbXpNucleus); levelPage.renderLevelBar( "Skill Related Task", new ItemStack(Items.diamond_sword), - guiLeft + 23, - guiTop + 115, + guiLeft + 23, guiTop + 115, 110, 0, - sbXpHotmTier + sbXpCommissionMilestone + sbXpGainedByAnita + sbXpPotmTier + sbXpTrophyFish + sbXpRockPet + - sbXpDolphinPet, + totalXp, levelPage.getConstant().getAsJsonObject("category_xp").get("skill_related_task").getAsInt(), - mouseX, - mouseY, + mouseX, mouseY, true, lore ); } - - private static double powder(double multiplier, float left, int CAP) { - double cons = 1758267; - if (left <= 0) return 0; - - left = Math.min(CAP, left); - - return multiplier * (Math.sqrt(1 + 8 * (Math.sqrt((cons / CAP) * left + 9))) - 3); - } - } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/SlayingTaskLevel.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/SlayingTaskLevel.java index 3aded435..6b624a52 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/SlayingTaskLevel.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/SlayingTaskLevel.java @@ -233,20 +233,21 @@ public class SlayingTaskLevel { int slayingTaskMax = levelPage.getConstant().getAsJsonObject("category_xp").get("slaying_task").getAsInt(); + int totalXp = sbXpGainedSlayer + bossCollectionXp + mythologicalKillsXp + + sbXpFromDragonKills + sbXpFromSlayerDefeat + sbXpDefeatKuudra + sbXpGainedArachne; levelPage.renderLevelBar( "Slaying Task", new ItemStack(Items.golden_sword), - guiLeft + 23, - guiTop + 85, + guiLeft + 23, guiTop + 85, 110, - 0, sbXpGainedSlayer + bossCollectionXp + mythologicalKillsXp + - sbXpFromDragonKills + sbXpFromSlayerDefeat + sbXpDefeatKuudra + sbXpGainedArachne, + 0, + totalXp, slayingTaskMax, - mouseX, - mouseY, + mouseX, mouseY, true, lore ); + totalXp += sbXpBestiary; } private int loopThroughCollection(int[] array, double value, JsonArray jsonArray) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/StoryTaskLevel.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/StoryTaskLevel.java index 2b1b59cb..3846db5f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/StoryTaskLevel.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/level/task/StoryTaskLevel.java @@ -61,14 +61,12 @@ public class StoryTaskLevel { levelPage.renderLevelBar( "Story Task", new ItemStack(Items.map), - guiLeft + 299, - guiTop + 85, + guiLeft + 299, guiTop + 85, 110, 0, sbXpStory, levelPage.getConstant().getAsJsonObject("category_xp").get("story_task").getAsInt(), - mouseX, - mouseY, + mouseX, mouseY, true, lore ); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/trophy/TrophyFishPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/trophy/TrophyFishPage.java index e885e04f..f4378926 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/trophy/TrophyFishPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/trophy/TrophyFishPage.java @@ -143,14 +143,7 @@ public class TrophyFishPage extends GuiProfileViewerPage { JsonObject profileInformation = GuiProfileViewer.getProfile().getProfileInformation(GuiProfileViewer.getProfileId()); if (profileInformation == null || !profileInformation.has("trophy_fish")) { - Utils.drawStringCentered( - EnumChatFormatting.RED + "No data found", - Minecraft.getMinecraft().fontRendererObj, - guiLeft + 431 / 2f, - guiTop + 101, - true, - 0 - ); + Utils.drawStringCentered(EnumChatFormatting.RED + "No data found", guiLeft + 431 / 2f, guiTop + 101, true, 0); return; } JsonObject trophyObject = profileInformation.get("trophy_fish").getAsJsonObject(); @@ -181,11 +174,7 @@ public class TrophyFishPage extends GuiProfileViewerPage { Utils.drawStringF( EnumChatFormatting.AQUA + "Thunder Kills: §f" + thunderKills, - Minecraft.getMinecraft().fontRendererObj, - guiLeft + 36, - guiTop + 112, - true, - 0 + guiLeft + 36, guiTop + 112, true, 0 ); ItemStack lord_jawbus_sc = NotEnoughUpdates.INSTANCE.manager.jsonToStack( @@ -199,11 +188,7 @@ public class TrophyFishPage extends GuiProfileViewerPage { Utils.drawStringF( EnumChatFormatting.AQUA + "Lord Jawbus Kills: §f" + jawbusKills, - Minecraft.getMinecraft().fontRendererObj, - guiLeft + 36, - guiTop + 124, - true, - 0 + guiLeft + 36, guiTop + 124, true, 0 ); ItemStack fishing_rod = NotEnoughUpdates.INSTANCE.manager.jsonToStack( @@ -211,14 +196,7 @@ public class TrophyFishPage extends GuiProfileViewerPage { ); Minecraft.getMinecraft().getRenderItem().renderItemIntoGUI(fishing_rod, guiLeft + 20, guiTop + 21); - Utils.drawStringF( - EnumChatFormatting.AQUA + "Total Caught: §f" + totalCount, - Minecraft.getMinecraft().fontRendererObj, - guiLeft + 38, - guiTop + 25, - true, - 0 - ); + Utils.drawStringF(EnumChatFormatting.AQUA + "Total Caught: §f" + totalCount, guiLeft + 38, guiTop + 25, true, 0); ArrayList<TrophyFish> arrayList = new ArrayList<>(trophyFishList.values()); arrayList.sort((c1, c2) -> Integer.compare(c2.getTotal(), c1.getTotal())); @@ -289,7 +267,7 @@ public class TrophyFishPage extends GuiProfileViewerPage { y = guiTop + 50 + i; Minecraft.getMinecraft().getRenderItem().renderItemIntoGUI(itemStack, x, y); - Utils.drawStringF(armorHelmets.get(itemStack).getLeft(), Minecraft.getMinecraft().fontRendererObj, x + 20, y + 4, true, 0); + Utils.drawStringF(armorHelmets.get(itemStack).getLeft(), x + 20, y + 4, true, 0); int hasValue = trophiesPerTier[integer - 1]; int neededValue = integer == 1 ? 15 : 18; @@ -298,12 +276,12 @@ public class TrophyFishPage extends GuiProfileViewerPage { try { JsonElement jsonElement = rewards.get(integer - 1); if (!jsonElement.isJsonNull()) { - Utils.drawStringF(check, Minecraft.getMinecraft().fontRendererObj, x + 100, y + 2, true, 0); + Utils.drawStringF(check, x + 100, y + 2, true, 0); } else { - Utils.drawStringF(neededText, Minecraft.getMinecraft().fontRendererObj, x + 100, y + 4, true, 0); + Utils.drawStringF(neededText, x + 100, y + 4, true, 0); } } catch (IndexOutOfBoundsException exception) { - Utils.drawStringF(neededText, Minecraft.getMinecraft().fontRendererObj, x + 100, y + 4, true, 0); + Utils.drawStringF(neededText, x + 100, y + 4, true, 0); } i += 10; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/recipes/CraftingOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/recipes/CraftingOverlay.java index bd45f3e1..4be3b051 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/recipes/CraftingOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/recipes/CraftingOverlay.java @@ -141,8 +141,7 @@ public class CraftingOverlay { Utils.drawHoveringText( recipeIngredient.getItemStack().getTooltip(Minecraft.getMinecraft().thePlayer, false), mouseX, mouseY, - Utils.peekGuiScale().getScaledWidth(), Utils.peekGuiScale().getScaledHeight(), -1, - Minecraft.getMinecraft().fontRendererObj + Utils.peekGuiScale().getScaledWidth(), Utils.peekGuiScale().getScaledHeight(), -1 ); } }); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/recipes/CraftingRecipe.java b/src/main/java/io/github/moulberry/notenoughupdates/recipes/CraftingRecipe.java index a642187b..8e4623e3 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/recipes/CraftingRecipe.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/recipes/CraftingRecipe.java @@ -24,8 +24,6 @@ import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NEUManager; import io.github.moulberry.notenoughupdates.miscgui.GuiItemRecipe; import io.github.moulberry.notenoughupdates.util.Utils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; @@ -115,11 +113,9 @@ public class CraftingRecipe implements NeuRecipe { @Override public void drawExtraInfo(GuiItemRecipe gui, int mouseX, int mouseY) { - FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj; - String craftingText = getCraftText(); if (craftingText != null) - Utils.drawStringCenteredScaledMaxWidth(craftingText, fontRenderer, + Utils.drawStringCenteredScaledMaxWidth(craftingText, gui.guiLeft + EXTRA_STRING_X, gui.guiTop + EXTRA_STRING_Y, false, 75, 0x404040 ); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/recipes/EssenceUpgrades.java b/src/main/java/io/github/moulberry/notenoughupdates/recipes/EssenceUpgrades.java index 439ac56b..15b3c832 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/recipes/EssenceUpgrades.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/recipes/EssenceUpgrades.java @@ -350,14 +350,7 @@ public class EssenceUpgrades implements NeuRecipe { Minecraft.getMinecraft().getTextureManager().bindTexture(BACKGROUND); GlStateManager.color(1, 1, 1, 1); drawButton(x, y, i + 1 == selectedTier); - Utils.drawStringCentered( - String.valueOf(i + 1), - Minecraft.getMinecraft().fontRendererObj, - x + 8, - y + 9, - false, - 0x2d4ffc - ); + Utils.drawStringCentered(String.valueOf(i + 1), x + 8, y + 9, false, 0x2d4ffc); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/recipes/ForgeRecipe.java b/src/main/java/io/github/moulberry/notenoughupdates/recipes/ForgeRecipe.java index 47eb0d11..ff6a175d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/recipes/ForgeRecipe.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/recipes/ForgeRecipe.java @@ -25,17 +25,17 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; import io.github.moulberry.notenoughupdates.NEUManager; +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.miscgui.GuiItemRecipe; +import io.github.moulberry.notenoughupdates.options.NEUConfig; import io.github.moulberry.notenoughupdates.util.HotmInformation; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Set; @@ -88,10 +88,6 @@ public class ForgeRecipe implements NeuRecipe { return output; } - public int getHotmLevel() { - return hotmLevel; - } - public int getTimeInSeconds() { return timeInSeconds; } @@ -151,11 +147,9 @@ public class ForgeRecipe implements NeuRecipe { @Override public void drawExtraInfo(GuiItemRecipe gui, int mouseX, int mouseY) { - FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj; if (timeInSeconds > 0) Utils.drawStringCenteredScaledMaxWidth( formatDuration(timeInSeconds), - fontRenderer, gui.guiLeft + EXTRA_INFO_X, gui.guiTop + EXTRA_INFO_Y, false, @@ -166,30 +160,24 @@ public class ForgeRecipe implements NeuRecipe { @Override public void drawHoverInformation(GuiItemRecipe gui, int mouseX, int mouseY) { - manager.hotm.getInformationOnCurrentProfile().ifPresent(hotmTree -> { - if (timeInSeconds > 0 && gui.isWithinRect( - mouseX, mouseY, - gui.guiLeft + EXTRA_INFO_X - EXTRA_INFO_MAX_WIDTH / 2, - gui.guiTop + EXTRA_INFO_Y - 8, - EXTRA_INFO_MAX_WIDTH, 16 - )) { - int qf = hotmTree.getLevel("forge_time"); - int reducedTime = getReducedTime(qf); - if (qf > 0) { + NEUConfig.HiddenProfileSpecific profileSpecific = NotEnoughUpdates.INSTANCE.config.getProfileSpecific(); + if (profileSpecific == null) return; + + if (timeInSeconds <= 0 || !gui.isWithinRect( + mouseX, mouseY, + gui.guiLeft + EXTRA_INFO_X - EXTRA_INFO_MAX_WIDTH / 2, + gui.guiTop + EXTRA_INFO_Y - 8, + EXTRA_INFO_MAX_WIDTH, 16 + )) return; + + int level = profileSpecific.hotmTree.getOrDefault("Quick Forge", 0); + if (level == 0) return; + int reducedTime = getReducedTime(level); - Utils.drawHoveringText( - Arrays.asList( - EnumChatFormatting.YELLOW + formatDuration(reducedTime) + " with Quick Forge (Level " + qf + ")"), - mouseX, - mouseY, - gui.width, - gui.height, - 500, - Minecraft.getMinecraft().fontRendererObj - ); - } - } - }); + Utils.drawHoveringText( + Collections.singletonList( + EnumChatFormatting.YELLOW + formatDuration(reducedTime) + " with Quick Forge (Level " + level + ")"), + mouseX, mouseY, gui.width, gui.height, 500); } public int getReducedTime(int quickForgeUpgradeLevel) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/recipes/MobLootRecipe.java b/src/main/java/io/github/moulberry/notenoughupdates/recipes/MobLootRecipe.java index 61749593..0e580cb8 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/recipes/MobLootRecipe.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/recipes/MobLootRecipe.java @@ -31,7 +31,6 @@ import io.github.moulberry.notenoughupdates.profileviewer.Panorama; import io.github.moulberry.notenoughupdates.util.ItemUtils; import io.github.moulberry.notenoughupdates.util.JsonUtils; import io.github.moulberry.notenoughupdates.util.Utils; -import net.minecraft.client.Minecraft; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; @@ -276,15 +275,7 @@ public class MobLootRecipe implements NeuRecipe { if (combatXp > 0) stuff.add("§r§bCombat Experience: " + combatXp); stuff.addAll(extra); - Utils.drawHoveringText( - stuff, - mouseX, - mouseY, - gui.width, - gui.height, - -1, - Minecraft.getMinecraft().fontRendererObj - ); + Utils.drawHoveringText(stuff, mouseX, mouseY, gui.width, gui.height, -1); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/recipes/VillagerTradeRecipe.java b/src/main/java/io/github/moulberry/notenoughupdates/recipes/VillagerTradeRecipe.java index 9bb79604..4938c383 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/recipes/VillagerTradeRecipe.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/recipes/VillagerTradeRecipe.java @@ -27,9 +27,7 @@ import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.miscgui.GuiItemRecipe; import io.github.moulberry.notenoughupdates.util.SBInfo; import io.github.moulberry.notenoughupdates.util.Utils; -import net.minecraft.client.Minecraft; import net.minecraft.client.entity.AbstractClientPlayer; -import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.inventory.GuiInventory; import net.minecraft.client.network.NetworkPlayerInfo; import net.minecraft.entity.EntityLivingBase; @@ -135,10 +133,8 @@ public class VillagerTradeRecipe implements NeuRecipe { @Override public void drawExtraInfo(GuiItemRecipe gui, int mouseX, int mouseY) { if (hasVariableCost()) { - FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj; Utils.drawStringCenteredScaledMaxWidth( - minCost + " - " + maxCost, fontRenderer, - gui.guiLeft + 50, gui.guiTop + 90, false, 75, 0xff00ff + minCost + " - " + maxCost, gui.guiLeft + 50, gui.guiTop + 90, false, 75, 0xff00ff ); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/ApiUtil.java b/src/main/java/io/github/moulberry/notenoughupdates/util/ApiUtil.java index 023be060..28298fe0 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/ApiUtil.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/ApiUtil.java @@ -48,18 +48,26 @@ import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.UnrecoverableKeyException; import java.security.cert.CertificateException; +import java.time.Duration; import java.util.ArrayList; import java.util.Collection; +import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.zip.GZIPInputStream; public class ApiUtil { private static final Gson gson = new Gson(); + + private static final Comparator<NameValuePair> nameValuePairComparator = Comparator + .comparing(NameValuePair::getName) + .thenComparing(NameValuePair::getValue); + private static final ExecutorService executorService = Executors.newFixedThreadPool(3); private static String getUserAgent() { if (NotEnoughUpdates.INSTANCE.config.hidden.customUserAgent != null) { @@ -110,6 +118,7 @@ public class ApiUtil { private final List<NameValuePair> queryArguments = new ArrayList<>(); private String baseUrl = null; private boolean shouldGunzip = false; + private Duration maxCacheAge = Duration.ofSeconds(500); private String method = "GET"; private String postData = null; private String postContentType = null; @@ -119,6 +128,15 @@ public class ApiUtil { return this; } + /** + * Specify a cache timeout of {@code null} to signify an uncacheable request. + * Non {@code GET} requests are always uncacheable. + */ + public Request maxCacheAge(Duration maxCacheAge) { + this.maxCacheAge = maxCacheAge; + return this; + } + public Request url(String baseUrl) { this.baseUrl = baseUrl; return this; @@ -160,7 +178,17 @@ public class ApiUtil { return fut; } - public CompletableFuture<String> requestString() { + public String getBaseUrl() { + return baseUrl; + } + + private ApiCache.CacheKey getCacheKey() { + if (!"GET".equals(method)) return null; + queryArguments.sort(nameValuePairComparator); + return new ApiCache.CacheKey(baseUrl, queryArguments, shouldGunzip); + } + + private CompletableFuture<String> requestString0() { return buildUrl().thenApplyAsync(url -> { try { InputStream inputStream = null; @@ -183,7 +211,7 @@ public class ApiUtil { conn.setDoOutput(true); OutputStream os = conn.getOutputStream(); try { - os.write(this.postData.getBytes("utf-8")); + os.write(this.postData.getBytes(StandardCharsets.UTF_8)); } finally { os.close(); } @@ -213,7 +241,16 @@ public class ApiUtil { } catch (IOException e) { throw new RuntimeException(e); // We can rethrow, since supplyAsync catches exceptions. } - }, executorService); + }, executorService).handle((obj, t) -> { + if (t != null) { + System.err.println(ErrorUtil.printStackTraceWithoutApiKey(t)); + } + return obj; + }); + } + + public CompletableFuture<String> requestString() { + return ApiCache.INSTANCE.cacheRequest(this, getCacheKey(), this::requestString0, maxCacheAge); } public CompletableFuture<JsonObject> requestJson() { @@ -221,7 +258,7 @@ public class ApiUtil { } public <T> CompletableFuture<T> requestJson(Class<? extends T> clazz) { - return requestString().thenApply(str -> gson.fromJson(str, clazz)); + return requestString().thenApplyAsync(str -> gson.fromJson(str, clazz)); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/HotmInformation.java b/src/main/java/io/github/moulberry/notenoughupdates/util/HotmInformation.java deleted file mode 100644 index 57c4ae3b..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/HotmInformation.java +++ /dev/null @@ -1,208 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.util; - -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.events.ProfileDataLoadedEvent; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.inventory.GuiChest; -import net.minecraft.inventory.ContainerChest; -import net.minecraftforge.client.event.ClientChatReceivedEvent; -import net.minecraftforge.client.event.GuiOpenEvent; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.world.WorldEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ConcurrentHashMap; - -public class HotmInformation { - private final NotEnoughUpdates neu; - public static final int[] EXPERIENCE_FOR_HOTM_LEVEL = { - // Taken from the wiki: https://hypixel-skyblock.fandom.com/wiki/Heart_of_the_Mountain#Experience_for_Each_Tier - 0, - 3000, - 12000, - 37000, - 97000, - 197000, - 347000 - }; - public static final int[] QUICK_FORGE_MULTIPLIERS = { - 985, - 970, - 955, - 940, - 925, - 910, - 895, - 880, - 865, - 850, - 845, - 840, - 835, - 830, - 825, - 820, - 815, - 810, - 805, - 700 - }; - private final Map<String, Tree> profiles = new ConcurrentHashMap<>(); - - public static class Tree { - private final Map<String, Integer> levels = new HashMap<>(); - private int totalMithrilPowder; - private int totalGemstonePowder; - private int hotmExp; - - public int getHotmExp() { - return hotmExp; - } - - public int getTotalGemstonePowder() { - return totalGemstonePowder; - } - - public int getTotalMithrilPowder() { - return totalMithrilPowder; - } - - public Set<String> getAllUnlockedNodes() { - return levels.keySet(); - } - - public int getHotmLevel() { - for (int i = EXPERIENCE_FOR_HOTM_LEVEL.length - 1; i >= 0; i--) { - if (EXPERIENCE_FOR_HOTM_LEVEL[i] >= this.hotmExp) - return i; - } - return 0; - } - - public int getLevel(String node) { - return levels.getOrDefault(node, 0); - } - - } - - private CompletableFuture<Void> updateTask = CompletableFuture.completedFuture(null); - - private boolean shouldReloadSoon = false; - - public HotmInformation(NotEnoughUpdates neu) { - this.neu = neu; - MinecraftForge.EVENT_BUS.register(this); - } - - public Optional<Tree> getInformationOn(String profile) { - if (profile == null) { - return Optional.empty(); - } - return Optional.ofNullable(this.profiles.get(profile)); - } - - public Optional<Tree> getInformationOnCurrentProfile() { - return getInformationOn(neu.manager.getCurrentProfile()); - } - - @SubscribeEvent - public synchronized void onLobbyJoin(WorldEvent.Load event) { - if (shouldReloadSoon) { - shouldReloadSoon = false; - neu.manager.apiUtils.updateProfileData(); - } - } - - @SubscribeEvent - public synchronized void onGuiOpen(GuiOpenEvent event) { - if (event.gui instanceof GuiChest) { - String containerName = ((ContainerChest) ((GuiChest) event.gui).inventorySlots) - .getLowerChestInventory() - .getDisplayName() - .getUnformattedText(); - if (containerName.equals("Heart of the Mountain")) - shouldReloadSoon = true; - } - } - - @SubscribeEvent - public synchronized void onChat(ClientChatReceivedEvent event) { - if (event.message.getUnformattedText().equals("Welcome to Hypixel SkyBlock!")) - neu.manager.apiUtils.updateProfileData(); - } - - /* - * 1000 = 100% of the time left - * 700 = 70% of the time left - * */ - public static int getQuickForgeMultiplier(int level) { - if (level <= 0) return 1000; - if (level > 20) return -1; - return QUICK_FORGE_MULTIPLIERS[level - 1]; - } - @SubscribeEvent - public void onApiDataLoaded(ProfileDataLoadedEvent event) { - JsonObject data = event.getData(); - if (data == null) return; - - if (!data.has("success") || !data.get("success").getAsBoolean()) return; - JsonArray profiles = data.getAsJsonArray("profiles"); - for (JsonElement element : profiles) { - JsonObject profile = element.getAsJsonObject(); - String profileName = profile.get("cute_name").getAsString(); - JsonObject player = profile.getAsJsonObject("members").getAsJsonObject(Minecraft.getMinecraft().thePlayer - .getUniqueID() - .toString() - .replace("-", "")); - if (!player.has("mining_core")) - continue; - JsonObject miningCore = player.getAsJsonObject("mining_core"); - Tree tree = new Tree(); - JsonObject nodes = miningCore.getAsJsonObject("nodes"); - for (Map.Entry<String, JsonElement> node : nodes.entrySet()) { - String key = node.getKey(); - if (!key.startsWith("toggle_")) { - tree.levels.put(key, node.getValue().getAsInt()); - } - } - if (miningCore.has("powder_mithril_total")) { - tree.totalMithrilPowder = miningCore.get("powder_mithril_total").getAsInt(); - } - if (miningCore.has("powder_gemstone_total")) { - tree.totalGemstonePowder = miningCore.get("powder_gemstone_total").getAsInt(); - } - if (miningCore.has("experience")) { - tree.hotmExp = miningCore.get("experience").getAsInt(); - } - this.profiles.put(profileName, tree); - } - } - -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/ItemResolutionQuery.java b/src/main/java/io/github/moulberry/notenoughupdates/util/ItemResolutionQuery.java index ea5e13ab..280a0d3d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/ItemResolutionQuery.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/ItemResolutionQuery.java @@ -24,6 +24,7 @@ import com.google.gson.JsonParseException; import io.github.moulberry.notenoughupdates.NEUManager; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.util.StringUtils; +import lombok.var; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.inventory.GuiChest; @@ -36,9 +37,10 @@ import net.minecraft.nbt.NBTTagCompound; import javax.annotation.Nullable; import java.util.Arrays; +import java.util.HashSet; import java.util.List; import java.util.Locale; -import java.util.Map; +import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -188,31 +190,63 @@ public class ItemResolutionQuery { return null; } + /** + * Search for an item by the display name + * + * @param displayName The display name of the item we are searching + * @param mayBeMangled Whether the item name may be mangled (for example: reforges, stars) + * @return the internal neu item id of that item, or null + */ + public static String findInternalNameByDisplayName(String displayName, boolean mayBeMangled) { + var cleanDisplayName = StringUtils.cleanColour(displayName); + var manager = NotEnoughUpdates.INSTANCE.manager; + String bestMatch = null; + int bestMatchLength = -1; + for (String internalName : findInternalNameCandidatesForDisplayName(cleanDisplayName)) { + var item = manager.createItem(internalName); + if (item.getDisplayName() == null) continue; + var cleanItemDisplayName = StringUtils.cleanColour(item.getDisplayName()); + if (cleanItemDisplayName.length() == 0) continue; + if (mayBeMangled + ? !cleanDisplayName.contains(cleanItemDisplayName) + : !cleanItemDisplayName.equals(cleanDisplayName)) { + continue; + } + if (cleanItemDisplayName.length() > bestMatchLength) { + bestMatchLength = cleanItemDisplayName.length(); + bestMatch = internalName; + } + } + return bestMatch; + } + + /** + * Find potential item ids for a given display name. This function is over eager to give results, + * and may give invalid results, but if there is a matching item in the repository it will return <em>at least</em> + * that item. This should be used as a first filtering pass. Use {@link #findInternalNameByDisplayName} for a more + * user-friendly API. + * + * @param displayName The display name of the item we are searching + * @return a list of internal neu item ids some of which may have a matching display name + */ + public static Set<String> findInternalNameCandidatesForDisplayName(String displayName) { + var cleanDisplayName = NEUManager.cleanForTitleMapSearch(displayName); + var titleWordMap = NotEnoughUpdates.INSTANCE.manager.titleWordMap; + var candidates = new HashSet<String>(); + for (var partialDisplayName : cleanDisplayName.split(" ")) { + if (!titleWordMap.containsKey(partialDisplayName)) continue; + candidates.addAll(titleWordMap.get(partialDisplayName).keySet()); + } + return candidates; + } + private String resolveItemInCatacombsRngMeter() { List<String> lore = ItemUtils.getLore(compound); if (lore.size() > 16) { String s = lore.get(15); if (s.equals("§7Selected Drop")) { String displayName = lore.get(16); - return getInternalNameByDisplayName(displayName); - } - } - - return null; - } - - private String getInternalNameByDisplayName(String displayName) { - String cleanDisplayName = StringUtils.cleanColour(displayName); - for (Map.Entry<String, JsonObject> entry : NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .entrySet()) { - - JsonObject object = entry.getValue(); - if (object.has("displayname")) { - String name = object.get("displayname").getAsString(); - if (StringUtils.cleanColour(name).equals(cleanDisplayName)) { - return entry.getKey(); - } + return findInternalNameByDisplayName(displayName, false); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/LRUCache.java b/src/main/java/io/github/moulberry/notenoughupdates/util/LRUCache.java index f107d522..6adbc30d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/LRUCache.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/LRUCache.java @@ -32,13 +32,15 @@ public interface LRUCache<K, V> extends Function<K, V> { } static <K, V> LRUCache<K, V> memoize(Function<K, V> mapper, IntSupplier maxCacheSize) { - Map<K, V> cache = new LinkedHashMap<K, V>(10, 0.75F, true) { + Map<K, Object> cache = new LinkedHashMap<K, Object>(10, 0.75F, true) { @Override - protected boolean removeEldestEntry(Map.Entry<K, V> eldest) { + protected boolean removeEldestEntry(Map.Entry<K, Object> eldest) { return this.size() > maxCacheSize.getAsInt(); } }; - Map<K, V> synchronizedCache = Collections.synchronizedMap(cache); + Object SENTINEL_CACHE_RESULT_NULL = new Object(); + Function<K, Object> sentinelAwareMapper = mapper.andThen(it -> it == null ? SENTINEL_CACHE_RESULT_NULL : it); + Map<K, Object> synchronizedCache = Collections.synchronizedMap(cache); return new LRUCache<K, V>() { @Override public void clearCache() { @@ -52,7 +54,8 @@ public interface LRUCache<K, V> extends Function<K, V> { @Override public V apply(K k) { - return synchronizedCache.computeIfAbsent(k, mapper); + Object value = synchronizedCache.computeIfAbsent(k, sentinelAwareMapper); + return value == SENTINEL_CACHE_RESULT_NULL ? null : (V) value; } }; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/NotificationHandler.java b/src/main/java/io/github/moulberry/notenoughupdates/util/NotificationHandler.java index d373ef2c..99a39d0a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/NotificationHandler.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/NotificationHandler.java @@ -83,10 +83,7 @@ public class NotificationHandler { int xLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth("[X] Close"); Minecraft.getMinecraft().fontRendererObj.drawString( "[X] Close", - midX + width / 2f - 3 - xLen, - topY + 3, - 0xFFFF5555, - false + midX + width / 2f - 3 - xLen, topY + 3, 0xFFFF5555, false ); if (notificationDisplayMillis > 0) { @@ -99,24 +96,10 @@ public class NotificationHandler { ); } - Utils.drawStringCentered( - notificationLines.get(0), - Minecraft.getMinecraft().fontRendererObj, - midX, - topY + 4 + 5, - false, - -1 - ); + Utils.drawStringCentered(notificationLines.get(0), midX, topY + 4 + 5, false, -1); for (int i = 1; i < notificationLines.size(); i++) { String line = notificationLines.get(i); - Utils.drawStringCentered( - line, - Minecraft.getMinecraft().fontRendererObj, - midX, - topY + 4 + 5 + 2 + i * 10, - false, - -1 - ); + Utils.drawStringCentered(line, midX, topY + 4 + 5 + 2 + i * 10, false, -1); } Utils.pushGuiScale(-1); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java index d0af9091..9d2d1056 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java @@ -24,6 +24,7 @@ import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe; import io.github.moulberry.notenoughupdates.listener.ScoreboardLocationChangeListener; +import io.github.moulberry.notenoughupdates.miscfeatures.CookieWarning; import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.LocationChangeEvent; import io.github.moulberry.notenoughupdates.miscgui.minionhelper.MinionHelperManager; import io.github.moulberry.notenoughupdates.overlays.OverlayManager; @@ -307,7 +308,8 @@ public class SBInfo { private static final String profilePrefix = "\u00a7r\u00a7e\u00a7lProfile: \u00a7r\u00a7a"; private static final String skillsPrefix = "\u00a7r\u00a7e\u00a7lSkills: \u00a7r\u00a7a"; - private static final String completedFactionQuests = "\u00a7r \u00a7r\u00a7a"; + private static final String completedFactionQuests = + "\u00a7r \u00a7r\u00a7a(?!(Paul|Finnegan|Aatrox|Cole|Diana|Diaz|Foxy|Marina)).*"; public ArrayList<String> completedQuests = new ArrayList<>(); private static final Pattern SKILL_LEVEL_PATTERN = Pattern.compile("([^0-9:]+) (\\d{1,2})"); @@ -352,7 +354,7 @@ public class SBInfo { } catch (Exception ignored) { } } - } else if (name.startsWith(completedFactionQuests)) { + } else if (name.matches(completedFactionQuests) && "crimson_isle".equals(mode)) { if (completedQuests.isEmpty()) { completedQuests.add(name); } else if (!completedQuests.contains(name)) { @@ -477,7 +479,6 @@ public class SBInfo { .thenAccept(newJson -> mayorJson = newJson); } - public JsonObject getMayorJson() { return mayorJson; } @@ -486,6 +487,7 @@ public class SBInfo { if (!newProfile.equals(currentProfile)) { currentProfile = newProfile; MinionHelperManager.getInstance().onProfileSwitch(); + CookieWarning.onProfileSwitch(); } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java index 90e53097..fed05473 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -294,9 +294,9 @@ public class Utils { while (matcher.find()) { matcher.appendReplacement( sb, - Utils.chromaString(matcher.group(1)) - .replace("\\", "\\\\") - .replace("$", "\\$") + chromaString(matcher.group(1)) + .replace("\\", "\\\\") + .replace("$", "\\$") ); } matcher.appendTail(sb); @@ -629,10 +629,10 @@ public class Utils { Minecraft.getMinecraft().getTextureManager().bindTexture(GuiProfileViewer.pv_elements); - Utils.drawTexturedRect(x, y, pressed ? 32 : 28, 28, uMin, uMax, vMin, vMax, GL11.GL_NEAREST); + drawTexturedRect(x, y, pressed ? 32 : 28, 28, uMin, uMax, vMin, vMax, GL11.GL_NEAREST); GlStateManager.enableDepth(); - Utils.drawItemStack(itemStack, x + 8, y + 7); + drawItemStack(itemStack, x + 8, y + 7); } public static void drawTexturedRect(float x, float y, float width, float height, int filter) { @@ -677,7 +677,7 @@ public class Utils { public static int checkItemTypePet(List<String> lore) { for (int i = lore.size() - 1; i >= 0; i--) { - String line = Utils.cleanColour(lore.get(i)); + String line = cleanColour(lore.get(i)); for (int i1 = 0; i1 < rarityArr.length; i1++) { if (line.equals(rarityArr[i1])) { return i1; @@ -926,6 +926,10 @@ public class Utils { return createItemStack(item, displayName, 0, lore); } + public static ItemStack createItemStackArray(Item item, String displayName, String[] lore) { + return createItemStack(item, displayName, 0, lore); + } + public static ItemStack createItemStack(Block item, String displayName, String... lore) { return createItemStack(Item.getItemFromBlock(item), displayName, lore); } @@ -933,17 +937,7 @@ public class Utils { public static ItemStack createItemStack(Item item, String displayName, int damage, String... lore) { ItemStack stack = new ItemStack(item, 1, damage); NBTTagCompound tag = new NBTTagCompound(); - NBTTagCompound display = new NBTTagCompound(); - NBTTagList Lore = new NBTTagList(); - - for (String line : lore) { - Lore.appendTag(new NBTTagString(line)); - } - - display.setString("Name", displayName); - display.setTag("Lore", Lore); - - tag.setTag("display", display); + addNameAndLore(tag, displayName, lore); tag.setInteger("HideFlags", 254); stack.setTagCompound(tag); @@ -951,6 +945,22 @@ public class Utils { return stack; } + private static void addNameAndLore(NBTTagCompound tag, String displayName, String[] lore) { + NBTTagCompound display = new NBTTagCompound(); + + display.setString("Name", displayName); + + if (lore != null) { + NBTTagList tagLore = new NBTTagList(); + for (String line : lore) { + tagLore.appendTag(new NBTTagString(line)); + } + display.setTag("Lore", tagLore); + } + + tag.setTag("display", display); + } + public static ItemStack editItemStackInfo( ItemStack itemStack, String displayName, @@ -980,15 +990,17 @@ public class Utils { return itemStack; } - public static ItemStack createSkull(String displayName, String uuid, String value) { + return createSkull(displayName, uuid, value, null); + } + + public static ItemStack createSkull(String displayName, String uuid, String value, String[] lore) { ItemStack render = new ItemStack(Items.skull, 1, 3); NBTTagCompound tag = new NBTTagCompound(); NBTTagCompound skullOwner = new NBTTagCompound(); NBTTagCompound properties = new NBTTagCompound(); NBTTagList textures = new NBTTagList(); NBTTagCompound textures_0 = new NBTTagCompound(); - NBTTagCompound display = new NBTTagCompound(); skullOwner.setString("Id", uuid); skullOwner.setString("Name", uuid); @@ -996,8 +1008,7 @@ public class Utils { textures_0.setString("Value", value); textures.appendTag(textures_0); - display.setString("Name", displayName); - tag.setTag("display", display); + addNameAndLore(tag, displayName, lore); properties.setTag("textures", textures); skullOwner.setTag("Properties", properties); @@ -1006,6 +1017,11 @@ public class Utils { return render; } + public static void drawStringF(String str, float x, float y, boolean shadow, int colour) { + drawStringF(str, Minecraft.getMinecraft().fontRendererObj, x, y, shadow, colour); + } + + @Deprecated public static void drawStringF(String str, FontRenderer fr, float x, float y, boolean shadow, int colour) { fr.drawString(str, x, y, colour, shadow); } @@ -1029,6 +1045,11 @@ public class Utils { return height; } + public static void drawStringVertical(String str, float x, float y, boolean shadow, int colour) { + drawStringVertical(str, Minecraft.getMinecraft().fontRendererObj, x, y, shadow, colour); + } + + @Deprecated public static void drawStringVertical(String str, FontRenderer fr, float x, float y, boolean shadow, int colour) { String format = FontRenderer.getFormatFromString(str); str = cleanColour(str); @@ -1056,9 +1077,8 @@ public class Utils { for (int xOff = -2; xOff <= 2; xOff++) { for (int yOff = -2; yOff <= 2; yOff++) { if (Math.abs(xOff) != Math.abs(yOff)) { - Utils.drawStringCenteredScaledMaxWidth( - Utils.cleanColourNotModifiers(str), - Minecraft.getMinecraft().fontRendererObj, + drawStringCenteredScaledMaxWidth( + cleanColourNotModifiers(str), x + xOff / 2f * factor, y + 4 + yOff / 2f * factor, false, @@ -1070,9 +1090,7 @@ public class Utils { } GlStateManager.color(1, 1, 1, 1); - Utils.drawStringCenteredScaledMaxWidth(str, Minecraft.getMinecraft().fontRendererObj, - x, y + 4, false, maxLength, 4210752 - ); + drawStringCenteredScaledMaxWidth(str, x, y + 4, false, maxLength, 421075); } public static void renderAlignedString(String first, String second, float x, float y, int length) { @@ -1083,7 +1101,7 @@ public class Utils { for (int xOff = -2; xOff <= 2; xOff++) { for (int yOff = -2; yOff <= 2; yOff++) { if (Math.abs(xOff) != Math.abs(yOff)) { - fontRendererObj.drawString(Utils.cleanColourNotModifiers(first), + fontRendererObj.drawString(cleanColourNotModifiers(first), x + xOff / 2f, y + yOff / 2f, new Color(0, 0, 0, 200 / Math.max(Math.abs(xOff), Math.abs(yOff))).getRGB(), false ); @@ -1097,7 +1115,7 @@ public class Utils { for (int xOff = -2; xOff <= 2; xOff++) { for (int yOff = -2; yOff <= 2; yOff++) { if (Math.abs(xOff) != Math.abs(yOff)) { - fontRendererObj.drawString(Utils.cleanColourNotModifiers(second), + fontRendererObj.drawString(cleanColourNotModifiers(second), x + length - secondLen + xOff / 2f, y + yOff / 2f, new Color(0, 0, 0, 200 / Math.max(Math.abs(xOff), Math.abs(yOff))).getRGB(), false ); @@ -1112,6 +1130,18 @@ public class Utils { public static void drawStringScaledMaxWidth( String str, + float x, + float y, + boolean shadow, + int len, + int colour + ) { + drawStringScaledMaxWidth(str, Minecraft.getMinecraft().fontRendererObj, x, y, shadow, len, colour); + } + + @Deprecated + public static void drawStringScaledMaxWidth( + String str, FontRenderer fr, float x, float y, @@ -1123,9 +1153,14 @@ public class Utils { float factor = len / (float) strLen; factor = Math.min(1, factor); - drawStringScaled(str, fr, x, y, shadow, colour, factor); + drawStringScaled(str, x, y, shadow, colour, factor); + } + + public static void drawStringCentered(String str, float x, float y, boolean shadow, int colour) { + drawStringCentered(str, Minecraft.getMinecraft().fontRendererObj, x, y, shadow, colour); } + @Deprecated public static void drawStringCentered(String str, FontRenderer fr, float x, float y, boolean shadow, int colour) { int strLen = fr.getStringWidth(str); @@ -1139,6 +1174,18 @@ public class Utils { public static void drawStringScaled( String str, + float x, + float y, + boolean shadow, + int colour, + float factor + ) { + drawStringScaled(str, Minecraft.getMinecraft().fontRendererObj, x, y, shadow, colour, factor); + } + + @Deprecated + public static void drawStringScaled( + String str, FontRenderer fr, float x, float y, @@ -1160,11 +1207,24 @@ public class Utils { int colour, float factor ) { - drawStringScaled(str, fr, x - fr.getStringWidth(str) * factor, y, shadow, colour, factor); + drawStringScaled(str, x - fr.getStringWidth(str) * factor, y, shadow, colour, factor); } public static void drawStringScaledMax( String str, + float x, + float y, + boolean shadow, + int colour, + float factor, + int len + ) { + drawStringScaledMax(str, Minecraft.getMinecraft().fontRendererObj, x, y, shadow, colour, factor, len); + } + + @Deprecated + public static void drawStringScaledMax( + String str, FontRenderer fr, float x, float y, @@ -1184,6 +1244,18 @@ public class Utils { public static void drawStringCenteredScaledMaxWidth( String str, + float x, + float y, + boolean shadow, + int len, + int colour + ) { + drawStringCenteredScaledMaxWidth(str, Minecraft.getMinecraft().fontRendererObj, x, y, shadow, len, colour); + } + + @Deprecated + public static void drawStringCenteredScaledMaxWidth( + String str, FontRenderer fr, float x, float y, @@ -1198,7 +1270,7 @@ public class Utils { float fontHeight = 8 * factor; - drawStringScaled(str, fr, x - newLen / 2, y - fontHeight / 2, shadow, colour, factor); + drawStringScaled(str, x - newLen / 2, y - fontHeight / 2, shadow, colour, factor); } public static Matrix4f createProjectionMatrix(int width, int height) { @@ -1216,20 +1288,34 @@ public class Utils { public static void drawStringCenteredScaled( String str, - FontRenderer fr, - float x, - float y, + float x, float y, boolean shadow, int len, int colour ) { - int strLen = fr.getStringWidth(str); + int strLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(str); float factor = len / (float) strLen; float fontHeight = 8 * factor; - drawStringScaled(str, fr, x - len / 2, y - fontHeight / 2, shadow, colour, factor); + drawStringScaled( + str, + x - len / 2, y - fontHeight / 2, + shadow, + colour, + factor + ); + } + + public static void drawStringCenteredScaled( + String str, + float x, float y, + boolean shadow, + float factor + ) { + drawStringCenteredScaled(str, Minecraft.getMinecraft().fontRendererObj, x, y, shadow, factor); } + @Deprecated public static void drawStringCenteredScaled( String str, FontRenderer fr, @@ -1243,7 +1329,7 @@ public class Utils { float x2 = x - strLen / 2f; float y2 = y - fr.FONT_HEIGHT / 2f; - drawStringScaled(str, fr, x2, y2, shadow, 0, factor); + drawStringScaled(str, x2, y2, shadow, 0, factor); } public static void drawStringCenteredYScaled( @@ -1259,7 +1345,7 @@ public class Utils { float factor = len / (float) strLen; float fontHeight = 8 * factor; - drawStringScaled(str, fr, x, y - fontHeight / 2, shadow, colour, factor); + drawStringScaled(str, x, y - fontHeight / 2, shadow, colour, factor); } public static void drawStringCenteredYScaledMaxWidth( @@ -1276,12 +1362,11 @@ public class Utils { factor = Math.min(1, factor); float fontHeight = 8 * factor; - drawStringScaled(str, fr, x, y - fontHeight / 2, shadow, colour, factor); + drawStringScaled(str, x, y - fontHeight / 2, shadow, colour, factor); } public static int renderStringTrimWidth( String str, - FontRenderer fr, boolean shadow, int x, int y, @@ -1289,12 +1374,11 @@ public class Utils { int colour, int maxLines ) { - return renderStringTrimWidth(str, fr, shadow, x, y, len, colour, maxLines, 1); + return renderStringTrimWidth(str, shadow, x, y, len, colour, maxLines, 1); } public static int renderStringTrimWidth( String str, - FontRenderer fr, boolean shadow, int x, int y, @@ -1321,20 +1405,20 @@ public class Utils { int lines = 0; while ((lines++ < maxLines) || maxLines < 0) { if (trimmed.length() == str.length()) { - drawStringScaled(trimmed, fr, x, y + yOff, shadow, colour, scale); + drawStringScaled(trimmed, x, y + yOff, shadow, colour, scale); break; } else if (trimmed.isEmpty()) { yOff -= 12 * scale; break; } else { if (firstLine) { - drawStringScaled(trimmed, fr, x, y + yOff, shadow, colour, scale); + drawStringScaled(trimmed, x, y + yOff, shadow, colour, scale); firstLine = false; } else { if (trimmed.startsWith(" ")) { trimmed = trimmed.substring(1); } - drawStringScaled(colourCodes + trimmed, fr, x, y + yOff, shadow, colour, scale); + drawStringScaled(colourCodes + trimmed, x, y + yOff, shadow, colour, scale); } excess = str.substring(trimmedCharacters); @@ -1420,6 +1504,38 @@ public class Utils { GlStateManager.enableTexture2D(); } + public static void drawHoveringText( + List<String> textLines, + final int mouseX, + final int mouseY, + final int screenWidth, + final int screenHeight, + final int maxTextWidth + ) { + drawHoveringText( + textLines, + mouseX, + mouseY, + screenWidth, + screenHeight, + maxTextWidth, + Minecraft.getMinecraft().fontRendererObj + ); + } + + @Deprecated + public static void drawHoveringText( + List<String> textLines, + final int mouseX, + final int mouseY, + final int screenWidth, + final int screenHeight, + final int maxTextWidth, + FontRenderer font + ) { + drawHoveringText(textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth, font, true); + } + public static JsonObject getConstant(String constant, Gson gson) { return getConstant(constant, gson, JsonObject.class); } @@ -1555,6 +1671,28 @@ public class Utils { public static void drawHoveringText( List<String> textLines, + final int mouseX, + final int mouseY, + final int screenWidth, + final int screenHeight, + final int maxTextWidth, + boolean coloured + ) { + drawHoveringText( + textLines, + mouseX, + mouseY, + screenWidth, + screenHeight, + maxTextWidth, + Minecraft.getMinecraft().fontRendererObj, + coloured + ); + } + + @Deprecated + public static void drawHoveringText( + List<String> textLines, int mouseX, int mouseY, int screenWidth, @@ -2136,7 +2274,7 @@ public class Utils { runtime.exec("xdg-open " + url); return true; } catch (IOException e) { - Utils.playSound(new ResourceLocation("game.player.hurt"), true); + playSound(new ResourceLocation("game.player.hurt"), true); return false; } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/brigadier/NEUBrigadierHook.kt b/src/main/java/io/github/moulberry/notenoughupdates/util/brigadier/NEUBrigadierHook.kt new file mode 100644 index 00000000..668c412a --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/brigadier/NEUBrigadierHook.kt @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2023 Linnea Gräf + * + * This file is part of NotEnoughUpdates. + * + * NotEnoughUpdates is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * NotEnoughUpdates is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. + */ + +package io.github.moulberry.notenoughupdates.util.brigadier + +import com.mojang.brigadier.ParseResults +import com.mojang.brigadier.exceptions.CommandSyntaxException +import com.mojang.brigadier.suggestion.Suggestions +import com.mojang.brigadier.tree.CommandNode +import net.minecraft.command.CommandBase +import net.minecraft.command.ICommandSender +import net.minecraft.util.BlockPos +import net.minecraft.util.ChatComponentText +import net.minecraft.util.EnumChatFormatting.RED +import net.minecraft.util.EnumChatFormatting.YELLOW +import java.util.concurrent.CompletableFuture +import java.util.function.Predicate + +/** + * Hook for converting brigadier commands to normal legacy Minecraft commands (string array style). + */ +class NEUBrigadierHook( + val brigadierRoot: BrigadierRoot, + val commandNode: CommandNode<DefaultSource>, + val aliases: List<String> +) : CommandBase() { + /** + * Runs before the command gets executed. Return false to prevent execution. + */ + var beforeCommand: Predicate<ParseResults<DefaultSource>>? = null + + override fun getCommandName(): String { + return commandNode.name + } + + override fun getCommandAliases(): List<String> { + return aliases + } + + data class Usage( + val path: String, + val help: String?, + ) + + + override fun getCommandUsage(sender: ICommandSender): String { + return brigadierRoot.getAllUsages("/$commandName", commandNode, mutableSetOf()).joinToString("\n") { "${it.path} - ${it.help ?: "Missing help"}"} + } + + private fun getText(args: Array<out String>) = "${commandNode.name} ${args.joinToString(" ")}" + + override fun processCommand(sender: ICommandSender, args: Array<out String>) { + val results = brigadierRoot.parseText.apply(sender to getText(args).trim()) + if (beforeCommand?.test(results) == false) + return + try { + brigadierRoot.dispatcher.execute(results) + } catch (syntax: CommandSyntaxException) { + brigadierRoot.getAllUsages("/$commandName", commandNode, mutableSetOf()).forEach { + sender.addChatMessage(ChatComponentText("${YELLOW}[NEU] ${it.path} - ${it.help}")) + } + } + } + + // We love async tab completion (may end up requiring pressing tab multiple times, but uhhhhh .get() bad) + private var lastCompletionText: String? = null + private var lastCompletion: CompletableFuture<Suggestions>? = null + override fun addTabCompletionOptions( + sender: ICommandSender, + args: Array<out String>, + pos: BlockPos + ): List<String> { + val originalText = getText(args) + var lc: CompletableFuture<Suggestions>? = null + if (lastCompletionText == originalText) { + lc = lastCompletion + } + if (lc == null) { + lastCompletion?.cancel(true) + val results = brigadierRoot.parseText.apply(sender to originalText) + lc = brigadierRoot.dispatcher.getCompletionSuggestions(results) + } + lastCompletion = lc + lastCompletionText = originalText + val suggestions = lastCompletion?.getNow(null) ?: return emptyList() + return suggestions.list.map { it.text } + } + + override fun canCommandSenderUseCommand(sender: ICommandSender): Boolean { + return true // Permissions are checked by brigadier instead (or by the beforeCommand hook) + } + +} |