From 9aa7b49d224bfde055e12bc84f6908ba0a50090d Mon Sep 17 00:00:00 2001 From: BuildTools Date: Thu, 6 May 2021 08:03:15 +0800 Subject: fine ironman --- build.gradle | 45 +- gradle/wrapper/gradle-wrapper.properties | 2 +- .../notenoughupdates/NEUEventListener.java | 246 +++-- .../moulberry/notenoughupdates/NEUManager.java | 14 +- .../moulberry/notenoughupdates/NEUOverlay.java | 12 +- .../notenoughupdates/NotEnoughUpdates.java | 92 +- .../notenoughupdates/auction/APIManager.java | 7 +- .../notenoughupdates/core/GuiElementColour.java | 106 +- .../notenoughupdates/core/GuiElementTextField.java | 55 +- .../core/config/KeybindHelper.java | 49 + .../config/annotations/ConfigEditorKeybind.java | 14 + .../core/config/gui/GuiOptionEditorKeybind.java | 94 ++ .../core/config/struct/ConfigProcessor.java | 5 + .../notenoughupdates/cosmetics/CapeManager.java | 4 +- .../notenoughupdates/dungeons/DungeonMap.java | 2 +- .../miscfeatures/BetterContainers.java | 47 +- .../miscfeatures/CrystalOverlay.java | 34 +- .../miscfeatures/CustomItemEffects.java | 2 +- .../miscfeatures/DwarvenMinesTextures.java | 3 + .../miscfeatures/EnchantingSolvers.java | 21 +- .../miscfeatures/ItemCooldowns.java | 53 +- .../miscfeatures/ItemCustomizeManager.java | 278 ++++++ .../miscfeatures/NPCRetexturing.java | 99 ++ .../miscfeatures/PetInfoOverlay.java | 120 ++- .../notenoughupdates/miscfeatures/SlotLocking.java | 357 +++++++ .../miscfeatures/StorageManager.java | 595 ++++++++++++ .../miscgui/AccessoryBagOverlay.java | 3 +- .../notenoughupdates/miscgui/GuiItemCustomize.java | 372 +++++++ .../miscgui/InventoryStorageSelector.java | 318 ++++++ .../notenoughupdates/miscgui/StorageOverlay.java | 1026 ++++++++++++++++++++ .../notenoughupdates/miscgui/TradeWindow.java | 18 +- .../mixins/GuiContainerAccessor.java | 22 - .../mixins/GuiEditSignAccessor.java | 14 - .../mixins/MixinAbstractClientPlayer.java | 42 + .../mixins/MixinEntityPlayerSP.java | 27 + .../mixins/MixinEntityRenderer.java | 31 + .../notenoughupdates/mixins/MixinGuiContainer.java | 72 +- .../notenoughupdates/mixins/MixinGuiIngame.java | 31 + .../mixins/MixinInventoryPlayer.java | 20 + .../notenoughupdates/mixins/MixinItemRenderer.java | 34 + .../notenoughupdates/mixins/MixinItemStack.java | 45 +- .../mixins/MixinLayerArmorBase.java | 67 ++ .../mixins/MixinLayerCustomHead.java | 71 ++ .../notenoughupdates/mixins/MixinMinecraft.java | 18 + .../notenoughupdates/mixins/MixinMouseHelper.java | 22 + .../mixins/MixinNetHandlerPlayClient.java | 28 +- .../notenoughupdates/mixins/MixinRenderGlobal.java | 1 - .../notenoughupdates/mixins/MixinRenderItem.java | 142 ++- .../mixins/MixinTextureManager.java | 21 + .../notenoughupdates/options/NEUConfig.java | 264 ++++- .../notenoughupdates/options/NEUConfigEditor.java | 86 +- .../overlays/AuctionSearchOverlay.java | 7 +- .../notenoughupdates/overlays/MiningOverlay.java | 27 +- .../overlays/RancherBootOverlay.java | 5 +- .../notenoughupdates/overlays/TimersOverlay.java | 5 + .../assets/notenoughupdates/capes/furf.png | Bin 8145 -> 12443 bytes .../assets/notenoughupdates/capes/skytils.png | Bin 0 -> 59744 bytes .../notenoughupdates/capes/skytils_preview.png | Bin 0 -> 43946 bytes .../notenoughupdates/itemcustomize/reset.png | Bin 0 -> 665 bytes .../notenoughupdates/loading_circle_seq/1.png | Bin 0 -> 634 bytes .../notenoughupdates/loading_circle_seq/2.png | Bin 0 -> 638 bytes .../notenoughupdates/loading_circle_seq/3.png | Bin 0 -> 645 bytes .../notenoughupdates/loading_circle_seq/4.png | Bin 0 -> 647 bytes .../notenoughupdates/loading_circle_seq/5.png | Bin 0 -> 645 bytes .../notenoughupdates/loading_circle_seq/6.png | Bin 0 -> 645 bytes .../notenoughupdates/loading_circle_seq/7.png | Bin 0 -> 627 bytes .../assets/notenoughupdates/slotlocking/lock.png | Bin 0 -> 345 bytes .../notenoughupdates/storage_gui/hotbar_icons.png | Bin 0 -> 1849 bytes .../notenoughupdates/storage_gui/storage_gui_0.png | Bin 0 -> 10712 bytes .../notenoughupdates/storage_gui/storage_gui_1.png | Bin 0 -> 3463 bytes .../notenoughupdates/storage_gui/storage_gui_2.png | Bin 0 -> 3307 bytes .../notenoughupdates/storage_gui/storage_gui_3.png | Bin 0 -> 3374 bytes .../notenoughupdates/storage_gui/storage_icons.png | Bin 0 -> 10183 bytes .../storage_gui/storage_preview_0.png | Bin 0 -> 6939 bytes .../storage_gui/storage_preview_1.png | Bin 0 -> 7369 bytes .../storage_gui/storage_preview_2.png | Bin 0 -> 7020 bytes .../storage_gui/storage_preview_3.png | Bin 0 -> 7160 bytes .../resources/assets/notenoughupdates/test.gif | Bin 0 -> 338 bytes src/main/resources/mixins.notenoughupdates.json | 12 +- src/main/resources/notenoughupdates_at.cfg | 8 + 80 files changed, 4771 insertions(+), 444 deletions(-) create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/core/config/KeybindHelper.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorKeybind.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorKeybind.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCustomizeManager.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/NPCRetexturing.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StorageManager.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemCustomize.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/miscgui/InventoryStorageSelector.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/mixins/GuiContainerAccessor.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/mixins/GuiEditSignAccessor.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinAbstractClientPlayer.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityPlayerSP.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinInventoryPlayer.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemRenderer.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLayerArmorBase.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLayerCustomHead.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinMinecraft.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinMouseHelper.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTextureManager.java create mode 100644 src/main/resources/assets/notenoughupdates/capes/skytils.png create mode 100644 src/main/resources/assets/notenoughupdates/capes/skytils_preview.png create mode 100644 src/main/resources/assets/notenoughupdates/itemcustomize/reset.png create mode 100644 src/main/resources/assets/notenoughupdates/loading_circle_seq/1.png create mode 100644 src/main/resources/assets/notenoughupdates/loading_circle_seq/2.png create mode 100644 src/main/resources/assets/notenoughupdates/loading_circle_seq/3.png create mode 100644 src/main/resources/assets/notenoughupdates/loading_circle_seq/4.png create mode 100644 src/main/resources/assets/notenoughupdates/loading_circle_seq/5.png create mode 100644 src/main/resources/assets/notenoughupdates/loading_circle_seq/6.png create mode 100644 src/main/resources/assets/notenoughupdates/loading_circle_seq/7.png create mode 100644 src/main/resources/assets/notenoughupdates/slotlocking/lock.png create mode 100644 src/main/resources/assets/notenoughupdates/storage_gui/hotbar_icons.png create mode 100644 src/main/resources/assets/notenoughupdates/storage_gui/storage_gui_0.png create mode 100644 src/main/resources/assets/notenoughupdates/storage_gui/storage_gui_1.png create mode 100644 src/main/resources/assets/notenoughupdates/storage_gui/storage_gui_2.png create mode 100644 src/main/resources/assets/notenoughupdates/storage_gui/storage_gui_3.png create mode 100644 src/main/resources/assets/notenoughupdates/storage_gui/storage_icons.png create mode 100644 src/main/resources/assets/notenoughupdates/storage_gui/storage_preview_0.png create mode 100644 src/main/resources/assets/notenoughupdates/storage_gui/storage_preview_1.png create mode 100644 src/main/resources/assets/notenoughupdates/storage_gui/storage_preview_2.png create mode 100644 src/main/resources/assets/notenoughupdates/storage_gui/storage_preview_3.png create mode 100644 src/main/resources/assets/notenoughupdates/test.gif create mode 100644 src/main/resources/notenoughupdates_at.cfg diff --git a/build.gradle b/build.gradle index 4662310d..d51e2f77 100644 --- a/build.gradle +++ b/build.gradle @@ -1,13 +1,19 @@ buildscript { + repositories { jcenter() - maven { url = "https://files.minecraftforge.net/maven" } + maven { + name 'JitPack' + url 'https://jitpack.io' + } + maven { url = "https://maven.minecraftforge.net/" } maven { url = "https://repo.spongepowered.org/maven" } } dependencies { - classpath 'net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT' - classpath 'org.spongepowered:mixingradle:0.6-SNAPSHOT' - classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4' + classpath "com.github.Skytils:ForgeGradle:86b23926f3" + classpath "com.github.Skytils:mixingradle:d75e32e743" + classpath 'com.github.LxGaming:MixinGradle:0.6-SNAPSHOT' + classpath 'com.github.jengelman.gradle.plugins:shadow:6.1.0' } } @@ -41,8 +47,7 @@ repositories { dependencies { compile('org.spongepowered:mixin:0.7.11-SNAPSHOT') - //compile('org.kohsuke:github-api:1.108') - //compile('org.eclipse.jgit:org.eclipse.jgit:5.7.0.202003110725-r') + annotationProcessor('org.spongepowered:mixin:0.7.11-SNAPSHOT') compile('com.fasterxml.jackson.core:jackson-core:2.10.2') compile('info.bliki.wiki:bliki-core:3.1.0') implementation name: 'Morus-1.0' @@ -58,7 +63,8 @@ jar { 'TweakClass': 'org.spongepowered.asm.launch.MixinTweaker', 'MixinConfigs': "mixins.${modid}.json", 'FMLCorePluginContainsFMLMod': true, - "ForceLoadAsMod": true + "ForceLoadAsMod": true, + "FMLAT": 'notenoughupdates_at.cfg' ) } @@ -96,22 +102,8 @@ reobf { } } - -task runClientFix { - doLast { - String fileName = "${archivesBaseName}-${version}-${mixinClassifier}.jar" - ant.move file: "${buildDir}/libs/${fileName}", tofile: "${projectDir}/run/mods/${fileName}" - ant.delete file: "${buildDir}/libs/${archivesBaseName}-${version}.jar" - } -} - -runClient { - standardInput = System.in -} - build.dependsOn(shadowJar) runClient.dependsOn(build) -runClient.dependsOn(runClientFix) processResources { @@ -126,4 +118,15 @@ processResources from(sourceSets.main.resources.srcDirs) { exclude 'mcmod.info' } + + rename '(.+_at.cfg)', 'META-INF/$1' +} + +task moveResources { + doLast { + ant.move file: "${buildDir}/resources/main", + todir: "${buildDir}/classes/java" + } } +moveResources.dependsOn processResources +classes.dependsOn moveResources diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 671daab2..c1ff7937 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java index 8219c903..081a0c1d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java @@ -17,7 +17,6 @@ import io.github.moulberry.notenoughupdates.dungeons.DungeonWin; import io.github.moulberry.notenoughupdates.gamemodes.SBGamemodes; import io.github.moulberry.notenoughupdates.miscfeatures.*; import io.github.moulberry.notenoughupdates.miscgui.*; -import io.github.moulberry.notenoughupdates.mixins.GuiContainerAccessor; import io.github.moulberry.notenoughupdates.options.NEUConfig; import io.github.moulberry.notenoughupdates.overlays.*; import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer; @@ -157,12 +156,57 @@ public class NEUEventListener { private final ExecutorService itemPreloader = Executors.newFixedThreadPool(10); private final List toPreload = new ArrayList<>(); + private int inventoryLoadedTicks = 0; + private String loadedInvName = ""; + public static boolean inventoryLoaded = false; + @SubscribeEvent public void onTick(TickEvent.ClientTickEvent event) { if(event.phase != TickEvent.Phase.START) return; if(Minecraft.getMinecraft().theWorld == null) return; if(Minecraft.getMinecraft().thePlayer == null) return; + if(Minecraft.getMinecraft().currentScreen instanceof GuiChest) { + GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen; + ContainerChest cc = (ContainerChest) chest.inventorySlots; + + if(!loadedInvName.equals(cc.getLowerChestInventory().getDisplayName().getUnformattedText())) { + loadedInvName = cc.getLowerChestInventory().getDisplayName().getUnformattedText(); + inventoryLoaded = false; + inventoryLoadedTicks = 3; + } + + if(!inventoryLoaded) { + if(cc.getLowerChestInventory().getStackInSlot(cc.getLowerChestInventory().getSizeInventory()-1) != null) { + inventoryLoaded = true; + } else { + for(ItemStack stack : chest.inventorySlots.getInventory()) { + if(stack != null) { + if(--inventoryLoadedTicks <= 0) { + inventoryLoaded = true; + } + break; + } + } + } + } + } else { + inventoryLoaded = false; + inventoryLoadedTicks = 3; + } + + if(Keyboard.isKeyDown(Keyboard.KEY_NUMPAD1) && Keyboard.isKeyDown(Keyboard.KEY_NUMPAD4) && Keyboard.isKeyDown(Keyboard.KEY_NUMPAD9)) { + ChatComponentText component = new ChatComponentText("\u00a7cYou are permanently banned from this server!"); + component.appendText("\n"); + component.appendText("\n\u00a77Reason: \u00a7rSuspicious account activity/Other"); + 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; + } + if(neu.hasSkyblockScoreboard()) { if(!preloadedItems) { preloadedItems = true; @@ -194,17 +238,8 @@ public class NEUEventListener { DungeonBlocks.tick(); } DungeonWin.tick(); - FlyFix.tick(); - if(longUpdate) { - /*for(Entity entity : Minecraft.getMinecraft().theWorld.loadedEntityList) { - if(entity instanceof EntityArmorStand) { - EntityArmorStand stand = (EntityArmorStand) entity; - stand.setInvisible(false); - stand.getDataWatcher().updateObject(10, (byte)(stand.getDataWatcher().getWatchableObjectByte(10) & 0b1111111101111)); - } - }*/ CrystalOverlay.tick(); DwarvenMinesTextures.tick(); @@ -212,42 +247,15 @@ public class NEUEventListener { XPInformation.getInstance().tick(); ProfileApiSyncer.getInstance().tick(); DamageCommas.tick(); + ItemCustomizeManager.tick(); BackgroundBlur.markDirty(); + NPCRetexturing.getInstance().tick(); if(neu.hasSkyblockScoreboard()) { for(TextOverlay overlay : OverlayManager.textOverlays) { overlay.tick(); } } - if(TradeWindow.hypixelTradeWindowActive()) { - for(int i=0; i<16; i++) { - int x = i % 4; - int y = i / 4; - int containerIndex = y*9+x+5; - - GuiContainer chest = ((GuiContainer)Minecraft.getMinecraft().currentScreen); - - ItemStack stack = chest.inventorySlots.getInventory().get(containerIndex); - if(stack != null && BAD_ITEM_REGEX.matcher(Utils.cleanColour(stack.getDisplayName())).find()) { - Minecraft.getMinecraft().ingameGUI.displayTitle( - null, null, - 4, 200, 4); - Minecraft.getMinecraft().ingameGUI.displayTitle( - null, - EnumChatFormatting.RED+"WARNING: GLITCHED ITEM DETECTED IN TRADE WINDOW. CANCELLING TRADE", - -1, -1, -1); - Minecraft.getMinecraft().ingameGUI.displayTitle( - EnumChatFormatting.RED+"YOU ARE TRADING WITH A SCAMMER!", - null, - -1, -1, -1); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED+ - "WARNING: The person you are trading with just tried to give you a glitched item.\n" + - "The item is NOT worth what they say it is worth.\n" + - "Report this scammer immediately and ignore them!")); - break; - } - } - } NotEnoughUpdates.INSTANCE.overlay.redrawItems(); CapeManager.onTickSlow(); @@ -471,6 +479,8 @@ public class NEUEventListener { } } + public static long lastGuiClosed = 0; + /** * When opening a GuiContainer, will reset the overlay and load the config. * When closing a GuiContainer, will save the config. @@ -492,8 +502,14 @@ public class NEUEventListener { CalendarOverlay.setEnabled(false); } + if(Minecraft.getMinecraft().currentScreen != null) { + lastGuiClosed = System.currentTimeMillis(); + } + neu.manager.auctionManager.customAH.lastGuiScreenSwitch = System.currentTimeMillis(); BetterContainers.reset(); + inventoryLoaded = false; + inventoryLoadedTicks = 3; if(event.gui == null && neu.manager.auctionManager.customAH.isRenderOverAuctionView() && !(Minecraft.getMinecraft().currentScreen instanceof CustomAHGui)) { @@ -762,10 +778,10 @@ public class NEUEventListener { if(event.gui instanceof GuiContainer) { try { - int xSize = ((GuiContainerAccessor)event.gui).getXSize(); - int ySize = ((GuiContainerAccessor)event.gui).getYSize(); - int guiLeft = ((GuiContainerAccessor)event.gui).getGuiLeft(); - int guiTop = ((GuiContainerAccessor)event.gui).getGuiTop(); + int xSize = ((GuiContainer)event.gui).xSize; + int ySize = ((GuiContainer)event.gui).ySize; + int guiLeft = ((GuiContainer)event.gui).guiLeft; + int guiTop = ((GuiContainer)event.gui).guiTop; hoverInv = event.getMouseX() > guiLeft && event.getMouseX() < guiLeft + xSize && event.getMouseY() > guiTop && event.getMouseY() < guiTop + ySize; @@ -824,8 +840,25 @@ public class NEUEventListener { return; } - if(TradeWindow.tradeWindowActive() || - event.gui instanceof CustomAHGui || neu.manager.auctionManager.customAH.isRenderOverAuctionView()) { + String containerName = null; + GuiScreen guiScreen = Minecraft.getMinecraft().currentScreen; + if(guiScreen instanceof GuiChest) { + GuiChest eventGui = (GuiChest) guiScreen; + ContainerChest cc = (ContainerChest) eventGui.inventorySlots; + containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText(); + } + + boolean tradeWindowActive = TradeWindow.tradeWindowActive(containerName); + boolean storageOverlayActive = StorageManager.getInstance().shouldRenderStorageOverlay(containerName); + boolean customAhActive = event.gui instanceof CustomAHGui || neu.manager.auctionManager.customAH.isRenderOverAuctionView(); + + if(storageOverlayActive) { + StorageOverlay.getInstance().render(); + event.setCanceled(true); + return; + } + + if(tradeWindowActive || customAhActive) { event.setCanceled(true); ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); @@ -836,17 +869,17 @@ public class NEUEventListener { Utils.drawGradientRect(0, 0, width, height, -1072689136, -804253680); if(event.mouseX < width*neu.overlay.getWidthMult()/3 || event.mouseX > width-width*neu.overlay.getWidthMult()/3) { - if(event.gui instanceof CustomAHGui || neu.manager.auctionManager.customAH.isRenderOverAuctionView()) { + if(customAhActive) { neu.manager.auctionManager.customAH.drawScreen(event.mouseX, event.mouseY); - } else { + } else if(tradeWindowActive) { TradeWindow.render(event.mouseX, event.mouseY); } neu.overlay.render(false); } else { neu.overlay.render(false); - if(event.gui instanceof CustomAHGui || neu.manager.auctionManager.customAH.isRenderOverAuctionView()) { + if(customAhActive) { neu.manager.auctionManager.customAH.drawScreen(event.mouseX, event.mouseY); - } else { + } else if(tradeWindowActive) { TradeWindow.render(event.mouseX, event.mouseY); } } @@ -861,10 +894,10 @@ public class NEUEventListener { GlStateManager.translate(0, 0, zOffset); - int xSize = ((GuiContainerAccessor)event.gui).getXSize(); - int ySize = ((GuiContainerAccessor)event.gui).getYSize(); - int guiLeft = ((GuiContainerAccessor)event.gui).getGuiLeft(); - int guiTop = ((GuiContainerAccessor)event.gui).getGuiTop(); + int xSize = ((GuiContainer)event.gui).xSize; + int ySize = ((GuiContainer)event.gui).ySize; + int guiLeft = ((GuiContainer)event.gui).guiLeft; + int guiTop = ((GuiContainer)event.gui).guiTop; for(NEUConfig.InventoryButton button : NotEnoughUpdates.INSTANCE.config.hidden.inventoryButtons) { if(!button.isActive()) continue; @@ -924,8 +957,19 @@ public class NEUEventListener { drawingGuiScreen = false; disableCraftingText = false; - if(!(TradeWindow.tradeWindowActive() || event.gui instanceof CustomAHGui || - neu.manager.auctionManager.customAH.isRenderOverAuctionView())) { + String containerName = null; + GuiScreen guiScreen = Minecraft.getMinecraft().currentScreen; + if(guiScreen instanceof GuiChest) { + GuiChest eventGui = (GuiChest) guiScreen; + ContainerChest cc = (ContainerChest) eventGui.inventorySlots; + containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText(); + } + + boolean tradeWindowActive = TradeWindow.tradeWindowActive(containerName); + boolean storageOverlayActive = StorageManager.getInstance().shouldRenderStorageOverlay(containerName); + boolean customAhActive = event.gui instanceof CustomAHGui || neu.manager.auctionManager.customAH.isRenderOverAuctionView(); + + if(!(tradeWindowActive || storageOverlayActive || customAhActive)) { if(shouldRenderOverlay(event.gui) && neu.isOnSkyblock()) { GlStateManager.pushMatrix(); if(!focusInv) { @@ -948,10 +992,10 @@ public class NEUEventListener { if(!doInventoryButtons) return; if(NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && shouldRenderOverlay(event.gui) && event.gui instanceof GuiContainer) { - int xSize = ((GuiContainerAccessor)event.gui).getXSize(); - int ySize = ((GuiContainerAccessor)event.gui).getYSize(); - int guiLeft = ((GuiContainerAccessor)event.gui).getGuiLeft(); - int guiTop = ((GuiContainerAccessor)event.gui).getGuiTop(); + int xSize = ((GuiContainer)event.gui).xSize; + int ySize = ((GuiContainer)event.gui).ySize; + int guiLeft = ((GuiContainer)event.gui).guiLeft; + int guiTop = ((GuiContainer)event.gui).guiTop; for(NEUConfig.InventoryButton button : NotEnoughUpdates.INSTANCE.config.hidden.inventoryButtons) { if(!button.isActive()) continue; @@ -1000,10 +1044,10 @@ public class NEUEventListener { if(gui instanceof GuiChest && neu.config.dungeons.profitDisplayLoc != 2) { try { - int xSize = ((GuiContainerAccessor)gui).getXSize(); - int ySize = ((GuiContainerAccessor)gui).getYSize(); - int guiLeft = ((GuiContainerAccessor)gui).getGuiLeft(); - int guiTop = ((GuiContainerAccessor)gui).getGuiTop(); + int xSize = ((GuiContainer)gui).xSize; + int ySize = ((GuiContainer)gui).ySize; + int guiLeft = ((GuiContainer)gui).guiLeft; + int guiTop = ((GuiContainer)gui).guiTop; GuiChest eventGui = (GuiChest) gui; ContainerChest cc = (ContainerChest) eventGui.inventorySlots; @@ -1210,18 +1254,44 @@ public class NEUEventListener { event.setCanceled(true); return; } - if(TradeWindow.tradeWindowActive() || event.gui instanceof CustomAHGui || - neu.manager.auctionManager.customAH.isRenderOverAuctionView()) { + + + final ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft()); + final int scaledWidth = scaledresolution.getScaledWidth(); + final int scaledHeight = scaledresolution.getScaledHeight(); + int mouseX = Mouse.getX() * scaledWidth / Minecraft.getMinecraft().displayWidth; + int mouseY = scaledHeight - Mouse.getY() * scaledHeight / Minecraft.getMinecraft().displayHeight - 1; + + String containerName = null; + GuiScreen guiScreen = Minecraft.getMinecraft().currentScreen; + if(guiScreen instanceof GuiChest) { + GuiChest eventGui = (GuiChest) guiScreen; + ContainerChest cc = (ContainerChest) eventGui.inventorySlots; + containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText(); + } + + boolean tradeWindowActive = TradeWindow.tradeWindowActive(containerName); + boolean storageOverlayActive = StorageManager.getInstance().shouldRenderStorageOverlay(containerName); + boolean customAhActive = event.gui instanceof CustomAHGui || neu.manager.auctionManager.customAH.isRenderOverAuctionView(); + + if(storageOverlayActive) { + if(StorageOverlay.getInstance().mouseInput(mouseX, mouseY)) { + event.setCanceled(true); + } + return; + } + + if(tradeWindowActive || customAhActive) { event.setCanceled(true); - if(event.gui instanceof CustomAHGui || - neu.manager.auctionManager.customAH.isRenderOverAuctionView()) { + if(customAhActive) { neu.manager.auctionManager.customAH.handleMouseInput(); - } else { + } else if(tradeWindowActive) { TradeWindow.handleMouseInput(); } neu.overlay.mouseInput(); return; } + if(shouldRenderOverlay(event.gui) && neu.isOnSkyblock()) { if(!neu.config.accessoryBag.enableOverlay || !AccessoryBagOverlay.mouseClick()) { if(!(hoverInv && focusInv)) { @@ -1237,16 +1307,10 @@ public class NEUEventListener { if(!doInventoryButtons) return; if(NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && shouldRenderOverlay(event.gui) && Mouse.getEventButton() >= 0 && event.gui instanceof GuiContainer) { - int xSize = ((GuiContainerAccessor)event.gui).getXSize(); - int ySize = ((GuiContainerAccessor)event.gui).getYSize(); - int guiLeft = ((GuiContainerAccessor)event.gui).getGuiLeft(); - int guiTop = ((GuiContainerAccessor)event.gui).getGuiTop(); - - final ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft()); - final int scaledWidth = scaledresolution.getScaledWidth(); - final int scaledHeight = scaledresolution.getScaledHeight(); - int mouseX = Mouse.getX() * scaledWidth / Minecraft.getMinecraft().displayWidth; - int mouseY = scaledHeight - Mouse.getY() * scaledHeight / Minecraft.getMinecraft().displayHeight - 1; + int xSize = ((GuiContainer)event.gui).xSize; + int ySize = ((GuiContainer)event.gui).ySize; + int guiLeft = ((GuiContainer)event.gui).guiLeft; + int guiTop = ((GuiContainer)event.gui).guiTop; for(NEUConfig.InventoryButton button : NotEnoughUpdates.INSTANCE.config.hidden.inventoryButtons) { if(!button.isActive()) continue; @@ -1303,17 +1367,33 @@ public class NEUEventListener { return; } - if(TradeWindow.tradeWindowActive() || event.gui instanceof CustomAHGui || - neu.manager.auctionManager.customAH.isRenderOverAuctionView()) { - if(event.gui instanceof CustomAHGui || - neu.manager.auctionManager.customAH.isRenderOverAuctionView()) { + String containerName = null; + GuiScreen guiScreen = Minecraft.getMinecraft().currentScreen; + if(guiScreen instanceof GuiChest) { + GuiChest eventGui = (GuiChest) guiScreen; + ContainerChest cc = (ContainerChest) eventGui.inventorySlots; + containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText(); + } + + boolean tradeWindowActive = TradeWindow.tradeWindowActive(containerName); + boolean storageOverlayActive = StorageManager.getInstance().shouldRenderStorageOverlay(containerName); + boolean customAhActive = event.gui instanceof CustomAHGui || neu.manager.auctionManager.customAH.isRenderOverAuctionView(); + + if(storageOverlayActive) { + event.setCanceled(true); + StorageOverlay.getInstance().keyboardInput(); + return; + } + + if(tradeWindowActive || customAhActive) { + if(customAhActive) { if(neu.manager.auctionManager.customAH.keyboardInput()) { event.setCanceled(true); Minecraft.getMinecraft().dispatchKeypresses(); } else if(neu.overlay.keyboardInput(focusInv)) { event.setCanceled(true); } - } else { + } else if(tradeWindowActive) { TradeWindow.keyboardInput(); if(Keyboard.getEventKey() != Keyboard.KEY_ESCAPE) { event.setCanceled(true); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java index 4f392ae8..24c90c7b 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java @@ -3,6 +3,8 @@ package io.github.moulberry.notenoughupdates; import com.google.common.collect.Lists; import com.google.gson.*; import io.github.moulberry.notenoughupdates.auction.APIManager; +import io.github.moulberry.notenoughupdates.miscfeatures.StorageManager; +import io.github.moulberry.notenoughupdates.miscgui.GuiItemCustomize; import io.github.moulberry.notenoughupdates.miscgui.GuiItemRecipe; import io.github.moulberry.notenoughupdates.util.Constants; import io.github.moulberry.notenoughupdates.util.HypixelApi; @@ -73,8 +75,6 @@ public class NEUManager { public File configLocation; public File repoLocation; public File configFile; - public File itemRenameFile; - public JsonObject itemRenameJson; public NEUManager(NotEnoughUpdates neu, File configLocation) { this.neu = neu; @@ -85,12 +85,6 @@ public class NEUManager { this.repoLocation = new File(configLocation, "repo"); repoLocation.mkdir(); - - this.itemRenameFile = new File(configLocation, "itemRename.json"); - itemRenameJson = getJsonFromFile(itemRenameFile); - if(itemRenameJson == null) { - itemRenameJson = new JsonObject(); - } } public void setCurrentProfile(String currentProfile) { @@ -101,10 +95,6 @@ public class NEUManager { return SBInfo.getInstance().currentProfile; } - public void saveItemRenameConfig() { - try { writeJson(itemRenameJson, itemRenameFile); } catch(IOException ignored) {} - } - /** * Parses a file in to a JsonObject. */ diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java index d11d21fa..8df3f0eb 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java @@ -1111,11 +1111,15 @@ public class NEUOverlay extends Gui { float cost1 = manager.auctionManager.getLowestBin(o1.get("internalname").getAsString()); float cost2 = manager.auctionManager.getLowestBin(o2.get("internalname").getAsString()); - if(cost1 == -1) cost1 = manager.auctionManager.getCraftCost(o1.get("internalname").getAsString()).craftCost; - if(cost2 == -1) cost2 = manager.auctionManager.getCraftCost(o2.get("internalname").getAsString()).craftCost; + float craftCost1 = manager.auctionManager.getCraftCost(o1.get("internalname").getAsString()).craftCost; + float craftCost2 = manager.auctionManager.getCraftCost(o2.get("internalname").getAsString()).craftCost; - if(cost1 < cost2) return mult; - if(cost1 > cost2) return -mult; + float diff = (cost1 - craftCost1) - (cost2 - craftCost2); + + if(diff > 0) return mult; + if(diff < 0) return -mult; + /*if(cost1 < cost2) return mult; + if(cost1 > cost2) return -mult;*/ } String i1 = o1.get("internalname").getAsString(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index 2da79f84..8e0c1444 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -9,6 +9,7 @@ import io.github.moulberry.notenoughupdates.auction.CustomAHGui; import io.github.moulberry.notenoughupdates.commands.SimpleCommand; import io.github.moulberry.notenoughupdates.core.BackgroundBlur; import io.github.moulberry.notenoughupdates.core.GuiScreenElementWrapper; +import io.github.moulberry.notenoughupdates.core.util.MiscUtils; import io.github.moulberry.notenoughupdates.cosmetics.CapeManager; import io.github.moulberry.notenoughupdates.cosmetics.GuiCosmetics; import io.github.moulberry.notenoughupdates.dungeons.DungeonMap; @@ -32,6 +33,7 @@ import io.github.moulberry.notenoughupdates.util.Utils; import io.github.moulberry.notenoughupdates.util.XPInformation; import net.minecraft.block.material.MapColor; import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.inventory.GuiContainer; @@ -42,7 +44,6 @@ import net.minecraft.client.settings.KeyBinding; import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.event.ClickEvent; -import net.minecraft.event.HoverEvent; import net.minecraft.item.ItemMap; import net.minecraft.item.ItemStack; import net.minecraft.scoreboard.ScoreObjective; @@ -62,7 +63,6 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.text.WordUtils; -import org.apache.commons.lang3.text.translate.UnicodeUnescaper; import org.lwjgl.opengl.Display; import org.lwjgl.opengl.GL11; @@ -147,7 +147,7 @@ public class NotEnoughUpdates { } }); - SimpleCommand itemRenameCommand = new SimpleCommand("neurename", new SimpleCommand.ProcessCommandRunnable() { + /*SimpleCommand itemRenameCommand = new SimpleCommand("neurename", new SimpleCommand.ProcessCommandRunnable() { public void processCommand(ICommandSender sender, String[] args) { if(args.length == 0) { args = new String[]{"help"}; @@ -230,7 +230,7 @@ public class NotEnoughUpdates { } } - }); + });*/ SimpleCommand gamemodesCommand = new SimpleCommand("neugamemodes", new SimpleCommand.ProcessCommandRunnable() { public void processCommand(ICommandSender sender, String[] args) { @@ -559,6 +559,7 @@ public class NotEnoughUpdates { builder.append("[API Key]").append("[").append(!config.apiKey.apiKey.isEmpty()).append("]").append("\n"); builder.append("[On Skyblock]").append("[").append(hasSkyblockScoreboard).append("]").append("\n"); builder.append("[Mod Version]").append("[").append(Loader.instance().getIndexedModList().get(MODID).getSource().getName()).append("]").append("\n"); + builder.append("[SB Profile]").append("[").append(SBInfo.getInstance().currentProfile).append("]").append("\n"); builder.append("# Repo Stats").append("\n"); builder.append("[Last Commit]").append("[").append(manager.latestRepoCommit).append("]").append("\n"); builder.append("[Loaded Items]").append("[").append(manager.getItemInformation().size()).append("]").append("\n"); @@ -709,7 +710,7 @@ public class NotEnoughUpdates { "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.", "Dammit. I thought that would work. Uhh...", - "\u00a7dFrom \u00a7c[ADMIN] Minikloon\u00a77: If you use that command again, I'll have to ban you", + "\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; SimpleCommand devTestCommand = new SimpleCommand("neudevtest", new SimpleCommand.ProcessCommandRunnable() { @@ -724,6 +725,19 @@ public class NotEnoughUpdates { } }; } + if(devFailIndex == devFailStrings.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; + } Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED+devFailStrings[devFailIndex++])); return; } @@ -750,6 +764,28 @@ public class NotEnoughUpdates { SimpleCommand packDevCommand = new SimpleCommand("neupackdev", new SimpleCommand.ProcessCommandRunnable() { @Override public void processCommand(ICommandSender sender, String[] args) { + if(args.length == 1 && args[0].equalsIgnoreCase("getnpc")) { + double distSq = 25; + EntityPlayer closestNPC = null; + EntityPlayerSP p = Minecraft.getMinecraft().thePlayer; + for(EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) { + if(player instanceof AbstractClientPlayer && p != player && player.getUniqueID().version() != 4) { + double dSq = player.getDistanceSq(p.posX, p.posY, p.posZ); + if(dSq < distSq) { + distSq = dSq; + closestNPC = player; + } + } + } + + if(closestNPC == null) { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED+"No NPCs found within 5 blocks :(")); + } else { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN+"Copied entity texture id to clipboard")); + MiscUtils.copyToClipboard(((AbstractClientPlayer)closestNPC).getLocationSkin().getResourcePath().replace("skins/", "")); + } + return; + } packDevEnabled = !packDevEnabled; if(packDevEnabled) { Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN+"Enabled pack developer mode.")); @@ -942,6 +978,26 @@ public class NotEnoughUpdates { } }); + SimpleCommand customizeCommand = new SimpleCommand("neucustomize", new SimpleCommand.ProcessCommandRunnable() { + public void processCommand(ICommandSender sender, String[] args) { + ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem(); + + if(held == null) { + sender.addChatMessage(new ChatComponentText("\u00a7cYou can't customize your hand...")); + return; + } + + String heldUUID = manager.getUUIDForItem(held); + + if(heldUUID == null) { + sender.addChatMessage(new ChatComponentText("\u00a7cHeld item does not have UUID, cannot be customized")); + return; + } + + openGui = new GuiItemCustomize(held, heldUUID); + } + }); + SimpleCommand.ProcessCommandRunnable settingsRunnable = new SimpleCommand.ProcessCommandRunnable() { public void processCommand(ICommandSender sender, String[] args) { if(args.length > 0) { @@ -992,6 +1048,8 @@ public class NotEnoughUpdates { */ @EventHandler public void preinit(FMLPreInitializationEvent event) { + //if(!Minecraft.getMinecraft().getSession().getUsername().equalsIgnoreCase("moulberry")) throw new RuntimeException("moulbeBad"); + INSTANCE = this; String uuid = Minecraft.getMinecraft().getSession().getPlayerID(); @@ -1008,7 +1066,10 @@ public class NotEnoughUpdates { } catch(Exception e) { } } + ItemCustomizeManager.loadCustomization(new File(neuDir, "itemCustomization.json")); + StorageManager.getInstance().loadConfig(new File(neuDir, "storageItems.json")); FairySouls.load(new File(neuDir, "collected_fairy_souls.json"), gson); + PetInfoOverlay.loadConfig(new File(neuDir, "petCache.json")); if(config == null) { config = new NEUConfig(); @@ -1036,9 +1097,13 @@ public class NotEnoughUpdates { MinecraftForge.EVENT_BUS.register(OverlayManager.petInfoOverlay); MinecraftForge.EVENT_BUS.register(OverlayManager.timersOverlay); MinecraftForge.EVENT_BUS.register(new NullzeeSphere()); + MinecraftForge.EVENT_BUS.register(InventoryStorageSelector.getInstance()); + MinecraftForge.EVENT_BUS.register(SlotLocking.getInstance()); if(Minecraft.getMinecraft().getResourceManager() instanceof IReloadableResourceManager) { ((IReloadableResourceManager)Minecraft.getMinecraft().getResourceManager()).registerReloadListener(CustomSkulls.getInstance()); + ((IReloadableResourceManager)Minecraft.getMinecraft().getResourceManager()).registerReloadListener(NPCRetexturing.getInstance()); + ((IReloadableResourceManager)Minecraft.getMinecraft().getResourceManager()).registerReloadListener(new ItemCustomizeManager.ReloadListener()); } ClientCommandHandler.instance.registerCommand(collectionLogCommand); @@ -1049,12 +1114,13 @@ public class NotEnoughUpdates { ClientCommandHandler.instance.registerCommand(buttonsCommand); ClientCommandHandler.instance.registerCommand(resetRepoCommand); ClientCommandHandler.instance.registerCommand(reloadRepoCommand); - ClientCommandHandler.instance.registerCommand(itemRenameCommand); + //ClientCommandHandler.instance.registerCommand(itemRenameCommand); ClientCommandHandler.instance.registerCommand(joinDungeonCommand); ClientCommandHandler.instance.registerCommand(viewProfileCommand); ClientCommandHandler.instance.registerCommand(viewProfileShortCommand); ClientCommandHandler.instance.registerCommand(dhCommand); ClientCommandHandler.instance.registerCommand(dnCommand); + ClientCommandHandler.instance.registerCommand(customizeCommand); ClientCommandHandler.instance.registerCommand(devTestCommand); ClientCommandHandler.instance.registerCommand(packDevCommand); if(!Loader.isModLoaded("skyblockextras")) ClientCommandHandler.instance.registerCommand(viewCataCommand); @@ -1091,7 +1157,7 @@ public class NotEnoughUpdates { } tmp.delete(); } - saveConfig(); + //saveConfig(); })); } @@ -1102,9 +1168,12 @@ public class NotEnoughUpdates { try(BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(configFile), StandardCharsets.UTF_8))) { writer.write(gson.toJson(config)); } + } catch(Exception ignored) {} - FairySouls.save(new File(neuDir, "collected_fairy_souls.json"), gson); - } catch(IOException ignored) {} + try { ItemCustomizeManager.saveCustomization(new File(neuDir, "itemCustomization.json")); } catch(Exception ignored) {} + try { StorageManager.getInstance().saveConfig(new File(neuDir, "storageItems.json")); } catch(Exception ignored) {} + try { FairySouls.save(new File(neuDir, "collected_fairy_souls.json"), gson); } catch(Exception ignored) {} + try { PetInfoOverlay.saveConfig(new File(neuDir, "petCache.json")); } catch(Exception ignored) {} } /** @@ -1167,6 +1236,11 @@ public class NotEnoughUpdates { @SubscribeEvent public void onTick(TickEvent.ClientTickEvent event) { if (event.phase != TickEvent.Phase.START) return; + if(Minecraft.getMinecraft().thePlayer == null) { + openGui = null; + currChatMessage = null; + return; + } long currentTime = System.currentTimeMillis(); if (openGui != null) { 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 93887e23..f896f1c2 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java @@ -761,6 +761,7 @@ public class APIManager { ci.vanillaItem = isVanillaItem(internalname); JsonObject auctionInfo = getItemAuctionInfo(internalname); + float lowestBin = getLowestBin(internalname); JsonObject bazaarInfo = getBazaarInfo(internalname); if(bazaarInfo != null && bazaarInfo.get("curr_buy") != null) { @@ -768,7 +769,11 @@ public class APIManager { ci.craftCost = bazaarInstantBuyPrice; } //Don't use auction prices for vanilla items cuz people like to transfer money, messing up the cost of vanilla items. - if(auctionInfo != null && !ci.vanillaItem) { + if(lowestBin > 0 && !ci.vanillaItem) { + if(ci.craftCost < 0 || lowestBin < ci.craftCost) { + ci.craftCost = lowestBin; + } + } else if(auctionInfo != null && !ci.vanillaItem) { float auctionPrice = auctionInfo.get("price").getAsFloat() / auctionInfo.get("count").getAsFloat(); if(ci.craftCost < 0 || auctionPrice < ci.craftCost) { ci.craftCost = auctionPrice; 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 8de2205d..fb75ea23 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementColour.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementColour.java @@ -32,8 +32,8 @@ public class GuiElementColour extends GuiElement { private int x; private int y; - private final int xSize = 119; - private final int ySize = 89; + private int xSize = 119; + private int ySize = 89; private float wheelAngle = 0; private float wheelRadius = 0; @@ -44,9 +44,16 @@ public class GuiElementColour extends GuiElement { private Runnable closeCallback; private String colour; + private final boolean opacitySlider; + private final boolean valueSlider; + public GuiElementColour(int x, int y, String initialColour, Consumer colourChangedCallback, Runnable closeCallback) { + this(x, y, initialColour, colourChangedCallback, closeCallback, true, true); + } + public GuiElementColour(int x, int y, String initialColour, Consumer colourChangedCallback, + Runnable closeCallback, boolean opacitySlider, boolean valueSlider) { final ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); this.y = Math.max(10, Math.min(scaledResolution.getScaledHeight()-ySize-10, y)); @@ -60,6 +67,12 @@ public class GuiElementColour extends GuiElement { Color c = new Color(colour); float[] hsv = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null); updateAngleAndRadius(hsv); + + this.opacitySlider = opacitySlider; + this.valueSlider = valueSlider; + + if(!valueSlider) xSize -= 15; + if(!opacitySlider) xSize -= 15; } public void updateAngleAndRadius(float[] hsv) { @@ -127,19 +140,29 @@ public class GuiElementColour extends GuiElement { int selx = (int)(Math.cos(Math.toRadians(wheelAngle))*selradius); int sely = (int)(Math.sin(Math.toRadians(wheelAngle))*selradius); - Minecraft.getMinecraft().getTextureManager().bindTexture(colour_selector_bar_alpha); - GlStateManager.color(1, 1, 1, 1); - RenderUtils.drawTexturedRect(x+5+64+5+10+5, y+5, 10, 64, GL11.GL_NEAREST); + int valueOffset = 0; + if(valueSlider) { + valueOffset = 15; - Minecraft.getMinecraft().getTextureManager().loadTexture(colourPickerBarValueLocation, new DynamicTexture(bufferedImageValue)); - Minecraft.getMinecraft().getTextureManager().bindTexture(colourPickerBarValueLocation); - GlStateManager.color(1, 1, 1, 1); - RenderUtils.drawTexturedRect(x+5+64+5, y+5, 10, 64, GL11.GL_NEAREST); + Minecraft.getMinecraft().getTextureManager().loadTexture(colourPickerBarValueLocation, new DynamicTexture(bufferedImageValue)); + Minecraft.getMinecraft().getTextureManager().bindTexture(colourPickerBarValueLocation); + GlStateManager.color(1, 1, 1, 1); + RenderUtils.drawTexturedRect(x+5+64+5, y+5, 10, 64, GL11.GL_NEAREST); + } - Minecraft.getMinecraft().getTextureManager().loadTexture(colourPickerBarOpacityLocation, new DynamicTexture(bufferedImageOpacity)); - Minecraft.getMinecraft().getTextureManager().bindTexture(colourPickerBarOpacityLocation); - GlStateManager.color(1, 1, 1, 1); - RenderUtils.drawTexturedRect(x+5+64+5+10+5, y+5, 10, 64, GL11.GL_NEAREST); + int opacityOffset = 0; + if(opacitySlider) { + opacityOffset = 15; + + Minecraft.getMinecraft().getTextureManager().bindTexture(colour_selector_bar_alpha); + GlStateManager.color(1, 1, 1, 1); + RenderUtils.drawTexturedRect(x+5+64+5+valueOffset, y+5, 10, 64, GL11.GL_NEAREST); + + Minecraft.getMinecraft().getTextureManager().loadTexture(colourPickerBarOpacityLocation, new DynamicTexture(bufferedImageOpacity)); + Minecraft.getMinecraft().getTextureManager().bindTexture(colourPickerBarOpacityLocation); + GlStateManager.color(1, 1, 1, 1); + RenderUtils.drawTexturedRect(x+5+64+5+valueOffset, y+5, 10, 64, GL11.GL_NEAREST); + } int chromaSpeed = ChromaColour.getSpeed(colour); int currentColourChroma = ChromaColour.specialToChromaRGB(colour); @@ -147,35 +170,35 @@ public class GuiElementColour extends GuiElement { float hsvChroma[] = Color.RGBtoHSB(cChroma.getRed(), cChroma.getGreen(), cChroma.getBlue(), null); if(chromaSpeed > 0) { - Gui.drawRect(x+5+64+5+10+5+10+5+1, y+5+1, - x+5+64+5+10+5+10+5+10-1, y+5+64-1, + Gui.drawRect(x+5+64+valueOffset+opacityOffset+5+1, y+5+1, + x+5+64+valueOffset+opacityOffset+5+10-1, y+5+64-1, Color.HSBtoRGB(hsvChroma[0], 0.8f, 0.8f)); } else { - Gui.drawRect(x+5+64+5+10+5+10+5+1, y+5+27+1, - x+5+64+5+10+5+10+5+10-1, y+5+37-1, + Gui.drawRect(x+5+64+valueOffset+opacityOffset+5+1, y+5+27+1, + x+5+64+valueOffset+opacityOffset+5+10-1, y+5+37-1, Color.HSBtoRGB((hsvChroma[0]+(System.currentTimeMillis()-ChromaColour.startTime)/1000f)%1, 0.8f, 0.8f)); } Minecraft.getMinecraft().getTextureManager().bindTexture(colour_selector_bar); GlStateManager.color(1, 1, 1, 1); - RenderUtils.drawTexturedRect(x+5+64+5, y+5, 10, 64, GL11.GL_NEAREST); - RenderUtils.drawTexturedRect(x+5+64+5+10+5, y+5, 10, 64, GL11.GL_NEAREST); + if(valueSlider) RenderUtils.drawTexturedRect(x+5+64+5, y+5, 10, 64, GL11.GL_NEAREST); + if(opacitySlider) RenderUtils.drawTexturedRect(x+5+64+5+valueOffset, y+5, 10, 64, GL11.GL_NEAREST); if(chromaSpeed > 0) { - RenderUtils.drawTexturedRect(x+5+64+5+10+5+10+5, y+5, 10, 64, GL11.GL_NEAREST); + RenderUtils.drawTexturedRect(x+5+64+valueOffset+opacityOffset+5, y+5, 10, 64, GL11.GL_NEAREST); } else { Minecraft.getMinecraft().getTextureManager().bindTexture(colour_selector_chroma); - RenderUtils.drawTexturedRect(x+5+64+5+10+5+10+5, y+5+27, 10, 10, GL11.GL_NEAREST); + RenderUtils.drawTexturedRect(x+5+64+valueOffset+opacityOffset+5, y+5+27, 10, 10, GL11.GL_NEAREST); } - Gui.drawRect(x+5+64+5, y+5+64-(int)(64*hsv[2]), - x+5+64+5+10, y+5+64-(int)(64*hsv[2])+1, 0xFF000000); - Gui.drawRect(x+5+64+5+10+5, y+5+64-c.getAlpha()/4, - x+5+64+5+10+5+10, y+5+64-c.getAlpha()/4-1, 0xFF000000); + if(valueSlider) Gui.drawRect(x+5+64+5, y+5+64-(int)(64*hsv[2]), + x+5+64+valueOffset, y+5+64-(int)(64*hsv[2])+1, 0xFF000000); + if(opacitySlider) Gui.drawRect(x+5+64+5+valueOffset, y+5+64-c.getAlpha()/4, + x+5+64+valueOffset+opacityOffset, y+5+64-c.getAlpha()/4-1, 0xFF000000); if(chromaSpeed > 0) { - Gui.drawRect(x+5+64+5+10+5+10+5, + Gui.drawRect(x+5+64+valueOffset+opacityOffset+5, y+5+64-(int)(chromaSpeed/255f*64), - x+5+64+5+10+5+10+5+10, + x+5+64+valueOffset+opacityOffset+5+10, y+5+64-(int)(chromaSpeed/255f*64)+1, 0xFF000000); } @@ -191,14 +214,16 @@ public class GuiElementColour extends GuiElement { 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); - TextRenderUtils.drawStringCenteredScaledMaxWidth(EnumChatFormatting.GRAY.toString()+Math.round(c.getAlpha()/255f*100)+"", - Minecraft.getMinecraft().fontRendererObj, - x+5+64+5+15+5, 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+15+5, y+5+64+5+5, true, 13, -1); + } if(chromaSpeed > 0) { TextRenderUtils.drawStringCenteredScaledMaxWidth(EnumChatFormatting.GRAY.toString()+ (int)ChromaColour.getSecondsForSpeed(chromaSpeed)+"s", Minecraft.getMinecraft().fontRendererObj, - x+5+64+5+30+6, y+5+64+5+5, true, 13, -1); + x+5+64+5+valueOffset+15+6, y+5+64+5+5, true, 13, -1); } hexField.setSize(48, 10); @@ -250,20 +275,27 @@ public class GuiElementColour extends GuiElement { int xValue = mouseX - (x+5+64+5); int y = mouseY - this.y - 5; + int opacityOffset = opacitySlider ? 15 : 0; + int valueOffset = valueSlider ? 15 : 0; + if(y > -5 && y <= 69) { - if(xValue > 0 && xValue < 10) { - clickedComponent = 1; + if(valueSlider) { + if(xValue > 0 && xValue < 10) { + clickedComponent = 1; + } } - int xOpacity = mouseX - (x+5+64+5+10+5); + if(opacitySlider) { + int xOpacity = mouseX - (x+5+64+5+valueOffset); - if(xOpacity > 0 && xOpacity < 10) { - clickedComponent = 2; + if(xOpacity > 0 && xOpacity < 10) { + clickedComponent = 2; + } } } int chromaSpeed = ChromaColour.getSpeed(colour); - int xChroma = mouseX - (x+5+64+5+10+5+10+5); + int xChroma = mouseX - (x+5+64+valueOffset+opacityOffset+5); if(xChroma > 0 && xChroma < 10) { if(chromaSpeed > 0) { if(y > -5 && y <= 69) { 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 111803e8..965c705d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementTextField.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementTextField.java @@ -16,6 +16,7 @@ import java.util.regex.Pattern; public class GuiElementTextField { + public static final int DISABLE_BG = 0b1000000; public static final int SCALE_TEXT = 0b100000; public static final int NUM_ONLY = 0b10000; public static final int NO_SPACE = 0b01000; @@ -35,6 +36,7 @@ public class GuiElementTextField { private int y; private String prependText = ""; + private int customTextColour = 0xffffffff; private final GuiTextField textField = new GuiTextField(0, Minecraft.getMinecraft().fontRendererObj, 0 , 0, 0, 0); @@ -63,6 +65,10 @@ public class GuiElementTextField { this.customBorderColour = colour; } + public void setCustomTextColour(int colour) { + this.customTextColour = colour; + } + public String getText() { return textField.getText(); } @@ -142,7 +148,7 @@ public class GuiElementTextField { int lineNum = Math.round(((yComp - (searchBarYSize-8)/2))/extraSize); - Pattern patternControlCode = Pattern.compile("(?i)\\u00A7([^\\u00B6])(?!\\u00B6)"); + Pattern patternControlCode = Pattern.compile("(?i)\\u00A7([^\\u00B6]|$)(?!\\u00B6)"); String text = renderText; String textNoColour = renderText; if((options & COLOUR) != 0) { @@ -150,7 +156,11 @@ public class GuiElementTextField { Matcher matcher = patternControlCode.matcher(text); if(!matcher.find() || matcher.groupCount() < 1) break; String code = matcher.group(1); - text = matcher.replaceFirst("\u00A7"+code+"\u00B6"+code); + if(code.isEmpty()) { + text = matcher.replaceFirst("\u00A7r\u00B6"); + } else { + text = matcher.replaceFirst("\u00A7"+code+"\u00B6"+code); + } } } while(true) { @@ -169,7 +179,6 @@ public class GuiElementTextField { } } - String textNC = textNoColour.substring(0, cursorIndex); int colorCodes = org.apache.commons.lang3.StringUtils.countMatches(textNC, "\u00B6"); String line = text.substring(cursorIndex+(((options & COLOUR) != 0)?colorCodes*2:0)).split("\n")[0]; @@ -223,7 +232,7 @@ public class GuiElementTextField { public void keyTyped(char typedChar, int keyCode) { if(focus) { if((options & MULTILINE) != 0) { //Carriage return - Pattern patternControlCode = Pattern.co