diff options
Diffstat (limited to 'src/main/java')
13 files changed, 259 insertions, 362 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index 7f0136ee..8b6c2255 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -43,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; @@ -168,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; } @@ -180,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. */ @@ -270,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(); 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 03f3a449..5e39aa45 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java @@ -28,12 +28,11 @@ import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.auction.CustomAHGui; 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; @@ -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,104 +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 - ); - } - } - } - } - } + }); } - if (!hoveringButton) buttonHovered = null; + if (!hoveringButton[0]) buttonHovered = null; if (AuctionBINWarning.getInstance().shouldShow()) { AuctionBINWarning.getInstance().render(); @@ -1121,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; - } + 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 (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; - } - } - - 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); } - } + + }); } } 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/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/DungeonNpcProfitOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DungeonNpcProfitOverlay.java index c4b03b84..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; 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 562eb1e0..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" @@ -475,15 +494,9 @@ public class AccessoryBagOverlay { 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); @@ -844,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/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/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/mixins/MixinRenderItem.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderItem.java index 2173a3c8..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. * @@ -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) { 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 498b3b0d..53906cd8 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java @@ -250,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(); 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 affaa68a..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 @@ -319,5 +319,4 @@ public class Misc { ) @ConfigEditorBoolean public boolean oldSkyBlockMenu = false; - } 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 index c476fc3b..6f03c2bb 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Museum.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Museum.java @@ -22,6 +22,7 @@ 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 { @@ -42,4 +43,22 @@ public class Museum { @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/overlays/EquipmentOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/EquipmentOverlay.java index a812ff52..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,12 +25,14 @@ 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; @@ -149,6 +151,29 @@ public class EquipmentOverlay { 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) { |