aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.editorconfig9
-rw-r--r--.github/workflows/build.yml55
-rwxr-xr-x.github/workflows/send_webhook_update.sh88
-rw-r--r--.gitignore3
-rw-r--r--.idea/codeStyles/Project.xml55
-rw-r--r--.idea/codeStyles/codeStyleConfig.xml5
-rw-r--r--README.md8
-rw-r--r--Update Notes/2.1.md89
-rw-r--r--build.gradle128
-rw-r--r--build.gradle.kts149
-rw-r--r--settings.gradle.kts17
-rw-r--r--src/main/java/NotSkyblockAddonsInstallerFrame.java1307
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/CustomItems.java170
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java556
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUApi.java9
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java5015
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java2900
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java5095
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java700
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java1792
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java3825
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAHGui.java15
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/collectionlog/CollectionConstant.java14
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/collectionlog/GuiCollectionLog.java184
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/ClientCommandBase.java33
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/Commands.java1162
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/ScreenCommand.java26
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/SimpleCommand.java56
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/StatsCommand.java146
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java207
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DungeonWinTestCommand.java23
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/dev/NullzeeSphereCommand.java42
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/dev/PackDevCommand.java59
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/dev/StatsCommand.java181
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/DhCommand.java18
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/DnCommand.java22
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/JoinDungeonCommand.java41
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/MapCommand.java142
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/help/FeaturesCommand.java58
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/help/HelpCommand.java79
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/help/LinksCommand.java34
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/help/SettingsCommand.java34
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/help/StorageViewerWhyCommand.java26
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/misc/AhCommand.java38
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/misc/ButtonsCommand.java16
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/misc/CalendarCommand.java22
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/misc/CollectionLogCommand.java20
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/misc/CosmeticsCommand.java29
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/misc/CustomizeCommand.java130
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/misc/GamemodesCommand.java20
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/profile/CataCommand.java17
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/profile/PeekCommand.java291
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/profile/PvCommand.java22
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/profile/ViewProfileCommand.java83
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/repo/ReloadRepoCommand.java39
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/repo/RepoModeCommand.java23
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/repo/ResetRepoCommand.java18
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/BackgroundBlur.java484
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/ChromaColour.java175
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/GlScissorStack.java134
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/GuiElement.java9
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementBoolean.java221
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementColour.java788
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementTextField.java1162
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/GuiScreenElementWrapper.java51
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/Config.java5
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/GuiPositionEditor.java213
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/KeybindHelper.java79
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/Position.java366
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/PositionNew.java332
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/Category.java5
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigAccordionId.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorAccordion.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorBoolean.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorButton.java5
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorColour.java5
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorDraggableList.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorDropdown.java6
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorFSR.java14
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorKeybind.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorSlider.java8
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorText.java5
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigOption.java7
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditor.java73
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorAccordion.java118
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorBoolean.java61
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorButton.java88
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorColour.java124
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDraggableList.java555
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDropdown.java307
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorFSR.java63
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorKeybind.java133
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorSlider.java243
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorText.java149
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java329
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/struct/ConfigProcessor.java350
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/util/GuiElementSlider.java215
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/util/MiscUtils.java156
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/util/Splitters.java5
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/util/StringUtils.java56
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/util/lerp/LerpUtils.java34
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/util/lerp/LerpingFloat.java127
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/util/lerp/LerpingInteger.java143
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/util/render/RenderUtils.java778
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/util/render/TextRenderUtils.java509
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java688
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeNode.java715
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/cosmetics/GuiCosmetics.java1201
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/cosmetics/NEUCape.java2567
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/cosmetics/ShaderManager.java279
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonBlocks.java513
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java3064
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonWin.java827
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java1496
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/events/NEUEvent.java11
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/events/OnBlockBreakSoundEffect.java40
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/gamemodes/GuiGamemodes.java600
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java644
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/infopanes/CollectionLogInfoPane.java952
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/infopanes/DevInfoPane.java1781
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/infopanes/FlipperInfoPane.java204
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/infopanes/HTMLInfoPane.java723
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/infopanes/InfoPane.java77
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/infopanes/ScrollableInfoPane.java41
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/infopanes/TextInfoPane.java104
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElement.java18
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementButton.java57
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementText.java68
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementTextField.java1012
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/itemeditor/NEUItemEditor.java754
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBAnchorPoint.java93
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBDeserializer.java12
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiElement.java17
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroup.java109
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupAligned.java99
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupFloating.java244
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionBINWarning.java482
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionSortModeWarning.java118
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/BetterContainers.java976
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CollectionLogManager.java64
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java298
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalOverlay.java769
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java2450
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomSkulls.java588
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DamageCommas.java223
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesTextures.java407
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesWaypoints.java429
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/EnchantingSolvers.java1065
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java547
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FancyPortals.java522
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java1160
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java382
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCustomizeManager.java503
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemRarityHalo.java512
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/MiningStuff.java354
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/NPCRetexturing.java119
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/NullzeeSphere.java516
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java2166
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java1240
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StorageManager.java1286
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StreamerMode.java57
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SunTzu.java162
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/CrystalHollowsTextures.java22
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/CustomBiomes.java152
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/CustomBlockSounds.java104
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/DwarvenMinesTextures.java194
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/IslandZoneSubdivider.java7
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/LocationChangeEvent.java13
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/SpecialBlockZone.java67
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java2005
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java2745
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java3449
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java1083
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiInvButtonEditor.java1612
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemCustomize.java785
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemRecipe.java455
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiPriceGraph.java555
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/InventoryStorageSelector.java892
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/KatSitterOverlay.java88
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/NEUOverlayPlacements.java430
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java4201
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java2126
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/tutorials/NeuConfigTutorial.java8
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/tutorials/NeuTutorial.java258
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/tutorials/TutorialBase.java650
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinAbstractClientPlayer.java50
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinContainer.java14
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEffectRenderer.java30
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntity.java24
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityAgeable.java21
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityPlayer.java61
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityPlayerSP.java26
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityRenderer.java269
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiChest.java82
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java547
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiIngame.java67
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiInventory.java16
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiScreen.java11
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinInventoryEffectRenderer.java22
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinInventoryPlayer.java24
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemCameraTransforms.java10
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemRenderer.java29
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemStack.java76
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLayerArmorBase.java87
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLayerCustomHead.java93
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLoadingScreenRenderer.java16
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinMinecraft.java37
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinMouseHelper.java16
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinNetHandlerPlayClient.java154
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinPlayerControllerMP.java34
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRender.java28
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderFish.java274
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderGlobal.java168
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderItem.java409
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderList.java19
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRendererLivingEntity.java40
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTextureManager.java14
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTileEntitySkullRenderer.java28
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTileEntitySpecialRenderer.java43
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinVboRenderList.java17
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinWorld.java43
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinWorldClient.java18
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java1001
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java1543
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/AHGraph.java83
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/AHTweaks.java160
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/AccessoryBag.java14
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ApiKey.java14
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Calendar.java80
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/CustomArmour.java36
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/DungeonMapConfig.java266
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Dungeons.java414
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Enchanting.java350
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Fishing.java400
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ImprovedSBMenu.java72
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/InventoryButtons.java46
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ItemOverlays.java654
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Itemlist.java186
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/LocationEdit.java187
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java1198
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java220
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MiscOverlays.java637
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/NeuAuctionHouse.java66
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Notifications.java44
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/PetOverlay.java158
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SkillOverlays.java351
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SlayerOverlay.java76
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SlotLocking.java127
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/StorageGUI.java486
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Toolbar.java163
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TooltipTweaks.java243
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TradeMenu.java33
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java1107
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/overlays/BonemerangOverlay.java190
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/overlays/CombatSkillOverlay.java258
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/overlays/CraftingOverlay.java118
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/overlays/CrystalHollowOverlay.java836
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/overlays/FarmingOverlay.java759
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/overlays/FishingSkillOverlay.java405
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBar.java311
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java1322
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningSkillOverlay.java361
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/overlays/OverlayManager.java431
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/overlays/RancherBootOverlay.java294
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/overlays/SlayerOverlay.java236
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlay.java323
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlayStyle.java10
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java1197
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java8310
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/Panorama.java300
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java1249
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java2563
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/recipes/CraftingOverlay.java150
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/recipes/CraftingRecipe.java146
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/recipes/ForgeRecipe.java256
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/recipes/Ingredient.java91
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/recipes/NeuRecipe.java52
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/recipes/RecipeGenerator.java192
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/recipes/RecipeSlot.java28
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/recipes/VillagerTradeRecipe.java156
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/AllowEmptyHTMLTag.java112
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java103
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/Debouncer.java34
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/DiscordMarkdownBuilder.java35
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/GuiTextures.java226
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/HastebinUploader.java84
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/HotmInformation.java194
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java301
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/LerpingFloat.java127
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/NEUResourceManager.java50
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/ProfileApiSyncer.java131
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/RequestFocusListener.java111
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/ReverseWorldRenderer.java1091
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java542
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/SpecialColour.java175
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/TexLoc.java90
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java3051
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/XPInformation.java431
-rw-r--r--src/main/resources/assets/notenoughupdates/FSR_do_not_texture_this_please.pngbin0 -> 142 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/armordisplay/armordisplay.pngbin0 -> 1599 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/armordisplay/armordisplay_fsr.pngbin0 -> 267 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/armordisplay/armordisplay_grey.pngbin0 -> 270 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/armordisplay/armordisplay_phq_dark.pngbin0 -> 258 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/armordisplay/armordisplay_transparent.pngbin0 -> 225 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/armordisplay/armordisplay_transparent_pet.pngbin0 -> 1500 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/capes/dg.pngbin0 -> 81534 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/capes/dg_preview.pngbin0 -> 42377 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/capes/furf_preview.pngbin2089 -> 3506 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/capes/space.pngbin866931 -> 922429 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/collectionlog.pngbin12083 -> 0 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/core/bar_1.pngbin0 -> 2095 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/core/bar_2.pngbin0 -> 2095 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/core/bar_3.pngbin0 -> 2095 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/core/bar_on.pngbin0 -> 2095 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/custom_enchant_gui.pngbin5501 -> 4982 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/dreamskin.pngbin0 -> 220 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/groundplane.pngbin40868 -> 0 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/panoramas/crystal_hollows/panorama_0.jpgbin0 -> 117941 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/panoramas/crystal_hollows/panorama_1.jpgbin0 -> 129312 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/panoramas/crystal_hollows/panorama_2.jpgbin0 -> 118567 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/panoramas/crystal_hollows/panorama_3.jpgbin0 -> 129964 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/panoramas/crystal_hollows/panorama_4.jpgbin0 -> 151882 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/panoramas/crystal_hollows/panorama_5.jpgbin0 -> 20266 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/panoramas/mining_3/panorama_0.jpgbin0 -> 106322 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/panoramas/mining_3/panorama_1.jpgbin0 -> 127085 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/panoramas/mining_3/panorama_2.jpgbin0 -> 112627 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/panoramas/mining_3/panorama_3.jpgbin0 -> 139768 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/panoramas/mining_3/panorama_4.jpgbin0 -> 122294 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/panoramas/mining_3/panorama_5.jpgbin0 -> 29041 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/petdisplay/petdisplayarmor.pngbin0 -> 229 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/petdisplay/petdisplayarmor_dark.pngbin0 -> 1738 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/petdisplay/petdisplayarmor_fsr.pngbin0 -> 1734 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/petdisplay/petdisplayarmor_phqdark.pngbin0 -> 1728 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/petdisplay/petdisplayarmor_transparent.pngbin0 -> 1890 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/petdisplay/petdisplaysolo.pngbin0 -> 1743 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/petdisplay/petdisplaysolo_dark.pngbin0 -> 1545 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/petdisplay/petdisplaysolo_fsr.pngbin0 -> 1548 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/petdisplay/petdisplaysolo_phqdark.pngbin0 -> 1537 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/petdisplay/petdisplaysolo_transparent.pngbin0 -> 1720 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/portal_panoramas/nether/pansc-1.pngbin82574 -> 0 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/portal_panoramas/nether/pansc-2.pngbin1228306 -> 0 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/portal_panoramas/nether/pansc-3.pngbin646267 -> 0 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/portal_panoramas/nether/pansc-4.pngbin668239 -> 0 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/portal_panoramas/nether/pansc-5.pngbin531635 -> 0 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/portal_panoramas/nether/pansc-6.pngbin275559 -> 0 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/price_graph_gui/price_information_gui.pngbin0 -> 2079 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/price_graph_gui/price_information_gui_dark.pngbin0 -> 2088 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/price_graph_gui/price_information_gui_fsr.pngbin0 -> 2045 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/price_graph_gui/price_information_gui_phqdark.pngbin0 -> 2091 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/pv_bingo.pngbin0 -> 250 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/pv_mining.pngbin0 -> 4516 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/pv_stranded.pngbin0 -> 242 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/pv_unknown.pngbin0 -> 1814 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/social/twitch.pngbin0 -> 828 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/sounds.json120
-rw-r--r--src/main/resources/assets/notenoughupdates/sounds/gemstoneamberbreak.json1
-rw-r--r--src/main/resources/assets/notenoughupdates/sounds/gemstoneamberbreak.oggbin0 -> 40373 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/sounds/gemstoneamethystbreak.json1
-rw-r--r--src/main/resources/assets/notenoughupdates/sounds/gemstoneamethystbreak.oggbin0 -> 40373 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/sounds/gemstonejadebreak.json1
-rw-r--r--src/main/resources/assets/notenoughupdates/sounds/gemstonejadebreak.oggbin0 -> 40373 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/sounds/gemstonejasperbreak.json1
-rw-r--r--src/main/resources/assets/notenoughupdates/sounds/gemstonejasperbreak.oggbin0 -> 40373 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/sounds/gemstonerubybreak.json1
-rw-r--r--src/main/resources/assets/notenoughupdates/sounds/gemstonerubybreak.oggbin0 -> 40373 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/sounds/gemstonesapphirebreak.json1
-rw-r--r--src/main/resources/assets/notenoughupdates/sounds/gemstonesapphirebreak.oggbin0 -> 40373 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/sounds/gemstonetopazbreak.json1
-rw-r--r--src/main/resources/assets/notenoughupdates/sounds/gemstonetopazbreak.oggbin0 -> 40373 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/sounds/mithrilbreak.json1
-rw-r--r--src/main/resources/assets/notenoughupdates/sounds/mithrilbreak.oggbin0 -> 40373 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/sounds/titaniumbreak.json1
-rw-r--r--src/main/resources/assets/notenoughupdates/sounds/titaniumbreak.oggbin0 -> 40373 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/ss_border.jpgbin14021 -> 0 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/storage_gui/storage_icons.pngbin11843 -> 5046 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/textures/gui/forge_recipe.pngbin0 -> 889 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/textures/gui/villager_recipe.pngbin0 -> 8633 bytes
-rw-r--r--src/main/resources/mixins.notenoughupdates.json73
378 files changed, 73633 insertions, 59694 deletions
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 00000000..7f45d8f6
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,9 @@
+root = true
+
+[*]
+end_of_line = lf
+insert_final_newline = true
+
+[*.{java,kts}]
+indent_style = tab
+tab_width = 2 \ No newline at end of file
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 2df530bf..3b6d0cbd 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -2,13 +2,15 @@ name: Build
on:
push:
- branches: [ master ]
+ branches:
+ - '*'
paths-ignore:
- 'README.md'
- 'LICENSE'
- '.gitignore'
pull_request:
- branches: [ master ]
+ branches:
+ - '*'
paths-ignore:
- 'README.md'
- 'LICENSE'
@@ -16,27 +18,44 @@ on:
workflow_dispatch:
jobs:
build:
-
+ env:
+ GIT_URL: ${{ github.server_url }}/${{ github.repository }}/tree/${{ github.sha }}
+ REF_NAME: ${{ github.ref_name }}
+ WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}
+ ACTOR: ${{ github.actor }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- - name: Set up JDK 1.8
- uses: actions/setup-java@v1
- with:
- java-version: 1.8
- - uses: actions/cache@v2
+ - name: Send discord notification
+ id: sendmsg
+ if: ${{ env.WEBHOOK_URL }}
+ run: |
+ ./.github/workflows/send_webhook_update.sh
+ env:
+ STATUS: WORKING
+ - name: Set up JDK 8
+ uses: actions/setup-java@v2
with:
- path: |
- ~/.gradle/caches
- ~/.gradle/wrapper
- key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
- restore-keys: |
- ${{ runner.os }}-gradle-
- - name: Grant execute permission for gradlew
- run: chmod +x gradlew
+ java-version: 8
+ distribution: zulu
+ cache: gradle
- name: Build with Gradle
- run: ./gradlew build --no-daemon
+ run: chmod +x ./gradlew && ./gradlew setupCIWorkspace build --no-daemon
- uses: actions/upload-artifact@v2
with:
- path: build/libs/*.jar
+ path: build/libs/*-dep.jar
+ - name: Update discord notification
+ if: ${{ env.WEBHOOK_URL && success() }}
+ run: |
+ ./.github/workflows/send_webhook_update.sh
+ env:
+ STATUS: SUCCESS
+ MESSAGE_ID: ${{ steps.sendmsg.outputs.MESSAGE_ID }}
+ - name: Update discord notification
+ if: ${{ env.WEBHOOK_URL && failure() }}
+ run: |
+ ./.github/workflows/send_webhook_update.sh
+ env:
+ STATUS: FAILURE
+ MESSAGE_ID: ${{ steps.sendmsg.outputs.MESSAGE_ID }}
diff --git a/.github/workflows/send_webhook_update.sh b/.github/workflows/send_webhook_update.sh
new file mode 100755
index 00000000..56852159
--- /dev/null
+++ b/.github/workflows/send_webhook_update.sh
@@ -0,0 +1,88 @@
+#!/bin/bash
+set -x
+
+COLOR_SUCCESS=8040199
+COLOR_WORKING=7472302
+COLOR_ERROR=14960972
+case "$STATUS" in
+ WORKING)
+ color="$COLOR_WORKING"
+ status_message="Build started."
+ ;;
+ FAILURE)
+ color="$COLOR_ERROR"
+ status_message="Build failed."
+ ;;
+ SUCCESS)
+ color="$COLOR_SUCCESS"
+ status_message="Build succeeded."
+ to_upload=$(echo build/libs/*-dep.jar)
+ upload_name=NotEnoughUpdates-beta-dep.jar
+ ;;
+esac
+
+author_name="$ACTOR"
+commit_hash=$(git log -1 --pretty=format:'%h')
+commit_subject=$(git log -1 --pretty=format:'%s')
+commit_body=$(git log -1 --pretty=format:'%b')
+commit_date=$(git log -1 --pretty=format:'%ct')
+
+author_avatar="https://github.com/$author_name.png"
+
+#language=json
+read -r -d '' structure <<-"EOF"
+{
+ "content": $status,
+ "username": $username,
+ "avatar_url": $avatar_url,
+ "embeds": [
+ {
+ "color": $color,
+ "url": $url,
+ "title": $subject,
+ "description": $body,
+ "footer": {
+ "text": $ref
+ }
+ }
+ ],
+ "allowed_mentions": {
+ "parse": []
+ }
+}
+EOF
+json=$(jq -n \
+ --arg body "$commit_body" \
+ --arg status "$status_message" \
+ --arg subject "$commit_subject" \
+ --arg username "$author_name" \
+ --arg avatar_url "$author_avatar" \
+ --argjson color "$color" \
+ --arg url "$GIT_URL" \
+ --arg ref "$REF_NAME" \
+ "$structure")
+
+function make_request() {
+ if [ "$to_upload" != "" ]; then
+ upload_arg="-F"
+ fi
+ curl -X $1 -H "Content-Type: multipart/form-data" -F "payload_json=$json" "$upload_arg" "$upload_name=@$to_upload" "$WEBHOOK_URL$2?wait=true"
+}
+
+echo "Should replace message with id: $MESSAGE_ID"
+if [ "$MESSAGE_ID" != "" ]; then
+ discord_output=$(make_request PATCH "/messages/$MESSAGE_ID")
+ RESULT=$?
+else
+ discord_output=$(make_request POST)
+ RESULT=$?
+fi
+
+if [ $RESULT != 0 ]; then
+ echo "$discord_output"
+ exit 1
+fi
+echo "Message sent to discord."
+echo "$discord_output" | jq .
+id_string=$(echo "$discord_output" | jq .id)
+echo "::set-output name=MESSAGE_ID::${id_string//\"/}"
diff --git a/.gitignore b/.gitignore
index e5ac9893..a7b89d94 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,7 +11,8 @@ out
*.ipr
*.iws
*.iml
-.idea
+.idea/*
+!.idea/codeStyles
# gradle
build
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
new file mode 100644
index 00000000..6cedf3ff
--- /dev/null
+++ b/.idea/codeStyles/Project.xml
@@ -0,0 +1,55 @@
+<component name="ProjectCodeStyleConfiguration">
+ <code_scheme name="Project" version="173">
+ <JetCodeStyleSettings>
+ <option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
+ </JetCodeStyleSettings>
+ <codeStyleSettings language="JAVA">
+ <option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" />
+ <option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
+ <option name="KEEP_BLANK_LINES_BETWEEN_PACKAGE_DECLARATION_AND_HEADER" value="1" />
+ <option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" />
+ <option name="ALIGN_MULTILINE_CHAINED_METHODS" value="true" />
+ <option name="CALL_PARAMETERS_WRAP" value="5" />
+ <option name="PREFER_PARAMETERS_WRAP" value="true" />
+ <option name="CALL_PARAMETERS_LPAREN_ON_NEXT_LINE" value="true" />
+ <option name="CALL_PARAMETERS_RPAREN_ON_NEXT_LINE" value="true" />
+ <option name="METHOD_PARAMETERS_WRAP" value="5" />
+ <option name="METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE" value="true" />
+ <option name="METHOD_PARAMETERS_RPAREN_ON_NEXT_LINE" value="true" />
+ <option name="RESOURCE_LIST_WRAP" value="5" />
+ <option name="RESOURCE_LIST_LPAREN_ON_NEXT_LINE" value="true" />
+ <option name="RESOURCE_LIST_RPAREN_ON_NEXT_LINE" value="true" />
+ <option name="EXTENDS_LIST_WRAP" value="1" />
+ <option name="THROWS_LIST_WRAP" value="1" />
+ <option name="EXTENDS_KEYWORD_WRAP" value="1" />
+ <option name="THROWS_KEYWORD_WRAP" value="1" />
+ <option name="METHOD_CALL_CHAIN_WRAP" value="5" />
+ <option name="WRAP_FIRST_METHOD_IN_CALL_CHAIN" value="true" />
+ <option name="BINARY_OPERATION_WRAP" value="1" />
+ <option name="TERNARY_OPERATION_WRAP" value="5" />
+ <option name="TERNARY_OPERATION_SIGNS_ON_NEXT_LINE" value="true" />
+ <option name="KEEP_SIMPLE_METHODS_IN_ONE_LINE" value="true" />
+ <option name="KEEP_SIMPLE_LAMBDAS_IN_ONE_LINE" value="true" />
+ <option name="KEEP_SIMPLE_CLASSES_IN_ONE_LINE" value="true" />
+ <option name="FOR_STATEMENT_WRAP" value="5" />
+ <option name="FOR_STATEMENT_LPAREN_ON_NEXT_LINE" value="true" />
+ <option name="FOR_STATEMENT_RPAREN_ON_NEXT_LINE" value="true" />
+ <option name="ARRAY_INITIALIZER_WRAP" value="5" />
+ <option name="ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE" value="true" />
+ <option name="ARRAY_INITIALIZER_RBRACE_ON_NEXT_LINE" value="true" />
+ <option name="ASSIGNMENT_WRAP" value="1" />
+ <option name="ASSERT_STATEMENT_WRAP" value="5" />
+ <option name="ASSERT_STATEMENT_COLON_ON_NEXT_LINE" value="true" />
+ <option name="ENUM_CONSTANTS_WRAP" value="5" />
+ <indentOptions>
+ <option name="INDENT_SIZE" value="2" />
+ <option name="CONTINUATION_INDENT_SIZE" value="2" />
+ <option name="TAB_SIZE" value="2" />
+ <option name="USE_TAB_CHARACTER" value="true" />
+ </indentOptions>
+ </codeStyleSettings>
+ <codeStyleSettings language="kotlin">
+ <option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
+ </codeStyleSettings>
+ </code_scheme>
+</component> \ No newline at end of file
diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml
new file mode 100644
index 00000000..79ee123c
--- /dev/null
+++ b/.idea/codeStyles/codeStyleConfig.xml
@@ -0,0 +1,5 @@
+<component name="ProjectCodeStyleConfiguration">
+ <state>
+ <option name="USE_PER_PROJECT_SETTINGS" value="true" />
+ </state>
+</component> \ No newline at end of file
diff --git a/README.md b/README.md
index 0b6648c4..2b771bb9 100644
--- a/README.md
+++ b/README.md
@@ -26,9 +26,9 @@
<a href="https://discord.gg/moulberry" target="_blank">
<img src="https://img.shields.io/discord/516977525906341928?label=discord&color=informational&logo=Discord&logoColor=FFFFFF" alt="discord">
</a>
- <!-- patreon -->
- <a href="https://www.patreon.com/moulberry" target="_blank">
- <img src="https://img.shields.io/endpoint.svg?url=https%3A%2F%2Fshieldsio-patreon.vercel.app%2Fapi%3Fusername%3Dmoulberry%26type%3Dpatrons&logoColor=FFFFFF&color=informational" alt="patreon">
+ <!-- downloads -->
+ <a href="https://github.com/Moulberry/NotEnoughUpdates/releases" target="_blank">
+ <img src="https://img.shields.io/github/downloads/Moulberry/NotEnoughUpdates/total?label=downloads&color=informational&logo=GitHub" alt="downloads">
</a>
</p>
@@ -76,4 +76,4 @@ NotEnoughUpdates (NEU) is a feature rich 1.8.9 Minecraft forge mod for Hypixel S
- A custom enchanting table GUI.
- Slot Locking
- Fishing Particle customization & alerts.
-- And much, much, more.
+- And [much, much, more.](https://gist.github.com/jani270/d33e249d40b0333b87ba5c5e70fca398)
diff --git a/Update Notes/2.1.md b/Update Notes/2.1.md
new file mode 100644
index 00000000..1a120dfb
--- /dev/null
+++ b/Update Notes/2.1.md
@@ -0,0 +1,89 @@
+# These are the change notes for NEU 2.1 REL
+
+### **Major Changes**
+- Added mining skill overlay
+- Added fishing skill overlay
+- Added combat skill overlay
+- Added slayer overlay
+- [Added mining tab in /pv](https://cdn.discordapp.com/attachments/832652653292027904/903619242384056370/unknown.png)
+- Big thanks to kwev1n for some math and jani for the texture
+- Added blocking clicks back to the enchanting minigames (because apparently, it's not bannable?)
+- [Donpireso replied to a sba dev's email about some of sba features, and it seems to imply that blocking clicks in guis aren't bannable](https://cdn.discordapp.com/attachments/823769568933576764/906101631861526559/unknown.png)
+- Fixed pet overlay not updating when going into /pets
+- [Added an armor overlay for the new armor slots](https://cdn.discordapp.com/attachments/832652653292027904/922399046528794634/unknown.png)
+- Added a pet overlay that shows your active pet in your inventory
+- [Price graph for items on /ah and /bz](https://cdn.discordapp.com/attachments/896407218151366687/926968296929107999/unknown.png) - DeDiamondPro
+### **Minor Changes:**
+- Add built-in recipes for forge crafts - nea89
+- Add Stranded Villager Trades to the item list - nea89
+- Make cata xp in /pv be calculated on how many runs you have and shows master mode xp rates
+- Added a config option to hide Dwarven Mines waypoints when already at the location - Lulonaut
+- Added some info panels to some settings in /neu
+- Added Kat Level After Upgrade Estimator - nea89
+- Added /pv button in /neu
+- Added pitch and coins/m as options in farming skill overlay
+- Make it so tab completion in ah search GUI goes down the items - Lulonaut
+- Added a toggle for enchant glint in storage gui (ty ery for texture)
+- Added fairy souls option to /neu misc
+- Make it so fairy souls are tracked independently for each profile - Lulonaut
+- Added a button in the storage gui to open the settings
+- Added an option to change the click names for /pv to /ah
+- Added a help menu to /neuec
+- Made it so treecap shows foraging xp instead of farming xp on the farming overlay
+- Made it so a jungle axe with cult will show the "farming" overlay
+- Added /neurepomode to toggle item editing and dev mode
+- Changed "NEUAH is DISABLED! Enable in /neusettings." to /neu
+- Changed misc overlays tab to todo overlays
+- Added a config option for npc retexturing
+- Added a config option for dirt wand overlay
+- Added a config option for hoe of tilling
+- Added an option to use short numbers (1.5mil) for price tooltips
+- Added Drills and Gauntlet to the itemlist tools category - jani
+- Added an option to turn off showing next click in chronomatron
+- Turns off inv search mode after 2 minutes
+- Made /neustats modlist show normal /neustats if under 15 mods
+- Added max enchant book to /neuec - Dokm
+- [Added bingo and Stranded profile icons to /pv](https://cdn.discordapp.com/attachments/832652653292027904/915844465372065842/unknown.png)
+- Added an icon if neu doesn't know about a gamemode in /pv
+- Fixed pet overlay not resetting pet when making new profile
+- Added a warning in the tooltip when price info couldn't be found/is outdated - Lulonaut
+- Added "Has Advanced Tab" to /neustats
+- Added custom runes and crab hat system - jani
+- Removed unused textures
+- Added total xp if player is above cata 50 in /pv - efefury
+- Added daily powder to todo overlay - efefury
+- Added a way to include kismet feather to profit calculator - efefury
+- Added custom sounds for crystal hollow gemstones - nea89
+- Added custom biomes for crystal hollow areas - nopo
+- Added a config option to hide the reforge stats for Legendary items from Hypixel on reforge stones - Lulonaut
+### **Bug Fixes**
+- Fix wiki pages freezing the entire game - nea89
+- Made titanium overlay and waypoints work with dwarven overlay off
+- "fixed" divan rarity in NEUAH (scuffed)
+- Made etherwarp block overlay config option
+- Fixed ram usage in crystal hollows - Dokm
+- Made skills not show int limit when at max level in skill overlays
+- Fixed space cape texture - Microcontrollers
+- Make it so you can hold down keys in sign GUIs
+- Added entrance to "floor one" + made blur limit at 100
+- Fixed screenshot key in /et overlay
+- Fixed api key autofill with dg copy chat feature
+- Made missing enchants not show on an item if its not missing any enchants
+- Fixed Mining overlay crash - Dokm
+- Fixed pet crash - Dokm
+- Fixed fetchur for the 75th time
+- [Made an error if you have new tab list off](https://cdn.discordapp.com/attachments/896407218151366687/913681097605398528/unknown.png)
+- Fixed lava fishing with the fishing alert
+- Fixed /locraw detection, [previously allowed chat messages to trigger it](https://github.com/NotEnoughUpdates/NotEnoughUpdates/issues/35) - IRONM00N
+- Fixed experiment timer in todo overlay - efefury
+- Fixed replace click events with /pv working in other modes
+- Fixed /neuec presets not applying the strikethrough attribute - Lulonaut
+### **Other**
+- New icons was added in storage_icons.png
+- Moved the help icon in /neucustomize over a little
+- Added dg partner cape
+- Changed custom_enchant_gui.png to remove top right button
+- Added 4 new textures for the on/off switches in /neu
+- Code Cleanup - IRONM00N
+### **Previous change log**
+https://github.com/NotEnoughUpdates/NotEnoughUpdates/blob/master/Update%20Notes/2.0-Pre31-Release.md
diff --git a/build.gradle b/build.gradle
deleted file mode 100644
index f2620a00..00000000
--- a/build.gradle
+++ /dev/null
@@ -1,128 +0,0 @@
-buildscript {
- repositories {
- jcenter()
- maven {
- name 'JitPack'
- url 'https://jitpack.io'
- }
- maven { url = "https://maven.minecraftforge.net/" }
- maven { url = "https://repo.spongepowered.org/maven" }
- }
- dependencies {
- classpath "com.github.asbyth:ForgeGradle:6f53277"
- classpath 'com.github.LxGaming:MixinGradle:d75e32e'//0.6-SNAPSHOT'
- classpath 'com.github.jengelman.gradle.plugins:shadow:6.1.0'
- }
-}
-
-apply plugin: 'java'
-apply plugin: "net.minecraftforge.gradle.forge"
-apply plugin: 'org.spongepowered.mixin'
-apply plugin: 'com.github.johnrengelman.shadow'
-
-sourceCompatibility = 1.8
-targetCompatibility = 1.8
-
-version = "2.0-PRE"
-group= "io.github.moulberry"
-archivesBaseName = "NotEnoughUpdates"
-String modid = "notenoughupdates"
-String mixinClassifier = "dep"
-compileJava.options.encoding = 'UTF-8'
-
-minecraft {
- version = "1.8.9-11.15.1.2318-1.8.9"
- runDir = "run"
- mappings = "stable_22"
-}
-
-repositories {
- jcenter()
- maven { url 'https://repo.spongepowered.org/maven/' }
- flatDir {
- dirs 'deps'
- }
-}
-
-dependencies {
- compile('org.spongepowered:mixin:0.7.11-SNAPSHOT')
- 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')
-}
-
-mixin {
- add sourceSets.main, "mixins.${modid}.refmap.json"
-}
-
-jar {
- manifest.attributes(
- 'Main-Class': 'NotSkyblockAddonsInstallerFrame',
- 'TweakClass': 'org.spongepowered.asm.launch.MixinTweaker',
- 'MixinConfigs': "mixins.${modid}.json",
- 'FMLCorePluginContainsFMLMod': true,
- "ForceLoadAsMod": true,
- "FMLAT": 'notenoughupdates_at.cfg'
- )
-}
-
-shadowJar {
- dependencies {
- include(dependency('org.spongepowered:mixin:0.7.11-SNAPSHOT'))
-
- include(dependency('commons-io:commons-io'))
- include(dependency('org.apache.commons:commons-lang3'))
- include(dependency('com.fasterxml.jackson.core:jackson-databind:2.10.2'))
- include(dependency('com.fasterxml.jackson.core:jackson-annotations:2.10.2'))
- include(dependency('com.fasterxml.jackson.core:jackson-core:2.10.2'))
-
- include(dependency('info.bliki.wiki:bliki-core:3.1.0'))
- include(dependency('org.slf4j:slf4j-api:1.7.18'))
- include(dependency('org.luaj:luaj-jse:3.0.1'))
- }
-
- relocate 'com.fasterxml.jackson', 'neu.com.fasterxml.jackson'
- relocate 'org.eclipse', 'neu.org.eclipse'
- relocate 'org.slf4j', 'neu.org.slf4j'
-
- exclude 'module-info.class'
- exclude 'dummyThing'
- exclude 'LICENSE.txt'
-
- classifier = mixinClassifier
-}
-
-reobf {
- shadowJar {
- mappingType = 'SEARGE'
- }
-}
-
-build.dependsOn(shadowJar)
-runClient.dependsOn(build)
-
-processResources
-{
- inputs.property "version", project.version
- inputs.property "mcversion", project.minecraft.version
-
- from(sourceSets.main.resources.srcDirs) {
- include 'mcmod.info'
- expand 'version':project.version, 'mcversion':project.minecraft.version
- }
-
- 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/build.gradle.kts b/build.gradle.kts
new file mode 100644
index 00000000..e824a9a0
--- /dev/null
+++ b/build.gradle.kts
@@ -0,0 +1,149 @@
+import java.io.ByteArrayOutputStream
+import net.minecraftforge.gradle.user.ReobfMappingType
+plugins {
+ java
+ id("net.minecraftforge.gradle.forge") version "6f5327738df"
+ id("com.github.johnrengelman.shadow") version "6.1.0"
+ id("org.spongepowered.mixin") version "d75e32e"
+}
+
+group = "io.github.moulberry"
+val baseVersion = "2.1"
+
+
+var buildVersion = properties["BUILD_VERSION"]
+if (buildVersion == null) {
+ val stdout = ByteArrayOutputStream()
+ val execResult = exec {
+ commandLine("git", "describe", "--always", "--first-parent", "--abbrev=7")
+ standardOutput = stdout
+ }
+ if (execResult.exitValue == 0)
+ buildVersion = String(stdout.toByteArray()).trim()
+}
+
+version = baseVersion + (buildVersion?.let { "+$it" } ?: "")
+
+
+// Toolchains:
+
+java {
+ // Forge Gradle currently prevents using the toolchain: toolchain.languageVersion.set(JavaLanguageVersion.of(8))
+ sourceCompatibility = JavaVersion.VERSION_1_8
+ targetCompatibility = JavaVersion.VERSION_1_8
+}
+
+minecraft {
+ version = "1.8.9-11.15.1.2318-1.8.9"
+ runDir = "run"
+ mappings = "stable_22"
+ clientJvmArgs.addAll(
+ listOf(
+ "-Dmixin.debug=true",
+ "-Dasmhelper.verbose=true"
+ )
+ )
+ clientRunArgs.addAll(
+ listOf(
+ "--tweakClass org.spongepowered.asm.launch.MixinTweaker",
+ "--mixin mixins.notenoughupdates.json"
+ )
+ )
+}
+
+mixin {
+ add(sourceSets.main.get(), "mixins.notenoughupdates.refmap.json")
+}
+
+// Dependencies:
+
+repositories {
+ mavenCentral()
+ flatDir { dirs("deps/") }
+ maven("https://repo.spongepowered.org/maven/")
+}
+
+dependencies {
+ implementation("org.spongepowered:mixin:0.7.11-SNAPSHOT")
+ annotationProcessor("org.spongepowered:mixin:0.7.11-SNAPSHOT")
+ implementation("com.fasterxml.jackson.core:jackson-core:2.13.1")
+ implementation("info.bliki.wiki:bliki-core:3.1.0")
+}
+
+
+// Tasks:
+
+tasks.withType(JavaCompile::class) {
+ options.encoding = "UTF-8"
+}
+
+tasks.withType(Jar::class) {
+ archiveBaseName.set("NotEnoughUpdates")
+ manifest.attributes.run {
+ this["Main-Class"] = "NotSkyblockAddonsInstallerFrame"
+ this["TweakClass"] = "org.spongepowered.asm.launch.MixinTweaker"
+ this["MixinConfigs"] = "mixins.notenoughupdates.json"
+ this["FMLCorePluginContainsFMLMod"] = "true"
+ this["ForceLoadAsMod"] = "true"
+ this["FMLAT"] = "notenoughupdates_at.cfg"
+ }
+}
+
+tasks.shadowJar {
+ archiveClassifier.set("dep")
+ exclude(
+ "module-info.class",
+ "LICENSE.txt"
+ )
+ dependencies {
+ include(dependency("org.spongepowered:mixin:0.7.11-SNAPSHOT"))
+
+ include(dependency("commons-io:commons-io"))
+ include(dependency("org.apache.commons:commons-lang3"))
+ include(dependency("com.fasterxml.jackson.core:jackson-databind:2.10.2"))
+ include(dependency("com.fasterxml.jackson.core:jackson-annotations:2.10.2"))
+ include(dependency("com.fasterxml.jackson.core:jackson-core:2.10.2"))
+
+ include(dependency("info.bliki.wiki:bliki-core:3.1.0"))
+ include(dependency("org.slf4j:slf4j-api:1.7.18"))
+ include(dependency("org.luaj:luaj-jse:3.0.1"))
+ }
+ fun relocate(name: String) = relocate(name, "io.github.moulberry.notenoughupdates.deps.$name")
+ relocate("com.fasterxml.jackson")
+ relocate("org.eclipse")
+ relocate("org.slf4j")
+}
+
+tasks.build.get().dependsOn(tasks.shadowJar)
+
+reobf {
+ create("shadowJar") {
+ mappingType = ReobfMappingType.SEARGE
+ }
+}
+
+tasks.processResources {
+ from(sourceSets.main.get().resources.srcDirs)
+ filesMatching("mcmod.info") {
+ expand(
+ "version" to project.version,
+ "mcversion" to minecraft.version
+ )
+ }
+ rename("(.+_at.cfg)".toPattern(), "META-INF/$1")
+}
+
+val moveResources by tasks.creating {
+ doLast {
+ ant.withGroovyBuilder {
+ "move"(
+ "file" to "$buildDir/resources/main",
+ "todir" to "$buildDir/classes/java"
+ )
+ }
+ }
+ dependsOn(tasks.processResources)
+}
+
+tasks.classes { dependsOn(moveResources) }
+
diff --git a/settings.gradle.kts b/settings.gradle.kts
new file mode 100644
index 00000000..44138312
--- /dev/null
+++ b/settings.gradle.kts
@@ -0,0 +1,17 @@
+pluginManagement {
+ repositories {
+ mavenCentral()
+ gradlePluginPortal()
+ maven(url = "https://jitpack.io/")
+ maven(url = "https://maven.minecraftforge.net/")
+ maven(url = "https://repo.spongepowered.org/maven/")
+ }
+ resolutionStrategy {
+ eachPlugin {
+ when (requested.id.id) {
+ "net.minecraftforge.gradle.forge" -> useModule("com.github.asbyth:ForgeGradle:${requested.version}")
+ "org.spongepowered.mixin" -> useModule("com.github.LxGaming:MixinGradle:${requested.version}")
+ }
+ }
+ }
+}
diff --git a/src/main/java/NotSkyblockAddonsInstallerFrame.java b/src/main/java/NotSkyblockAddonsInstallerFrame.java
index 7c5a1638..e6543617 100644
--- a/src/main/java/NotSkyblockAddonsInstallerFrame.java
+++ b/src/main/java/NotSkyblockAddonsInstallerFrame.java
@@ -16,652 +16,663 @@ import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
public class NotSkyblockAddonsInstallerFrame extends JFrame implements ActionListener, MouseListener {
-
- private static final Pattern IN_MODS_SUBFOLDER = Pattern.compile("1\\.8\\.9[/\\\\]?$");
-
- private JLabel logo = null;
- private JLabel versionInfo = null;
- private JLabel labelFolder = null;
-
- private JPanel panelCenter = null;
- private JPanel panelBottom = null;
- private JPanel totalContentPane = null;
-
- private JTextArea descriptionText = null;
- private JTextArea forgeDescriptionText = null;
-
- private JTextField textFieldFolderLocation = null;
- private JButton buttonChooseFolder = null;
-
- private JButton buttonInstall = null;
- private JButton buttonOpenFolder = null;
- private JButton buttonClose = null;
-
- private static final int TOTAL_HEIGHT = 435;
- private static final int TOTAL_WIDTH = 404;
-
- private int x = 0;
- private int y = 0;
-
- private int w = TOTAL_WIDTH;
- private int h;
- private int margin;
-
- public NotSkyblockAddonsInstallerFrame() {
- try {
- setName("NotEnoughUpdatesInstallerFrame");
- setTitle("NotEnoughUpdates Installer");
- setResizable(false);
- setSize(TOTAL_WIDTH, TOTAL_HEIGHT);
- setContentPane(getPanelContentPane());
-
- getButtonFolder().addActionListener(this);
- getButtonInstall().addActionListener(this);
- getButtonOpenFolder().addActionListener(this);
- getButtonClose().addActionListener(this);
- getForgeTextArea().addMouseListener(this);
-
- pack();
- setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
-
- getFieldFolder().setText(getModsFolder().getPath());
- getButtonInstall().setEnabled(true);
- getButtonInstall().requestFocus();
- } catch (Exception ex) {
- showErrorPopup(ex);
- }
- }
-
- public static void main(String[] args) {
- try {
- UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
- NotSkyblockAddonsInstallerFrame frame = new NotSkyblockAddonsInstallerFrame();
- frame.centerFrame(frame);
- frame.show();
-
- } catch (Exception ex) {
- showErrorPopup(ex);
- }
- }
-
- private JPanel getPanelContentPane() {
- if (totalContentPane == null) {
- try {
- totalContentPane = new JPanel();
- totalContentPane.setName("PanelContentPane");
- totalContentPane.setLayout(new BorderLayout(5, 5));
- totalContentPane.setPreferredSize(new Dimension(TOTAL_WIDTH, TOTAL_HEIGHT));
- totalContentPane.add(getPanelCenter(), "Center");
- totalContentPane.add(getPanelBottom(), "South");
- } catch (Throwable ivjExc) {
- showErrorPopup(ivjExc);
- }
- }
- return totalContentPane;
- }
-
- private JPanel getPanelCenter() {
- if (panelCenter == null) {
- try {
- (panelCenter = new JPanel()).setName("PanelCenter");
- panelCenter.setLayout(null);
- panelCenter.add(getPictureLabel(), getPictureLabel().getName());
- panelCenter.add(getVersionInfo(), getVersionInfo().getName());
- panelCenter.add(getTextArea(), getTextArea().getName());
- panelCenter.add(getForgeTextArea(), getForgeTextArea().getName());
- panelCenter.add(getLabelFolder(), getLabelFolder().getName());
- panelCenter.add(getFieldFolder(), getFieldFolder().getName());
- panelCenter.add(getButtonFolder(), getButtonFolder().getName());
- } catch (Throwable ivjExc) {
- showErrorPopup(ivjExc);
- }
- }
- return panelCenter;
- }
-
- private JLabel getPictureLabel() {
- if (logo == null) {
- try {
- h = w/2;
- margin = 5;
-
- BufferedImage myPicture = ImageIO.read(getClass().getClassLoader().getResourceAsStream("assets/notenoughupdates/logo.png"));
- Image scaled = myPicture.getScaledInstance(w-margin*2, h-margin, Image.SCALE_SMOOTH);
- logo = new JLabel(new ImageIcon(scaled));
- logo.setName("Logo");
- logo.setBounds(x+margin, y+margin, w-margin*2, h-margin);
- logo.setFont(new Font(Font.DIALOG, Font.BOLD, 18));
- logo.setHorizontalAlignment(SwingConstants.CENTER);
- logo.setPreferredSize(new Dimension(h*742/537, h));
-
- y += h;
- } catch (Throwable ivjExc) {
- showErrorPopup(ivjExc);
- }
- }
- return logo;
- }
-
- private JLabel getVersionInfo() {
- if (versionInfo == null) {
- try {
- h = 25;
-
- versionInfo = new JLabel();
- versionInfo.setName("LabelMcVersion");
- versionInfo.setBounds(x, y, w, h);
- versionInfo.setFont(new Font(Font.DIALOG, Font.BOLD, 14));
- versionInfo.setHorizontalAlignment(SwingConstants.CENTER);
- versionInfo.setPreferredSize(new Dimension(w, h));
- versionInfo.setText("NEU by Moulberry, Installer by Biscuit - for Minecraft 1.8.9");
-
- y += h;
- } catch (Throwable ivjExc) {
- showErrorPopup(ivjExc);
- }
- }
- return versionInfo;
- }
-
- private JTextArea getTextArea() {
- if (descriptionText == null) {
- try {
- h = 60;
- margin = 10;
-
- descriptionText = new JTextArea();
- descriptionText.setName("TextArea");
- descriptionText.setBounds(x+margin, y+margin, w-margin*2, h-margin);
- descriptionText.setEditable(false);
- descriptionText.setHighlighter(null);
- descriptionText.setEnabled(true);
- descriptionText.setFont(new Font(Font.DIALOG, Font.PLAIN, 12));
- descriptionText.setLineWrap(true);
- descriptionText.setOpaque(false);
- descriptionText.setPreferredSize(new Dimension(w-margin*2, h-margin));
- descriptionText.setText("This installer will copy NotEnoughUpdates into your forge mods folder for you, and replace any old versions that already exist. " +
- "Close this if you prefer to do this yourself!");
- descriptionText.setWrapStyleWord(true);
-
- y += h;
- } catch (Throwable ivjExc) {
- showErrorPopup(ivjExc);
- }
- }
- return descriptionText;
- }
-
- private JTextArea getForgeTextArea() {
- if (forgeDescriptionText == null) {
- try {
- h = 55;
- margin = 10;
-
- forgeDescriptionText = new JTextArea();
- forgeDescriptionText.setName("TextAreaForge");
- forgeDescriptionText.setBounds(x+margin, y+margin, w-margin*2, h-margin);
- forgeDescriptionText.setEditable(false);
- forgeDescriptionText.setHighlighter(null);
- forgeDescriptionText.setEnabled(true);
- forgeDescriptionText.setFont(new Font(Font.DIALOG, Font.PLAIN, 12));
- forgeDescriptionText.setLineWrap(true);
- forgeDescriptionText.setOpaque(false);
- forgeDescriptionText.setPreferredSize(new Dimension(w-margin*2, h-margin));
- forgeDescriptionText.setText("However, you still need to install Forge client in order to be able to run this mod. Click here to visit the download page for Forge 1.8.9!");
- forgeDescriptionText.setForeground(Color.BLUE.darker());
- forgeDescriptionText.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
- forgeDescriptionText.setWrapStyleWord(true);
-
- y += h;
- } catch (Throwable ivjExc) {
- showErrorPopup(ivjExc);
- }
- }
- return forgeDescriptionText;
- }
-
- private JLabel getLabelFolder() {
- if (labelFolder == null) {
- h = 16;
- w = 65;
-
- x += 10; // Padding
-
- try {
- labelFolder = new JLabel();
- labelFolder.setName("LabelFolder");
- labelFolder.setBounds(x, y+2, w, h);
- labelFolder.setPreferredSize(new Dimension(w, h));
- labelFolder.setText("Mods Folder");
- } catch (Throwable ivjExc) {
- showErrorPopup(ivjExc);
- }
-
- x += w;
- }
- return labelFolder;
- }
-
- private JTextField getFieldFolder() {
- if (textFieldFolderLocation == null) {
- h = 20;
- w = 287;
-
- try {
- textFieldFolderLocation = new JTextField();
- textFieldFolderLocation.setName("FieldFolder");
- textFieldFolderLocation.setBounds(x, y, w, h);
- textFieldFolderLocation.setEditable(false);
- textFieldFolderLocation.setPreferredSize(new Dimension(w, h));
- } catch (Throwable ivjExc) {
- showErrorPopup(ivjExc);
- }
-
- x += w;
- }
- return textFieldFolderLocation;
- }
-
- private JButton getButtonFolder() {
- if (buttonChooseFolder == null) {
- h = 20;
- w = 25;
-
- x += 10; // Padding
-
- try {
- BufferedImage myPicture = ImageIO.read(getClass().getClassLoader().getResourceAsStream("assets/notenoughupdates/folder.png"));
- Image scaled = myPicture.getScaledInstance(w-8, h-6, Image.SCALE_SMOOTH);
- buttonChooseFolder = new JButton(new ImageIcon(scaled));
- buttonChooseFolder.setName("ButtonFolder");
- buttonChooseFolder.setBounds(x, y, w, h);
- buttonChooseFolder.setPreferredSize(new Dimension(w, h));
- } catch (Throwable ivjExc) {
- showErrorPopup(ivjExc);
- }
- }
- return buttonChooseFolder;
- }
-
- private JPanel getPanelBottom() {
- if (panelBottom == null) {
- try {
- panelBottom = new JPanel();
- panelBottom.setName("PanelBottom");
- panelBottom.setLayout(new FlowLayout(FlowLayout.CENTER, 15, 10));
- panelBottom.setPreferredSize(new Dimension(390, 55));
- panelBottom.add(getButtonInstall(), getButtonInstall().getName());
- panelBottom.add(getButtonOpenFolder(), getButtonOpenFolder().getName());
- panelBottom.add(getButtonClose(), getButtonClose().getName());
- } catch (Throwable ivjExc) {
- showErrorPopup(ivjExc);
- }
- }
- return panelBottom;
- }
-
- private JButton getButtonInstall() {
- if (buttonInstall == null) {
- w = 100;
- h = 26;
-
- try {
- buttonInstall = new JButton();
- buttonInstall.setName("ButtonInstall");
- buttonInstall.setPreferredSize(new Dimension(w, h));
- buttonInstall.setText("Install");
- } catch (Throwable ivjExc) {
- showErrorPopup(ivjExc);
- }
- }
- return buttonInstall;
- }
-
- private JButton getButtonOpenFolder() {
- if (buttonOpenFolder == null) {
- w = 130;
- h = 26;
-
- try {
- buttonOpenFolder = new JButton();
- buttonOpenFolder.setName("ButtonOpenFolder");
- buttonOpenFolder.setPreferredSize(new Dimension(w, h));
- buttonOpenFolder.setText("Open Mods Folder");
- } catch (Throwable ivjExc) {
- showErrorPopup(ivjExc);
- }
- }
- return buttonOpenFolder;
- }
-
- private JButton getButtonClose() {
- if (buttonClose == null) {
- w = 100;
- h = 26;
-
- try {
- (buttonClose = new JButton()).setName("ButtonClose");
- buttonClose.setPreferredSize(new Dimension(w, h));
- buttonClose.setText("Cancel");
- } catch (Throwable ivjExc) {
- showErrorPopup(ivjExc);
- }
- }
- return buttonClose;
- }
-
- public void onFolderSelect() {
- File currentDirectory = new File(getFieldFolder().getText());
-
- JFileChooser jFileChooser = new JFileChooser(currentDirectory);
- jFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
- jFileChooser.setAcceptAllFileFilterUsed(false);
- if (jFileChooser.showOpenDialog(this) == 0) {
- File newDirectory = jFileChooser.getSelectedFile();
- getFieldFolder().setText(newDirectory.getPath());
- }
- }
-
- @Override
- public void actionPerformed(ActionEvent e) {
- if (e.getSource() == getButtonClose()) {
- dispose();
- System.exit(0);
- }
- if (e.getSource() == getButtonFolder()) {
- onFolderSelect();
- }
- if (e.getSource() == getButtonInstall()) {
- onInstall();
- }
- if (e.getSource() == getButtonOpenFolder()) {
- onOpenFolder();
- }
- }
-
- @Override
- public void mouseClicked(MouseEvent e) {
- if (e.getSource() == getForgeTextArea()) {
- try {
- Desktop.getDesktop().browse(new URI("http://files.minecraftforge.net/maven/net/minecraftforge/forge/index_1.8.9.html"));
- } catch (IOException | URISyntaxException ex) {
- showErrorPopup(ex);
- }
- }
- }
-
- public void onInstall() {
- try {
- File modsFolder = new File(getFieldFolder().getText());
- if (!modsFolder.exists()) {
- showErrorMessage("Folder not found: " + modsFolder.getPath());
- return;
- }
- if (!modsFolder.isDirectory()) {
- showErrorMessage("Not a folder: " + modsFolder.getPath());
- return;
- }
- tryInstall(modsFolder);
- } catch (Exception e) {
- showErrorPopup(e);
- }
- }
-
- private void tryInstall(File modsFolder) {
- File thisFile = getThisFile();
-
- if (thisFile != null) {
- boolean inSubFolder = false;
- if (IN_MODS_SUBFOLDER.matcher(modsFolder.getPath()).find()) {
- inSubFolder = true;
- }
-
- boolean deletingFailure = false;
- if (modsFolder.isDirectory()) { // Delete in this current folder.
- boolean failed = findSkyblockAddonsAndDelete(modsFolder.listFiles());
- if (failed) deletingFailure = true;
- }
- if (inSubFolder) { // We are in the 1.8.9 folder, delete in the parent folder as well.
- if (modsFolder.getParentFile().isDirectory()) {
- boolean failed = findSkyblockAddonsAndDelete(modsFolder.getParentFile().listFiles());
- if (failed) deletingFailure = true;
- }
- } else { // We are in the main mods folder, but the 1.8.9 subfolder exists... delete in there too.
- File subFolder = new File(modsFolder, "1.8.9");
- if (subFolder.exists() && subFolder.isDirectory()) {
- boolean failed = findSkyblockAddonsAndDelete(subFolder.listFiles());
- if (failed) deletingFailure = true;
- }
- }
-
- if (deletingFailure) return;
-
- if (thisFile.isDirectory()) {
- showErrorMessage("This file is a directory... Are we in a development environment?");
- return;
- }
-
- try {
- Files.copy(thisFile.toPath(), new File(modsFolder, thisFile.getName()).toPath());
- } catch (Exception ex) {
- showErrorPopup(ex);
- return;
- }
-
- showMessage("NotEnoughUpdates has been successfully installed into your mods folder.");
- dispose();
- System.exit(0);
- }
- }
-
- private boolean findSkyblockAddonsAndDelete(File[] files) {
- if (files == null) return false;
-
- for (File file : files) {
- if (!file.isDirectory() && file.getPath().endsWith(".jar")) {
- try {
- JarFile jarFile = new JarFile(file);
- ZipEntry mcModInfo = jarFile.getEntry("mcmod.info");
- if (mcModInfo != null) {
- InputStream inputStream = jarFile.getInputStream(mcModInfo);
- String modID = getModIDFromInputStream(inputStream);
- if (modID.equals("notenoughupdates")) {
- jarFile.close();
- try {
- boolean deleted = file.delete();
- if (!deleted) {
- throw new Exception();
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- showErrorMessage("Was not able to delete the other NotEnoughUpdates files found in your mods folder!" + System.lineSeparator() +
- "Please make sure that your minecraft is currently closed and try again, or feel" + System.lineSeparator() +
- "free to open your mods folder and delete those files manually.");
- return true;
- }
- continue;
- }
- }
- jarFile.close();
- } catch (Exception ex) {
- // Just don't check the file I guess, move on to the next...
- }
- }
- }
- return false;
- }
-
- public void onOpenFolder() {
- try {
- Desktop.getDesktop().open(getModsFolder());
- } catch (Exception e) {
- showErrorPopup(e);
- }
- }
-
- public File getModsFolder() {
- String userHome = System.getProperty("user.home", ".");
-
- File modsFolder = getFile(userHome, "minecraft/mods/1.8.9");
- if (!modsFolder.exists()) {
- modsFolder = getFile(userHome, "minecraft/mods");
- }
-
- if (!modsFolder.exists() && !modsFolder.mkdirs()) {
- throw new RuntimeException("The working directory could not be created: " + modsFolder);
- }
- return modsFolder;
- }
-
- public File getFile(String userHome, String minecraftPath) {
- File workingDirectory;
- switch (getOperatingSystem()) {
- case LINUX:
- case SOLARIS: {
- workingDirectory = new File(userHome, '.' + minecraftPath + '/');
- break;
- }
- case WINDOWS: {
- String applicationData = System.getenv("APPDATA");
- if (applicationData != null) {
- workingDirectory = new File(applicationData, "." + minecraftPath + '/');
- break;
- }
- workingDirectory = new File(userHome, '.' + minecraftPath + '/');
- break;
- }
- case MACOS: {
- workingDirectory = new File(userHome, "Library/Application Support/" + minecraftPath);
- break;
- }
- default: {
- workingDirectory = new File(userHome, minecraftPath + '/');
- break;
- }
- }
- return workingDirectory;
- }
-
- public OperatingSystem getOperatingSystem() {
- String osName = System.getProperty("os.name").toLowerCase(Locale.US);
- if (osName.contains("win")) {
- return OperatingSystem.WINDOWS;
-
- } else if (osName.contains("mac")) {
- return OperatingSystem.MACOS;
-
- } else if (osName.contains("solaris") || osName.contains("sunos")) {
-
- return OperatingSystem.SOLARIS;
- } else if (osName.contains("linux") || osName.contains("unix")) {
-
- return OperatingSystem.LINUX;
- }
- return OperatingSystem.UNKNOWN;
- }
-
- public void centerFrame(JFrame frame) {
- Rectangle rectangle = frame.getBounds();
- Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
- Rectangle screenRectangle = new Rectangle(0, 0, screenSize.width, screenSize.height);
-
- int newX = screenRectangle.x + (screenRectangle.width - rectangle.width) / 2;
- int newY = screenRectangle.y + (screenRectangle.height - rectangle.height) / 2;
-
- if (newX < 0) newX = 0;
- if (newY < 0) newY = 0;
-
- frame.setBounds(newX, newY, rectangle.width, rectangle.height);
- }
-
- public void showMessage(String message) {
- JOptionPane.showMessageDialog(null, message, "NotEnoughUpdates", JOptionPane.INFORMATION_MESSAGE);
- }
-
- public void showErrorMessage(String message) {
- JOptionPane.showMessageDialog(null, message, "NotEnoughUpdates - Error", JOptionPane.ERROR_MESSAGE);
- }
-
- public enum OperatingSystem {
- LINUX,
- SOLARIS,
- WINDOWS,
- MACOS,
- UNKNOWN
- }
-
- private static String getStacktraceText(Throwable ex) {
- StringWriter stringWriter = new StringWriter();
- ex.printStackTrace(new PrintWriter(stringWriter));
- return stringWriter.toString().replace("\t", " ");
- }
-
- private static void showErrorPopup(Throwable ex) {
- ex.printStackTrace();
-
- JTextArea textArea = new JTextArea(getStacktraceText(ex));
- textArea.setEditable(false);
- Font currentFont = textArea.getFont();
- Font newFont = new Font(Font.MONOSPACED, currentFont.getStyle(), currentFont.getSize());
- textArea.setFont(newFont);
-
- JScrollPane errorScrollPane = new JScrollPane(textArea);
- errorScrollPane.setPreferredSize(new Dimension(600, 400));
- JOptionPane.showMessageDialog(null, errorScrollPane, "Error", JOptionPane.ERROR_MESSAGE);
- }
-
- private String getVersionFromMcmodInfo() {
- String version = "";
- try {
- BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("mcmod.info")));
- while ((version = bufferedReader.readLine()) != null) {
- if (version.contains("\"version\": \"")) {
- version = version.split(Pattern.quote("\"version\": \""))[1];
- version = version.substring(0, version.length() - 2);
- break;
- }
- }
- } catch (Exception ex) {
- // It's okay, I guess just don't use the version lol.
- }
- return version;
- }
-
- private String getModIDFromInputStream(InputStream inputStream) {
- String version = "";
- try {
- BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
- while ((version = bufferedReader.readLine()) != null) {
- if (version.contains("\"modid\": \"")) {
- version = version.split(Pattern.quote("\"modid\": \""))[1];
- version = version.substring(0, version.length() - 2);
- break;
- }
- }
- } catch (Exception ex) {
- // RIP, couldn't find the modid...
- }
- return version;
- }
-
- private File getThisFile() {
- try {
- return new File(NotSkyblockAddonsInstallerFrame.class.getProtectionDomain().getCodeSource().getLocation().toURI());
- } catch (URISyntaxException ex) {
- showErrorPopup(ex);
- }
- return null;
- }
-
- @Override
- public void mousePressed(MouseEvent e) {}
-
- @Override
- public void mouseReleased(MouseEvent e) {}
-
- @Override
- public void mouseEntered(MouseEvent e) {}
-
- @Override
- public void mouseExited(MouseEvent e) {}
+ private static final Pattern IN_MODS_SUBFOLDER = Pattern.compile("1\\.8\\.9[/\\\\]?$");
+
+ private JLabel logo = null;
+ private JLabel versionInfo = null;
+ private JLabel labelFolder = null;
+
+ private JPanel panelCenter = null;
+ private JPanel panelBottom = null;
+ private JPanel totalContentPane = null;
+
+ private JTextArea descriptionText = null;
+ private JTextArea forgeDescriptionText = null;
+
+ private JTextField textFieldFolderLocation = null;
+ private JButton buttonChooseFolder = null;
+
+ private JButton buttonInstall = null;
+ private JButton buttonOpenFolder = null;
+ private JButton buttonClose = null;
+
+ private static final int TOTAL_HEIGHT = 435;
+ private static final int TOTAL_WIDTH = 404;
+
+ private int x = 0;
+ private int y = 0;
+
+ private int w = TOTAL_WIDTH;
+ private int h;
+ private int margin;
+
+ public NotSkyblockAddonsInstallerFrame() {
+ try {
+ setName("NotEnoughUpdatesInstallerFrame");
+ setTitle("NotEnoughUpdates Installer");
+ setResizable(false);
+ setSize(TOTAL_WIDTH, TOTAL_HEIGHT);
+ setContentPane(getPanelContentPane());
+
+ getButtonFolder().addActionListener(this);
+ getButtonInstall().addActionListener(this);
+ getButtonOpenFolder().addActionListener(this);
+ getButtonClose().addActionListener(this);
+ getForgeTextArea().addMouseListener(this);
+
+ pack();
+ setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
+
+ getFieldFolder().setText(getModsFolder().getPath());
+ getButtonInstall().setEnabled(true);
+ getButtonInstall().requestFocus();
+ } catch (Exception ex) {
+ showErrorPopup(ex);
+ }
+ }
+
+ public static void main(String[] args) {
+ try {
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+ NotSkyblockAddonsInstallerFrame frame = new NotSkyblockAddonsInstallerFrame();
+ frame.centerFrame(frame);
+ frame.show();
+
+ } catch (Exception ex) {
+ showErrorPopup(ex);
+ }
+ }
+
+ private JPanel getPanelContentPane() {
+ if (totalContentPane == null) {
+ try {
+ totalContentPane = new JPanel();
+ totalContentPane.setName("PanelContentPane");
+ totalContentPane.setLayout(new BorderLayout(5, 5));
+ totalContentPane.setPreferredSize(new Dimension(TOTAL_WIDTH, TOTAL_HEIGHT));
+ totalContentPane.add(getPanelCenter(), "Center");
+ totalContentPane.add(getPanelBottom(), "South");
+ } catch (Throwable ivjExc) {
+ showErrorPopup(ivjExc);
+ }
+ }
+ return totalContentPane;
+ }
+
+ private JPanel getPanelCenter() {
+ if (panelCenter == null) {
+ try {
+ (panelCenter = new JPanel()).setName("PanelCenter");
+ panelCenter.setLayout(null);
+ panelCenter.add(getPictureLabel(), getPictureLabel().getName());
+ panelCenter.add(getVersionInfo(), getVersionInfo().getName());
+ panelCenter.add(getTextArea(), getTextArea().getName());
+ panelCenter.add(getForgeTextArea(), getForgeTextArea().getName());
+ panelCenter.add(getLabelFolder(), getLabelFolder().getName());
+ panelCenter.add(getFieldFolder(), getFieldFolder().getName());
+ panelCenter.add(getButtonFolder(), getButtonFolder().getName());
+ } catch (Throwable ivjExc) {
+ showErrorPopup(ivjExc);
+ }
+ }
+ return panelCenter;
+ }
+
+ private JLabel getPictureLabel() {
+ if (logo == null) {
+ try {
+ h = w / 2;
+ margin = 5;
+
+ BufferedImage myPicture = ImageIO.read(getClass()
+ .getClassLoader()
+ .getResourceAsStream("assets/notenoughupdates/logo.png"));
+ Image scaled = myPicture.getScaledInstance(w - margin * 2, h - margin, Image.SCALE_SMOOTH);
+ logo = new JLabel(new ImageIcon(scaled));
+ logo.setName("Logo");
+ logo.setBounds(x + margin, y + margin, w - margin * 2, h - margin);
+ logo.setFont(new Font(Font.DIALOG, Font.BOLD, 18));
+ logo.setHorizontalAlignment(SwingConstants.CENTER);
+ logo.setPreferredSize(new Dimension(h * 742 / 537, h));
+
+ y += h;
+ } catch (Throwable ivjExc) {
+ showErrorPopup(ivjExc);
+ }
+ }
+ return logo;
+ }
+
+ private JLabel getVersionInfo() {
+ if (versionInfo == null) {
+ try {
+ h = 25;
+
+ versionInfo = new JLabel();
+ versionInfo.setName("LabelMcVersion");
+ versionInfo.setBounds(x, y, w, h);
+ versionInfo.setFont(new Font(Font.DIALOG, Font.BOLD, 14));
+ versionInfo.setHorizontalAlignment(SwingConstants.CENTER);
+ versionInfo.setPreferredSize(new Dimension(w, h));
+ versionInfo.setText("NEU by Moulberry, Installer by Biscuit - for Minecraft 1.8.9");
+
+ y += h;
+ } catch (Throwable ivjExc) {
+ showErrorPopup(ivjExc);
+ }
+ }
+ return versionInfo;
+ }
+
+ private JTextArea getTextArea() {
+ if (descriptionText == null) {
+ try {
+ h = 60;
+ margin = 10;
+
+ descriptionText = new JTextArea();
+ descriptionText.setName("TextArea");
+ descriptionText.setBounds(x + margin, y + margin, w - margin * 2, h - margin);
+ descriptionText.setEditable(false);
+ descriptionText.setHighlighter(null);
+ descriptionText.setEnabled(true);
+ descriptionText.setFont(new Font(Font.DIALOG, Font.PLAIN, 12));
+ descriptionText.setLineWrap(true);
+ descriptionText.setOpaque(false);
+ descriptionText.setPreferredSize(new Dimension(w - margin * 2, h - margin));
+ descriptionText.setText(
+ "This installer will copy NotEnoughUpdates into your forge mods folder for you, and replace any old versions that already exist. " +
+ "Close this if you prefer to do this yourself!");
+ descriptionText.setWrapStyleWord(true);
+
+ y += h;
+ } catch (Throwable ivjExc) {
+ showErrorPopup(ivjExc);
+ }
+ }
+ return descriptionText;
+ }
+
+ private JTextArea getForgeTextArea() {
+ if (forgeDescriptionText == null) {
+ try {
+ h = 55;
+ margin = 10;
+
+ forgeDescriptionText = new JTextArea();
+ forgeDescriptionText.setName("TextAreaForge");
+ forgeDescriptionText.setBounds(x + margin, y + margin, w - margin * 2, h - margin);
+ forgeDescriptionText.setEditable(false);
+ forgeDescriptionText.setHighlighter(null);
+ forgeDescriptionText.setEnabled(true);
+ forgeDescriptionText.setFont(new Font(Font.DIALOG, Font.PLAIN, 12));
+ forgeDescriptionText.setLineWrap(true);
+ forgeDescriptionText.setOpaque(false);
+ forgeDescriptionText.setPreferredSize(new Dimension(w - margin * 2, h - margin));
+ forgeDescriptionText.setText(
+ "However, you still need to install Forge client in order to be able to run this mod. Click here to visit the download page for Forge 1.8.9!");
+ forgeDescriptionText.setForeground(Color.BLUE.darker());
+ forgeDescriptionText.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
+ forgeDescriptionText.setWrapStyleWord(true);
+
+ y += h;
+ } catch (Throwable ivjExc) {
+ showErrorPopup(ivjExc);
+ }
+ }
+ return forgeDescriptionText;
+ }
+
+ private JLabel getLabelFolder() {
+ if (labelFolder == null) {
+ h = 16;
+ w = 65;
+
+ x += 10; // Padding
+
+ try {
+ labelFolder = new JLabel();
+ labelFolder.setName("LabelFolder");
+ labelFolder.setBounds(x, y + 2, w, h);
+ labelFolder.setPreferredSize(new Dimension(w, h));
+ labelFolder.setText("Mods Folder");
+ } catch (Throwable ivjExc) {
+ showErrorPopup(ivjExc);
+ }
+
+ x += w;
+ }
+ return labelFolder;
+ }
+
+ private JTextField getFieldFolder() {
+ if (textFieldFolderLocation == null) {
+ h = 20;
+ w = 287;
+
+ try {
+ textFieldFolderLocation = new JTextField();
+ textFieldFolderLocation.setName("FieldFolder");
+ textFieldFolderLocation.setBounds(x, y, w, h);
+ textFieldFolderLocation.setEditable(false);
+ textFieldFolderLocation.setPreferredSize(new Dimension(w, h));
+ } catch (Throwable ivjExc) {
+ showErrorPopup(ivjExc);
+ }
+
+ x += w;
+ }
+ return textFieldFolderLocation;
+ }
+
+ private JButton getButtonFolder() {
+ if (buttonChooseFolder == null) {
+ h = 20;
+ w = 25;
+
+ x += 10; // Padding
+
+ try {
+ BufferedImage myPicture = ImageIO.read(getClass()
+ .getClassLoader()
+ .getResourceAsStream("assets/notenoughupdates/folder.png"));
+ Image scaled = myPicture.getScaledInstance(w - 8, h - 6, Image.SCALE_SMOOTH);
+ buttonChooseFolder = new JButton(new ImageIcon(scaled));
+ buttonChooseFolder.setName("ButtonFolder");
+ buttonChooseFolder.setBounds(x, y, w, h);
+ buttonChooseFolder.setPreferredSize(new Dimension(w, h));
+ } catch (Throwable ivjExc) {
+ showErrorPopup(ivjExc);
+ }
+ }
+ return buttonChooseFolder;
+ }
+
+ private JPanel getPanelBottom() {
+ if (panelBottom == null) {
+ try {
+ panelBottom = new JPanel();
+ panelBottom.setName("PanelBottom");
+ panelBottom.setLayout(new FlowLayout(FlowLayout.CENTER, 15, 10));
+ panelBottom.setPreferredSize(new Dimension(390, 55));
+ panelBottom.add(getButtonInstall(), getButtonInstall().getName());
+ panelBottom.add(getButtonOpenFolder(), getButtonOpenFolder().getName());
+ panelBottom.add(getButtonClose(), getButtonClose().getName());
+ } catch (Throwable ivjExc) {
+ showErrorPopup(ivjExc);
+ }
+ }
+ return panelBottom;
+ }
+
+ private JButton getButtonInstall() {
+ if (buttonInstall == null) {
+ w = 100;
+ h = 26;
+
+ try {
+ buttonInstall = new JButton();
+ buttonInstall.setName("ButtonInstall");
+ buttonInstall.setPreferredSize(new Dimension(w, h));
+ buttonInstall.setText("Install");
+ } catch (Throwable ivjExc) {
+ showErrorPopup(ivjExc);
+ }
+ }
+ return buttonInstall;
+ }
+
+ private JButton getButtonOpenFolder() {
+ if (buttonOpenFolder == null) {
+ w = 130;
+ h = 26;
+
+ try {
+ buttonOpenFolder = new JButton();
+ buttonOpenFolder.setName("ButtonOpenFolder");
+ buttonOpenFolder.setPreferredSize(new Dimension(w, h));
+ buttonOpenFolder.setText("Open Mods Folder");
+ } catch (Throwable ivjExc) {
+ showErrorPopup(ivjExc);
+ }
+ }
+ return buttonOpenFolder;
+ }
+
+ private JButton getButtonClose() {
+ if (buttonClose == null) {
+ w = 100;
+ h = 26;
+
+ try {
+ (buttonClose = new JButton()).setName("ButtonClose");
+ buttonClose.setPreferredSize(new Dimension(w, h));
+ buttonClose.setText("Cancel");
+ } catch (Throwable ivjExc) {
+ showErrorPopup(ivjExc);
+ }
+ }
+ return buttonClose;
+ }
+
+ public void onFolderSelect() {
+ File currentDirectory = new File(getFieldFolder().getText());
+
+ JFileChooser jFileChooser = new JFileChooser(currentDirectory);
+ jFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+ jFileChooser.setAcceptAllFileFilterUsed(false);
+ if (jFileChooser.showOpenDialog(this) == 0) {
+ File newDirectory = jFileChooser.getSelectedFile();
+ getFieldFolder().setText(newDirectory.getPath());
+ }
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if (e.getSource() == getButtonClose()) {
+ dispose();
+ System.exit(0);
+ }
+ if (e.getSource() == getButtonFolder()) {
+ onFolderSelect();
+ }
+ if (e.getSource() == getButtonInstall()) {
+ onInstall();
+ }
+ if (e.getSource() == getButtonOpenFolder()) {
+ onOpenFolder();
+ }
+ }
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ if (e.getSource() == getForgeTextArea()) {
+ try {
+ Desktop.getDesktop().browse(new URI(
+ "http://files.minecraftforge.net/maven/net/minecraftforge/forge/index_1.8.9.html"));
+ } catch (IOException | URISyntaxException ex) {
+ showErrorPopup(ex);
+ }
+ }
+ }
+
+ public void onInstall() {
+ try {
+ File modsFolder = new File(getFieldFolder().getText());
+ if (!modsFolder.exists()) {
+ showErrorMessage("Folder not found: " + modsFolder.getPath());
+ return;
+ }
+ if (!modsFolder.isDirectory()) {
+ showErrorMessage("Not a folder: " + modsFolder.getPath());
+ return;
+ }
+ tryInstall(modsFolder);
+ } catch (Exception e) {
+ showErrorPopup(e);
+ }
+ }
+
+ private void tryInstall(File modsFolder) {
+ File thisFile = getThisFile();
+
+ if (thisFile != null) {
+ boolean inSubFolder = IN_MODS_SUBFOLDER.matcher(modsFolder.getPath()).find();
+
+ boolean deletingFailure = false;
+ if (modsFolder.isDirectory()) { // Delete in this current folder.
+ boolean failed = findSkyblockAddonsAndDelete(modsFolder.listFiles());
+ if (failed) deletingFailure = true;
+ }
+ if (inSubFolder) { // We are in the 1.8.9 folder, delete in the parent folder as well.
+ if (modsFolder.getParentFile().isDirectory()) {
+ boolean failed = findSkyblockAddonsAndDelete(modsFolder.getParentFile().listFiles());
+ if (failed) deletingFailure = true;
+ }
+ } else { // We are in the main mods folder, but the 1.8.9 subfolder exists... delete in there too.
+ File subFolder = new File(modsFolder, "1.8.9");
+ if (subFolder.exists() && subFolder.isDirectory()) {
+ boolean failed = findSkyblockAddonsAndDelete(subFolder.listFiles());
+ if (failed) deletingFailure = true;
+ }
+ }
+
+ if (deletingFailure) return;
+
+ if (thisFile.isDirectory()) {
+ showErrorMessage("This file is a directory... Are we in a development environment?");
+ return;
+ }
+
+ try {
+ Files.copy(thisFile.toPath(), new File(modsFolder, thisFile.getName()).toPath());
+ } catch (Exception ex) {
+ showErrorPopup(ex);
+ return;
+ }
+
+ showMessage("NotEnoughUpdates has been successfully installed into your mods folder.");
+ dispose();
+ System.exit(0);
+ }
+ }
+
+ private boolean findSkyblockAddonsAndDelete(File[] files) {
+ if (files == null) return false;
+
+ for (File file : files) {
+ if (!file.isDirectory() && file.getPath().endsWith(".jar")) {
+ try {
+ JarFile jarFile = new JarFile(file);
+ ZipEntry mcModInfo = jarFile.getEntry("mcmod.info");
+ if (mcModInfo != null) {
+ InputStream inputStream = jarFile.getInputStream(mcModInfo);
+ String modID = getModIDFromInputStream(inputStream);
+ if (modID.equals("notenoughupdates")) {
+ jarFile.close();
+ try {
+ boolean deleted = file.delete();
+ if (!deleted) {
+ throw new Exception();
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ showErrorMessage("Was not able to delete the other NotEnoughUpdates files found in your mods folder!" +
+ System.lineSeparator() +
+ "Please make sure that your minecraft is currently closed and try again, or feel" +
+ System.lineSeparator() +
+ "free to open your mods folder and delete those files manually.");
+ return true;
+ }
+ continue;
+ }
+ }
+ jarFile.close();
+ } catch (Exception ex) {
+ // Just don't check the file I guess, move on to the next...
+ }
+ }
+ }
+ return false;
+ }
+
+ public void onOpenFolder() {
+ try {
+ Desktop.getDesktop().open(getModsFolder());
+ } catch (Exception e) {
+ showErrorPopup(e);
+ }
+ }
+
+ public File getModsFolder() {
+ String userHome = System.getProperty("user.home", ".");
+
+ File modsFolder = getFile(userHome, "minecraft/mods/1.8.9");
+ if (!modsFolder.exists()) {
+ modsFolder = getFile(userHome, "minecraft/mods");
+ }
+
+ if (!modsFolder.exists() && !modsFolder.mkdirs()) {
+ throw new RuntimeException("The working directory could not be created: " + modsFolder);
+ }
+ return modsFolder;
+ }
+
+ public File getFile(String userHome, String minecraftPath) {
+ File workingDirectory;
+ switch (getOperatingSystem()) {
+ case LINUX:
+ case SOLARIS: {
+ workingDirectory = new File(userHome, '.' + minecraftPath + '/');
+ break;
+ }
+ case WINDOWS: {
+ String applicationData = System.getenv("APPDATA");
+ if (applicationData != null) {
+ workingDirectory = new File(applicationData, "." + minecraftPath + '/');
+ break;
+ }
+ workingDirectory = new File(userHome, '.' + minecraftPath + '/');
+ break;
+ }
+ case MACOS: {
+ workingDirectory = new File(userHome, "Library/Application Support/" + minecraftPath);
+ break;
+ }
+ default: {
+ workingDirectory = new File(userHome, minecraftPath + '/');
+ break;
+ }
+ }
+ return workingDirectory;
+ }
+
+ public OperatingSystem getOperatingSystem() {
+ String osName = System.getProperty("os.name").toLowerCase(Locale.US);
+ if (osName.contains("win")) {
+ return OperatingSystem.WINDOWS;
+
+ } else if (osName.contains("mac")) {
+ return OperatingSystem.MACOS;
+
+ } else if (osName.contains("solaris") || osName.contains("sunos")) {
+
+ return OperatingSystem.SOLARIS;
+ } else if (osName.contains("linux") || osName.contains("unix")) {
+
+ return OperatingSystem.LINUX;
+ }
+ return OperatingSystem.UNKNOWN;
+ }
+
+ public void centerFrame(JFrame frame) {
+ Rectangle rectangle = frame.getBounds();
+ Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+ Rectangle screenRectangle = new Rectangle(0, 0, screenSize.width, screenSize.height);
+
+ int newX = screenRectangle.x + (screenRectangle.width - rectangle.width) / 2;
+ int newY = screenRectangle.y + (screenRectangle.height - rectangle.height) / 2;
+
+ if (newX < 0) newX = 0;
+ if (newY < 0) newY = 0;
+
+ frame.setBounds(newX, newY, rectangle.width, rectangle.height);
+ }
+
+ public void showMessage(String message) {
+ JOptionPane.showMessageDialog(null, message, "NotEnoughUpdates", JOptionPane.INFORMATION_MESSAGE);
+ }
+
+ public void showErrorMessage(String message) {
+ JOptionPane.showMessageDialog(null, message, "NotEnoughUpdates - Error", JOptionPane.ERROR_MESSAGE);
+ }
+
+ public enum OperatingSystem {
+ LINUX,
+ SOLARIS,
+ WINDOWS,
+ MACOS,
+ UNKNOWN
+ }
+
+ private static String getStacktraceText(Throwable ex) {
+ StringWriter stringWriter = new StringWriter();
+ ex.printStackTrace(new PrintWriter(stringWriter));
+ return stringWriter.toString().replace("\t", " ");
+ }
+
+ private static void showErrorPopup(Throwable ex) {
+ ex.printStackTrace();
+
+ JTextArea textArea = new JTextArea(getStacktraceText(ex));
+ textArea.setEditable(false);
+ Font currentFont = textArea.getFont();
+ Font newFont = new Font(Font.MONOSPACED, currentFont.getStyle(), currentFont.getSize());
+ textArea.setFont(newFont);
+
+ JScrollPane errorScrollPane = new JScrollPane(textArea);
+ errorScrollPane.setPreferredSize(new Dimension(600, 400));
+ JOptionPane.showMessageDialog(null, errorScrollPane, "Error", JOptionPane.ERROR_MESSAGE);
+ }
+
+ private String getVersionFromMcmodInfo() {
+ String version = "";
+ try {
+ BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(getClass()
+ .getClassLoader()
+ .getResourceAsStream("mcmod.info")));
+ while ((version = bufferedReader.readLine()) != null) {
+ if (version.contains("\"version\": \"")) {
+ version = version.split(Pattern.quote("\"version\": \""))[1];
+ version = version.substring(0, version.length() - 2);
+ break;
+ }
+ }
+ } catch (Exception ex) {
+ // It's okay, I guess just don't use the version lol.
+ }
+ return version;
+ }
+
+ private String getModIDFromInputStream(InputStream inputStream) {
+ String version = "";
+ try {
+ BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
+ while ((version = bufferedReader.readLine()) != null) {
+ if (version.contains("\"modid\": \"")) {
+ version = version.split(Pattern.quote("\"modid\": \""))[1];
+ version = version.substring(0, version.length() - 2);
+ break;
+ }
+ }
+ } catch (Exception ex) {
+ // RIP, couldn't find the modid...
+ }
+ return version;
+ }
+
+ private File getThisFile() {
+ try {
+ return new File(NotSkyblockAddonsInstallerFrame.class
+ .getProtectionDomain()
+ .getCodeSource()
+ .getLocation()
+ .toURI());
+ } catch (URISyntaxException ex) {
+ showErrorPopup(ex);
+ }
+ return null;
+ }
+
+ @Override
+ public void mousePressed(MouseEvent e) {}
+
+ @Override
+ public void mouseReleased(MouseEvent e) {}
+
+ @Override
+ public void mouseEntered(MouseEvent e) {}
+
+ @Override
+ public void mouseExited(MouseEvent e) {}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/CustomItems.java b/src/main/java/io/github/moulberry/notenoughupdates/CustomItems.java
index c16cb7d0..28686073 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/CustomItems.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/CustomItems.java
@@ -7,84 +7,100 @@ import io.github.moulberry.notenoughupdates.util.Constants;
import net.minecraft.util.EnumChatFormatting;
public class CustomItems {
+ /*
+ * So it has come to this, huh? Snooping through the source to find all my carefully crafted easter eggs. You
+ * cheated not only the game, but yourself. You didn't grow. You didn't improve. You took a
+ * shortcut and gained nothing. You experienced a hollow victory. Nothing was risked and nothing was gained.
+ * It's sad that you don't know the difference.
+ */
- /**
- * So it has come to this, huh? Snooping through the source to find all my carefully crafted easter eggs. You
- * cheated not only the game, but yourself. You didn't grow. You didn't improve. You took a
- * shortcut and gained nothing. You experienced a hollow victory. Nothing was risked and nothing was gained.
- * It's sad that you don't know the difference.
- */
+ public static JsonObject NULLZEE = create(
+ "NULLZEE",
+ "dirt",
+ "Nullzee242 Youtube Channel",
+ "Dirt, AOTD. Dirt, AOTD.",
+ "Dirt, AOTD. Dirt, AOTD.",
+ "Ooh, Dirt to Midas! Let's shake it up a little.",
+ "",
+ "Also, did you know that only 8.7% of the people watching are subscribed?",
+ "It's OK, everyone makes mistakes",
+ "Also follow -> twitch.tv/nullzeelive",
+ "Also -> discord.gg/nullzee"
+ );
+ public static JsonObject DUCTTAPE = create(
+ "DUCTTAPE",
+ "iron_shovel",
+ "You ever accidentally bury your duct tape?",
+ "No problem! Our team of experts specialise in",
+ "subterranean duct tape excavation. That's right:",
+ "your buried duct tape problems are a thing of the past,",
+ "all for the low price of $7.99 or a subscription",
+ "to the Ducttapedigger youtube channel!"
+ );
+ public static JsonObject SPINAXX = create(
+ "SPINAXX",
+ "emerald",
+ "Spinaxx",
+ "Famous streamer btw :)"
+ );
+ public static JsonObject RUNE = create("RUNE", "paper", "No.", "I hate runes.");
+ public static JsonObject TWOBEETWOTEE = create(
+ "2B2T",
+ "bedrock",
+ "Minecraft's oldest anarchy Minecraft server in Minecraft.",
+ "This Minecraft anarchy server is the oldest server,",
+ "being a server since 2010 when Minecraft was a game with a server.",
+ "It is complete anarchy in Minecraft which means that there is total anarchy.",
+ "Hacking is allowed in Minecraft on this anarchy server which",
+ "is the oldest anarchy server in Minecraft, 2b2t. Hack. Steal. Cheat. Lie.",
+ "On the oldest anarchy server in Minecraft. 2b2t. The worst server in Minecraft,",
+ "where there are no rules. On the oldest anarchy server in Minecraft.",
+ "In this Minecraft anarchy server, there have been numerous Minecraft",
+ "incursions on the server, some of which I, a player on this Minecraft",
+ "anarchy server in Minecraft, have participated in. One of this server's",
+ "most infamous Minecraft players on the oldest Minecraft"
+ );
+ public static JsonObject LEOCTHL = create(
+ "LEOCTHL",
+ "dragon_egg",
+ "--- Stats below may not be entirely accurate ---",
+ "17 legendary dragon pets",
+ "24 epic dragon pets",
+ "18 epic golem pets",
+ "12 legendary golem pets",
+ "39 legendary phoenix pets",
+ "",
+ "get flexed"
+ );
+ public static JsonObject CREDITS = Constants.MISC.getAsJsonObject("credits");
+ public static JsonObject IRONM00N = create(
+ "IRONM00N",
+ "end_stone",
+ "IRONM00N",
+ "Your life has been a lie,",
+ "the moon is made out of iron."
+ );
+ public static JsonObject NOPO = create(
+ "nopo",
+ "writable_book",
+ "Nopo",
+ "We do a lil Chatting"
+ );
- public static JsonObject NULLZEE = create(
- "NULLZEE",
- "dirt",
- "Nullzee242 Youtube Channel",
- "Dirt, AOTD. Dirt, AOTD.",
- "Dirt, AOTD. Dirt, AOTD.",
- "Ooh, Dirt to Midas! Let's shake it up a little.",
- "",
- "Also, did you know that only 8.7% of the people watching are subscribed?",
- "It's OK, everyone makes mistakes",
- "Also follow -> twitch.tv/nullzeelive",
- "Also -> discord.gg/nullzee");
- public static JsonObject DUCTTAPE = create(
- "DUCTTAPE",
- "iron_shovel",
- "You ever accidentally bury your duct tape?",
- "No problem! Our team of experts specialise in",
- "subterranean duct tape excavation. That's right:",
- "your buried duct tape problems are a thing of the past,",
- "all for the low price of $7.99 or a subscription",
- "to the Ducttapedigger youtube channel!");
- public static JsonObject SPINAXX = create(
- "SPINAXX",
- "emerald",
- "Spinaxx",
- "Famous streamer btw :)");
- public static JsonObject RUNE = create("RUNE", "paper", "No.", "I hate runes.");
- public static JsonObject TWOBEETWOTEE = create("2B2T", "bedrock", "Minecraft's oldest anarchy Minecraft server in Minecraft.",
- "This Minecraft anarchy server is the oldest server,",
- "being a server since 2010 when Minecraft was a game with a server.",
- "It is complete anarchy in Minecraft which means that there is total anarchy.",
- "Hacking is allowed in Minecraft on this anarchy server which",
- "is the oldest anarchy server in Minecraft, 2b2t. Hack. Steal. Cheat. Lie.",
- "On the oldest anarchy server in Minecraft. 2b2t. The worst server in Minecraft,",
- "where there are no rules. On the oldest anarchy server in Minecraft.",
- "In this Minecraft anarchy server, there have been numerous Minecraft",
- "incursions on the server, some of which I, a player on this Minecraft",
- "anarchy server in Minecraft, have participated in. One of this server's",
- "most infamous Minecraft players on the oldest Minecraft");
- public static JsonObject LEOCTHL = create("LEOCTHL", "dragon_egg", "--- Stats below may not be entirely accurate ---",
- "17 legendary dragon pets",
- "24 epic dragon pets",
- "18 epic golem pets",
- "12 legendary golem pets",
- "39 legendary phoenix pets",
- "",
- "get flexed");
- public static JsonObject CREDITS = Constants.MISC.getAsJsonObject("credits");
- public static JsonObject IRONM00N = create(
- "IRONM00N",
- "end_stone",
- "IRONM00N",
- "Your life has been a lie,",
- "the moon is made out of iron."
- );
+ /*
+ * SHAAAAAAAAAAAAAAAAAAME
+ */
- /**
- * SHAAAAAAAAAAAAAAAAAAME
- */
-
- private static JsonObject create(String internalname, String itemid, String displayname, String... lore) {
- JsonObject json = new JsonObject();
- json.addProperty("itemid", itemid);
- json.addProperty("internalname", internalname);
- json.addProperty("displayname", EnumChatFormatting.RED+displayname);
- JsonArray jsonlore = new JsonArray();
- for(String line : lore) {
- jsonlore.add(new JsonPrimitive(EnumChatFormatting.GRAY + line));
- }
- json.add("lore", jsonlore);
- return json;
- }
+ private static JsonObject create(String internalname, String itemid, String displayname, String... lore) {
+ JsonObject json = new JsonObject();
+ json.addProperty("itemid", itemid);
+ json.addProperty("internalname", internalname);
+ json.addProperty("displayname", EnumChatFormatting.RED + displayname);
+ JsonArray jsonlore = new JsonArray();
+ for (String line : lore) {
+ jsonlore.add(new JsonPrimitive(EnumChatFormatting.GRAY + line));
+ }
+ json.add("lore", jsonlore);
+ return json;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java b/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java
index 83c4b7ae..1804831b 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java
@@ -1,5 +1,6 @@
package io.github.moulberry.notenoughupdates;
+import com.google.gson.Gson;
import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.auction.APIManager;
import io.github.moulberry.notenoughupdates.core.config.KeybindHelper;
@@ -10,233 +11,344 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import org.lwjgl.input.Keyboard;
+import java.io.*;
+import java.nio.charset.StandardCharsets;
import java.text.NumberFormat;
+import java.util.HashSet;
import java.util.List;
import java.util.Locale;
+import java.util.Set;
public class ItemPriceInformation {
+ private static File file;
+ private static HashSet<String> auctionableItems = null;
+ private static Gson gson;
- public static boolean addToTooltip(List<String> tooltip, String internalname, ItemStack stack) {
- return addToTooltip(tooltip, internalname, stack, true);
- }
-
- public static boolean addToTooltip(List<String> tooltip, String internalname, ItemStack stack, boolean useStackSize) {
- if(stack.getTagCompound().hasKey("disableNeuTooltip") && stack.getTagCompound().getBoolean("disableNeuTooltip")){
- return false;
- }
- if(NotEnoughUpdates.INSTANCE.config.tooltipTweaks.disablePriceKey && !KeybindHelper.isKeyDown(NotEnoughUpdates.INSTANCE.config.tooltipTweaks.disablePriceKeyKeybind)){
- return false;
- }
- JsonObject auctionInfo = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfo(internalname);
- JsonObject bazaarInfo = NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarInfo(internalname);
- float lowestBinAvg = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAvgBin(internalname);
-
- int lowestBin = NotEnoughUpdates.INSTANCE.manager.auctionManager.getLowestBin(internalname);
- APIManager.CraftInfo craftCost = NotEnoughUpdates.INSTANCE.manager.auctionManager.getCraftCost(internalname);
-
- boolean auctionItem = lowestBin > 0 || lowestBinAvg > 0 || auctionInfo != null;
- boolean bazaarItem = bazaarInfo != null;
-
- NumberFormat format = NumberFormat.getInstance(Locale.US);
-
- if(bazaarItem) {
- List<Integer> lines = NotEnoughUpdates.INSTANCE.config.tooltipTweaks.priceInfoBaz;
-
- boolean added = false;
-
- boolean shiftPressed = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT);
-
- int stackMultiplier = 1;
- int shiftStackMultiplier = useStackSize && stack.stackSize > 1 ? stack.stackSize : 64;
- if(shiftPressed) {
- stackMultiplier = shiftStackMultiplier;
- }
-
- //values = {"", "Buy", "Sell", "Buy (Insta)", "Sell (Insta)", "Raw Craft Cost"}
- for(int lineId : lines) {
- switch (lineId) {
- case 0:
- if(bazaarInfo.has("avg_buy")) {
- if(!added) {
- tooltip.add("");
- if(!shiftPressed) tooltip.add(EnumChatFormatting.DARK_GRAY.toString()+"[SHIFT show x"+shiftStackMultiplier+"]");
- added = true;
- }
- int bazaarBuyPrice = (int)bazaarInfo.get("avg_buy").getAsFloat()*stackMultiplier;
- tooltip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Buy: "+
- EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarBuyPrice)+" coins");
- }
- break;
- case 1:
- if(bazaarInfo.has("avg_sell")) {
- if(!added) {
- tooltip.add("");
- if(!shiftPressed) tooltip.add(EnumChatFormatting.DARK_GRAY.toString()+"[SHIFT show x"+shiftStackMultiplier+"]");
- added = true;
- }
- int bazaarSellPrice = (int)bazaarInfo.get("avg_sell").getAsFloat()*stackMultiplier;
- tooltip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Sell: "+
- EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarSellPrice)+" coins");
- }
- break;
- case 2:
- if(bazaarInfo.has("curr_buy")) {
- if(!added) {
- tooltip.add("");
- if(!shiftPressed) tooltip.add(EnumChatFormatting.DARK_GRAY.toString()+"[SHIFT show x"+shiftStackMultiplier+"]");
- added = true;
- }
- int bazaarInstantBuyPrice = (int)bazaarInfo.get("curr_buy").getAsFloat()*stackMultiplier;
- tooltip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Insta-Buy: "+
- EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarInstantBuyPrice)+" coins");
- }
- break;
- case 3:
- if(bazaarInfo.has("curr_sell")) {
- if(!added) {
- tooltip.add("");
- if(!shiftPressed) tooltip.add(EnumChatFormatting.DARK_GRAY.toString()+"[SHIFT show x"+shiftStackMultiplier+"]");
- added = true;
- }
- int bazaarInstantSellPrice = (int)bazaarInfo.get("curr_sell").getAsFloat()*stackMultiplier;
- tooltip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Insta-Sell: "+
- EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarInstantSellPrice)+" coins");
- }
- break;
- case 4:
- if(craftCost.fromRecipe) {
- if((int)craftCost.craftCost == 0){ continue;}
- if(!added) {
- tooltip.add("");
- added = true;
- }
- tooltip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Raw Craft Cost: "+
- EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format((int)craftCost.craftCost)+" coins");
- }
- break;
- }
- }
-
- return added;
- } else if(auctionItem) {
- List<Integer> lines = NotEnoughUpdates.INSTANCE.config.tooltipTweaks.priceInfoAuc;
-
- boolean added = false;
-
- for(int lineId : lines) {
- switch (lineId) {
- case 0:
- if(lowestBin > 0) {
- if(!added) {
- tooltip.add("");
- added = true;
- }
- tooltip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Lowest BIN: " +
- EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(lowestBin)+" coins");
- }
- break;
- case 1:
- if(auctionInfo != null) {
- if(!added) {
- tooltip.add("");
- added = true;
- }
-
- if(auctionInfo.has("clean_price")) {
- tooltip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"AH Price (Clean): "+ EnumChatFormatting.GOLD+
- EnumChatFormatting.BOLD+
- format.format((int)auctionInfo.get("clean_price").getAsFloat())+" coins");
- } else {
- int auctionPrice = (int)(auctionInfo.get("price").getAsFloat() / auctionInfo.get("count").getAsFloat());
- tooltip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"AH Price: "+ EnumChatFormatting.GOLD+
- EnumChatFormatting.BOLD+format.format(auctionPrice)+" coins");
- }
-
- }
- break;
- case 2:
- if(auctionInfo != null) {
- if(!added) {
- tooltip.add("");
- added = true;
- }
- if(auctionInfo.has("clean_price")) {
- tooltip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"AH Sales (Clean): "+
- EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+
- format.format(auctionInfo.get("clean_sales").getAsFloat())+" sales/day");
- } else {
- tooltip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"AH Sales: "+
- EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+
- format.format(auctionInfo.get("sales").getAsFloat())+" sales/day");
- }
- }
- break;
- case 3:
- if(craftCost.fromRecipe) {
- if((int)craftCost.craftCost == 0){ continue;}
- if(!added) {
- tooltip.add("");
- added = true;
- }
- tooltip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Raw Craft Cost: "+
- EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format((int)craftCost.craftCost)+" coins");
- }
- break;
- case 4:
- if(lowestBinAvg > 0) {
- if(!added) {
- tooltip.add("");
- added = true;
- }
- tooltip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"AVG Lowest BIN: "+
- EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(lowestBinAvg)+" coins");
- }
- break;
- case 5:
- if(Constants.ESSENCECOSTS == null) break;
- JsonObject essenceCosts = Constants.ESSENCECOSTS;
- if(!essenceCosts.has(internalname)) {
- break;
- }
- JsonObject itemCosts = essenceCosts.get(internalname).getAsJsonObject();
- String essenceType = itemCosts.get("type").getAsString();
-
- int dungeonItemLevel = -1;
- if(stack != null && stack.hasTagCompound() &&
- stack.getTagCompound().hasKey("ExtraAttributes", 10)) {
- NBTTagCompound ea = stack.getTagCompound().getCompoundTag("ExtraAttributes");
-
- if (ea.hasKey("dungeon_item_level", 99)) {
- dungeonItemLevel = ea.getInteger("dungeon_item_level");
- }
- }
- if(dungeonItemLevel == -1) {
- int dungeonizeCost = 0;
- if(itemCosts.has("dungeonize")) {
- dungeonizeCost = itemCosts.get("dungeonize").getAsInt();
- }
- tooltip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Dungeonize Cost: " +
- EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+dungeonizeCost+" "+essenceType);
- } else if(dungeonItemLevel >= 0 && dungeonItemLevel <= 4) {
- String costType = (dungeonItemLevel+1)+"";
-
- int upgradeCost = itemCosts.get(costType).getAsInt();
- StringBuilder star = new StringBuilder();
- for(int i=0; i<=dungeonItemLevel; i++) {
- star.append('\u272A');
- }
- tooltip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Upgrade to "+
- EnumChatFormatting.GOLD+star+EnumChatFormatting.YELLOW+EnumChatFormatting.BOLD+": " +
- EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+upgradeCost+" "+essenceType);
- }
- break;
- }
- }
-
- return added;
- }
-
- return false;
- }
+ public static boolean addToTooltip(List<String> tooltip, String internalname, ItemStack stack) {
+ return addToTooltip(tooltip, internalname, stack, true);
+ }
+ public static void init(File saveLocation, Gson neuGson) {
+ file = saveLocation;
+ gson = neuGson;
+ if (file.exists()) {
+ try (
+ BufferedReader reader = new BufferedReader(new InputStreamReader(
+ new FileInputStream(file),
+ StandardCharsets.UTF_8
+ ))
+ ) {
+ auctionableItems = gson.fromJson(reader, HashSet.class);
+ } catch (Exception ignored) {
+ }
+ }
+ }
+
+ public static void updateAuctionableItemsList() {
+ Set<String> items = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfoKeySet();
+ if (!items.isEmpty()) {
+ auctionableItems = (HashSet<String>) items;
+ try (
+ BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
+ new FileOutputStream(file),
+ StandardCharsets.UTF_8
+ ))
+ ) {
+ //noinspection ResultOfMethodCallIgnored
+ file.createNewFile();
+ writer.write(gson.toJson(items));
+ } catch (IOException ignored) {
+ }
+ }
+ }
+
+ public static boolean addToTooltip(List<String> tooltip, String internalname, ItemStack stack, boolean useStackSize) {
+ if (stack.getTagCompound().hasKey("disableNeuTooltip") && stack.getTagCompound().getBoolean("disableNeuTooltip")) {
+ return false;
+ }
+ if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.disablePriceKey &&
+ !KeybindHelper.isKeyDown(NotEnoughUpdates.INSTANCE.config.tooltipTweaks.disablePriceKeyKeybind)) {
+ return false;
+ }
+ if (internalname.equals("SKYBLOCK_MENU")) {
+ return false;
+ }
+ JsonObject auctionInfo = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfo(internalname);
+ JsonObject bazaarInfo = NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarInfo(internalname);
+ float lowestBinAvg = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAvgBin(internalname);
+
+ int lowestBin = NotEnoughUpdates.INSTANCE.manager.auctionManager.getLowestBin(internalname);
+ APIManager.CraftInfo craftCost = NotEnoughUpdates.INSTANCE.manager.auctionManager.getCraftCost(internalname);
+
+ boolean auctionItem = lowestBin > 0 || lowestBinAvg > 0;
+ boolean auctionInfoErrored = auctionInfo == null;
+ if (auctionItem) {
+ long currentTime = System.currentTimeMillis();
+ long lastUpdate = NotEnoughUpdates.INSTANCE.manager.auctionManager.getLastLowestBinUpdateTime();
+ //check if info is older than 10 minutes
+ if (currentTime - lastUpdate > 600 * 1000) {
+ tooltip.add(EnumChatFormatting.RED + "[NEU] Price info is outdated.");
+ tooltip.add(EnumChatFormatting.RED + "It will be updated again as soon as possible.");
+ }
+ }
+
+ boolean bazaarItem = bazaarInfo != null;
+
+ NumberFormat format = NumberFormat.getInstance(Locale.US);
+ boolean shortNumber = NotEnoughUpdates.INSTANCE.config.tooltipTweaks.shortNumberFormatPrices;
+ if (bazaarItem) {
+ List<Integer> lines = NotEnoughUpdates.INSTANCE.config.tooltipTweaks.priceInfoBaz;
+
+ boolean added = false;
+
+ boolean shiftPressed = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT);
+
+ int stackMultiplier = 1;
+ int shiftStackMultiplier = useStackSize && stack.stackSize > 1 ? stack.stackSize : 64;
+ if (shiftPressed) {
+ stackMultiplier = shiftStackMultiplier;
+ }
+
+ //values = {"", "Buy", "Sell", "Buy (Insta)", "Sell (Insta)", "Raw Craft Cost"}
+ for (int lineId : lines) {
+ switch (lineId) {
+ case 0:
+ if (bazaarInfo.has("avg_buy")) {
+ if (!added) {
+ tooltip.add("");
+ if (!shiftPressed)
+ tooltip.add(EnumChatFormatting.DARK_GRAY + "[SHIFT show x" + shiftStackMultiplier + "]");
+ added = true;
+ }
+ int bazaarBuyPrice = (int) bazaarInfo.get("avg_buy").getAsFloat() * stackMultiplier;
+ tooltip.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "Bazaar Buy: " +
+ EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + (shortNumber && bazaarBuyPrice > 1000
+ ? Utils.shortNumberFormat(bazaarBuyPrice, 0)
+ : format.format(bazaarBuyPrice)) + " coins");
+ }
+ break;
+ case 1:
+ if (bazaarInfo.has("avg_sell")) {
+ if (!added) {
+ tooltip.add("");
+ if (!shiftPressed)
+ tooltip.add(EnumChatFormatting.DARK_GRAY + "[SHIFT show x" + shiftStackMultiplier + "]");
+ added = true;
+ }
+ int bazaarSellPrice = (int) bazaarInfo.get("avg_sell").getAsFloat() * stackMultiplier;
+ tooltip.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "Bazaar Sell: " +
+ EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + (shortNumber && bazaarSellPrice > 1000
+ ? Utils.shortNumberFormat(bazaarSellPrice, 0)
+ : format.format(bazaarSellPrice)) + " coins");
+ }
+ break;
+ case 2:
+ if (bazaarInfo.has("curr_buy")) {
+ if (!added) {
+ tooltip.add("");
+ if (!shiftPressed)
+ tooltip.add(EnumChatFormatting.DARK_GRAY + "[SHIFT show x" + shiftStackMultiplier + "]");
+ added = true;
+ }
+ int bazaarInstantBuyPrice = (int) bazaarInfo.get("curr_buy").getAsFloat() * stackMultiplier;
+ tooltip.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "Bazaar Insta-Buy: " +
+ EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + (shortNumber && bazaarInstantBuyPrice > 1000
+ ? Utils.shortNumberFormat(bazaarInstantBuyPrice, 0)
+ : format.format(bazaarInstantBuyPrice)) +
+ " coins");
+ }
+ break;
+ case 3:
+ if (bazaarInfo.has("curr_sell")) {
+ if (!added) {
+ tooltip.add("");
+ if (!shiftPressed)
+ tooltip.add(EnumChatFormatting.DARK_GRAY + "[SHIFT show x" + shiftStackMultiplier + "]");
+ added = true;
+ }
+ int bazaarInstantSellPrice = (int) bazaarInfo.get("curr_sell").getAsFloat() * stackMultiplier;
+ tooltip.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "Bazaar Insta-Sell: " +
+ EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + (shortNumber && bazaarInstantSellPrice > 1000
+ ? Utils.shortNumberFormat(
+ bazaarInstantSellPrice,
+ 0
+ )
+ : format.format(bazaarInstantSellPrice)) +
+ " coins");
+ }
+ break;
+ case 4:
+ if (craftCost != null && craftCost.fromRecipe) {
+ if ((int) craftCost.craftCost == 0) {
+ continue;
+ }
+ if (!added) {
+ tooltip.add("");
+ added = true;
+ }
+ float cost = craftCost.craftCost;
+ if (shiftPressed) cost = cost * shiftStackMultiplier;
+
+ tooltip.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "Raw Craft Cost: " +
+ EnumChatFormatting.GOLD + EnumChatFormatting.BOLD +
+ (shortNumber && cost > 1000 ? Utils.shortNumberFormat(cost, 0) : format.format((int) cost)) + " coins");
+ }
+ break;
+ }
+ }
+
+ return added;
+ } else if (auctionItem) {
+ List<Integer> lines = NotEnoughUpdates.INSTANCE.config.tooltipTweaks.priceInfoAuc;
+
+ boolean added = false;
+
+ for (int lineId : lines) {
+ switch (lineId) {
+ case 0:
+ if (lowestBin > 0) {
+ if (!added) {
+ tooltip.add("");
+ added = true;
+ }
+ tooltip.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "Lowest BIN: " +
+ EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + format.format(lowestBin) + " coins");
+ }
+ break;
+ case 1:
+ if (auctionInfo != null) {
+ if (!added) {
+ tooltip.add("");
+ added = true;
+ }
+
+ if (auctionInfo.has("clean_price")) {
+ tooltip.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "AH Price (Clean): " +
+ EnumChatFormatting.GOLD + EnumChatFormatting.BOLD +
+ (shortNumber && auctionInfo.get("clean_price").getAsFloat() > 1000 ? Utils.shortNumberFormat(
+ auctionInfo.get("clean_price").getAsFloat(),
+ 0
+ ) : format.format((int) auctionInfo.get("clean_price").getAsFloat())
+ + " coins"));
+ } else {
+ int auctionPrice =
+ (int) (auctionInfo.get("price").getAsFloat() / auctionInfo.get("count").getAsFloat());
+ tooltip.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "AH Price: " +
+ EnumChatFormatting.GOLD + EnumChatFormatting.BOLD +
+ (shortNumber && auctionPrice > 1000
+ ? Utils.shortNumberFormat(auctionPrice, 0)
+ : format.format(auctionPrice)) + " coins");
+ }
+
+ }
+ break;
+ case 2:
+ if (auctionInfo != null) {
+ if (!added) {
+ tooltip.add("");
+ added = true;
+ }
+ if (auctionInfo.has("clean_price")) {
+ tooltip.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "AH Sales (Clean): " +
+ EnumChatFormatting.GOLD + EnumChatFormatting.BOLD +
+ (auctionInfo.get("clean_sales").getAsFloat() < 2 ?
+ format.format(auctionInfo.get("clean_sales").getAsFloat()) + " sale/day"
+ :
+ format.format(auctionInfo.get("clean_sales").getAsFloat()) + " sales/day"));
+ } else {
+ tooltip.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "AH Sales: " +
+ EnumChatFormatting.GOLD + EnumChatFormatting.BOLD +
+ (auctionInfo.get("sales").getAsFloat() < 2 ? format.format(auctionInfo.get("sales").getAsFloat()) +
+ " sale/day"
+ : format.format(auctionInfo.get("sales").getAsFloat()) +
+ " sales/day"));
+ }
+ }
+ break;
+ case 3:
+ if (craftCost != null && craftCost.fromRecipe) {
+ if ((int) craftCost.craftCost == 0) {
+ continue;
+ }
+ if (!added) {
+ tooltip.add("");
+ added = true;
+ }
+ tooltip.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "Raw Craft Cost: " +
+ EnumChatFormatting.GOLD + EnumChatFormatting.BOLD +
+ (shortNumber && craftCost.craftCost > 1000
+ ? Utils.shortNumberFormat(craftCost.craftCost, 0)
+ : format.format((int) craftCost.craftCost)) + " coins");
+ }
+ break;
+ case 4:
+ if (lowestBinAvg > 0) {
+ if (!added) {
+ tooltip.add("");
+ added = true;
+ }
+ tooltip.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "AVG Lowest BIN: " +
+ EnumChatFormatting.GOLD + EnumChatFormatting.BOLD +
+ (shortNumber && lowestBinAvg > 1000
+ ? Utils.shortNumberFormat(lowestBinAvg, 0)
+ : format.format(lowestBinAvg)) + " coins");
+ }
+ break;
+ case 5:
+ if (Constants.ESSENCECOSTS == null) break;
+ JsonObject essenceCosts = Constants.ESSENCECOSTS;
+ if (!essenceCosts.has(internalname)) {
+ break;
+ }
+ JsonObject itemCosts = essenceCosts.get(internalname).getAsJsonObject();
+ String essenceType = itemCosts.get("type").getAsString();
+
+ int dungeonItemLevel = -1;
+ if (stack != null && stack.hasTagCompound() &&
+ stack.getTagCompound().hasKey("ExtraAttributes", 10)) {
+ NBTTagCompound ea = stack.getTagCompound().getCompoundTag("ExtraAttributes");
+
+ if (ea.hasKey("dungeon_item_level", 99)) {
+ dungeonItemLevel = ea.getInteger("dungeon_item_level");
+ }
+ }
+ if (dungeonItemLevel == -1) {
+ int dungeonizeCost = 0;
+ if (itemCosts.has("dungeonize")) {
+ dungeonizeCost = itemCosts.get("dungeonize").getAsInt();
+ }
+ tooltip.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "Dungeonize Cost: " +
+ EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + dungeonizeCost + " " + essenceType);
+ } else if (dungeonItemLevel >= 0 && dungeonItemLevel <= 4) {
+ String costType = (dungeonItemLevel + 1) + "";
+
+ int upgradeCost = itemCosts.get(costType).getAsInt();
+ StringBuilder star = new StringBuilder();
+ for (int i = 0; i <= dungeonItemLevel; i++) {
+ star.append('\u272A');
+ }
+ tooltip.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "Upgrade to " +
+ EnumChatFormatting.GOLD + star + EnumChatFormatting.YELLOW + EnumChatFormatting.BOLD + ": " +
+ EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + upgradeCost + " " + essenceType);
+ }
+ break;
+ }
+ }
+
+ return added;
+ } else if (auctionInfoErrored) {
+ String message = EnumChatFormatting.RED.toString() + EnumChatFormatting.BOLD + "[NEU] API is down";
+ if (auctionableItems != null && !auctionableItems.isEmpty()) {
+ if (auctionableItems.contains(internalname)) {
+ tooltip.add(message);
+ return true;
+ }
+ } else {
+ tooltip.add(message + " and no item data is cached");
+ return true;
+ }
+ }
+
+ return false;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUApi.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUApi.java
index 56a196b4..d83035d0 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUApi.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUApi.java
@@ -3,8 +3,9 @@ package io.github.moulberry.notenoughupdates;
import net.minecraftforge.fml.relauncher.ReflectionHelper;
public class NEUApi {
- static boolean disableInventoryButtons = false;
- public static void setInventoryButtonsToDisabled(){
- disableInventoryButtons = true;
- }
+ static boolean disableInventoryButtons = false;
+
+ public static void setInventoryButtonsToDisabled() {
+ disableInventoryButtons = true;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java
index 42b53ef2..84289e34 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java
@@ -1,10 +1,14 @@
package io.github.moulberry.notenoughupdates;
import com.google.common.collect.Lists;
-import com.google.gson.*;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import io.github.moulberry.notenoughupdates.auction.CustomAHGui;
+import io.github.moulberry.notenoughupdates.commands.profile.ViewProfileCommand;
import io.github.moulberry.notenoughupdates.core.BackgroundBlur;
import io.github.moulberry.notenoughupdates.core.GuiScreenElementWrapper;
import io.github.moulberry.notenoughupdates.core.util.MiscUtils;
@@ -30,6 +34,7 @@ import net.minecraft.event.ClickEvent;
import net.minecraft.init.Items;
import net.minecraft.inventory.ContainerChest;
import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
@@ -65,333 +70,356 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import static io.github.moulberry.notenoughupdates.overlays.SlayerOverlay.*;
import static io.github.moulberry.notenoughupdates.util.GuiTextures.dungeon_chest_worth;
public class NEUEventListener {
- private final NotEnoughUpdates neu;
-
- private boolean hoverInv = false;
- private boolean focusInv = false;
-
- private boolean joinedSB = false;
-
- public NEUEventListener(NotEnoughUpdates neu) {
- this.neu = neu;
- }
-
- private void displayUpdateMessageIfOutOfDate() {
- File repo = neu.manager.repoLocation;
- if(repo.exists()) {
- File updateJson = new File(repo, "update.json");
- try {
- JsonObject o = neu.manager.getJsonFromFile(updateJson);
-
- String version = o.get("version").getAsString();
- String preVersion = o.get("pre_version").getAsString();
-
- boolean shouldUpdate = !NotEnoughUpdates.VERSION.equalsIgnoreCase(version);
- boolean shouldPreUpdate = !NotEnoughUpdates.PRE_VERSION.equalsIgnoreCase(preVersion);
-
- if(o.has("version_id") && o.get("version_id").isJsonPrimitive()) {
- int version_id = o.get("version_id").getAsInt();
- shouldUpdate = version_id > NotEnoughUpdates.VERSION_ID;
- }
- if (o.has("pre_version_id") && o.get("pre_version_id").isJsonPrimitive()) {
- int pre_version_id = o.get("pre_version_id").getAsInt();
- shouldPreUpdate = pre_version_id > NotEnoughUpdates.PRE_VERSION_ID;
- }
-
- if(shouldUpdate) {
- String update_msg = o.get("update_msg").getAsString();
-
- int first_len = -1;
- for(String line : update_msg.split("\n")) {
- FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
- int len = fr.getStringWidth(line);
- if(first_len == -1) {
- first_len = len;
- }
- int missing_len = first_len-len;
- if(missing_len > 0) {
- StringBuilder sb = new StringBuilder(line);
- for(int i=0; i<missing_len/8; i++) {
- sb.insert(0, " ");
- }
- line = sb.toString();
- }
- line = line.replaceAll("\\{version}", version);
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(line));
- }
-
- neu.displayLinks(o);
-
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
- } else if (shouldPreUpdate && NotEnoughUpdates.VERSION.equalsIgnoreCase("2.0.0-REL")) {
- String pre_update_msg = o.get("pre_update_msg").getAsString();
-
- int first_len = -1;
- for (String line : pre_update_msg.split("\n")) {
- FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
- int len = fr.getStringWidth(line);
- if (first_len == -1) {
- first_len = len;
- }
- int missing_len = first_len - len;
- if (missing_len > 0) {
- StringBuilder sb = new StringBuilder(line);
- for (int i = 0; i < missing_len / 8; i++) {
- sb.insert(0, " ");
- }
- line = sb.toString();
- }
- line = line.replaceAll("\\{pre_version}", preVersion);
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(line));
- }
-
- neu.displayLinks(o);
-
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
- }
- } catch(Exception ignored) {}
- }
- }
-
- @SubscribeEvent
- public void onWorldLoad(WorldEvent.Unload event) {
- NotEnoughUpdates.INSTANCE.saveConfig();
- CrystalMetalDetectorSolver.reset(false);
- }
-
- private static long notificationDisplayMillis = 0;
- private static List<String> notificationLines = null;
- private static boolean showNotificationOverInv = false;
-
- private static final Pattern BAD_ITEM_REGEX = Pattern.compile("x[0-9]{1,2}$");
-
- /**
- * 1)Will send the cached message from #sendChatMessage when at least 200ms has passed since the last message.
- * This is used in order to prevent the mod spamming messages.
- * 2)Adds unique items to the collection log
- */
- private boolean preloadedItems = false;
- private long lastLongUpdate = 0;
- private long lastSkyblockScoreboard = 0;
-
- private final ExecutorService itemPreloader = Executors.newFixedThreadPool(10);
- private final List<ItemStack> toPreload = new ArrayList<>();
-
- private int inventoryLoadedTicks = 0;
- private String loadedInvName = "";
- public static boolean inventoryLoaded = false;
- public static void displayNotification(List<String> lines, boolean showForever) {
- displayNotification(lines, showForever, false);
- }
-
- public static void displayNotification(List<String> lines, boolean showForever, boolean overInventory) {
- if(showForever) {
- notificationDisplayMillis = -420;
- } else {
- notificationDisplayMillis = System.currentTimeMillis();
- }
- notificationLines = lines;
- showNotificationOverInv = overInventory;
- }
-
- @SubscribeEvent
- public void onTick(TickEvent.ClientTickEvent event) {
- if(Minecraft.getMinecraft().currentScreen == null || !(Minecraft.getMinecraft().currentScreen instanceof GuiChat)) {
- Keyboard.enableRepeatEvents(false);
- }
- 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;
- List<JsonObject> list = new ArrayList<>(neu.manager.getItemInformation().values());
- for(JsonObject json : list) {
- itemPreloader.submit(() -> {
- ItemStack stack = neu.manager.jsonToStack(json, true, true);
- if(stack.getItem() == Items.skull) toPreload.add(stack);
- });
- }
- } else if(!toPreload.isEmpty()) {
- Utils.drawItemStack(toPreload.get(0), -100, -100);
- toPreload.remove(0);
- } else {
- itemPreloader.shutdown();
- }
-
- for(TextOverlay overlay : OverlayManager.textOverlays) {
- overlay.shouldUpdateFrequent = true;
- }
- }
-
- boolean longUpdate = false;
- long currentTime = System.currentTimeMillis();
- if(currentTime - lastLongUpdate > 1000) {
- longUpdate = true;
- lastLongUpdate = currentTime;
- }
- if(!NotEnoughUpdates.INSTANCE.config.dungeons.slowDungeonBlocks) {
- DungeonBlocks.tick();
- }
- DungeonWin.tick();
-
- String containerName = null;
- if(Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
- GuiChest eventGui = (GuiChest) Minecraft.getMinecraft().currentScreen;
- ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
- containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText();
-
- if(GuiCustomEnchant.getInstance().shouldOverride(containerName)) {
- GuiCustomEnchant.getInstance().tick();
- }
- }
-
- if(longUpdate) {
- CrystalOverlay.tick();
- DwarvenMinesTextures.tick();
- FairySouls.tick();
- XPInformation.getInstance().tick();
- ProfileApiSyncer.getInstance().tick();
- ItemCustomizeManager.tick();
- BackgroundBlur.markDirty();
- NPCRetexturing.getInstance().tick();
- StorageOverlay.getInstance().markDirty();
-
- if(neu.hasSkyblockScoreboard()) {
- for(TextOverlay overlay : OverlayManager.textOverlays) {
- overlay.tick();
- }
- }
-
- NotEnoughUpdates.INSTANCE.overlay.redrawItems();
- CapeManager.onTickSlow();
-
- NotEnoughUpdates.profileViewer.putNameUuid(Minecraft.getMinecraft().thePlayer.getName(),
- Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""));
-
- if(NotEnoughUpdates.INSTANCE.config.dungeons.slowDungeonBlocks) {
- DungeonBlocks.tick();
- }
-
- if(System.currentTimeMillis() - SBInfo.getInstance().joinedWorld > 500 &&
- System.currentTimeMillis() - SBInfo.getInstance().unloadedWorld > 500) {
- neu.updateSkyblockScoreboard();
- }
- CapeManager.getInstance().tick();
-
- if(containerName != null) {
- if(!containerName.trim().startsWith("Accessory Bag")) {
- AccessoryBagOverlay.resetCache();
- }
- } else {
- AccessoryBagOverlay.resetCache();
- }
-
- if(neu.hasSkyblockScoreboard()) {
- SBInfo.getInstance().tick();
- lastSkyblockScoreboard = currentTime;
- if(!joinedSB) {
- joinedSB = true;
-
- //SBGamemodes.loadFromFile();
-
-
- if(NotEnoughUpdates.INSTANCE.config.notifications.showUpdateMsg) {
- displayUpdateMessageIfOutOfDate();
- }
-
- if(NotEnoughUpdates.INSTANCE.config.notifications.doRamNotif) {
- long maxMemoryMB = Runtime.getRuntime().maxMemory()/1024L/1024L;
- if(maxMemoryMB > 4100) {
- notificationDisplayMillis = System.currentTimeMillis();
- notificationLines = new ArrayList<>();
- notificationLines.add(EnumChatFormatting.GRAY+"Too much memory allocated!");
- notificationLines.add(String.format(EnumChatFormatting.DARK_GRAY+"NEU has detected %03dMB of memory allocated to Minecraft!", maxMemoryMB));
- notificationLines.add(EnumChatFormatting.GRAY+"It is recommended to allocated between 2-4GB of memory");
- notificationLines.add(EnumChatFormatting.GRAY+"More than 4GB MAY cause FPS issues, EVEN if you have 16GB+ available");
- notificationLines.add("");
- notificationLines.add(EnumChatFormatting.GRAY+"For more information, visit #ram-info in discord.gg/moulberry");
- }
- }
-
- if(!NotEnoughUpdates.INSTANCE.config.hidden.loadedModBefore) {
- NotEnoughUpdates.INSTANCE.config.hidden.loadedModBefore = true;
- if(Constants.MISC == null || !Constants.MISC.has("featureslist")){
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""+EnumChatFormatting.DARK_RED+EnumChatFormatting.BOLD+"WARNING: "+EnumChatFormatting.RESET+EnumChatFormatting.RED+"Could not load Feature List URL from repo."));
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""+EnumChatFormatting.RED+ "Please run "+EnumChatFormatting.BOLD+"/neuresetrepo"+EnumChatFormatting.RESET+EnumChatFormatting.RED+" and "+EnumChatFormatting.BOLD+"restart your game"+EnumChatFormatting.RESET+EnumChatFormatting.RED+" in order to fix. "+EnumChatFormatting.DARK_RED+EnumChatFormatting.BOLD+"If that doesn't fix it"+EnumChatFormatting.RESET+EnumChatFormatting.RED+", please join discord.gg/moulberry and post in #neu-support"));
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""+EnumChatFormatting.GOLD+"To view the feature list after restarting type /neufeatures"));
- } else {
- String url = Constants.MISC.get("featureslist").getAsString();
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
- EnumChatFormatting.BLUE + "It seems this is your first time using NotEnoughUpdates."));
- ChatComponentText clickTextFeatures = new ChatComponentText(
- EnumChatFormatting.YELLOW + "Click this message if you would like to view a list of NotEnoughUpdate's Features.");
- clickTextFeatures.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, url));
- Minecraft.getMinecraft().thePlayer.addChatMessage(clickTextFeatures);
- }
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
- ChatComponentText clickTextHelp = new ChatComponentText(
- EnumChatFormatting.YELLOW+"Click this message if you would like to view a list of NotEnoughUpdate's commands.");
- clickTextHelp.setChatStyle(Utils.createClickStyle(ClickEvent.Action.RUN_COMMAND, "/neuhelp"));
- Minecraft.getMinecraft().thePlayer.addChatMessage(clickTextHelp);
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
- }
- }
- }
- if(currentTime - lastSkyblockScoreboard < 5*60*1000) { //5 minutes
- neu.manager.auctionManager.tick();
- } else {
- neu.manager.auctionManager.markNeedsUpdate();
- }
- }
+ private final NotEnoughUpdates neu;
+
+ private boolean hoverInv = false;
+ private boolean focusInv = false;
+
+ private boolean joinedSB = false;
+
+ public NEUEventListener(NotEnoughUpdates neu) {
+ this.neu = neu;
+ }
+
+ private void displayUpdateMessageIfOutOfDate() {
+ File repo = neu.manager.repoLocation;
+ if (repo.exists()) {
+ File updateJson = new File(repo, "update.json");
+ try {
+ JsonObject o = neu.manager.getJsonFromFile(updateJson);
+
+ String version = o.get("version").getAsString();
+ String preVersion = o.get("pre_version").getAsString();
+
+ boolean shouldUpdate = !NotEnoughUpdates.VERSION.equalsIgnoreCase(version);
+ boolean shouldPreUpdate = !NotEnoughUpdates.PRE_VERSION.equalsIgnoreCase(preVersion);
+
+ if (o.has("version_id") && o.get("version_id").isJsonPrimitive()) {
+ int version_id = o.get("version_id").getAsInt();
+ shouldUpdate = version_id > NotEnoughUpdates.VERSION_ID;
+ }
+ if (o.has("pre_version_id") && o.get("pre_version_id").isJsonPrimitive()) {
+ int pre_version_id = o.get("pre_version_id").getAsInt();
+ shouldPreUpdate = pre_version_id > NotEnoughUpdates.PRE_VERSION_ID;
+ }
+
+ if (shouldUpdate) {
+ String update_msg = o.get("update_msg").getAsString();
+
+ int first_len = -1;
+ for (String line : update_msg.split("\n")) {
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+ int len = fr.getStringWidth(line);
+ if (first_len == -1) {
+ first_len = len;
+ }
+ int missing_len = first_len - len;
+ if (missing_len > 0) {
+ StringBuilder sb = new StringBuilder(line);
+ for (int i = 0; i < missing_len / 8; i++) {
+ sb.insert(0, " ");
+ }
+ line = sb.toString();
+ }
+ line = line.replaceAll("\\{version}", version);
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(line));
+ }
+
+ neu.displayLinks(o);
+
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
+ } else if (shouldPreUpdate && NotEnoughUpdates.VERSION_ID == o.get("version").getAsInt()) {
+ String pre_update_msg = o.get("pre_update_msg").getAsString();
+
+ int first_len = -1;
+ for (String line : pre_update_msg.split("\n")) {
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+ int len = fr.getStringWidth(line);
+ if (first_len == -1) {
+ first_len = len;
+ }
+ int missing_len = first_len - len;
+ if (missing_len > 0) {
+ StringBuilder sb = new StringBuilder(line);
+ for (int i = 0; i < missing_len / 8; i++) {
+ sb.insert(0, " ");
+ }
+ line = sb.toString();
+ }
+ line = line.replaceAll("\\{pre_version}", preVersion);
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(line));
+ }
+
+ neu.displayLinks(o);
+
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
+ }
+ } catch (Exception ignored) {
+ }
+ }
+ }
+
+ @SubscribeEvent
+ public void onWorldLoad(WorldEvent.Unload event) {
+ NotEnoughUpdates.INSTANCE.saveConfig();
+ CrystalMetalDetectorSolver.reset(false);
+ }
+
+ private static long notificationDisplayMillis = 0;
+ private static List<String> notificationLines = null;
+ private static boolean showNotificationOverInv = false;
+
+ private static final Pattern BAD_ITEM_REGEX = Pattern.compile("x[0-9]{1,2}$");
+ private static final Pattern SLAYER_XP =
+ Pattern.compile(" (Spider|Zombie|Wolf|Enderman) Slayer LVL (\\d) - (?:Next LVL in ([\\d,]+) XP!|LVL MAXED OUT!)");
+
+ /**
+ * 1)Will send the cached message from #sendChatMessage when at least 200ms has passed since the last message.
+ * This is used in order to prevent the mod spamming messages.
+ * 2)Adds unique items to the collection log
+ */
+ private boolean preloadedItems = false;
+ private long lastLongUpdate = 0;
+ private long lastSkyblockScoreboard = 0;
+
+ private final ExecutorService itemPreloader = Executors.newFixedThreadPool(10);
+ private final List<ItemStack> toPreload = new ArrayList<>();
+
+ private int inventoryLoadedTicks = 0;
+ private String loadedInvName = "";
+ public static boolean inventoryLoaded = false;
+
+ public static void displayNotification(List<String> lines, boolean showForever) {
+ displayNotification(lines, showForever, false);
+ }
+
+ public static void displayNotification(List<String> lines, boolean showForever, boolean overInventory) {
+ if (showForever) {
+ notificationDisplayMillis = -420;
+ } else {
+ notificationDisplayMillis = System.currentTimeMillis();
+ }
+ notificationLines = lines;
+ showNotificationOverInv = overInventory;
+ }
+
+ @SubscribeEvent
+ public void onTick(TickEvent.ClientTickEvent event) {
+ Keyboard.enableRepeatEvents(
+ Minecraft.getMinecraft().currentScreen != null && (Minecraft.getMinecraft().currentScreen instanceof GuiChat
+ || Minecraft.getMinecraft().currentScreen instanceof GuiEditSign ||
+ Minecraft.getMinecraft().currentScreen instanceof GuiScreenBook));
+ 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;
+ List<JsonObject> list = new ArrayList<>(neu.manager.getItemInformation().values());
+ for (JsonObject json : list) {
+ itemPreloader.submit(() -> {
+ ItemStack stack = neu.manager.jsonToStack(json, true, true);
+ if (stack.getItem() == Items.skull) toPreload.add(stack);
+ });
+ }
+ } else if (!toPreload.isEmpty()) {
+ Utils.drawItemStack(toPreload.get(0), -100, -100);
+ toPreload.remove(0);
+ } else {
+ itemPreloader.shutdown();
+ }
+
+ for (TextOverlay overlay : OverlayManager.textOverlays) {
+ overlay.shouldUpdateFrequent = true;
+ }
+ }
+
+ boolean longUpdate = false;
+ long currentTime = System.currentTimeMillis();
+ if (currentTime - lastLongUpdate > 1000) {
+ longUpdate = true;
+ lastLongUpdate = currentTime;
+ }
+ if (!NotEnoughUpdates.INSTANCE.config.dungeons.slowDungeonBlocks) {
+ DungeonBlocks.tick();
+ }
+ DungeonWin.tick();
+
+ String containerName = null;
+ if (Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
+ GuiChest eventGui = (GuiChest) Minecraft.getMinecraft().currentScreen;
+ ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
+ containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText();
+
+ if (GuiCustomEnchant.getInstance().shouldOverride(containerName)) {
+ GuiCustomEnchant.getInstance().tick();
+ }
+ }
+
+ if (longUpdate) {
+ CrystalOverlay.tick();
+ FairySouls.tick();
+ XPInformation.getInstance().tick();
+ ProfileApiSyncer.getInstance().tick();
+ ItemCustomizeManager.tick();
+ BackgroundBlur.markDirty();
+ NPCRetexturing.getInstance().tick();
+ StorageOverlay.getInstance().markDirty();
+
+ if (neu.hasSkyblockScoreboard()) {
+ for (TextOverlay overlay : OverlayManager.textOverlays) {
+ overlay.tick();
+ }
+ }
+
+ NotEnoughUpdates.INSTANCE.overlay.redrawItems();
+ CapeManager.onTickSlow();
+
+ NotEnoughUpdates.profileViewer.putNameUuid(
+ Minecraft.getMinecraft().thePlayer.getName(),
+ Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", "")
+ );
+
+ if (NotEnoughUpdates.INSTANCE.config.dungeons.slowDungeonBlocks) {
+ DungeonBlocks.tick();
+ }
+
+ if (System.currentTimeMillis() - SBInfo.getInstance().joinedWorld > 500 &&
+ System.currentTimeMillis() - SBInfo.getInstance().unloadedWorld > 500) {
+ neu.updateSkyblockScoreboard();
+ }
+ CapeManager.getInstance().tick();
+
+ if (containerName != null) {
+ if (!containerName.trim().startsWith("Accessory Bag")) {
+ AccessoryBagOverlay.resetCache();
+ }
+ } else {
+ AccessoryBagOverlay.resetCache();
+ }
+
+ if (neu.hasSkyblockScoreboard()) {
+ SBInfo.getInstance().tick();
+ lastSkyblockScoreboard = currentTime;
+ if (!joinedSB) {
+ joinedSB = true;
+
+ //SBGamemodes.loadFromFile();
+
+ if (NotEnoughUpdates.INSTANCE.config.notifications.showUpdateMsg) {
+ displayUpdateMessageIfOutOfDate();
+ }
+
+ if (NotEnoughUpdates.INSTANCE.config.notifications.doRamNotif) {
+ long maxMemoryMB = Runtime.getRuntime().maxMemory() / 1024L / 1024L;
+ if (maxMemoryMB > 4100) {
+ notificationDisplayMillis = System.currentTimeMillis();
+ notificationLines = new ArrayList<>();
+ notificationLines.add(EnumChatFormatting.GRAY + "Too much memory allocated!");
+ notificationLines.add(String.format(
+ EnumChatFormatting.DARK_GRAY + "NEU has detected %03dMB of memory allocated to Minecraft!",
+ maxMemoryMB
+ ));
+ notificationLines.add(EnumChatFormatting.GRAY + "It is recommended to allocated between 2-4GB of memory");
+ notificationLines.add(
+ EnumChatFormatting.GRAY + "More than 4GB MAY cause FPS issues, EVEN if you have 16GB+ available");
+ notificationLines.add("");
+ notificationLines.add(
+ EnumChatFormatting.GRAY + "For more information, visit #ram-info in discord.gg/moulberry");
+ }
+ }
+
+ if (!NotEnoughUpdates.INSTANCE.config.hidden.loadedModBefore) {
+ NotEnoughUpdates.INSTANCE.config.hidden.loadedModBefore = true;
+ if (Constants.MISC == null || !Constants.MISC.has("featureslist")) {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
+ "" + EnumChatFormatting.DARK_RED + EnumChatFormatting.BOLD + "WARNING: " + EnumChatFormatting.RESET +
+ EnumChatFormatting.RED + "Could not load Feature List URL from repo."));
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
+ "" + EnumChatFormatting.RED + "Please run " + EnumChatFormatting.BOLD + "/neuresetrepo" +
+ EnumChatFormatting.RESET + EnumChatFormatting.RED + " and " + EnumChatFormatting.BOLD +
+ "restart your game" + EnumChatFormatting.RESET + EnumChatFormatting.RED + " in order to fix. " +
+ EnumChatFormatting.DARK_RED + EnumChatFormatting.BOLD + "If that doesn't fix it" +
+ EnumChatFormatting.RESET + EnumChatFormatting.RED +
+ ", please join discord.gg/moulberry and post in #neu-support"));
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
+ "" + EnumChatFormatting.GOLD + "To view the feature list after restarting type /neufeatures"));
+ } else {
+ String url = Constants.MISC.get("featureslist").getAsString();
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
+ EnumChatFormatting.BLUE + "It seems this is your first time using NotEnoughUpdates."));
+ ChatComponentText clickTextFeatures = new ChatComponentText(
+ EnumChatFormatting.YELLOW +
+ "Click this message if you would like to view a list of NotEnoughUpdate's Features.");
+ clickTextFeatures.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, url));
+ Minecraft.getMinecraft().thePlayer.addChatMessage(clickTextFeatures);
+ }
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
+ ChatComponentText clickTextHelp = new ChatComponentText(
+ EnumChatFormatting.YELLOW +
+ "Click this message if you would like to view a list of NotEnoughUpdate's commands.");
+ clickTextHelp.setChatStyle(Utils.createClickStyle(ClickEvent.Action.RUN_COMMAND, "/neuhelp"));
+ Minecraft.getMinecraft().thePlayer.addChatMessage(clickTextHelp);
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
+ }
+ }
+ }
+ if (currentTime - lastSkyblockScoreboard < 5 * 60 * 1000) { //5 minutes
+ neu.manager.auctionManager.tick();
+ } else {
+ neu.manager.auctionManager.markNeedsUpdate();
+ }
+ }
/*if(longUpdate && neu.hasSkyblockScoreboard()) {
if(neu.manager.getCurrentProfile() == null || neu.manager.getCurrentProfile().length() == 0) {
@@ -449,7 +477,7 @@ public class NEUEventListener {
newItemAddMap.keySet().retainAll(newItem);
}
}*/
- }
+ }
/*private void processUniqueStack(ItemStack stack, HashSet<String> newItem) {
if(stack != null && stack.hasTagCompound()) {
@@ -472,196 +500,205 @@ public class NEUEventListener {
}
}*/
- @SubscribeEvent(priority= EventPriority.HIGHEST)
- public void onRenderEntitySpecials(RenderLivingEvent.Specials.Pre<EntityPlayer> event) {
- if(Minecraft.getMinecraft().currentScreen instanceof GuiProfileViewer) {
- if(((GuiProfileViewer)Minecraft.getMinecraft().currentScreen).getEntityPlayer() == event.entity) {
- event.setCanceled(true);
- }
- }
- }
-
- @SubscribeEvent
- public void onRenderGameOverlayPre(RenderGameOverlayEvent.Pre event) {
- if (event.type != null && event.type.equals(RenderGameOverlayEvent.ElementType.BOSSHEALTH) &&
- Minecraft.getMinecraft().currentScreen instanceof GuiContainer && neu.overlay.isUsingMobsFilter()) {
- event.setCanceled(true);
- }
- if(event.type != null && event.type.equals(RenderGameOverlayEvent.ElementType.PLAYER_LIST)) {
- GlStateManager.enableDepth();
- }
- }
-
- @SubscribeEvent
- public void onRenderGameOverlayPost(RenderGameOverlayEvent.Post event) {
- if(neu.hasSkyblockScoreboard() && event.type.equals(RenderGameOverlayEvent.ElementType.ALL)) {
- DungeonWin.render(event.partialTicks);
- GlStateManager.pushMatrix();
- GlStateManager.translate(0, 0, -200);
- for(TextOverlay overlay : OverlayManager.textOverlays) {
- if(OverlayManager.dontRenderOverlay != null && OverlayManager.dontRenderOverlay.isAssignableFrom(overlay.getClass())) {
- continue;
- }
- GlStateManager.translate(0, 0, -1);
- GlStateManager.enableDepth();
- overlay.render();
- }
- GlStateManager.popMatrix();
- OverlayManager.dontRenderOverlay = null;
- }
- if(Keyboard.isKeyDown(Keyboard.KEY_X)) {
- notificationDisplayMillis = 0;
- }
-
- if(event.type == RenderGameOverlayEvent.ElementType.ALL){
- renderNotification();
- }
-
- }
- private static void renderNotification(){
-
- long timeRemaining = 15000 - (System.currentTimeMillis() - notificationDisplayMillis);
- boolean display = timeRemaining > 0 || notificationDisplayMillis == -420;
- if(display && notificationLines != null && notificationLines.size() > 0) {
- int width = 0;
- int height = notificationLines.size()*10+10;
-
- for(String line : notificationLines) {
- int len = Minecraft.getMinecraft().fontRendererObj.getStringWidth(line) + 8;
- if(len > width) {
- width = len;
- }
- }
-
- ScaledResolution sr = Utils.pushGuiScale(2);
-
- int midX = sr.getScaledWidth()/2;
- int topY = sr.getScaledHeight()*3/4-height/2;
- RenderUtils.drawFloatingRectDark(midX-width/2, sr.getScaledHeight()*3/4-height/2, width, height);
+ @SubscribeEvent(priority = EventPriority.HIGHEST)
+ public void onRenderEntitySpecials(RenderLivingEvent.Specials.Pre<EntityPlayer> event) {
+ if (Minecraft.getMinecraft().currentScreen instanceof GuiProfileViewer) {
+ if (((GuiProfileViewer) Minecraft.getMinecraft().currentScreen).getEntityPlayer() == event.entity) {
+ event.setCanceled(true);
+ }
+ }
+ }
+
+ @SubscribeEvent
+ public void onRenderGameOverlayPre(RenderGameOverlayEvent.Pre event) {
+ if (event.type != null && event.type.equals(RenderGameOverlayEvent.ElementType.BOSSHEALTH) &&
+ Minecraft.getMinecraft().currentScreen instanceof GuiContainer && neu.overlay.isUsingMobsFilter()) {
+ event.setCanceled(true);
+ }
+ if (event.type != null && event.type.equals(RenderGameOverlayEvent.ElementType.PLAYER_LIST)) {
+ GlStateManager.enableDepth();
+ }
+ }
+
+ @SubscribeEvent
+ public void onRenderGameOverlayPost(RenderGameOverlayEvent.Post event) {
+ if (neu.hasSkyblockScoreboard() && event.type.equals(RenderGameOverlayEvent.ElementType.ALL)) {
+ DungeonWin.render(event.partialTicks);
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(0, 0, -200);
+ for (TextOverlay overlay : OverlayManager.textOverlays) {
+ if (OverlayManager.dontRenderOverlay != null &&
+ OverlayManager.dontRenderOverlay.isAssignableFrom(overlay.getClass())) {
+ continue;
+ }
+ GlStateManager.translate(0, 0, -1);
+ GlStateManager.enableDepth();
+ overlay.render();
+ }
+ GlStateManager.popMatrix();
+ OverlayManager.dontRenderOverlay = null;
+ }
+ if (Keyboard.isKeyDown(Keyboard.KEY_X)) {
+ notificationDisplayMillis = 0;
+ }
+
+ if (event.type == RenderGameOverlayEvent.ElementType.ALL) {
+ renderNotification();
+ }
+
+ }
+
+ private static void renderNotification() {
+
+ long timeRemaining = 15000 - (System.currentTimeMillis() - notificationDisplayMillis);
+ boolean display = timeRemaining > 0 || notificationDisplayMillis == -420;
+ if (display && notificationLines != null && notificationLines.size() > 0) {
+ int width = 0;
+ int height = notificationLines.size() * 10 + 10;
+
+ for (String line : notificationLines) {
+ int len = Minecraft.getMinecraft().fontRendererObj.getStringWidth(line) + 8;
+ if (len > width) {
+ width = len;
+ }
+ }
+
+ ScaledResolution sr = Utils.pushGuiScale(2);
+
+ int midX = sr.getScaledWidth() / 2;
+ int topY = sr.getScaledHeight() * 3 / 4 - height / 2;
+ RenderUtils.drawFloatingRectDark(midX - width / 2, sr.getScaledHeight() * 3 / 4 - height / 2, width, height);
/*Gui.drawRect(midX-width/2, sr.getScaledHeight()*3/4-height/2,
midX+width/2, sr.getScaledHeight()*3/4+height/2, 0xFF3C3C3C);
Gui.drawRect(midX-width/2+2, sr.getScaledHeight()*3/4-height/2+2,
midX+width/2-2, sr.getScaledHeight()*3/4+height/2-2, 0xFFC8C8C8);*/
- int xLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth("[X] Close");
- Minecraft.getMinecraft().fontRendererObj.drawString("[X] Close", midX+width/2f-3-xLen,
- topY+3, 0xFFFF5555, false);
-
- if(notificationDisplayMillis > 0) {
- Minecraft.getMinecraft().fontRendererObj.drawString((timeRemaining/1000)+"s", midX-width/2f+3,
- topY+3, 0xFFaaaaaa, false);
- }
-
- Utils.drawStringCentered(notificationLines.get(0), Minecraft.getMinecraft().fontRendererObj,
- midX, topY+4+5, false, -1);
- for(int i=1; i<notificationLines.size(); i++) {
- String line = notificationLines.get(i);
- Utils.drawStringCentered(line, Minecraft.getMinecraft().fontRendererObj,
- midX, topY+4+5+2+i*10, false, -1);
- }
-
- Utils.pushGuiScale(-1);
- }
- }
-
- 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.
- * Also includes a dev feature used for automatically acquiring crafting information from the "Crafting Table" GUI.
- */
- AtomicBoolean missingRecipe = new AtomicBoolean(false);
- @SubscribeEvent
- public void onGuiOpen(GuiOpenEvent event) {
- CraftingOverlay.shouldRender = false;
- NEUApi.disableInventoryButtons = false;
-
- if((Minecraft.getMinecraft().currentScreen instanceof GuiScreenElementWrapper ||
- Minecraft.getMinecraft().currentScreen instanceof GuiItemRecipe) &&
- event.gui == null && !(Keyboard.getEventKeyState() && Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) &&
- System.currentTimeMillis() - NotEnoughUpdates.INSTANCE.lastOpenedGui < 500) {
- NotEnoughUpdates.INSTANCE.lastOpenedGui = 0;
- event.setCanceled(true);
- return;
- }
-
- if(!(event.gui instanceof GuiContainer) && Minecraft.getMinecraft().currentScreen != null) {
- 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)) {
- event.gui = new CustomAHGui();
- }
-
- if(!(event.gui instanceof GuiChest || event.gui instanceof GuiEditSign)) {
- neu.manager.auctionManager.customAH.setRenderOverAuctionView(false);
- } else if(event.gui instanceof GuiChest && (neu.manager.auctionManager.customAH.isRenderOverAuctionView() ||
- Minecraft.getMinecraft().currentScreen instanceof CustomAHGui)){
- GuiChest chest = (GuiChest) event.gui;
- ContainerChest container = (ContainerChest) chest.inventorySlots;
- String containerName = container.getLowerChestInventory().getDisplayName().getUnformattedText();
-
- neu.manager.auctionManager.customAH.setRenderOverAuctionView(containerName.trim().equals("Auction View") ||
- containerName.trim().equals("BIN Auction View") || containerName.trim().equals("Confirm Bid") ||
- containerName.trim().equals("Confirm Purchase"));
- }
-
- //OPEN
- if(Minecraft.getMinecraft().currentScreen == null
- && event.gui instanceof GuiContainer) {
- neu.overlay.reset();
- }
- if(event.gui != null && NotEnoughUpdates.INSTANCE.config.hidden.dev) {
- if(event.gui instanceof GuiChest) {
- GuiChest eventGui = (GuiChest) event.gui;
- ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
- IInventory lower = cc.getLowerChestInventory();
- ses.schedule(() -> {
- if(Minecraft.getMinecraft().currentScreen != event.gui) {
- return;
- }
- if(lower.getStackInSlot(23).getDisplayName().endsWith("Crafting Table")) {
- try {
- ItemStack res = lower.getStackInSlot(25);
- String resInternalname = neu.manager.getInternalNameForItem(res);
-
- if(lower.getStackInSlot(48) != null) {
- String backName = null;
- NBTTagCompound tag = lower.getStackInSlot(48).getTagCompound();
- if(tag.hasKey("display", 10)) {
- NBTTagCompound nbttagcompound = tag.getCompoundTag("display");
- if(nbttagcompound.getTagId("Lore") == 9){
- NBTTagList nbttaglist1 = nbttagcompound.getTagList("Lore", 8);
- backName = nbttaglist1.getStringTagAt(0);
- }
- }
-
- if(backName != null) {
- String[] split = backName.split(" ");
- if(split[split.length-1].contains("Rewards")) {
- String col = backName.substring(split[0].length()+1,
- backName.length()-split[split.length-1].length()-1);
-
- JsonObject json = neu.manager.getItemInformation().get(resInternalname);
- json.addProperty("crafttext", "Requires: " + col);
-
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Added: " + resInternalname));
- neu.manager.writeJsonDefaultDir(json, resInternalname+".json");
- neu.manager.loadItem(resInternalname);
- }
- }
- }
+ int xLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth("[X] Close");
+ Minecraft.getMinecraft().fontRendererObj.drawString("[X] Close", midX + width / 2f - 3 - xLen,
+ topY + 3, 0xFFFF5555, false
+ );
+
+ if (notificationDisplayMillis > 0) {
+ Minecraft.getMinecraft().fontRendererObj.drawString((timeRemaining / 1000) + "s", midX - width / 2f + 3,
+ topY + 3, 0xFFaaaaaa, false
+ );
+ }
+
+ Utils.drawStringCentered(notificationLines.get(0), Minecraft.getMinecraft().fontRendererObj,
+ midX, topY + 4 + 5, false, -1
+ );
+ for (int i = 1; i < notificationLines.size(); i++) {
+ String line = notificationLines.get(i);
+ Utils.drawStringCentered(line, Minecraft.getMinecraft().fontRendererObj,
+ midX, topY + 4 + 5 + 2 + i * 10, false, -1
+ );
+ }
+
+ Utils.pushGuiScale(-1);
+ }
+ }
+
+ 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.
+ * Also includes a dev feature used for automatically acquiring crafting information from the "Crafting Table" GUI.
+ */
+ AtomicBoolean missingRecipe = new AtomicBoolean(false);
+
+ @SubscribeEvent
+ public void onGuiOpen(GuiOpenEvent event) {
+ NEUApi.disableInventoryButtons = false;
+
+ if ((Minecraft.getMinecraft().currentScreen instanceof GuiScreenElementWrapper ||
+ Minecraft.getMinecraft().currentScreen instanceof GuiItemRecipe) &&
+ event.gui == null && !(Keyboard.getEventKeyState() && Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) &&
+ System.currentTimeMillis() - NotEnoughUpdates.INSTANCE.lastOpenedGui < 500) {
+ NotEnoughUpdates.INSTANCE.lastOpenedGui = 0;
+ event.setCanceled(true);
+ return;
+ }
+
+ if (!(event.gui instanceof GuiContainer) && Minecraft.getMinecraft().currentScreen != null) {
+ 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)) {
+ event.gui = new CustomAHGui();
+ }
+
+ if (!(event.gui instanceof GuiChest || event.gui instanceof GuiEditSign)) {
+ neu.manager.auctionManager.customAH.setRenderOverAuctionView(false);
+ } else if (event.gui instanceof GuiChest && (neu.manager.auctionManager.customAH.isRenderOverAuctionView() ||
+ Minecraft.getMinecraft().currentScreen instanceof CustomAHGui)) {
+ GuiChest chest = (GuiChest) event.gui;
+ ContainerChest container = (ContainerChest) chest.inventorySlots;
+ String containerName = container.getLowerChestInventory().getDisplayName().getUnformattedText();
+
+ neu.manager.auctionManager.customAH.setRenderOverAuctionView(containerName.trim().equals("Auction View") ||
+ containerName.trim().equals("BIN Auction View") || containerName.trim().equals("Confirm Bid") ||
+ containerName.trim().equals("Confirm Purchase"));
+ }
+
+ //OPEN
+ if (Minecraft.getMinecraft().currentScreen == null
+ && event.gui instanceof GuiContainer) {
+ neu.overlay.reset();
+ }
+ if (event.gui != null && NotEnoughUpdates.INSTANCE.config.hidden.dev) {
+ if (event.gui instanceof GuiChest) {
+ GuiChest eventGui = (GuiChest) event.gui;
+ ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
+ IInventory lower = cc.getLowerChestInventory();
+ ses.schedule(() -> {
+ if (Minecraft.getMinecraft().currentScreen != event.gui) {
+ return;
+ }
+ if (lower.getStackInSlot(23).getDisplayName().endsWith("Crafting Table")) {
+ try {
+ ItemStack res = lower.getStackInSlot(25);
+ String resInternalname = neu.manager.getInternalNameForItem(res);
+
+ if (lower.getStackInSlot(48) != null) {
+ String backName = null;
+ NBTTagCompound tag = lower.getStackInSlot(48).getTagCompound();
+ if (tag.hasKey("display", 10)) {
+ NBTTagCompound nbttagcompound = tag.getCompoundTag("display");
+ if (nbttagcompound.getTagId("Lore") == 9) {
+ NBTTagList nbttaglist1 = nbttagcompound.getTagList("Lore", 8);
+ backName = nbttaglist1.getStringTagAt(0);
+ }
+ }
+
+ if (backName != null) {
+ String[] split = backName.split(" ");
+ if (split[split.length - 1].contains("Rewards")) {
+ String col = backName.substring(
+ split[0].length() + 1,
+ backName.length() - split[split.length - 1].length() - 1
+ );
+
+ JsonObject json = neu.manager.getItemInformation().get(resInternalname);
+ json.addProperty("crafttext", "Requires: " + col);
+
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
+ "Added: " + resInternalname));
+ neu.manager.writeJsonDefaultDir(json, resInternalname + ".json");
+ neu.manager.loadItem(resInternalname);
+ }
+ }
+ }
/*JsonArray arr = null;
File f = new File(neu.manager.configLocation, "missing.json");
@@ -713,14 +750,14 @@ public class NEUEventListener {
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Added: " + resInternalname));
neu.manager.writeJsonDefaultDir(json, resInternalname+".json");
neu.manager.loadItem(resInternalname);*/
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
- }, 200, TimeUnit.MILLISECONDS);
- }
- }
- }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }, 200, TimeUnit.MILLISECONDS);
+ }
+ }
+ }
/*@SubscribeEvent
public void onPlayerInteract(EntityInteractEvent event) {
@@ -740,1884 +777,2066 @@ public class NEUEventListener {
}
}*/
- private IChatComponent processChatComponent(IChatComponent chatComponent) {
- IChatComponent newComponent;
- if(chatComponent instanceof ChatComponentText) {
- ChatComponentText text = (ChatComponentText) chatComponent;
-
- newComponent = new ChatComponentText(processText(text.getUnformattedTextForChat()));
- newComponent.setChatStyle(text.getChatStyle().createShallowCopy());
-
- for(IChatComponent sibling : text.getSiblings()) {
- newComponent.appendSibling(processChatComponent(sibling));
- }
- } else if(chatComponent instanceof ChatComponentTranslation) {
- ChatComponentTranslation trans = (ChatComponentTranslation) chatComponent;
-
- Object[] args = trans.getFormatArgs();
- Object[] newArgs = new Object[args.length];
- for(int i=0; i<trans.getFormatArgs().length; i++) {
- if(args[i] instanceof IChatComponent) {
- newArgs[i] = processChatComponent((IChatComponent) args[i]);
- } else {
- newArgs[i] = args[i];
- }
- }
- newComponent = new ChatComponentTranslation(trans.getKey(), newArgs);
-
- for(IChatComponent sibling : trans.getSiblings()) {
- newComponent.appendSibling(processChatComponent(sibling));
- }
- } else {
- newComponent = chatComponent.createCopy();
- }
-
- return newComponent;
- }
-
- private String processText(String text) {
- if(SBInfo.getInstance().getLocation() == null) return text;
- if(!SBInfo.getInstance().getLocation().startsWith("mining_")&&!SBInfo.getInstance().getLocation().equals("crystal_hollows")) return text;
-
- if(Minecraft.getMinecraft().thePlayer == null) return text;
- if(!NotEnoughUpdates.INSTANCE.config.mining.drillFuelBar) return text;
-
- return Utils.trimIgnoreColour(text.replaceAll(EnumChatFormatting.DARK_GREEN+"\\S+ Drill Fuel", ""));
- }
-
-
- private IChatComponent replaceSocialControlsWithPV(IChatComponent chatComponent){
-
- if(NotEnoughUpdates.INSTANCE.config.misc.replaceSocialOptions && chatComponent.getChatStyle() != null && chatComponent.getChatStyle().getChatClickEvent() != null && chatComponent.getChatStyle().getChatClickEvent().getAction() == ClickEvent.Action.RUN_COMMAND){
- if(chatComponent.getChatStyle().getChatClickEvent().getValue().startsWith("/socialoptions")){
- String username = chatComponent.getChatStyle().getChatClickEvent().getValue().substring(15);
-
- chatComponent.setChatStyle(Utils.createClickStyle(ClickEvent.Action.RUN_COMMAND, "/pv "+username, ""+EnumChatFormatting.YELLOW+"Click to open "+EnumChatFormatting.AQUA+EnumChatFormatting.BOLD+username+EnumChatFormatting.RESET+EnumChatFormatting.YELLOW+"'s profile in "+EnumChatFormatting.DARK_PURPLE+EnumChatFormatting.BOLD+"NEU's"+EnumChatFormatting.RESET+EnumChatFormatting.YELLOW+ " profile viewer."));
- return chatComponent;
- }
- }
- return chatComponent;
- }
-
- /**
- * 1) When receiving "You are playing on profile" messages, will set the current profile.
- * 2) When a /viewrecipe command fails (i.e. player does not have recipe unlocked, will open the custom recipe GUI)
- * 3) Replaces lobby join notifications when streamer mode is active
- */
- @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true)
- public void onGuiChat(ClientChatReceivedEvent e) {
- if(e.type == 2) {
- CrystalMetalDetectorSolver.process(e.message);
- e.message = processChatComponent(e.message);
- return;
- } else if(e.type == 0){
- e.message = replaceSocialControlsWithPV(e.message);
- }
-
- DungeonWin.onChatMessage(e);
-
- String r = null;
- String unformatted = Utils.cleanColour(e.message.getUnformattedText());
- if(unformatted.startsWith("You are playing on profile: ")) {
- neu.manager.setCurrentProfile(unformatted.substring("You are playing on profile: ".length()).split(" ")[0].trim());
- } else if(unformatted.startsWith("Your profile was changed to: ")) {//Your profile was changed to:
- neu.manager.setCurrentProfile(unformatted.substring("Your profile was changed to: ".length()).split(" ")[0].trim());
- } else if(unformatted.startsWith("Your new API key is ")) {
- NotEnoughUpdates.INSTANCE.config.apiKey.apiKey = unformatted.substring("Your new API key is ".length());
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW+
- "[NEU] API Key automatically configured"));
- }
- if(e.message.getFormattedText().equals(EnumChatFormatting.RESET.toString()+
- EnumChatFormatting.RED+"You haven't unlocked this recipe!"+EnumChatFormatting.RESET)) {
- r = EnumChatFormatting.RED+"You haven't unlocked this recipe!";
- } else if(e.message.getFormattedText().startsWith(EnumChatFormatting.RESET.toString()+
- EnumChatFormatting.RED+"Invalid recipe ")) {
- r = "";
- }
- if(e.message.getFormattedText().contains(EnumChatFormatting.YELLOW+"Visit the Auction House to collect your item!")) {
- if(NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.latestBid != null &&
- System.currentTimeMillis() - NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.latestBidMillis < 5000) {
- NotEnoughUpdates.INSTANCE.sendChatMessage("/viewauction " +
- NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.niceAucId(
- NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.latestBid));
- }
- }
- if(r != null) {
- if(neu.manager.failViewItem(r)) {
- e.setCanceled(true);
- }
- missingRecipe.set(true);
- }
- //System.out.println(e.message);
- if(unformatted.startsWith("Sending to server") &&
- neu.isOnSkyblock() && NotEnoughUpdates.INSTANCE.config.misc.streamerMode && e.message instanceof ChatComponentText) {
- String m = e.message.getFormattedText();
- String m2 = StreamerMode.filterChat(e.message.getFormattedText());
- if(!m.equals(m2)) {
- e.message = new ChatComponentText(m2);
- }
- }
- if (unformatted.startsWith("You found ") && SBInfo.getInstance().getLocation() != null && SBInfo.getInstance().getLocation().equals("crystal_hollows")){
- CrystalMetalDetectorSolver.reset(true);
- }
- if(unformatted.startsWith("[NPC] Keeper of ") | unformatted.startsWith("[NPC] Professor Robot: ") || unformatted.startsWith(" ") || unformatted.startsWith("✦") ||
- unformatted.equals(" You've earned a Crystal Loot Bundle!"))
- OverlayManager.crystalHollowOverlay.message(unformatted);
- }
-
- public static boolean drawingGuiScreen = false;
-
- /**
- * Sets hoverInv and focusInv variables, representing whether the NEUOverlay should render behind the inventory when
- * (hoverInv == true) and whether mouse/kbd inputs shouldn't be sent to NEUOverlay (focusInv == true).
- *
- * If hoverInv is true, will render the overlay immediately (resulting in the inventory being drawn over the GUI)
- * If hoverInv is false, the overlay will render in #onGuiScreenDraw (resulting in the GUI being drawn over the inv)
- *
- * All of this only matters if players are using gui scale auto which may result in the inventory being drawn
- * over the various panes.
- * @param event
- */
- @SubscribeEvent
- public void onGuiBackgroundDraw(GuiScreenEvent.BackgroundDrawnEvent event) {
- if(showNotificationOverInv){
-
- renderNotification();
-
- }
- if((shouldRenderOverlay(event.gui) || event.gui instanceof CustomAHGui) && neu.isOnSkyblock()) {
- ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
- int width = scaledresolution.getScaledWidth();
-
- boolean hoverPane = event.getMouseX() < width*neu.overlay.getInfoPaneOffsetFactor() ||
- event.getMouseX() > width*neu.overlay.getItemPaneOffsetFactor();
-
- if(event.gui instanceof GuiContainer) {
- try {
- 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;
-
- if(hoverPane) {
- if(!hoverInv) focusInv = false;
- } else {
- focusInv = true;
- }
- } catch(NullPointerException npe) {
- focusInv = !hoverPane;
- }
- }
- if(event.gui instanceof GuiItemRecipe) {
- GuiItemRecipe guiItemRecipe = ((GuiItemRecipe)event.gui);
- hoverInv = event.getMouseX() > guiItemRecipe.guiLeft && event.getMouseX() < guiItemRecipe.guiLeft + guiItemRecipe.xSize &&
- event.getMouseY() > guiItemRecipe.guiTop && event.getMouseY() < guiItemRecipe.guiTop + guiItemRecipe.ySize;
-
- if(hoverPane) {
- if(!hoverInv) focusInv = false;
- } else {
- focusInv = true;
- }
- }
- if(focusInv) {
- try {
- neu.overlay.render(hoverInv);
- } catch(ConcurrentModificationException e) {e.printStackTrace();}
- GL11.glTranslatef(0, 0, 10);
- }
- if(hoverInv) {
- renderDungeonChestOverlay(event.gui);
- if(NotEnoughUpdates.INSTANCE.config.accessoryBag.enableOverlay) {
- AccessoryBagOverlay.renderOverlay();
- }
- }
- }
-
- drawingGuiScreen = true;
- }
-
- private boolean doInventoryButtons = false;
-
- @SubscribeEvent
- public void onGuiScreenDrawPre(GuiScreenEvent.DrawScreenEvent.Pre event) {
- doInventoryButtons = false;
-
- if(AuctionSearchOverlay.shouldReplace()) {
- AuctionSearchOverlay.render();
- event.setCanceled(true);
- return;
- }
- if(RancherBootOverlay.shouldReplace()) {
- RancherBootOverlay.render();
- event.setCanceled(true);
- return;
- }
-
- 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();
- }
-
- if(GuiCustomEnchant.getInstance().shouldOverride(containerName)) {
- GuiCustomEnchant.getInstance().render(event.renderPartialTicks);
- event.setCanceled(true);
- return;
- }
-
- 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());
- int width = scaledResolution.getScaledWidth();
- int height = scaledResolution.getScaledHeight();
-
- //Dark background
- 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(customAhActive) {
- neu.manager.auctionManager.customAH.drawScreen(event.mouseX, event.mouseY);
- } else if(tradeWindowActive) {
- TradeWindow.render(event.mouseX, event.mouseY);
- }
- neu.overlay.render(false);
- } else {
- neu.overlay.render(false);
- if(customAhActive) {
- neu.manager.auctionManager.customAH.drawScreen(event.mouseX, event.mouseY);
- } else if(tradeWindowActive) {
- TradeWindow.render(event.mouseX, event.mouseY);
- }
- }
- }
-
- if(CalendarOverlay.isEnabled() || event.isCanceled()) return;
- if(NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && shouldRenderOverlay(event.gui)
- && event.gui instanceof GuiContainer) {
- doInventoryButtons = true;
-
- int zOffset = 50;
-
- GlStateManager.translate(0, 0, zOffset);
-
- int xSize = ((GuiContainer) event.gui).xSize;
- int ySize = ((GuiContainer) event.gui).ySize;
- int guiLeft = ((GuiContainer) event.gui).guiLeft;
- int guiTop = ((GuiContainer) event.gui).guiTop;
-
- if (!NEUApi.disableInventoryButtons) {
- 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;
- }
- }
-
- 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);
-
- if (button.icon != null && !button.icon.trim().isEmpty()) {
- GuiInvButtonEditor.renderIcon(button.icon, x + 1, y + 1);
- }
- }
- }
- GlStateManager.translate(0, 0, -zOffset);
- }
- }
-
- private static boolean shouldRenderOverlay(Gui gui) {
- boolean validGui = gui instanceof GuiContainer || gui instanceof GuiItemRecipe;
- if(gui instanceof GuiChest) {
- GuiChest eventGui = (GuiChest) gui;
- ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
- String containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText();
- if(containerName.trim().equals("Fast Travel")) {
- validGui = false;
- }
- }
- return validGui;
- }
-
- private static final ResourceLocation EDITOR = new ResourceLocation("notenoughupdates:invbuttons/editor.png");
- private NEUConfig.InventoryButton buttonHovered = null;
- private long buttonHoveredMillis = 0;
- public static boolean disableCraftingText = false;
-
- /**
- * Will draw the NEUOverlay over the inventory if focusInv == false. (z-translation of 300 is so that NEUOverlay
- * will draw over Items in the inventory (which render at a z value of about 250))
- * @param event
- */
- @SubscribeEvent
- public void onGuiScreenDrawPost(GuiScreenEvent.DrawScreenEvent.Post event) {
- drawingGuiScreen = false;
- disableCraftingText = false;
-
- 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();
- if (containerName.equals("Craft Item")) {
- CraftingOverlay.render();
- }
- }
-
- if(GuiCustomEnchant.getInstance().shouldOverride(containerName)) {
- return;
- }
-
- 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) {
- GL11.glTranslatef(0, 0, 300);
- neu.overlay.render(hoverInv && focusInv);
- GL11.glTranslatef(0, 0, -300);
- }
- GlStateManager.popMatrix();
- }
- }
-
- if(shouldRenderOverlay(event.gui) && neu.isOnSkyblock() && !hoverInv) {
- renderDungeonChestOverlay(event.gui);
- if(NotEnoughUpdates.INSTANCE.config.accessoryBag.enableOverlay) {
- AccessoryBagOverlay.renderOverlay();
- }
- }
-
- boolean hoveringButton = false;
- if(!doInventoryButtons) return;
- if(NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && shouldRenderOverlay(event.gui) &&
- event.gui instanceof GuiContainer) {
- int xSize = ((GuiContainer) event.gui).xSize;
- int ySize = ((GuiContainer) event.gui).ySize;
- int guiLeft = ((GuiContainer) event.gui).guiLeft;
- int guiTop = ((GuiContainer) event.gui).guiTop;
-
- if (!NEUApi.disableInventoryButtons) {
- 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 (x - guiLeft >= 85 && x - guiLeft <= 115 && y - guiTop >= 4 && y - guiTop <= 25) {
- disableCraftingText = true;
- }
-
- 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 (currentTime - buttonHoveredMillis > 600) {
- 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, Minecraft.getMinecraft().fontRendererObj);
- }
- }
- }
- }
- }
- if(!hoveringButton) buttonHovered = null;
-
- if(AuctionBINWarning.getInstance().shouldShow()) {
- AuctionBINWarning.getInstance().render();
- }
- }
-
- private void renderDungeonChestOverlay(GuiScreen gui) {
- if(NotEnoughUpdates.INSTANCE.config.dungeons.profitDisplayLoc == 3) return;
-
- if(gui instanceof GuiChest && NotEnoughUpdates.INSTANCE.config.dungeons.profitDisplayLoc != 2) {
- try {
- 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;
- IInventory lower = cc.getLowerChestInventory();
-
- ItemStack rewardChest = lower.getStackInSlot(31);
- if (rewardChest != null && rewardChest.getDisplayName().endsWith(EnumChatFormatting.GREEN+"Open Reward Chest")) {
- int chestCost = 0;
- try {
- String line6 = Utils.cleanColour(neu.manager.getLoreFromNBT(rewardChest.getTagCompound())[6]);
- StringBuilder cost = new StringBuilder();
- for(int i=0; i<line6.length(); i++) {
- char c = line6.charAt(i);
- if("0123456789".indexOf(c) >= 0) {
- cost.append(c);
- }
- }
- if(cost.length() > 0) {
- chestCost = Integer.parseInt(cost.toString());
- }
- } catch(Exception ignored) {}
-
- String missingItem = null;
- int totalValue = 0;
- HashMap<String, Float> itemValues = new HashMap<>();
- for(int i=0; i<5; i++) {
- ItemStack item = lower.getStackInSlot(11+i);
- String internal = neu.manager.getInternalNameForItem(item);
- if(internal != null) {
- internal = internal.replace("\u00CD", "I").replace("\u0130", "I");
- float bazaarPrice = -1;
- JsonObject bazaarInfo = neu.manager.auctionManager.getBazaarInfo(internal);
- if(bazaarInfo != null && bazaarInfo.has("curr_sell")) {
- bazaarPrice = bazaarInfo.get("curr_sell").getAsFloat();
- }
- if(bazaarPrice < 5000000 && internal.equals("RECOMBOBULATOR_3000")) bazaarPrice = 5000000;
-
- float worth = -1;
- if(bazaarPrice > 0) {
- worth = bazaarPrice;
- } else {
- switch(NotEnoughUpdates.INSTANCE.config.dungeons.profitType) {
- case 1:
- worth = neu.manager.auctionManager.getItemAvgBin(internal);
- break;
- case 2:
- JsonObject auctionInfo = neu.manager.auctionManager.getItemAuctionInfo(internal);
- if(auctionInfo != null) {
- if(auctionInfo.has("clean_price")) {
- worth = (int)auctionInfo.get("clean_price").getAsFloat();
- } else {
- worth = (int)(auctionInfo.get("price").getAsFloat() / auctionInfo.get("count").getAsFloat());
- }
- }
- break;
- default:
- worth = neu.manager.auctionManager.getLowestBin(internal);
- }
- if(worth <= 0) {
- worth = neu.manager.auctionManager.getLowestBin(internal);
- if(worth <= 0) {
- worth = neu.manager.auctionManager.getItemAvgBin(internal);
- if(worth <= 0) {
- JsonObject auctionInfo = neu.manager.auctionManager.getItemAuctionInfo(internal);
- if(auctionInfo != null) {
- if(auctionInfo.has("clean_price")) {
- worth = (int)auctionInfo.get("clean_price").getAsFloat();
- } else {
- worth = (int)(auctionInfo.get("price").getAsFloat() / auctionInfo.get("count").getAsFloat());
- }
- }
- }
- }
- }
- }
-
- if(worth > 0 && totalValue >= 0) {
- totalValue += worth;
- String display = item.getDisplayName();
-
- if(display.contains("Enchanted Book")) {
- NBTTagCompound tag = item.getTagCompound();
- if(tag != null && tag.hasKey("ExtraAttributes", 10)) {
- NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
- NBTTagCompound enchants = ea.getCompoundTag("enchantments");
-
- int highestLevel = -1;
- for(String enchname : enchants.getKeySet()) {
- int level = enchants.getInteger(enchname);
- if(level > highestLevel) {
- display = EnumChatFormatting.BLUE+WordUtils.capitalizeFully(
- enchname.replace("_", " ")
- .replace("Ultimate", "")
- .trim()) + " " + level;
- }
- }
- }
- }
-
- itemValues.put(display, worth);
- } else {
- if(totalValue != -1) {
- missingItem = internal;
- }
- totalValue = -1;
- }
- }
- }
-
- NumberFormat format = NumberFormat.getInstance(Locale.US);
- String valueStringBIN1;
- String valueStringBIN2;
- if(totalValue >= 0) {
- valueStringBIN1 = EnumChatFormatting.YELLOW+"Value (BIN): ";
- valueStringBIN2 = EnumChatFormatting.GOLD + format.format(totalValue) + " coins";
- } else {
- valueStringBIN1 = EnumChatFormatting.YELLOW+"Can't find BIN: ";
- valueStringBIN2 = missingItem;
- }
-
- int profitLossBIN = totalValue - chestCost;
-
- String profitPrefix = EnumChatFormatting.DARK_GREEN.toString();
- String lossPrefix = EnumChatFormatting.RED.toString();
- String prefix = profitLossBIN >= 0 ? profitPrefix : lossPrefix;
-
- String plStringBIN;
- if(profitLossBIN >= 0) {
- plStringBIN = prefix + "+" + format.format(profitLossBIN) + " coins";
- } else {
- plStringBIN = prefix + "-" + format.format(-profitLossBIN) + " coins";
- }
-
- if(NotEnoughUpdates.INSTANCE.config.dungeons.profitDisplayLoc == 1 && !valueStringBIN2.equals(missingItem)) {
- int w = Minecraft.getMinecraft().fontRendererObj.getStringWidth(plStringBIN);
- GlStateManager.disableLighting();
- GlStateManager.translate(0, 0, 200);
- Minecraft.getMinecraft().fontRendererObj.drawString(plStringBIN, guiLeft+xSize-5-w, guiTop+5,
- 0xffffffff, true);
- GlStateManager.translate(0, 0, -200);
- return;
- }
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(dungeon_chest_worth);
- GL11.glColor4f(1, 1, 1, 1);
- GlStateManager.disableLighting();
- Utils.drawTexturedRect(guiLeft+xSize+4, guiTop, 180, 101, 0, 180/256f, 0, 101/256f, GL11.GL_NEAREST);
-
- Utils.renderAlignedString(valueStringBIN1, valueStringBIN2,
- guiLeft+xSize+4+10, guiTop+14, 160);
- if(totalValue >= 0) {
- Utils.renderAlignedString(EnumChatFormatting.YELLOW+"Profit/Loss: ", plStringBIN,
- guiLeft+xSize+4+10, guiTop+24, 160);
- }
-
- int index=0;
- for(Map.Entry<String, Float> entry : itemValues.entrySet()) {
- Utils.renderAlignedString(entry.getKey(), prefix+
- format.format(entry.getValue().intValue()),
- guiLeft+xSize+4+10, guiTop+29+(++index)*10, 160);
- }
- }
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
- }
-
- public void drawStringShadow(String str, float x, float y, int len) {
- for(int xOff=-2; xOff<=2; xOff++) {
- for(int yOff=-2; yOff<=2; yOff++) {
- if(Math.abs(xOff) != Math.abs(yOff)) {
- Utils.drawStringCenteredScaledMaxWidth(Utils.cleanColourNotModifiers(str),
- Minecraft.getMinecraft().fontRendererObj,
- x+xOff/2f, y+yOff/2f, false, len,
- new Color(20, 20, 20, 100/Math.max(Math.abs(xOff), Math.abs(yOff))).getRGB());
- }
- }
- }
-
- Utils.drawStringCenteredScaledMaxWidth(str,
- Minecraft.getMinecraft().fontRendererObj,
- x, y, false, len,
- new Color(64, 64, 64, 255).getRGB());
- }
-
- /**
- * Sends a mouse event to NEUOverlay if the inventory isn't hovered AND focused.
- * Will also cancel the event if if NEUOverlay#mouseInput returns true.
- * @param event
- */
- @SubscribeEvent(priority = EventPriority.LOW)
- public void onGuiScreenMouse(GuiScreenEvent.MouseInputEvent.Pre event) {
- if(Mouse.getEventButtonState() && StorageManager.getInstance().onAnyClick()) {
- event.setCanceled(true);
- return;
- }
-
- 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;
-
- if(AuctionBINWarning.getInstance().shouldShow()) {
- AuctionBINWarning.getInstance().mouseInput(mouseX, mouseY);
- event.setCanceled(true);
- return;
- }
-
- if(!event.isCanceled()) {
- Utils.scrollTooltip(Mouse.getEventDWheel());
- }
- if(AuctionSearchOverlay.shouldReplace()) {
- AuctionSearchOverlay.mouseEvent();
- event.setCanceled(true);
- return;
- }
- if(RancherBootOverlay.shouldReplace()) {
- RancherBootOverlay.mouseEvent();
- event.setCanceled(true);
- return;
- }
-
- 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();
- if(containerName.contains(" Profile") && BetterContainers.profileViewerStackIndex != -1 &&
- eventGui.isMouseOverSlot(cc.inventorySlots.get(BetterContainers.profileViewerStackIndex), mouseX, mouseY) && Mouse.getEventButton() >= 0) {
- event.setCanceled(true);
- if(Mouse.getEventButtonState() && eventGui.inventorySlots.inventorySlots.get(22).getStack() != null &&
- eventGui.inventorySlots.inventorySlots.get(22).getStack().getTagCompound() != null){
- NBTTagCompound tag = eventGui.inventorySlots.inventorySlots.get(22).getStack().getTagCompound();
- if(tag.hasKey("SkullOwner") && tag.getCompoundTag("SkullOwner").hasKey("Name")){
- String username = tag.getCompoundTag("SkullOwner").getString("Name");
- Utils.playPressSound();
- NotEnoughUpdates.INSTANCE.commands.viewProfileRunnable.processCommand(null, new String[]{username});
- }
- }
- }
- }
-
- if(GuiCustomEnchant.getInstance().shouldOverride(containerName) &&
- GuiCustomEnchant.getInstance().mouseInput(mouseX, mouseY)) {
- event.setCanceled(true);
- return;
- }
-
- 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(customAhActive) {
- neu.manager.auctionManager.customAH.handleMouseInput();
- } else if(tradeWindowActive) {
- TradeWindow.handleMouseInput();
- }
- neu.overlay.mouseInput();
- return;
- }
-
- if(shouldRenderOverlay(event.gui) && neu.isOnSkyblock()) {
- if(!NotEnoughUpdates.INSTANCE.config.accessoryBag.enableOverlay || !AccessoryBagOverlay.mouseClick()) {
- if(!(hoverInv && focusInv)) {
- if(neu.overlay.mouseInput()) {
- event.setCanceled(true);
- }
- } else {
- neu.overlay.mouseInputInv();
- }
- }
- }
- if(event.isCanceled()) return;
- if(!doInventoryButtons) return;
- if(NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && shouldRenderOverlay(event.gui) && Mouse.getEventButton() >= 0
- && event.gui instanceof GuiContainer) {
- int xSize = ((GuiContainer)event.gui).xSize;
- int ySize = ((GuiContainer)event.gui).ySize;
- int guiLeft = ((GuiContainer)event.gui).guiLeft;
- int guiTop = ((GuiContainer)event.gui).guiTop;
- if(!NEUApi.disableInventoryButtons) {
- 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 (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;
- }
- }
- }
- }
- }
-
- ScheduledExecutorService ses = Executors.newScheduledThreadPool(1);
-
- JsonObject essenceJson = new JsonObject();
-
- /**
- * Sends a kbd event to NEUOverlay, cancelling if NEUOverlay#keyboardInput returns true.
- * Also includes a dev function used for creating custom named json files with recipes.
- */
- @SubscribeEvent
- public void onGuiScreenKeyboard(GuiScreenEvent.KeyboardInputEvent.Pre event) {
- if(AuctionBINWarning.getInstance().shouldShow()) {
- AuctionBINWarning.getInstance().keyboardInput();
- event.setCanceled(true);
- return;
- }
-
- if(AuctionSearchOverlay.shouldReplace()) {
- AuctionSearchOverlay.keyEvent();
- event.setCanceled(true);
- return;
- }
- if(RancherBootOverlay.shouldReplace()) {
- RancherBootOverlay.keyEvent();
- event.setCanceled(true);
- return;
- }
-
- 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();
- if(CraftingOverlay.shouldRender && containerName.equals("Craft Item")){
- CraftingOverlay.keyInput();
- }
- }
-
- if(GuiCustomEnchant.getInstance().shouldOverride(containerName) &&
- GuiCustomEnchant.getInstance().keyboardInput()) {
- event.setCanceled(true);
- return;
- }
-
- 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().keyboardInput()) {
- event.setCanceled(true);
- 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 if(tradeWindowActive) {
- TradeWindow.keyboardInput();
- if(Keyboard.getEventKey() != Keyboard.KEY_ESCAPE) {
- event.setCanceled(true);
- Minecraft.getMinecraft().dispatchKeypresses();
- neu.overlay.keyboardInput(focusInv);
- }
- }
- return;
- }
-
- if(shouldRenderOverlay(event.gui) && neu.isOnSkyblock()) {
- if(neu.overlay.keyboardInput(focusInv)) {
- event.setCanceled(true);
- }
- }
- if(NotEnoughUpdates.INSTANCE.config.hidden.dev && NotEnoughUpdates.INSTANCE.config.hidden.enableItemEditing && Minecraft.getMinecraft().theWorld != null &&
- Keyboard.getEventKey() == Keyboard.KEY_N && Keyboard.getEventKeyState()) {
- GuiScreen gui = Minecraft.getMinecraft().currentScreen;
- if(gui instanceof GuiChest) {
- GuiChest eventGui = (GuiChest) event.gui;
- ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
- IInventory lower = cc.getLowerChestInventory();
-
- if(!lower.getDisplayName().getUnformattedText().endsWith("Essence")) return;
-
- for(int i=0; i<lower.getSizeInventory(); i++) {
- ItemStack stack = lower.getStackInSlot(i);
-
- String internalname = neu.manager.getInternalNameForItem(stack);
- if(internalname != null) {
- String[] lore = neu.manager.getLoreFromNBT(stack.getTagCompound());
-
- for(String line : lore) {
- if(line.contains(":") && (line.startsWith("\u00A77Upgrade to") ||
- line.startsWith("\u00A77Convert to Dungeon Item"))) {
- String[] split = line.split(":");
- String after = Utils.cleanColour(split[1]);
- StringBuilder costS = new StringBuilder();
- for(char c : after.toCharArray()) {
- if(c >= '0' && c <= '9') {
- costS.append(c);
- }
- }
- int cost = Integer.parseInt(costS.toString());
- String[] afterSplit = after.split(" ");
- String type = afterSplit[afterSplit.length-2];
-
- if(!essenceJson.has(internalname)) {
- essenceJson.add(internalname, new JsonObject());
- }
- JsonObject obj = essenceJson.get(internalname).getAsJsonObject();
- obj.addProperty("type", type);
-
- if(line.startsWith("\u00A77Convert to Dungeon Item")) {
- obj.addProperty("dungeonize", cost);
- } else if(line.startsWith("\u00A77Upgrade to")) {
- int stars = 0;
- for(char c : line.toCharArray()) {
- if(c == '\u272A') stars++;
- }
- if(stars > 0) {
- obj.addProperty(stars+"", cost);
- }
- }
- }
- }
- }
- }
- System.out.println(essenceJson);
- }
- }
- if(NotEnoughUpdates.INSTANCE.config.hidden.dev && NotEnoughUpdates.INSTANCE.config.hidden.enableItemEditing && Minecraft.getMinecraft().theWorld != null &&
- Keyboard.getEventKey() == Keyboard.KEY_O && Keyboard.getEventKeyState()) {
- GuiScreen gui = Minecraft.getMinecraft().currentScreen;
- if(gui instanceof GuiChest) {
- GuiChest eventGui = (GuiChest) event.gui;
- ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
- IInventory lower = cc.getLowerChestInventory();
-
- if(lower.getStackInSlot(23) != null &&
- lower.getStackInSlot(23).getDisplayName().endsWith("Crafting Table")) {
- ItemStack res = lower.getStackInSlot(25);
- String resInternalname = neu.manager.getInternalNameForItem(res);
- JTextField tf = new JTextField();
- tf.setText(resInternalname);
- tf.addAncestorListener(new RequestFocusListener());
- JOptionPane.showOptionDialog(null,
- tf,
- "Enter Name:",
- JOptionPane.NO_OPTION,
- JOptionPane.PLAIN_MESSAGE,
- null, new String[]{"Enter"}, "Enter");
- resInternalname = tf.getText();
- if(resInternalname.trim().length() == 0) {
- return;
- }
-
- JsonObject recipe = new JsonObject();
-
- String[] x = {"1","2","3"};
- String[] y = {"A","B","C"};
-
- for(int i=0; i<=18; i+=9) {
- for(int j=0; j<3; j++) {
- ItemStack stack = lower.getStackInSlot(10+i+j);
- String internalname = "";
- if(stack != null) {
- internalname = neu.manager.getInternalNameForItem(stack);
- if(!neu.manager.getItemInformation().containsKey(internalname)) {
- neu.manager.writeItemToFile(stack);
- }
- internalname += ":"+stack.stackSize;
- }
- recipe.addProperty(y[i/9]+x[j], internalname);
- }
- }
-
- JsonObject json = neu.manager.getJsonForItem(res);
- json.add("recipe", recipe);
- json.addProperty("internalname", resInternalname);
- json.addProperty("clickcommand", "viewrecipe");
- json.addProperty("modver", NotEnoughUpdates.VERSION);
- try {
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Added: " + resInternalname));
- neu.manager.writeJsonDefaultDir(json, resInternalname+".json");
- neu.manager.loadItem(resInternalname);
- } catch(IOException e) {}
- }
- }
- }
- }
-
-
-
- private HashSet<String> percentStats = new HashSet<>();
- {
- percentStats.add("bonus_attack_speed");
- percentStats.add("crit_damage");
- percentStats.add("crit_chance");
- percentStats.add("sea_creature_chance");
- percentStats.add("ability_damage");
- }
-
- private String currentRarity = "COMMON";
- private boolean showReforgeStoneStats = true;
- private boolean pressedArrowLast = false;
- private boolean pressedShiftLast = false;
-
- private boolean copied = false;
-
- //just to try and optimize it a bit
- private int sbaloaded = -1;
- private boolean isSbaloaded(){
- if(sbaloaded == -1){
- if(Loader.isModLoaded("skyblockaddons")) {
- sbaloaded = 1;
- } else {
- sbaloaded = 0;
- }
- }
- return sbaloaded == 1;
- }
-
- @SubscribeEvent(priority = EventPriority.LOW)
- public void onItemTooltipLow(ItemTooltipEvent event) {
- if(!NotEnoughUpdates.INSTANCE.isOnSkyblock()) return;
-
- String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(event.itemStack);
- if(internalname == null) {
- onItemToolTipInternalNameNull(event);
- return;
- }
-
- boolean hasEnchantments = event.itemStack.getTagCompound().getCompoundTag("ExtraAttributes").hasKey("enchantments", 10);
- Set<String> enchantIds = new HashSet<>();
- if(hasEnchantments) enchantIds = event.itemStack.getTagCompound().getCompoundTag("ExtraAttributes").getCompoundTag("enchantments").getKeySet();
-
- JsonObject enchantsConst = Constants.ENCHANTS;
- JsonArray allItemEnchs = null;
- Set<String> ignoreFromPool = new HashSet<>();
- if(enchantsConst != null && hasEnchantments && NotEnoughUpdates.INSTANCE.config.tooltipTweaks.missingEnchantList) {
- try {
- JsonArray enchantPools = enchantsConst.get("enchant_pools").getAsJsonArray();
- for(JsonElement element : enchantPools) {
- Set<String> currentPool = new HashSet<>();
- for(JsonElement poolElement : element.getAsJsonArray()) {
- String poolS = poolElement.getAsString();
- currentPool.add(poolS);
- }
- for(JsonElement poolElement : element.getAsJsonArray()) {
- String poolS = poolElement.getAsString();
- if(enchantIds.contains(poolS)) {
- ignoreFromPool.addAll(currentPool);
- break;
- }
- }
- }
-
- JsonObject enchantsObj = enchantsConst.get("enchants").getAsJsonObject();
- NBTTagCompound tag = event.itemStack.getTagCompound();
- if(tag != null) {
- NBTTagCompound display = tag.getCompoundTag("display");
- if (display.hasKey("Lore", 9)) {
- NBTTagList list = display.getTagList("Lore", 8);
- out:
- for (int i = list.tagCount(); i >= 0; i--) {
- String line = list.getStringTagAt(i);
- for(int j=0; j<Utils.rarityArrC.length; j++) {
- for(Map.Entry<String, JsonElement> entry : enchantsObj.entrySet()) {
- if(line.contains(Utils.rarityArrC[j] + " " + entry.getKey()) || line.contains(Utils.rarityArrC[j] + " DUNGEON " + entry.getKey())) {
- allItemEnchs = entry.getValue().getAsJsonArray();
- break out;
- }
- }
- }
- }
- }
- }
- } catch(Exception e) {}
- }
-
- boolean gotToEnchants = false;
- boolean passedEnchants = false;
-
- boolean dungeonProfit = false;
- int index = 0;
- List<String> newTooltip = new ArrayList<>();
-
- for(String line : event.toolTip) {
- if(line.endsWith(EnumChatFormatting.DARK_GRAY+"Reforge Stone") && NotEnoughUpdates.INSTANCE.config.tooltipTweaks.showReforgeStats) {
- JsonObject reforgeStones = Constants.REFORGESTONES;
-
-
- if(reforgeStones != null && reforgeStones.has(internalname)) {
- boolean shift = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
- if(!pressedShiftLast && shift) {
- showReforgeStoneStats = !showReforgeStoneStats;
- }
- pressedShiftLast = shift;
-
- newTooltip.add(line);
- newTooltip.add("");
- if(!showReforgeStoneStats) {
- newTooltip.add(EnumChatFormatting.DARK_GRAY+"[Press SHIFT to show extra info]");
- } else {
- newTooltip.add(EnumChatFormatting.DARK_GRAY+"[Press SHIFT to hide extra info]");
- }
-
- JsonObject reforgeInfo = reforgeStones.get(internalname).getAsJsonObject();
- JsonArray requiredRaritiesArray = reforgeInfo.get("requiredRarities").getAsJsonArray();
-
- if(showReforgeStoneStats && requiredRaritiesArray.size() > 0) {
- String reforgeName = Utils.getElementAsString(reforgeInfo.get("reforgeName"), "");
-
- String[] requiredRarities = new String[requiredRaritiesArray.size()];
- for(int i=0; i<requiredRaritiesArray.size(); i++) {
- requiredRarities[i] = requiredRaritiesArray.get(i).getAsString();
- }
-
- int rarityIndex = requiredRarities.length-1;
- String rarity = requiredRarities[rarityIndex];
- for(int i=0; i<requiredRarities.length; i++) {
- String rar = requiredRarities[i];
- if(rar.equalsIgnoreCase(currentRarity)) {
- rarity = rar;
- rarityIndex = i;
- break;
- }
- }
-
- boolean left = Keyboard.isKeyDown(Keyboard.KEY_LEFT);
- boolean right = Keyboard.isKeyDown(Keyboard.KEY_RIGHT);
- if(!pressedArrowLast && (left || right)) {
- if(left) {
- rarityIndex--;
- } else if(right) {
- rarityIndex++;
- }
- if(rarityIndex < 0) rarityIndex = 0;
- if(rarityIndex >= requiredRarities.length) rarityIndex = requiredRarities.length-1;
- currentRarity = requiredRarities[rarityIndex];
- rarity = currentRarity;
- }
- pressedArrowLast = left || right;
-
- JsonElement statsE = reforgeInfo.get("reforgeStats");
-
-
- String rarityFormatted = Utils.rarityArrMap.getOrDefault(rarity, rarity);
-
- JsonElement reforgeAbilityE = reforgeInfo.get("reforgeAbility");
- String reforgeAbility = null;
- if (reforgeAbilityE != null) {
- if (reforgeAbilityE.isJsonPrimitive() && reforgeAbilityE.getAsJsonPrimitive().isString()) {
- reforgeAbility = Utils.getElementAsString(reforgeInfo.get("reforgeAbility"), "");
-
- } else if (reforgeAbilityE.isJsonObject()) {
- if (reforgeAbilityE.getAsJsonObject().has(rarity)) {
- reforgeAbility = reforgeAbilityE.getAsJsonObject().get(rarity).getAsString();
- }
- }
- }
-
- if (reforgeAbility != null && !reforgeAbility.isEmpty()) {
- String text = EnumChatFormatting.BLUE + (reforgeName.isEmpty() ? "Bonus: " : reforgeName + " Bonus: ") +
- EnumChatFormatting.GRAY + reforgeAbility;
- boolean first = true;
- for (String s : Minecraft.getMinecraft().fontRendererObj.listFormattedStringToWidth(text, 150)) {
- newTooltip.add((first ? "" : " ") + s);
- first = false;
- }
- newTooltip.add("");
- }
-
- newTooltip.add(EnumChatFormatting.BLUE + "Stats for " + rarityFormatted + "\u00a79: [\u00a7l\u00a7m< \u00a79Switch\u00a7l\u27a1\u00a79]");
-
- if(statsE != null && statsE.isJsonObject()) {
- JsonObject stats = statsE.getAsJsonObject();
-
- JsonElement statsRarE = stats.get(rarity);
- if (statsRarE != null && statsRarE.isJsonObject()) {
-
- JsonObject statsRar = statsRarE.getAsJsonObject();
-
- TreeSet<Map.Entry<String, JsonElement>> sorted = new TreeSet<>(Map.Entry.comparingByKey());
- sorted.addAll(statsRar.entrySet());
-
- for (Map.Entry<String, JsonElement> entry : sorted) {
- if (entry.getValue().isJsonPrimitive() && ((JsonPrimitive) entry.getValue()).isNumber()) {
- float statNumF = entry.getValue().getAsFloat();
- String statNumS;
- if (statNumF % 1 == 0) {
- statNumS = String.valueOf(Math.round(statNumF));
- } else {
- statNumS = Utils.floatToString(statNumF, 1);
- }
- String reforgeNamePretty = WordUtils.capitalizeFully(entry.getKey().replace("_", " "));
- String text = EnumChatFormatting.GRAY + reforgeNamePretty + ": " + EnumChatFormatting.GREEN + "+" + statNumS;
- if (percentStats.contains(entry.getKey())) {
- text += "%";
- }
- newTooltip.add(" " + text);
- }
- }
- }
- }
-
- JsonElement reforgeCostsE = reforgeInfo.get("reforgeCosts");
- int reforgeCost = -1;
- if (reforgeCostsE != null) {
- if (reforgeCostsE.isJsonPrimitive() && reforgeCostsE.getAsJsonPrimitive().isNumber()) {
- reforgeCost = (int) Utils.getElementAsFloat(reforgeInfo.get("reforgeAbility"), -1);
-
- } else if (reforgeCostsE.isJsonObject()) {
- if (reforgeCostsE.getAsJsonObject().has(rarity)) {
- reforgeCost = (int) Utils.getElementAsFloat(reforgeCostsE.getAsJsonObject().get(rarity), -1);
- }
- }
- }
-
- if (reforgeCost >= 0) {
- String text = EnumChatFormatting.BLUE + "Apply Cost: " + EnumChatFormatting.GOLD + NumberFormat.getNumberInstance().format(reforgeCost) + " coins";
- newTooltip.add("");
- newTooltip.add(text);
- }
-
- }
-
-
- continue;
- }
-
- } else if(line.contains("\u00A7cR\u00A76a\u00A7ei\u00A7an\u00A7bb\u00A79o\u00A7dw\u00A79 Rune")) {
- line = line.replace("\u00A7cR\u00A76a\u00A7ei\u00A7an\u00A7bb\u00A79o\u00A7dw\u00A79 Rune",
- Utils.chromaString("Rainbow Rune", index, false)+EnumChatFormatting.BLUE);
- } else if(hasEnchantments) {
- if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && NotEnoughUpdates.INSTANCE.config.tooltipTweaks.missingEnchantList) {
- boolean lineHasEnch = false;
- for(String s : enchantIds) {
- String enchantName = WordUtils.capitalizeFully(s.replace("_", " "));
- if(line.contains(enchantName)) {
- lineHasEnch = true;
- break;
- }
- }
- if(lineHasEnch) {
- gotToEnchants = true;
- } else {
- if(gotToEnchants && !passedEnchants && Utils.cleanColour(line).trim().length() == 0) {
- if(enchantsConst != null && allItemEnchs != null) {
- List<String> missing = new ArrayList<>();
- for(JsonElement enchIdElement : allItemEnchs) {
- String enchId = enchIdElement.getAsString();
- if(!enchId.startsWith("ultimate_") && !ignoreFromPool.contains(enchId) && !enchantIds.contains(enchId)) {
- missing.add(enchId);
- }
- }
- newTooltip.add("");
- StringBuilder currentLine = new StringBuilder(EnumChatFormatting.RED+"Missing: "+EnumChatFormatting.GRAY);
- for(int i=0; i<missing.size(); i++) {
- String enchName = WordUtils.capitalizeFully(missing.get(i).replace("_", " "));
- if(currentLine.length() != 0 && (Utils.cleanColour(currentLine.toString()).length() + enchName.length()) > 40) {
- newTooltip.add(currentLine.toString());
- currentLine = new StringBuilder();
- }
- if(currentLine.length() != 0 && i != 0) {
- currentLine.append(", ").append(enchName);
- } else {
- currentLine.append(EnumChatFormatting.GRAY).append(enchName);
- }
- }
- if(currentLine.length() != 0) {
- newTooltip.add(currentLine.toString());
- }
- }
- passedEnchants = true;
- }
- }
- }
- for(String op : NotEnoughUpdates.INSTANCE.config.hidden.enchantColours) {
- List<String> colourOps = GuiEnchantColour.splitter.splitToList(op);
- String enchantName = GuiEnchantColour.getColourOpIndex(colourOps, 0);
- String comparator = GuiEnchantColour.getColourOpIndex(colourOps, 1);
- String comparison = GuiEnchantColour.getColourOpIndex(colourOps, 2);
- String colourCode = GuiEnchantColour.getColourOpIndex(colourOps, 3);
- String modifier = GuiEnchantColour.getColourOpIndex(colourOps, 4);
-
- int modifierI = GuiEnchantColour.getIntModifier(modifier);
-
- if(enchantName.length() == 0) continue;
- if(comparator.length() == 0) continue;
- if(comparison.length() == 0) continue;
- if(colourCode.length() == 0) continue;
-
- int comparatorI = ">=<".indexOf(comparator.charAt(0));
-
- int levelToFind = -1;
- try {
- levelToFind = Integer.parseInt(comparison);
- } catch(Exception e) { continue; }
-
- if(comparatorI < 0) continue;
- String regexText = "0123456789abcdefz";
- if(isSbaloaded()) {
- regexText = regexText + "Z";
- }
-
- if (regexText.indexOf(colourCode.charAt(0)) < 0) continue;
-
- //item_lore = item_lore.replaceAll("\\u00A79("+lvl4Max+" IV)", EnumChatFormatting.DARK_PURPLE+"$1");
- //9([a-zA-Z ]+?) ([0-9]+|(I|II|III|IV|V|VI|VII|VIII|IX|X))(,|$)
- Pattern pattern;
- try {
- pattern = Pattern.compile("(\\u00A79|\\u00A7(9|l)\\u00A7d\\u00A7l)(?<enchantName>"+enchantName+") " +
- "(?<level>[0-9]+|(I|II|III|IV|V|VI|VII|VIII|IX|X|XI|XII|XIII|XIV|XV|XVI|XVII|XVIII|XIX|XX))((\\u00A79)?,|( \\u00A78(?:,?[0-9]+)*)?$)");
- } catch(Exception e) {continue;} //malformed regex
- Matcher matcher = pattern.matcher(line);
- int matchCount = 0;
- while(matcher.find() && matchCount < 5) {
- if(Utils.cleanColour(matcher.group("enchantName")).startsWith(" ")) continue;
-
-
- matchCount++;
- int level = -1;
- String levelStr = matcher.group("level");
- if(levelStr == null) continue;
- try {
- level = Integer.parseInt(levelStr);
- } catch(Exception e) {
- switch(levelStr) {
- case "I":
- level = 1; break;
- case "II":
- level = 2; break;
- case "III":
- level = 3; break;
- case "IV":
- level = 4; break;
- case "V":
- level = 5; break;
- case "VI":
- level = 6; break;
- case "VII":
- level = 7; break;
- case "VIII":
- level = 8; break;
- case "IX":
- level = 9; break;
- case "X":
- level = 10; break;
- case "XI":
- level = 11; break;
- case "XII":
- level = 12; break;
- case "XIII":
- level = 13; break;
- case "XIV":
- level = 14; break;
- case "XV":
- level = 15; break;
- case "XVI":
- level = 16; break;
- case "XVII":
- level = 17; break;
- case "XVIII":
- level = 18; break;
- case "XIX":
- level = 19; break;
- case "XX":
- level = 20; break;
- }
- }
- boolean matches = false;
- if(level > 0) {
- switch(comparator) {
- case ">":
- matches = level > levelToFind; break;
- case "=":
- matches = level == levelToFind; break;
- case "<":
- matches = level < levelToFind; break;
- }
- }
- if(matches) {
- String enchantText = matcher.group("enchantName");
- StringBuilder extraModifiersBuilder = new StringBuilder();
-
- if((modifierI & GuiEnchantColour.BOLD_MODIFIER) != 0) {
- extraModifiersBuilder.append(EnumChatFormatting.BOLD);
- }
- if((modifierI & GuiEnchantColour.ITALIC_MODIFIER) != 0) {
- extraModifiersBuilder.append(EnumChatFormatting.ITALIC);
- }
- if((modifierI & GuiEnchantColour.UNDERLINE_MODIFIER) != 0) {
- extraModifiersBuilder.append(EnumChatFormatting.UNDERLINE);
- }
- if((modifierI & GuiEnchantColour.OBFUSCATED_MODIFIER) != 0) {
- extraModifiersBuilder.append(EnumChatFormatting.OBFUSCATED);
- }
- if((modifierI & GuiEnchantColour.STRIKETHROUGH_MODIFIER) != 0) {
- extraModifiersBuilder.append(EnumChatFormatting.STRIKETHROUGH);
- }
-
- String extraMods = extraModifiersBuilder.toString();
-
- if(!colourCode.equals("z")) {
- line = line.replace("\u00A79"+enchantText,
- "\u00A7"+colourCode+extraMods+enchantText);
- line = line.replace("\u00A79\u00A7d\u00A7l"+enchantText,
- "\u00A7"+colourCode+extraMods+enchantText);
- line = line.replace("\u00A7l\u00A7d\u00A7l"+enchantText,
- "\u00A7"+colourCode+extraMods+enchantText);
- } else {
- int offset = Minecraft.getMinecraft().fontRendererObj.getStringWidth(line.replaceAll(
- "\\u00A79"+enchantText+".*", ""));
- line = line.replace("\u00A79"+enchantText, Utils.chromaString(enchantText, offset/12f+index, false));
-
- offset = Minecraft.getMinecraft().fontRendererObj.getStringWidth(line.replaceAll(
- "\\u00A79\\u00A7d\\u00A7l"+enchantText+".*", ""));
- line = line.replace("\u00A79\u00A7d\u00A7l"+enchantText, Utils.chromaString(enchantText,
- offset/12f+index, true));
- offset = Minecraft.getMinecraft().fontRendererObj.getStringWidth(line.replaceAll(
- "\\u00A7l\\u00A7d\\u00A7l"+enchantText+".*", ""));
- line = line.replace("\u00A7l\u00A7d\u00A7l"+enchantText, Utils.chromaString(enchantText,
- offset/12f+index, true));
- }
- }
- }
- }
- }
-
- newTooltip.add(line);
-
-
- if(NotEnoughUpdates.INSTANCE.config.tooltipTweaks.showPriceInfoAucItem) {
- if(line.contains(EnumChatFormatting.GRAY+"Buy it now: ") ||
- line.contains(EnumChatFormatting.GRAY+"Bidder: ") ||
- line.contains(EnumChatFormatting.GRAY+"Starting bid: ")) {
-
- if(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && !Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
- newTooltip.add("");
- newTooltip.add(EnumChatFormatting.GRAY+"[SHIFT for Price Info]");
- } else {
- ItemPriceInformation.addToTooltip(newTooltip, internalname, event.itemStack);
- }
- }
- }
-
- if(NotEnoughUpdates.INSTANCE.config.dungeons.profitDisplayLoc == 2 && Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
- if(line.contains(EnumChatFormatting.GREEN+"Open Reward Chest")) {
- dungeonProfit = true;
- } else if(index == 7 && dungeonProfit) {
- GuiChest eventGui = (GuiChest) Minecraft.getMinecraft().currentScreen;
- ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
- IInventory lower = cc.getLowerChestInventory();
-
- int chestCost = 0;
- try {
- String line6 = Utils.cleanColour(line);
- StringBuilder cost = new StringBuilder();
- for(int i=0; i<line6.length(); i++) {
- char c = line6.charAt(i);
- if("0123456789".indexOf(c) >= 0) {
- cost.append(c);
- }
- }
- if(cost.length() > 0) {
- chestCost = Integer.parseInt(cost.toString());
- }
- } catch(Exception ignored) {}
-
- String missingItem = null;
- int totalValue = 0;
- HashMap<String, Float> itemValues = new HashMap<>();
- for(int i=0; i<5; i++) {
- ItemStack item = lower.getStackInSlot(11+i);
- String internal = neu.manager.getInternalNameForItem(item);
- if(internal != null) {
- internal = internal.replace("\u00CD", "I").replace("\u0130", "I");
- float bazaarPrice = -1;
- JsonObject bazaarInfo = neu.manager.auctionManager.getBazaarInfo(internal);
- if(bazaarInfo != null && bazaarInfo.has("curr_sell")) {
- bazaarPrice = bazaarInfo.get("curr_sell").getAsFloat();
- }
- if(bazaarPrice < 5000000 && internal.equals("RECOMBOBULATOR_3000")) bazaarPrice = 5000000;
-
- float worth = -1;
- if(bazaarPrice > 0) {
- worth = bazaarPrice;
- } else {
- switch(NotEnoughUpdates.INSTANCE.config.dungeons.profitType) {
- case 1:
- worth = neu.manager.auctionManager.getItemAvgBin(internal);
- break;
- case 2:
- JsonObject auctionInfo = neu.manager.auctionManager.getItemAuctionInfo(internal);
- if(auctionInfo != null) {
- if(auctionInfo.has("clean_price")) {
- worth = (int)auctionInfo.get("clean_price").getAsFloat();
- } else {
- worth = (int)(auctionInfo.get("price").getAsFloat() / auctionInfo.get("count").getAsFloat());
- }
- }
- break;
- default:
- worth = neu.manager.auctionManager.getLowestBin(internal);
- }
- if(worth <= 0) {
- worth = neu.manager.auctionManager.getLowestBin(internal);
- if(worth <= 0) {
- worth = neu.manager.auctionManager.getItemAvgBin(internal);
- if(worth <= 0) {
- JsonObject auctionInfo = neu.manager.auctionManager.getItemAuctionInfo(internal);
- if(auctionInfo != null) {
- if(auctionInfo.has("clean_price")) {
- worth = (int)auctionInfo.get("clean_price").getAsFloat();
- } else {
- worth = (int)(auctionInfo.get("price").getAsFloat() / auctionInfo.get("count").getAsFloat());
- }
- }
- }
- }
- }
- }
-
- if(worth > 0 && totalValue >= 0) {
- totalValue += worth;
-
- String display = item.getDisplayName();
-
- if(display.contains("Enchanted Book")) {
- NBTTagCompound tag = item.getTagCompound();
- if(tag != null && tag.hasKey("ExtraAttributes", 10)) {
- NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
- NBTTagCompound enchants = ea.getCompoundTag("enchantments");
-
- int highestLevel = -1;
- for(String enchname : enchants.getKeySet()) {
- int level = enchants.getInteger(enchname);
- if(level > highestLevel) {
- display = EnumChatFormatting.BLUE+WordUtils.capitalizeFully(
- enchname.replace("_", " ")
- .replace("Ultimate", "")
- .trim()) + " " + level;
- }
- }
- }
- }
-
- itemValues.put(display, worth);
- } else {
- if(totalValue != -1) {
- missingItem = internal;
- }
- totalValue = -1;
- }
- }
- }
-
- NumberFormat format = NumberFormat.getInstance(Locale.US);
- String valueStringBIN1;
- String valueStringBIN2;
- if(totalValue >= 0) {
- valueStringBIN1 = EnumChatFormatting.YELLOW+"Value (BIN): ";
- valueStringBIN2 = EnumChatFormatting.GOLD + format.format(totalValue) + " coins";
- } else {
- valueStringBIN1 = EnumChatFormatting.YELLOW+"Can't find BIN: ";
- valueStringBIN2 = missingItem;
- }
-
- int profitLossBIN = totalValue - chestCost;
- String profitPrefix = EnumChatFormatting.DARK_GREEN.toString();
- String lossPrefix = EnumChatFormatting.RED.toString();
- String prefix = profitLossBIN >= 0 ? profitPrefix : lossPrefix;
-
- String plStringBIN;
- if(profitLossBIN >= 0) {
- plStringBIN = prefix + "+" + format.format(profitLossBIN) + " coins";
- } else {
- plStringBIN = prefix + "-"+ format.format(-profitLossBIN) + " coins";
- }
-
- String neu = EnumChatFormatting.YELLOW + "[NEU] ";
-
- newTooltip.add(neu + valueStringBIN1 + " " + valueStringBIN2);
- if(totalValue >= 0) {
- newTooltip.add(neu + EnumChatFormatting.YELLOW+"Profit/Loss: " + plStringBIN);
- }
-
- for(Map.Entry<String, Float> entry : itemValues.entrySet()) {
- newTooltip.add(neu + entry.getKey() + prefix+"+"+
- format.format(entry.getValue().intValue()));
- }
- }
- }
-
- index++;
- }
-
- for (int i = newTooltip.size()-1; i >=0; i--) {
- String line = Utils.cleanColour(newTooltip.get(i));
- for (int i1 = 0; i1 < Utils.rarityArr.length; i1++) {
- if(line.equals(Utils.rarityArr[i1])){
- if(i-2 <0){
- break;
- }
- newTooltip.addAll(i-1, petToolTipXPExtend(event));
- break;
- }
- }
- }
-
- pressedShiftLast = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
- pressedArrowLast = Keyboard.isKeyDown(Keyboard.KEY_LEFT) || Keyboard.isKeyDown(Keyboard.KEY_RIGHT);
-
- event.toolTip.clear();
- event.toolTip.addAll(newTooltip);
-
- HashMap<String, List<String>> loreBuckets = new HashMap<>();
-
- List<String> hypixelOrder = new ArrayList<>();
-
- hypixelOrder.add("attributes");
- hypixelOrder.add("enchants");
- hypixelOrder.add("ability");
- hypixelOrder.add("reforge_bonus");
- hypixelOrder.add("rarity");
-
- if(NotEnoughUpdates.INSTANCE.config.tooltipTweaks.showPriceInfoInvItem) {
- ItemPriceInformation.addToTooltip(event.toolTip, internalname, event.itemStack);
- }
-
-
-
-
-
- }
-
- private Pattern xpLevelPattern = Pattern.compile("(.*) (\\xA7e(.*)\\xA76/\\xA7e(.*))");
-
- private void onItemToolTipInternalNameNull(ItemTooltipEvent event){
- petToolTipXPExtendPetMenu(event);
- }
-
- private List<String> petToolTipXPExtend(ItemTooltipEvent event) {
- List<String> tooltipText = new ArrayList();
- if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.petExtendExp) {
- if(event.itemStack.getTagCompound().hasKey("DisablePetExp")){
- if(event.itemStack.getTagCompound().getBoolean("DisablePetExp")){
- return tooltipText;
- }
- }
- //7 is just a random number i chose, prob no pets with less lines than 7
- if (event.toolTip.size() > 7) {
- if (Utils.cleanColour(event.toolTip.get(1)).matches(petToolTipRegex)) {
-
- GuiProfileViewer.PetLevel petlevel = null;
-
- //this is the item itself
- NBTTagCompound tag = event.itemStack.getTagCompound();
- if (tag.hasKey("ExtraAttributes")) {
- if (tag.getCompoundTag("ExtraAttributes").hasKey("petInfo")) {
- JsonObject petInfo = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(
- tag.getCompoundTag("ExtraAttributes").getString("petInfo"), JsonObject.class);
- if (petInfo.has("exp") && petInfo.get("exp").isJsonPrimitive()) {
- JsonPrimitive exp = petInfo.getAsJsonPrimitive("exp");
- String petName = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(event.itemStack);
- //Utils.getRarityFromInt(Utils.checkItemTypePet(event.toolTip))).getAsInt();
- petlevel = GuiProfileViewer.getPetLevel(petName, Utils.getRarityFromInt(Utils.checkItemTypePet(event.toolTip)), exp.getAsLong());
- }
- }
- }
-
- if (petlevel != null) {
- tooltipText.add("");
- if(petlevel.totalXp > petlevel.maxXP) {
- tooltipText.add(EnumChatFormatting.AQUA + "" + EnumChatFormatting.BOLD +"MAX LEVEL");
- } else {
- tooltipText.add(EnumChatFormatting.GRAY+"Progress to Level "+(int)Math.floor(petlevel.level+1)+": "+EnumChatFormatting.YELLOW+Utils.round(petlevel.levelPercentage*100, 1)+"%");
- int levelpercentage = Math.round(petlevel.levelPercentage*20);
- tooltipText.add(EnumChatFormatting.DARK_GREEN+String.join("", Collections.nCopies(levelpercentage, "-"))+EnumChatFormatting.WHITE+String.join("", Collections.nCopies(20-levelpercentage, "-")));
- tooltipText.add(EnumChatFormatting.GRAY + "EXP: " + EnumChatFormatting.YELLOW + myFormatter.format(petlevel.levelXp) +
- EnumChatFormatting.GOLD + "/" + EnumChatFormatting.YELLOW + myFormatter.format(petlevel.currentLevelRequirement) + " EXP");
- }
- }
- }
- }
- }
- return tooltipText;
- }
-
- private static final String petToolTipRegex = "((Farming)|(Combat)|(Fishing)|(Mining)|(Foraging)|(Enchanting)|(Alchemy)) ((Mount)|(Pet)|(Morph)).*";
-
- private void petToolTipXPExtendPetMenu(ItemTooltipEvent event) {
- if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.petExtendExp) {
- //7 is just a random number i chose, prob no pets with less lines than 7
- if (event.toolTip.size() > 7) {
- if (Utils.cleanColour(event.toolTip.get(1)).matches(petToolTipRegex)) {
- GuiProfileViewer.PetLevel petlevel = null;
-
- int xpLine = -1;
- for (int i = event.toolTip.size() - 1; i >= 0; i--) {
- Matcher matcher = xpLevelPattern.matcher(event.toolTip.get(i));
- if (matcher.matches()) {
- xpLine = i;
- event.toolTip.set(xpLine, matcher.group(1));
- break;
- } else if (event.toolTip.get(i).matches("MAX LEVEL")) {
- return;
- }
- }
-
- PetInfoOverlay.Pet pet = PetInfoOverlay.getPetFromStack(event.itemStack.getDisplayName(), NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(event.itemStack.getTagCompound()));
- if (pet == null) {
- return;
- }
- petlevel = pet.petLevel;
-
- if (petlevel == null||xpLine==-1) {
- return;
- }
-
- event.toolTip.add(xpLine+1, EnumChatFormatting.GRAY + "EXP: " + EnumChatFormatting.YELLOW + myFormatter.format(petlevel.levelXp) +
- EnumChatFormatting.GOLD + "/" + EnumChatFormatting.YELLOW + myFormatter.format(petlevel.currentLevelRequirement));
-
- }
- }
- }
- }
-
- DecimalFormat myFormatter = new DecimalFormat("###,###.###");
-
- /**
- * This makes it so that holding LCONTROL while hovering over an item with NBT will show the NBT of the item.
- * @param event
- */
- @SubscribeEvent
- public void onItemTooltip(ItemTooltipEvent event) {
- if(!neu.isOnSkyblock()) return;
- /*if(NotEnoughUpdates.INSTANCE.config.improvedSBMenu.hideEmptyPanes &&
- event.itemStack.getItem().equals(Item.getItemFromBlock(Blocks.stained_glass_pane))) {
- String first = Utils.cleanColour(event.toolTip.get(0));
- first = first.replaceAll("\\(.*\\)", "").trim();
- if(first.length() == 0) {
- event.toolTip.clear();
- }
- }*/
- //AH prices
- /*if(Minecraft.getMinecraft().currentScreen != null) {
- if(Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
- GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
- ContainerChest container = (ContainerChest) chest.inventorySlots;
- String containerName = container.getLowerChestInventory().getDisplayName().getUnformattedText();
- if(containerName.trim().equals("Auctions Browser")) {
- String internalname = neu.manager.getInternalNameForItem(event.itemStack);
- if(internalname != null) {
- for(int i=0; i<event.toolTip.size(); i++) {
- String line = event.toolTip.get(i);
- if(line.contains(EnumChatFormatting.GRAY + "Bidder: ") ||
- line.contains(EnumChatFormatting.GRAY + "Starting bid: ") ||
- line.contains(EnumChatFormatting.GRAY + "Buy it now: ")) {
- neu.manager.updatePrices();
- JsonObject auctionInfo = neu.manager.getItemAuctionInfo(internalname);
-
- if(auctionInfo != null) {
- NumberFormat format = NumberFormat.getInstance(Locale.US);
- int auctionPrice = (int)(auctionInfo.get("price").getAsFloat() / auctionInfo.get("count").getAsFloat());
- float costOfEnchants = neu.manager.getCostOfEnchants(internalname,
- event.itemStack.getTagCompound());
- int priceWithEnchants = auctionPrice+(int)costOfEnchants;
-
- event.toolTip.add(++i, EnumChatFormatting.GRAY + "Average price: " +
- EnumChatFormatting.GOLD + format.format(auctionPrice) + " coins");
- if(costOfEnchants > 0) {
- event.toolTip.add(++i, EnumChatFormatting.GRAY + "Average price (w/ enchants): " +
- EnumChatFormatting.GOLD +
- format.format(priceWithEnchants) + " coins");
- }
-
- if(neu.manager.config.advancedPriceInfo.value) {
- int salesVolume = (int) auctionInfo.get("sales").getAsFloat();
- int flipPrice = (int)(0.93*priceWithEnchants);
-
- event.toolTip.add(++i, EnumChatFormatting.GRAY + "Flip Price (93%): " +
- EnumChatFormatting.GOLD + format.format(flipPrice) + " coins");
- event.toolTip.add(++i, EnumChatFormatting.GRAY + "Volume: " +
- EnumChatFormatting.GOLD + format.format(salesVolume) + " sales/day");
- }
- break;
- }
- }
- }
- }
- }
- }
- }*/
- if(Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) && NotEnoughUpdates.INSTANCE.config.hidden.dev &&
- event.toolTip.size()>0&&event.toolTip.get(event.toolTip.size()-1).startsWith(EnumChatFormatting.DARK_GRAY + "NBT: ")) {
- event.toolTip.remove(event.toolTip.size()-1);
-
- StringBuilder sb = new StringBuilder();
- String nbt = event.itemStack.getTagCompound().toString();
- int indent = 0;
- for(char c : nbt.toCharArray()) {
- boolean newline = false;
- if(c == '{' || c == '[') {
- indent++;
- newline = true;
- } else if(c == '}' || c == ']') {
- indent--;
- sb.append("\n");
- for(int i=0; i<indent; i++) sb.append(" ");
- } else if(c == ',') {
- newline = true;
- } else if(c == '\"') {
- sb.append(EnumChatFormatting.RESET.toString() + EnumChatFormatting.GRAY);
- }
-
- sb.append(c);
- if(newline) {
- sb.append("\n");
- for(int i=0; i<indent; i++) sb.append(" ");
- }
- }
- event.toolTip.add(sb.toString());
- if(Keyboard.isKeyDown(Keyboard.KEY_H)) {
- if(!copied) {
- copied = true;
- StringSelection selection = new StringSelection(sb.toString());
- Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, selection);
- }
- } else {
- copied = false;
- }
- } else if(NotEnoughUpdates.INSTANCE.packDevEnabled) {
- event.toolTip.add("");
- event.toolTip.add(EnumChatFormatting.AQUA+"NEU Pack Dev Info:");
- event.toolTip.add("Press "+EnumChatFormatting.GOLD+"[KEY]"+EnumChatFormatting.GRAY+" to copy line");
-
- String internal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(event.itemStack);
-
- boolean k = Keyboard.isKeyDown(Keyboard.KEY_K);
- boolean m = Keyboard.isKeyDown(Keyboard.KEY_M);
- boolean n = Keyboard.isKeyDown(Keyboard.KEY_N);
-
- event.toolTip.add(EnumChatFormatting.AQUA+"Internal Name: "+EnumChatFormatting.GRAY+internal+EnumChatFormatting.GOLD+" [K]");
- if(!copied && k) {
- MiscUtils.copyToClipboard(internal);
- }
-
- if(event.itemStack.getTagCompound() != null) {
- NBTTagCompound tag = event.itemStack.getTagCompound();
-
- if (tag.hasKey("SkullOwner", 10)) {
- GameProfile gameprofile = NBTUtil.readGameProfileFromNBT(tag.getCompoundTag("SkullOwner"));
-
- if(gameprofile != null) {
- event.toolTip.add(EnumChatFormatting.AQUA+"Skull UUID: "+EnumChatFormatting.GRAY+gameprofile.getId()+EnumChatFormatting.GOLD+" [M]");
- if(!copied && m) {
- MiscUtils.copyToClipboard(gameprofile.getId().toString());
- }
-
- Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map = Minecraft.getMinecraft().getSkinManager().loadSkinFromCache(gameprofile);
-
- if (map.containsKey(MinecraftProfileTexture.Type.SKIN)) {
- MinecraftProfileTexture profTex = map.get(MinecraftProfileTexture.Type.SKIN);
- event.toolTip.add(EnumChatFormatting.AQUA+"Skull Texture Link: "+EnumChatFormatting.GRAY+profTex.getUrl()+EnumChatFormatting.GOLD+" [N]");
-
- if(!copied && n) {
- MiscUtils.copyToClipboard(profTex.getUrl());
- }
- }
- }
- }
- }
-
- if(k || m || n) {
- copied = true;
- } else {
- copied = false;
- }
- }
- }
-
- @SubscribeEvent
- public void onRenderLast(RenderWorldLastEvent event){
- CrystalMetalDetectorSolver.render(event.partialTicks);
- }
+ private IChatComponent processChatComponent(IChatComponent chatComponent) {
+ IChatComponent newComponent;
+ if (chatComponent instanceof ChatComponentText) {
+ ChatComponentText text = (ChatComponentText) chatComponent;
+
+ newComponent = new ChatComponentText(processText(text.getUnformattedTextForChat()));
+ newComponent.setChatStyle(text.getChatStyle().createShallowCopy());
+
+ for (IChatComponent sibling : text.getSiblings()) {
+ newComponent.appendSibling(processChatComponent(sibling));
+ }
+ } else if (chatComponent instanceof ChatComponentTranslation) {
+ ChatComponentTranslation trans = (ChatComponentTranslation) chatComponent;
+
+ Object[] args = trans.getFormatArgs();
+ Object[] newArgs = new Object[args.length];
+ for (int i = 0; i < trans.getFormatArgs().length; i++) {
+ if (args[i] instanceof IChatComponent) {
+ newArgs[i] = processChatComponent((IChatComponent) args[i]);
+ } else {
+ newArgs[i] = args[i];
+ }
+ }
+ newComponent = new ChatComponentTranslation(trans.getKey(), newArgs);
+
+ for (IChatComponent sibling : trans.getSiblings()) {
+ newComponent.appendSibling(processChatComponent(sibling));
+ }
+ } else {
+ newComponent = chatComponent.createCopy();
+ }
+
+ return newComponent;
+ }
+
+ private String processText(String text) {
+ if (SBInfo.getInstance().getLocation() == null) return text;
+ if (!SBInfo.getInstance().getLocation().startsWith("mining_") &&
+ !SBInfo.getInstance().getLocation().equals("crystal_hollows"))
+ return text;
+
+ if (Minecraft.getMinecraft().thePlayer == null) return text;
+ if (!NotEnoughUpdates.INSTANCE.config.mining.drillFuelBar) return text;
+
+ return Utils.trimIgnoreColour(text.replaceAll(EnumChatFormatting.DARK_GREEN + "\\S+ Drill Fuel", ""));
+ }
+
+ private IChatComponent replaceSocialControlsWithPV(IChatComponent chatComponent) {
+
+ if (NotEnoughUpdates.INSTANCE.config.misc.replaceSocialOptions1 > 0 && chatComponent.getChatStyle() != null &&
+ chatComponent.getChatStyle().getChatClickEvent() != null &&
+ chatComponent.getChatStyle().getChatClickEvent().getAction() == ClickEvent.Action.RUN_COMMAND &&
+ NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
+ if (chatComponent.getChatStyle().getChatClickEvent().getValue().startsWith("/socialoptions")) {
+ String username = chatComponent.getChatStyle().getChatClickEvent().getValue().substring(15);
+ if (NotEnoughUpdates.INSTANCE.config.misc.replaceSocialOptions1 == 1) {
+ chatComponent.setChatStyle(Utils.createClickStyle(
+ ClickEvent.Action.RUN_COMMAND,
+ "/pv " + username,
+ "" + EnumChatFormatting.YELLOW + "Click to open " + EnumChatFormatting.AQUA + EnumChatFormatting.BOLD +
+ username + EnumChatFormatting.RESET + EnumChatFormatting.YELLOW + "'s profile in " +
+ EnumChatFormatting.DARK_PURPLE + EnumChatFormatting.BOLD + "NEU's" + EnumChatFormatting.RESET +
+ EnumChatFormatting.YELLOW + " profile viewer."
+ ));
+ return chatComponent;
+ } else if (NotEnoughUpdates.INSTANCE.config.misc.replaceSocialOptions1 == 2) {
+ chatComponent.setChatStyle(Utils.createClickStyle(
+ ClickEvent.Action.RUN_COMMAND,
+ "/ah " + username,
+ "" + EnumChatFormatting.YELLOW + "Click to open " + EnumChatFormatting.AQUA + EnumChatFormatting.BOLD +
+ username + EnumChatFormatting.RESET + EnumChatFormatting.YELLOW + "'s /ah page"
+ ));
+ return chatComponent;
+ }
+ } // wanted to add this for guild but guild uses uuid :sad:
+ }
+ return chatComponent;
+ }
+
+ /**
+ * 1) When receiving "You are playing on profile" messages, will set the current profile.
+ * 2) When a /viewrecipe command fails (i.e. player does not have recipe unlocked, will open the custom recipe GUI)
+ * 3) Replaces lobby join notifications when streamer mode is active
+ */
+ @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true)
+ public void onGuiChat(ClientChatReceivedEvent e) {
+ if (e.type == 2) {
+ CrystalMetalDetectorSolver.process(e.message);
+ e.message = processChatComponent(e.message);
+ return;
+ } else if (e.type == 0) {
+ e.message = replaceSocialControlsWithPV(e.message);
+ }
+
+ DungeonWin.onChatMessage(e);
+
+ String r = null;
+ String unformatted = Utils.cleanColour(e.message.getUnformattedText());
+ Matcher matcher = SLAYER_XP.matcher(unformatted);
+ if (unformatted.startsWith("You are playing on profile: ")) {
+ neu.manager.setCurrentProfile(unformatted
+ .substring("You are playing on profile: ".length())
+ .split(" ")[0].trim());
+ } else if (unformatted.startsWith("Your profile was changed to: ")) {//Your profile was changed to:
+ neu.manager.setCurrentProfile(unformatted
+ .substring("Your profile was changed to: ".length())
+ .split(" ")[0].trim());
+ } else if (unformatted.startsWith("Your new API key is ")) {
+ NotEnoughUpdates.INSTANCE.config.apiKey.apiKey = unformatted.substring("Your new API key is ".length());
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW +
+ "[NEU] API Key automatically configured"));
+ NotEnoughUpdates.INSTANCE.config.apiKey.apiKey = NotEnoughUpdates.INSTANCE.config.apiKey.apiKey.substring(0, 36);
+ } else if (unformatted.startsWith("Player List Info is now disabled!")) {
+ SBInfo.getInstance().hasNewTab = false;
+ } else if (unformatted.startsWith("Player List Info is now enabled!")) {
+ SBInfo.getInstance().hasNewTab = true;
+ }
+ if (e.message.getFormattedText().equals(EnumChatFormatting.RESET.toString() +
+ EnumChatFormatting.RED + "You haven't unlocked this recipe!" + EnumChatFormatting.RESET)) {
+ r = EnumChatFormatting.RED + "You haven't unlocked this recipe!";
+ } else if (e.message.getFormattedText().startsWith(EnumChatFormatting.RESET.toString() +
+ EnumChatFormatting.RED + "Invalid recipe ")) {
+ r = "";
+ } else if (unformatted.equals(" NICE! SLAYER BOSS SLAIN!")) {
+ SlayerOverlay.isSlain = true;
+ } else if (unformatted.equals(" SLAYER QUEST STARTED!")) {
+ SlayerOverlay.isSlain = false;
+ if (timeSinceLastBoss == 0) {
+ SlayerOverlay.timeSinceLastBoss = System.currentTimeMillis();
+ } else {
+ timeSinceLastBoss2 = timeSinceLastBoss;
+ timeSinceLastBoss = System.currentTimeMillis();
+ }
+ } else if (unformatted.startsWith(" RNGesus Meter:")) {
+ RNGMeter = unformatted.substring(" RNGesus Meter: -------------------- ".length());
+ } else if (matcher.matches()) {
+ //matcher.group(1);
+ SlayerOverlay.slayerLVL = matcher.group(2);
+ if (!SlayerOverlay.slayerLVL.equals("9")) {
+ SlayerOverlay.slayerXp = matcher.group(3);
+ } else {
+ slayerXp = "maxed";
+ }
+ } else if (unformatted.startsWith("Sending to server") ||
+ (unformatted.startsWith("Your Slayer Quest has been cancelled!"))) {
+ SlayerOverlay.slayerQuest = false;
+ SlayerOverlay.unloadOverlayTimer = System.currentTimeMillis();
+ }
+ if (e.message
+ .getFormattedText()
+ .contains(EnumChatFormatting.YELLOW + "Visit the Auction House to collect your item!")) {
+ if (NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.latestBid != null &&
+ System.currentTimeMillis() - NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.latestBidMillis < 5000) {
+ NotEnoughUpdates.INSTANCE.sendChatMessage("/viewauction " +
+ NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.niceAucId(
+ NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.latestBid));
+ }
+ }
+ if (r != null) {
+ if (neu.manager.failViewItem(r)) {
+ e.setCanceled(true);
+ }
+ missingRecipe.set(true);
+ }
+ //System.out.println(e.message);
+ if (unformatted.startsWith("Sending to server") &&
+ neu.isOnSkyblock() && NotEnoughUpdates.INSTANCE.config.misc.streamerMode &&
+ e.message instanceof ChatComponentText) {
+ String m = e.message.getFormattedText();
+ String m2 = StreamerMode.filterChat(e.message.getFormattedText());
+ if (!m.equals(m2)) {
+ e.message = new ChatComponentText(m2);
+ }
+ }
+ if (unformatted.startsWith("You found ") && SBInfo.getInstance().getLocation() != null &&
+ SBInfo.getInstance().getLocation().equals("crystal_hollows")) {
+ CrystalMetalDetectorSolver.reset(true);
+ }
+ if (unformatted.startsWith("[NPC] Keeper of ") | unformatted.startsWith("[NPC] Professor Robot: ") ||
+ unformatted.startsWith(" ") || unformatted.startsWith("✦") ||
+ unformatted.equals(" You've earned a Crystal Loot Bundle!"))
+ OverlayManager.crystalHollowOverlay.message(unformatted);
+ }
+
+ public static boolean drawingGuiScreen = false;
+
+ /**
+ * Sets hoverInv and focusInv variables, representing whether the NEUOverlay should render behind the inventory when
+ * (hoverInv == true) and whether mouse/kbd inputs shouldn't be sent to NEUOverlay (focusInv == true).
+ * <p>
+ * If hoverInv is true, will render the overlay immediately (resulting in the inventory being drawn over the GUI)
+ * If hoverInv is false, the overlay will render in #onGuiScreenDraw (resulting in the GUI being drawn over the inv)
+ * <p>
+ * All of this only matters if players are using gui scale auto which may result in the inventory being drawn
+ * over the various panes.
+ */
+ @SubscribeEvent
+ public void onGuiBackgroundDraw(GuiScreenEvent.BackgroundDrawnEvent event) {
+ if (showNotificationOverInv) {
+
+ renderNotification();
+
+ }
+ if ((shouldRenderOverlay(event.gui) || event.gui instanceof CustomAHGui) && neu.isOnSkyblock()) {
+ ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
+ int width = scaledresolution.getScaledWidth();
+
+ boolean hoverPane = event.getMouseX() < width * neu.overlay.getInfoPaneOffsetFactor() ||
+ event.getMouseX() > width * neu.overlay.getItemPaneOffsetFactor();
+
+ if (event.gui instanceof GuiContainer) {
+ try {
+ 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;
+
+ if (hoverPane) {
+ if (!hoverInv) focusInv = false;
+ } else {
+ focusInv = true;
+ }
+ } catch (NullPointerException npe) {
+ focusInv = !hoverPane;
+ }
+ }
+ if (event.gui instanceof GuiItemRecipe) {
+ GuiItemRecipe guiItemRecipe = ((GuiItemRecipe) event.gui);
+ hoverInv = event.getMouseX() > guiItemRecipe.guiLeft &&
+ event.getMouseX() < guiItemRecipe.guiLeft + guiItemRecipe.xSize &&
+ event.getMouseY() > guiItemRecipe.guiTop && event.getMouseY() < guiItemRecipe.guiTop + guiItemRecipe.ySize;
+
+ if (hoverPane) {
+ if (!hoverInv) focusInv = false;
+ } else {
+ focusInv = true;
+ }
+ }
+ if (focusInv) {
+ try {
+ neu.overlay.render(hoverInv);
+ } catch (ConcurrentModificationException e) {
+ e.printStackTrace();
+ }
+ GL11.glTranslatef(0, 0, 10);
+ }
+ if (hoverInv) {
+ renderDungeonChestOverlay(event.gui);
+ if (NotEnoughUpdates.INSTANCE.config.accessoryBag.enableOverlay) {
+ AccessoryBagOverlay.renderOverlay();
+ }
+ }
+ }
+
+ drawingGuiScreen = true;
+ }
+
+ private boolean doInventoryButtons = false;
+
+ @SubscribeEvent
+ public void onGuiScreenDrawPre(GuiScreenEvent.DrawScreenEvent.Pre event) {
+ doInventoryButtons = false;
+
+ if (AuctionSearchOverlay.shouldReplace()) {
+ AuctionSearchOverlay.render();
+ event.setCanceled(true);
+ return;
+ }
+ if (RancherBootOverlay.shouldReplace()) {
+ RancherBootOverlay.render();
+ event.setCanceled(true);
+ return;
+ }
+
+ 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();
+ }
+
+ if (GuiCustomEnchant.getInstance().shouldOverride(containerName)) {
+ GuiCustomEnchant.getInstance().render(event.renderPartialTicks);
+ event.setCanceled(true);
+ return;
+ }
+
+ 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());
+ int width = scaledResolution.getScaledWidth();
+ int height = scaledResolution.getScaledHeight();
+
+ //Dark background
+ 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 (customAhActive) {
+ neu.manager.auctionManager.customAH.drawScreen(event.mouseX, event.mouseY);
+ } else if (tradeWindowActive) {
+ TradeWindow.render(event.mouseX, event.mouseY);
+ }
+ neu.overlay.render(false);
+ } else {
+ neu.overlay.render(false);
+ if (customAhActive) {
+ neu.manager.auctionManager.customAH.drawScreen(event.mouseX, event.mouseY);
+ } else if (tradeWindowActive) {
+ TradeWindow.render(event.mouseX, event.mouseY);
+ }
+ }
+ }
+
+ if (CalendarOverlay.isEnabled() || event.isCanceled()) return;
+ if (NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && shouldRenderOverlay(event.gui)
+ && event.gui instanceof GuiContainer) {
+ doInventoryButtons = true;
+
+ int zOffset = 50;
+
+ GlStateManager.translate(0, 0, zOffset);
+
+ int xSize = ((GuiContainer) event.gui).xSize;
+ int ySize = ((GuiContainer) event.gui).ySize;
+ int guiLeft = ((GuiContainer) event.gui).guiLeft;
+ int guiTop = ((GuiContainer) event.gui).guiTop;
+
+ if (!NEUApi.disableInventoryButtons) {
+ 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 (NEUOverlay.isRenderingArmorHud()) {
+ if (x < guiLeft + xSize - 150 && x > guiLeft + xSize - 200 && y > guiTop && y < guiTop + 84) {
+ x -= 25;
+ }
+ }
+ if (NEUOverlay.isRenderingPetHud()) {
+ if (x < guiLeft + xSize - 150 && x > guiLeft + xSize - 200 && y > guiTop + 60 && y < guiTop + 120) {
+ x -= 25;
+ }
+ }
+
+ 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
+ );
+
+ if (button.icon != null && !button.icon.trim().isEmpty()) {
+ GuiInvButtonEditor.renderIcon(button.icon, x + 1, y + 1);
+ }
+ }
+ }
+ GlStateManager.translate(0, 0, -zOffset);
+ }
+ }
+
+ private static boolean shouldRenderOverlay(Gui gui) {
+ boolean validGui = gui instanceof GuiContainer || gui instanceof GuiItemRecipe;
+ if (gui instanceof GuiChest) {
+ GuiChest eventGui = (GuiChest) gui;
+ ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
+ String containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText();
+ if (containerName.trim().equals("Fast Travel")) {
+ validGui = false;
+ }
+ }
+ return validGui;
+ }
+
+ private static final ResourceLocation EDITOR = new ResourceLocation("notenoughupdates:invbuttons/editor.png");
+ private NEUConfig.InventoryButton buttonHovered = null;
+ private long buttonHoveredMillis = 0;
+ public static boolean disableCraftingText = false;
+
+ /**
+ * Will draw the NEUOverlay over the inventory if focusInv == false. (z-translation of 300 is so that NEUOverlay
+ * will draw over Items in the inventory (which render at a z value of about 250))
+ */
+ @SubscribeEvent
+ public void onGuiScreenDrawPost(GuiScreenEvent.DrawScreenEvent.Post event) {
+ drawingGuiScreen = false;
+ disableCraftingText = false;
+
+ 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();
+
+ if (GuiCustomEnchant.getInstance().shouldOverride(containerName))
+ return;
+ }
+
+ 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) {
+ GL11.glTranslatef(0, 0, 300);
+ neu.overlay.render(hoverInv && focusInv);
+ GL11.glTranslatef(0, 0, -300);
+ }
+ GlStateManager.popMatrix();
+ }
+ }
+
+ if (shouldRenderOverlay(event.gui) && neu.isOnSkyblock() && !hoverInv) {
+ renderDungeonChestOverlay(event.gui);
+ if (NotEnoughUpdates.INSTANCE.config.accessoryBag.enableOverlay) {
+ AccessoryBagOverlay.renderOverlay();
+ }
+ }
+
+ boolean hoveringButton = false;
+ if (!doInventoryButtons) return;
+ if (NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && shouldRenderOverlay(event.gui) &&
+ event.gui instanceof GuiContainer) {
+ int xSize = ((GuiContainer) event.gui).xSize;
+ int ySize = ((GuiContainer) event.gui).ySize;
+ int guiLeft = ((GuiContainer) event.gui).guiLeft;
+ int guiTop = ((GuiContainer) event.gui).guiTop;
+
+ if (!NEUApi.disableInventoryButtons) {
+ 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 (NEUOverlay.isRenderingArmorHud()) {
+ if (x < guiLeft + xSize - 150 && x > guiLeft + xSize - 200 && y > guiTop && y < guiTop + 84) {
+ x -= 25;
+ }
+ }
+ if (NEUOverlay.isRenderingPetHud()) {
+ if (x < guiLeft + xSize - 150 && x > guiLeft + xSize - 200 && y > guiTop + 60 && y < guiTop + 120) {
+ x -= 25;
+ }
+ }
+
+ if (x - guiLeft >= 85 && x - guiLeft <= 115 && y - guiTop >= 4 && y - guiTop <= 25) {
+ disableCraftingText = true;
+ }
+
+ 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 (currentTime - buttonHoveredMillis > 600) {
+ 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, Minecraft.getMinecraft().fontRendererObj
+ );
+ }
+ }
+ }
+ }
+ }
+ if (!hoveringButton) buttonHovered = null;
+
+ if (AuctionBINWarning.getInstance().shouldShow()) {
+ AuctionBINWarning.getInstance().render();
+ }
+ }
+
+ private void renderDungeonChestOverlay(GuiScreen gui) {
+ if (NotEnoughUpdates.INSTANCE.config.dungeons.profitDisplayLoc == 3) return;
+
+ if (gui instanceof GuiChest && NotEnoughUpdates.INSTANCE.config.dungeons.profitDisplayLoc != 2) {
+ try {
+ 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;
+ IInventory lower = cc.getLowerChestInventory();
+
+ ItemStack rewardChest = lower.getStackInSlot(31);
+ if (rewardChest != null &&
+ rewardChest.getDisplayName().endsWith(EnumChatFormatting.GREEN + "Open Reward Chest")) {
+ int chestCost = 0;
+ try {
+ String line6 = Utils.cleanColour(neu.manager.getLoreFromNBT(rewardChest.getTagCompound())[6]);
+ StringBuilder cost = new StringBuilder();
+ for (int i = 0; i < line6.length(); i++) {
+ char c = line6.charAt(i);
+ if ("0123456789".indexOf(c) >= 0) {
+ cost.append(c);
+ }
+ }
+ if (cost.length() > 0) {
+ chestCost = Integer.parseInt(cost.toString());
+ }
+ } catch (Exception ignored) {
+ }
+
+ String missingItem = null;
+ int totalValue = 0;
+ HashMap<String, Float> itemValues = new HashMap<>();
+ for (int i = 0; i < 5; i++) {
+ ItemStack item = lower.getStackInSlot(11 + i);
+ String internal = neu.manager.getInternalNameForItem(item);
+ if (internal != null) {
+ internal = internal.replace("\u00CD", "I").replace("\u0130", "I");
+ float bazaarPrice = -1;
+ JsonObject bazaarInfo = neu.manager.auctionManager.getBazaarInfo(internal);
+ if (bazaarInfo != null && bazaarInfo.has("curr_sell")) {
+ bazaarPrice = bazaarInfo.get("curr_sell").getAsFloat();
+ }
+ if (bazaarPrice < 5000000 && internal.equals("RECOMBOBULATOR_3000")) bazaarPrice = 5000000;
+
+ float worth = -1;
+ if (bazaarPrice > 0) {
+ worth = bazaarPrice;
+ } else {
+ switch (NotEnoughUpdates.INSTANCE.config.dungeons.profitType) {
+ case 1:
+ worth = neu.manager.auctionManager.getItemAvgBin(internal);
+ break;
+ case 2:
+ JsonObject auctionInfo = neu.manager.auctionManager.getItemAuctionInfo(internal);
+ if (auctionInfo != null) {
+ if (auctionInfo.has("clean_price")) {
+ worth = (int) auctionInfo.get("clean_price").getAsFloat();
+ } else {
+ worth = (int) (auctionInfo.get("price").getAsFloat() / auctionInfo.get("count").getAsFloat());
+ }
+ }
+ break;
+ default:
+ worth = neu.manager.auctionManager.getLowestBin(internal);
+ }
+ if (worth <= 0) {
+ worth = neu.manager.auctionManager.getLowestBin(internal);
+ if (worth <= 0) {
+ worth = neu.manager.auctionManager.getItemAvgBin(internal);
+ if (worth <= 0) {
+ JsonObject auctionInfo = neu.manager.auctionManager.getItemAuctionInfo(internal);
+ if (auctionInfo != null) {
+ if (auctionInfo.has("clean_price")) {
+ worth = (int) auctionInfo.get("clean_price").getAsFloat();
+ } else {
+ worth = (int) (auctionInfo.get("price").getAsFloat() / auctionInfo.get("count").getAsFloat());
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (worth > 0 && totalValue >= 0) {
+ totalValue += worth;
+ String display = item.getDisplayName();
+
+ if (display.contains("Enchanted Book")) {
+ NBTTagCompound tag = item.getTagCompound();
+ if (tag != null && tag.hasKey("ExtraAttributes", 10)) {
+ NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
+ NBTTagCompound enchants = ea.getCompoundTag("enchantments");
+
+ int highestLevel = -1;
+ for (String enchname : enchants.getKeySet()) {
+ int level = enchants.getInteger(enchname);
+ if (level > highestLevel) {
+ display = EnumChatFormatting.BLUE + WordUtils.capitalizeFully(
+ enchname.replace("_", " ")
+ .replace("Ultimate", "")
+ .trim()) + " " + level;
+ }
+ }
+ }
+ }
+
+ itemValues.put(display, worth);
+ } else {
+ if (totalValue != -1) {
+ missingItem = internal;
+ }
+ totalValue = -1;
+ }
+ }
+ }
+
+ NumberFormat format = NumberFormat.getInstance(Locale.US);
+ String valueStringBIN1;
+ String valueStringBIN2;
+ if (totalValue >= 0) {
+ valueStringBIN1 = EnumChatFormatting.YELLOW + "Value (BIN): ";
+ valueStringBIN2 = EnumChatFormatting.GOLD + format.format(totalValue) + " coins";
+ } else {
+ valueStringBIN1 = EnumChatFormatting.YELLOW + "Can't find BIN: ";
+ valueStringBIN2 = missingItem;
+ }
+
+ int profitLossBIN = totalValue - chestCost;
+
+ boolean kismetUsed = false;
+ // checking for kismet
+ Slot slot = (eventGui.inventorySlots.getSlot(50));
+ if (slot.getHasStack()) {
+ String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(slot.getStack().getTagCompound());
+ for (String line : lore) {
+ if (line.contains("You already rerolled a chest!")) {
+ kismetUsed = true;
+ break;
+ }
+ }
+ }
+ int kismetPrice = neu.manager.auctionManager.getLowestBin("KISMET_FEATHER");
+ String kismetStr = EnumChatFormatting.RED + format.format(kismetPrice) + " coins";
+ if (neu.config.dungeons.useKismetOnDungeonProfit)
+ profitLossBIN = kismetUsed ? profitLossBIN - kismetPrice : profitLossBIN;
+
+ String profitPrefix = EnumChatFormatting.DARK_GREEN.toString();
+ String lossPrefix = EnumChatFormatting.RED.toString();
+ String prefix = profitLossBIN >= 0 ? profitPrefix : lossPrefix;
+
+ String plStringBIN;
+ if (profitLossBIN >= 0) {
+ plStringBIN = prefix + "+" + format.format(profitLossBIN) + " coins";
+ } else {
+ plStringBIN = prefix + "-" + format.format(-profitLossBIN) + " coins";
+ }
+
+ if (NotEnoughUpdates.INSTANCE.config.dungeons.profitDisplayLoc == 1 && !valueStringBIN2.equals(missingItem)) {
+ int w = Minecraft.getMinecraft().fontRendererObj.getStringWidth(plStringBIN);
+ GlStateManager.disableLighting();
+ GlStateManager.translate(0, 0, 200);
+ Minecraft.getMinecraft().fontRendererObj.drawString(plStringBIN, guiLeft + xSize - 5 - w, guiTop + 5,
+ 0xffffffff, true
+ );
+ GlStateManager.translate(0, 0, -200);
+ return;
+ }
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(dungeon_chest_worth);
+ GL11.glColor4f(1, 1, 1, 1);
+ GlStateManager.disableLighting();
+ Utils.drawTexturedRect(guiLeft + xSize + 4, guiTop, 180, 101, 0, 180 / 256f, 0, 101 / 256f, GL11.GL_NEAREST);
+
+ Utils.renderAlignedString(valueStringBIN1, valueStringBIN2,
+ guiLeft + xSize + 4 + 10, guiTop + 14, 160
+ );
+ if (neu.config.dungeons.useKismetOnDungeonProfit && kismetUsed) {
+ Utils.renderAlignedString(EnumChatFormatting.YELLOW + "Kismet Feather: ", kismetStr,
+ guiLeft + xSize + 4 + 10, guiTop + 24, 160
+ );
+ }
+ if (totalValue >= 0) {
+ Utils.renderAlignedString(
+ EnumChatFormatting.YELLOW + "Profit/Loss: ",
+ plStringBIN,
+ guiLeft + xSize + 4 + 10,
+ guiTop + (neu.config.dungeons.useKismetOnDungeonProfit ? (kismetUsed ? 34 : 24) : 24),
+ 160
+ );
+ }
+
+ int index = 0;
+ for (Map.Entry<String, Float> entry : itemValues.entrySet()) {
+ Utils.renderAlignedString(
+ entry.getKey(),
+ prefix +
+ format.format(entry.getValue().intValue()),
+ guiLeft + xSize + 4 + 10,
+ guiTop + (neu.config.dungeons.useKismetOnDungeonProfit ? (kismetUsed ? 39 : 29) : 29) + (++index) * 10,
+ 160
+ );
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public void drawStringShadow(String str, float x, float y, int len) {
+ for (int xOff = -2; xOff <= 2; xOff++) {
+ for (int yOff = -2; yOff <= 2; yOff++) {
+ if (Math.abs(xOff) != Math.abs(yOff)) {
+ Utils.drawStringCenteredScaledMaxWidth(Utils.cleanColourNotModifiers(str),
+ Minecraft.getMinecraft().fontRendererObj,
+ x + xOff / 2f, y + yOff / 2f, false, len,
+ new Color(20, 20, 20, 100 / Math.max(Math.abs(xOff), Math.abs(yOff))).getRGB()
+ );
+ }
+ }
+ }
+
+ Utils.drawStringCenteredScaledMaxWidth(str,
+ Minecraft.getMinecraft().fontRendererObj,
+ x, y, false, len,
+ new Color(64, 64, 64, 255).getRGB()
+ );
+ }
+
+ /**
+ * Sends a mouse event to NEUOverlay if the inventory isn't hovered AND focused.
+ * Will also cancel the event if if NEUOverlay#mouseInput returns true.
+ */
+ @SubscribeEvent(priority = EventPriority.LOW)
+ public void onGuiScreenMouse(GuiScreenEvent.MouseInputEvent.Pre event) {
+ if (Mouse.getEventButtonState() && StorageManager.getInstance().onAnyClick()) {
+ event.setCanceled(true);
+ return;
+ }
+
+ 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;
+
+ if (AuctionBINWarning.getInstance().shouldShow()) {
+ AuctionBINWarning.getInstance().mouseInput(mouseX, mouseY);
+ event.setCanceled(true);
+ return;
+ }
+
+ if (!event.isCanceled()) {
+ Utils.scrollTooltip(Mouse.getEventDWheel());
+ }
+ if (AuctionSearchOverlay.shouldReplace()) {
+ AuctionSearchOverlay.mouseEvent();
+ event.setCanceled(true);
+ return;
+ }
+ if (RancherBootOverlay.shouldReplace()) {
+ RancherBootOverlay.mouseEvent();
+ event.setCanceled(true);
+ return;
+ }
+
+ 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();
+ if (containerName.contains(" Profile") && BetterContainers.profileViewerStackIndex != -1 &&
+ eventGui.isMouseOverSlot(cc.inventorySlots.get(BetterContainers.profileViewerStackIndex), mouseX, mouseY) &&
+ Mouse.getEventButton() >= 0) {
+ event.setCanceled(true);
+ if (Mouse.getEventButtonState() && eventGui.inventorySlots.inventorySlots.get(22).getStack() != null &&
+ eventGui.inventorySlots.inventorySlots.get(22).getStack().getTagCompound() != null) {
+ NBTTagCompound tag = eventGui.inventorySlots.inventorySlots.get(22).getStack().getTagCompound();
+ if (tag.hasKey("SkullOwner") && tag.getCompoundTag("SkullOwner").hasKey("Name")) {
+ String username = tag.getCompoundTag("SkullOwner").getString("Name");
+ Utils.playPressSound();
+ ViewProfileCommand.RUNNABLE.accept(new String[]{username});
+ }
+ }
+ }
+ }
+
+ if (GuiCustomEnchant.getInstance().shouldOverride(containerName) &&
+ GuiCustomEnchant.getInstance().mouseInput(mouseX, mouseY)) {
+ event.setCanceled(true);
+ return;
+ }
+
+ 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 (customAhActive) {
+ neu.manager.auctionManager.customAH.handleMouseInput();
+ } else if (tradeWindowActive) {
+ TradeWindow.handleMouseInput();
+ }
+ neu.overlay.mouseInput();
+ return;
+ }
+
+ if (shouldRenderOverlay(event.gui) && neu.isOnSkyblock()) {
+ if (!NotEnoughUpdates.INSTANCE.config.accessoryBag.enableOverlay || !AccessoryBagOverlay.mouseClick()) {
+ if (!(hoverInv && focusInv)) {
+ if (neu.overlay.mouseInput()) {
+ event.setCanceled(true);
+ }
+ } else {
+ neu.overlay.mouseInputInv();
+ }
+ }
+ }
+ if (event.isCanceled()) return;
+ if (!doInventoryButtons) return;
+ if (NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && shouldRenderOverlay(event.gui) &&
+ Mouse.getEventButton() >= 0
+ && event.gui instanceof GuiContainer) {
+ int xSize = ((GuiContainer) event.gui).xSize;
+ int ySize = ((GuiContainer) event.gui).ySize;
+ int guiLeft = ((GuiContainer) event.gui).guiLeft;
+ int guiTop = ((GuiContainer) event.gui).guiTop;
+ if (!NEUApi.disableInventoryButtons) {
+ 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 (NEUOverlay.isRenderingArmorHud()) {
+ if (x < guiLeft + xSize - 150 && x > guiLeft + xSize - 200 && y > guiTop && y < guiTop + 84) {
+ x -= 25;
+ }
+ }
+ if (NEUOverlay.isRenderingPetHud()) {
+ if (x < guiLeft + xSize - 150 && x > guiLeft + xSize - 200 && y > guiTop + 60 && y < guiTop + 120) {
+ x -= 25;
+ }
+ }
+
+ 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;
+ }
+ }
+ }
+ }
+ }
+
+ ScheduledExecutorService ses = Executors.newScheduledThreadPool(1);
+
+ JsonObject essenceJson = new JsonObject();
+
+ /**
+ * Sends a kbd event to NEUOverlay, cancelling if NEUOverlay#keyboardInput returns true.
+ * Also includes a dev function used for creating custom named json files with recipes.
+ */
+ @SubscribeEvent
+ public void onGuiScreenKeyboard(GuiScreenEvent.KeyboardInputEvent.Pre event) {
+ if (AuctionBINWarning.getInstance().shouldShow()) {
+ AuctionBINWarning.getInstance().keyboardInput();
+ event.setCanceled(true);
+ return;
+ }
+
+ if (AuctionSearchOverlay.shouldReplace()) {
+ AuctionSearchOverlay.keyEvent();
+ event.setCanceled(true);
+ return;
+ }
+ if (RancherBootOverlay.shouldReplace()) {
+ RancherBootOverlay.keyEvent();
+ event.setCanceled(true);
+ return;
+ }
+
+ String containerName = null;
+ GuiScreen guiScreen = Minecraft.getMinecraft().currentScreen;
+
+ if (guiScreen instanceof GuiChest) {
+ containerName = ((ContainerChest) ((GuiChest) guiScreen).inventorySlots)
+ .getLowerChestInventory()
+ .getDisplayName()
+ .getUnformattedText();
+ }
+
+ if (GuiCustomEnchant.getInstance().shouldOverride(containerName) &&
+ GuiCustomEnchant.getInstance().keyboardInput()) {
+ event.setCanceled(true);
+ return;
+ }
+
+ 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().keyboardInput()) {
+ event.setCanceled(true);
+ 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 if (tradeWindowActive) {
+ TradeWindow.keyboardInput();
+ if (Keyboard.getEventKey() != Keyboard.KEY_ESCAPE) {
+ event.setCanceled(true);
+ Minecraft.getMinecraft().dispatchKeypresses();
+ neu.overlay.keyboardInput(focusInv);
+ }
+ }
+ return;
+ }
+
+ if (shouldRenderOverlay(event.gui) && neu.isOnSkyblock()) {
+ if (neu.overlay.keyboardInput(focusInv)) {
+ event.setCanceled(true);
+ }
+ }
+ if (NotEnoughUpdates.INSTANCE.config.hidden.dev && NotEnoughUpdates.INSTANCE.config.hidden.enableItemEditing &&
+ Minecraft.getMinecraft().theWorld != null &&
+ Keyboard.getEventKey() == Keyboard.KEY_N && Keyboard.getEventKeyState()) {
+ GuiScreen gui = Minecraft.getMinecraft().currentScreen;
+ if (gui instanceof GuiChest) {
+ GuiChest eventGui = (GuiChest) event.gui;
+ ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
+ IInventory lower = cc.getLowerChestInventory();
+
+ if (!lower.getDisplayName().getUnformattedText().endsWith("Essence")) return;
+
+ for (int i = 0; i < lower.getSizeInventory(); i++) {
+ ItemStack stack = lower.getStackInSlot(i);
+
+ String internalname = neu.manager.getInternalNameForItem(stack);
+ if (internalname != null) {
+ String[] lore = neu.manager.getLoreFromNBT(stack.getTagCompound());
+
+ for (String line : lore) {
+ if (line.contains(":") && (line.startsWith("\u00A77Upgrade to") ||
+ line.startsWith("\u00A77Convert to Dungeon Item"))) {
+ String[] split = line.split(":");
+ String after = Utils.cleanColour(split[1]);
+ StringBuilder costS = new StringBuilder();
+ for (char c : after.toCharArray()) {
+ if (c >= '0' && c <= '9') {
+ costS.append(c);
+ }
+ }
+ int cost = Integer.parseInt(costS.toString());
+ String[] afterSplit = after.split(" ");
+ String type = afterSplit[afterSplit.length - 2];
+
+ if (!essenceJson.has(internalname)) {
+ essenceJson.add(internalname, new JsonObject());
+ }
+ JsonObject obj = essenceJson.get(internalname).getAsJsonObject();
+ obj.addProperty("type", type);
+
+ if (line.startsWith("\u00A77Convert to Dungeon Item")) {
+ obj.addProperty("dungeonize", cost);
+ } else if (line.startsWith("\u00A77Upgrade to")) {
+ int stars = 0;
+ for (char c : line.toCharArray()) {
+ if (c == '\u272A') stars++;
+ }
+ if (stars > 0) {
+ obj.addProperty(stars + "", cost);
+ }
+ }
+ }
+ }
+ }
+ }
+ System.out.println(essenceJson);
+ }
+ }
+ if (NotEnoughUpdates.INSTANCE.config.hidden.dev && NotEnoughUpdates.INSTANCE.config.hidden.enableItemEditing &&
+ Minecraft.getMinecraft().theWorld != null &&
+ Keyboard.getEventKey() == Keyboard.KEY_O && Keyboard.getEventKeyState()) {
+ GuiScreen gui = Minecraft.getMinecraft().currentScreen;
+ if (gui instanceof GuiChest) {
+ GuiChest eventGui = (GuiChest) event.gui;
+ ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
+ IInventory lower = cc.getLowerChestInventory();
+
+ if (lower.getStackInSlot(23) != null &&
+ lower.getStackInSlot(23).getDisplayName().endsWith("Crafting Table")) {
+ ItemStack res = lower.getStackInSlot(25);
+ String resInternalname = neu.manager.getInternalNameForItem(res);
+ JTextField tf = new JTextField();
+ tf.setText(resInternalname);
+ tf.addAncestorListener(new RequestFocusListener());
+ JOptionPane.showOptionDialog(null,
+ tf,
+ "Enter Name:",
+ JOptionPane.NO_OPTION,
+ JOptionPane.PLAIN_MESSAGE,
+ null, new String[]{"Enter"}, "Enter"
+ );
+ resInternalname = tf.getText();
+ if (resInternalname.trim().length() == 0) {
+ return;
+ }
+
+ JsonObject recipe = new JsonObject();
+
+ String[] x = {"1", "2", "3"};
+ String[] y = {"A", "B", "C"};
+
+ for (int i = 0; i <= 18; i += 9) {
+ for (int j = 0; j < 3; j++) {
+ ItemStack stack = lower.getStackInSlot(10 + i + j);
+ String internalname = "";
+ if (stack != null) {
+ internalname = neu.manager.getInternalNameForItem(stack);
+ if (!neu.manager.getItemInformation().containsKey(internalname)) {
+ neu.manager.writeItemToFile(stack);
+ }
+ internalname += ":" + stack.stackSize;
+ }
+ recipe.addProperty(y[i / 9] + x[j], internalname);
+ }
+ }
+
+ JsonObject json = neu.manager.getJsonForItem(res);
+ json.add("recipe", recipe);
+ json.addProperty("internalname", resInternalname);
+ json.addProperty("clickcommand", "viewrecipe");
+ json.addProperty("modver", NotEnoughUpdates.VERSION);
+ try {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Added: " + resInternalname));
+ neu.manager.writeJsonDefaultDir(json, resInternalname + ".json");
+ neu.manager.loadItem(resInternalname);
+ } catch (IOException ignored) {
+ }
+ }
+ }
+ }
+ }
+
+ private final HashSet<String> percentStats = new HashSet<>();
+
+ {
+ percentStats.add("bonus_attack_speed");
+ percentStats.add("crit_damage");
+ percentStats.add("crit_chance");
+ percentStats.add("sea_creature_chance");
+ percentStats.add("ability_damage");
+ }
+
+ private String currentRarity = "COMMON";
+ private boolean showReforgeStoneStats = true;
+ private boolean pressedArrowLast = false;
+ private boolean pressedShiftLast = false;
+
+ private boolean copied = false;
+
+ //just to try and optimize it a bit
+ private int sbaloaded = -1;
+
+ private boolean isSbaloaded() {
+ if (sbaloaded == -1) {
+ if (Loader.isModLoaded("skyblockaddons")) {
+ sbaloaded = 1;
+ } else {
+ sbaloaded = 0;
+ }
+ }
+ return sbaloaded == 1;
+ }
+
+ @SubscribeEvent(priority = EventPriority.LOW)
+ public void onItemTooltipLow(ItemTooltipEvent event) {
+ if (!NotEnoughUpdates.INSTANCE.isOnSkyblock()) return;
+
+ String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(event.itemStack);
+ if (internalname == null) {
+ onItemToolTipInternalNameNull(event);
+ return;
+ }
+
+ boolean hasEnchantments =
+ event.itemStack.getTagCompound().getCompoundTag("ExtraAttributes").hasKey("enchantments", 10);
+ Set<String> enchantIds = new HashSet<>();
+ if (hasEnchantments)
+ enchantIds =
+ event.itemStack.getTagCompound().getCompoundTag("ExtraAttributes").getCompoundTag("enchantments").getKeySet();
+
+ JsonObject enchantsConst = Constants.ENCHANTS;
+ JsonArray allItemEnchs = null;
+ Set<String> ignoreFromPool = new HashSet<>();
+ if (enchantsConst != null && hasEnchantments && NotEnoughUpdates.INSTANCE.config.tooltipTweaks.missingEnchantList) {
+ try {
+ JsonArray enchantPools = enchantsConst.get("enchant_pools").getAsJsonArray();
+ for (JsonElement element : enchantPools) {
+ Set<String> currentPool = new HashSet<>();
+ for (JsonElement poolElement : element.getAsJsonArray()) {
+ String poolS = poolElement.getAsString();
+ currentPool.add(poolS);
+ }
+ for (JsonElement poolElement : element.getAsJsonArray()) {
+ String poolS = poolElement.getAsString();
+ if (enchantIds.contains(poolS)) {
+ ignoreFromPool.addAll(currentPool);
+ break;
+ }
+ }
+ }
+
+ JsonObject enchantsObj = enchantsConst.get("enchants").getAsJsonObject();
+ NBTTagCompound tag = event.itemStack.getTagCompound();
+ if (tag != null) {
+ NBTTagCompound display = tag.getCompoundTag("display");
+ if (display.hasKey("Lore", 9)) {
+ NBTTagList list = display.getTagList("Lore", 8);
+ out:
+ for (int i = list.tagCount(); i >= 0; i--) {
+ String line = list.getStringTagAt(i);
+ for (int j = 0; j < Utils.rarityArrC.length; j++) {
+ for (Map.Entry<String, JsonElement> entry : enchantsObj.entrySet()) {
+ if (line.contains(Utils.rarityArrC[j] + " " + entry.getKey()) ||
+ line.contains(Utils.rarityArrC[j] + " DUNGEON " + entry.getKey())) {
+ allItemEnchs = entry.getValue().getAsJsonArray();
+ break out;
+ }
+ }
+ }
+ }
+ }
+ }
+ } catch (Exception ignored) {
+ }
+ }
+
+ boolean gotToEnchants = false;
+ boolean passedEnchants = false;
+
+ boolean dungeonProfit = false;
+ int index = 0;
+ List<String> newTooltip = new ArrayList<>();
+
+ for (String line : event.toolTip) {
+ if (line.endsWith(EnumChatFormatting.DARK_GRAY + "Reforge Stone") &&
+ NotEnoughUpdates.INSTANCE.config.tooltipTweaks.showReforgeStats) {
+ JsonObject reforgeStones = Constants.REFORGESTONES;
+
+ if (reforgeStones != null && reforgeStones.has(internalname)) {
+ boolean shift = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
+ if (!pressedShiftLast && shift) {
+ showReforgeStoneStats = !showReforgeStoneStats;
+ }
+ pressedShiftLast = shift;
+
+ newTooltip.add(line);
+ newTooltip.add("");
+ if (!showReforgeStoneStats) {
+ newTooltip.add(EnumChatFormatting.DARK_GRAY + "[Press SHIFT to show extra info]");
+ } else {
+ newTooltip.add(EnumChatFormatting.DARK_GRAY + "[Press SHIFT to hide extra info]");
+ }
+
+ JsonObject reforgeInfo = reforgeStones.get(internalname).getAsJsonObject();
+ JsonArray requiredRaritiesArray = reforgeInfo.get("requiredRarities").getAsJsonArray();
+
+ if (showReforgeStoneStats && requiredRaritiesArray.size() > 0) {
+ String reforgeName = Utils.getElementAsString(reforgeInfo.get("reforgeName"), "");
+
+ String[] requiredRarities = new String[requiredRaritiesArray.size()];
+ for (int i = 0; i < requiredRaritiesArray.size(); i++) {
+ requiredRarities[i] = requiredRaritiesArray.get(i).getAsString();
+ }
+
+ int rarityIndex = requiredRarities.length - 1;
+ String rarity = requiredRarities[rarityIndex];
+ for (int i = 0; i < requiredRarities.length; i++) {
+ String rar = requiredRarities[i];
+ if (rar.equalsIgnoreCase(currentRarity)) {
+ rarity = rar;
+ rarityIndex = i;
+ break;
+ }
+ }
+
+ boolean left = Keyboard.isKeyDown(Keyboard.KEY_LEFT);
+ boolean right = Keyboard.isKeyDown(Keyboard.KEY_RIGHT);
+ if (!pressedArrowLast && (left || right)) {
+ if (left) {
+ rarityIndex--;
+ } else if (right) {
+ rarityIndex++;
+ }
+ if (rarityIndex < 0) rarityIndex = 0;
+ if (rarityIndex >= requiredRarities.length) rarityIndex = requiredRarities.length - 1;
+ currentRarity = requiredRarities[rarityIndex];
+ rarity = currentRarity;
+ }
+ pressedArrowLast = left || right;
+
+ JsonElement statsE = reforgeInfo.get("reforgeStats");
+
+ String rarityFormatted = Utils.rarityArrMap.getOrDefault(rarity, rarity);
+
+ JsonElement reforgeAbilityE = reforgeInfo.get("reforgeAbility");
+ String reforgeAbility = null;
+ if (reforgeAbilityE != null) {
+ if (reforgeAbilityE.isJsonPrimitive() && reforgeAbilityE.getAsJsonPrimitive().isString()) {
+ reforgeAbility = Utils.getElementAsString(reforgeInfo.get("reforgeAbility"), "");
+
+ } else if (reforgeAbilityE.isJsonObject()) {
+ if (reforgeAbilityE.getAsJsonObject().has(rarity)) {
+ reforgeAbility = reforgeAbilityE.getAsJsonObject().get(rarity).getAsString();
+ }
+ }
+ }
+
+ if (reforgeAbility != null && !reforgeAbility.isEmpty()) {
+ String text = EnumChatFormatting.BLUE + (reforgeName.isEmpty() ? "Bonus: " : reforgeName + " Bonus: ") +
+ EnumChatFormatting.GRAY + reforgeAbility;
+ boolean first = true;
+ for (String s : Minecraft.getMinecraft().fontRendererObj.listFormattedStringToWidth(text, 150)) {
+ newTooltip.add((first ? "" : " ") + s);
+ first = false;
+ }
+ newTooltip.add("");
+ }
+
+ newTooltip.add(EnumChatFormatting.BLUE + "Stats for " + rarityFormatted +
+ "\u00a79: [\u00a7l\u00a7m< \u00a79Switch\u00a7l\u27a1\u00a79]");
+
+ if (statsE != null && statsE.isJsonObject()) {
+ JsonObject stats = statsE.getAsJsonObject();
+
+ JsonElement statsRarE = stats.get(rarity);
+ if (statsRarE != null && statsRarE.isJsonObject()) {
+
+ JsonObject statsRar = statsRarE.getAsJsonObject();
+
+ TreeSet<Map.Entry<String, JsonElement>> sorted = new TreeSet<>(Map.Entry.comparingByKey());
+ sorted.addAll(statsRar.entrySet());
+
+ for (Map.Entry<String, JsonElement> entry : sorted) {
+ if (entry.getValue().isJsonPrimitive() && ((JsonPrimitive) entry.getValue()).isNumber()) {
+ float statNumF = entry.getValue().getAsFloat();
+ String statNumS;
+ if (statNumF % 1 == 0) {
+ statNumS = String.valueOf(Math.round(statNumF));
+ } else {
+ statNumS = Utils.floatToString(statNumF, 1);
+ }
+ String reforgeNamePretty = WordUtils.capitalizeFully(entry.getKey().replace("_", " "));
+ String text =
+ EnumChatFormatting.GRAY + reforgeNamePretty + ": " + EnumChatFormatting.GREEN + "+" + statNumS;
+ if (percentStats.contains(entry.getKey())) {
+ text += "%";
+ }
+ newTooltip.add(" " + text);
+ }
+ }
+ }
+ }
+
+ JsonElement reforgeCostsE = reforgeInfo.get("reforgeCosts");
+ int reforgeCost = -1;
+ if (reforgeCostsE != null) {
+ if (reforgeCostsE.isJsonPrimitive() && reforgeCostsE.getAsJsonPrimitive().isNumber()) {
+ reforgeCost = (int) Utils.getElementAsFloat(reforgeInfo.get("reforgeAbility"), -1);
+
+ } else if (reforgeCostsE.isJsonObject()) {
+ if (reforgeCostsE.getAsJsonObject().has(rarity)) {
+ reforgeCost = (int) Utils.getElementAsFloat(reforgeCostsE.getAsJsonObject().get(rarity), -1);
+ }
+ }
+ }
+
+ if (reforgeCost >= 0) {
+ String text = EnumChatFormatting.BLUE + "Apply Cost: " + EnumChatFormatting.GOLD +
+ NumberFormat.getNumberInstance().format(reforgeCost) + " coins";
+ newTooltip.add("");
+ newTooltip.add(text);
+ }
+
+ }
+
+ continue;
+ }
+
+ } else if (line.contains("\u00A7cR\u00A76a\u00A7ei\u00A7an\u00A7bb\u00A79o\u00A7dw\u00A79 Rune")) {
+ line = line.replace(
+ "\u00A7cR\u00A76a\u00A7ei\u00A7an\u00A7bb\u00A79o\u00A7dw\u00A79 Rune",
+ Utils.chromaString("Rainbow Rune", index, false) + EnumChatFormatting.BLUE
+ );
+ } else if (hasEnchantments) {
+ if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) &&
+ NotEnoughUpdates.INSTANCE.config.tooltipTweaks.missingEnchantList) {
+ boolean lineHasEnch = false;
+ for (String s : enchantIds) {
+ String enchantName = WordUtils.capitalizeFully(s.replace("_", " "));
+ if (line.contains(enchantName)) {
+ lineHasEnch = true;
+ break;
+ }
+ }
+ if (lineHasEnch) {
+ gotToEnchants = true;
+ } else {
+ if (gotToEnchants && !passedEnchants && Utils.cleanColour(line).trim().length() == 0) {
+ if (enchantsConst != null && allItemEnchs != null) {
+ List<String> missing = new ArrayList<>();
+ for (JsonElement enchIdElement : allItemEnchs) {
+ String enchId = enchIdElement.getAsString();
+ if (!enchId.startsWith("ultimate_") && !ignoreFromPool.contains(enchId) &&
+ !enchantIds.contains(enchId)) {
+ missing.add(enchId);
+ }
+ }
+ if (!missing.isEmpty()) {
+ newTooltip.add("");
+ StringBuilder currentLine =
+ new StringBuilder(EnumChatFormatting.RED + "Missing: " + EnumChatFormatting.GRAY);
+ for (int i = 0; i < missing.size(); i++) {
+ String enchName = WordUtils.capitalizeFully(missing.get(i).replace("_", " "));
+ if (currentLine.length() != 0 &&
+ (Utils.cleanColour(currentLine.toString()).length() + enchName.length()) > 40) {
+ newTooltip.add(currentLine.toString());
+ currentLine = new StringBuilder();
+ }
+ if (currentLine.length() != 0 && i != 0) {
+ currentLine.append(", ").append(enchName);
+ } else {
+ currentLine.append(EnumChatFormatting.GRAY).append(enchName);
+ }
+ }
+ if (currentLine.length() != 0) {
+ newTooltip.add(currentLine.toString());
+ }
+ }
+ }
+ passedEnchants = true;
+ }
+ }
+ }
+ for (String op : NotEnoughUpdates.INSTANCE.config.hidden.enchantColours) {
+ List<String> colourOps = GuiEnchantColour.splitter.splitToList(op);
+ String enchantName = GuiEnchantColour.getColourOpIndex(colourOps, 0);
+ String comparator = GuiEnchantColour.getColourOpIndex(colourOps, 1);
+ String comparison = GuiEnchantColour.getColourOpIndex(colourOps, 2);
+ String colourCode = GuiEnchantColour.getColourOpIndex(colourOps, 3);
+ String modifier = GuiEnchantColour.getColourOpIndex(colourOps, 4);
+
+ int modifierI = GuiEnchantColour.getIntModifier(modifier);
+
+ if (enchantName.length() == 0) continue;
+ if (comparator.length() == 0) continue;
+ if (comparison.length() == 0) continue;
+ if (colourCode.length() == 0) continue;
+
+ int comparatorI = ">=<".indexOf(comparator.charAt(0));
+
+ int levelToFind = -1;
+ try {
+ levelToFind = Integer.parseInt(comparison);
+ } catch (Exception e) {
+ continue;
+ }
+
+ if (comparatorI < 0) continue;
+ String regexText = "0123456789abcdefz";
+ if (isSbaloaded()) {
+ regexText = regexText + "Z";
+ }
+
+ if (regexText.indexOf(colourCode.charAt(0)) < 0) continue;
+
+ //item_lore = item_lore.replaceAll("\\u00A79("+lvl4Max+" IV)", EnumChatFormatting.DARK_PURPLE+"$1");
+ //9([a-zA-Z ]+?) ([0-9]+|(I|II|III|IV|V|VI|VII|VIII|IX|X))(,|$)
+ Pattern pattern;
+ try {
+ pattern = Pattern.compile("(\\u00A79|\\u00A7(9|l)\\u00A7d\\u00A7l)(?<enchantName>" + enchantName + ") " +
+ "(?<level>[0-9]+|(I|II|III|IV|V|VI|VII|VIII|IX|X|XI|XII|XIII|XIV|XV|XVI|XVII|XVIII|XIX|XX))((\\u00A79)?,|( \\u00A78(?:,?[0-9]+)*)?$)");
+ } catch (Exception e) {
+ continue;
+ } //malformed regex
+ Matcher matcher = pattern.matcher(line);
+ int matchCount = 0;
+ while (matcher.find() && matchCount < 5) {
+ if (Utils.cleanColour(matcher.group("enchantName")).startsWith(" ")) continue;
+
+ matchCount++;
+ int level = -1;
+ String levelStr = matcher.group("level");
+ if (levelStr == null) continue;
+ try {
+ level = Integer.parseInt(levelStr);
+ } catch (Exception e) {
+ switch (levelStr) {
+ case "I":
+ level = 1;
+ break;
+ case "II":
+ level = 2;
+ break;
+ case "III":
+ level = 3;
+ break;
+ case "IV":
+ level = 4;
+ break;
+ case "V":
+ level = 5;
+ break;
+ case "VI":
+ level = 6;
+ break;
+ case "VII":
+ level = 7;
+ break;
+ case "VIII":
+ level = 8;
+ break;
+ case "IX":
+ level = 9;
+ break;
+ case "X":
+ level = 10;
+ break;
+ case "XI":
+ level = 11;
+ break;
+ case "XII":
+ level = 12;
+ break;
+ case "XIII":
+ level = 13;
+ break;
+ case "XIV":
+ level = 14;
+ break;
+ case "XV":
+ level = 15;
+ break;
+ case "XVI":
+ level = 16;
+ break;
+ case "XVII":
+ level = 17;
+ break;
+ case "XVIII":
+ level = 18;
+ break;
+ case "XIX":
+ level = 19;
+ break;
+ case "XX":
+ level = 20;
+ break;
+ }
+ }
+ boolean matches = false;
+ if (level > 0) {
+ switch (comparator) {
+ case ">":
+ matches = level > levelToFind;
+ break;
+ case "=":
+ matches = level == levelToFind;
+ break;
+ case "<":
+ matches = level < levelToFind;
+ break;
+ }
+ }
+ if (matches) {
+ String enchantText = matcher.group("enchantName");
+ StringBuilder extraModifiersBuilder = new StringBuilder();
+
+ if ((modifierI & GuiEnchantColour.BOLD_MODIFIER) != 0) {
+ extraModifiersBuilder.append(EnumChatFormatting.BOLD);
+ }
+ if ((modifierI & GuiEnchantColour.ITALIC_MODIFIER) != 0) {
+ extraModifiersBuilder.append(EnumChatFormatting.ITALIC);
+ }
+ if ((modifierI & GuiEnchantColour.UNDERLINE_MODIFIER) != 0) {
+ extraModifiersBuilder.append(EnumChatFormatting.UNDERLINE);
+ }
+ if ((modifierI & GuiEnchantColour.OBFUSCATED_MODIFIER) != 0) {
+ extraModifiersBuilder.append(EnumChatFormatting.OBFUSCATED);
+ }
+ if ((modifierI & GuiEnchantColour.STRIKETHROUGH_MODIFIER) != 0) {
+ extraModifiersBuilder.append(EnumChatFormatting.STRIKETHROUGH);
+ }
+
+ String extraMods = extraModifiersBuilder.toString();
+
+ if (!colourCode.equals("z")) {
+ line = line.replace(
+ "\u00A79" + enchantText,
+ "\u00A7" + colourCode + extraMods + enchantText
+ );
+ line = line.replace(
+ "\u00A79\u00A7d\u00A7l" + enchantText,
+ "\u00A7" + colourCode + extraMods + enchantText
+ );
+ line = line.replace(
+ "\u00A7l\u00A7d\u00A7l" + enchantText,
+ "\u00A7" + colourCode + extraMods + enchantText
+ );
+ } else {
+ int offset = Minecraft.getMinecraft().fontRendererObj.getStringWidth(line.replaceAll(
+ "\\u00A79" + enchantText + ".*", ""));
+ line =
+ line.replace("\u00A79" + enchantText, Utils.chromaString(enchantText, offset / 12f + index, false));
+
+ offset = Minecraft.getMinecraft().fontRendererObj.getStringWidth(line.replaceAll(
+ "\\u00A79\\u00A7d\\u00A7l" + enchantText + ".*", ""));
+ line = line.replace("\u00A79\u00A7d\u00A7l" + enchantText, Utils.chromaString(enchantText,
+ offset / 12f + index, true
+ ));
+ offset = Minecraft.getMinecraft().fontRendererObj.getStringWidth(line.replaceAll(
+ "\\u00A7l\\u00A7d\\u00A7l" + enchantText + ".*", ""));
+ line = line.replace("\u00A7l\u00A7d\u00A7l" + enchantText, Utils.chromaString(enchantText,
+ offset / 12f + index, true
+ ));
+ }
+ }
+ }
+ }
+ }
+
+ newTooltip.add(line);
+
+ if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.showPriceInfoAucItem) {
+ if (line.contains(EnumChatFormatting.GRAY + "Buy it now: ") ||
+ line.contains(EnumChatFormatting.GRAY + "Bidder: ") ||
+ line.contains(EnumChatFormatting.GRAY + "Starting bid: ")) {
+
+ if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && !Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
+ newTooltip.add("");
+ newTooltip.add(EnumChatFormatting.GRAY + "[SHIFT for Price Info]");
+ } else {
+ ItemPriceInformation.addToTooltip(newTooltip, internalname, event.itemStack);
+ }
+ }
+ }
+
+ if (NotEnoughUpdates.INSTANCE.config.dungeons.profitDisplayLoc == 2 &&
+ Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
+ if (line.contains(EnumChatFormatting.GREEN + "Open Reward Chest")) {
+ dungeonProfit = true;
+ } else if (index == 7 && dungeonProfit) {
+ GuiChest eventGui = (GuiChest) Minecraft.getMinecraft().currentScreen;
+ ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
+ IInventory lower = cc.getLowerChestInventory();
+
+ int chestCost = 0;
+ try {
+ String line6 = Utils.cleanColour(line);
+ StringBuilder cost = new StringBuilder();
+ for (int i = 0; i < line6.length(); i++) {
+ char c = line6.charAt(i);
+ if ("0123456789".indexOf(c) >= 0) {
+ cost.append(c);
+ }
+ }
+ if (cost.length() > 0) {
+ chestCost = Integer.parseInt(cost.toString());
+ }
+ } catch (Exception ignored) {
+ }
+
+ String missingItem = null;
+ int totalValue = 0;
+ HashMap<String, Float> itemValues = new HashMap<>();
+ for (int i = 0; i < 5; i++) {
+ ItemStack item = lower.getStackInSlot(11 + i);
+ String internal = neu.manager.getInternalNameForItem(item);
+ if (internal != null) {
+ internal = internal.replace("\u00CD", "I").replace("\u0130", "I");
+ float bazaarPrice = -1;
+ JsonObject bazaarInfo = neu.manager.auctionManager.getBazaarInfo(internal);
+ if (bazaarInfo != null && bazaarInfo.has("curr_sell")) {
+ bazaarPrice = bazaarInfo.get("curr_sell").getAsFloat();
+ }
+ if (bazaarPrice < 5000000 && internal.equals("RECOMBOBULATOR_3000")) bazaarPrice = 5000000;
+
+ float worth = -1;
+ if (bazaarPrice > 0) {
+ worth = bazaarPrice;
+ } else {
+ switch (NotEnoughUpdates.INSTANCE.config.dungeons.profitType) {
+ case 1:
+ worth = neu.manager.auctionManager.getItemAvgBin(internal);
+ break;
+ case 2:
+ JsonObject auctionInfo = neu.manager.auctionManager.getItemAuctionInfo(internal);
+ if (auctionInfo != null) {
+ if (auctionInfo.has("clean_price")) {
+ worth = (int) auctionInfo.get("clean_price").getAsFloat();
+ } else {
+ worth = (int) (auctionInfo.get("price").getAsFloat() / auctionInfo.get("count").getAsFloat());
+ }
+ }
+ break;
+ default:
+ worth = neu.manager.auctionManager.getLowestBin(internal);
+ }
+ if (worth <= 0) {
+ worth = neu.manager.auctionManager.getLowestBin(internal);
+ if (worth <= 0) {
+ worth = neu.manager.auctionManager.getItemAvgBin(internal);
+ if (worth <= 0) {
+ JsonObject auctionInfo = neu.manager.auctionManager.getItemAuctionInfo(internal);
+ if (auctionInfo != null) {
+ if (auctionInfo.has("clean_price")) {
+ worth = (int) auctionInfo.get("clean_price").getAsFloat();
+ } else {
+ worth = (int) (auctionInfo.get("price").getAsFloat() / auctionInfo.get("count").getAsFloat());
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (worth > 0 && totalValue >= 0) {
+ totalValue += worth;
+
+ String display = item.getDisplayName();
+
+ if (display.contains("Enchanted Book")) {
+ NBTTagCompound tag = item.getTagCompound();
+ if (tag != null && tag.hasKey("ExtraAttributes", 10)) {
+ NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
+ NBTTagCompound enchants = ea.getCompoundTag("enchantments");
+
+ int highestLevel = -1;
+ for (String enchname : enchants.getKeySet()) {
+ int level = enchants.getInteger(enchname);
+ if (level > highestLevel) {
+ display = EnumChatFormatting.BLUE + WordUtils.capitalizeFully(
+ enchname.replace("_", " ")
+ .replace("Ultimate", "")
+ .trim()) + " " + level;
+ }
+ }
+ }
+ }
+
+ itemValues.put(display, worth);
+ } else {
+ if (totalValue != -1) {
+ missingItem = internal;
+ }
+ totalValue = -1;
+ }
+ }
+ }
+
+ NumberFormat format = NumberFormat.getInstance(Locale.US);
+ String valueStringBIN1;
+ String valueStringBIN2;
+ if (totalValue >= 0) {
+ valueStringBIN1 = EnumChatFormatting.YELLOW + "Value (BIN): ";
+ valueStringBIN2 = EnumChatFormatting.GOLD + format.format(totalValue) + " coins";
+ } else {
+ valueStringBIN1 = EnumChatFormatting.YELLOW + "Can't find BIN: ";
+ valueStringBIN2 = missingItem;
+ }
+
+ int profitLossBIN = totalValue - chestCost;
+ String profitPrefix = EnumChatFormatting.DARK_GREEN.toString();
+ String lossPrefix = EnumChatFormatting.RED.toString();
+ String prefix = profitLossBIN >= 0 ? profitPrefix : lossPrefix;
+
+ String plStringBIN;
+ if (profitLossBIN >= 0) {
+ plStringBIN = prefix + "+" + format.format(profitLossBIN) + " coins";
+ } else {
+ plStringBIN = prefix + "-" + format.format(-profitLossBIN) + " coins";
+ }
+
+ String neu = EnumChatFormatting.YELLOW + "[NEU] ";
+
+ newTooltip.add(neu + valueStringBIN1 + " " + valueStringBIN2);
+ if (totalValue >= 0) {
+ newTooltip.add(neu + EnumChatFormatting.YELLOW + "Profit/Loss: " + plStringBIN);
+ }
+
+ for (Map.Entry<String, Float> entry : itemValues.entrySet()) {
+ newTooltip.add(neu + entry.getKey() + prefix + "+" +
+ format.format(entry.getValue().intValue()));
+ }
+ }
+ }
+
+ index++;
+ }
+
+ for (int i = newTooltip.size() - 1; i >= 0; i--) {
+ String line = Utils.cleanColour(newTooltip.get(i));
+ for (int i1 = 0; i1 < Utils.rarityArr.length; i1++) {
+ if (line.equals(Utils.rarityArr[i1])) {
+ if (i - 2 < 0) {
+ break;
+ }
+ newTooltip.addAll(i - 1, petToolTipXPExtend(event));
+ break;
+ }
+ }
+ }
+
+ pressedShiftLast = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
+ pressedArrowLast = Keyboard.isKeyDown(Keyboard.KEY_LEFT) || Keyboard.isKeyDown(Keyboard.KEY_RIGHT);
+
+ event.toolTip.clear();
+ event.toolTip.addAll(newTooltip);
+
+ HashMap<String, List<String>> loreBuckets = new HashMap<>();
+
+ List<String> hypixelOrder = new ArrayList<>();
+
+ hypixelOrder.add("attributes");
+ hypixelOrder.add("enchants");
+ hypixelOrder.add("ability");
+ hypixelOrder.add("reforge_bonus");
+ hypixelOrder.add("rarity");
+
+ if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.showPriceInfoInvItem) {
+ ItemPriceInformation.addToTooltip(event.toolTip, internalname, event.itemStack);
+ }
+
+ if (event.itemStack.getTagCompound() != null && event.itemStack.getTagCompound().getBoolean("NEUHIDEPETTOOLTIP") &&
+ NotEnoughUpdates.INSTANCE.config.petOverlay.hidePetTooltip) {
+ event.toolTip.clear();
+ }
+ }
+
+ private final Pattern xpLevelPattern = Pattern.compile("(.*) (\\xA7e(.*)\\xA76/\\xA7e(.*))");
+
+ private void onItemToolTipInternalNameNull(ItemTooltipEvent event) {
+ petToolTipXPExtendPetMenu(event);
+ }
+
+ private List<String> petToolTipXPExtend(ItemTooltipEvent event) {
+ List<String> tooltipText = new ArrayList<>();
+ if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.petExtendExp) {
+ if (event.itemStack.getTagCompound().hasKey("DisablePetExp")) {
+ if (event.itemStack.getTagCompound().getBoolean("DisablePetExp")) {
+ return tooltipText;
+ }
+ }
+ //7 is just a random number i chose, prob no pets with less lines than 7
+ if (event.toolTip.size() > 7) {
+ if (Utils.cleanColour(event.toolTip.get(1)).matches(petToolTipRegex)) {
+
+ GuiProfileViewer.PetLevel petlevel = null;
+
+ //this is the item itself
+ NBTTagCompound tag = event.itemStack.getTagCompound();
+ if (tag.hasKey("ExtraAttributes")) {
+ if (tag.getCompoundTag("ExtraAttributes").hasKey("petInfo")) {
+ JsonObject petInfo = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(
+ tag.getCompoundTag("ExtraAttributes").getString("petInfo"), JsonObject.class);
+ if (petInfo.has("exp") && petInfo.get("exp").isJsonPrimitive()) {
+ JsonPrimitive exp = petInfo.getAsJsonPrimitive("exp");
+ String petName = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(event.itemStack);
+ //Utils.getRarityFromInt(Utils.checkItemTypePet(event.toolTip))).getAsInt();
+ petlevel = GuiProfileViewer.getPetLevel(
+ petName,
+ Utils.getRarityFromInt(Utils.checkItemTypePet(event.toolTip)),
+ exp.getAsLong()
+ );
+ }
+ }
+ }
+
+ if (petlevel != null) {
+ tooltipText.add("");
+ if (petlevel.totalXp > petlevel.maxXP) {
+ tooltipText.add(EnumChatFormatting.AQUA + "" + EnumChatFormatting.BOLD + "MAX LEVEL");
+ } else {
+ tooltipText.add(
+ EnumChatFormatting.GRAY + "Progress to Level " + (int) Math.floor(petlevel.level + 1) + ": " +
+ EnumChatFormatting.YELLOW + Utils.round(petlevel.levelPercentage * 100, 1) + "%");
+ int levelpercentage = Math.round(petlevel.levelPercentage * 20);
+ tooltipText.add(
+ EnumChatFormatting.DARK_GREEN + String.join("", Collections.nCopies(levelpercentage, "-")) +
+ EnumChatFormatting.WHITE + String.join("", Collections.nCopies(20 - levelpercentage, "-")));
+ tooltipText.add(
+ EnumChatFormatting.GRAY + "EXP: " + EnumChatFormatting.YELLOW + myFormatter.format(petlevel.levelXp) +
+ EnumChatFormatting.GOLD + "/" + EnumChatFormatting.YELLOW +
+ myFormatter.format(petlevel.currentLevelRequirement) + " EXP");
+ }
+ }
+ }
+ }
+ }
+ return tooltipText;
+ }
+
+ private static final String petToolTipRegex =
+ "((Farming)|(Combat)|(Fishing)|(Mining)|(Foraging)|(Enchanting)|(Alchemy)) ((Mount)|(Pet)|(Morph)).*";
+
+ private void petToolTipXPExtendPetMenu(ItemTooltipEvent event) {
+ if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.petExtendExp) {
+ //7 is just a random number i chose, prob no pets with less lines than 7
+ if (event.toolTip.size() > 7) {
+ if (Utils.cleanColour(event.toolTip.get(1)).matches(petToolTipRegex)) {
+ GuiProfileViewer.PetLevel petlevel = null;
+
+ int xpLine = -1;
+ for (int i = event.toolTip.size() - 1; i >= 0; i--) {
+ Matcher matcher = xpLevelPattern.matcher(event.toolTip.get(i));
+ if (matcher.matches()) {
+ xpLine = i;
+ event.toolTip.set(xpLine, matcher.group(1));
+ break;
+ } else if (event.toolTip.get(i).matches("MAX LEVEL")) {
+ return;
+ }
+ }
+
+ PetInfoOverlay.Pet pet = PetInfoOverlay.getPetFromStack(
+ event.itemStack.getDisplayName(),
+ NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(event.itemStack.getTagCompound())
+ );
+ if (pet == null) {
+ return;
+ }
+ petlevel = pet.petLevel;
+
+ if (petlevel == null || xpLine == -1) {
+ return;
+ }
+
+ event.toolTip.add(
+ xpLine + 1,
+ EnumChatFormatting.GRAY + "EXP: " + EnumChatFormatting.YELLOW + myFormatter.format(petlevel.levelXp) +
+ EnumChatFormatting.GOLD + "/" + EnumChatFormatting.YELLOW +
+ myFormatter.format(petlevel.currentLevelRequirement)
+ );
+
+ }
+ }
+ }
+ }
+
+ DecimalFormat myFormatter = new DecimalFormat("###,###.###");
+
+ /**
+ * This method does the following:
+ * Move the pet inventory display tooltip to the left to avoid conflicts
+ * Remove reforge stats for Legendary items from Hypixel if enabled
+ * Show NBT data when holding LCONTROL
+ */
+ @SubscribeEvent
+ public void onItemTooltip(ItemTooltipEvent event) {
+ if (!neu.isOnSkyblock()) return;
+ if (event.toolTip == null) return;
+ //Render the pet inventory display tooltip to the left to avoid things from other mods rendering over the tooltip
+ if (event.itemStack.getTagCompound() != null && event.itemStack.getTagCompound().getBoolean("NEUPETINVDISPLAY")) {
+ GlStateManager.translate(-200, 0, 0);
+ }
+
+ if (event.toolTip.size() > 2 && NotEnoughUpdates.INSTANCE.config.tooltipTweaks.hideDefaultReforgeStats) {
+ String secondLine = StringUtils.stripControlCodes(event.toolTip.get(1));
+ if (secondLine.equals("Reforge Stone")) {
+ Integer startIndex = null;
+ Integer cutoffIndex = null;
+ //loop from the back of the List to find the wanted index sooner
+ for (int i = event.toolTip.size() - 1; i >= 0; i--) {
+ //rarity or mining level requirement
+ String line = StringUtils.stripControlCodes(event.toolTip.get(i));
+ if (line.contains("REFORGE STONE") || line.contains("Requires Mining Skill Level")) {
+ cutoffIndex = i;
+ }
+
+ //The line where the Hypixel stats start
+ if (line.contains("(Legendary):")) {
+ startIndex = i;
+ break;
+ }
+ }
+ if (startIndex != null && cutoffIndex != null && startIndex < cutoffIndex) {
+ event.toolTip.subList(startIndex, cutoffIndex).clear();
+ }
+ }
+ }
+
+ if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) && NotEnoughUpdates.INSTANCE.config.hidden.dev &&
+ event.toolTip.size() > 0 &&
+ event.toolTip.get(event.toolTip.size() - 1).startsWith(EnumChatFormatting.DARK_GRAY + "NBT: ")) {
+ event.toolTip.remove(event.toolTip.size() - 1);
+
+ StringBuilder sb = new StringBuilder();
+ String nbt = event.itemStack.getTagCompound().toString();
+ int indent = 0;
+ for (char c : nbt.toCharArray()) {
+ boolean newline = false;
+ if (c == '{' || c == '[') {
+ indent++;
+ newline = true;
+ } else if (c == '}' || c == ']') {
+ indent--;
+ sb.append("\n");
+ for (int i = 0; i < indent; i++) sb.append(" ");
+ } else if (c == ',') {
+ newline = true;
+ } else if (c == '\"') {
+ sb.append(EnumChatFormatting.RESET.toString() + EnumChatFormatting.GRAY);
+ }
+
+ sb.append(c);
+ if (newline) {
+ sb.append("\n");
+ for (int i = 0; i < indent; i++) sb.append(" ");
+ }
+ }
+ event.toolTip.add(sb.toString());
+ if (Keyboard.isKeyDown(Keyboard.KEY_H)) {
+ if (!copied) {
+ copied = true;
+ StringSelection selection = new StringSelection(sb.toString());
+ Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, selection);
+ }
+ } else {
+ copied = false;
+ }
+ } else if (NotEnoughUpdates.INSTANCE.packDevEnabled) {
+ event.toolTip.add("");
+ event.toolTip.add(EnumChatFormatting.AQUA + "NEU Pack Dev Info:");
+ event.toolTip.add("Press " + EnumChatFormatting.GOLD + "[KEY]" + EnumChatFormatting.GRAY + " to copy line");
+
+ String internal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(event.itemStack);
+
+ boolean k = Keyboard.isKeyDown(Keyboard.KEY_K);
+ boolean m = Keyboard.isKeyDown(Keyboard.KEY_M);
+ boolean n = Keyboard.isKeyDown(Keyboard.KEY_N);
+
+ event.toolTip.add(
+ EnumChatFormatting.AQUA + "Internal Name: " + EnumChatFormatting.GRAY + internal + EnumChatFormatting.GOLD +
+ " [K]");
+ if (!copied && k) {
+ MiscUtils.copyToClipboard(internal);
+ }
+
+ if (event.itemStack.getTagCompound() != null) {
+ NBTTagCompound tag = event.itemStack.getTagCompound();
+
+ if (tag.hasKey("SkullOwner", 10)) {
+ GameProfile gameprofile = NBTUtil.readGameProfileFromNBT(tag.getCompoundTag("SkullOwner"));
+
+ if (gameprofile != null) {
+ event.toolTip.add(EnumChatFormatting.AQUA + "Skull UUID: " + EnumChatFormatting.GRAY + gameprofile.getId() +
+ EnumChatFormatting.GOLD + " [M]");
+ if (!copied && m) {
+ MiscUtils.copyToClipboard(gameprofile.getId().toString());
+ }
+
+ Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map =
+ Minecraft.getMinecraft().getSkinManager().loadSkinFromCache(gameprofile);
+
+ if (map.containsKey(MinecraftProfileTexture.Type.SKIN)) {
+ MinecraftProfileTexture profTex = map.get(MinecraftProfileTexture.Type.SKIN);
+ event.toolTip.add(
+ EnumChatFormatting.AQUA + "Skull Texture Link: " + EnumChatFormatting.GRAY + profTex.getUrl() +
+ EnumChatFormatting.GOLD + " [N]");
+
+ if (!copied && n) {
+ MiscUtils.copyToClipboard(profTex.getUrl());
+ }
+ }
+ }
+ }
+ }
+
+ copied = k || m || n;
+ }
+ }
+
+ @SubscribeEvent
+ public void onRenderLast(RenderWorldLastEvent event) {
+ CrystalMetalDetectorSolver.render(event.partialTicks);
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
index 5fef4c62..df31834f 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
@@ -1,14 +1,14 @@
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.miscgui.GuiItemRecipe;
-import io.github.moulberry.notenoughupdates.overlays.CraftingOverlay;
-import io.github.moulberry.notenoughupdates.util.Constants;
-import io.github.moulberry.notenoughupdates.util.HypixelApi;
-import io.github.moulberry.notenoughupdates.util.SBInfo;
-import io.github.moulberry.notenoughupdates.util.Utils;
+import io.github.moulberry.notenoughupdates.miscgui.KatSitterOverlay;
+import io.github.moulberry.notenoughupdates.recipes.CraftingOverlay;
+import io.github.moulberry.notenoughupdates.recipes.CraftingRecipe;
+import io.github.moulberry.notenoughupdates.recipes.Ingredient;
+import io.github.moulberry.notenoughupdates.recipes.NeuRecipe;
+import io.github.moulberry.notenoughupdates.util.*;
import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.init.Blocks;
@@ -17,113 +17,153 @@ import net.minecraft.inventory.ContainerChest;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.*;
-import net.minecraft.network.play.client.C0DPacketCloseWindow;
import net.minecraft.util.ResourceLocation;
+import net.minecraftforge.fml.common.ProgressManager;
import org.apache.commons.io.FileUtils;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.Display;
-import javax.swing.*;
+import javax.swing.JDialog;
+import javax.swing.JOptionPane;
import java.io.*;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
import java.util.*;
+import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
+import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
public class NEUManager {
-
- private final NotEnoughUpdates neu;
- public final Gson gson;
- public final APIManager auctionManager;
-
- private TreeMap<String, JsonObject> itemMap = new TreeMap<>();
-
- private TreeMap<String, HashMap<String, List<Integer>>> titleWordMap = new TreeMap<>();
- private TreeMap<String, HashMap<String, List<Integer>>> loreWordMap = new TreeMap<>();
-
- public final KeyBinding keybindGive = new KeyBinding("Add item to inventory (Creative-only)", Keyboard.KEY_L, "NotEnoughUpdates");
- public final KeyBinding keybindFavourite = new KeyBinding("Set item as favourite", Keyboard.KEY_F, "NotEnoughUpdates");
- public final KeyBinding keybindViewUsages = new KeyBinding("Show usages for item", Keyboard.KEY_U, "NotEnoughUpdates");
- public final KeyBinding keybindViewRecipe = new KeyBinding("Show recipe for item", Keyboard.KEY_R, "NotEnoughUpdates");
- public final KeyBinding keybindToggleDisplay = new KeyBinding("Toggle NEU overlay", 0, "NotEnoughUpdates");
- public final KeyBinding keybindClosePanes = new KeyBinding("Close NEU panes", 0, "NotEnoughUpdates");
- public final KeyBinding keybindItemSelect = new KeyBinding("Select Item", -98 /*middle*/, "NotEnoughUpdates");
- public final KeyBinding[] keybinds = new KeyBinding[]{ keybindGive, keybindFavourite, keybindViewUsages, keybindViewRecipe,
- keybindToggleDisplay, keybindClosePanes, keybindItemSelect};
-
- public String viewItemAttemptID = null;
- public long viewItemAttemptTime = 0;
-
- private String currentProfile = "";
- private String currentProfileBackup = "";
- public final HypixelApi hypixelApi = new HypixelApi();
-
- private Map<String, ItemStack> itemstackCache = new HashMap<>();
-
- private ExecutorService repoLoaderES = Executors.newSingleThreadExecutor();
-
- private static String GIT_COMMITS_URL;
-
- private HashMap<String, Set<String>> usagesMap = new HashMap<>();
-
- public String latestRepoCommit = null;
-
- public File configLocation;
- public File repoLocation;
- public File configFile;
-
- public NEUManager(NotEnoughUpdates neu, File configLocation) {
- this.neu = neu;
- this.configLocation = configLocation;
- this.auctionManager = new APIManager(this);
- GIT_COMMITS_URL = neu.config.hidden.repoCommitsURL;
-
- gson = new GsonBuilder().setPrettyPrinting().create();
-
- this.repoLocation = new File(configLocation, "repo");
- repoLocation.mkdir();
- }
-
- public void setCurrentProfile(String currentProfile) {
- this.currentProfile = currentProfile;
- }
-
- public String getCurrentProfile() {
- return SBInfo.getInstance().currentProfile;
- }
-
- public <T> T getJsonFromFile(File file, Class<T> clazz) {
- try(BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) {
- T obj = gson.fromJson(reader, clazz);
- return obj;
- } catch(Exception e) { return null; }
- }
-
- /**
- * Parses a file in to a JsonObject.
- */
- public JsonObject getJsonFromFile(File file) {
- try(BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) {
- JsonObject json = gson.fromJson(reader, JsonObject.class);
- return json;
- } catch(Exception e) { return null; }
- }
-
- public void resetRepo() {
- try { Utils.recursiveDelete(new File(configLocation, "repo")); } catch(Exception e) {}
- try { new File(configLocation, "currentCommit.json").delete(); } catch(Exception e) {}
- }
-
- /**
- * Called when the game is first loaded. Compares the local repository to the github repository and handles
- * the downloading of new/updated files. This then calls the "loadItem" method for every item in the local
- * repository.
- */
- public void loadItemInformation() {
+ private final NotEnoughUpdates neu;
+ public final Gson gson;
+ public final APIManager auctionManager;
+
+ private final TreeMap<String, JsonObject> itemMap = new TreeMap<>();
+
+ private final TreeMap<String, HashMap<String, List<Integer>>> titleWordMap = new TreeMap<>();
+ private final TreeMap<String, HashMap<String, List<Integer>>> loreWordMap = new TreeMap<>();
+
+ public final KeyBinding keybindGive =
+ new KeyBinding("Add item to inventory (Creative-only)", Keyboard.KEY_L, "NotEnoughUpdates");
+ public final KeyBinding keybindFavourite =
+ new KeyBinding("Set item as favourite", Keyboard.KEY_F, "NotEnoughUpdates");
+ public final KeyBinding keybindViewUsages =
+ new KeyBinding("Show usages for item", Keyboard.KEY_U, "NotEnoughUpdates");
+ public final KeyBinding keybindViewRecipe =
+ new KeyBinding("Show recipe for item", Keyboard.KEY_R, "NotEnoughUpdates");
+ public final KeyBinding keybindToggleDisplay = new KeyBinding("Toggle NEU overlay", 0, "NotEnoughUpdates");
+ public final KeyBinding keybindClosePanes = new KeyBinding("Close NEU panes", 0, "NotEnoughUpdates");
+ public final KeyBinding keybindItemSelect = new KeyBinding("Select Item", -98 /*middle*/, "NotEnoughUpdates");
+ public final KeyBinding[] keybinds = new KeyBinding[]{
+ keybindGive, keybindFavourite, keybindViewUsages, keybindViewRecipe,
+ keybindToggleDisplay, keybindClosePanes, keybindItemSelect
+ };
+
+ public String viewItemAttemptID = null;
+ public long viewItemAttemptTime = 0;
+
+ private final String currentProfile = "";
+ private final String currentProfileBackup = "";
+ public final HypixelApi hypixelApi = new HypixelApi();
+
+ private final Map<String, ItemStack> itemstackCache = new HashMap<>();
+
+ private final ExecutorService repoLoaderES = Executors.newSingleThreadExecutor();
+
+ private static String GIT_COMMITS_URL;
+
+ // TODO: private final Map<String, NeuItem>
+
+ private final Set<NeuRecipe> recipes = new HashSet<>();
+ private final HashMap<String, Set<NeuRecipe>> recipesMap = new HashMap<>();
+ private final HashMap<String, Set<NeuRecipe>> usagesMap = new HashMap<>();
+
+ public String latestRepoCommit = null;
+
+ public File configLocation;
+ public File repoLocation;
+ public File configFile;
+ public HotmInformation hotm;
+
+ public KatSitterOverlay katSitterOverlay;
+
+ public CraftingOverlay craftingOverlay;
+
+ public NEUManager(NotEnoughUpdates neu, File configLocation) {
+ this.neu = neu;
+ this.configLocation = configLocation;
+ this.auctionManager = new APIManager(this);
+ this.hotm = new HotmInformation(neu);
+ this.craftingOverlay = new CraftingOverlay(this);
+ this.katSitterOverlay = new KatSitterOverlay();
+
+ GIT_COMMITS_URL = neu.config.hidden.repoCommitsURL;
+
+ gson = new GsonBuilder().setPrettyPrinting().create();
+
+ this.repoLocation = new File(configLocation, "repo");
+ repoLocation.mkdir();
+ }
+
+ public void setCurrentProfile(String currentProfile) {
+ SBInfo.getInstance().currentProfile = currentProfile;
+ }
+
+ public String getCurrentProfile() {
+ return SBInfo.getInstance().currentProfile;
+ }
+
+ public <T> T getJsonFromFile(File file, Class<T> clazz) {
+ try (
+ BufferedReader reader = new BufferedReader(new InputStreamReader(
+ new FileInputStream(file),
+ StandardCharsets.UTF_8
+ ))
+ ) {
+ T obj = gson.fromJson(reader, clazz);
+ return obj;
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ /**
+ * Parses a file in to a JsonObject.
+ */
+ public JsonObject getJsonFromFile(File file) {
+ try (
+ BufferedReader reader = new BufferedReader(new InputStreamReader(
+ new FileInputStream(file),
+ StandardCharsets.UTF_8
+ ))
+ ) {
+ JsonObject json = gson.fromJson(reader, JsonObject.class);
+ return json;
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ public void resetRepo() {
+ try {
+ Utils.recursiveDelete(new File(configLocation, "repo"));
+ } catch (Exception ignored) {
+ }
+ try {
+ new File(configLocation, "currentCommit.json").delete();
+ } catch (Exception ignored) {
+ }
+ }
+
+ /**
+ * Called when the game is first loaded. Compares the local repository to the github repository and handles the
+ * downloading of new/updated files. This then calls the "loadItem" method for every item in the local repository.
+ */
+ public void loadItemInformation() {
/*File repoFile = new File(configLocation, "repo2");
repoFile.mkdirs();
@@ -155,1297 +195,1377 @@ public class NEUManager {
}*/
- repoLoaderES.submit(() -> {
- JDialog dialog = null;
- try {
- if(NotEnoughUpdates.INSTANCE.config.hidden.autoupdate) {
- JOptionPane pane = new JOptionPane("Getting items to download from remote repository.");
- dialog = pane.createDialog("NotEnoughUpdates Remote Sync");
- dialog.setModal(false);
- if(NotEnoughUpdates.INSTANCE.config.hidden.dev) dialog.setVisible(true);
-
- if (Display.isActive()) dialog.toFront();
-
- JsonObject currentCommitJSON = getJsonFromFile(new File(configLocation, "currentCommit.json"));
-
- latestRepoCommit = null;
- try(Reader inReader = new InputStreamReader(new URL(GIT_COMMITS_URL).openStream())) {
- JsonObject commits = gson.fromJson(inReader, JsonObject.class);
- latestRepoCommit = commits.get("sha").getAsString();
- } catch (Exception e) {
- e.printStackTrace();
- }
- if(latestRepoCommit == null || latestRepoCommit.isEmpty()) return;
-
- if(new File(configLocation, "repo").exists() && new File(configLocation, "repo/items").exists()) {
- if(currentCommitJSON != null && currentCommitJSON.get("sha").getAsString().equals(latestRepoCommit)) {
- dialog.setVisible(false);
- return;
- }
- }
-
- if (Display.isActive()) dialog.toFront();
-
- Utils.recursiveDelete(repoLocation);
- repoLocation.mkdirs();
-
-
- String dlUrl = neu.config.hidden.repoURL;
-
- pane.setMessage("Downloading NEU Master Archive. (DL# >20)");
- dialog.pack();
- if(NotEnoughUpdates.INSTANCE.config.hidden.dev) dialog.setVisible(true);
- if (Display.isActive()) dialog.toFront();
-
- File itemsZip = new File(repoLocation, "neu-items-master.zip");
- try {
- itemsZip.createNewFile();
- } catch (IOException e) {
- return;
- }
-
-
- URL url = new URL(dlUrl);
- URLConnection urlConnection = url.openConnection();
- urlConnection.setConnectTimeout(15000);
- urlConnection.setReadTimeout(30000);
-
- try(InputStream is = urlConnection.getInputStream()) {
- FileUtils.copyInputStreamToFile(is, itemsZip);
- } catch (IOException e) {
- dialog.dispose();
- e.printStackTrace();
- System.err.println("Failed to download NEU Repo! Please report this issue to the mod creator");
- return;
- }
- /*try (BufferedInputStream inStream = new BufferedInputStream(urlConnection.getInputStream());
- FileOutputStream fileOutputStream = new FileOutputStream(itemsZip)) {
- byte dataBuffer[] = new byte[1024];
- int bytesRead;
- while ((bytesRead = inStream.read(dataBuffer, 0, 1024)) != -1) {
- fileOutputStream.write(dataBuffer, 0, bytesRead);
- }
- } catch (IOException e) {
- dialog.dispose();
- return;
- }*/
-
- pane.setMessage("Unzipping NEU Master Archive.");
- dialog.pack();
- //dialog.setVisible(true);
- if (Display.isActive()) dialog.toFront();
-
- unzipIgnoreFirstFolder(itemsZip.getAbsolutePath(), repoLocation.getAbsolutePath());
-
- if(currentCommitJSON == null || !currentCommitJSON.get("sha").getAsString().equals(latestRepoCommit)) {
- JsonObject newCurrentCommitJSON = new JsonObject();
- newCurrentCommitJSON.addProperty("sha", latestRepoCommit);
- try {
- writeJson(newCurrentCommitJSON, new File(configLocation, "currentCommit.json"));
- } catch (IOException e) {
- }
- }
- }
- } catch(Exception e) {
- e.printStackTrace();
- } finally {
- if(dialog != null) dialog.dispose();
- }
-
- File items = new File(repoLocation, "items");
- if(items.exists()) {
- File[] itemFiles = new File(repoLocation, "items").listFiles();
- if(itemFiles != null) {
- for(File f : itemFiles) {
- String internalname = f.getName().substring(0, f.getName().length()-5);
- synchronized(itemMap) {
- if(!itemMap.keySet().contains(internalname)) {
- loadItem(internalname);
- }
- }
- }
- }
- }
-
- try {
- Constants.reload();
- } catch(Exception e) {
- e.printStackTrace();
- }
- });
-
- File items = new File(repoLocation, "items");
- if(items.exists()) {
- File[] itemFiles = new File(repoLocation, "items").listFiles();
- if(itemFiles != null) {
- for(File f : itemFiles) {
- String internalname = f.getName().substring(0, f.getName().length()-5);
- synchronized(itemMap) {
- if(!itemMap.keySet().contains(internalname)) {
- loadItem(internalname);
- }
- }
- }
- }
- }
-
- try {
- Constants.reload();
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
-
- /**
- * Loads the item in to the itemMap and also stores various words associated with this item
- * in to titleWordMap and loreWordMap. These maps are used in the searching algorithm.
- * @param internalName
- */
- public void loadItem(String internalName) {
- itemstackCache.remove(internalName);
- try {
- JsonObject json = getJsonFromFile(new File(new File(repoLocation, "items"), internalName + ".json"));
- if(json == null) {
- return;
- }
-
- if(json.get("itemid") == null) return;
-
- String itemid = json.get("itemid").getAsString();
- Item mcitem = Item.getByNameOrId(itemid);
- if(mcitem != null) {
- itemid = mcitem.getRegistryName();
- }
- json.addProperty("itemid", itemid);
-
- itemMap.put(internalName, json);
-
- if(json.has("recipe")) {
- synchronized(usagesMap) {
- JsonObject recipe = json.get("recipe").getAsJsonObject();
-
- String[] x = {"1","2","3"};
- String[] y = {"A","B","C"};
- for(int i=0; i<9; i++) {
- String name = y[i/3]+x[i%3];
- String itemS = recipe.get(name).getAsString();
- if(itemS != null && itemS.split(":").length == 2) {
- itemS = itemS.split(":")[0];
- }
-
- if(!usagesMap.containsKey(itemS)) {
- usagesMap.put(itemS, new HashSet<>());
- }
- usagesMap.get(itemS).add(internalName);
- }
- }
- }
-
- if(json.has("displayname")) {
- synchronized(titleWordMap) {
- int wordIndex=0;
- for(String str : json.get("displayname").getAsString().split(" ")) {
- str = clean(str);
- if(!titleWordMap.containsKey(str)) {
- titleWordMap.put(str, new HashMap<>());
- }
- if(!titleWordMap.get(str).containsKey(internalName)) {
- titleWordMap.get(str).put(internalName, new ArrayList<>());
- }
- titleWordMap.get(str).get(internalName).add(wordIndex);
- wordIndex++;
- }
- }
- }
-
- if(json.has("lore")) {
- synchronized(loreWordMap) {
- int wordIndex=0;
- for(JsonElement element : json.get("lore").getAsJsonArray()) {
- for(String str : element.getAsString().split(" ")) {
- str = clean(str);
- if(!loreWordMap.containsKey(str)) {
- loreWordMap.put(str, new HashMap<>());
- }
- if(!loreWordMap.get(str).containsKey(internalName)) {
- loreWordMap.get(str).put(internalName, new ArrayList<>());
- }
- loreWordMap.get(str).get(internalName).add(wordIndex);
- wordIndex++;
- }
- }
- }
- }
- } catch(Exception e) {
- synchronized(loreWordMap) {
- System.out.println("loreWordMap is : " + loreWordMap);
- }
- synchronized(titleWordMap) {
- System.out.println("titleWordMap is : " + titleWordMap);
- }
- System.out.println("internalName is : " + internalName);
- e.printStackTrace();
- }
- }
-
- /**
- * Searches a string for a query. This method is used to mimic the behaviour of the
- * more complex map-based search function. This method is used for the chest-item-search feature.
- */
- public boolean searchString(String toSearch, String query) {
- int lastMatch = -1;
-
- toSearch = clean(toSearch).toLowerCase();
- query = clean(query).toLowerCase();
- String[] splitToSeach = toSearch.split(" ");
- out:
- for(String s : query.split(" ")) {
- for(int i=0; i<splitToSeach.length; i++) {
- if(lastMatch == -1 || lastMatch == i-1) {
- if (splitToSeach[i].startsWith(s)) {
- lastMatch = i;
- continue out;
- }
- }
- }
- return false;
- }
-
- return true;
- }
-
- /**
- * Checks whether an itemstack matches a certain query, following the same rules implemented by the
- * more complex map-based search function.
- */
- public boolean doesStackMatchSearch(ItemStack stack, String query) {
- if(query.startsWith("title:")) {
- query = query.substring(6);
- return searchString(stack.getDisplayName(), query);
- } else if(query.startsWith("desc:")) {
- query = query.substring(5);
- String lore = "";
- NBTTagCompound tag = stack.getTagCompound();
- if(tag != null) {
- NBTTagCompound display = tag.getCompoundTag("display");
- if (display.hasKey("Lore", 9)) {
- NBTTagList list = display.getTagList("Lore", 8);
- for (int i = 0; i < list.tagCount(); i++) {
- lore += list.getStringTagAt(i) + " ";
- }
- }
- }
- return searchString(lore, query);
- } else if(query.startsWith("id:")) {
- query = query.substring(3);
- String internalName = getInternalNameForItem(stack);
- return query.equalsIgnoreCase(internalName);
- } else {
- boolean result = false;
- if(!query.trim().contains(" ")) {
- StringBuilder sb = new StringBuilder();
- for(char c : query.toCharArray()) {
- sb.append(c).append(" ");
- }
- result = result || searchString(stack.getDisplayName(), sb.toString());
- }
- result = result || searchString(stack.getDisplayName(), query);
-
- String lore = "";
- NBTTagCompound tag = stack.getTagCompound();
- if(tag != null) {
- NBTTagCompound display = tag.getCompoundTag("display");
- if (display.hasKey("Lore", 9)) {
- NBTTagList list = display.getTagList("Lore", 8);
- for (int i = 0; i < list.tagCount(); i++) {
- lore += list.getStringTagAt(i) + " ";
- }
- }
- }
-
- result = result || searchString(lore, query);
-
- return result;
- }
- }
-
- /**
- * Calls search for each query, separated by |
- * eg. search(A|B) = search(A) + search(B)
- */
- public Set<String> search(String query, boolean multi) {
- if(multi) {
- Set<String> result = new HashSet<>();
-
- StringBuilder query2 = new StringBuilder();
- char lastOp = '|';
- for(char c : query.toCharArray()) {
- if(c == '|' || c == '&') {
- if(lastOp == '|') {
- result.addAll(search(query2.toString()));
- } else if(lastOp == '&') {
- result.retainAll(search(query2.toString()));
- }
-
- query2 = new StringBuilder();
- lastOp = c;
- } else {
- query2.append(c);
- }
- }
- if(lastOp == '|') {
- result.addAll(search(query2.toString()));
- } else if(lastOp == '&') {
- result.retainAll(search(query2.toString()));
- }
-
- return result;
- } else {
- return search(query);
- }
- }
-
- /*public TreeMap<ItemStack> searchForStacks(String query, Set<ItemStack> stacks, boolean multi) {
- if(multi) {
- Set<String> result = new HashSet<>();
-
- StringBuilder query2 = new StringBuilder();
- char lastOp = '|';
- for(char c : query.toCharArray()) {
- if(c == '|' || c == '&') {
- if(lastOp == '|') {
- result.addAll(doesStackMatchSearch(stack, query2.toString()));
- } else if(lastOp == '&') {
- result.retainAll(search(query2.toString()));
- }
-
- query2 = new StringBuilder();
- lastOp = c;
- } else {
- query2.append(c);
- }
- }
- if(lastOp == '|') {
- result.addAll(search(query2.toString()));
- } else if(lastOp == '&') {
- result.retainAll(search(query2.toString()));
- }
-
- return result;
- } else {
- return search(query);
- }
- }*/
-
- /**
- * Returns the name of items which match a certain search query.
- */
- public Set<String> search(String query) {
- query = query.trim();
- boolean negate = query.startsWith("!");
- if(negate) query = query.substring(1);
-
- LinkedHashSet<String> results = new LinkedHashSet<>();
- if(query.startsWith("title:")) {
- query = query.substring(6);
- results.addAll(new TreeSet<>(search(query, titleWordMap)));
- } else if(query.startsWith("desc:")) {
- query = query.substring(5);
- results.addAll(new TreeSet<>(search(query, loreWordMap)));
- } else if(query.startsWith("id:")) {
- query = query.substring(3);
- results.addAll(new TreeSet<>(subMapWithKeysThatAreSuffixes(query.toUpperCase(), itemMap).keySet()));
- } else {
- if(!query.trim().contains(" ")) {
- StringBuilder sb = new StringBuilder();
- for(char c : query.toCharArray()) {
- sb.append(c).append(" ");
- }
- results.addAll(new TreeSet<>(search(sb.toString(), titleWordMap)));
- }
- results.addAll(new TreeSet<>(search(query, titleWordMap)));
- results.addAll(new TreeSet<>(search(query, loreWordMap)));
- }
- if(!negate) {
- return results;
- } else {
- Set<String> negatedResults = new HashSet<>();
- for(String internalname : itemMap.keySet()) {
- negatedResults.add(internalname);
- }
- negatedResults.removeAll(results);
- return negatedResults;
- }
- }
-
- /**
- * Splits a search query into an array of strings delimited by a space character. Then, matches the query to
- * the start of words in the various maps (title & lore). The small query does not need to match the whole entry
- * of the map, only the beginning. eg. "ench" and "encha" will both match "enchanted". All sub queries must
- * follow a word matching the previous sub query. eg. "ench po" will match "enchanted pork" but will not match
- * "pork enchanted".
- */
- public Set<String> search(String query, TreeMap<String, HashMap<String, List<Integer>>> wordMap) {
- HashMap<String, List<Integer>> matches = null;
-
- query = clean(query).toLowerCase();
- for(String queryWord : query.split(" ")) {
- HashMap<String, List<Integer>> matchesToKeep = new HashMap<>();
- for(HashMap<String, List<Integer>> wordMatches : subMapWithKeysThatAreSuffixes(queryWord, wordMap).values()) {
- if(wordMatches != null && !wordMatches.isEmpty()) {
- if(matches == null) {
- //Copy all wordMatches to titleMatches
- for(String internalname : wordMatches.keySet()) {
- if(!matchesToKeep.containsKey(internalname)) {
- matchesToKeep.put(internalname, new ArrayList<>());
- }
- matchesToKeep.get(internalname).addAll(wordMatches.get(internalname));
- }
- } else {
- for(String internalname : matches.keySet()) {
- if(wordMatches.containsKey(internalname)) {
- for(Integer newIndex : wordMatches.get(internalname)) {
- if(matches.get(internalname).contains(newIndex-1)) {
- if(!matchesToKeep.containsKey(internalname)) {
- matchesToKeep.put(internalname, new ArrayList<>());
- }
- matchesToKeep.get(internalname).add(newIndex);
- }
- }
- }
- }
- }
- }
- }
- if(matchesToKeep.isEmpty()) return new HashSet<>();
- matches = matchesToKeep;
- }
-
- return matches.keySet();
- }
-
- /**
- * From https://stackoverflow.com/questions/10711494/get-values-in-treemap-whose-string-keys-start-with-a-pattern
- */
- public <T> Map<String, T> subMapWithKeysThatAreSuffixes(String prefix, NavigableMap<String, T> map) {
- if ("".equals(prefix)) return map;
- String lastKey = createLexicographicallyNextStringOfTheSameLength(prefix);
- return map.subMap(prefix, true, lastKey, false);
- }
-
- public String createLexicographicallyNextStringOfTheSameLength(String input) {
- final int lastCharPosition = input.length()-1;
- String inputWithoutLastChar = input.substring(0, lastCharPosition);
- char lastChar = input.charAt(lastCharPosition) ;
- char incrementedLastChar = (char) (lastChar + 1);
- return inputWithoutLastChar+incrementedLastChar;
- }
-
- public JsonObject getJsonFromItemBytes(String item_bytes) {
- try {
- NBTTagCompound tag = CompressedStreamTools.readCompressed(new ByteArrayInputStream(Base64.getDecoder().decode(item_bytes)));
- //System.out.println(tag.toString());
- return getJsonFromNBT(tag);
- } catch(IOException e) {
- return null;
- }
- }
-
- public String getUUIDFromNBT(NBTTagCompound tag) {
- String uuid = null;
- if (tag != null && tag.hasKey("ExtraAttributes", 10)) {
- NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
-
- if (ea.hasKey("uuid", 8)) {
- uuid = ea.getString("uuid");
- }
- }
- return uuid;
- }
-
- public String getInternalnameFromNBT(NBTTagCompound tag) {
- String internalname = null;
- if(tag != null && tag.hasKey("ExtraAttributes", 10)) {
- NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
-
- if(ea.hasKey("id", 8)) {
- internalname = ea.getString("id").replaceAll(":", "-");
- } else {
- return null;
- }
-
- if("PET".equals(internalname)) {
- String petInfo = ea.getString("petInfo");
- if(petInfo.length() > 0) {
- JsonObject petInfoObject = gson.fromJson(petInfo, JsonObject.class);
- internalname = petInfoObject.get("type").getAsString();
- String tier = petInfoObject.get("tier").getAsString();
- switch(tier) {
- case "COMMON":
- internalname += ";0"; break;
- case "UNCOMMON":
- internalname += ";1"; break;
- case "RARE":
- internalname += ";2"; break;
- case "EPIC":
- internalname += ";3"; break;
- case "LEGENDARY":
- internalname += ";4"; break;
- case "MYTHIC":
- internalname += ";5"; break;
- }
- }
- }
- if("ENCHANTED_BOOK".equals(internalname)) {
- NBTTagCompound enchants = ea.getCompoundTag("enchantments");
-
- for(String enchname : enchants.getKeySet()) {
- internalname = enchname.toUpperCase() + ";" + enchants.getInteger(enchname);
- break;
- }
- }
- }
-
- return internalname;
- }
-
- public String[] getLoreFromNBT(NBTTagCompound tag) {
- String[] lore = new String[0];
- NBTTagCompound display = tag.getCompoundTag("display");
-
- if(display.hasKey("Lore", 9)) {
- NBTTagList list = display.getTagList("Lore", 8);
- lore = new String[list.tagCount()];
- for(int k=0; k<list.tagCount(); k++) {
- lore[k] = list.getStringTagAt(k);
- }
- }
- return lore;
- }
-
- public JsonObject getJsonFromNBT(NBTTagCompound tag) {
- return getJsonFromNBTEntry(tag.getTagList("i", 10).getCompoundTagAt(0));
- }
-
- public JsonObject getJsonFromNBTEntry(NBTTagCompound tag) {
- if(tag.getKeySet().size() == 0) return null;
-
- int id = tag.getShort("id");
- int damage = tag.getShort("Damage");
- int count = tag.getShort("Count");
- tag = tag.getCompoundTag("tag");
-
- if(id == 141) id = 391; //for some reason hypixel thinks carrots have id 141
-
- String internalname = getInternalnameFromNBT(tag);
- if(internalname == null) return null;
-
- NBTTagCompound display = tag.getCompoundTag("display");
- String[] lore = getLoreFromNBT(tag);
-
- Item itemMc = Item.getItemById(id);
- String itemid = "null";
- if(itemMc != null) {
- itemid = itemMc.getRegistryName();
- }
- String displayname = display.getString("Name");
- String[] info = new String[0];
- String clickcommand = "";
-
- JsonObject item = new JsonObject();
- item.addProperty("internalname", internalname);
- item.addProperty("itemid", itemid);
- item.addProperty("displayname", displayname);
-
- if(tag != null && tag.hasKey("ExtraAttributes", 10)) {
- NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
-
- byte[] bytes = null;
- for(String key : ea.getKeySet()) {
- if(key.endsWith("backpack_data") || key.equals("new_year_cake_bag_data")) {
- bytes = ea.getByteArray(key);
- break;
- }
- }
- if(bytes != null) {
- JsonArray bytesArr = new JsonArray();
- for(byte b : bytes) {
- bytesArr.add(new JsonPrimitive(b));
- }
- item.add("item_contents", bytesArr);
- }
- if(ea.hasKey("dungeon_item_level")) {
- item.addProperty("dungeon_item_level", ea.getInteger("dungeon_item_level"));
- }
- }
-
- if(lore != null && lore.length > 0) {
- JsonArray jsonLore = new JsonArray();
- for (String line : lore) {
- jsonLore.add(new JsonPrimitive(line));
- }
- item.add("lore", jsonLore);
- }
-
- item.addProperty("damage", damage);
- if(count > 1) item.addProperty("count", count);
- item.addProperty("nbttag", tag.toString());
-
- return item;
- }
-
- private String clean(String str) {
- return str.replaceAll("(\u00a7.)|[^0-9a-zA-Z ]", "").toLowerCase().trim();
- }
-
- public void showRecipe(JsonObject item) {
- ContainerChest container = null;
- if(Minecraft.getMinecraft().thePlayer.openContainer instanceof ContainerChest)
- container = (ContainerChest) Minecraft.getMinecraft().thePlayer.openContainer;
- if (item.has("recipe") && container != null && container.getLowerChestInventory().getDisplayName().getUnformattedText().equals("Craft Item")) {
- CraftingOverlay.updateItem(item);
- } else if(item.has("useneucraft") && item.get("useneucraft").getAsBoolean()) {
- displayGuiItemRecipe(item.get("internalname").getAsString(), "");
- } else if(item.has("clickcommand")) {
- String clickcommand = item.get("clickcommand").getAsString();
-
- if(clickcommand.equals("viewrecipe")) {
- neu.sendChatMessage(
- "/" + clickcommand + " " +
- item.get("internalname").getAsString().split(";")[0]);
- viewItemAttemptID = item.get("internalname").getAsString();
- viewItemAttemptTime = System.currentTimeMillis();
- } else if(clickcommand.equals("viewpotion")) {
- neu.sendChatMessage(
- "/" + clickcommand + " " +
- item.get("internalname").getAsString().split(";")[0].toLowerCase());
- viewItemAttemptID = item.get("internalname").getAsString();
- viewItemAttemptTime = System.currentTimeMillis();
- }
- }
- }
-
- /**
- * Takes an item stack and produces a JsonObject.
- */
- public JsonObject getJsonForItem(ItemStack stack) {
- NBTTagCompound tag = stack.getTagCompound() == null ? new NBTTagCompound() : stack.getTagCompound();
-
- //Item lore
- String[] lore = new String[0];
- if(tag.hasKey("display", 10)) {
- NBTTagCompound display = tag.getCompoundTag("display");
-
- if(display.hasKey("Lore", 9)) {
- NBTTagList list = display.getTagList("Lore", 8);
- lore = new String[list.tagCount()];
- for(int i=0; i<list.tagCount(); i++) {
- lore[i] = list.getStringTagAt(i);
- }
- }
- }
-
- if(stack.getDisplayName().endsWith(" Recipes")) {
- stack.setStackDisplayName(stack.getDisplayName().substring(0, stack.getDisplayName().length()-8));
- }
-
- if(lore.length > 0 && (lore[lore.length-1].contains("Click to view recipes!") ||
- lore[lore.length-1].contains("Click to view recipe!"))) {
- String[] lore2 = new String[lore.length-2];
- System.arraycopy(lore, 0, lore2, 0, lore.length-2);
- lore = lore2;
- }
-
- JsonObject json = new JsonObject();
- json.addProperty("itemid", stack.getItem().getRegistryName());
- json.addProperty("displayname", stack.getDisplayName());
- json.addProperty("nbttag", tag.toString());
- json.addProperty("damage", stack.getItemDamage());
-
- JsonArray jsonlore = new JsonArray();
- for(String line : lore) {
- jsonlore.add(new JsonPrimitive(line));
- }
- json.add("lore", jsonlore);
-
- return json;
- }
-
- public String getInternalNameForItem(ItemStack stack) {
- if(stack == null) return null;
- NBTTagCompound tag = stack.getTagCompound();
- return getInternalnameFromNBT(tag);
- }
-
- public String getUUIDForItem(ItemStack stack) {
- if(stack == null) return null;
- NBTTagCompound tag = stack.getTagCompound();
- return getUUIDFromNBT(tag);
- }
-
- public void writeItemToFile(ItemStack stack) {
- String internalname = getInternalNameForItem(stack);
-
- if(internalname == null) {
- return;
- }
-
- JsonObject json = getJsonForItem(stack);
- json.addProperty("internalname", internalname);
- json.addProperty("clickcommand", "");
- json.addProperty("modver", NotEnoughUpdates.VERSION);
-
- try {
- writeJson(json, new File(new File(repoLocation, "items"), internalname+".json"));
- } catch (IOException e) {}
-
- loadItem(internalname);
- }
-
- /**
- * Constructs a GuiItemUsages from the recipe usage data (see #usagesMap) of a given item
- */
- public boolean displayGuiItemUsages(String internalName) {
- List<ItemStack[]> craftMatrices = new ArrayList<>();
- List<JsonObject> results = new ArrayList<>();
-
- if(!usagesMap.containsKey(internalName)) {
- return false;
- }
-
- for(String internalNameResult : usagesMap.get(internalName)) {
- JsonObject item = getItemInformation().get(internalNameResult);
- results.add(item);
-
- if(item != null && item.has("recipe")) {
- JsonObject recipe = item.get("recipe").getAsJsonObject();
-
- ItemStack[] craftMatrix = new ItemStack[9];
-
- String[] x = {"1","2","3"};
- String[] y = {"A","B","C"};
- for(int i=0; i<9; i++) {
- String name = y[i/3]+x[i%3];
- String itemS = recipe.get(name).getAsString();
- int count = 1;
- if(itemS != null && itemS.split(":").length == 2) {
- count = Integer.valueOf(itemS.split(":")[1]);
- itemS = itemS.split(":")[0];
- }
- JsonObject craft = getItemInformation().get(itemS);
- if(craft != null) {
- ItemStack stack = jsonToStack(craft);
- stack.stackSize = count;
- craftMatrix[i] = stack;
- }
- }
-
- craftMatrices.add(craftMatrix);
- }
- }
-
- if(craftMatrices.size() > 0) {
- Minecraft.getMinecraft().displayGuiScreen(new GuiItemRecipe("Item Usages", craftMatrices, results, this));
- return true;
- }
- return false;
- }
-
- /**
- * Constructs a GuiItemRecipeOld from the recipe data of a given item.
- */
- public boolean displayGuiItemRecipe(String internalName, String text) {
- JsonObject item = getItemInformation().get(internalName);
- if(item != null && item.has("recipe")) {
- JsonObject recipe = item.get("recipe").getAsJsonObject();
-
- ItemStack[] craftMatrix = new ItemStack[9];
-
- String[] x = {"1","2","3"};
- String[] y = {"A","B","C"};
- for(int i=0; i<9; i++) {
- String name = y[i/3]+x[i%3];
- String itemS = recipe.get(name).getAsString();
- int count = 1;
- if(itemS != null && itemS.split(":").length == 2) {
- count = Integer.valueOf(itemS.split(":")[1]);
- itemS = itemS.split(":")[0];
- }
- JsonObject craft = getItemInformation().get(itemS);
- if(craft != null) {
- ItemStack stack = jsonToStack(craft);
- stack.stackSize = count;
- craftMatrix[i] = stack;
- }
- }
-
- Minecraft.getMinecraft().thePlayer.sendQueue.addToSendQueue(new C0DPacketCloseWindow(
- Minecraft.getMinecraft().thePlayer.openContainer.windowId));
- Minecraft.getMinecraft().displayGuiScreen(new GuiItemRecipe(text!=null?text:"Item Recipe",
- Lists.<ItemStack[]>newArrayList(craftMatrix), Lists.newArrayList(item), this));
- return true;
- }
- return false;
- }
-
- /**
- * Will display guiItemRecipe if a player attempted to view the recipe to an item but they didn't have the recipe
- * unlocked. See NotEnoughUpdates#onGuiChat for where this method is called.
- */
- public boolean failViewItem(String text) {
- if(viewItemAttemptID != null && !viewItemAttemptID.isEmpty()) {
- if(System.currentTimeMillis() - viewItemAttemptTime < 500) {
- return displayGuiItemRecipe(viewItemAttemptID, text);
- }
- }
- return false;
- }
-
- /**
- * Downloads a web file, appending some HTML attributes that makes wikia give us the raw wiki syntax.
- */
- public File getWebFile(String url) {
- File f = new File(configLocation, "tmp/"+Base64.getEncoder().encodeToString(url.getBytes())+".html");
- if(f.exists()) {
- return f;
- }
-
- try {
- f.getParentFile().mkdirs();
- f.createNewFile();
- f.deleteOnExit();
- } catch (IOException e) {
- return null;
- }
- try (BufferedInputStream inStream = new BufferedInputStream(new URL(url+"?action=raw&templates=expand").openStream());
- FileOutputStream fileOutputStream = new FileOutputStream(f)) {
- byte dataBuffer[] = new byte[1024];
- int bytesRead;
- while ((bytesRead = inStream.read(dataBuffer, 0, 1024)) != -1) {
- fileOutputStream.write(dataBuffer, 0, bytesRead);
- }
- } catch (IOException e) {
- e.printStackTrace();
- return null;
- }
-
- return f;
- }
-
-
- /**
- * Modified from https://www.journaldev.com/960/java-unzip-file-example
- */
- private static void unzipIgnoreFirstFolder(String zipFilePath, String destDir) {
- File dir = new File(destDir);
- // create output directory if it doesn't exist
- if(!dir.exists()) dir.mkdirs();
- FileInputStream fis;
- //buffer for read and write data to file
- byte[] buffer = new byte[1024];
- try {
- fis = new FileInputStream(zipFilePath);
- ZipInputStream zis = new ZipInputStream(fis);
- ZipEntry ze = zis.getNextEntry();
- while(ze != null){
- if(!ze.isDirectory()) {
- String fileName = ze.getName();
- fileName = fileName.substring(fileName.split("/")[0].length()+1);
- File newFile = new File(destDir + File.separator + fileName);
- //create directories for sub directories in zip
- new File(newFile.getParent()).mkdirs();
- FileOutputStream fos = new FileOutputStream(newFile);
- int len;
- while ((len = zis.read(buffer)) > 0) {
- fos.write(buffer, 0, len);
- }
- fos.close();
- }
- //close this ZipEntry
- zis.closeEntry();
- ze = zis.getNextEntry();
- }
- //close last ZipEntry
- zis.closeEntry();
- zis.close();
- fis.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * Modified from https://www.journaldev.com/960/java-unzip-file-example
- */
- public static void unzip(InputStream src, File dest) {
- //buffer for read and write data to file
- byte[] buffer = new byte[1024];
- try {
- ZipInputStream zis = new ZipInputStream(src);
- ZipEntry ze = zis.getNextEntry();
- while(ze != null){
- if(!ze.isDirectory()) {
- String fileName = ze.getName();
- File newFile = new File(dest, fileName);
- //create directories for sub directories in zip
- new File(newFile.getParent()).mkdirs();
- FileOutputStream fos = new FileOutputStream(newFile);
- int len;
- while ((len = zis.read(buffer)) > 0) {
- fos.write(buffer, 0, len);
- }
- fos.close();
- }
- //close this ZipEntry
- zis.closeEntry();
- ze = zis.getNextEntry();
- }
- //close last ZipEntry
- zis.closeEntry();
- zis.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * From here to the end of the file are various helper functions for creating and writing json files,
- * in particular json files representing skyblock item data.
- */
- public JsonObject createItemJson(String internalname, String itemid, String displayname, String[] lore,
- String crafttext, String infoType, String[] info,
- String clickcommand, int damage, NBTTagCompound nbttag) {
- return createItemJson(new JsonObject(), internalname, itemid, displayname, lore, crafttext, infoType, info, clickcommand, damage, nbttag);
- }
-
- public JsonObject createItemJson(JsonObject base, String internalname, String itemid, String displayname, String[] lore,
- String crafttext, String infoType, String[] info,
- String clickcommand, int damage, NBTTagCompound nbttag) {
- if(internalname == null || internalname.isEmpty()) {
- return null;
- }
-
- JsonObject json = gson.fromJson(gson.toJson(base, JsonObject.class), JsonObject.class);
- json.addProperty("internalname", internalname);
- json.addProperty("itemid", itemid);
- json.addProperty("displayname", displayname);
- json.addProperty("crafttext", crafttext);
- json.addProperty("clickcommand", clickcommand);
- json.addProperty("damage", damage);
- json.addProperty("nbttag", nbttag.toString());
- json.addProperty("modver", NotEnoughUpdates.VERSION);
- json.addProperty("infoType", infoType.toString());
-
- if(info != null && info.length > 0) {
- JsonArray jsoninfo = new JsonArray();
- for (String line : info) {
- jsoninfo.add(new JsonPrimitive(line));
- }
- json.add("info", jsoninfo);
- }
-
- JsonArray jsonlore = new JsonArray();
- for(String line : lore) {
- jsonlore.add(new JsonPrimitive(line));
- }
- json.add("lore", jsonlore);
-
- return json;
- }
-
- public boolean writeItemJson(String internalname, String itemid, String displayname, String[] lore, String crafttext,
- String infoType, String[] info, String clickcommand, int damage, NBTTagCompound nbttag) {
- return writeItemJson(new JsonObject(), internalname, itemid, displayname, lore, crafttext, infoType, info, clickcommand, damage, nbttag);
- }
-
- public boolean writeItemJson(JsonObject base, String internalname, String itemid, String displayname, String[] lore,
- String crafttext, String infoType, String[] info, String clickcommand, int damage, NBTTagCompound nbttag) {
- JsonObject json = createItemJson(base, internalname, itemid, displayname, lore, crafttext, infoType, info, clickcommand, damage, nbttag);
- if(json == null) {
- return false;
- }
-
- try {
- writeJsonDefaultDir(json, internalname+".json");
- } catch(IOException e) {
- return false;
- }
-
- loadItem(internalname);
- return true;
- }
-
- public void writeJson(JsonObject json, File file) throws IOException {
- file.createNewFile();
-
- try(BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8))) {
- writer.write(gson.toJson(json));
- }
- }
-
- public void writeJsonDefaultDir(JsonObject json, String filename) throws IOException {
- File file = new File(new File(repoLocation, "items"), filename);
- writeJson(json, file);
- }
-
- public TreeMap<String, JsonObject> getItemInformation() {
- return itemMap;
- }
-
- public String removeUnusedDecimal(double num) {
- if(num % 1 == 0) {
- return String.valueOf((int)num);
- } else {
- return String.valueOf(num);
- }
- }
-
- public HashMap<String, String> getLoreReplacements(String petname, String tier, int level) {
- JsonObject petnums = null;
- if(petname != null && tier != null) {
- petnums = Constants.PETNUMS;
- }
-
- HashMap<String, String> replacements = new HashMap<>();
- if(level < 1) {
- if (Constants.PETS.has("custom_pet_leveling") && Constants.PETS.getAsJsonObject("custom_pet_leveling").has(petname) && Constants.PETS.getAsJsonObject("custom_pet_leveling").getAsJsonObject(petname).has("max_level")){
- int maxLvl = Constants.PETS.getAsJsonObject("custom_pet_leveling").getAsJsonObject(petname).get("max_level").getAsInt();
- replacements.put("LVL", "1\u27A1"+maxLvl);
- } else {
- replacements.put("LVL", "1\u27A1100");
- }
- } else {
- replacements.put("LVL", ""+level);
- }
-
-
- if(petnums != null) {
- if(petnums.has(petname)) {
- JsonObject petInfo = petnums.get(petname).getAsJsonObject();
- if(petInfo.has(tier)) {
- JsonObject petInfoTier = petInfo.get(tier).getAsJsonObject();
- if(petInfoTier == null || !petInfoTier.has("1") || !petInfoTier.has("100")) {
- return replacements;
- }
-
- JsonObject min = petInfoTier.get("1").getAsJsonObject();
- JsonObject max = petInfoTier.get("100").getAsJsonObject();
-
- if(level < 1) {
- JsonArray otherNumsMin = min.get("otherNums").getAsJsonArray();
- JsonArray otherNumsMax = max.get("otherNums").getAsJsonArray();
- boolean addZero = false;
- if(petInfoTier.has("stats_levelling_curve")){
- String[] stringArray = petInfoTier.get("stats_levelling_curve").getAsString().split(":");
- if(stringArray.length == 3) {
- int type = Integer.parseInt(stringArray[2]);
- if(type == 1){
- addZero = true;
- }
- }
- }
- for(int i=0; i<otherNumsMax.size(); i++) {
- replacements.put(""+i, (addZero?"0\u27A1":"")+removeUnusedDecimal(Math.floor(otherNumsMin.get(i).getAsFloat()*10)/10f)+
- "\u27A1"+removeUnusedDecimal(Math.floor(otherNumsMax.get(i).getAsFloat()*10)/10f));
- }
-
- for(Map.Entry<String, JsonElement> entry : max.get("statNums").getAsJsonObject().entrySet()) {
- int statMax = (int)Math.floor(entry.getValue().getAsFloat());
- int statMin = (int)Math.floor(min.get("statNums").getAsJsonObject().get(entry.getKey()).getAsFloat());
- String statStr = (statMin>0?"+":"")+statMin+"\u27A1"+statMax;
- statStr = (addZero?"0\u27A1":"")+statStr;
- replacements.put(entry.getKey(), statStr);
- }
- } else {
-
- int minStatsLevel = 0;
- int maxStatsLevel = 100;
- int statsLevelingType = -1;
-
- int statsLevel = level;
-
-
- if(petInfoTier.has("stats_levelling_curve")) {
- String[] stringArray = petInfoTier.get("stats_levelling_curve").getAsString().split(":");
- if (stringArray.length == 3) {
- minStatsLevel = Integer.parseInt(stringArray[0]);
- maxStatsLevel = Integer.parseInt(stringArray[1]);
- statsLevelingType = Integer.parseInt(stringArray[2]);
- switch (statsLevelingType) {
- //Case for maybe a pet that might exist
- case 0:
- case 1:
- if (level < minStatsLevel) {
- statsLevel = 1;
- } else if (level < maxStatsLevel) {
- statsLevel = level - minStatsLevel + 1;
- } else {
- statsLevel = maxStatsLevel - minStatsLevel + 1;
- }
- break;
-
- }
- }
- }
- float minMix = (maxStatsLevel-(minStatsLevel-(statsLevelingType==-1?0:1))-statsLevel)/99f;
- float maxMix = (statsLevel-1)/99f;
-
- JsonArray otherNumsMin = min.get("otherNums").getAsJsonArray();
- JsonArray otherNumsMax = max.get("otherNums").getAsJsonArray();
- for(int i=0; i<otherNumsMax.size(); i++) {
- float val = otherNumsMin.get(i).getAsFloat()*minMix + otherNumsMax.get(i).getAsFloat()*maxMix;
- if(statsLevelingType == 1 && level < minStatsLevel){
- replacements.put("" + i, "0");
- } else {
- replacements.put("" + i, removeUnusedDecimal(Math.floor(val * 10) / 10f));
- }
- }
-
- for(Map.Entry<String, JsonElement> entry : max.get("statNums").getAsJsonObject().entrySet()) {
- if(statsLevelingType == 1 && level < minStatsLevel) {
- replacements.put(entry.getKey(), "0");
- } else {
- float statMax = entry.getValue().getAsFloat();
- float statMin = min.get("statNums").getAsJsonObject().get(entry.getKey()).getAsFloat();
- float val = statMin * minMix + statMax * maxMix;
- String statStr = (statMin > 0 ? "+" : "") + (int) Math.floor(val);
- replacements.put(entry.getKey(), statStr);
- }
- }
- }
- }
- }
- }
-
- return replacements;
- }
-
- public HashMap<String, String> getLoreReplacements(NBTTagCompound tag, int level) {
- String petname = null;
- String tier = null;
- if(tag != null && tag.hasKey("ExtraAttributes")) {
- NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
- if(ea.hasKey("petInfo")) {
- String petInfoStr = ea.getString("petInfo");
- JsonObject petInfo = gson.fromJson(petInfoStr, JsonObject.class);
- petname = petInfo.get("type").getAsString();
- tier = petInfo.get("tier").getAsString();
- if(petInfo.has("heldItem")) {
- String heldItem = petInfo.get("heldItem").getAsString();
- if(heldItem.equals("PET_ITEM_TIER_BOOST")) {
- switch(tier) {
- case "COMMON":
- tier = "UNCOMMON"; break;
- case "UNCOMMON":
- tier = "RARE"; break;
- case "RARE":
- tier = "EPIC"; break;
- case "EPIC":
- tier = "LEGENDARY"; break;
- case "LEGENDARY":
- tier = "MYTHIC"; break;
- }
- }
- }
- }
- }
- return getLoreReplacements(petname, tier, level);
- }
-
- public NBTTagList processLore(JsonArray lore, HashMap<String, String> replacements) {
- NBTTagList nbtLore = new NBTTagList();
- for(JsonElement line : lore) {
- String lineStr = line.getAsString();
- if(!lineStr.contains("Click to view recipes!") &&
- !lineStr.contains("Click to view recipe!")) {
- for(Map.Entry<String, String> entry : replacements.entrySet()) {
- lineStr = lineStr.replace("{"+entry.getKey()+"}", entry.getValue());
- }
- nbtLore.appendTag(new NBTTagString(lineStr));
- }
- }
- return nbtLore;
- }
-
- public ItemStack jsonToStack(JsonObject json) {
- return jsonToStack(json, true);
- }
-
- public ItemStack jsonToStack(JsonObject json, boolean useCache) {
- return jsonToStack(json, useCache, true);
- }
-
- public ItemStack jsonToStack(JsonObject json, boolean useCache, boolean useReplacements) {
- return jsonToStack(json, useCache, useReplacements, true);
- }
-
- public ItemStack jsonToStack(JsonObject json, boolean useCache, boolean useReplacements, boolean copyStack) {
- if(json == null) return new ItemStack(Items.painting, 1, 10);
- String internalname = json.get("internalname").getAsString();
-
- if(useCache) {
- ItemStack stack = itemstackCache.get(internalname);
- if(stack != null) {
- if(copyStack) {
- return stack.copy();
- } else {
- return stack;
- }
- }
- }
-
- ItemStack stack = new ItemStack(Item.itemRegistry.getObject(
- new ResourceLocation(json.get("itemid").getAsString())));
-
- if(json.has("count")) {
- stack.stackSize = json.get("count").getAsInt();
- }
-
- if(stack.getItem() == null) {
- stack = new ItemStack(Item.getItemFromBlock(Blocks.stone), 0, 255); //Purple broken texture item
- } else {
- if(json.has("damage")) {
- stack.setItemDamage(json.get("damage").getAsInt());
- }
-
- if(json.has("nbttag")) {
- try {
- NBTTagCompound tag = JsonToNBT.getTagFromJson(json.get("nbttag").getAsString());
- stack.setTagCompound(tag);
- } catch(NBTException e) {
- }
- }
-
- HashMap<String, String> replacements = new HashMap<>();
-
- if(useReplacements) {
- replacements = getLoreReplacements(stack.getTagCompound(), -1);
-
- String displayname = json.get("displayname").getAsString();
- for(Map.Entry<String, String> entry : replacements.entrySet()) {
- displayname = displayname.replace("{"+entry.getKey()+"}", entry.getValue());
- }
- stack.setStackDisplayName(displayname);
- }
-
- if(json.has("lore")) {
- NBTTagCompound display = new NBTTagCompound();
- if(stack.getTagCompound() != null && stack.getTagCompound().hasKey("display")) {
- display = stack.getTagCompound().getCompoundTag("display");
- }
- display.setTag("Lore", processLore(json.get("lore").getAsJsonArray(), replacements));
- NBTTagCompound tag = stack.getTagCompound() != null ? stack.getTagCompound() : new NBTTagCompound();
- tag.setTag("display", display);
- stack.setTagCompound(tag);
- }
- }
-
- if(useCache) itemstackCache.put(internalname, stack);
- if(copyStack) {
- return stack.copy();
- } else {
- return stack;
- }
- }
-
+ repoLoaderES.submit(() -> {
+ JDialog dialog = null;
+ try {
+ if (NotEnoughUpdates.INSTANCE.config.hidden.autoupdate) {
+ JOptionPane pane = new JOptionPane("Getting items to download from remote repository.");
+ dialog = pane.createDialog("NotEnoughUpdates Remote Sync");
+ dialog.setModal(false);
+ if (NotEnoughUpdates.INSTANCE.config.hidden.dev) dialog.setVisible(true);
+
+ if (Display.isActive()) dialog.toFront();
+
+ JsonObject currentCommitJSON = getJsonFromFile(new File(configLocation, "currentCommit.json"));
+
+ latestRepoCommit = null;
+ try (Reader inReader = new InputStreamReader(new URL(GIT_COMMITS_URL).openStream())) {
+ JsonObject commits = gson.fromJson(inReader, JsonObject.class);
+ latestRepoCommit = commits.get("sha").getAsString();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ if (latestRepoCommit == null || latestRepoCommit.isEmpty()) return;
+
+ if (new File(configLocation, "repo").exists() && new File(configLocation, "repo/items").exists()) {
+ if (currentCommitJSON != null && currentCommitJSON.get("sha").getAsString().equals(latestRepoCommit)) {
+ dialog.setVisible(false);
+ return;
+ }
+ }
+
+ if (Display.isActive()) dialog.toFront();
+
+ Utils.recursiveDelete(repoLocation);
+ repoLocation.mkdirs();
+
+ String dlUrl = neu.config.hidden.repoURL;
+
+ pane.setMessage("Downloading NEU Master Archive. (DL# >20)");
+ dialog.pack();
+ if (NotEnoughUpdates.INSTANCE.config.hidden.dev) dialog.setVisible(true);
+ if (Display.isActive()) dialog.toFront();
+
+ File itemsZip = new File(repoLocation, "neu-items-master.zip");
+ try {
+ itemsZip.createNewFile();
+ } catch (IOException e) {
+ return;
+ }
+
+ URL url = new URL(dlUrl);
+ URLConnection urlConnection = url.openConnection();
+ urlConnection.setConnectTimeout(15000);
+ urlConnection.setReadTimeout(30000);
+
+ try (InputStream is = urlConnection.getInputStream()) {
+ FileUtils.copyInputStreamToFile(is, itemsZip);
+ } catch (IOException e) {
+ dialog.dispose();
+ e.printStackTrace();
+ System.err.println("Failed to download NEU Repo! Please report this issue to the mod creator");
+ return;
+ }
+ /*try (
+ BufferedInputStream inStream = new BufferedInputStream(urlConnection.getInputStream());
+ FileOutputStream fileOutputStream = new FileOutputStream(itemsZip)
+ ) {
+ byte dataBuffer[] = new byte[1024];
+ int bytesRead;
+ while ((bytesRead = inStream.read(dataBuffer, 0, 1024)) != -1) {
+ fileOutputStream.write(dataBuffer, 0, bytesRead);
+ }
+ } catch (IOException e) {
+ dialog.dispose();
+ return;
+ }*/
+
+ pane.setMessage("Unzipping NEU Master Archive.");
+ dialog.pack();
+ //dialog.setVisible(true);
+ if (Display.isActive()) dialog.toFront();
+
+ unzipIgnoreFirstFolder(itemsZip.getAbsolutePath(), repoLocation.getAbsolutePath());
+
+ if (currentCommitJSON == null || !currentCommitJSON.get("sha").getAsString().equals(latestRepoCommit)) {
+ JsonObject newCurrentCommitJSON = new JsonObject();
+ newCurrentCommitJSON.addProperty("sha", latestRepoCommit);
+ try {
+ writeJson(newCurrentCommitJSON, new File(configLocation, "currentCommit.json"));
+ } catch (IOException ignored) {
+ }
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ if (dialog != null) dialog.dispose();
+ }
+
+ File items = new File(repoLocation, "items");
+ if (items.exists()) {
+ File[] itemFiles = new File(repoLocation, "items").listFiles();
+ if (itemFiles != null) {
+ ProgressManager.ProgressBar bar = ProgressManager.push("Loading recipes", itemFiles.length);
+ for (File f : itemFiles) {
+ String internalname = f.getName().substring(0, f.getName().length() - 5);
+ bar.step(internalname);
+ synchronized (itemMap) {
+ if (!itemMap.containsKey(internalname)) {
+ loadItem(internalname);
+ }
+ }
+ }
+ ProgressManager.pop(bar);
+ }
+ }
+
+ try {
+ Constants.reload();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ });
+
+ File items = new File(repoLocation, "items");
+ if (items.exists()) {
+ File[] itemFiles = new File(repoLocation, "items").listFiles();
+ if (itemFiles != null) {
+ ProgressManager.ProgressBar bar = ProgressManager.push("Loading items", itemFiles.length);
+ for (File f : itemFiles) {
+ String internalname = f.getName().substring(0, f.getName().length() - 5);
+ bar.step(internalname);
+ synchronized (itemMap) {
+ if (!itemMap.containsKey(internalname)) {
+ loadItem(internalname);
+ }
+ }
+ }
+ ProgressManager.pop(bar);
+ }
+ }
+
+ try {
+ Constants.reload();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Loads the item in to the itemMap and also stores various words associated with this item in to titleWordMap and
+ * loreWordMap. These maps are used in the searching algorithm.
+ */
+ public void loadItem(String internalName) {
+ itemstackCache.remove(internalName);
+ try {
+ JsonObject json = getJsonFromFile(new File(new File(repoLocation, "items"), internalName + ".json"));
+ if (json == null) {
+ return;
+ }
+
+ if (json.get("itemid") == null) return;
+
+ String itemid = json.get("itemid").getAsString();
+ Item mcitem = Item.getByNameOrId(itemid);
+ if (mcitem != null) {
+ itemid = mcitem.getRegistryName();
+ }
+ json.addProperty("itemid", itemid);
+
+ itemMap.put(internalName, json);
+
+ if (json.has("recipe")) {
+ JsonObject recipe = json.getAsJsonObject("recipe");
+ NeuRecipe neuRecipe = NeuRecipe.parseRecipe(this, recipe, json);
+ if (neuRecipe != null)
+ registerNeuRecipe(neuRecipe);
+ }
+ if (json.has("recipes")) {
+ for (JsonElement element : json.getAsJsonArray("recipes")) {
+ JsonObject recipe = element.getAsJsonObject();
+ NeuRecipe neuRecipe = NeuRecipe.parseRecipe(this, recipe, json);
+ if (neuRecipe != null)
+ registerNeuRecipe(neuRecipe);
+ }
+ }
+
+ if (json.has("displayname")) {
+ synchronized (titleWordMap) {
+ int wordIndex = 0;
+ for (String str : json.get("displayname").getAsString().split(" ")) {
+ str = clean(str);
+ if (!titleWordMap.containsKey(str)) {
+ titleWordMap.put(str, new HashMap<>());
+ }
+ if (!titleWordMap.get(str).containsKey(internalName)) {
+ titleWordMap.get(str).put(internalName, new ArrayList<>());
+ }
+ titleWordMap.get(str).get(internalName).add(wordIndex);
+ wordIndex++;
+ }
+ }
+ }
+
+ if (json.has("lore")) {
+ synchronized (loreWordMap) {
+ int wordIndex = 0;
+ for (JsonElement element : json.get("lore").getAsJsonArray()) {
+ for (String str : element.getAsString().split(" ")) {
+ str = clean(str);
+ if (!loreWordMap.containsKey(str)) {
+ loreWordMap.put(str, new HashMap<>());
+ }
+ if (!loreWordMap.get(str).containsKey(internalName)) {
+ loreWordMap.get(str).put(internalName, new ArrayList<>());
+ }
+ loreWordMap.get(str).get(internalName).add(wordIndex);
+ wordIndex++;
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ synchronized (loreWordMap) {
+ System.out.println("loreWordMap is : " + loreWordMap);
+ }
+ synchronized (titleWordMap) {
+ System.out.println("titleWordMap is : " + titleWordMap);
+ }
+ System.out.println("internalName is : " + internalName);
+ e.printStackTrace();
+ }
+ }
+
+ public void registerNeuRecipe(NeuRecipe recipe) {
+ recipes.add(recipe);
+ for (Ingredient output : recipe.getOutputs()) {
+ recipesMap.computeIfAbsent(output.getInternalItemId(), ignored -> new HashSet<>()).add(recipe);
+ }
+ for (Ingredient input : recipe.getIngredients()) {
+ usagesMap.computeIfAbsent(input.getInternalItemId(), ignored -> new HashSet<>()).add(recipe);
+ }
+ }
+
+ public Set<NeuRecipe> getRecipesFor(String internalName) {
+ return recipesMap.getOrDefault(internalName, Collections.emptySet());
+ }
+
+ public List<NeuRecipe> getAvailableRecipesFor(String internalname) {
+ return getRecipesFor(internalname).stream().filter(NeuRecipe::isAvailable).collect(Collectors.toList());
+ }
+
+ public Set<NeuRecipe> getUsagesFor(String internalName) {
+ return usagesMap.getOrDefault(internalName, Collections.emptySet());
+ }
+
+ public List<NeuRecipe> getAvailableUsagesFor(String internalname) {
+ return getUsagesFor(internalname).stream().filter(NeuRecipe::isAvailable).collect(Collectors.toList());
+ }
+
+ /**
+ * Searches a string for a query. This method is used to mimic the behaviour of the more complex map-based search
+ * function. This method is used for the chest-item-search feature.
+ */
+ public boolean searchString(String toSearch, String query) {
+ int lastMatch = -1;
+
+ toSearch = clean(toSearch).toLowerCase();
+ query = clean(query).toLowerCase();
+ String[] splitToSeach = toSearch.split(" ");
+ out:
+ for (String s : query.split(" ")) {
+ for (int i = 0; i < splitToSeach.length; i++) {
+ if (!(lastMatch == -1 || lastMatch == i - 1)) continue;
+ if (splitToSeach[i].startsWith(s)) {
+ lastMatch = i;
+ continue out;
+ }
+ }
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Checks whether an itemstack matches a certain query, following the same rules implemented by the more complex
+ * map-based search function.
+ */
+ public boolean doesStackMatchSearch(ItemStack stack, String query) {
+ if (query.startsWith("title:")) {
+ query = query.substring(6);
+ return searchString(stack.getDisplayName(), query);
+ } else if (query.startsWith("desc:")) {
+ query = query.substring(5);
+ String lore = "";
+ NBTTagCompound tag = stack.getTagCompound();
+ if (tag != null) {
+ NBTTagCompound display = tag.getCompoundTag("display");
+ if (display.hasKey("Lore", 9)) {
+ NBTTagList list = display.getTagList("Lore", 8);
+ for (int i = 0; i < list.tagCount(); i++) {
+ lore += list.getStringTagAt(i) + " ";
+ }
+ }
+ }
+ return searchString(lore, query);
+ } else if (query.startsWith("id:")) {
+ query = query.substring(3);
+ String internalName = getInternalNameForItem(stack);
+ return query.equalsIgnoreCase(internalName);
+ } else {
+ boolean result = false;
+ if (!query.trim().contains(" ")) {
+ StringBuilder sb = new StringBuilder();
+ for (char c : query.toCharArray()) {
+ sb.append(c).append(" ");
+ }
+ result = result || searchString(stack.getDisplayName(), sb.toString());
+ }
+ result = result || searchString(stack.getDisplayName(), query);
+
+ String lore = "";
+ NBTTagCompound tag = stack.getTagCompound();
+ if (tag != null) {
+ NBTTagCompound display = tag.getCompoundTag("display");
+ if (display.hasKey("Lore", 9)) {
+ NBTTagList list = display.getTagList("Lore", 8);
+ for (int i = 0; i < list.tagCount(); i++) {
+ lore += list.getStringTagAt(i) + " ";
+ }
+ }
+ }
+
+ result = result || searchString(lore, query);
+
+ return result;
+ }
+ }
+
+ /**
+ * Calls search for each query, separated by | eg. search(A|B) = search(A) + search(B)
+ */
+ public Set<String> search(String query, boolean multi) {
+ if (multi) {
+ Set<String> result = new HashSet<>();
+
+ StringBuilder query2 = new StringBuilder();
+ char lastOp = '|';
+ for (char c : query.toCharArray()) {
+ if (c == '|' || c == '&') {
+ if (lastOp == '|') {
+ result.addAll(search(query2.toString()));
+ } else if (lastOp == '&') {
+ result.retainAll(search(query2.toString()));
+ }
+
+ query2 = new StringBuilder();
+ lastOp = c;
+ } else {
+ query2.append(c);
+ }
+ }
+ if (lastOp == '|') {
+ result.addAll(search(query2.toString()));
+ } else if (lastOp == '&') {
+ result.retainAll(search(query2.toString()));
+ }
+
+ return result;
+ } else {
+ return search(query);
+ }
+ }
+
+ /*public TreeMap<ItemStack> searchForStacks(String query, Set<ItemStack> stacks, boolean multi) {
+ if (multi) {
+ Set<String> result = new HashSet<>();
+
+ StringBuilder query2 = new StringBuilder();
+ char lastOp = '|';
+ for (char c : query.toCharArray()) {
+ if (c == '|' || c == '&') {
+ if (lastOp == '|') {
+ result.addAll(doesStackMatchSearch(stack, query2.toString()));
+ } else if (lastOp == '&') {
+ result.retainAll(search(query2.toString()));
+ }
+
+ query2 = new StringBuilder();
+ lastOp = c;
+ } else {
+ query2.append(c);
+ }
+ }
+ if (lastOp == '|') {
+ result.addAll(search(query2.toString()));
+ } else if (lastOp == '&') {
+ result.retainAll(search(query2.toString()));
+ }
+
+ return result;
+ } else {
+ return search(query);
+ }
+ }*/
+
+ /**
+ * Returns the name of items which match a certain search query.
+ */
+ public Set<String> search(String query) {
+ query = query.trim();
+ boolean negate = query.startsWith("!");
+ if (negate) query = query.substring(1);
+
+ LinkedHashSet<String> results = new LinkedHashSet<>();
+ if (query.startsWith("title:")) {
+ query = query.substring(6);
+ results.addAll(new TreeSet<>(search(query, titleWordMap)));
+ } else if (query.startsWith("desc:")) {
+ query = query.substring(5);
+ results.addAll(new TreeSet<>(search(query, loreWordMap)));
+ } else if (query.startsWith("id:")) {
+ query = query.substring(3);
+ results.addAll(new TreeSet<>(subMapWithKeysThatAreSuffixes(query.toUpperCase(), itemMap).keySet()));
+ } else {
+ if (!query.trim().contains(" ")) {
+ StringBuilder sb = new StringBuilder();
+ for (char c : query.toCharArray()) {
+ sb.append(c).append(" ");
+ }
+ results.addAll(new TreeSet<>(search(sb.toString(), titleWordMap)));
+ }
+ results.addAll(new TreeSet<>(search(query, titleWordMap)));
+ results.addAll(new TreeSet<>(search(query, loreWordMap)));
+ }
+ if (!negate) {
+ return results;
+ } else {
+ Set<String> negatedResults = new HashSet<>();
+ for (String internalname : itemMap.keySet()) {
+ negatedResults.add(internalname);
+ }
+ negatedResults.removeAll(results);
+ return negatedResults;
+ }
+ }
+
+ /**
+ * Splits a search query into an array of strings delimited by a space character. Then, matches the query to the
+ * start of words in the various maps (title & lore). The small query does not need to match the whole entry of the
+ * map, only the beginning. eg. "ench" and "encha" will both match "enchanted". All sub queries must follow a word
+ * matching the previous sub query. eg. "ench po" will match "enchanted pork" but will not match "pork enchanted".
+ */
+ public Set<String> search(String query, TreeMap<String, HashMap<String, List<Integer>>> wordMap) {
+ HashMap<String, List<Integer>> matches = null;
+
+ query = clean(query).toLowerCase();
+ for (String queryWord : query.split(" ")) {
+ HashMap<String, List<Integer>> matchesToKeep = new HashMap<>();
+ for (HashMap<String, List<Integer>> wordMatches : subMapWithKeysThatAreSuffixes(queryWord, wordMap).values()) {
+ if (!(wordMatches != null && !wordMatches.isEmpty())) continue;
+ if (matches == null) {
+ //Copy all wordMatches to titleMatches
+ for (String internalname : wordMatches.keySet()) {
+ if (!matchesToKeep.containsKey(internalname)) {
+ matchesToKeep.put(internalname, new ArrayList<>());
+ }
+ matchesToKeep.get(internalname).addAll(wordMatches.get(internalname));
+ }
+ } else {
+ for (String internalname : matches.keySet()) {
+ if (!wordMatches.containsKey(internalname)) continue;
+ for (Integer newIndex : wordMatches.get(internalname)) {
+ if (!matches.get(internalname).contains(newIndex - 1)) continue;
+ if (!matchesToKeep.containsKey(internalname)) {
+ matchesToKeep.put(internalname, new ArrayList<>());
+ }
+ matchesToKeep.get(internalname).add(newIndex);
+ }
+ }
+ }
+ }
+ if (matchesToKeep.isEmpty()) return new HashSet<>();
+ matches = matchesToKeep;
+ }
+
+ return matches.keySet();
+ }
+
+ /**
+ * From https://stackoverflow.com/questions/10711494/get-values-in-treemap-whose-string-keys-start-with-a-pattern
+ */
+ public <T> Map<String, T> subMapWithKeysThatAreSuffixes(String prefix, NavigableMap<String, T> map) {
+ if ("".equals(prefix)) return map;
+ String lastKey = createLexicographicallyNextStringOfTheSameLength(prefix);
+ return map.subMap(prefix, true, lastKey, false);
+ }
+
+ public String createLexicographicallyNextStringOfTheSameLength(String input) {
+ final int lastCharPosition = input.length() - 1;
+ String inputWithoutLastChar = input.substring(0, lastCharPosition);
+ char lastChar = input.charAt(lastCharPosition);
+ char incrementedLastChar = (char) (lastChar + 1);
+ return inputWithoutLastChar + incrementedLastChar;
+ }
+
+ public JsonObject getJsonFromItemBytes(String item_bytes) {
+ try {
+ NBTTagCompound tag =
+ CompressedStreamTools.readCompressed(new ByteArrayInputStream(Base64.getDecoder().decode(item_bytes)));
+ //System.out.println(tag.toString());
+ return getJsonFromNBT(tag);
+ } catch (IOException e) {
+ return null;
+ }
+ }
+
+ public String getUUIDFromNBT(NBTTagCompound tag) {
+ String uuid = null;
+ if (tag != null && tag.hasKey("ExtraAttributes", 10)) {
+ NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
+
+ if (ea.hasKey("uuid", 8)) {
+ uuid = ea.getString("uuid");
+ }
+ }
+ return uuid;
+ }
+
+ public String getInternalnameFromNBT(NBTTagCompound tag) {
+ String internalname = null;
+ if (tag != null && tag.hasKey("ExtraAttributes", 10)) {
+ NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
+
+ if (ea.hasKey("id", 8)) {
+ internalname = ea.getString("id").replaceAll(":", "-");
+ } else {
+ return null;
+ }
+
+ if ("PET".equals(internalname)) {
+ String petInfo = ea.getString("petInfo");
+ if (petInfo.length() > 0) {
+ JsonObject petInfoObject = gson.fromJson(petInfo, JsonObject.class);
+ internalname = petInfoObject.get("type").getAsString();
+ String tier = petInfoObject.get("tier").getAsString();
+ switch (tier) {
+ case "COMMON":
+ internalname += ";0";
+ break;
+ case "UNCOMMON":
+ internalname += ";1";
+ break;
+ case "RARE":
+ internalname += ";2";
+ break;
+ case "EPIC":
+ internalname += ";3";
+ break;
+ case "LEGENDARY":
+ internalname += ";4";
+ break;
+ case "MYTHIC":
+ internalname += ";5";
+ break;
+ }
+ }
+ }
+ if ("ENCHANTED_BOOK".equals(internalname) && ea.hasKey("enchantments", 10)) {
+ NBTTagCompound enchants = ea.getCompoundTag("enchantments");
+
+ for (String enchname : enchants.getKeySet()) {
+ internalname = enchname.toUpperCase() + ";" + enchants.getInteger(enchname);
+ break;
+ }
+ }
+ if ("RUNE".equals(internalname) && ea.hasKey("runes", 10)) {
+ NBTTagCompound rune = ea.getCompoundTag("runes");
+
+ for (String runename : rune.getKeySet()) {
+ internalname = runename.toUpperCase() + "_RUNE" + ";" + rune.getInteger(runename);
+ break;
+ }
+ }
+ if ("PARTY_HAT_CRAB".equals(internalname) && (ea.getString("party_hat_color") != null)) {
+ String crabhat = ea.getString("party_hat_color");
+ internalname = "PARTY_HAT_CRAB" + "_" + crabhat.toUpperCase();
+ }
+ }
+
+ return internalname;
+ }
+
+ public String[] getLoreFromNBT(NBTTagCompound tag) {
+ String[] lore = new String[0];
+ NBTTagCompound display = tag.getCompoundTag("display");
+
+ if (display.hasKey("Lore", 9)) {
+ NBTTagList list = display.getTagList("Lore", 8);
+ lore = new String[list.tagCount()];
+ for (int k = 0; k < list.tagCount(); k++) {
+ lore[k] = list.getStringTagAt(k);
+ }
+ }
+ return lore;
+ }
+
+ public JsonObject getJsonFromNBT(NBTTagCompound tag) {
+ return getJsonFromNBTEntry(tag.getTagList("i", 10).getCompoundTagAt(0));
+ }
+
+ public JsonObject getJsonFromNBTEntry(NBTTagCompound tag) {
+ if (tag.getKeySet().size() == 0) return null;
+
+ int id = tag.getShort("id");
+ int damage = tag.getShort("Damage");
+ int count = tag.getShort("Count");
+ tag = tag.getCompoundTag("tag");
+
+ if (id == 141) id = 391; //for some reason hypixel thinks carrots have id 141
+
+ String internalname = getInternalnameFromNBT(tag);
+ if (internalname == null) return null;
+
+ NBTTagCompound display = tag.getCompoundTag("display");
+ String[] lore = getLoreFromNBT(tag);
+
+ Item itemMc = Item.getItemById(id);
+ String itemid = "null";
+ if (itemMc != null) {
+ itemid = itemMc.getRegistryName();
+ }
+ String displayname = display.getString("Name");
+ String[] info = new String[0];
+ String clickcommand = "";
+
+ JsonObject item = new JsonObject();
+ item.addProperty("internalname", internalname);
+ item.addProperty("itemid", itemid);
+ item.addProperty("displayname", displayname);
+
+ if (tag != null && tag.hasKey("ExtraAttributes", 10)) {
+ NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
+
+ byte[] bytes = null;
+ for (String key : ea.getKeySet()) {
+ if (key.endsWith("backpack_data") || key.equals("new_year_cake_bag_data")) {
+ bytes = ea.getByteArray(key);
+ break;
+ }
+ }
+ if (bytes != null) {
+ JsonArray bytesArr = new JsonArray();
+ for (byte b : bytes) {
+ bytesArr.add(new JsonPrimitive(b));
+ }
+ item.add("item_contents", bytesArr);
+ }
+ if (ea.hasKey("dungeon_item_level")) {
+ item.addProperty("dungeon_item_level", ea.getInteger("dungeon_item_level"));
+ }
+ }
+
+ if (lore != null && lore.length > 0) {
+ JsonArray jsonLore = new JsonArray();
+ for (String line : lore) {
+ jsonLore.add(new JsonPrimitive(line));
+ }
+ item.add("lore", jsonLore);
+ }
+
+ item.addProperty("damage", damage);
+ if (count > 1) item.addProperty("count", count);
+ item.addProperty("nbttag", tag.toString());
+
+ return item;
+ }
+
+ private String clean(String str) {
+ return str.replaceAll("(\u00a7.)|[^0-9a-zA-Z ]", "").toLowerCase().trim();
+ }
+
+ public void showRecipe(JsonObject item) {
+ ContainerChest container = null;
+ if (Minecraft.getMinecraft().thePlayer.openContainer instanceof ContainerChest)
+ container = (ContainerChest) Minecraft.getMinecraft().thePlayer.openContainer;
+ String internalName = item.get("internalname").getAsString();
+ Set<NeuRecipe> recipesFor = getRecipesFor(internalName);
+ if (container != null &&
+ container.getLowerChestInventory().getDisplayName().getUnformattedText().equals("Craft Item")) {
+ Optional<NeuRecipe> recipe = recipesFor.stream().filter(it -> it instanceof CraftingRecipe).findAny();
+ if (recipe.isPresent()) {
+ craftingOverlay.setShownRecipe((CraftingRecipe) recipe.get());
+ return;
+ }
+ }
+ if (!item.has("clickcommand")) return;
+ String clickcommand = item.get("clickcommand").getAsString();
+ switch (clickcommand.intern()) {
+ case "viewrecipe":
+ displayGuiItemRecipe(internalName, null);
+ break;
+ case "viewoption":
+ neu.sendChatMessage("/viewpotion " + internalName.split(";")[0].toLowerCase(Locale.ROOT));
+ }
+ displayGuiItemRecipe(internalName, "");
+ }
+
+ public void showRecipe(String internalName) {
+ showRecipe(getItemInformation().get(internalName));
+ }
+
+ /**
+ * Takes an item stack and produces a JsonObject.
+ */
+ public JsonObject getJsonForItem(ItemStack stack) {
+ NBTTagCompound tag = stack.getTagCompound() == null ? new NBTTagCompound() : stack.getTagCompound();
+
+ //Item lore
+ String[] lore = new String[0];
+ if (tag.hasKey("display", 10)) {
+ NBTTagCompound display = tag.getCompoundTag("display");
+
+ if (display.hasKey("Lore", 9)) {
+ NBTTagList list = display.getTagList("Lore", 8);
+ lore = new String[list.tagCount()];
+ for (int i = 0; i < list.tagCount(); i++) {
+ lore[i] = list.getStringTagAt(i);
+ }
+ }
+ }
+
+ if (stack.getDisplayName().endsWith(" Recipes")) {
+ stack.setStackDisplayName(stack.getDisplayName().substring(0, stack.getDisplayName().length() - 8));
+ }
+
+ if (lore.length > 0 && (lore[lore.length - 1].contains("Click to view recipes!") ||
+ lore[lore.length - 1].contains("Click to view recipe!"))) {
+ String[] lore2 = new String[lore.length - 2];
+ System.arraycopy(lore, 0, lore2, 0, lore.length - 2);
+ lore = lore2;
+ }
+
+ JsonObject json = new JsonObject();
+ json.addProperty("itemid", stack.getItem().getRegistryName());
+ json.addProperty("displayname", stack.getDisplayName());
+ json.addProperty("nbttag", tag.toString());
+ json.addProperty("damage", stack.getItemDamage());
+
+ JsonArray jsonlore = new JsonArray();
+ for (String line : lore) {
+ jsonlore.add(new JsonPrimitive(line));
+ }
+ json.add("lore", jsonlore);
+
+ return json;
+ }
+
+ public String getInternalNameForItem(ItemStack stack) {
+ if (stack == null) return null;
+ NBTTagCompound tag = stack.getTagCompound();
+ return getInternalnameFromNBT(tag);
+ }
+
+ public String getUUIDForItem(ItemStack stack) {
+ if (stack == null) return null;
+ NBTTagCompound tag = stack.getTagCompound();
+ return getUUIDFromNBT(tag);
+ }
+
+ public void writeItemToFile(ItemStack stack) {
+ String internalname = getInternalNameForItem(stack);
+
+ if (internalname == null) {
+ return;
+ }
+
+ JsonObject json = getJsonForItem(stack);
+ json.addProperty("internalname", internalname);
+ json.addProperty("clickcommand", "");
+ json.addProperty("modver", NotEnoughUpdates.VERSION);
+
+ try {
+ writeJson(json, new File(new File(repoLocation, "items"), internalname + ".json"));
+ } catch (IOException ignored) {
+ }
+
+ loadItem(internalname);
+ }
+
+ public boolean displayGuiItemUsages(String internalName) {
+ if (!usagesMap.containsKey(internalName)) return false;
+ List<NeuRecipe> usages = getAvailableUsagesFor(internalName);
+ if (usages.isEmpty()) return false;
+ Minecraft.getMinecraft().displayGuiScreen(
+ new GuiItemRecipe("Item Usages", usages, this));
+ return true;
+ }
+
+ public boolean displayGuiItemRecipe(String internalName, String text) {
+ if (!recipesMap.containsKey(internalName)) return false;
+ List<NeuRecipe> recipes = getAvailableRecipesFor(internalName);
+ if (recipes.isEmpty()) return false;
+ Minecraft.getMinecraft().displayGuiScreen(
+ new GuiItemRecipe(text != null ? text : "Item Recipe", recipes, this));
+ return true;
+ }
+
+ /**
+ * Will display guiItemRecipe if a player attempted to view the recipe to an item but they didn't have the recipe
+ * unlocked. See NotEnoughUpdates#onGuiChat for where this method is called.
+ */
+ public boolean failViewItem(String text) {
+ if (viewItemAttemptID != null && !viewItemAttemptID.isEmpty()) {
+ if (System.currentTimeMillis() - viewItemAttemptTime < 500) {
+ return displayGuiItemRecipe(viewItemAttemptID, text);
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Downloads a web file, appending some HTML attributes that makes wikia give us the raw wiki syntax.
+ */
+ public CompletableFuture<File> getWebFile(String url) {
+ return CompletableFuture.supplyAsync(() -> {
+ File f = new File(configLocation, "tmp/" + Base64.getEncoder().encodeToString(url.getBytes()) + ".html");
+ if (f.exists()) {
+ return f;
+ }
+
+ try {
+ f.getParentFile().mkdirs();
+ f.createNewFile();
+ f.deleteOnExit();
+ } catch (IOException e) {
+ return null;
+ }
+ try (
+ BufferedInputStream inStream = new BufferedInputStream(new URL(
+ url + "?action=raw&templates=expand").openStream());
+ FileOutputStream fileOutputStream = new FileOutputStream(f)
+ ) {
+ byte[] dataBuffer = new byte[1024];
+ int bytesRead;
+ while ((bytesRead = inStream.read(dataBuffer, 0, 1024)) != -1) {
+ fileOutputStream.write(dataBuffer, 0, bytesRead);
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ return null;
+ }
+
+ return f;
+ });
+ }
+
+ /**
+ * Modified from https://www.journaldev.com/960/java-unzip-file-example
+ */
+ private static void unzipIgnoreFirstFolder(String zipFilePath, String destDir) {
+ File dir = new File(destDir);
+ // create output directory if it doesn't exist
+ if (!dir.exists()) dir.mkdirs();
+ FileInputStream fis;
+ //buffer for read and write data to file
+ byte[] buffer = new byte[1024];
+ try {
+ fis = new FileInputStream(zipFilePath);
+ ZipInputStream zis = new ZipInputStream(fis);
+ ZipEntry ze = zis.getNextEntry();
+ while (ze != null) {
+ if (!ze.isDirectory()) {
+ String fileName = ze.getName();
+ fileName = fileName.substring(fileName.split("/")[0].length() + 1);
+ File newFile = new File(destDir + File.separator + fileName);
+ //create directories for sub directories in zip
+ new File(newFile.getParent()).mkdirs();
+ if (!isInTree(dir, newFile)) {
+ throw new RuntimeException(
+ "Not Enough Updates detected an invalid zip file. This is a potential security risk, please report this in the Moulberry discord.");
+ }
+ FileOutputStream fos = new FileOutputStream(newFile);
+ int len;
+ while ((len = zis.read(buffer)) > 0) {
+ fos.write(buffer, 0, len);
+ }
+ fos.close();
+ }
+ //close this ZipEntry
+ zis.closeEntry();
+ ze = zis.getNextEntry();
+ }
+ //close last ZipEntry
+ zis.closeEntry();
+ zis.close();
+ fis.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private static boolean isInTree(File rootDirectory, File file) throws IOException {
+ file = file.getCanonicalFile();
+ rootDirectory = rootDirectory.getCanonicalFile();
+ while (file != null) {
+ if (file.equals(rootDirectory)) return true;
+ file = file.getParentFile();
+ }
+ return false;
+ }
+
+ /**
+ * Modified from https://www.journaldev.com/960/java-unzip-file-example
+ */
+ public static void unzip(InputStream src, File dest) {
+ //buffer for read and write data to file
+ byte[] buffer = new byte[1024];
+ try {
+ ZipInputStream zis = new ZipInputStream(src);
+ ZipEntry ze = zis.getNextEntry();
+ while (ze != null) {
+ if (!ze.isDirectory()) {
+ String fileName = ze.getName();
+ File newFile = new File(dest, fileName);
+ if (!isInTree(dest, newFile)) {
+ throw new RuntimeException(
+ "Not Enough Updates detected an invalid zip file. This is a potential security risk, please report this in the Moulberry discord.");
+ }
+ //create directories for sub directories in zip
+ new File(newFile.getParent()).mkdirs();
+ FileOutputStream fos = new FileOutputStream(newFile);
+ int len;
+ while ((len = zis.read(buffer)) > 0) {
+ fos.write(buffer, 0, len);
+ }
+ fos.close();
+ }
+ //close this ZipEntry
+ zis.closeEntry();
+ ze = zis.getNextEntry();
+ }
+ //close last ZipEntry
+ zis.closeEntry();
+ zis.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * From here to the end of the file are various helper functions for creating and writing json files, in particular
+ * json files representing skyblock item data.
+ */
+ public JsonObject createItemJson(
+ String internalname, String itemid, String displayname, String[] lore,
+ String crafttext, String infoType, String[] info,
+ String clickcommand, int damage, NBTTagCompound nbttag
+ ) {
+ return createItemJson(
+ new JsonObject(),
+ internalname,
+ itemid,
+ displayname,
+ lore,
+ crafttext,
+ infoType,
+ info,
+ clickcommand,
+ damage,
+ nbttag
+ );
+ }
+
+ public JsonObject createItemJson(
+ JsonObject base, String internalname, String itemid, String displayname, String[] lore,
+ String crafttext, String infoType, String[] info,
+ String clickcommand, int damage, NBTTagCompound nbttag
+ ) {
+ if (internalname == null || internalname.isEmpty()) {
+ return null;
+ }
+
+ JsonObject json = gson.fromJson(gson.toJson(base, JsonObject.class), JsonObject.class);
+ json.addProperty("internalname", internalname);
+ json.addProperty("itemid", itemid);
+ json.addProperty("displayname", displayname);
+ json.addProperty("crafttext", crafttext);
+ json.addProperty("clickcommand", clickcommand);
+ json.addProperty("damage", damage);
+ json.addProperty("nbttag", nbttag.toString());
+ json.addProperty("modver", NotEnoughUpdates.VERSION);
+ json.addProperty("infoType", infoType);
+
+ if (info != null && info.length > 0) {
+ JsonArray jsoninfo = new JsonArray();
+ for (String line : info) {
+ jsoninfo.add(new JsonPrimitive(line));
+ }
+ json.add("info", jsoninfo);
+ }
+
+ JsonArray jsonlore = new JsonArray();
+ for (String line : lore) {
+ jsonlore.add(new JsonPrimitive(line));
+ }
+ json.add("lore", jsonlore);
+
+ return json;
+ }
+
+ public boolean writeItemJson(
+ String internalname, String itemid, String displayname, String[] lore, String crafttext,
+ String infoType, String[] info, String clickcommand, int damage, NBTTagCompound nbttag
+ ) {
+ return writeItemJson(
+ new JsonObject(),
+ internalname,
+ itemid,
+ displayname,
+ lore,
+ crafttext,
+ infoType,
+ info,
+ clickcommand,
+ damage,
+ nbttag
+ );
+ }
+
+ public boolean writeItemJson(
+ JsonObject base, String internalname, String itemid, String displayname, String[] lore,
+ String crafttext, String infoType, String[] info, String clickcommand, int damage, NBTTagCompound nbttag
+ ) {
+ JsonObject json = createItemJson(
+ base,
+ internalname,
+ itemid,
+ displayname,
+ lore,
+ crafttext,
+ infoType,
+ info,
+ clickcommand,
+ damage,
+ nbttag
+ );
+ if (json == null) {
+ return false;
+ }
+
+ try {
+ writeJsonDefaultDir(json, internalname + ".json");
+ } catch (IOException e) {
+ return false;
+ }
+
+ loadItem(internalname);
+ return true;
+ }
+
+ public void writeJson(JsonObject json, File file) throws IOException {
+ file.createNewFile();
+
+ try (
+ BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
+ new FileOutputStream(file),
+ StandardCharsets.UTF_8
+ ))
+ ) {
+ writer.write(gson.toJson(json));
+ }
+ }
+
+ public void writeJsonDefaultDir(JsonObject json, String filename) throws IOException {
+ File file = new File(new File(repoLocation, "items"), filename);
+ writeJson(json, file);
+ }
+
+ public JsonObject readJsonDefaultDir(String filename) throws IOException {
+ File f = new File(new File(repoLocation, "items"), filename);
+ if (f.exists() && f.isFile() && f.canRead())
+ try (Reader reader = new InputStreamReader(new FileInputStream(f), StandardCharsets.UTF_8)) {
+ return gson.fromJson(reader, JsonObject.class);
+ } // rethrow io exceptions
+ return null;
+ }
+
+ public TreeMap<String, JsonObject> getItemInformation() {
+ return itemMap;
+ }
+
+ public String removeUnusedDecimal(double num) {
+ if (num % 1 == 0) {
+ return String.valueOf((int) num);
+ } else {
+ return String.valueOf(num);
+ }
+ }
+
+ public HashMap<String, String> getLoreReplacements(String petname, String tier, int level) {
+ JsonObject petnums = null;
+ if (petname != null && tier != null) {
+ petnums = Constants.PETNUMS;
+ }
+
+ HashMap<String, String> replacements = new HashMap<>();
+ if (level < 1) {
+ if (Constants.PETS != null && Constants.PETS.has("custom_pet_leveling") &&
+ Constants.PETS.getAsJsonObject("custom_pet_leveling").has(petname) &&
+ Constants.PETS.getAsJsonObject("custom_pet_leveling").getAsJsonObject(petname).has("max_level")) {
+ int maxLvl =
+ Constants.PETS.getAsJsonObject("custom_pet_leveling").getAsJsonObject(petname).get("max_level").getAsInt();
+ replacements.put("LVL", "1\u27A1" + maxLvl);
+ } else {
+ replacements.put("LVL", "1\u27A1100");
+ }
+ } else {
+ replacements.put("LVL", "" + level);
+ }
+
+ if (petnums != null) {
+ if (petnums.has(petname)) {
+ JsonObject petInfo = petnums.get(petname).getAsJsonObject();
+ if (petInfo.has(tier)) {
+ JsonObject petInfoTier = petInfo.get(tier).getAsJsonObject();
+ if (petInfoTier == null || !petInfoTier.has("1") || !petInfoTier.has("100")) {
+ return replacements;
+ }
+
+ JsonObject min = petInfoTier.get("1").getAsJsonObject();
+ JsonObject max = petInfoTier.get("100").getAsJsonObject();
+
+ if (level < 1) {
+ JsonArray otherNumsMin = min.get("otherNums").getAsJsonArray();
+ JsonArray otherNumsMax = max.get("otherNums").getAsJsonArray();
+ boolean addZero = false;
+ if (petInfoTier.has("stats_levelling_curve")) {
+ String[] stringArray = petInfoTier.get("stats_levelling_curve").getAsString().split(":");
+ if (stringArray.length == 3) {
+ int type = Integer.parseInt(stringArray[2]);
+ if (type == 1) {
+ addZero = true;
+ }
+ }
+ }
+ for (int i = 0; i < otherNumsMax.size(); i++) {
+ replacements.put(
+ "" + i,
+ (addZero ? "0\u27A1" : "") +
+ removeUnusedDecimal(Math.floor(otherNumsMin.get(i).getAsFloat() * 10) / 10f) +
+ "\u27A1" + removeUnusedDecimal(Math.floor(otherNumsMax.get(i).getAsFloat() * 10) / 10f)
+ );
+ }
+
+ for (Map.Entry<String, JsonElement> entry : max.get("statNums").getAsJsonObject().entrySet()) {
+ int statMax = (int) Math.floor(entry.getValue().getAsFloat());
+ int statMin = (int) Math.floor(min.get("statNums").getAsJsonObject().get(entry.getKey()).getAsFloat());
+ String statStr = (statMin > 0 ? "+" : "") + statMin + "\u27A1" + statMax;
+ statStr = (addZero ? "0\u27A1" : "") + statStr;
+ replacements.put(entry.getKey(), statStr);
+ }
+ } else {
+
+ int minStatsLevel = 0;
+ int maxStatsLevel = 100;
+ int statsLevelingType = -1;
+
+ int statsLevel = level;
+
+ if (petInfoTier.has("stats_levelling_curve")) {
+ String[] stringArray = petInfoTier.get("stats_levelling_curve").getAsString().split(":");
+ if (stringArray.length == 3) {
+ minStatsLevel = Integer.parseInt(stringArray[0]);
+ maxStatsLevel = Integer.parseInt(stringArray[1]);
+ statsLevelingType = Integer.parseInt(stringArray[2]);
+ switch (statsLevelingType) {
+ //Case for maybe a pet that might exist
+ case 0:
+ case 1:
+ if (level < minStatsLevel) {
+ statsLevel = 1;
+ } else if (level < maxStatsLevel) {
+ statsLevel = level - minStatsLevel + 1;
+ } else {
+ statsLevel = maxStatsLevel - minStatsLevel + 1;
+ }
+ break;
+
+ }
+ }
+ }
+ float minMix = (maxStatsLevel - (minStatsLevel - (statsLevelingType == -1 ? 0 : 1)) - statsLevel) / 99f;
+ float maxMix = (statsLevel - 1) / 99f;
+
+ JsonArray otherNumsMin = min.get("otherNums").getAsJsonArray();
+ JsonArray otherNumsMax = max.get("otherNums").getAsJsonArray();
+ for (int i = 0; i < otherNumsMax.size(); i++) {
+ float val = otherNumsMin.get(i).getAsFloat() * minMix + otherNumsMax.get(i).getAsFloat() * maxMix;
+ if (statsLevelingType == 1 && level < minStatsLevel) {
+ replacements.put("" + i, "0");
+ } else {
+ replacements.put("" + i, removeUnusedDecimal(Math.floor(val * 10) / 10f));
+ }
+ }
+
+ for (Map.Entry<String, JsonElement> entry : max.get("statNums").getAsJsonObject().entrySet()) {
+ if (statsLevelingType == 1 && level < minStatsLevel) {
+ replacements.put(entry.getKey(), "0");
+ } else {
+ float statMax = entry.getValue().getAsFloat();
+ float statMin = min.get("statNums").getAsJsonObject().get(entry.getKey()).getAsFloat();
+ float val = statMin * minMix + statMax * maxMix;
+ String statStr = (statMin > 0 ? "+" : "") + (int) Math.floor(val);
+ replacements.put(entry.getKey(), statStr);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return replacements;
+ }
+
+ public HashMap<String, String> getLoreReplacements(NBTTagCompound tag, int level) {
+ String petname = null;
+ String tier = null;
+ if (tag != null && tag.hasKey("ExtraAttributes")) {
+ NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
+ if (ea.hasKey("petInfo")) {
+ String petInfoStr = ea.getString("petInfo");
+ JsonObject petInfo = gson.fromJson(petInfoStr, JsonObject.class);
+ petname = petInfo.get("type").getAsString();
+ tier = petInfo.get("tier").getAsString();
+ if (petInfo.has("heldItem")) {
+ String heldItem = petInfo.get("heldItem").getAsString();
+ if (heldItem.equals("PET_ITEM_TIER_BOOST")) {
+ switch (tier) {
+ case "COMMON":
+ tier = "UNCOMMON";
+ break;
+ case "UNCOMMON":
+ tier = "RARE";
+ break;
+ case "RARE":
+ tier = "EPIC";
+ break;
+ case "EPIC":
+ tier = "LEGENDARY";
+ break;
+ case "LEGENDARY":
+ tier = "MYTHIC";
+ break;
+ }
+ }
+ }
+ }
+ }
+ return getLoreReplacements(petname, tier, level);
+ }
+
+ public NBTTagList processLore(JsonArray lore, HashMap<String, String> replacements) {
+ NBTTagList nbtLore = new NBTTagList();
+ for (JsonElement line : lore) {
+ String lineStr = line.getAsString();
+ if (!lineStr.contains("Click to view recipes!") &&
+ !lineStr.contains("Click to view recipe!")) {
+ for (Map.Entry<String, String> entry : replacements.entrySet()) {
+ lineStr = lineStr.replace("{" + entry.getKey() + "}", entry.getValue());
+ }
+ nbtLore.appendTag(new NBTTagString(lineStr));
+ }
+ }
+ return nbtLore;
+ }
+
+ public ItemStack jsonToStack(JsonObject json) {
+ return jsonToStack(json, true);
+ }
+
+ public ItemStack jsonToStack(JsonObject json, boolean useCache) {
+ return jsonToStack(json, useCache, true);
+ }
+
+ public ItemStack jsonToStack(JsonObject json, boolean useCache, boolean useReplacements) {
+ return jsonToStack(json, useCache, useReplacements, true);
+ }
+
+ public ItemStack jsonToStack(JsonObject json, boolean useCache, boolean useReplacements, boolean copyStack) {
+ if (json == null) return new ItemStack(Items.painting, 1, 10);
+ String internalname = json.get("internalname").getAsString();
+
+ if (useCache) {
+ ItemStack stack = itemstackCache.get(internalname);
+ if (stack != null) {
+ if (copyStack) {
+ return stack.copy();
+ } else {
+ return stack;
+ }
+ }
+ }
+
+ ItemStack stack = new ItemStack(Item.itemRegistry.getObject(
+ new ResourceLocation(json.get("itemid").getAsString())));
+
+ if (json.has("count")) {
+ stack.stackSize = json.get("count").getAsInt();
+ }
+
+ if (stack.getItem() == null) {
+ stack = new ItemStack(Item.getItemFromBlock(Blocks.stone), 0, 255); //Purple broken texture item
+ } else {
+ if (json.has("damage")) {
+ stack.setItemDamage(json.get("damage").getAsInt());
+ }
+
+ if (json.has("nbttag")) {
+ try {
+ NBTTagCompound tag = JsonToNBT.getTagFromJson(json.get("nbttag").getAsString());
+ stack.setTagCompound(tag);
+ } catch (NBTException ignored) {
+ }
+ }
+
+ HashMap<String, String> replacements = new HashMap<>();
+
+ if (useReplacements) {
+ replacements = getLoreReplacements(stack.getTagCompound(), -1);
+
+ String displayname = json.get("displayname").getAsString();
+ for (Map.Entry<String, String> entry : replacements.entrySet()) {
+ displayname = displayname.replace("{" + entry.getKey() + "}", entry.getValue());
+ }
+ stack.setStackDisplayName(displayname);
+ }
+
+ if (json.has("lore")) {
+ NBTTagCompound display = new NBTTagCompound();
+ if (stack.getTagCompound() != null && stack.getTagCompound().hasKey("display")) {
+ display = stack.getTagCompound().getCompoundTag("display");
+ }
+ display.setTag("Lore", processLore(json.get("lore").getAsJsonArray(), replacements));
+ NBTTagCompound tag = stack.getTagCompound() != null ? stack.getTagCompound() : new NBTTagCompound();
+ tag.setTag("display", display);
+ stack.setTagCompound(tag);
+ }
+ }
+
+ if (useCache) itemstackCache.put(internalname, stack);
+ if (copyStack) {
+ return stack.copy();
+ } else {
+ return stack;
+ }
+ }
+
+ public void reloadRepository() {
+ File items = new File(repoLocation, "items");
+ if (items.exists()) {
+ recipes.clear();
+ recipesMap.clear();
+ usagesMap.clear();
+
+ File[] itemFiles = new File(repoLocation, "items").listFiles();
+ if (itemFiles != null) {
+ for (File f : itemFiles) {
+ String internalname = f.getName().substring(0, f.getName().length() - 5);
+ loadItem(internalname);
+ }
+ }
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
index 080353a7..d1bfed14 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
@@ -8,18 +8,30 @@ import io.github.moulberry.notenoughupdates.auction.CustomAHGui;
import io.github.moulberry.notenoughupdates.core.BackgroundBlur;
import io.github.moulberry.notenoughupdates.core.GuiScreenElementWrapper;
import io.github.moulberry.notenoughupdates.core.util.lerp.LerpingInteger;
-import io.github.moulberry.notenoughupdates.infopanes.*;
+import io.github.moulberry.notenoughupdates.infopanes.DevInfoPane;
+import io.github.moulberry.notenoughupdates.infopanes.InfoPane;
+import io.github.moulberry.notenoughupdates.infopanes.TextInfoPane;
import io.github.moulberry.notenoughupdates.itemeditor.NEUItemEditor;
import io.github.moulberry.notenoughupdates.mbgui.MBAnchorPoint;
import io.github.moulberry.notenoughupdates.mbgui.MBGuiElement;
import io.github.moulberry.notenoughupdates.mbgui.MBGuiGroupAligned;
import io.github.moulberry.notenoughupdates.mbgui.MBGuiGroupFloating;
+import io.github.moulberry.notenoughupdates.miscfeatures.PetInfoOverlay;
import io.github.moulberry.notenoughupdates.miscfeatures.SunTzu;
+import io.github.moulberry.notenoughupdates.miscgui.GuiPriceGraph;
import io.github.moulberry.notenoughupdates.options.NEUConfigEditor;
-import io.github.moulberry.notenoughupdates.util.*;
+import io.github.moulberry.notenoughupdates.util.Constants;
+import io.github.moulberry.notenoughupdates.util.LerpingFloat;
+import io.github.moulberry.notenoughupdates.util.SpecialColour;
+import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.*;
+import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.gui.Gui;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.client.gui.GuiTextField;
+import net.minecraft.client.gui.inventory.GuiChest;
import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.client.gui.inventory.GuiInventory;
import net.minecraft.client.renderer.*;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.entity.RenderManager;
@@ -31,6 +43,8 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Items;
+import net.minecraft.inventory.ContainerChest;
+import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@@ -42,17 +56,16 @@ import net.minecraft.util.Matrix4f;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.client.ClientCommandHandler;
-import org.apache.commons.lang3.StringUtils;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL14;
import org.lwjgl.util.vector.Vector2f;
-import java.awt.*;
+import java.awt.Color;
import java.lang.reflect.InvocationTargetException;
-import java.util.List;
import java.util.*;
+import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -61,2276 +74,2800 @@ import java.util.concurrent.atomic.AtomicReference;
import static io.github.moulberry.notenoughupdates.util.GuiTextures.*;
public class NEUOverlay extends Gui {
-
- private static final ResourceLocation SUPERGEHEIMNISVERMOGEN = new ResourceLocation("notenoughupdates:supersecretassets/bald.png");
- private static final ResourceLocation SEARCH_BAR = new ResourceLocation("notenoughupdates:search_bar.png");
- private static final ResourceLocation SEARCH_BAR_GOLD = new ResourceLocation("notenoughupdates:search_bar_gold.png");
-
- private NEUManager manager;
-
- private String mobRegex = ".*?((_MONSTER)|(_ANIMAL)|(_MINIBOSS)|(_BOSS)|(_SC))$";
- private String petRegex = ".*?;[0-5]$";
-
- private ResourceLocation[] sortIcons = new ResourceLocation[] {
- sort_all, sort_mob, sort_pet, sort_tool, sort_armor, sort_accessory
- };
- private ResourceLocation[] sortIconsActive = new ResourceLocation[] {
- sort_all_active, sort_mob_active, sort_pet_active, sort_tool_active, sort_armor_active, sort_accessory_active
- };
-
- private ResourceLocation[] orderIcons = new ResourceLocation[] {
- order_alphabetical, order_rarity, order_value
- };
- private ResourceLocation[] orderIconsActive = new ResourceLocation[] {
- order_alphabetical_active, order_rarity_active, order_value_active
- };
-
- //Various constants used for GUI structure
- private final int searchBarYOffset = 10;
- private final int searchBarPadding = 2;
-
- private float oldWidthMult = 0;
-
- public static final int ITEM_PADDING = 4;
- public static final int ITEM_SIZE = 16;
-
- private Color bg = new Color(90, 90, 140, 50);
- private Color fg = new Color(100,100,100, 255);
-
- private InfoPane activeInfoPane = null;
-
- private TreeSet<JsonObject> searchedItems = null;
- private final List<JsonObject> searchedItemsArr = new ArrayList<>();
-
- private HashMap<String, List<String>> searchedItemsSubgroup = new HashMap<>();
-
- private long selectedItemMillis = 0;
- private int selectedItemGroupX = -1;
- private int selectedItemGroupY = -1;
- private List<JsonObject> selectedItemGroup = null;
-
- private boolean itemPaneOpen = false;
-
- private int page = 0;
-
- private LerpingFloat itemPaneOffsetFactor = new LerpingFloat(1);
- private LerpingInteger itemPaneTabOffset = new LerpingInteger(20, 50);
- private LerpingFloat infoPaneOffsetFactor = new LerpingFloat(0);
-
- public boolean searchMode = false;
- private long millisLastLeftClick = 0;
- private long millisLastMouseMove = 0;
- private int lastMouseX = 0;
- private int lastMouseY = 0;
-
- public static final int overlayColourDark = new Color(0, 0, 0, 120).getRGB();
- public static final int overlayColourLight = new Color(255, 255, 255, 120).getRGB();
-
- boolean mouseDown = false;
-
- private boolean redrawItems = false;
-
- private boolean searchBarHasFocus = false;
- private GuiTextField textField = new GuiTextField(0, null, 0, 0, 0, 0);
-
- private static final int COMPARE_MODE_ALPHABETICAL = 0;
- private static final int COMPARE_MODE_RARITY = 1;
- private static final int COMPARE_MODE_VALUE = 2;
-
- private static final int SORT_MODE_ALL = 0;
- private static final int SORT_MODE_MOB = 1;
- private static final int SORT_MODE_PET = 2;
- private static final int SORT_MODE_TOOL = 3;
- private static final int SORT_MODE_ARMOR = 4;
- private static final int SORT_MODE_ACCESSORY = 5;
-
- private boolean disabled = false;
-
- private int lastScreenWidth;
- private int lastScreenHeight;
- private int lastScale;
-
- private List<String> textToDisplay = null;
-
- public MBGuiGroupFloating guiGroup = null;
-
- public NEUOverlay(NEUManager manager) {
- this.manager = manager;
- textField.setFocused(true);
- textField.setCanLoseFocus(false);
-
- guiGroup = createGuiGroup();
- }
-
- private MBGuiElement createSearchBar() {
- return new MBGuiElement() {
- public int getWidth() {
- int paddingUnscaled = getPaddingUnscaled();
-
- return getSearchBarXSize() + 2*paddingUnscaled;
- }
-
- public int getHeight() {
- int paddingUnscaled = getPaddingUnscaled();
-
- return getSearchBarYSize() + 2*paddingUnscaled;
- }
-
- @Override
- public void mouseClick(float x, float y, int mouseX, int mouseY) {
- if(!NotEnoughUpdates.INSTANCE.config.toolbar.searchBar) {
- return;
- }
- if(Mouse.getEventButtonState()) {
- setSearchBarFocus(true);
- if(Mouse.getEventButton() == 1) { //Right mouse button down
- textField.setText("");
- updateSearch();
- } else {
- if(System.currentTimeMillis() - millisLastLeftClick < 300) {
- searchMode = !searchMode;
- if (searchMode && NotEnoughUpdates.INSTANCE.config.hidden.firstTimeSearchFocus) {
- NEUEventListener.displayNotification(Lists.newArrayList(
- "\u00a7eSearch Highlight",
- "\u00a77In this mode NEU will gray out non matching items in",
- "\u00a77your inventory or chests.",
- "\u00a77This allows you easily find items as the item will stand out.",
- "\u00a77To toggle this please double click on the search bar in your inventory.",
- "\u00a77",
- "\u00a77Press X on your keyboard to close this notifcation"), true, true);
- NotEnoughUpdates.INSTANCE.config.hidden.firstTimeSearchFocus = false;
-
- }
- }
- textField.setCursorPosition(getClickedIndex(mouseX, mouseY));
- millisLastLeftClick = System.currentTimeMillis();
- }
- }
- }
-
- @Override
- public void mouseClickOutside() {
- setSearchBarFocus(false);
- }
-
- @Override
- public void render(float x, float y) {
- if(!NotEnoughUpdates.INSTANCE.config.toolbar.searchBar) {
- return;
- }
- FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
- int paddingUnscaled = getPaddingUnscaled();
-
- GlStateManager.color(1, 1, 1, 1);
- if(searchMode) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(SEARCH_BAR_GOLD);
- } else {
- Minecraft.getMinecraft().getTextureManager().bindTexture(SEARCH_BAR);
- }
-
- int w = getWidth();
- int h = getHeight();
-
- for(int yIndex=0; yIndex<=2; yIndex++) {
- for(int xIndex=0; xIndex<=2; xIndex++) {
- float uMin = 0;
- float uMax = 4/20f;
- int partX = (int)x;
- int partW = 4;
- if(xIndex == 1) {
- partX += 4;
- uMin = 4/20f;
- uMax = 16/20f;
- partW = w-8;
- } else if(xIndex == 2) {
- partX += w-4;
- uMin = 16/20f;
- uMax = 20/20f;
- }
-
- float vMin = 0;
- float vMax = 4/20f;
- int partY = (int)y;
- int partH = 4;
- if(yIndex == 1) {
- partY += 4;
- vMin = 4/20f;
- vMax = 16/20f;
- partH = h-8;
- } else if(yIndex == 2) {
- partY += h-4;
- vMin = 16/20f;
- vMax = 20/20f;
- }
-
- Utils.drawTexturedRect(partX, partY, partW, partH, uMin, uMax, vMin, vMax, GL11.GL_NEAREST);
- }
- }
-
- //Search bar text
- fr.drawString(textField.getText(), (int)x + 5,
- (int) y-4 + getHeight()/2, Color.WHITE.getRGB());
-
- //Determines position of cursor. Cursor blinks on and off every 500ms.
- if(searchBarHasFocus && System.currentTimeMillis()%1000>500) {
- String textBeforeCursor = textField.getText().substring(0, textField.getCursorPosition());
- int textBeforeCursorWidth = fr.getStringWidth(textBeforeCursor);
- drawRect((int)x + 5 + textBeforeCursorWidth,
- (int)y-5 + getHeight()/2,
- (int)x + 5 + textBeforeCursorWidth+1,
- (int)y-4+9 + getHeight()/2, Color.WHITE.getRGB());
- }
-
- String selectedText = textField.getSelectedText();
- if(!selectedText.isEmpty()) {
- int selectionWidth = fr.getStringWidth(selectedText);
-
- int leftIndex = Math.min(textField.getCursorPosition(), textField.getSelectionEnd());
- String textBeforeSelection = textField.getText().substring(0, leftIndex);
- int textBeforeSelectionWidth = fr.getStringWidth(textBeforeSelection);
-
- drawRect((int)x + 5 + textBeforeSelectionWidth,
- (int)y-5 + getHeight()/2,
- (int)x + 5 + textBeforeSelectionWidth + selectionWidth,
- (int)y-4+9 + getHeight()/2, Color.LIGHT_GRAY.getRGB());
-
- fr.drawString(selectedText,
- (int)x + 5 + textBeforeSelectionWidth,
- (int)y-4 + getHeight()/2, Color.BLACK.getRGB());
- }
-
- }
-
- @Override
- public void recalculate() {
- }
- };
- }
-
- private MBGuiElement createSettingsButton(NEUOverlay overlay) {
- return new MBGuiElement() {
- @Override
- public int getWidth() {
- return getSearchBarYSize()+getPaddingUnscaled()*2;
- }
-
- @Override
- public int getHeight() {
- return getWidth();
- }
-
- @Override
- public void recalculate() {
- }
-
- @Override
- public void mouseClick(float x, float y, int mouseX, int mouseY) {
- if(!NotEnoughUpdates.INSTANCE.config.toolbar.enableSettingsButton) {
- return;
- }
- if(Mouse.getEventButtonState()) {
- NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper(NEUConfigEditor.editor);
- }
- }
-
- @Override
- public void mouseClickOutside() {
- }
-
- @Override
- public void render(float x, float y) {
- int paddingUnscaled = getPaddingUnscaled();
- int searchYSize = getSearchBarYSize();
-
-
- if(!NotEnoughUpdates.INSTANCE.config.toolbar.enableSettingsButton) {
- return;
- }
- Minecraft.getMinecraft().getTextureManager().bindTexture(quickcommand_background);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(x, y,
- searchYSize + paddingUnscaled * 2, searchYSize + paddingUnscaled * 2, GL11.GL_NEAREST);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(settings);
- GlStateManager.color(1f, 1f, 1f, 1f);
- Utils.drawTexturedRect((int) x + paddingUnscaled, (int) y + paddingUnscaled,
- searchYSize, searchYSize);
-
- GlStateManager.bindTexture(0);
- }
- };
- }
-
- private MBGuiElement createHelpButton(NEUOverlay overlay) {
- return new MBGuiElement() {
- @Override
- public int getWidth() {
- return getSearchBarYSize()+getPaddingUnscaled()*2;
- }
-
- @Override
- public int getHeight() {
- return getWidth();
- }
-
- @Override
- public void recalculate() {
- }
-
- @Override
- public void mouseClick(float x, float y, int mouseX, int mouseY) {
- if(!NotEnoughUpdates.INSTANCE.config.toolbar.enableHelpButton){
- return;
- }
- if(Mouse.getEventButtonState()) {
- //displayInformationPane(HTMLInfoPane.createFromWikiUrl(overlay, manager, "Help",
- // "https://moulberry.github.io/files/neu_help.html"));
- //Minecraft.getMinecraft().displayGuiScreen(new HelpGUI());
- ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/neuhelp");
- Utils.playPressSound();
- }
- }
-
- @Override
- public void mouseClickOutside() {
- }
-
- @Override
- public void render(float x, float y) {
- int paddingUnscaled = getPaddingUnscaled();
- int searchYSize = getSearchBarYSize();
-
- if(!NotEnoughUpdates.INSTANCE.config.toolbar.enableHelpButton) {
- return;
- }
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(quickcommand_background);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(x, y,
- searchYSize + paddingUnscaled * 2, searchYSize + paddingUnscaled * 2, GL11.GL_NEAREST);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(help);
- GlStateManager.color(1f, 1f, 1f, 1f);
- Utils.drawTexturedRect((int) x + paddingUnscaled, (int) y + paddingUnscaled,
- getSearchBarYSize(), getSearchBarYSize());
- GlStateManager.bindTexture(0);
-
- }
- };
- }
-
- private MBGuiElement createQuickCommand(String quickCommandStr) {
- return new MBGuiElement() {
- @Override
- public int getWidth() {
- return getSearchBarYSize()+getPaddingUnscaled()*2;
- }
-
- @Override
- public int getHeight() {
- return getWidth();
- }
-
- @Override
- public void recalculate() {
- }
-
- @Override
- public void mouseClick(float x, float y, int mouseX, int mouseY) {
- if(!NotEnoughUpdates.INSTANCE.config.toolbar.quickCommands) return;
-
- if((NotEnoughUpdates.INSTANCE.config.toolbar.quickCommandsClickType != 0 && Mouse.getEventButtonState()) ||
- (NotEnoughUpdates.INSTANCE.config.toolbar.quickCommandsClickType == 0 && !Mouse.getEventButtonState() && Mouse.getEventButton() != -1)) {
- if(quickCommandStr.contains(":")) {
- String command = quickCommandStr.split(":")[0].trim();
- if(command.startsWith("/")) {
- NotEnoughUpdates.INSTANCE.sendChatMessage(command);
- } else {
- ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/"+command);
- }
- Utils.playPressSound();
- }
- }
- }
-
- @Override
- public void mouseClickOutside() {
- }
-
- @Override
- public void render(float x, float y) {
- if(!NotEnoughUpdates.INSTANCE.config.toolbar.quickCommands) return;
-
- int paddingUnscaled = getPaddingUnscaled();
- int bigItemSize = getSearchBarYSize();
-
- String[] quickCommandStrSplit = quickCommandStr.split(":");
- if(quickCommandStrSplit.length!=3) {
- return;
- }
- String display = quickCommandStrSplit[2];
- ItemStack render = null;
- float extraScale = 1;
- if(display.length() > 20) { //Custom head
- render = new ItemStack(Items.skull, 1, 3);
- NBTTagCompound nbt = new NBTTagCompound();
- NBTTagCompound skullOwner = new NBTTagCompound();
- NBTTagCompound properties = new NBTTagCompound();
- NBTTagList textures = new NBTTagList();
- NBTTagCompound textures_0 = new NBTTagCompound();
-
- String uuid = UUID.nameUUIDFromBytes(display.getBytes()).toString();
- skullOwner.setString("Id", uuid);
- skullOwner.setString("Name", uuid);
-
- textures_0.setString("Value", display);
- textures.appendTag(textures_0);
-
- properties.setTag("textures", textures);
- skullOwner.setTag("Properties", properties);
- nbt.setTag("SkullOwner", skullOwner);
- render.setTagCompound(nbt);
-
- extraScale = 1.3f;
- } else if(manager.getItemInformation().containsKey(display)) {
- render = manager.jsonToStack(manager.getItemInformation().get(display), true, true);
- } else {
- Item item = Item.itemRegistry.getObject(new ResourceLocation(display.toLowerCase()));
- if(item != null) {
- render = new ItemStack(item);
- }
- }
- if(render != null) {
- NBTTagCompound tag = render.getTagCompound() != null ? render.getTagCompound() : new NBTTagCompound();
- tag.setString("qc_id", quickCommandStrSplit[0].toLowerCase().trim());
- render.setTagCompound(tag);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(quickcommand_background);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(x, y,
- bigItemSize + paddingUnscaled*2, bigItemSize + paddingUnscaled*2, GL11.GL_NEAREST);
-
- int mouseX = Mouse.getX() * Utils.peekGuiScale().getScaledWidth() / Minecraft.getMinecraft().displayWidth;
- int mouseY = Utils.peekGuiScale().getScaledHeight() - Mouse.getY() * Utils.peekGuiScale().getScaledHeight() / Minecraft.getMinecraft().displayHeight - 1;
-
- if(mouseX > x && mouseX < x+bigItemSize) {
- if(mouseY > y && mouseY < y+bigItemSize) {
- textToDisplay = new ArrayList<>();
- textToDisplay.add(EnumChatFormatting.GRAY+quickCommandStrSplit[1]);
- }
- }
-
- GlStateManager.enableDepth();
- float itemScale = bigItemSize/(float)ITEM_SIZE*extraScale;
- GlStateManager.pushMatrix();
- GlStateManager.scale(itemScale, itemScale, 1);
- GlStateManager.translate((x-(extraScale-1)*bigItemSize/2+paddingUnscaled) /itemScale,
- (y-(extraScale-1)*bigItemSize/2+paddingUnscaled)/itemScale, 0f);
- Utils.drawItemStack(render, 0, 0);
- GlStateManager.popMatrix();
- }
- }
- };
- }
-
- private MBGuiGroupAligned createQuickCommandGroup() {
- List<MBGuiElement> children = new ArrayList<>();
- for(String quickCommand : NotEnoughUpdates.INSTANCE.config.hidden.quickCommands) {
- children.add(createQuickCommand(quickCommand));
- }
- return new MBGuiGroupAligned(children, false) {
- public int getPadding() {
- return getPaddingUnscaled()*4;
- }
- };
- }
-
- private MBGuiGroupAligned createSearchBarGroup() {
- List<MBGuiElement> children = Lists.newArrayList(createSettingsButton(this), createSearchBar(), createHelpButton(this));
- return new MBGuiGroupAligned(children, false) {
- public int getPadding() {
- return getPaddingUnscaled()*4;
- }
- };
- }
-
- private MBGuiGroupFloating createGuiGroup() {
- LinkedHashMap<MBGuiElement, MBAnchorPoint> map = new LinkedHashMap<>();
-
- MBAnchorPoint searchBarAnchor = MBAnchorPoint.createFromString(NotEnoughUpdates.INSTANCE.config.hidden.overlaySearchBar);
- MBAnchorPoint quickCommandAnchor = MBAnchorPoint.createFromString(NotEnoughUpdates.INSTANCE.config.hidden.overlayQuickCommand);
-
- searchBarAnchor = searchBarAnchor != null ? searchBarAnchor :
- new MBAnchorPoint(MBAnchorPoint.AnchorPoint.BOTMID, new Vector2f(0, -searchBarYOffset));
- quickCommandAnchor = quickCommandAnchor != null ? quickCommandAnchor :
- new MBAnchorPoint(MBAnchorPoint.AnchorPoint.BOTMID, new Vector2f(0,
- -searchBarYOffset-getSearchBarYSize()-getPaddingUnscaled()*4));
-
- map.put(createSearchBarGroup(), searchBarAnchor);
- map.put(createQuickCommandGroup(), quickCommandAnchor);
-
- return new MBGuiGroupFloating(Utils.peekGuiScale().getScaledWidth(), Utils.peekGuiScale().getScaledHeight(), map);
- }
-
- public void resetAnchors(boolean onlyIfNull) {
- MBAnchorPoint searchBarAnchor = MBAnchorPoint.createFromString(NotEnoughUpdates.INSTANCE.config.hidden.overlaySearchBar);
- MBAnchorPoint quickCommandAnchor = MBAnchorPoint.createFromString(NotEnoughUpdates.INSTANCE.config.hidden.overlayQuickCommand);
-
- if(onlyIfNull) {
- searchBarAnchor = searchBarAnchor != null ? null :
- new MBAnchorPoint(MBAnchorPoint.AnchorPoint.BOTMID, new Vector2f(0, -searchBarYOffset));
- quickCommandAnchor = quickCommandAnchor != null ? null :
- new MBAnchorPoint(MBAnchorPoint.AnchorPoint.BOTMID, new Vector2f(0,
- -searchBarYOffset-getSearchBarYSize()-getPaddingUnscaled()*4));
- } else {
- searchBarAnchor = searchBarAnchor != null ? searchBarAnchor :
- new MBAnchorPoint(MBAnchorPoint.AnchorPoint.BOTMID, new Vector2f(0, -searchBarYOffset));
- quickCommandAnchor = quickCommandAnchor != null ? quickCommandAnchor :
- new MBAnchorPoint(MBAnchorPoint.AnchorPoint.BOTMID, new Vector2f(0,
- -searchBarYOffset-getSearchBarYSize()-getPaddingUnscaled()*4));
- }
-
-
- int index = 0;
- Set<MBGuiElement> set = new LinkedHashSet<>(guiGroup.getChildrenMap().keySet());
- for(MBGuiElement element : set) {
- switch(index) {
- case 0:
- if(searchBarAnchor == null) continue;
- guiGroup.getChildrenMap().get(element).anchorPoint = searchBarAnchor.anchorPoint;
- guiGroup.getChildrenMap().get(element).offset = searchBarAnchor.offset;
- break;
- case 1:
- if(quickCommandAnchor == null) continue;
- guiGroup.getChildrenMap().get(element).anchorPoint = quickCommandAnchor.anchorPoint;
- guiGroup.getChildrenMap().get(element).offset = quickCommandAnchor.offset;
- break;
- }
- index++;
- }
- }
-
- /**
- * Disables searchBarFocus and resets the item pane position. Called whenever NEUOverlay is opened.
- */
- public void reset() {
- searchBarHasFocus = false;
- if(!(searchMode || (NotEnoughUpdates.INSTANCE.config.itemlist.keepopen && itemPaneOpen))) {
- itemPaneOpen = false;
- itemPaneOffsetFactor.setValue(1);
- itemPaneTabOffset.setValue(20);
- }
- if(activeInfoPane != null) activeInfoPane.reset();
- guiGroup.recalculate();
- }
-
- /**
- * Calls #displayInformationPane with a HTMLInfoPane created from item.info and item.infoType.
- */
- public void showInfo(JsonObject item) {
- if(item.has("info") && item.has("infoType")) {
- JsonArray lore = item.get("info").getAsJsonArray();
- String[] loreA = new String[lore.size()];
- for (int i = 0; i < lore.size(); i++) loreA[i] = lore.get(i).getAsString();
- String loreS = StringUtils.join(loreA, "\n");
-
- String internalname = item.get("internalname").getAsString();
- String name = item.get("displayname").getAsString();
- switch(item.get("infoType").getAsString()) {
- case "WIKI_URL":
- displayInformationPane(HTMLInfoPane.createFromWikiUrl(this, manager, name, loreS));
- return;
- case "WIKI":
- displayInformationPane(HTMLInfoPane.createFromWiki(this, manager, name, internalname, loreS));
- return;
- case "HTML":
- displayInformationPane(new HTMLInfoPane(this, manager, name, internalname, loreS));
- return;
- }
- displayInformationPane(new TextInfoPane(this, manager, name, loreS));
- }
- }
-
- public void mouseInputInv() {
- if(Minecraft.getMinecraft().currentScreen instanceof GuiContainer) {
- if(Mouse.getEventButton() == manager.keybindItemSelect.getKeyCode()+100 && NotEnoughUpdates.INSTANCE.config.toolbar.searchBar) {
- Slot slot = Utils.getSlotUnderMouse((GuiContainer)Minecraft.getMinecraft().currentScreen);
- if(slot != null) {
- ItemStack hover = slot.getStack();
- if(hover != null) {
- textField.setText("id:"+manager.getInternalNameForItem(hover));
- itemPaneOpen = true;
- updateSearch();
- }
- }
- }
- }
- }
-
- /**
- * Handles the mouse input, cancelling the forge event if a NEU gui element is clicked.
- */
- public boolean mouseInput() {
- if(disabled) {
- return false;
- }
-
- Utils.pushGuiScale(NotEnoughUpdates.INSTANCE.config.itemlist.paneGuiScale);
-
- int width = Utils.peekGuiScale().getScaledWidth();
- int height = Utils.peekGuiScale().getScaledHeight();
- int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
- int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
-
- //if(lastMouseX != mouseX || lastMouseY != mouseY) {
- // millisLastMouseMove = System.currentTimeMillis();
- //}
-
- lastMouseX = mouseX;
- lastMouseY = mouseY;
-
- if(Mouse.getEventButtonState()) {
- mouseDown = true;
- } else if(Mouse.getEventButton() != -1) {
- mouseDown = false;
- }
-
- //Unfocuses the search bar by default. Search bar is focused if the click is on the bar itself.
- if(Mouse.getEventButtonState()) setSearchBarFocus(false);
-
- guiGroup.mouseClick(0, 0, mouseX, mouseY);
-
- if(selectedItemGroup != null) {
- int selectedX = Math.min(selectedItemGroupX, width-getBoxPadding()-18*selectedItemGroup.size());
- if(mouseY > selectedItemGroupY+17 && mouseY < selectedItemGroupY+35) {
- for(int i=0; i<selectedItemGroup.size(); i++) {
- if(mouseX >= selectedX-1+18*i && mouseX <= selectedX+17+18*i) {
- JsonObject item = selectedItemGroup.get(i);
- if (item != null) {
- if(Mouse.getEventButton() == 0) {
- manager.showRecipe(item);
- } else if(Mouse.getEventButton() == 1) {
- showInfo(item);
- } else if(Mouse.getEventButton() == manager.keybindItemSelect.getKeyCode()+100 && NotEnoughUpdates.INSTANCE.config.toolbar.searchBar) {
- textField.setText("id:"+item.get("internalname").getAsString());
- updateSearch();
- searchMode = true;
- }
- }
- Utils.pushGuiScale(-1);
- return true;
- }
- }
- }
- }
-
- //Item selection (right) gui
- if(mouseX > width*getItemPaneOffsetFactor()) {
- if(!Mouse.getEventButtonState()) {
- Utils.pushGuiScale(-1);
- return true; //End early if the mouse isn't pressed, but still cancel event.
- }
-
- AtomicBoolean clickedItem = new AtomicBoolean(false);
- iterateItemSlots(new ItemSlotConsumer() {
- public void consume(int x, int y, int id) {
- if(mouseX >= x-1 && mouseX <= x+ITEM_SIZE+1) {
- if(mouseY >= y-1 && mouseY <= y+ITEM_SIZE+1) {
- clickedItem.set(true);
-
- JsonObject item = getSearchedItemPage(id);
- if (item != null) {
- if(Mouse.getEventButton() == 0) {
- manager.showRecipe(item);
- } else if(Mouse.getEventButton() == 1) {
- showInfo(item);
- } else if(Mouse.getEventButton() == manager.keybindItemSelect.getKeyCode()+100 && NotEnoughUpdates.INSTANCE.config.toolbar.searchBar) {
- textField.setText("id:"+item.get("internalname").getAsString());
- updateSearch();
- searchMode = true;
- }
- }
- }
- }
- }
- });
- if(!clickedItem.get()) {
- int paneWidth = (int)(width/3*getWidthMult());
- int leftSide = (int)(width*getItemPaneOffsetFactor());
- int rightSide = leftSide+paneWidth-getBoxPadding()-getItemBoxXPadding();
- leftSide = leftSide+getBoxPadding()+getItemBoxXPadding();
-
- FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
- int maxPages = getMaxPages();
- String name = Utils.peekGuiScale().getScaleFactor()<4?"Page: ":"";
- float maxStrLen = fr.getStringWidth(EnumChatFormatting.BOLD+name + maxPages + "/" + maxPages);
- float maxButtonXSize = (rightSide-leftSide+2 - maxStrLen*0.5f - 10)/2f;
- int buttonXSize = (int)Math.min(maxButtonXSize, getSearchBarYSize()*480/160f);
- int ySize = (int)(buttonXSize/480f*160);
- int yOffset = (int)((getSearchBarYSize()-ySize)/2f);
- int top = getBoxPadding()+yOffset;
-
- if(mouseY >= top && mouseY <= top+ySize) {
- int leftPrev = leftSide-1;
- if(mouseX > leftPrev && mouseX < leftPrev+buttonXSize) { //"Previous" button
- setPage(page-1);
- Utils.playPressSound();
- }
- int leftNext = rightSide+1-buttonXSize;
- if(mouseX > leftNext && mouseX < leftNext+buttonXSize) { //"Next" button
- setPage(page+1);
- Utils.playPressSound();
- }
- }
-
- float sortIconsMinX = (sortIcons.length+orderIcons.length)*(ITEM_SIZE+ITEM_PADDING)+ITEM_SIZE;
- float availableX = rightSide-leftSide;
- float sortOrderScaleFactor = Math.min(1, availableX / sortIconsMinX);
-
- int scaledITEM_SIZE = (int)(ITEM_SIZE*sortOrderScaleFactor);
- int scaledItemPaddedSize = (int)((ITEM_SIZE+ITEM_PADDING)*sortOrderScaleFactor);
- int iconTop = height-getBoxPadding()-(ITEM_SIZE+scaledITEM_SIZE)/2-1;
-
- if(mouseY >= iconTop && mouseY <= iconTop+scaledITEM_SIZE) {
- for(int i=0; i<orderIcons.length; i++) {
- int orderIconX = leftSide+i*scaledItemPaddedSize;
- if(mouseX >= orderIconX && mouseX <= orderIconX+scaledITEM_SIZE) {
- if(Mouse.getEventButton() == 0) {
- NotEnoughUpdates.INSTANCE.config.hidden.compareMode = i;
- updateSearch();
- Utils.playPressSound();
- } else if(Mouse.getEventButton() == 1) {
- NotEnoughUpdates.INSTANCE.config.hidden.compareAscending.set(i,
- !NotEnoughUpdates.INSTANCE.config.hidden.compareAscending.get(i));
- updateSearch();
- Utils.playPressSound();
- }
- }
- }
-
- for(int i=0; i<sortIcons.length; i++) {
- int sortIconX = rightSide-scaledITEM_SIZE-i*scaledItemPaddedSize;
- if(mouseX >= sortIconX && mouseX <= sortIconX+scaledITEM_SIZE) {
- NotEnoughUpdates.INSTANCE.config.hidden.sortMode = i;
- updateSearch();
- Utils.playPressSound();
- }
- }
- }
- }
- Utils.pushGuiScale(-1);
- return true;
- }
-
- //Clicking on "close info pane" button
- if(mouseX > width*getInfoPaneOffsetFactor()-getBoxPadding()-8 && mouseX < width*getInfoPaneOffsetFactor()-getBoxPadding()+8) {
- if(mouseY > getBoxPadding()-8 && mouseY < getBoxPadding()+8) {
- if(Mouse.getEventButtonState() && Mouse.getEventButton() < 2) { //Left or right click up
- displayInformationPane(null);
- Utils.pushGuiScale(-1);
- return true;
- }
- }
- }
-
- if(activeInfoPane != null) {
- if(mouseX < width*getInfoPaneOffsetFactor()) {
- activeInfoPane.mouseInput(width, height, mouseX, mouseY, mouseDown);
- Utils.pushGuiScale(-1);
- return true;
- } else if(Mouse.getEventButton() <= 1 && Mouse.getEventButtonState()) { //Left or right click
- activeInfoPane.mouseInputOutside();
- }
- }
-
- Utils.pushGuiScale(-1);
- return false;
- }
-
- public int getPaddingUnscaled() {
- int paddingUnscaled = searchBarPadding/Utils.peekGuiScale().getScaleFactor();
- if(paddingUnscaled < 1) paddingUnscaled = 1;
-
- return paddingUnscaled;
- }
-
- public GuiTextField getTextField() {
- return textField;
- }
-
- /**
- * Returns searchBarXSize, scaled by 0.8 if gui scale == AUTO.
- */
- public int getSearchBarXSize() {
- int searchBarXSize = NotEnoughUpdates.INSTANCE.config.toolbar.searchBarWidth;
- if(Utils.peekGuiScale().getScaleFactor()==4) return (int)(searchBarXSize*0.8);
- return searchBarXSize;
- }
-
- /**
- * Sets the activeInfoPane and sets the target of the infoPaneOffsetFactor to make the infoPane "slide" out.
- */
- public void displayInformationPane(InfoPane pane) {
- if(pane == null) {
- infoPaneOffsetFactor.setTarget(0);
- } else {
- infoPaneOffsetFactor.setTarget(1/3f);
- }
- infoPaneOffsetFactor.resetTimer();
- this.activeInfoPane = pane;
- }
-
- public InfoPane getActiveInfoPane() {
- return activeInfoPane;
- }
-
- /**
- * Finds the index of the character inside the search bar that was clicked, used to set the caret.
- */
- public int getClickedIndex(int mouseX, int mouseY) {
- int width = Utils.peekGuiScale().getScaledWidth();
- int height = Utils.peekGuiScale().getScaledHeight();
-
- int xComp = mouseX - (width/2 - getSearchBarXSize()/2 + 5);
-
- String trimmed = Minecraft.getMinecraft().fontRendererObj.trimStringToWidth(textField.getText(), xComp);
- int linePos = trimmed.length();
- if(linePos != textField.getText().length()) {
- char after = textField.getText().charAt(linePos);
- int trimmedWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(trimmed);
- int charWidth = Minecraft.getMinecraft().fontRendererObj.getCharWidth(after);
- if(trimmedWidth + charWidth/2 < xComp-5) {
- linePos++;
- }
- }
- return linePos;
- }
-
- public void setSearchBarFocus(boolean focus) {
- if(focus) {
- itemPaneOpen = true;
- }
- searchBarHasFocus = focus;
- }
-
- /**
- * Handles the keyboard input, cancelling the forge event if the search bar has focus.
- */
- public boolean keyboardInput(boolean hoverInv) {
- if(Minecraft.getMinecraft().currentScreen == null) return false;
- Keyboard.enableRepeatEvents(true);
-
- int keyPressed = Keyboard.getEventKey() == 0 ? Keyboard.getEventCharacter()+256 : Keyboard.getEventKey();
-
- if(disabled) {
- if(Keyboard.getEventKeyState() && keyPressed == manager.keybindToggleDisplay.getKeyCode()) {
- disabled = !disabled;
- }
- return false;
- }
-
- if(Keyboard.isKeyDown(Keyboard.KEY_Y) && NotEnoughUpdates.INSTANCE.config.hidden.dev) {
- displayInformationPane(new DevInfoPane(this, manager));
- }
-
- if(Keyboard.getEventKeyState()) {
- if(!NotEnoughUpdates.INSTANCE.config.toolbar.searchBar) {
- searchBarHasFocus = false;
- }
- if(searchBarHasFocus) {
- if(keyPressed == 1) {
- searchBarHasFocus = false;
- } else {
- if(textField.textboxKeyTyped(Keyboard.getEventCharacter(), keyPressed)) {
- updateSearch();
- }
- }
- } else {
- if(activeInfoPane != null) {
- if(activeInfoPane.keyboardInput()) {
- return true;
- }
- }
-
- if(keyPressed == manager.keybindClosePanes.getKeyCode()) {
- itemPaneOffsetFactor.setValue(1);
- itemPaneTabOffset.setValue(20);
- itemPaneOpen = false;
- displayInformationPane(null);
- }
-
- if(keyPressed == manager.keybindToggleDisplay.getKeyCode()) {
- disabled = !disabled;
- return true;
- }
-
- AtomicReference<String> internalname = new AtomicReference<>(null);
- AtomicReference<ItemStack> itemstack = new AtomicReference<>(null);
- if(Minecraft.getMinecraft().currentScreen instanceof GuiContainer &&
- Utils.getSlotUnderMouse((GuiContainer)Minecraft.getMinecraft().currentScreen) != null) {
- Slot slot = Utils.getSlotUnderMouse((GuiContainer)Minecraft.getMinecraft().currentScreen);
- ItemStack hover = slot.getStack();
- if(hover != null) {
- internalname.set(manager.getInternalNameForItem(hover));
- itemstack.set(hover);
- }
- } else if(!hoverInv) {
- Utils.pushGuiScale(NotEnoughUpdates.INSTANCE.config.itemlist.paneGuiScale);
-
- int width = Utils.peekGuiScale().getScaledWidth();
- int height = Utils.peekGuiScale().getScaledHeight();
- int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
- int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
-
- if (selectedItemGroup != null) {
- int selectedX = Math.min(selectedItemGroupX, width - getBoxPadding() - 18 * selectedItemGroup.size());
-
- if (mouseY > selectedItemGroupY + 17 && mouseY < selectedItemGroupY + 35) {
- for (int i = 0; i < selectedItemGroup.size(); i++) {
- if (mouseX >= selectedX - 1 + 18 * i && mouseX <= selectedX + 17 + 18 * i) {
- internalname.set(selectedItemGroup.get(i).get("internalname").getAsString());
- }
- }
- }
- } else {
- iterateItemSlots(new ItemSlotConsumer() {
- public void consume(int x, int y, int id) {
- if (mouseX >= x - 1 && mouseX <= x + ITEM_SIZE + 1) {
- if (mouseY >= y - 1 && mouseY <= y + ITEM_SIZE + 1) {
- JsonObject json = getSearchedItemPage(id);
- if (json != null) internalname.set(json.get("internalname").getAsString());
- }
- }
- }
- });
- }
-
-
- Utils.pushGuiScale(-1);
- }
- if(internalname.get() != null) {
- if(itemstack.get() != null) {
- if(NotEnoughUpdates.INSTANCE.config.hidden.enableItemEditing && Keyboard.getEventCharacter() == 'k') {
- Minecraft.getMinecraft().displayGuiScreen(new NEUItemEditor(manager,
- internalname.get(), manager.getJsonForItem(itemstack.get())));
- return true;
- }
- }
- JsonObject item = manager.getItemInformation().get(internalname.get());
- if(item != null) {
- if(keyPressed == manager.keybindViewUsages.getKeyCode()) {
- manager.displayGuiItemUsages(internalname.get());
- return true;
- } else if(keyPressed == manager.keybindFavourite.getKeyCode()) {
- toggleFavourite(item.get("internalname").getAsString());
- return true;
- } else if(keyPressed == manager.keybindViewRecipe.getKeyCode()) {
- manager.showRecipe(item);
- return true;
- } else if(keyPressed == manager.keybindGive.getKeyCode()) {
- if(Minecraft.getMinecraft().thePlayer.capabilities.isCreativeMode) {
- Minecraft.getMinecraft().thePlayer.inventory.addItemStackToInventory(
- manager.jsonToStack(item));
- }
- } else if(NotEnoughUpdates.INSTANCE.config.hidden.enableItemEditing && Keyboard.getEventCharacter() == 'k') {
- Minecraft.getMinecraft().displayGuiScreen(new NEUItemEditor(manager,
- internalname.get(), item));
- return true;
- } else if(keyPressed == manager.keybindItemSelect.getKeyCode() && NotEnoughUpdates.INSTANCE.config.toolbar.searchBar) {
- textField.setText("id:"+internalname.get());
- itemPaneOpen = true;
- updateSearch();
- }
- }
- }
- }
- }
-
- return searchBarHasFocus; //Cancels keyboard events if the search bar has focus
- }
-
- public void toggleFavourite(String internalname) {
- if(getFavourites().contains(internalname)) {
- getFavourites().remove(internalname);
- } else {
- getFavourites().add(internalname);
- }
- updateSearch();
- }
-
- String[] rarityArr = new String[] {
- EnumChatFormatting.WHITE+EnumChatFormatting.BOLD.toString()+"COMMON",
- EnumChatFormatting.GREEN+EnumChatFormatting.BOLD.toString()+"UNCOMMON",
- EnumChatFormatting.BLUE+EnumChatFormatting.BOLD.toString()+"RARE",
- EnumChatFormatting.DARK_PURPLE+EnumChatFormatting.BOLD.toString()+"EPIC",
- EnumChatFormatting.GOLD+EnumChatFormatting.BOLD.toString()+"LEGENDARY",
- EnumChatFormatting.LIGHT_PURPLE+EnumChatFormatting.BOLD.toString()+"MYTHIC",
- EnumChatFormatting.RED+EnumChatFormatting.BOLD.toString()+"SPECIAL",
- };
-
- /**
- * Finds the rarity from the lore of an item.
- * -1 = UNKNOWN
- * 0 = COMMON
- * 1 = UNCOMMON
- * 2 = RARE
- * 3 = EPIC
- * 4 = LEGENDARY
- * 5 = MYTHIC
- * 6 = SPECIAL
- */
- public int getRarity(JsonArray lore) {
- for(int i=lore.size()-1; i>=0; i--) {
- String line = lore.get(i).getAsString();
-
- for(int j=0; j<rarityArr.length; j++) {
- if(line.startsWith(rarityArr[j])) {
- return j;
- }
- }
- }
- return -1;
- }
-
- /**
- * Convenience functions that get various compare/sort modes from the config.
- */
- private int getCompareMode() {
- return NotEnoughUpdates.INSTANCE.config.hidden.compareMode;
- }
- private int getSortMode() {
- return NotEnoughUpdates.INSTANCE.config.hidden.sortMode;
- }
- private List<Boolean> getCompareAscending() {
- return NotEnoughUpdates.INSTANCE.config.hidden.compareAscending;
- }
- private List<String> getFavourites() {
- return NotEnoughUpdates.INSTANCE.config.hidden.favourites;
- }
-
- /**
- * Creates an item comparator used to sort the list of items according to the favourite set then compare mode.
- * Defaults to alphabetical sorting if the above factors cannot distinguish between two items.
- */
- private Comparator<JsonObject> getItemComparator() {
- return (o1, o2) -> {
- //1 (mult) if o1 should appear after o2
- //-1 (-mult) if o2 should appear after o1
- if(getFavourites().contains(o1.get("internalname").getAsString()) && !getFavourites().contains(o2.get("internalname").getAsString())) {
- return -1;
- }
- if(!getFavourites().contains(o1.get("internalname").getAsString()) && getFavourites().contains(o2.get("internalname").getAsString())) {
- return 1;
- }
-
- int mult = getCompareAscending().get(getCompareMode()) ? 1 : -1;
- if(getCompareMode() == COMPARE_MODE_RARITY) {
- int rarity1 = getRarity(o1.get("lore").getAsJsonArray());
- int rarity2 = getRarity(o2.get("lore").getAsJsonArray());
-
- if(rarity1 < rarity2) return mult;
- if(rarity1 > rarity2) return -mult;
- } else if(getCompareMode() == COMPARE_MODE_VALUE) {
- String internal1 = o1.get("internalname").getAsString();
- String internal2 = o2.get("internalname").getAsString();
-
- float cost1 = manager.auctionManager.getLowestBin(internal1);
- float cost2 = manager.auctionManager.getLowestBin(internal2);
-
-
- if(cost1 < cost2) return mult;
- if(cost1 > cost2) return -mult;
- }
-
- String i1 = o1.get("internalname").getAsString();
- String[] split1 = i1.split("_");
- String last1 = split1[split1.length-1];
- String start1 = i1.substring(0, i1.length()-last1.length());
-
- String i2 = o2.get("internalname").getAsString();
- String[] split2 = i2.split("_");
- String last2 = split2[split2.length-1];
- String start2 = i2.substring(0, i2.length()-last2.length());
-
- mult = getCompareAscending().get(COMPARE_MODE_ALPHABETICAL) ? 1 : -1;
- if(start1.equals(start2)) {
- String[] order = new String[]{"HELMET","CHESTPLATE","LEGGINGS","BOOTS"};
- int type1 = checkItemType(o1.get("lore").getAsJsonArray(), order);
- int type2 = checkItemType(o2.get("lore").getAsJsonArray(), order);
-
-
- if(type1 < type2) return -mult;
- if(type1 > type2) return mult;
- }
-
- int nameComp = mult*o1.get("displayname").getAsString().replaceAll("(?i)\\u00A7.", "")
- .compareTo(o2.get("displayname").getAsString().replaceAll("(?i)\\u00A7.", ""));
- if(nameComp != 0) {
- return nameComp;
- }
- return mult*o1.get("internalname").getAsString().compareTo(o2.get("internalname").getAsString());
- };
- }
-
- /**
- * Checks whether an item matches a certain type, i.e. whether the item lore ends in "{rarity} {item type}"
- * eg. "SHOVEL" will return >0 for "COMMON SHOVEL", "EPIC SHOVEL", etc.
- * @return the index of the type that matched, or -1 otherwise.
- */
- public int checkItemType(JsonArray lore, String... typeMatches) {
- for(int i=lore.size()-1; i>=0; i--) {
- String line = lore.get(i).getAsString();
-
- for(String rarity : rarityArr) {
- for(int j=0; j<typeMatches.length; j++) {
- if(line.trim().equals(rarity + " " + typeMatches[j])) {
- return j;
- }
- }
- }
- }
- return -1;
- }
-
- /**
- * Checks whether an item matches the current sort mode.
- */
- public boolean checkMatchesSort(String internalname, JsonObject item) {
- if(!NotEnoughUpdates.INSTANCE.config.itemlist.showVanillaItems && item.has("vanilla") && item.get("vanilla").getAsBoolean()) {
- return false;
- }
-
- if(getSortMode() == SORT_MODE_ALL) {
- return !internalname.matches(mobRegex);
- } else if(getSortMode() == SORT_MODE_MOB) {
- return internalname.matches(mobRegex);
- } else if(getSortMode() == SORT_MODE_PET) {
- return internalname.matches(petRegex) && item.get("displayname").getAsString().contains("[");
- } else if(getSortMode() == SORT_MODE_TOOL) {
- return checkItemType(item.get("lore").getAsJsonArray(),
- "SWORD", "BOW", "AXE", "PICKAXE", "FISHING ROD", "WAND", "SHOVEL", "HOE", "DUNGEON SWORD", "DUNGEON BOW") >= 0;
- } else if(getSortMode() == SORT_MODE_ARMOR) {
- return checkItemType(item.get("lore").getAsJsonArray(), "HELMET", "CHESTPLATE", "LEGGINGS", "BOOTS", "DUNGEON HELMET", "DUNGEON CHESTPLATE", "DUNGEON LEGGINGS", "DUNGEON BOOTS") >= 0;
- } else if(getSortMode() == SORT_MODE_ACCESSORY) {
- return checkItemType(item.get("lore").getAsJsonArray(), "ACCESSORY", "HATCCESSORY", "DUNGEON ACCESSORY") >= 0;
- }
- return true;
- }
-
- private HashMap<String, JsonObject> parentMap = new HashMap<>();
-
- private ExecutorService searchES = Executors.newSingleThreadExecutor();
-
- /**
- * Clears the current item list, creating a new TreeSet if necessary.
- * Adds all items that match the search AND match the sort mode to the current item list.
- * Also adds some easter egg items. (Also I'm very upset if you came here to find them :'( )
- */
- public void updateSearch() {
- SunTzu.randomizeQuote();
-
- if(searchedItems == null) searchedItems = new TreeSet<>(getItemComparator());
-
- searchES.submit(() -> {
- TreeSet<JsonObject> searchedItems = new TreeSet<>(getItemComparator());
- HashMap<String, List<String>> searchedItemsSubgroup = new HashMap<>();
-
- Set<JsonObject> removeChildItems = new HashSet<>();
- Set<String> itemsMatch = manager.search(textField.getText(), true);
- for(String itemname : itemsMatch) {
- JsonObject item = manager.getItemInformation().get(itemname);
- if(checkMatchesSort(itemname, item)) {
- if(Constants.PARENTS != null) {
- if(Constants.PARENTS.has(itemname) && Constants.PARENTS.get(itemname).isJsonArray()) {
- List<String> children = new ArrayList<>();
- for(JsonElement e : Constants.PARENTS.get(itemname).getAsJsonArray()) {
- if(e.isJsonPrimitive()) {
- children.add(e.getAsString());
- }
- }
- children.retainAll(itemsMatch);
- for(String child : children) {
- removeChildItems.add(manager.getItemInformation().get(child));
- }
- searchedItemsSubgroup.put(itemname, children);
- }
- }
- searchedItems.add(item);
- }
- }
- searchedItems.removeAll(removeChildItems);
- out:
- for(Map.Entry<String, List<String>> entry : searchedItemsSubgroup.entrySet()) {
- if(searchedItems.contains(manager.getItemInformation().get(entry.getKey()))) {
- continue;
- }
- for(String itemname : entry.getValue()) {
- JsonObject item = manager.getItemInformation().get(itemname);
- if(item != null) searchedItems.add(item);
- }
- }
- switch(textField.getText().toLowerCase().trim()) {
- case "nullzee":
- searchedItems.add(CustomItems.NULLZEE);
- break;
- case "rune":
- searchedItems.add(CustomItems.RUNE);
- break;
- case "2b2t":
- searchedItems.add(CustomItems.TWOBEETWOTEE);
- break;
- case "ducttape":
- case "ducttapedigger":
- searchedItems.add(CustomItems.DUCTTAPE);
- break;
- case "thirtyvirus":
- searchedItems.add(manager.getItemInformation().get("SPIKED_BAIT"));
- break;
- case "leocthl":
- searchedItems.add(CustomItems.LEOCTHL);
- break;
- case "spinaxx":
- searchedItems.add(CustomItems.SPINAXX);
- break;
- case "credits":
- case "credit":
- case "who made this mod":
- searchedItems.add(CustomItems.CREDITS);
- break;
- case "ironmoon":
- case "ironm00n":
- searchedItems.add(CustomItems.IRONM00N);
- break;
- }
-
- this.searchedItems = searchedItems;
- this.searchedItemsSubgroup = searchedItemsSubgroup;
-
- synchronized(this.searchedItemsArr) {
- this.searchedItemsArr.clear();
- }
-
- redrawItems = true;
- });
- }
-
- /**
- * Returns an index-able array containing the elements in searchedItems.
- * Whenever searchedItems is updated in updateSearch(), the array is recreated here.
- */
- public List<JsonObject> getSearchedItems() {
- if(searchedItems == null) {
- updateSearch();
- return new ArrayList<>();
- }
-
- if(searchedItems.size() > 0 && searchedItemsArr.size() == 0) {
- synchronized(searchedItemsArr) {
- searchedItemsArr.addAll(searchedItems);
- }
- }
- return searchedItemsArr;
- }
-
- /**
- * Gets the item in searchedItemArr corresponding to the certain index on the current page.
- * @return item, if the item exists. null, otherwise.
- */
- public JsonObject getSearchedItemPage(int index) {
- if(index < getSlotsXSize()*getSlotsYSize()) {
- int actualIndex = index + getSlotsXSize()*getSlotsYSize()*page;
- List<JsonObject> searchedItems = getSearchedItems();
- if(actualIndex < searchedItems.size()) {
- return searchedItems.get(actualIndex);
- } else {
- return null;
- }
- } else {
- return null;
- }
- }
-
- public int getItemBoxXPadding() {
- int width = Utils.peekGuiScale().getScaledWidth();
- return (((int)(width/3*getWidthMult())-2*getBoxPadding())%(ITEM_SIZE+ITEM_PADDING)+ITEM_PADDING)/2;
- }
-
- public int getBoxPadding() {
- double panePadding = Math.max(0, Math.min(20, NotEnoughUpdates.INSTANCE.config.itemlist.panePadding));
- return (int)(panePadding*2/Utils.peekGuiScale().getScaleFactor()+5);
- }
-
- private abstract class ItemSlotConsumer {
- public abstract void consume(int x, int y, int id);
- }
-
- public void iterateItemSlots(ItemSlotConsumer itemSlotConsumer) {
- int width = Utils.peekGuiScale().getScaledWidth();
- int itemBoxXPadding = getItemBoxXPadding();
- iterateItemSlots(itemSlotConsumer, (int)(width*getItemPaneOffsetFactor())+getBoxPadding()+itemBoxXPadding);
- }
-
- /**
- * Iterates through all the item slots in the right panel and calls a ItemSlotConsumer for each slot with
- * arguments equal to the slot's x and y position respectively. This is used in order to prevent
- * code duplication issues.
- */
- public void iterateItemSlots(ItemSlotConsumer itemSlotConsumer, int xStart) {
- int width = Utils.peekGuiScale().getScaledWidth();
- int height = Utils.peekGuiScale().getScaledHeight();
-
- int paneWidth = (int)(width/3*getWidthMult());
- int itemBoxYPadding = ((height-getSearchBarYSize()-2*getBoxPadding()-ITEM_SIZE-2)%(ITEM_SIZE+ITEM_PADDING)+ITEM_PADDING)/2;
-
- int yStart = getBoxPadding()+getSearchBarYSize()+itemBoxYPadding;
- int itemBoxXPadding = getItemBoxXPadding();
- int xEnd = xStart+paneWidth-getBoxPadding()*2-ITEM_SIZE-itemBoxXPadding;
- int yEnd = height-getBoxPadding()-ITEM_SIZE-2-itemBoxYPadding;
-
- //Render the items, displaying the tooltip if the cursor is over the item
- int id = 0;
- for(int y = yStart; y < yEnd; y+=ITEM_SIZE+ITEM_PADDING) {
- for(int x = xStart; x < xEnd; x+=ITEM_SIZE+ITEM_PADDING) {
- itemSlotConsumer.consume(x, y, id++);
- }
- }
- }
-
- public float getWidthMult() {
- float scaleFMult = 1;
- if(Utils.peekGuiScale().getScaleFactor()==4) scaleFMult *= 0.9f;
- if(manager.auctionManager.customAH.isRenderOverAuctionView() || Minecraft.getMinecraft().currentScreen instanceof CustomAHGui) scaleFMult *= 0.8f;
- return (float)Math.max(0.5, Math.min(1.5, NotEnoughUpdates.INSTANCE.config.itemlist.paneWidthMult))*scaleFMult;
- }
-
- /**
- * Calculates the number of horizontal item slots.
- */
- public int getSlotsXSize() {
- int width = Utils.peekGuiScale().getScaledWidth();
-
- int paneWidth = (int)(width/3*getWidthMult());
- int itemBoxXPadding = (((int)(width-width*getItemPaneOffsetFactor())-2*getBoxPadding())%(ITEM_SIZE+ITEM_PADDING)+ITEM_PADDING)/2;
- int xStart = (int)(width*getItemPaneOffsetFactor())+getBoxPadding()+itemBoxXPadding;
- int xEnd = (int)(width*getItemPaneOffsetFactor())+paneWidth-getBoxPadding()-ITEM_SIZE;
-
- return (int)Math.ceil((xEnd - xStart)/((float)(ITEM_SIZE+ITEM_PADDING)));
- }
-
- /**
- * Calculates the number of vertical item slots.
- */
- public int getSlotsYSize() {
- int height = Utils.peekGuiScale().getScaledHeight();
-
- int itemBoxYPadding = ((height-getSearchBarYSize()-2*getBoxPadding()-ITEM_SIZE-2)%(ITEM_SIZE+ITEM_PADDING)+ITEM_PADDING)/2;
- int yStart = getBoxPadding()+getSearchBarYSize()+itemBoxYPadding;
- int yEnd = height-getBoxPadding()-ITEM_SIZE-2-itemBoxYPadding;
-
- return (int)Math.ceil((yEnd - yStart)/((float)(ITEM_SIZE+ITEM_PADDING)));
- }
-
- public int getMaxPages() {
- if(getSearchedItems().size() == 0) return 1;
- return (int)Math.ceil(getSearchedItems().size()/(float)getSlotsYSize()/getSlotsXSize());
- }
-
- public int getSearchBarYSize() {
- int searchBarYSize = NotEnoughUpdates.INSTANCE.config.toolbar.searchBarHeight;
- return Math.max(searchBarYSize/Utils.peekGuiScale().getScaleFactor(), ITEM_SIZE);
- }
-
- /**
- * Renders the top navigation bar, can be used by InfoPane implementations (such as SettingsInfoPane).
- * Renders "prev" button, index/maxIndex string, "next" button.
- */
- public void renderNavElement(int leftSide, int rightSide, int maxPages, int page, String name) {
- FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
-
- String pageText = EnumChatFormatting.BOLD+name + page + "/" + maxPages;
-
- float maxStrLen = fr.getStringWidth(EnumChatFormatting.BOLD+name + maxPages + "/" + maxPages);
- float maxButtonXSize = (rightSide-leftSide+2 - maxStrLen*0.5f - 10)/2f;
- int buttonXSize = (int)Math.min(maxButtonXSize, getSearchBarYSize()*480/160f);
- int ySize = (int)(buttonXSize/480f*160);
- int yOffset = (int)((getSearchBarYSize()-ySize)/2f);
- int top = getBoxPadding()+yOffset;
-
- int leftPressed = 0;
- int rightPressed = 0;
-
- if(Mouse.isButtonDown(0) || Mouse.isButtonDown(1)) {
- int width = Utils.peekGuiScale().getScaledWidth();
- int height = Utils.peekGuiScale().getScaledHeight();
-
- int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
- int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
-
- if(mouseY >= top && mouseY <= top+ySize) {
- int leftPrev = leftSide-1;
- if(mouseX > leftPrev && mouseX < leftPrev+buttonXSize) { //"Previous" button
- leftPressed = 1;
- }
- int leftNext = rightSide+1-buttonXSize;
- if(mouseX > leftNext && mouseX < leftNext+buttonXSize) { //"Next" button
- rightPressed = 1;
- }
- }
- }
-
- drawRect(leftSide-1, top, leftSide-1+buttonXSize, top+ySize, fg.getRGB());
- GlStateManager.color(1f, 1f, 1f, 1f);
- Minecraft.getMinecraft().getTextureManager().bindTexture(rightarrow);
- Utils.drawTexturedRect(leftSide-1+leftPressed,
- top+leftPressed,
- buttonXSize, ySize, 1, 0, 0, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(rightarrow_overlay);
- Utils.drawTexturedRect(leftSide-1,
- top,
- buttonXSize, ySize, 1-leftPressed, leftPressed, 1-leftPressed, leftPressed);
- GlStateManager.bindTexture(0);
- Utils.drawStringCenteredScaled(EnumChatFormatting.BOLD+"Prev", fr,
- leftSide-1+buttonXSize*300/480f+leftPressed,
- top+ySize/2f+leftPressed, false,
- (int)(buttonXSize*240/480f), Color.BLACK.getRGB());
-
- drawRect(rightSide+1-buttonXSize, top, rightSide+1, top+ySize, fg.getRGB());
- GlStateManager.color(1f, 1f, 1f, 1f);
- Minecraft.getMinecraft().getTextureManager().bindTexture(rightarrow);
- Utils.drawTexturedRect(rightSide+1-buttonXSize+rightPressed,
- top+rightPressed,
- buttonXSize, ySize);
- Minecraft.getMinecraft().getTextureManager().bindTexture(rightarrow_overlay);
- Utils.drawTexturedRect(rightSide+1-buttonXSize,
- top,
- buttonXSize, ySize, 1-rightPressed, rightPressed, 1-rightPressed, rightPressed);
- GlStateManager.bindTexture(0);
- Utils.drawStringCenteredScaled(EnumChatFormatting.BOLD+"Next", fr,
- rightSide+1-buttonXSize*300/480f+rightPressed,
- top+ySize/2f+rightPressed, false,
- (int)(buttonXSize*240/480f), Color.BLACK.getRGB());
-
- int strMaxLen = rightSide-leftSide-2*buttonXSize-10;
-
- drawRect(leftSide-1+buttonXSize+3, top, rightSide+1-buttonXSize-3, top+ySize,
- new Color(177,177,177).getRGB());
- drawRect(leftSide+buttonXSize+3, top+1, rightSide+1-buttonXSize-3, top+ySize,
- new Color(50,50,50).getRGB());
- drawRect(leftSide+buttonXSize+3, top+1, rightSide-buttonXSize-3, top+ySize-1, fg.getRGB());
- Utils.drawStringCenteredScaledMaxWidth(pageText, fr,(leftSide+rightSide)/2,
- top+ySize/2f, false, strMaxLen, Color.BLACK.getRGB());
- }
-
- private int limCol(int col) {
- return Math.min(255, Math.max(0, col));
- }
-
- public boolean isUsingMobsFilter() {
- return getSortMode() == SORT_MODE_MOB;
- }
-
- public float yaw = 0;
- public float pitch = 20;
-
- /**
- * Renders an entity onto the GUI at a certain x and y position.
- */
- private void renderEntity(float posX, float posY, float scale, String name, Class<? extends EntityLivingBase>... classes) {
- EntityLivingBase[] entities = new EntityLivingBase[classes.length];
- try {
- EntityLivingBase last = null;
- for(int i=0; i<classes.length; i++) {
- Class<? extends EntityLivingBase> clazz = classes[i];
- if(clazz == null) continue;
-
- EntityLivingBase newEnt = clazz.getConstructor(new Class[] {World.class}).newInstance(Minecraft.getMinecraft().theWorld);
-
- //newEnt.renderYawOffset = yaw;
- //newEnt.rotationYaw = yaw;
- newEnt.rotationPitch = pitch;
- //newEnt.rotationYawHead = yaw;
- //newEnt.prevRotationYawHead = yaw-1;
-
- newEnt.setCustomNameTag(name);
-
- if(last != null) {
- last.riddenByEntity = newEnt;
- newEnt.ridingEntity = last;
- last.updateRiderPosition();
- }
- last = newEnt;
-
- entities[i] = newEnt;
- }
- } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
- e.printStackTrace();
- return;
- }
-
-
- GlStateManager.enableColorMaterial();
- GlStateManager.pushMatrix();
- GlStateManager.translate(posX, posY, 50.0F);
- GlStateManager.scale(-scale, scale, scale);
- GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
-
- GlStateManager.rotate(135.0F, 0.0F, 1.0F, 0.0F);
- RenderHelper.enableStandardItemLighting();
- GlStateManager.rotate(-135.0F, 0.0F, 1.0F, 0.0F);
-
- GlStateManager.rotate(pitch, 1.0F, 0.0F, 0.0F);
- GlStateManager.rotate(yaw, 0.0F, 1.0F, 0.0F);
-
- RenderManager rendermanager = Minecraft.getMinecraft().getRenderManager();
- rendermanager.setPlayerViewY(180.0F);
- rendermanager.setRenderShadow(false);
- for(EntityLivingBase ent : entities) {
- GL11.glColor4f(1,1,1,1);
- if(ent != null) rendermanager.renderEntityWithPosYaw(ent, ent.posX, ent.posY, ent.posZ, 0.0F, 1.0F);
- }
- rendermanager.setRenderShadow(true);
-
- GlStateManager.popMatrix();
- RenderHelper.disableStandardItemLighting();
- GlStateManager.disableRescaleNormal();
- GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
- GlStateManager.disableTexture2D();
- GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
-
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
- }
-
- Shader blurShaderHorz = null;
- Framebuffer blurOutputHorz = null;
- Shader blurShaderVert = null;
- Framebuffer blurOutputVert = null;
-
- /**
- * Creates a projection matrix that projects from our coordinate space [0->width; 0->height] to OpenGL coordinate
- * space [-1 -> 1; 1 -> -1] (Note: flipped y-axis).
- *
- * This is so that we can render to and from the framebuffer in a way that is familiar to us, instead of needing to
- * apply scales and translations manually.
- */
- private Matrix4f createProjectionMatrix(int width, int height) {
- Matrix4f projMatrix = new Matrix4f();
- projMatrix.setIdentity();
- projMatrix.m00 = 2.0F / (float)width;
- projMatrix.m11 = 2.0F / (float)(-height);
- projMatrix.m22 = -0.0020001999F;
- projMatrix.m33 = 1.0F;
- projMatrix.m03 = -1.0F;
- projMatrix.m13 = 1.0F;
- projMatrix.m23 = -1.0001999F;
- return projMatrix;
- }
-
- public void updateGuiGroupSize() {
- Utils.pushGuiScale(NotEnoughUpdates.INSTANCE.config.itemlist.paneGuiScale);
- int width = Utils.peekGuiScale().getScaledWidth();
- int height = Utils.peekGuiScale().getScaledHeight();
-
- if(lastScreenWidth != width || lastScreenHeight != height || Utils.peekGuiScale().getScaleFactor() != lastScale) {
- guiGroup.width = width;
- guiGroup.height = height;
-
- resetAnchors(true);
- guiGroup.recalculate();
-
- lastScreenWidth = width;
- lastScreenHeight = height;
- lastScale = Utils.peekGuiScale().getScaleFactor();
- }
-
- Utils.pushGuiScale(-1);
- }
-
- int guiScaleLast = 0;
- private boolean showVanillaLast = false;
-
- /**
- * Renders the search bar, quick commands, item selection (right) and item info (left) gui elements.
- */
- public void render(boolean hoverInv) {
- if(disabled) {
- return;
- }
- GlStateManager.enableDepth();
-
- FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
-
- Utils.resetGuiScale();
- Utils.pushGuiScale(NotEnoughUpdates.INSTANCE.config.itemlist.paneGuiScale);
-
- int width = Utils.peekGuiScale().getScaledWidth();
- int height = Utils.peekGuiScale().getScaledHeight();
- int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
- int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
-
- if(showVanillaLast != NotEnoughUpdates.INSTANCE.config.itemlist.showVanillaItems) {
- showVanillaLast = NotEnoughUpdates.INSTANCE.config.itemlist.showVanillaItems;
- updateSearch();
- }
-
- if(textField.getText().toLowerCase().contains("bald")) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(SUPERGEHEIMNISVERMOGEN);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect((width-64)/2f, (height-64)/2f-114, 64, 64, GL11.GL_LINEAR);
- GlStateManager.bindTexture(0);
- }
-
- SunTzu.setEnabled(textField.getText().toLowerCase().startsWith("potato"));
-
- updateGuiGroupSize();
-
- if(guiScaleLast != Utils.peekGuiScale().getScaleFactor()) {
- guiScaleLast = Utils.peekGuiScale().getScaleFactor();
- redrawItems = true;
- }
-
- if(oldWidthMult != getWidthMult()) {
- oldWidthMult = getWidthMult();
- redrawItems = true;
- }
-
- yaw++;
- yaw %= 360;
-
- bg = new Color(SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.itemlist.backgroundColour), true);
- fg = new Color(SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.itemlist.foregroundColour));
- Color fgCustomOpacity = new Color(SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.itemlist.foregroundColour), true);
-
- Color fgFavourite2 = new Color(SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.itemlist.favouriteColour), true);
- Color fgFavourite = new Color((int)(fgFavourite2.getRed()*0.8f), (int)(fgFavourite2.getGreen()*0.8f),
- (int)(fgFavourite2.getBlue()*0.8f), fgFavourite2.getAlpha());
-
- if(itemPaneOpen) {
- if(itemPaneTabOffset.getValue() == 0) {
- if(itemPaneOffsetFactor.getTarget() != 2/3f) {
- itemPaneOffsetFactor.setTarget(2/3f);
- itemPaneOffsetFactor.resetTimer();
- }
- } else {
- if(itemPaneTabOffset.getTarget() != 0) {
- itemPaneTabOffset.setTarget(0);
- itemPaneTabOffset.resetTimer();
- }
- }
- } else {
- if(itemPaneOffsetFactor.getValue() == 1) {
- if(itemPaneTabOffset.getTarget() != 20) {
- itemPaneTabOffset.setTarget(20);
- itemPaneTabOffset.resetTimer();
- }
- } else {
- if(itemPaneOffsetFactor.getTarget() != 1f) {
- itemPaneOffsetFactor.setTarget(1f);
- itemPaneOffsetFactor.resetTimer();
- }
- }
- }
-
- itemPaneOffsetFactor.tick();
- itemPaneTabOffset.tick();
- infoPaneOffsetFactor.tick();
-
- if(page > getMaxPages()-1) setPage(getMaxPages()-1);
- if(page < 0) setPage(0);
-
- GlStateManager.disableLighting();
-
- /**
- * Item selection (right) gui element rendering
- */
- int paneWidth = (int)(width/3*getWidthMult());
- int leftSide = (int)(width*getItemPaneOffsetFactor());
- int rightSide = leftSide+paneWidth-getBoxPadding()-getItemBoxXPadding();
-
- //Tab
- if(NotEnoughUpdates.INSTANCE.config.itemlist.tabOpen) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(itemPaneTabArrow);
- GlStateManager.color(1f, 1f, 1f, 0.3f);
- Utils.drawTexturedRect(width-itemPaneTabOffset.getValue()*64/20f, height/2f - 32, 64, 64);
- GlStateManager.bindTexture(0);
-
- if(!itemPaneOpen && mouseX > width-itemPaneTabOffset.getValue() && mouseY > height/2 - 32
- && mouseY < height/2 + 32) {
- itemPaneOpen = true;
- }
- }
-
- //Atomic reference used so that below lambda doesn't complain about non-effectively-final variable
- AtomicReference<JsonObject> tooltipToDisplay = new AtomicReference<>(null);
- //System.out.println(itemPaneOffsetFactor.getValue());
- if(itemPaneOffsetFactor.getValue() < 0.99) {
- if(NotEnoughUpdates.INSTANCE.config.itemlist.bgBlurFactor > 0.5) {
- BackgroundBlur.renderBlurredBackground(NotEnoughUpdates.INSTANCE.config.itemlist.bgBlurFactor,
- width, height,
- leftSide+getBoxPadding()-5, getBoxPadding()-5,
- paneWidth-getBoxPadding()*2+10, height-getBoxPadding()*2+10,
- itemPaneOffsetFactor.getValue() > 0.01);
- Gui.drawRect(leftSide+getBoxPadding()-5, getBoxPadding()-5,
- leftSide+getBoxPadding()-5+paneWidth-getBoxPadding()*2+10,
- getBoxPadding()-5+height-getBoxPadding()*2+10, 0xc8101010);
- }
-
- drawRect(leftSide+getBoxPadding()-5, getBoxPadding()-5,
- leftSide+paneWidth-getBoxPadding()+5, height-getBoxPadding()+5, bg.getRGB());
-
- renderNavElement(leftSide+getBoxPadding()+getItemBoxXPadding(), rightSide, getMaxPages(), page+1,
- Utils.peekGuiScale().getScaleFactor()<4?"Page: ":"");
-
- //Sort bar
- drawRect(leftSide+getBoxPadding()+getItemBoxXPadding()-1,
- height-getBoxPadding()-ITEM_SIZE-2,
- rightSide+1,
- height-getBoxPadding(), fgCustomOpacity.getRGB());
-
- float sortIconsMinX = (sortIcons.length+orderIcons.length)*(ITEM_SIZE+ITEM_PADDING)+ITEM_SIZE;
- float availableX = rightSide-(leftSide+getBoxPadding()+getItemBoxXPadding());
- float sortOrderScaleFactor = Math.min(1, availableX / sortIconsMinX);
-
- int scaledITEM_SIZE = (int)(ITEM_SIZE*sortOrderScaleFactor);
- int scaledItemPaddedSize = (int)((ITEM_SIZE+ITEM_PADDING)*sortOrderScaleFactor);
- int iconTop = height-getBoxPadding()-(ITEM_SIZE+scaledITEM_SIZE)/2-1;
-
- boolean hoveredOverControl = false;
- for(int i=0; i<orderIcons.length; i++) {
- int orderIconX = leftSide+getBoxPadding()+getItemBoxXPadding()+i*scaledItemPaddedSize;
- drawRect(orderIconX, iconTop,scaledITEM_SIZE+orderIconX,iconTop+scaledITEM_SIZE, fg.getRGB());
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(getCompareMode() == i ? orderIconsActive[i] : orderIcons[i]);
- GlStateManager.color(1f, 1f, 1f, 1f);
- Utils.drawTexturedRect(orderIconX, iconTop, scaledITEM_SIZE, scaledITEM_SIZE,0, 1, 0, 1, GL11.GL_NEAREST);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(getCompareAscending().get(i) ? ascending_overlay : descending_overlay);
- GlStateManager.color(1f, 1f, 1f, 1f);
- Utils.drawTexturedRect(orderIconX, iconTop, scaledITEM_SIZE, scaledITEM_SIZE,0, 1, 0, 1, GL11.GL_NEAREST);
- GlStateManager.bindTexture(0);
-
- if(mouseY > iconTop && mouseY < iconTop+scaledITEM_SIZE) {
- if(mouseX > orderIconX && mouseX < orderIconX+scaledITEM_SIZE) {
- hoveredOverControl = true;
- if(System.currentTimeMillis() - millisLastMouseMove > 400) {
- String text = EnumChatFormatting.GRAY+"Order ";
- if(i == COMPARE_MODE_ALPHABETICAL) text += "Alphabetically";
- else if(i == COMPARE_MODE_RARITY) text += "by Rarity";
- else if(i == COMPARE_MODE_VALUE) text += "by Item Worth";
- else text = null;
- if(text != null) textToDisplay = Utils.createList(text);
- }
- }
- }
- }
-
- for(int i=0; i<sortIcons.length; i++) {
- int sortIconX = rightSide-scaledITEM_SIZE-i*scaledItemPaddedSize;
- drawRect(sortIconX, iconTop,scaledITEM_SIZE+sortIconX,iconTop+scaledITEM_SIZE, fg.getRGB());
- Minecraft.getMinecraft().getTextureManager().bindTexture(getSortMode() == i ? sortIconsActive[i] : sortIcons[i]);
- GlStateManager.color(1f, 1f, 1f, 1f);
- Utils.drawTexturedRect(sortIconX, iconTop, scaledITEM_SIZE, scaledITEM_SIZE, 0, 1, 0, 1, GL11.GL_NEAREST);
- GlStateManager.bindTexture(0);
-
- if(mouseY > iconTop && mouseY < iconTop+scaledITEM_SIZE) {
- if(mouseX > sortIconX && mouseX < sortIconX+scaledITEM_SIZE) {
- hoveredOverControl = true;
- if(System.currentTimeMillis() - millisLastMouseMove > 400) {
- String text = EnumChatFormatting.GRAY+"Filter ";
- if(i == SORT_MODE_ALL) text = EnumChatFormatting.GRAY+"No Filter";
- else if(i == SORT_MODE_MOB) text += "Mobs";
- else if(i == SORT_MODE_PET) text += "Pets";
- else if(i == SORT_MODE_TOOL) text += "Tools";
- else if(i == SORT_MODE_ARMOR) text += "Armor";
- else if(i == SORT_MODE_ACCESSORY) text += "Accessories";
- else text = null;
- if(text != null) textToDisplay = Utils.createList(text);
- }
- }
- }
- }
-
- if(!hoveredOverControl) {
- millisLastMouseMove = System.currentTimeMillis();
- }
-
- if(selectedItemGroup != null) {
- if(mouseX < selectedItemGroupX-1 || mouseX > selectedItemGroupX+17 ||
- mouseY < selectedItemGroupY-1 || mouseY > selectedItemGroupY+17) {
- int selectedX = Math.min(selectedItemGroupX, width-getBoxPadding()-18*selectedItemGroup.size());
- if(mouseX < selectedX-1 || mouseX > selectedX-1+18*selectedItemGroup.size() ||
- mouseY < selectedItemGroupY+17 || mouseY > selectedItemGroupY+35) {
- selectedItemGroup = null;
- selectedItemMillis = -1;
- }
- }
- }
-
- if(!hoverInv) {
- iterateItemSlots(new ItemSlotConsumer() {
- public void consume(int x, int y, int id) {
- JsonObject json = getSearchedItemPage(id);
- if (json == null) {
- return;
- }
- if (mouseX > x - 1 && mouseX < x + ITEM_SIZE + 1) {
- if (mouseY > y - 1 && mouseY < y + ITEM_SIZE + 1) {
- String internalname = json.get("internalname").getAsString();
- if(searchedItemsSubgroup.containsKey(internalname)) {
- if(selectedItemMillis == -1) selectedItemMillis = System.currentTimeMillis();
- if(System.currentTimeMillis() - selectedItemMillis > 200 &&
- (selectedItemGroup == null || selectedItemGroup.isEmpty())) {
-
- ArrayList<JsonObject> children = new ArrayList<>();
- children.add(json);
- for(String itemname : searchedItemsSubgroup.get(internalname)) {
- children.add(manager.getItemInformation().get(itemname));
- }
-
- selectedItemGroup = children;
- selectedItemGroupX = x;
- selectedItemGroupY = y;
- }
- } else {
- tooltipToDisplay.set(json);
- }
- }
- }
- }
- });
- }
-
- //Iterate through all item slots and display the appropriate item
- int itemBoxXPadding = getItemBoxXPadding();
- int xStart = (int)(width*getItemPaneOffsetFactor())+getBoxPadding()+itemBoxXPadding;
-
- if(OpenGlHelper.isFramebufferEnabled()) {
- renderItemsFromImage(xStart, width, height);
- renderEnchOverlay();
-
- checkFramebufferSizes(width, height);
-
- if(redrawItems || !NotEnoughUpdates.INSTANCE.config.hidden.cacheRenderedItempane) {
- renderItemsToImage(width, height, fgFavourite2, fgFavourite, fgCustomOpacity, true, true);
- redrawItems = false;
- }
- } else {
- renderItems(xStart, true, true, true);
- }
-
- if(selectedItemGroup != null) {
- GL11.glTranslatef(0, 0, 10);
-
- int selectedX = Math.min(selectedItemGroupX, width-getBoxPadding()-18*selectedItemGroup.size());
-
- GlStateManager.enableDepth();
- GlStateManager.depthFunc(GL11.GL_LESS);
- drawRect(selectedX, selectedItemGroupY+18,
- selectedX-2+18*selectedItemGroup.size(), selectedItemGroupY+34, fgCustomOpacity.getRGB());
- drawRect(selectedX-1, selectedItemGroupY+17,
- selectedX-2+18*selectedItemGroup.size(), selectedItemGroupY+34, new Color(180, 180, 180).getRGB());
- drawRect(selectedX, selectedItemGroupY+18,
- selectedX-1+18*selectedItemGroup.size(), selectedItemGroupY+35, new Color(30, 30, 30).getRGB());
- drawRect(selectedX-1+2, selectedItemGroupY+17+2,
- selectedX-1+18*selectedItemGroup.size()+2, selectedItemGroupY+35+2, 0xa0000000);
- GlStateManager.depthFunc(GL11.GL_LEQUAL);
-
- GL11.glTranslatef(0, 0, 10);
-
- tooltipToDisplay.set(null);
- if(mouseY > selectedItemGroupY+17 && mouseY < selectedItemGroupY+35) {
- for(int i=0; i<selectedItemGroup.size(); i++) {
- if(mouseX >= selectedX-1+18*i && mouseX <= selectedX+17+18*i) {
- tooltipToDisplay.set(selectedItemGroup.get(i));
- }
- }
- }
- for(int i=0; i<selectedItemGroup.size(); i++) {
- JsonObject item = selectedItemGroup.get(i);
- Utils.drawItemStack(manager.jsonToStack(item), selectedX+18*i, selectedItemGroupY+18);
- }
-
- GL11.glTranslatef(0, 0, -20);
- }
-
- GlStateManager.enableBlend();
- GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
- GlStateManager.enableAlpha();
- GlStateManager.alphaFunc(516, 0.1F);
- GlStateManager.disableLighting();
- }
-
- /**
- * Search bar & quickcommand elements
- */
- guiGroup.render(0, 0);
- resetAnchors(true);
-
- /**
- * Item info (left) gui element rendering
- */
-
- rightSide = (int)(width*getInfoPaneOffsetFactor());
- leftSide = rightSide - paneWidth;
-
- if(activeInfoPane != null) {
- activeInfoPane.tick();
- activeInfoPane.render(width, height, bg, fg, Utils.peekGuiScale(), mouseX, mouseY);
-
- GlStateManager.color(1f, 1f, 1f, 1f);
- Minecraft.getMinecraft().getTextureManager().bindTexture(close);
- Utils.drawTexturedRect(rightSide-getBoxPadding()-8, getBoxPadding()-8, 16, 16);
- GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
- }
-
- //Render tooltip
- JsonObject json = tooltipToDisplay.get();
- if(json != null) {
-
- ItemStack stack = manager.jsonToStack(json);
- {
- NBTTagCompound tag = stack.getTagCompound();
- tag.setBoolean("DisablePetExp", true);
- stack.setTagCompound(tag);
- }
-
- List<String> text = stack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
-
- String internalname = json.get("internalname").getAsString();
- if(!NotEnoughUpdates.INSTANCE.config.tooltipTweaks.showPriceInfoInvItem) {
- ItemPriceInformation.addToTooltip(text, internalname, stack);
- }
-
- boolean hasClick = false;
- boolean hasInfo = false;
- if(json.has("clickcommand") && !json.get("clickcommand").getAsString().isEmpty()) {
- hasClick = true;
- }
- if(json.has("info") && json.get("info").getAsJsonArray().size() > 0) {
- hasInfo = true;
- }
-
- if(hasClick || hasInfo) text.add("");
- if(hasClick) text.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"LMB/R : View recipe!");
- if(hasInfo) text.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"RMB : View additional information!");
-
-
- textToDisplay = text;
- }
- if(textToDisplay != null) {
- Utils.drawHoveringText(textToDisplay, mouseX, mouseY, width, height, -1, fr);
- textToDisplay = null;
- }
-
- GlStateManager.enableBlend();
- GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
- GlStateManager.enableAlpha();
- GlStateManager.alphaFunc(516, 0.1F);
- GlStateManager.disableLighting();
-
- Utils.pushGuiScale(-1);
- }
-
- /**
- * Used in SettingsInfoPane to redraw the items when a setting changes.
- */
- public void redrawItems() {
- redrawItems = true;
- }
-
- /**
- * Sets the current page and marks that the itemsPane should be redrawn
- * @param page
- */
- public void setPage(int page) {
- this.page = page;
- redrawItems = true;
- }
-
- private Framebuffer[] itemFramebuffers = new Framebuffer[2];
-
- /**
- * Checks whether the screen size has changed, if so it reconstructs the itemPane framebuffer and marks that the
- * itemPane should be redrawn.
- */
- private void checkFramebufferSizes(int width, int height) {
- int sw = width*Utils.peekGuiScale().getScaleFactor();
- int sh = height*Utils.peekGuiScale().getScaleFactor();
- for(int i=0; i<itemFramebuffers.length; i++) {
- if(itemFramebuffers[i] == null || itemFramebuffers[i].framebufferWidth != sw || itemFramebuffers[i].framebufferHeight != sh) {
- if(itemFramebuffers[i] == null) {
- itemFramebuffers[i] = new Framebuffer(sw, sh, true);
- } else {
- itemFramebuffers[i].createBindFramebuffer(sw, sh);
- }
- itemFramebuffers[i].setFramebufferFilter(GL11.GL_NEAREST);
- redrawItems = true;
- }
- }
- }
-
- private void prepareFramebuffer(Framebuffer buffer, int sw, int sh) {
- buffer.framebufferClear();
- buffer.bindFramebuffer(false);
- GL11.glViewport(0, 0, sw, sh);
- }
- private void cleanupFramebuffer(Framebuffer buffer, int sw, int sh) {
- buffer.unbindFramebuffer();
- Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true);
- }
-
- /**
- * Renders all items to a framebuffer so that it can be reused later, drastically improving performance.
- * Unfortunately using this feature will mean that animated textures will not work, but oh well.
- * Mojang please optimize item rendering thanks.
- */
- private void renderItemsToImage(int width, int height, Color fgFavourite2,
- Color fgFavourite, Color fgCustomOpacity, boolean items, boolean entities) {
- int sw = width*Utils.peekGuiScale().getScaleFactor();
- int sh = height*Utils.peekGuiScale().getScaleFactor();
-
- GL11.glPushMatrix();
- prepareFramebuffer(itemFramebuffers[0], sw, sh);
- renderItems(10, items, entities, false);
- cleanupFramebuffer(itemFramebuffers[0], sw, sh);
- GL11.glPopMatrix();
-
- GL11.glPushMatrix();
- prepareFramebuffer(itemFramebuffers[1], sw, sh);
- renderItemBackgrounds(fgFavourite2, fgFavourite, fgCustomOpacity);
- cleanupFramebuffer(itemFramebuffers[1], sw, sh);
- GL11.glPopMatrix();
- }
-
- private static final ResourceLocation RES_ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png");
-
- /**
- * Renders the framebuffer created by #renderItemsToImage to the screen.
- * itemRenderOffset is a magic number that makes the z-level of the rendered items equal to the z-level of
- * the item glint overlay model, meaning that a depthFunc of GL_EQUAL can correctly render on to the item.
- */
- float itemRenderOffset = 7.5001f;
- private void renderItemsFromImage(int xOffset, int width, int height) {
- if(itemFramebuffers[0] != null && itemFramebuffers[1] != null) {
- itemFramebuffers[1].bindFramebufferTexture();
- GlStateManager.color(1f, 1f, 1f, 1f);
- Utils.drawTexturedRect(xOffset-10, 0, width, height, 0, 1, 1, 0);
- itemFramebuffers[1].unbindFramebufferTexture();
-
- GL11.glTranslatef(0, 0, itemRenderOffset);
- itemFramebuffers[0].bindFramebufferTexture();
- GlStateManager.color(1f, 1f, 1f, 1f);
- Utils.drawTexturedRect(xOffset-10, 0, width, height, 0, 1, 1, 0);
- itemFramebuffers[0].unbindFramebufferTexture();
- GL11.glTranslatef(0, 0, -itemRenderOffset);
- }
- }
-
- /**
- * Renders the enchant overlay, since only the items have the specific z-offset of 7.5001, this will only apply
- * the enchant overlay to the actual items and not anything else.
- *
- * (I tried very hard to replicate the enchant rendering overlay code from vanilla, but I couldn't get it to
- * work without rendering with the "ITEM" vertex model like in vanilla, so I choose to render an arbitrary 2D
- * item. If a texture pack sets a custom 3D model for an apple, this will probably break.)
- */
- private void renderEnchOverlay() {
- ItemStack stack = new ItemStack(Items.apple);
- IBakedModel model = Minecraft.getMinecraft().getRenderItem().getItemModelMesher()
- .getItemModel(stack);
- float f = (float)(Minecraft.getSystemTime() % 3000L) / 3000.0F / 8.0F;
- float f1 = (float)(Minecraft.getSystemTime() % 4873L) / 4873.0F / 8.0F;
- Minecraft.getMinecraft().getTextureManager().bindTexture(RES_ITEM_GLINT);
-
- GL11.glPushMatrix();
- GL11.glTranslatef(0, 0, -7.5001f+itemRenderOffset);
- iterateItemSlots(new ItemSlotConsumer() {
- public void consume(int x, int y, int id) {
- JsonObject json = getSearchedItemPage(id);
- if(json == null) {
- return;
- }
- ItemStack stack = manager.jsonToStack(json, true, true, false);
- if (stack == null || !stack.hasEffect()) {
- return;
- }
-
- GlStateManager.pushMatrix();
- GlStateManager.enableRescaleNormal();
- GlStateManager.enableAlpha();
- GlStateManager.alphaFunc(516, 0.1F);
- GlStateManager.enableBlend();
-
- GlStateManager.disableLighting();
-
- GlStateManager.translate(x, y, 0);
- GlStateManager.scale(16f, 16f, 16f);
-
- GlStateManager.depthMask(false);
- GlStateManager.depthFunc(GL11.GL_EQUAL);
- GlStateManager.blendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
- GlStateManager.matrixMode(5890);
- GlStateManager.pushMatrix();
- GlStateManager.scale(8.0F, 8.0F, 8.0F);
- GlStateManager.translate(f, 0.0F, 0.0F);
- GlStateManager.rotate(-50.0F, 0.0F, 0.0F, 1.0F);
-
- renderModel(model, -8372020, null);
-
- GlStateManager.popMatrix();
- GlStateManager.pushMatrix();
- GlStateManager.scale(8.0F, 8.0F, 8.0F);
- GlStateManager.translate(-f1, 0.0F, 0.0F);
- GlStateManager.rotate(10.0F, 0.0F, 0.0F, 1.0F);
-
- renderModel(model, -8372020, null);
-
- GlStateManager.popMatrix();
- GlStateManager.matrixMode(5888);
- GlStateManager.blendFunc(770, 771);
- GlStateManager.depthFunc(515);
- GlStateManager.depthMask(true);
-
- GlStateManager.popMatrix();
- }
- });
- GlStateManager.disableBlend();
- GlStateManager.disableAlpha();
- GlStateManager.disableRescaleNormal();
- GL11.glTranslatef(0, 0, 7.5001f-itemRenderOffset);
- GL11.glPopMatrix();
-
- GlStateManager.bindTexture(0);
- }
-
- private void renderModel(IBakedModel model, int color, ItemStack stack) {
- Tessellator tessellator = Tessellator.getInstance();
- WorldRenderer worldrenderer = tessellator.getWorldRenderer();
- worldrenderer.begin(7, DefaultVertexFormats.ITEM);
-
- for (EnumFacing enumfacing : EnumFacing.values()) {
- this.renderQuads(worldrenderer, model.getFaceQuads(enumfacing), color);
- }
-
- this.renderQuads(worldrenderer, model.getGeneralQuads(), color);
-
- tessellator.draw();
- }
-
- private void renderQuads(WorldRenderer renderer, List<BakedQuad> quads, int color) {
- if(quads == null) return;
-
- for(BakedQuad quad : quads) {
- renderer.addVertexData(quad.getVertexData());
- renderer.putColor4(color);
- }
- }
-
- /**
- * Renders all the item backgrounds, either squares or squircles.
- */
- private void renderItemBackgrounds(Color fgFavourite2, Color fgFavourite, Color fgCustomOpacity) {
- if(fgCustomOpacity.getAlpha() == 0) return;
- iterateItemSlots(new ItemSlotConsumer() {
- public void consume(int x, int y, int id) {
- JsonObject json = getSearchedItemPage(id);
- if (json == null) {
- return;
- }
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(item_mask);
- if (getFavourites().contains(json.get("internalname").getAsString())) {
- if(NotEnoughUpdates.INSTANCE.config.itemlist.itemStyle == 0) {
- GlStateManager.color(fgFavourite2.getRed() / 255f, fgFavourite2.getGreen() / 255f,
- fgFavourite2.getBlue() / 255f, fgFavourite2.getAlpha() / 255f);
- Utils.drawTexturedRect(x - 1, y - 1, ITEM_SIZE + 2, ITEM_SIZE + 2, GL11.GL_NEAREST);
-
- GlStateManager.color(fgFavourite.getRed() / 255f, fgFavourite.getGreen() / 255f,
- fgFavourite.getBlue() / 255f, fgFavourite.getAlpha() / 255f);
- Utils.drawTexturedRect(x, y, ITEM_SIZE, ITEM_SIZE, GL11.GL_NEAREST);
- } else {
- drawRect(x-1, y-1, x+ITEM_SIZE+1, y+ITEM_SIZE+1, fgFavourite2.getRGB());
- drawRect(x, y, x+ITEM_SIZE, y+ITEM_SIZE, fgFavourite.getRGB());
- }
- } else {
- if(NotEnoughUpdates.INSTANCE.config.itemlist.itemStyle == 0) {
- GlStateManager.color(fgCustomOpacity.getRed() / 255f, fgCustomOpacity.getGreen() / 255f,
- fgCustomOpacity.getBlue() / 255f, fgCustomOpacity.getAlpha() / 255f);
- Utils.drawTexturedRect(x - 1, y - 1, ITEM_SIZE + 2, ITEM_SIZE + 2, GL11.GL_NEAREST);
- } else {
- drawRect(x-1, y-1, x+ITEM_SIZE+1, y+ITEM_SIZE+1, fgCustomOpacity.getRGB());
- }
- }
- GlStateManager.bindTexture(0);
- }
- }, 10);
- }
-
- private void renderItems(int xStart, boolean items, boolean entities, boolean glint) {
- iterateItemSlots(new ItemSlotConsumer() {
- public void consume(int x, int y, int id) {
- JsonObject json = getSearchedItemPage(id);
- if (json == null) {
- return;
- }
-
- if (json.has("entityrender")) {
- if(!entities) return;
- String name = json.get("displayname").getAsString();
- String[] split = name.split(" \\(");
- name = name.substring(0, name.length() - split[split.length - 1].length() - 2);
-
- Class<? extends EntityLivingBase>[] entities = new Class[1];
- if (json.get("entityrender").isJsonArray()) {
- JsonArray entityrender = json.get("entityrender").getAsJsonArray();
- entities = new Class[entityrender.size()];
- for (int i = 0; i < entityrender.size(); i++) {
- Class<? extends Entity> clazz = EntityList.stringToClassMapping.get(entityrender.get(i).getAsString());
- if (clazz != null && EntityLivingBase.class.isAssignableFrom(clazz)) {
- entities[i] = (Class<? extends EntityLivingBase>) clazz;
- }
- }
- } else if (json.get("entityrender").isJsonPrimitive()) {
- Class<? extends Entity> clazz = EntityList.stringToClassMapping.get(json.get("entityrender").getAsString());
- if (clazz != null && EntityLivingBase.class.isAssignableFrom(clazz)) {
- entities[0] = (Class<? extends EntityLivingBase>) clazz;
- }
- }
-
- float scale = 8;
- if (json.has("entityscale")) {
- scale *= json.get("entityscale").getAsFloat();
- }
-
- renderEntity(x + ITEM_SIZE / 2, y + ITEM_SIZE, scale, name, entities);
- } else {
- if(!items) return;
- ItemStack stack = manager.jsonToStack(json, true, true, false);
- if(stack != null) {
- if(glint) {
- Utils.drawItemStack(stack, x, y);
- } else {
- Utils.drawItemStackWithoutGlint(stack, x, y);
- }
- }
- }
-
- GlStateManager.translate(0, 0, 50);
- if(searchedItemsSubgroup.containsKey(json.get("internalname").getAsString())) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(item_haschild);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(x-1, y-1, ITEM_SIZE+2, ITEM_SIZE+2, GL11.GL_NEAREST);
- }
- GlStateManager.translate(0, 0, -50);
- }
- }, xStart);
- }
-
- public float getItemPaneOffsetFactor() {
- return itemPaneOffsetFactor.getValue() * getWidthMult() + (1-getWidthMult());
- }
-
- public float getInfoPaneOffsetFactor() {
- return infoPaneOffsetFactor.getValue() * getWidthMult();
- }
-
-} \ No newline at end of file
+ private static final ResourceLocation SUPERGEHEIMNISVERMOGEN =
+ new ResourceLocation("notenoughupdates:supersecretassets/bald.png");
+ private static final ResourceLocation SEARCH_BAR = new ResourceLocation("notenoughupdates:search_bar.png");
+ private static final ResourceLocation SEARCH_BAR_GOLD = new ResourceLocation("notenoughupdates:search_bar_gold.png");
+
+ private static final ResourceLocation ARMOR_DISPLAY =
+ new ResourceLocation("notenoughupdates:armordisplay/armordisplay.png");
+ private static final ResourceLocation ARMOR_DISPLAY_GREY =
+ new ResourceLocation("notenoughupdates:armordisplay/armordisplay_grey.png");
+ private static final ResourceLocation ARMOR_DISPLAY_DARK =
+ new ResourceLocation("notenoughupdates:armordisplay/armordisplay_phq_dark.png");
+ private static final ResourceLocation ARMOR_DISPLAY_FSR =
+ new ResourceLocation("notenoughupdates:armordisplay/armordisplay_fsr.png");
+ private static final ResourceLocation ARMOR_DISPLAY_TRANSPARENT =
+ new ResourceLocation("notenoughupdates:armordisplay/armordisplay_transparent.png");
+ private static final ResourceLocation ARMOR_DISPLAY_TRANSPARENT_PET =
+ new ResourceLocation("notenoughupdates:armordisplay/armordisplay_transparent_pet.png");
+
+ private static final ResourceLocation QUESTION_MARK = new ResourceLocation("notenoughupdates:pv_unknown.png");
+
+ private static final ResourceLocation PET_DISPLAY =
+ new ResourceLocation("notenoughupdates:petdisplay/petdisplaysolo.png");
+ private static final ResourceLocation PET_DISPLAY_GREY =
+ new ResourceLocation("notenoughupdates:petdisplay/petdisplaysolo_dark.png");
+ private static final ResourceLocation PET_DISPLAY_DARK =
+ new ResourceLocation("notenoughupdates:petdisplay/petdisplaysolo_phqdark.png");
+ private static final ResourceLocation PET_DISPLAY_FSR =
+ new ResourceLocation("notenoughupdates:petdisplay/petdisplaysolo_fsr.png");
+ private static final ResourceLocation PET_DISPLAY_TRANSPARENT =
+ new ResourceLocation("notenoughupdates:petdisplay/petdisplaysolo_transparent.png");
+
+ private static final ResourceLocation PET_ARMOR_DISPLAY =
+ new ResourceLocation("notenoughupdates:petdisplay/petdisplayarmor.png");
+ private static final ResourceLocation PET_ARMOR_DISPLAY_GREY =
+ new ResourceLocation("notenoughupdates:petdisplay/petdisplayarmor_dark.png");
+ private static final ResourceLocation PET_ARMOR_DISPLAY_DARK =
+ new ResourceLocation("notenoughupdates:petdisplay/petdisplayarmor_phqdark.png");
+ private static final ResourceLocation PET_ARMOR_DISPLAY_FSR =
+ new ResourceLocation("notenoughupdates:petdisplay/petdisplayarmor_fsr.png");
+ private static final ResourceLocation PET_ARMOR_DISPLAY_TRANSPARENT =
+ new ResourceLocation("notenoughupdates:petdisplay/petdisplayarmor_transparent.png");
+
+ private static boolean renderingArmorHud;
+ private static boolean renderingPetHud;
+ public static boolean shouldUseCachedPet;
+ public static long cachedPetTimer;
+
+ private final NEUManager manager;
+
+ private final String mobRegex = ".*?((_MONSTER)|(_ANIMAL)|(_MINIBOSS)|(_BOSS)|(_SC))$";
+ private final String petRegex = ".*?;[0-5]$";
+
+ private final ResourceLocation[] sortIcons = new ResourceLocation[]{
+ sort_all, sort_mob, sort_pet, sort_tool, sort_armor, sort_accessory
+ };
+ private final ResourceLocation[] sortIconsActive = new ResourceLocation[]{
+ sort_all_active, sort_mob_active, sort_pet_active, sort_tool_active, sort_armor_active, sort_accessory_active
+ };
+
+ private final ResourceLocation[] orderIcons = new ResourceLocation[]{
+ order_alphabetical, order_rarity, order_value
+ };
+ private final ResourceLocation[] orderIconsActive = new ResourceLocation[]{
+ order_alphabetical_active, order_rarity_active, order_value_active
+ };
+
+ //Various constants used for GUI structure
+ private final int searchBarYOffset = 10;
+ private final int searchBarPadding = 2;
+ private long lastSearchMode = 0;
+
+ private float oldWidthMult = 0;
+
+ public static final int ITEM_PADDING = 4;
+ public static final int ITEM_SIZE = 16;
+
+ private Color bg = new Color(90, 90, 140, 50);
+ private Color fg = new Color(100, 100, 100, 255);
+
+ private InfoPane activeInfoPane = null;
+
+ private TreeSet<JsonObject> searchedItems = null;
+ private final List<JsonObject> searchedItemsArr = new ArrayList<>();
+
+ private HashMap<String, List<String>> searchedItemsSubgroup = new HashMap<>();
+
+ private long selectedItemMillis = 0;
+ private int selectedItemGroupX = -1;
+ private int selectedItemGroupY = -1;
+ private List<JsonObject> selectedItemGroup = null;
+
+ private boolean itemPaneOpen = false;
+
+ private int page = 0;
+
+ private final LerpingFloat itemPaneOffsetFactor = new LerpingFloat(1);
+ private final LerpingInteger itemPaneTabOffset = new LerpingInteger(20, 50);
+ private final LerpingFloat infoPaneOffsetFactor = new LerpingFloat(0);
+
+ public boolean searchMode = false;
+ private long millisLastLeftClick = 0;
+ private long millisLastMouseMove = 0;
+ private int lastMouseX = 0;
+ private int lastMouseY = 0;
+
+ public static final int overlayColourDark = new Color(0, 0, 0, 120).getRGB();
+ public static final int overlayColourLight = new Color(255, 255, 255, 120).getRGB();
+
+ boolean mouseDown = false;
+
+ private boolean redrawItems = false;
+
+ private boolean searchBarHasFocus = false;
+ private final GuiTextField textField = new GuiTextField(0, null, 0, 0, 0, 0);
+
+ private static final int COMPARE_MODE_ALPHABETICAL = 0;
+ private static final int COMPARE_MODE_RARITY = 1;
+ private static final int COMPARE_MODE_VALUE = 2;
+
+ private static final int SORT_MODE_ALL = 0;
+ private static final int SORT_MODE_MOB = 1;
+ private static final int SORT_MODE_PET = 2;
+ private static final int SORT_MODE_TOOL = 3;
+ private static final int SORT_MODE_ARMOR = 4;
+ private static final int SORT_MODE_ACCESSORY = 5;
+
+ private boolean disabled = false;
+
+ private int lastScreenWidth;
+ private int lastScreenHeight;
+ private int lastScale;
+
+ private CompletableFuture<Void> infoPaneLoadingJob = CompletableFuture.completedFuture(null);
+
+ private List<String> textToDisplay = null;
+
+ public MBGuiGroupFloating guiGroup = null;
+
+ public NEUOverlay(NEUManager manager) {
+ this.manager = manager;
+ textField.setFocused(true);
+ textField.setCanLoseFocus(false);
+
+ guiGroup = createGuiGroup();
+ }
+
+ private MBGuiElement createSearchBar() {
+ return new MBGuiElement() {
+ public int getWidth() {
+ int paddingUnscaled = getPaddingUnscaled();
+
+ return getSearchBarXSize() + 2 * paddingUnscaled;
+ }
+
+ public int getHeight() {
+ int paddingUnscaled = getPaddingUnscaled();
+
+ return getSearchBarYSize() + 2 * paddingUnscaled;
+ }
+
+ @Override
+ public void mouseClick(float x, float y, int mouseX, int mouseY) {
+ if (!NotEnoughUpdates.INSTANCE.config.toolbar.searchBar) {
+ return;
+ }
+ if (Mouse.getEventButtonState()) {
+ setSearchBarFocus(true);
+ if (Mouse.getEventButton() == 1) { //Right mouse button down
+ textField.setText("");
+ updateSearch();
+ } else {
+ if (System.currentTimeMillis() - millisLastLeftClick < 300) {
+ searchMode = !searchMode;
+ lastSearchMode = System.currentTimeMillis();
+ if (searchMode && NotEnoughUpdates.INSTANCE.config.hidden.firstTimeSearchFocus) {
+ NEUEventListener.displayNotification(Lists.newArrayList(
+ "\u00a7eSearch Highlight",
+ "\u00a77In this mode NEU will gray out non matching items in",
+ "\u00a77your inventory or chests.",
+ "\u00a77This allows you easily find items as the item will stand out.",
+ "\u00a77To toggle this please double click on the search bar in your inventory.",
+ "\u00a77",
+ "\u00a77Press X on your keyboard to close this notification"
+ ), true, true);
+ NotEnoughUpdates.INSTANCE.config.hidden.firstTimeSearchFocus = false;
+
+ }
+ }
+ textField.setCursorPosition(getClickedIndex(mouseX, mouseY));
+ millisLastLeftClick = System.currentTimeMillis();
+ if (searchMode) {
+ lastSearchMode = System.currentTimeMillis();
+ }
+ }
+ }
+ }
+
+ @Override
+ public void mouseClickOutside() {
+ setSearchBarFocus(false);
+ }
+
+ @Override
+ public void render(float x, float y) {
+ if (!NotEnoughUpdates.INSTANCE.config.toolbar.searchBar) {
+ return;
+ }
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+ int paddingUnscaled = getPaddingUnscaled();
+
+ GlStateManager.color(1, 1, 1, 1);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(searchMode ? SEARCH_BAR_GOLD : SEARCH_BAR);
+
+ int w = getWidth();
+ int h = getHeight();
+
+ for (int yIndex = 0; yIndex <= 2; yIndex++) {
+ for (int xIndex = 0; xIndex <= 2; xIndex++) {
+ float uMin = 0;
+ float uMax = 4 / 20f;
+ int partX = (int) x;
+ int partW = 4;
+ if (xIndex == 1) {
+ partX += 4;
+ uMin = 4 / 20f;
+ uMax = 16 / 20f;
+ partW = w - 8;
+ } else if (xIndex == 2) {
+ partX += w - 4;
+ uMin = 16 / 20f;
+ uMax = 20 / 20f;
+ }
+
+ float vMin = 0;
+ float vMax = 4 / 20f;
+ int partY = (int) y;
+ int partH = 4;
+ if (yIndex == 1) {
+ partY += 4;
+ vMin = 4 / 20f;
+ vMax = 16 / 20f;
+ partH = h - 8;
+ } else if (yIndex == 2) {
+ partY += h - 4;
+ vMin = 16 / 20f;
+ vMax = 20 / 20f;
+ }
+
+ Utils.drawTexturedRect(partX, partY, partW, partH, uMin, uMax, vMin, vMax, GL11.GL_NEAREST);
+ }
+ }
+
+ //Search bar text
+ fr.drawString(textField.getText(), (int) x + 5,
+ (int) y - 4 + getHeight() / 2, Color.WHITE.getRGB()
+ );
+
+ //Determines position of cursor. Cursor blinks on and off every 500ms.
+ if (searchBarHasFocus && System.currentTimeMillis() % 1000 > 500) {
+ String textBeforeCursor = textField.getText().substring(0, textField.getCursorPosition());
+ int textBeforeCursorWidth = fr.getStringWidth(textBeforeCursor);
+ drawRect((int) x + 5 + textBeforeCursorWidth,
+ (int) y - 5 + getHeight() / 2,
+ (int) x + 5 + textBeforeCursorWidth + 1,
+ (int) y - 4 + 9 + getHeight() / 2, Color.WHITE.getRGB()
+ );
+ }
+
+ String selectedText = textField.getSelectedText();
+ if (!selectedText.isEmpty()) {
+ int selectionWidth = fr.getStringWidth(selectedText);
+
+ int leftIndex = Math.min(textField.getCursorPosition(), textField.getSelectionEnd());
+ String textBeforeSelection = textField.getText().substring(0, leftIndex);
+ int textBeforeSelectionWidth = fr.getStringWidth(textBeforeSelection);
+
+ drawRect((int) x + 5 + textBeforeSelectionWidth,
+ (int) y - 5 + getHeight() / 2,
+ (int) x + 5 + textBeforeSelectionWidth + selectionWidth,
+ (int) y - 4 + 9 + getHeight() / 2, Color.LIGHT_GRAY.getRGB()
+ );
+
+ fr.drawString(selectedText,
+ (int) x + 5 + textBeforeSelectionWidth,
+ (int) y - 4 + getHeight() / 2, Color.BLACK.getRGB()
+ );
+ }
+
+ }
+
+ @Override
+ public void recalculate() {
+ }
+ };
+ }
+
+ private MBGuiElement createSettingsButton(NEUOverlay overlay) {
+ return new MBGuiElement() {
+ @Override
+ public int getWidth() {
+ return getSearchBarYSize() + getPaddingUnscaled() * 2;
+ }
+
+ @Override
+ public int getHeight() {
+ return getWidth();
+ }
+
+ @Override
+ public void recalculate() {
+ }
+
+ @Override
+ public void mouseClick(float x, float y, int mouseX, int mouseY) {
+ if (!NotEnoughUpdates.INSTANCE.config.toolbar.enableSettingsButton) {
+ return;
+ }
+ if (Mouse.getEventButtonState()) {
+ NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper(NEUConfigEditor.editor);
+ }
+ }
+
+ @Override
+ public void mouseClickOutside() {
+ }
+
+ @Override
+ public void render(float x, float y) {
+ int paddingUnscaled = getPaddingUnscaled();
+ int searchYSize = getSearchBarYSize();
+
+ if (!NotEnoughUpdates.INSTANCE.config.toolbar.enableSettingsButton) {
+ return;
+ }
+ Minecraft.getMinecraft().getTextureManager().bindTexture(quickcommand_background);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(x, y,
+ searchYSize + paddingUnscaled * 2, searchYSize + paddingUnscaled * 2, GL11.GL_NEAREST
+ );
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(settings);
+ GlStateManager.color(1f, 1f, 1f, 1f);
+ Utils.drawTexturedRect((int) x + paddingUnscaled, (int) y + paddingUnscaled,
+ searchYSize, searchYSize
+ );
+
+ GlStateManager.bindTexture(0);
+ }
+ };
+ }
+
+ private MBGuiElement createHelpButton(NEUOverlay overlay) {
+ return new MBGuiElement() {
+ @Override
+ public int getWidth() {
+ return getSearchBarYSize() + getPaddingUnscaled() * 2;
+ }
+
+ @Override
+ public int getHeight() {
+ return getWidth();
+ }
+
+ @Override
+ public void recalculate() {
+ }
+
+ @Override
+ public void mouseClick(float x, float y, int mouseX, int mouseY) {
+ if (!NotEnoughUpdates.INSTANCE.config.toolbar.enableHelpButton) {
+ return;
+ }
+ if (Mouse.getEventButtonState()) {
+ //displayInformationPane(HTMLInfoPane.createFromWikiUrl(overlay, manager, "Help",
+ // "https://moulberry.github.io/files/neu_help.html"));
+ //Minecraft.getMinecraft().displayGuiScreen(new HelpGUI());
+ ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/neuhelp");
+ Utils.playPressSound();
+ }
+ }
+
+ @Override
+ public void mouseClickOutside() {
+ }
+
+ @Override
+ public void render(float x, float y) {
+ int paddingUnscaled = getPaddingUnscaled();
+ int searchYSize = getSearchBarYSize();
+
+ if (!NotEnoughUpdates.INSTANCE.config.toolbar.enableHelpButton) {
+ return;
+ }
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(quickcommand_background);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(x, y,
+ searchYSize + paddingUnscaled * 2, searchYSize + paddingUnscaled * 2, GL11.GL_NEAREST
+ );
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(help);
+ GlStateManager.color(1f, 1f, 1f, 1f);
+ Utils.drawTexturedRect((int) x + paddingUnscaled, (int) y + paddingUnscaled,
+ getSearchBarYSize(), getSearchBarYSize()
+ );
+ GlStateManager.bindTexture(0);
+
+ }
+ };
+ }
+
+ private MBGuiElement createQuickCommand(String quickCommandStr) {
+ return new MBGuiElement() {
+ @Override
+ public int getWidth() {
+ return getSearchBarYSize() + getPaddingUnscaled() * 2;
+ }
+
+ @Override
+ public int getHeight() {
+ return getWidth();
+ }
+
+ @Override
+ public void recalculate() {
+ }
+
+ @Override
+ public void mouseClick(float x, float y, int mouseX, int mouseY) {
+ if (!NotEnoughUpdates.INSTANCE.config.toolbar.quickCommands) return;
+
+ if ((NotEnoughUpdates.INSTANCE.config.toolbar.quickCommandsClickType != 0 && Mouse.getEventButtonState()) ||
+ (NotEnoughUpdates.INSTANCE.config.toolbar.quickCommandsClickType == 0 &&
+ !Mouse.getEventButtonState() &&
+ Mouse.getEventButton() != -1)) {
+ if (quickCommandStr.contains(":")) {
+ String command = quickCommandStr.split(":")[0].trim();
+ if (command.startsWith("/")) {
+ NotEnoughUpdates.INSTANCE.sendChatMessage(command);
+ } else {
+ ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/" + command);
+ }
+ Utils.playPressSound();
+ }
+ }
+ }
+
+ @Override
+ public void mouseClickOutside() {
+ }
+
+ @Override
+ public void render(float x, float y) {
+ if (!NotEnoughUpdates.INSTANCE.config.toolbar.quickCommands) return;
+
+ int paddingUnscaled = getPaddingUnscaled();
+ int bigItemSize = getSearchBarYSize();
+
+ String[] quickCommandStrSplit = quickCommandStr.split(":");
+ if (quickCommandStrSplit.length != 3) {
+ return;
+ }
+ String display = quickCommandStrSplit[2];
+ ItemStack render = null;
+ float extraScale = 1;
+ if (display.length() > 20) { //Custom head
+ render = new ItemStack(Items.skull, 1, 3);
+ NBTTagCompound nbt = new NBTTagCompound();
+ NBTTagCompound skullOwner = new NBTTagCompound();
+ NBTTagCompound properties = new NBTTagCompound();
+ NBTTagList textures = new NBTTagList();
+ NBTTagCompound textures_0 = new NBTTagCompound();
+
+ String uuid = UUID.nameUUIDFromBytes(display.getBytes()).toString();
+ skullOwner.setString("Id", uuid);
+ skullOwner.setString("Name", uuid);
+
+ textures_0.setString("Value", display);
+ textures.appendTag(textures_0);
+
+ properties.setTag("textures", textures);
+ skullOwner.setTag("Properties", properties);
+ nbt.setTag("SkullOwner", skullOwner);
+ render.setTagCompound(nbt);
+
+ extraScale = 1.3f;
+ } else if (manager.getItemInformation().containsKey(display)) {
+ render = manager.jsonToStack(manager.getItemInformation().get(display), true, true);
+ } else {
+ Item item = Item.itemRegistry.getObject(new ResourceLocation(display.toLowerCase()));
+ if (item != null) {
+ render = new ItemStack(item);
+ }
+ }
+ if (render != null) {
+ NBTTagCompound tag = render.getTagCompound() != null ? render.getTagCompound() : new NBTTagCompound();
+ tag.setString("qc_id", quickCommandStrSplit[0].toLowerCase().trim());
+ render.setTagCompound(tag);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(quickcommand_background);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(x, y,
+ bigItemSize + paddingUnscaled * 2, bigItemSize + paddingUnscaled * 2, GL11.GL_NEAREST
+ );
+
+ int mouseX = Mouse.getX() * Utils.peekGuiScale().getScaledWidth() / Minecraft.getMinecraft().displayWidth;
+ int mouseY = Utils.peekGuiScale().getScaledHeight() -
+ Mouse.getY() * Utils.peekGuiScale().getScaledHeight() / Minecraft.getMinecraft().displayHeight -
+ 1;
+
+ if (mouseX > x && mouseX < x + bigItemSize) {
+ if (mouseY > y && mouseY < y + bigItemSize) {
+ textToDisplay = new ArrayList<>();
+ textToDisplay.add(EnumChatFormatting.GRAY + quickCommandStrSplit[1]);
+ }
+ }
+
+ GlStateManager.enableDepth();
+ float itemScale = bigItemSize / (float) ITEM_SIZE * extraScale;
+ GlStateManager.pushMatrix();
+ GlStateManager.scale(itemScale, itemScale, 1);
+ GlStateManager.translate((x - (extraScale - 1) * bigItemSize / 2 + paddingUnscaled) / itemScale,
+ (y - (extraScale - 1) * bigItemSize / 2 + paddingUnscaled) / itemScale, 0f
+ );
+ Utils.drawItemStack(render, 0, 0);
+ GlStateManager.popMatrix();
+ }
+ }
+ };
+ }
+
+ private MBGuiGroupAligned createQuickCommandGroup() {
+ List<MBGuiElement> children = new ArrayList<>();
+ for (String quickCommand : NotEnoughUpdates.INSTANCE.config.hidden.quickCommands) {
+ children.add(createQuickCommand(quickCommand));
+ }
+ return new MBGuiGroupAligned(children, false) {
+ public int getPadding() {
+ return getPaddingUnscaled() * 4;
+ }
+ };
+ }
+
+ private MBGuiGroupAligned createSearchBarGroup() {
+ List<MBGuiElement> children =
+ Lists.newArrayList(createSettingsButton(this), createSearchBar(), createHelpButton(this));
+ return new MBGuiGroupAligned(children, false) {
+ public int getPadding() {
+ return getPaddingUnscaled() * 4;
+ }
+ };
+ }
+
+ private MBGuiGroupFloating createGuiGroup() {
+ LinkedHashMap<MBGuiElement, MBAnchorPoint> map = new LinkedHashMap<>();
+
+ MBAnchorPoint searchBarAnchor =
+ MBAnchorPoint.createFromString(NotEnoughUpdates.INSTANCE.config.hidden.overlaySearchBar);
+ MBAnchorPoint quickCommandAnchor =
+ MBAnchorPoint.createFromString(NotEnoughUpdates.INSTANCE.config.hidden.overlayQuickCommand);
+
+ searchBarAnchor = searchBarAnchor != null ? searchBarAnchor :
+ new MBAnchorPoint(MBAnchorPoint.AnchorPoint.BOTMID, new Vector2f(0, -searchBarYOffset));
+ quickCommandAnchor = quickCommandAnchor != null ? quickCommandAnchor :
+ new MBAnchorPoint(MBAnchorPoint.AnchorPoint.BOTMID, new Vector2f(
+ 0,
+ -searchBarYOffset - getSearchBarYSize() - getPaddingUnscaled() * 4
+ ));
+
+ map.put(createSearchBarGroup(), searchBarAnchor);
+ map.put(createQuickCommandGroup(), quickCommandAnchor);
+
+ return new MBGuiGroupFloating(Utils.peekGuiScale().getScaledWidth(), Utils.peekGuiScale().getScaledHeight(), map);
+ }
+
+ public void resetAnchors(boolean onlyIfNull) {
+ MBAnchorPoint searchBarAnchor =
+ MBAnchorPoint.createFromString(NotEnoughUpdates.INSTANCE.config.hidden.overlaySearchBar);
+ MBAnchorPoint quickCommandAnchor =
+ MBAnchorPoint.createFromString(NotEnoughUpdates.INSTANCE.config.hidden.overlayQuickCommand);
+
+ if (onlyIfNull) {
+ searchBarAnchor = searchBarAnchor != null ? null :
+ new MBAnchorPoint(MBAnchorPoint.AnchorPoint.BOTMID, new Vector2f(0, -searchBarYOffset));
+ quickCommandAnchor = quickCommandAnchor != null ? null :
+ new MBAnchorPoint(MBAnchorPoint.AnchorPoint.BOTMID, new Vector2f(
+ 0,
+ -searchBarYOffset - getSearchBarYSize() - getPaddingUnscaled() * 4
+ ));
+ } else {
+ searchBarAnchor = searchBarAnchor != null ? searchBarAnchor :
+ new MBAnchorPoint(MBAnchorPoint.AnchorPoint.BOTMID, new Vector2f(0, -searchBarYOffset));
+ quickCommandAnchor = quickCommandAnchor != null ? quickCommandAnchor :
+ new MBAnchorPoint(MBAnchorPoint.AnchorPoint.BOTMID, new Vector2f(
+ 0,
+ -searchBarYOffset - getSearchBarYSize() - getPaddingUnscaled() * 4
+ ));
+ }
+
+ int index = 0;
+ Set<MBGuiElement> set = new LinkedHashSet<>(guiGroup.getChildrenMap().keySet());
+ for (MBGuiElement element : set) {
+ switch (index) {
+ case 0:
+ if (searchBarAnchor == null) continue;
+ guiGroup.getChildrenMap().get(element).anchorPoint = searchBarAnchor.anchorPoint;
+ guiGroup.getChildrenMap().get(element).offset = searchBarAnchor.offset;
+ break;
+ case 1:
+ if (quickCommandAnchor == null) continue;
+ guiGroup.getChildrenMap().get(element).anchorPoint = quickCommandAnchor.anchorPoint;
+ guiGroup.getChildrenMap().get(element).offset = quickCommandAnchor.offset;
+ break;
+ }
+ index++;
+ }
+ }
+
+ /**
+ * Disables searchBarFocus and resets the item pane position. Called whenever NEUOverlay is opened.
+ */
+ public void reset() {
+ searchBarHasFocus = false;
+ if (!(searchMode || (NotEnoughUpdates.INSTANCE.config.itemlist.keepopen && itemPaneOpen))) {
+ itemPaneOpen = false;
+ displayInformationPane(null);
+ itemPaneOffsetFactor.setValue(1);
+ itemPaneTabOffset.setValue(20);
+ }
+ if (activeInfoPane != null) activeInfoPane.reset();
+ guiGroup.recalculate();
+ }
+
+ /**
+ * Calls #displayInformationPane with a HTMLInfoPane created from item.info and item.infoType.
+ */
+ public void showInfo(JsonObject item) {
+ if (item.has("info") && item.has("infoType")) {
+ JsonArray lore = item.get("info").getAsJsonArray();
+ StringBuilder loreBuilder = new StringBuilder();
+ for (int i = 0; i < lore.size(); i++) {
+ loreBuilder.append(lore.get(i).getAsString());
+ if (i != lore.size() - 1)
+ loreBuilder.append("\n");
+ }
+ String infoText = loreBuilder.toString();
+ String internalname = item.get("internalname").getAsString();
+ String name = item.get("displayname").getAsString();
+ String infoType = item.get("infoType").getAsString();
+ displayInformationPane(new TextInfoPane(this, manager, "Loading", "Loading your requested information about " +
+ name +
+ "."));
+ infoPaneLoadingJob = InfoPane.create(this, manager, infoType, name, internalname, infoText)
+ .thenAccept(this::displayInformationPane);
+ }
+ }
+
+ public void mouseInputInv() {
+ if (Minecraft.getMinecraft().currentScreen instanceof GuiContainer) {
+ if (Mouse.getEventButton() == manager.keybindItemSelect.getKeyCode() + 100 &&
+ NotEnoughUpdates.INSTANCE.config.toolbar.searchBar) {
+ Slot slot = Utils.getSlotUnderMouse((GuiContainer) Minecraft.getMinecraft().currentScreen);
+ if (slot != null) {
+ ItemStack hover = slot.getStack();
+ if (hover != null) {
+ textField.setText("id:" + manager.getInternalNameForItem(hover));
+ itemPaneOpen = true;
+ updateSearch();
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Handles the mouse input, cancelling the forge event if a NEU gui element is clicked.
+ */
+ public boolean mouseInput() {
+ if (disabled) {
+ return false;
+ }
+
+ Utils.pushGuiScale(NotEnoughUpdates.INSTANCE.config.itemlist.paneGuiScale);
+
+ int width = Utils.peekGuiScale().getScaledWidth();
+ int height = Utils.peekGuiScale().getScaledHeight();
+ int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
+ int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
+
+ //if(lastMouseX != mouseX || lastMouseY != mouseY) {
+ // millisLastMouseMove = System.currentTimeMillis();
+ //}
+
+ lastMouseX = mouseX;
+ lastMouseY = mouseY;
+
+ if (Mouse.getEventButtonState()) {
+ mouseDown = true;
+ } else if (Mouse.getEventButton() != -1) {
+ mouseDown = false;
+ }
+
+ //Unfocuses the search bar by default. Search bar is focused if the click is on the bar itself.
+ if (Mouse.getEventButtonState()) setSearchBarFocus(false);
+
+ guiGroup.mouseClick(0, 0, mouseX, mouseY);
+
+ if (selectedItemGroup != null) {
+ int selectedX = Math.min(selectedItemGroupX, width - getBoxPadding() - 18 * selectedItemGroup.size());
+ if (mouseY > selectedItemGroupY + 17 && mouseY < selectedItemGroupY + 35) {
+ for (int i = 0; i < selectedItemGroup.size(); i++) {
+ if (mouseX >= selectedX - 1 + 18 * i && mouseX <= selectedX + 17 + 18 * i) {
+ JsonObject item = selectedItemGroup.get(i);
+ if (item != null) {
+ if (Mouse.getEventButton() == 0) {
+ manager.showRecipe(item);
+ } else if (Mouse.getEventButton() == 1) {
+ showInfo(item);
+ } else if (Mouse.getEventButton() == manager.keybindItemSelect.getKeyCode() + 100 &&
+ NotEnoughUpdates.INSTANCE.config.toolbar.searchBar) {
+ textField.setText("id:" + item.get("internalname").getAsString());
+ updateSearch();
+ searchMode = true;
+ }
+ }
+ Utils.pushGuiScale(-1);
+ return true;
+ }
+ }
+ }
+ }
+
+ //Item selection (right) gui
+ if (mouseX > width * getItemPaneOffsetFactor()) {
+ if (!Mouse.getEventButtonState()) {
+ Utils.pushGuiScale(-1);
+ return true; //End early if the mouse isn't pressed, but still cancel event.
+ }
+
+ AtomicBoolean clickedItem = new AtomicBoolean(false);
+ iterateItemSlots(new ItemSlotConsumer() {
+ public void consume(int x, int y, int id) {
+ if (mouseX >= x - 1 && mouseX <= x + ITEM_SIZE + 1) {
+ if (mouseY >= y - 1 && mouseY <= y + ITEM_SIZE + 1) {
+ clickedItem.set(true);
+
+ JsonObject item = getSearchedItemPage(id);
+ if (item != null) {
+ if (Mouse.getEventButton() == 0) {
+ manager.showRecipe(item);
+ } else if (Mouse.getEventButton() == 1) {
+ showInfo(item);
+ } else if (Mouse.getEventButton() == manager.keybindItemSelect.getKeyCode() + 100 &&
+ NotEnoughUpdates.INSTANCE.config.toolbar.searchBar) {
+ textField.setText("id:" + item.get("internalname").getAsString());
+ updateSearch();
+ searchMode = true;
+ }
+ }
+ }
+ }
+ }
+ });
+ if (!clickedItem.get()) {
+ int paneWidth = (int) (width / 3 * getWidthMult());
+ int leftSide = (int) (width * getItemPaneOffsetFactor());
+ int rightSide = leftSide + paneWidth - getBoxPadding() - getItemBoxXPadding();
+ leftSide = leftSide + getBoxPadding() + getItemBoxXPadding();
+
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+ int maxPages = getMaxPages();
+ String name = Utils.peekGuiScale().getScaleFactor() < 4 ? "Page: " : "";
+ float maxStrLen = fr.getStringWidth(EnumChatFormatting.BOLD + name + maxPages + "/" + maxPages);
+ float maxButtonXSize = (rightSide - leftSide + 2 - maxStrLen * 0.5f - 10) / 2f;
+ int buttonXSize = (int) Math.min(maxButtonXSize, getSearchBarYSize() * 480 / 160f);
+ int ySize = (int) (buttonXSize / 480f * 160);
+ int yOffset = (int) ((getSearchBarYSize() - ySize) / 2f);
+ int top = getBoxPadding() + yOffset;
+
+ if (mouseY >= top && mouseY <= top + ySize) {
+ int leftPrev = leftSide - 1;
+ if (mouseX > leftPrev && mouseX < leftPrev + buttonXSize) { //"Previous" button
+ setPage(page - 1);
+ Utils.playPressSound();
+ }
+ int leftNext = rightSide + 1 - buttonXSize;
+ if (mouseX > leftNext && mouseX < leftNext + buttonXSize) { //"Next" button
+ setPage(page + 1);
+ Utils.playPressSound();
+ }
+ }
+
+ float sortIconsMinX = (sortIcons.length + orderIcons.length) * (ITEM_SIZE + ITEM_PADDING) + ITEM_SIZE;
+ float availableX = rightSide - leftSide;
+ float sortOrderScaleFactor = Math.min(1, availableX / sortIconsMinX);
+
+ int scaledITEM_SIZE = (int) (ITEM_SIZE * sortOrderScaleFactor);
+ int scaledItemPaddedSize = (int) ((ITEM_SIZE + ITEM_PADDING) * sortOrderScaleFactor);
+ int iconTop = height - getBoxPadding() - (ITEM_SIZE + scaledITEM_SIZE) / 2 - 1;
+
+ if (mouseY >= iconTop && mouseY <= iconTop + scaledITEM_SIZE) {
+ for (int i = 0; i < orderIcons.length; i++) {
+ int orderIconX = leftSide + i * scaledItemPaddedSize;
+ if (mouseX >= orderIconX && mouseX <= orderIconX + scaledITEM_SIZE) {
+ if (Mouse.getEventButton() == 0) {
+ NotEnoughUpdates.INSTANCE.config.hidden.compareMode = i;
+ updateSearch();
+ Utils.playPressSound();
+ } else if (Mouse.getEventButton() == 1) {
+ NotEnoughUpdates.INSTANCE.config.hidden.compareAscending.set(
+ i,
+ !NotEnoughUpdates.INSTANCE.config.hidden.compareAscending.get(i)
+ );
+ updateSearch();
+ Utils.playPressSound();
+ }
+ }
+ }
+
+ for (int i = 0; i < sortIcons.length; i++) {
+ int sortIconX = rightSide - scaledITEM_SIZE - i * scaledItemPaddedSize;
+ if (mouseX >= sortIconX && mouseX <= sortIconX + scaledITEM_SIZE) {
+ NotEnoughUpdates.INSTANCE.config.hidden.sortMode = i;
+ updateSearch();
+ Utils.playPressSound();
+ }
+ }
+ }
+ }
+ Utils.pushGuiScale(-1);
+ return true;
+ }
+
+ //Clicking on "close info pane" button
+ if (mouseX > width * getInfoPaneOffsetFactor() - getBoxPadding() - 8 &&
+ mouseX < width * getInfoPaneOffsetFactor() - getBoxPadding() + 8) {
+ if (mouseY > getBoxPadding() - 8 && mouseY < getBoxPadding() + 8) {
+ if (Mouse.getEventButtonState() && Mouse.getEventButton() < 2) { //Left or right click up
+ displayInformationPane(null);
+ Utils.pushGuiScale(-1);
+ return true;
+ }
+ }
+ }
+
+ if (activeInfoPane != null) {
+ if (mouseX < width * getInfoPaneOffsetFactor()) {
+ activeInfoPane.mouseInput(width, height, mouseX, mouseY, mouseDown);
+ Utils.pushGuiScale(-1);
+ return true;
+ } else if (Mouse.getEventButton() <= 1 && Mouse.getEventButtonState()) { //Left or right click
+ activeInfoPane.mouseInputOutside();
+ }
+ }
+
+ Utils.pushGuiScale(-1);
+ return false;
+ }
+
+ public int getPaddingUnscaled() {
+ int paddingUnscaled = searchBarPadding / Utils.peekGuiScale().getScaleFactor();
+ if (paddingUnscaled < 1) paddingUnscaled = 1;
+
+ return paddingUnscaled;
+ }
+
+ public GuiTextField getTextField() {
+ return textField;
+ }
+
+ /**
+ * Returns searchBarXSize, scaled by 0.8 if gui scale == AUTO.
+ */
+ public int getSearchBarXSize() {
+ int searchBarXSize = NotEnoughUpdates.INSTANCE.config.toolbar.searchBarWidth;
+ if (Utils.peekGuiScale().getScaleFactor() == 4) return (int) (searchBarXSize * 0.8);
+ return searchBarXSize;
+ }
+
+ /**
+ * Sets the activeInfoPane and sets the target of the infoPaneOffsetFactor to make the infoPane "slide" out.
+ */
+ public void displayInformationPane(InfoPane pane) {
+ infoPaneLoadingJob.cancel(false);
+ if (pane == null) {
+ infoPaneOffsetFactor.setTarget(0);
+ } else {
+ infoPaneOffsetFactor.setTarget(1 / 3f);
+ }
+ infoPaneOffsetFactor.resetTimer();
+ this.activeInfoPane = pane;
+ }
+
+ public InfoPane getActiveInfoPane() {
+ return activeInfoPane;
+ }
+
+ /**
+ * Finds the index of the character inside the search bar that was clicked, used to set the caret.
+ */
+ public int getClickedIndex(int mouseX, int mouseY) {
+ int width = Utils.peekGuiScale().getScaledWidth();
+ int height = Utils.peekGuiScale().getScaledHeight();
+
+ int xComp = mouseX - (width / 2 - getSearchBarXSize() / 2 + 5);
+
+ String trimmed = Minecraft.getMinecraft().fontRendererObj.trimStringToWidth(textField.getText(), xComp);
+ int linePos = trimmed.length();
+ if (linePos != textField.getText().length()) {
+ char after = textField.getText().charAt(linePos);
+ int trimmedWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(trimmed);
+ int charWidth = Minecraft.getMinecraft().fontRendererObj.getCharWidth(after);
+ if (trimmedWidth + charWidth / 2 < xComp - 5) {
+ linePos++;
+ }
+ }
+ return linePos;
+ }
+
+ public void setSearchBarFocus(boolean focus) {
+ if (focus) {
+ itemPaneOpen = true;
+ }
+ searchBarHasFocus = focus;
+ }
+
+ /**
+ * Handles the keyboard input, cancelling the forge event if the search bar has focus.
+ */
+ public boolean keyboardInput(boolean hoverInv) {
+ if (Minecraft.getMinecraft().currentScreen == null) return false;
+ Keyboard.enableRepeatEvents(true);
+
+ int keyPressed = Keyboard.getEventKey() == 0 ? Keyboard.getEventCharacter() + 256 : Keyboard.getEventKey();
+
+ if (disabled) {
+ if (Keyboard.getEventKeyState() && keyPressed == manager.keybindToggleDisplay.getKeyCode()) {
+ disabled = !disabled;
+ }
+ return false;
+ }
+
+ if (Keyboard.isKeyDown(Keyboard.KEY_Y) && NotEnoughUpdates.INSTANCE.config.hidden.dev) {
+ displayInformationPane(new DevInfoPane(this, manager));
+ }
+
+ if (Keyboard.getEventKeyState()) {
+ if (!NotEnoughUpdates.INSTANCE.config.toolbar.searchBar) {
+ searchBarHasFocus = false;
+ }
+ if (searchBarHasFocus) {
+ if (keyPressed == 1) {
+ searchBarHasFocus = false;
+ } else {
+ if (textField.textboxKeyTyped(Keyboard.getEventCharacter(), keyPressed)) {
+ updateSearch();
+ }
+ }
+ } else {
+ if (activeInfoPane != null) {
+ if (activeInfoPane.keyboardInput()) {
+ return true;
+ }
+ }
+
+ if (keyPressed == manager.keybindClosePanes.getKeyCode()) {
+ itemPaneOffsetFactor.setValue(1);
+ itemPaneTabOffset.setValue(20);
+ itemPaneOpen = false;
+ displayInformationPane(null);
+ }
+
+ if (keyPressed == manager.keybindToggleDisplay.getKeyCode()) {
+ disabled = !disabled;
+ return true;
+ }
+
+ AtomicReference<String> internalname = new AtomicReference<>(null);
+ AtomicReference<ItemStack> itemstack = new AtomicReference<>(null);
+ if (Minecraft.getMinecraft().currentScreen instanceof GuiContainer &&
+ Utils.getSlotUnderMouse((GuiContainer) Minecraft.getMinecraft().currentScreen) != null) {
+ Slot slot = Utils.getSlotUnderMouse((GuiContainer) Minecraft.getMinecraft().currentScreen);
+ ItemStack hover = slot.getStack();
+ if (hover != null) {
+ internalname.set(manager.getInternalNameForItem(hover));
+ itemstack.set(hover);
+ }
+ } else if (!hoverInv) {
+ Utils.pushGuiScale(NotEnoughUpdates.INSTANCE.config.itemlist.paneGuiScale);
+
+ int width = Utils.peekGuiScale().getScaledWidth();
+ int height = Utils.peekGuiScale().getScaledHeight();
+ int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
+ int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
+
+ if (selectedItemGroup != null) {
+ int selectedX = Math.min(selectedItemGroupX, width - getBoxPadding() - 18 * selectedItemGroup.size());
+
+ if (mouseY > selectedItemGroupY + 17 && mouseY < selectedItemGroupY + 35) {
+ for (int i = 0; i < selectedItemGroup.size(); i++) {
+ if (mouseX >= selectedX - 1 + 18 * i && mouseX <= selectedX + 17 + 18 * i) {
+ internalname.set(selectedItemGroup.get(i).get("internalname").getAsString());
+ }
+ }
+ }
+ } else {
+ iterateItemSlots(new ItemSlotConsumer() {
+ public void consume(int x, int y, int id) {
+ if (mouseX >= x - 1 && mouseX <= x + ITEM_SIZE + 1) {
+ if (mouseY >= y - 1 && mouseY <= y + ITEM_SIZE + 1) {
+ JsonObject json = getSearchedItemPage(id);
+ if (json != null) internalname.set(json.get("internalname").getAsString());
+ }
+ }
+ }
+ });
+ }
+
+ Utils.pushGuiScale(-1);
+ }
+ if (internalname.get() != null) {
+ if (itemstack.get() != null) {
+ if (NotEnoughUpdates.INSTANCE.config.hidden.enableItemEditing && Keyboard.getEventCharacter() == 'k') {
+ Minecraft.getMinecraft().displayGuiScreen(new NEUItemEditor(manager,
+ internalname.get(), manager.getJsonForItem(itemstack.get())
+ ));
+ return true;
+ }
+ }
+ JsonObject item = manager.getItemInformation().get(internalname.get());
+ if (item != null) {
+ if (keyPressed == manager.keybindViewUsages.getKeyCode()) {
+ manager.displayGuiItemUsages(internalname.get());
+ return true;
+ } else if (keyPressed == manager.keybindFavourite.getKeyCode()) {
+ toggleFavourite(item.get("internalname").getAsString());
+ return true;
+ } else if (keyPressed == manager.keybindViewRecipe.getKeyCode()) {
+ manager.showRecipe(item);
+ return true;
+ } else if (keyPressed == manager.keybindGive.getKeyCode()) {
+ if (Minecraft.getMinecraft().thePlayer.capabilities.isCreativeMode) {
+ Minecraft.getMinecraft().thePlayer.inventory.addItemStackToInventory(
+ manager.jsonToStack(item));
+ }
+ } else if (NotEnoughUpdates.INSTANCE.config.hidden.enableItemEditing &&
+ Keyboard.getEventCharacter() == 'k') {
+ Minecraft.getMinecraft().displayGuiScreen(new NEUItemEditor(manager,
+ internalname.get(), item
+ ));
+ return true;
+ } else if (keyPressed == manager.keybindItemSelect.getKeyCode() &&
+ NotEnoughUpdates.INSTANCE.config.toolbar.searchBar) {
+ textField.setText("id:" + internalname.get());
+ itemPaneOpen = true;
+ updateSearch();
+ } else if (keyPressed == NotEnoughUpdates.INSTANCE.config.ahGraph.graphKey &&
+ NotEnoughUpdates.INSTANCE.config.ahGraph.graphEnabled) {
+ NotEnoughUpdates.INSTANCE.openGui = new GuiPriceGraph(internalname.get());
+ return true;
+ }
+ }
+ }
+ }
+ }
+
+ return searchBarHasFocus; //Cancels keyboard events if the search bar has focus
+ }
+
+ public void toggleFavourite(String internalname) {
+ if (getFavourites().contains(internalname)) {
+ getFavourites().remove(internalname);
+ } else {
+ getFavourites().add(internalname);
+ }
+ updateSearch();
+ }
+
+ String[] rarityArr = new String[]{
+ EnumChatFormatting.WHITE + EnumChatFormatting.BOLD.toString() + "COMMON",
+ EnumChatFormatting.GREEN + EnumChatFormatting.BOLD.toString() + "UNCOMMON",
+ EnumChatFormatting.BLUE + EnumChatFormatting.BOLD.toString() + "RARE",
+ EnumChatFormatting.DARK_PURPLE + EnumChatFormatting.BOLD.toString() + "EPIC",
+ EnumChatFormatting.GOLD + EnumChatFormatting.BOLD.toString() + "LEGENDARY",
+ EnumChatFormatting.LIGHT_PURPLE + EnumChatFormatting.BOLD.toString() + "MYTHIC",
+ EnumChatFormatting.RED + EnumChatFormatting.BOLD.toString() + "SPECIAL",
+ };
+
+ /**
+ * Finds the rarity from the lore of an item.
+ * -1 = UNKNOWN
+ * 0 = COMMON
+ * 1 = UNCOMMON
+ * 2 = RARE
+ * 3 = EPIC
+ * 4 = LEGENDARY
+ * 5 = MYTHIC
+ * 6 = SPECIAL
+ */
+ public int getRarity(JsonArray lore) {
+ for (int i = lore.size() - 1; i >= 0; i--) {
+ String line = lore.get(i).getAsString();
+
+ for (int j = 0; j < rarityArr.length; j++) {
+ if (line.startsWith(rarityArr[j])) {
+ return j;
+ }
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * Convenience functions that get various compare/sort modes from the config.
+ */
+ private int getCompareMode() {
+ return NotEnoughUpdates.INSTANCE.config.hidden.compareMode;
+ }
+
+ private int getSortMode() {
+ return NotEnoughUpdates.INSTANCE.config.hidden.sortMode;
+ }
+
+ private List<Boolean> getCompareAscending() {
+ return NotEnoughUpdates.INSTANCE.config.hidden.compareAscending;
+ }
+
+ private List<String> getFavourites() {
+ return NotEnoughUpdates.INSTANCE.config.hidden.favourites;
+ }
+
+ /**
+ * Creates an item comparator used to sort the list of items according to the favourite set then compare mode.
+ * Defaults to alphabetical sorting if the above factors cannot distinguish between two items.
+ */
+ private Comparator<JsonObject> getItemComparator() {
+ return (o1, o2) -> {
+ //1 (mult) if o1 should appear after o2
+ //-1 (-mult) if o2 should appear after o1
+ if (getFavourites().contains(o1.get("internalname").getAsString()) &&
+ !getFavourites().contains(o2.get("internalname").getAsString())) {
+ return -1;
+ }
+ if (!getFavourites().contains(o1.get("internalname").getAsString()) &&
+ getFavourites().contains(o2.get("internalname").getAsString())) {
+ return 1;
+ }
+
+ int mult = getCompareAscending().get(getCompareMode()) ? 1 : -1;
+ if (getCompareMode() == COMPARE_MODE_RARITY) {
+ int rarity1 = getRarity(o1.get("lore").getAsJsonArray());
+ int rarity2 = getRarity(o2.get("lore").getAsJsonArray());
+
+ if (rarity1 < rarity2) return mult;
+ if (rarity1 > rarity2) return -mult;
+ } else if (getCompareMode() == COMPARE_MODE_VALUE) {
+ String internal1 = o1.get("internalname").getAsString();
+ String internal2 = o2.get("internalname").getAsString();
+
+ float cost1 = manager.auctionManager.getLowestBin(internal1);
+ float cost2 = manager.auctionManager.getLowestBin(internal2);
+
+ if (cost1 < cost2) return mult;
+ if (cost1 > cost2) return -mult;
+ }
+
+ String i1 = o1.get("internalname").getAsString();
+ String[] split1 = i1.split("_");
+ String last1 = split1[split1.length - 1];
+ String start1 = i1.substring(0, i1.length() - last1.length());
+
+ String i2 = o2.get("internalname").getAsString();
+ String[] split2 = i2.split("_");
+ String last2 = split2[split2.length - 1];
+ String start2 = i2.substring(0, i2.length() - last2.length());
+
+ mult = getCompareAscending().get(COMPARE_MODE_ALPHABETICAL) ? 1 : -1;
+ if (start1.equals(start2)) {
+ String[] order = new String[]{"HELMET", "CHESTPLATE", "LEGGINGS", "BOOTS"};
+ int type1 = checkItemType(o1.get("lore").getAsJsonArray(), order);
+ int type2 = checkItemType(o2.get("lore").getAsJsonArray(), order);
+
+ if (type1 < type2) return -mult;
+ if (type1 > type2) return mult;
+ }
+
+ int nameComp = mult * o1.get("displayname").getAsString().replaceAll("(?i)\\u00A7.", "")
+ .compareTo(o2.get("displayname").getAsString().replaceAll("(?i)\\u00A7.", ""));
+ if (nameComp != 0) {
+ return nameComp;
+ }
+ return mult * o1.get("internalname").getAsString().compareTo(o2.get("internalname").getAsString());
+ };
+ }
+
+ /**
+ * Checks whether an item matches a certain type, i.e. whether the item lore ends in "{rarity} {item type}"
+ * eg. "SHOVEL" will return >0 for "COMMON SHOVEL", "EPIC SHOVEL", etc.
+ *
+ * @return the index of the type that matched, or -1 otherwise.
+ */
+ public int checkItemType(JsonArray lore, String... typeMatches) {
+ for (int i = lore.size() - 1; i >= 0; i--) {
+ String line = lore.get(i).getAsString();
+
+ for (String rarity : rarityArr) {
+ for (int j = 0; j < typeMatches.length; j++) {
+ if (line.trim().equals(rarity + " " + typeMatches[j])) {
+ return j;
+ }
+ }
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * Checks whether an item matches the current sort mode.
+ */
+ public boolean checkMatchesSort(String internalname, JsonObject item) {
+ if (!NotEnoughUpdates.INSTANCE.config.itemlist.showVanillaItems &&
+ item.has("vanilla") &&
+ item.get("vanilla").getAsBoolean()) {
+ return false;
+ }
+
+ if (getSortMode() == SORT_MODE_ALL) {
+ return !internalname.matches(mobRegex);
+ } else if (getSortMode() == SORT_MODE_MOB) {
+ return internalname.matches(mobRegex);
+ } else if (getSortMode() == SORT_MODE_PET) {
+ return internalname.matches(petRegex) && item.get("displayname").getAsString().contains("[");
+ } else if (getSortMode() == SORT_MODE_TOOL) {
+ return checkItemType(
+ item.get("lore").getAsJsonArray(),
+ "SWORD",
+ "BOW",
+ "AXE",
+ "PICKAXE",
+ "FISHING ROD",
+ "WAND",
+ "SHOVEL",
+ "HOE",
+ "DUNGEON SWORD",
+ "DUNGEON BOW",
+ "DRILL",
+ "GAUNTLET"
+ ) >= 0;
+ } else if (getSortMode() == SORT_MODE_ARMOR) {
+ return checkItemType(
+ item
+ .get("lore")
+ .getAsJsonArray(),
+ "HELMET",
+ "CHESTPLATE",
+ "LEGGINGS",
+ "BOOTS",
+ "DUNGEON HELMET",
+ "DUNGEON CHESTPLATE",
+ "DUNGEON LEGGINGS",
+ "DUNGEON BOOTS"
+ ) >=
+ 0;
+ } else if (getSortMode() == SORT_MODE_ACCESSORY) {
+ return checkItemType(item.get("lore").getAsJsonArray(), "ACCESSORY", "HATCCESSORY", "DUNGEON ACCESSORY") >= 0;
+ }
+ return true;
+ }
+
+ private final HashMap<String, JsonObject> parentMap = new HashMap<>();
+
+ private final ExecutorService searchES = Executors.newSingleThreadExecutor();
+
+ /**
+ * Clears the current item list, creating a new TreeSet if necessary.
+ * Adds all items that match the search AND match the sort mode to the current item list.
+ * Also adds some easter egg items. (Also I'm very upset if you came here to find them :'( )
+ */
+ public void updateSearch() {
+ SunTzu.randomizeQuote();
+
+ if (searchedItems == null) searchedItems = new TreeSet<>(getItemComparator());
+
+ searchES.submit(() -> {
+ TreeSet<JsonObject> searchedItems = new TreeSet<>(getItemComparator());
+ HashMap<String, List<String>> searchedItemsSubgroup = new HashMap<>();
+
+ Set<JsonObject> removeChildItems = new HashSet<>();
+ Set<String> itemsMatch = manager.search(textField.getText(), true);
+ for (String itemname : itemsMatch) {
+ JsonObject item = manager.getItemInformation().get(itemname);
+ if (checkMatchesSort(itemname, item)) {
+ if (Constants.PARENTS != null) {
+ if (Constants.PARENTS.has(itemname) && Constants.PARENTS.get(itemname).isJsonArray()) {
+ List<String> children = new ArrayList<>();
+ for (JsonElement e : Constants.PARENTS.get(itemname).getAsJsonArray()) {
+ if (e.isJsonPrimitive()) {
+ children.add(e.getAsString());
+ }
+ }
+ children.retainAll(itemsMatch);
+ for (String child : children) {
+ removeChildItems.add(manager.getItemInformation().get(child));
+ }
+ searchedItemsSubgroup.put(itemname, children);
+ }
+ }
+ searchedItems.add(item);
+ }
+ }
+ searchedItems.removeAll(removeChildItems);
+ out:
+ for (Map.Entry<String, List<String>> entry : searchedItemsSubgroup.entrySet()) {
+ if (searchedItems.contains(manager.getItemInformation().get(entry.getKey()))) {
+ continue;
+ }
+ for (String itemname : entry.getValue()) {
+ JsonObject item = manager.getItemInformation().get(itemname);
+ if (item != null) searchedItems.add(item);
+ }
+ }
+ switch (textField.getText().toLowerCase().trim()) {
+ case "nullzee":
+ searchedItems.add(CustomItems.NULLZEE);
+ break;
+ case "rune":
+ searchedItems.add(CustomItems.RUNE);
+ break;
+ case "2b2t":
+ searchedItems.add(CustomItems.TWOBEETWOTEE);
+ break;
+ case "ducttape":
+ case "ducttapedigger":
+ searchedItems.add(CustomItems.DUCTTAPE);
+ break;
+ case "thirtyvirus":
+ searchedItems.add(manager.getItemInformation().get("SPIKED_BAIT"));
+ break;
+ case "leocthl":
+ searchedItems.add(CustomItems.LEOCTHL);
+ break;
+ case "spinaxx":
+ searchedItems.add(CustomItems.SPINAXX);
+ break;
+ case "credits":
+ case "credit":
+ case "who made this mod":
+ searchedItems.add(CustomItems.CREDITS);
+ break;
+ case "ironmoon":
+ case "ironm00n":
+ searchedItems.add(CustomItems.IRONM00N);
+ break;
+ case "nopo":
+ case "nopothegamer":
+ searchedItems.add(CustomItems.NOPO);
+ break;
+ }
+
+ this.searchedItems = searchedItems;
+ this.searchedItemsSubgroup = searchedItemsSubgroup;
+
+ synchronized (this.searchedItemsArr) {
+ this.searchedItemsArr.clear();
+ }
+
+ redrawItems = true;
+ });
+ }
+
+ /**
+ * Returns an index-able array containing the elements in searchedItems.
+ * Whenever searchedItems is updated in updateSearch(), the array is recreated here.
+ */
+ public List<JsonObject> getSearchedItems() {
+ if (searchedItems == null) {
+ updateSearch();
+ return new ArrayList<>();
+ }
+
+ if (searchedItems.size() > 0 && searchedItemsArr.size() == 0) {
+ synchronized (searchedItemsArr) {
+ searchedItemsArr.addAll(searchedItems);
+ }
+ }
+ return searchedItemsArr;
+ }
+
+ /**
+ * Gets the item in searchedItemArr corresponding to the certain index on the current page.
+ *
+ * @return item, if the item exists. null, otherwise.
+ */
+ public JsonObject getSearchedItemPage(int index) {
+ if (index < getSlotsXSize() * getSlotsYSize()) {
+ int actualIndex = index + getSlotsXSize() * getSlotsYSize() * page;
+ List<JsonObject> searchedItems = getSearchedItems();
+ if (actualIndex < searchedItems.size()) {
+ return searchedItems.get(actualIndex);
+ } else {
+ return null;
+ }
+ } else {
+ return null;
+ }
+ }
+
+ public int getItemBoxXPadding() {
+ int width = Utils.peekGuiScale().getScaledWidth();
+ return (((int) (width / 3 * getWidthMult()) - 2 * getBoxPadding()) % (ITEM_SIZE + ITEM_PADDING) + ITEM_PADDING) / 2;
+ }
+
+ public int getBoxPadding() {
+ double panePadding = Math.max(0, Math.min(20, NotEnoughUpdates.INSTANCE.config.itemlist.panePadding));
+ return (int) (panePadding * 2 / Utils.peekGuiScale().getScaleFactor() + 5);
+ }
+
+ private abstract static class ItemSlotConsumer {
+ public abstract void consume(int x, int y, int id);
+ }
+
+ public void iterateItemSlots(ItemSlotConsumer itemSlotConsumer) {
+ int width = Utils.peekGuiScale().getScaledWidth();
+ int itemBoxXPadding = getItemBoxXPadding();
+ iterateItemSlots(itemSlotConsumer, (int) (width * getItemPaneOffsetFactor()) + getBoxPadding() + itemBoxXPadding);
+ }
+
+ /**
+ * Iterates through all the item slots in the right panel and calls a ItemSlotConsumer for each slot with
+ * arguments equal to the slot's x and y position respectively. This is used in order to prevent
+ * code duplication issues.
+ */
+ public void iterateItemSlots(ItemSlotConsumer itemSlotConsumer, int xStart) {
+ int width = Utils.peekGuiScale().getScaledWidth();
+ int height = Utils.peekGuiScale().getScaledHeight();
+
+ int paneWidth = (int) (width / 3 * getWidthMult());
+ int itemBoxYPadding =
+ ((height - getSearchBarYSize() - 2 * getBoxPadding() - ITEM_SIZE - 2) % (ITEM_SIZE + ITEM_PADDING) +
+ ITEM_PADDING) / 2;
+
+ int yStart = getBoxPadding() + getSearchBarYSize() + itemBoxYPadding;
+ int itemBoxXPadding = getItemBoxXPadding();
+ int xEnd = xStart + paneWidth - getBoxPadding() * 2 - ITEM_SIZE - itemBoxXPadding;
+ int yEnd = height - getBoxPadding() - ITEM_SIZE - 2 - itemBoxYPadding;
+
+ //Render the items, displaying the tooltip if the cursor is over the item
+ int id = 0;
+ for (int y = yStart; y < yEnd; y += ITEM_SIZE + ITEM_PADDING) {
+ for (int x = xStart; x < xEnd; x += ITEM_SIZE + ITEM_PADDING) {
+ itemSlotConsumer.consume(x, y, id++);
+ }
+ }
+ }
+
+ public float getWidthMult() {
+ float scaleFMult = 1;
+ if (Utils.peekGuiScale().getScaleFactor() == 4) scaleFMult *= 0.9f;
+ if (manager.auctionManager.customAH.isRenderOverAuctionView() ||
+ Minecraft.getMinecraft().currentScreen instanceof CustomAHGui)
+ scaleFMult *= 0.8f;
+ return (float) Math.max(0.5, Math.min(1.5, NotEnoughUpdates.INSTANCE.config.itemlist.paneWidthMult)) * scaleFMult;
+ }
+
+ /**
+ * Calculates the number of horizontal item slots.
+ */
+ public int getSlotsXSize() {
+ int width = Utils.peekGuiScale().getScaledWidth();
+
+ int paneWidth = (int) (width / 3 * getWidthMult());
+ int itemBoxXPadding =
+ (((int) (width - width * getItemPaneOffsetFactor()) - 2 * getBoxPadding()) % (ITEM_SIZE + ITEM_PADDING) +
+ ITEM_PADDING) / 2;
+ int xStart = (int) (width * getItemPaneOffsetFactor()) + getBoxPadding() + itemBoxXPadding;
+ int xEnd = (int) (width * getItemPaneOffsetFactor()) + paneWidth - getBoxPadding() - ITEM_SIZE;
+
+ return (int) Math.ceil((xEnd - xStart) / ((float) (ITEM_SIZE + ITEM_PADDING)));
+ }
+
+ /**
+ * Calculates the number of vertical item slots.
+ */
+ public int getSlotsYSize() {
+ int height = Utils.peekGuiScale().getScaledHeight();
+
+ int itemBoxYPadding =
+ ((height - getSearchBarYSize() - 2 * getBoxPadding() - ITEM_SIZE - 2) % (ITEM_SIZE + ITEM_PADDING) +
+ ITEM_PADDING) / 2;
+ int yStart = getBoxPadding() + getSearchBarYSize() + itemBoxYPadding;
+ int yEnd = height - getBoxPadding() - ITEM_SIZE - 2 - itemBoxYPadding;
+
+ return (int) Math.ceil((yEnd - yStart) / ((float) (ITEM_SIZE + ITEM_PADDING)));
+ }
+
+ public int getMaxPages() {
+ if (getSearchedItems().size() == 0) return 1;
+ return (int) Math.ceil(getSearchedItems().size() / (float) getSlotsYSize() / getSlotsXSize());
+ }
+
+ public int getSearchBarYSize() {
+ int searchBarYSize = NotEnoughUpdates.INSTANCE.config.toolbar.searchBarHeight;
+ return Math.max(searchBarYSize / Utils.peekGuiScale().getScaleFactor(), ITEM_SIZE);
+ }
+
+ /**
+ * Renders the top navigation bar, can be used by InfoPane implementations (such as SettingsInfoPane).
+ * Renders "prev" button, index/maxIndex string, "next" button.
+ */
+ public void renderNavElement(int leftSide, int rightSide, int maxPages, int page, String name) {
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+
+ String pageText = EnumChatFormatting.BOLD + name + page + "/" + maxPages;
+
+ float maxStrLen = fr.getStringWidth(EnumChatFormatting.BOLD + name + maxPages + "/" + maxPages);
+ float maxButtonXSize = (rightSide - leftSide + 2 - maxStrLen * 0.5f - 10) / 2f;
+ int buttonXSize = (int) Math.min(maxButtonXSize, getSearchBarYSize() * 480 / 160f);
+ int ySize = (int) (buttonXSize / 480f * 160);
+ int yOffset = (int) ((getSearchBarYSize() - ySize) / 2f);
+ int top = getBoxPadding() + yOffset;
+
+ int leftPressed = 0;
+ int rightPressed = 0;
+
+ if (Mouse.isButtonDown(0) || Mouse.isButtonDown(1)) {
+ int width = Utils.peekGuiScale().getScaledWidth();
+ int height = Utils.peekGuiScale().getScaledHeight();
+
+ int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
+ int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
+
+ if (mouseY >= top && mouseY <= top + ySize) {
+ int leftPrev = leftSide - 1;
+ if (mouseX > leftPrev && mouseX < leftPrev + buttonXSize) { //"Previous" button
+ leftPressed = 1;
+ }
+ int leftNext = rightSide + 1 - buttonXSize;
+ if (mouseX > leftNext && mouseX < leftNext + buttonXSize) { //"Next" button
+ rightPressed = 1;
+ }
+ }
+ }
+
+ drawRect(leftSide - 1, top, leftSide - 1 + buttonXSize, top + ySize, fg.getRGB());
+ GlStateManager.color(1f, 1f, 1f, 1f);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(rightarrow);
+ Utils.drawTexturedRect(leftSide - 1 + leftPressed,
+ top + leftPressed,
+ buttonXSize, ySize, 1, 0, 0, 1
+ );
+ Minecraft.getMinecraft().getTextureManager().bindTexture(rightarrow_overlay);
+ Utils.drawTexturedRect(leftSide - 1,
+ top,
+ buttonXSize, ySize, 1 - leftPressed, leftPressed, 1 - leftPressed, leftPressed
+ );
+ GlStateManager.bindTexture(0);
+ Utils.drawStringCenteredScaled(EnumChatFormatting.BOLD + "Prev", fr,
+ leftSide - 1 + buttonXSize * 300 / 480f + leftPressed,
+ top + ySize / 2f + leftPressed, false,
+ (int) (buttonXSize * 240 / 480f), Color.BLACK.getRGB()
+ );
+
+ drawRect(rightSide + 1 - buttonXSize, top, rightSide + 1, top + ySize, fg.getRGB());
+ GlStateManager.color(1f, 1f, 1f, 1f);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(rightarrow);
+ Utils.drawTexturedRect(rightSide + 1 - buttonXSize + rightPressed,
+ top + rightPressed,
+ buttonXSize, ySize
+ );
+ Minecraft.getMinecraft().getTextureManager().bindTexture(rightarrow_overlay);
+ Utils.drawTexturedRect(rightSide + 1 - buttonXSize,
+ top,
+ buttonXSize, ySize, 1 - rightPressed, rightPressed, 1 - rightPressed, rightPressed
+ );
+ GlStateManager.bindTexture(0);
+ Utils.drawStringCenteredScaled(EnumChatFormatting.BOLD + "Next", fr,
+ rightSide + 1 - buttonXSize * 300 / 480f + rightPressed,
+ top + ySize / 2f + rightPressed, false,
+ (int) (buttonXSize * 240 / 480f), Color.BLACK.getRGB()
+ );
+
+ int strMaxLen = rightSide - leftSide - 2 * buttonXSize - 10;
+
+ drawRect(leftSide - 1 + buttonXSize + 3, top, rightSide + 1 - buttonXSize - 3, top + ySize,
+ new Color(177, 177, 177).getRGB()
+ );
+ drawRect(leftSide + buttonXSize + 3, top + 1, rightSide + 1 - buttonXSize - 3, top + ySize,
+ new Color(50, 50, 50).getRGB()
+ );
+ drawRect(leftSide + buttonXSize + 3, top + 1, rightSide - buttonXSize - 3, top + ySize - 1, fg.getRGB());
+ Utils.drawStringCenteredScaledMaxWidth(pageText, fr, (leftSide + rightSide) / 2,
+ top + ySize / 2f, false, strMaxLen, Color.BLACK.getRGB()
+ );
+ }
+
+ private int limCol(int col) {
+ return Math.min(255, Math.max(0, col));
+ }
+
+ public boolean isUsingMobsFilter() {
+ return getSortMode() == SORT_MODE_MOB;
+ }
+
+ public float yaw = 0;
+ public float pitch = 20;
+
+ /**
+ * Renders an entity onto the GUI at a certain x and y position.
+ */
+ private void renderEntity(
+ float posX,
+ float posY,
+ float scale,
+ String name,
+ Class<? extends EntityLivingBase>... classes
+ ) {
+ EntityLivingBase[] entities = new EntityLivingBase[classes.length];
+ try {
+ EntityLivingBase last = null;
+ for (int i = 0; i < classes.length; i++) {
+ Class<? extends EntityLivingBase> clazz = classes[i];
+ if (clazz == null) continue;
+
+ EntityLivingBase newEnt =
+ clazz.getConstructor(new Class[]{World.class}).newInstance(Minecraft.getMinecraft().theWorld);
+
+ //newEnt.renderYawOffset = yaw;
+ //newEnt.rotationYaw = yaw;
+ newEnt.rotationPitch = pitch;
+ //newEnt.rotationYawHead = yaw;
+ //newEnt.prevRotationYawHead = yaw-1;
+
+ newEnt.setCustomNameTag(name);
+
+ if (last != null) {
+ last.riddenByEntity = newEnt;
+ newEnt.ridingEntity = last;
+ last.updateRiderPosition();
+ }
+ last = newEnt;
+
+ entities[i] = newEnt;
+ }
+ } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
+ e.printStackTrace();
+ return;
+ }
+
+ GlStateManager.enableColorMaterial();
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(posX, posY, 50.0F);
+ GlStateManager.scale(-scale, scale, scale);
+ GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
+
+ GlStateManager.rotate(135.0F, 0.0F, 1.0F, 0.0F);
+ RenderHelper.enableStandardItemLighting();
+ GlStateManager.rotate(-135.0F, 0.0F, 1.0F, 0.0F);
+
+ GlStateManager.rotate(pitch, 1.0F, 0.0F, 0.0F);
+ GlStateManager.rotate(yaw, 0.0F, 1.0F, 0.0F);
+
+ RenderManager rendermanager = Minecraft.getMinecraft().getRenderManager();
+ rendermanager.setPlayerViewY(180.0F);
+ rendermanager.setRenderShadow(false);
+ for (EntityLivingBase ent : entities) {
+ GL11.glColor4f(1, 1, 1, 1);
+ if (ent != null) rendermanager.renderEntityWithPosYaw(ent, ent.posX, ent.posY, ent.posZ, 0.0F, 1.0F);
+ }
+ rendermanager.setRenderShadow(true);
+
+ GlStateManager.popMatrix();
+ RenderHelper.disableStandardItemLighting();
+ GlStateManager.disableRescaleNormal();
+ GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
+ GlStateManager.disableTexture2D();
+ GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
+
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ }
+
+ Shader blurShaderHorz = null;
+ Framebuffer blurOutputHorz = null;
+ Shader blurShaderVert = null;
+ Framebuffer blurOutputVert = null;
+
+ /**
+ * Creates a projection matrix that projects from our coordinate space [0->width; 0->height] to OpenGL coordinate
+ * space [-1 -> 1; 1 -> -1] (Note: flipped y-axis).
+ * <p>
+ * This is so that we can render to and from the framebuffer in a way that is familiar to us, instead of needing to
+ * apply scales and translations manually.
+ */
+ private Matrix4f createProjectionMatrix(int width, int height) {
+ Matrix4f projMatrix = new Matrix4f();
+ projMatrix.setIdentity();
+ projMatrix.m00 = 2.0F / (float) width;
+ projMatrix.m11 = 2.0F / (float) (-height);
+ projMatrix.m22 = -0.0020001999F;
+ projMatrix.m33 = 1.0F;
+ projMatrix.m03 = -1.0F;
+ projMatrix.m13 = 1.0F;
+ projMatrix.m23 = -1.0001999F;
+ return projMatrix;
+ }
+
+ public void updateGuiGroupSize() {
+ Utils.pushGuiScale(NotEnoughUpdates.INSTANCE.config.itemlist.paneGuiScale);
+ int width = Utils.peekGuiScale().getScaledWidth();
+ int height = Utils.peekGuiScale().getScaledHeight();
+
+ if (lastScreenWidth != width || lastScreenHeight != height || Utils.peekGuiScale().getScaleFactor() != lastScale) {
+ guiGroup.width = width;
+ guiGroup.height = height;
+
+ resetAnchors(true);
+ guiGroup.recalculate();
+
+ lastScreenWidth = width;
+ lastScreenHeight = height;
+ lastScale = Utils.peekGuiScale().getScaleFactor();
+ }
+
+ Utils.pushGuiScale(-1);
+ }
+
+ int guiScaleLast = 0;
+ private boolean showVanillaLast = false;
+
+ private boolean wardrobeOpen = false;
+
+ private boolean isInNamedGui(String guiName) {
+ GuiScreen guiScreen = Minecraft.getMinecraft().currentScreen;
+ if (guiScreen instanceof GuiChest) {
+ GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
+ ContainerChest container = (ContainerChest) chest.inventorySlots;
+ IInventory lower = container.getLowerChestInventory();
+ String containerName = lower.getDisplayName().getUnformattedText();
+ wardrobeOpen = containerName.contains(guiName);
+ }
+ if (guiScreen instanceof GuiInventory) {
+ wardrobeOpen = false;
+ }
+ return wardrobeOpen;
+ }
+
+ private int wardrobePage = -1;
+
+ private int getWardrobePage() {
+ GuiScreen guiScreen = Minecraft.getMinecraft().currentScreen;
+ if (guiScreen instanceof GuiChest) {
+ if (isInNamedGui("Wardrobe")) {
+ GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
+ ContainerChest container = (ContainerChest) chest.inventorySlots;
+ IInventory lower = container.getLowerChestInventory();
+ String containerName = lower.getDisplayName().getUnformattedText();
+ try {
+ wardrobePage = Integer.parseInt(containerName.substring(10, 11));
+ } catch (NumberFormatException e) {
+ System.out.println(containerName.charAt(10));
+ System.out.println("Did hypixel change the wardrobe string?");
+ wardrobePage = -1;
+ }
+ } else wardrobePage = -1;
+ }
+ return wardrobePage;
+ }
+
+ private ItemStack getChestSlotsAsItemStack(int slot) {
+ GuiScreen guiScreen = Minecraft.getMinecraft().currentScreen;
+ if (guiScreen instanceof GuiChest) {
+ GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
+ return chest.inventorySlots.getSlot(slot).getStack();
+ } else {
+ return null;
+ }
+ }
+
+ private int selectedArmor = 9;
+
+ private int getEquippedArmor() {
+ if (!isInNamedGui("Wardrobe")) return selectedArmor;
+
+ ItemStack nullTest1 = getChestSlotsAsItemStack(8);
+ ItemStack nullTest2 = getChestSlotsAsItemStack(17);
+ ItemStack nullTest3 = getChestSlotsAsItemStack(26);
+ ItemStack nullTest4 = getChestSlotsAsItemStack(35);
+ ItemStack nullTest5 = getChestSlotsAsItemStack(44);
+ if (nullTest1 != null || nullTest2 != null || nullTest3 != null || nullTest4 != null || nullTest5 != null) {
+ selectedArmor = 9;
+ }
+ for (int ii = 1; ii < 5; ii++) {
+ if (ii != 1 && selectedArmor != 9) continue;
+ if (getWardrobePage() != ii) continue;
+ for (int i = 8; i < 54; i += 9) {
+ ItemStack stack1 = getChestSlotsAsItemStack(i);
+ if (stack1 == null) continue;
+ String[] lore1 = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stack1.getTagCompound());
+ for (String line : lore1) {
+ if (line.contains("to unequip this armor")) {
+ selectedArmor = i;
+ break;
+ }
+ }
+ }
+ }
+ return selectedArmor;
+ }
+
+ private ItemStack getWardrobeSlot(int armourSlot) {
+ if (isInNamedGui("Wardrobe")) {
+ if (getChestSlotsAsItemStack(getEquippedArmor() - armourSlot) != null && getEquippedArmor() != 9) {
+ return getChestSlotsAsItemStack(getEquippedArmor() - armourSlot);
+ } else return null;
+ } else return null;
+ }
+
+ public boolean isWardrobeSystemOnMainServer() {
+ JsonElement alphaWardrobeElement = Utils.getElement(Constants.DISABLE, "wardrobeFeature");
+ if (alphaWardrobeElement == null || !alphaWardrobeElement.isJsonObject()) {
+ return true;
+ }
+ JsonObject isWardrobe = alphaWardrobeElement.getAsJsonObject();
+ if (isWardrobe.has("enableNewWardrob")) {
+ return isWardrobe.get("enableNewWardrob").getAsBoolean();
+ } else {
+ return true;
+ }
+ }
+
+ public ItemStack slot1 = null;
+ public ItemStack slot2 = null;
+ public ItemStack slot3 = null;
+ public ItemStack slot4 = null;
+ public ItemStack petSlot = null;
+
+ public static boolean isRenderingArmorHud() {
+ return renderingArmorHud;
+ }
+
+ public static boolean isRenderingPetHud() {
+ return renderingPetHud;
+ }
+
+ /**
+ * Renders the search bar, quick commands, item selection (right), item info (left) and armor hud gui elements.
+ */
+ public void render(boolean hoverInv) {
+ if (disabled) return;
+ renderingArmorHud = false;
+ renderingPetHud = false;
+ GlStateManager.enableDepth();
+
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+
+ Utils.resetGuiScale();
+ Utils.pushGuiScale(NotEnoughUpdates.INSTANCE.config.itemlist.paneGuiScale);
+
+ int width = Utils.peekGuiScale().getScaledWidth();
+ int height = Utils.peekGuiScale().getScaledHeight();
+ int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
+ int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
+
+ if (showVanillaLast != NotEnoughUpdates.INSTANCE.config.itemlist.showVanillaItems) {
+ showVanillaLast = NotEnoughUpdates.INSTANCE.config.itemlist.showVanillaItems;
+ updateSearch();
+ }
+
+ if (textField.getText().toLowerCase().contains("bald")) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(SUPERGEHEIMNISVERMOGEN);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect((width - 64) / 2f, (height - 64) / 2f - 114, 64, 64, GL11.GL_LINEAR);
+ GlStateManager.bindTexture(0);
+ }
+ GuiScreen guiScreen = Minecraft.getMinecraft().currentScreen;
+
+ if (NotEnoughUpdates.INSTANCE.config.customArmour.enableArmourHud &&
+ NotEnoughUpdates.INSTANCE.config.misc.hidePotionEffect
+ &&
+ NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() &&
+ isWardrobeSystemOnMainServer()) {
+ if (getWardrobeSlot(1) != null) {
+ slot1 = getWardrobeSlot(4);
+ slot2 = getWardrobeSlot(3);
+ slot3 = getWardrobeSlot(2);
+ slot4 = getWardrobeSlot(1);
+ }
+ if (guiScreen instanceof GuiInventory) {
+ renderingArmorHud = true;
+ selectedArmor = 9;
+
+ List<String> tooltipToDisplay = null;
+ if (NotEnoughUpdates.INSTANCE.config.customArmour.colourStyle == 0) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(ARMOR_DISPLAY);
+ }
+ if (NotEnoughUpdates.INSTANCE.config.customArmour.colourStyle == 1) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(ARMOR_DISPLAY_GREY);
+ }
+ if (NotEnoughUpdates.INSTANCE.config.customArmour.colourStyle == 2) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(ARMOR_DISPLAY_DARK);
+ }
+ if (NotEnoughUpdates.INSTANCE.config.customArmour.colourStyle == 3) {
+ if (NotEnoughUpdates.INSTANCE.config.petOverlay.colourStyle == 3 &&
+ NotEnoughUpdates.INSTANCE.config.petOverlay.petInvDisplay &&
+ petSlot != null) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(ARMOR_DISPLAY_TRANSPARENT_PET);
+ } else {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(ARMOR_DISPLAY_TRANSPARENT);
+ }
+ }
+ if (NotEnoughUpdates.INSTANCE.config.customArmour.colourStyle == 4) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(ARMOR_DISPLAY_FSR);
+ }
+
+ GlStateManager.color(1, 1, 1, 1);
+ GL11.glTranslatef(0, 0, 401);
+ float yNumber = (float) (height - 167) / 2f;
+ Utils.drawTexturedRect((float) ((width - 224.1) / 2f), yNumber, 31, 86, GL11.GL_NEAREST);
+ GlStateManager.bindTexture(0);
+
+ Utils.drawItemStack(slot1, (int) ((width - 208) / 2f), (int) ((height + 60) / 2f - 105));
+ Utils.drawItemStack(slot2, (int) ((width - 208) / 2f), (int) ((height + 60) / 2f - 105) + 18);
+ Utils.drawItemStack(slot3, (int) ((width - 208) / 2f), (int) ((height + 60) / 2f - 105) + 36);
+ Utils.drawItemStack(slot4, (int) ((width - 208) / 2f), (int) ((height + 60) / 2f - 105) + 54);
+ if (slot1 == null) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(QUESTION_MARK);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(((width - 208) / 2f), ((height + 60) / 2f - 105), 16, 16, GL11.GL_NEAREST);
+ GlStateManager.bindTexture(0);
+
+ tooltipToDisplay = Lists.newArrayList(
+ EnumChatFormatting.RED + "Warning",
+ EnumChatFormatting.GREEN + "You need to open /wardrobe",
+ EnumChatFormatting.GREEN + "To cache your armour"
+ );
+ if (mouseX >= ((width - 208) / 2f) && mouseX < ((width - 208) / 2f) + 16) {
+ if (mouseY >= ((height + 60) / 2f - 105) &&
+ mouseY <= ((height + 60) / 2f - 105) + 70 &&
+ NotEnoughUpdates.INSTANCE.config.customArmour.sendWardrobeCommand) {
+ if (Minecraft.getMinecraft().thePlayer.inventory.getItemStack() == null) {
+ if (Mouse.getEventButtonState()) {
+ if (ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/wardrobe") ==
+ 0) {
+ NotEnoughUpdates.INSTANCE.sendChatMessage("/wardrobe");
+ }
+ }
+ }
+ }
+ if (mouseY >= ((height + 60) / 2f - 105) && mouseY <= ((height + 60) / 2f - 105) + 16) {
+ Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, fr);
+ GL11.glTranslatef(0, 0, -401);
+ }
+ }
+
+ }
+ if (slot1 != null && slot2 != null && slot3 != null && slot4 != null) {
+ if (mouseX >= ((width - 208) / 2f) && mouseX < ((width - 208) / 2f) + 16) {
+ if (mouseY >= ((height + 60) / 2f - 105) &&
+ mouseY <= ((height + 60) / 2f - 105) + 70 &&
+ NotEnoughUpdates.INSTANCE.config.customArmour.sendWardrobeCommand) {
+ if (Minecraft.getMinecraft().thePlayer.inventory.getItemStack() == null) {
+ if (Mouse.getEventButtonState()) {
+ if (ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/wardrobe") ==
+ 0) {
+ NotEnoughUpdates.INSTANCE.sendChatMessage("/wardrobe");
+ }
+ }
+ }
+ }
+ //top slot
+ if (mouseY >= ((height + 60) / 2f - 105) && mouseY <= ((height + 60) / 2f - 105) + 16) {
+ tooltipToDisplay = slot1.getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, fr);
+ tooltipToDisplay = null;
+ GL11.glTranslatef(0, 0, -401);
+ }
+ if (mouseY >= ((height + 60) / 2f - 105) + 18 && mouseY <= ((height + 60) / 2f - 105) + 34) {
+ tooltipToDisplay = slot2.getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, fr);
+ tooltipToDisplay = null;
+ GL11.glTranslatef(0, 0, -401);
+ }
+ if (mouseY >= ((height + 60) / 2f - 105) + 36 && mouseY <= ((height + 60) / 2f - 105) + 52) {
+ tooltipToDisplay = slot3.getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, fr);
+ tooltipToDisplay = null;
+ GL11.glTranslatef(0, 0, -401);
+ }
+ if (mouseY >= ((height + 60) / 2f - 105) + 54 && mouseY <= ((height + 60) / 2f - 105) + 70) {
+ tooltipToDisplay = slot4.getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, fr);
+ tooltipToDisplay = null;
+ GL11.glTranslatef(0, 0, -401);
+ }
+ }
+ GL11.glTranslatef(0, 0, -401);
+ }
+ }
+ }
+ if (PetInfoOverlay.getCurrentPet() != null) {
+ if (NotEnoughUpdates.INSTANCE.config.petOverlay.petInvDisplay
+ &&
+ (NotEnoughUpdates.INSTANCE.manager
+ .jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get(PetInfoOverlay.getCurrentPet().petType + ";" + PetInfoOverlay.getCurrentPet().rarity.petId))
+ .hasDisplayName()
+ ||
+ NotEnoughUpdates.INSTANCE.manager
+ .jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get(PetInfoOverlay.getCurrentPet().petType + ";" + (PetInfoOverlay.getCurrentPet().rarity.petId - 1)))
+ .hasDisplayName())
+ &&
+ NotEnoughUpdates.INSTANCE.config.misc.hidePotionEffect &&
+ NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
+ if (!NotEnoughUpdates.INSTANCE.manager
+ .jsonToStack(
+ NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get(PetInfoOverlay.getCurrentPet().petType + ";" + PetInfoOverlay.getCurrentPet().rarity.petId))
+ .hasDisplayName()) {
+ petSlot = NotEnoughUpdates.INSTANCE.manager.jsonToStack(
+ NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(
+ PetInfoOverlay.getCurrentPet().petType + ";" + (PetInfoOverlay.getCurrentPet().rarity.petId - 1)));
+ } else {
+ petSlot = NotEnoughUpdates.INSTANCE.manager.jsonToStack(
+ NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(
+ PetInfoOverlay.getCurrentPet().petType + ";" + PetInfoOverlay.getCurrentPet().rarity.petId));
+ }
+ petSlot.getTagCompound().setBoolean("NEUPETINVDISPLAY", true);
+ petSlot
+ .getTagCompound()
+ .setBoolean("NEUHIDEPETTOOLTIP", NotEnoughUpdates.INSTANCE.config.petOverlay.hidePetTooltip);
+ ItemStack petInfo = petSlot;
+
+ if (guiScreen instanceof GuiInventory) {
+ GL11.glTranslatef(0, 0, 401);
+ if (!NotEnoughUpdates.INSTANCE.config.customArmour.enableArmourHud || !isWardrobeSystemOnMainServer()) {
+ if (NotEnoughUpdates.INSTANCE.config.petOverlay.colourStyle == 0) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(PET_DISPLAY);
+ }
+ if (NotEnoughUpdates.INSTANCE.config.petOverlay.colourStyle == 1) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(PET_DISPLAY_GREY);
+ }
+ if (NotEnoughUpdates.INSTANCE.config.petOverlay.colourStyle == 2) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(PET_DISPLAY_DARK);
+ }
+ if (NotEnoughUpdates.INSTANCE.config.petOverlay.colourStyle == 3) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(PET_DISPLAY_TRANSPARENT);
+ }
+ if (NotEnoughUpdates.INSTANCE.config.petOverlay.colourStyle == 4) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(PET_DISPLAY_FSR);
+ }
+ } else {
+ if (NotEnoughUpdates.INSTANCE.config.petOverlay.colourStyle == 0) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(PET_ARMOR_DISPLAY);
+ }
+ if (NotEnoughUpdates.INSTANCE.config.petOverlay.colourStyle == 1) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(PET_ARMOR_DISPLAY_GREY);
+ }
+ if (NotEnoughUpdates.INSTANCE.config.petOverlay.colourStyle == 2) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(PET_ARMOR_DISPLAY_DARK);
+ }
+ if (NotEnoughUpdates.INSTANCE.config.petOverlay.colourStyle == 3) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(PET_ARMOR_DISPLAY_TRANSPARENT);
+ }
+ if (NotEnoughUpdates.INSTANCE.config.petOverlay.colourStyle == 4) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(PET_ARMOR_DISPLAY_FSR);
+ }
+ }
+
+ GlStateManager.color(1, 1, 1, 1);
+ float yNumber = (float) (height - 23) / 2f;
+ Utils.drawTexturedRect((float) ((width - 224.1) / 2f), yNumber, 31, 32, GL11.GL_NEAREST);
+ GlStateManager.bindTexture(0);
+
+ Utils.drawItemStack(petInfo, (int) ((width - 208) / 2f), (int) ((height + 60) / 2f - 105) + 72);
+ renderingPetHud = true;
+
+ List<String> tooltipToDisplay = null;
+ if (petInfo != null) {
+ if (mouseX >= ((width - 208) / 2f) && mouseX < ((width - 208) / 2f) + 16) {
+ if (mouseY >= ((height + 60) / 2f - 105) + 72 &&
+ mouseY <= ((height + 60) / 2f - 105) + 88 &&
+ NotEnoughUpdates.INSTANCE.config.petOverlay.sendPetsCommand) {
+ if (Minecraft.getMinecraft().thePlayer.inventory.getItemStack() == null) {
+ if (Mouse.getEventButtonState()) {
+ if (ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/pets") ==
+ 0) {
+ NotEnoughUpdates.INSTANCE.sendChatMessage("/pets");
+ }
+ }
+ }
+ tooltipToDisplay = petInfo.getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, fr);
+ tooltipToDisplay = null;
+ GL11.glTranslatef(0, 0, -80);
+ }
+ }
+
+ }
+ }
+ }
+ }
+
+ SunTzu.setEnabled(textField.getText().toLowerCase().startsWith("potato"));
+
+ updateGuiGroupSize();
+
+ if (guiScaleLast != Utils.peekGuiScale().getScaleFactor()) {
+ guiScaleLast = Utils.peekGuiScale().getScaleFactor();
+ redrawItems = true;
+ }
+
+ if (oldWidthMult != getWidthMult()) {
+ oldWidthMult = getWidthMult();
+ redrawItems = true;
+ }
+
+ yaw++;
+ yaw %= 360;
+
+ bg = new Color(SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.itemlist.backgroundColour), true);
+ fg = new Color(SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.itemlist.foregroundColour));
+ Color fgCustomOpacity =
+ new Color(SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.itemlist.foregroundColour), true);
+
+ Color fgFavourite2 =
+ new Color(SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.itemlist.favouriteColour), true);
+ Color fgFavourite = new Color((int) (fgFavourite2.getRed() * 0.8f), (int) (fgFavourite2.getGreen() * 0.8f),
+ (int) (fgFavourite2.getBlue() * 0.8f), fgFavourite2.getAlpha()
+ );
+
+ if (itemPaneOpen) {
+ if (itemPaneTabOffset.getValue() == 0) {
+ if (itemPaneOffsetFactor.getTarget() != 2 / 3f) {
+ itemPaneOffsetFactor.setTarget(2 / 3f);
+ itemPaneOffsetFactor.resetTimer();
+ }
+ } else {
+ if (itemPaneTabOffset.getTarget() != 0) {
+ itemPaneTabOffset.setTarget(0);
+ itemPaneTabOffset.resetTimer();
+ }
+ }
+ } else {
+ if (itemPaneOffsetFactor.getValue() == 1) {
+ if (itemPaneTabOffset.getTarget() != 20) {
+ itemPaneTabOffset.setTarget(20);
+ itemPaneTabOffset.resetTimer();
+ }
+ } else {
+ if (itemPaneOffsetFactor.getTarget() != 1f) {
+ itemPaneOffsetFactor.setTarget(1f);
+ itemPaneOffsetFactor.resetTimer();
+ }
+ }
+ }
+
+ itemPaneOffsetFactor.tick();
+ itemPaneTabOffset.tick();
+ infoPaneOffsetFactor.tick();
+
+ if (page > getMaxPages() - 1) setPage(getMaxPages() - 1);
+ if (page < 0) setPage(0);
+
+ GlStateManager.disableLighting();
+
+ /*
+ * Item selection (right) gui element rendering
+ */
+ int paneWidth = (int) (width / 3 * getWidthMult());
+ int leftSide = (int) (width * getItemPaneOffsetFactor());
+ int rightSide = leftSide + paneWidth - getBoxPadding() - getItemBoxXPadding();
+
+ //Tab
+ if (NotEnoughUpdates.INSTANCE.config.itemlist.tabOpen) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(itemPaneTabArrow);
+ GlStateManager.color(1f, 1f, 1f, 0.3f);
+ Utils.drawTexturedRect(width - itemPaneTabOffset.getValue() * 64 / 20f, height / 2f - 32, 64, 64);
+ GlStateManager.bindTexture(0);
+
+ if (!itemPaneOpen && mouseX > width - itemPaneTabOffset.getValue() && mouseY > height / 2 - 32
+ && mouseY < height / 2 + 32) {
+ itemPaneOpen = true;
+ }
+ }
+
+ //Atomic reference used so that below lambda doesn't complain about non-effectively-final variable
+ AtomicReference<JsonObject> tooltipToDisplay = new AtomicReference<>(null);
+ //System.out.println(itemPaneOffsetFactor.getValue());
+ if (itemPaneOffsetFactor.getValue() < 0.99) {
+ if (NotEnoughUpdates.INSTANCE.config.itemlist.bgBlurFactor > 0.5) {
+ BackgroundBlur.renderBlurredBackground(NotEnoughUpdates.INSTANCE.config.itemlist.bgBlurFactor,
+ width, height,
+ leftSide + getBoxPadding() - 5, getBoxPadding() - 5,
+ paneWidth - getBoxPadding() * 2 + 10, height - getBoxPadding() * 2 + 10,
+ itemPaneOffsetFactor.getValue() > 0.01
+ );
+ Gui.drawRect(leftSide + getBoxPadding() - 5, getBoxPadding() - 5,
+ leftSide + getBoxPadding() - 5 + paneWidth - getBoxPadding() * 2 + 10,
+ getBoxPadding() - 5 + height - getBoxPadding() * 2 + 10, 0xc8101010
+ );
+ }
+
+ drawRect(leftSide + getBoxPadding() - 5, getBoxPadding() - 5,
+ leftSide + paneWidth - getBoxPadding() + 5, height - getBoxPadding() + 5, bg.getRGB()
+ );
+
+ renderNavElement(leftSide + getBoxPadding() + getItemBoxXPadding(), rightSide, getMaxPages(), page + 1,
+ Utils.peekGuiScale().getScaleFactor() < 4 ? "Page: " : ""
+ );
+
+ //Sort bar
+ drawRect(leftSide + getBoxPadding() + getItemBoxXPadding() - 1,
+ height - getBoxPadding() - ITEM_SIZE - 2,
+ rightSide + 1,
+ height - getBoxPadding(), fgCustomOpacity.getRGB()
+ );
+
+ float sortIconsMinX = (sortIcons.length + orderIcons.length) * (ITEM_SIZE + ITEM_PADDING) + ITEM_SIZE;
+ float availableX = rightSide - (leftSide + getBoxPadding() + getItemBoxXPadding());
+ float sortOrderScaleFactor = Math.min(1, availableX / sortIconsMinX);
+
+ int scaledITEM_SIZE = (int) (ITEM_SIZE * sortOrderScaleFactor);
+ int scaledItemPaddedSize = (int) ((ITEM_SIZE + ITEM_PADDING) * sortOrderScaleFactor);
+ int iconTop = height - getBoxPadding() - (ITEM_SIZE + scaledITEM_SIZE) / 2 - 1;
+
+ boolean hoveredOverControl = false;
+ for (int i = 0; i < orderIcons.length; i++) {
+ int orderIconX = leftSide + getBoxPadding() + getItemBoxXPadding() + i * scaledItemPaddedSize;
+ drawRect(orderIconX, iconTop, scaledITEM_SIZE + orderIconX, iconTop + scaledITEM_SIZE, fg.getRGB());
+
+ Minecraft
+ .getMinecraft()
+ .getTextureManager()
+ .bindTexture(getCompareMode() == i ? orderIconsActive[i] : orderIcons[i]);
+ GlStateManager.color(1f, 1f, 1f, 1f);
+ Utils.drawTexturedRect(orderIconX, iconTop, scaledITEM_SIZE, scaledITEM_SIZE, 0, 1, 0, 1, GL11.GL_NEAREST);
+
+ Minecraft
+ .getMinecraft()
+ .getTextureManager()
+ .bindTexture(getCompareAscending().get(i) ? ascending_overlay : descending_overlay);
+ GlStateManager.color(1f, 1f, 1f, 1f);
+ Utils.drawTexturedRect(orderIconX, iconTop, scaledITEM_SIZE, scaledITEM_SIZE, 0, 1, 0, 1, GL11.GL_NEAREST);
+ GlStateManager.bindTexture(0);
+
+ if (mouseY > iconTop && mouseY < iconTop + scaledITEM_SIZE) {
+ if (mouseX > orderIconX && mouseX < orderIconX + scaledITEM_SIZE) {
+ hoveredOverControl = true;
+ if (System.currentTimeMillis() - millisLastMouseMove > 400) {
+ String text = EnumChatFormatting.GRAY + "Order ";
+ if (i == COMPARE_MODE_ALPHABETICAL) text += "Alphabetically";
+ else if (i == COMPARE_MODE_RARITY) text += "by Rarity";
+ else if (i == COMPARE_MODE_VALUE) text += "by Item Worth";
+ else text = null;
+ if (text != null) textToDisplay = Utils.createList(text);
+ }
+ }
+ }
+ }
+
+ for (int i = 0; i < sortIcons.length; i++) {
+ int sortIconX = rightSide - scaledITEM_SIZE - i * scaledItemPaddedSize;
+ drawRect(sortIconX, iconTop, scaledITEM_SIZE + sortIconX, iconTop + scaledITEM_SIZE, fg.getRGB());
+ Minecraft
+ .getMinecraft()
+ .getTextureManager()
+ .bindTexture(getSortMode() == i ? sortIconsActive[i] : sortIcons[i]);
+ GlStateManager.color(1f, 1f, 1f, 1f);
+ Utils.drawTexturedRect(sortIconX, iconTop, scaledITEM_SIZE, scaledITEM_SIZE, 0, 1, 0, 1, GL11.GL_NEAREST);
+ GlStateManager.bindTexture(0);
+
+ if (mouseY > iconTop && mouseY < iconTop + scaledITEM_SIZE) {
+ if (mouseX > sortIconX && mouseX < sortIconX + scaledITEM_SIZE) {
+ hoveredOverControl = true;
+ if (System.currentTimeMillis() - millisLastMouseMove > 400) {
+ String text = EnumChatFormatting.GRAY + "Filter ";
+ if (i == SORT_MODE_ALL) text = EnumChatFormatting.GRAY + "No Filter";
+ else if (i == SORT_MODE_MOB) text += "Mobs";
+ else if (i == SORT_MODE_PET) text += "Pets";
+ else if (i == SORT_MODE_TOOL) text += "Tools";
+ else if (i == SORT_MODE_ARMOR) text += "Armor";
+ else if (i == SORT_MODE_ACCESSORY) text += "Accessories";
+ else text = null;
+ if (text != null) textToDisplay = Utils.createList(text);
+ }
+ }
+ }
+ }
+
+ if (!hoveredOverControl) {
+ millisLastMouseMove = System.currentTimeMillis();
+ }
+
+ if (selectedItemGroup != null) {
+ if (mouseX < selectedItemGroupX - 1 || mouseX > selectedItemGroupX + 17 ||
+ mouseY < selectedItemGroupY - 1 || mouseY > selectedItemGroupY + 17) {
+ int selectedX = Math.min(selectedItemGroupX, width - getBoxPadding() - 18 * selectedItemGroup.size());
+ if (mouseX < selectedX - 1 || mouseX > selectedX - 1 + 18 * selectedItemGroup.size() ||
+ mouseY < selectedItemGroupY + 17 || mouseY > selectedItemGroupY + 35) {
+ selectedItemGroup = null;
+ selectedItemMillis = -1;
+ }
+ }
+ }
+
+ if (!hoverInv) {
+ iterateItemSlots(new ItemSlotConsumer() {
+ public void consume(int x, int y, int id) {
+ JsonObject json = getSearchedItemPage(id);
+ if (json == null) {
+ return;
+ }
+ if (mouseX > x - 1 && mouseX < x + ITEM_SIZE + 1) {
+ if (mouseY > y - 1 && mouseY < y + ITEM_SIZE + 1) {
+ String internalname = json.get("internalname").getAsString();
+ if (searchedItemsSubgroup.containsKey(internalname)) {
+ if (selectedItemMillis == -1) selectedItemMillis = System.currentTimeMillis();
+ if (System.currentTimeMillis() - selectedItemMillis > 200 &&
+ (selectedItemGroup == null || selectedItemGroup.isEmpty())) {
+
+ ArrayList<JsonObject> children = new ArrayList<>();
+ children.add(json);
+ for (String itemname : searchedItemsSubgroup.get(internalname)) {
+ children.add(manager.getItemInformation().get(itemname));
+ }
+
+ selectedItemGroup = children;
+ selectedItemGroupX = x;
+ selectedItemGroupY = y;
+ }
+ } else {
+ tooltipToDisplay.set(json);
+ }
+ }
+ }
+ }
+ });
+ }
+
+ //Iterate through all item slots and display the appropriate item
+ int itemBoxXPadding = getItemBoxXPadding();
+ int xStart = (int) (width * getItemPaneOffsetFactor()) + getBoxPadding() + itemBoxXPadding;
+
+ if (OpenGlHelper.isFramebufferEnabled()) {
+ renderItemsFromImage(xStart, width, height);
+ renderEnchOverlay();
+
+ checkFramebufferSizes(width, height);
+
+ if (redrawItems || !NotEnoughUpdates.INSTANCE.config.hidden.cacheRenderedItempane) {
+ renderItemsToImage(width, height, fgFavourite2, fgFavourite, fgCustomOpacity, true, true);
+ redrawItems = false;
+ }
+ } else {
+ renderItems(xStart, true, true, true);
+ }
+
+ if (selectedItemGroup != null) {
+ GL11.glTranslatef(0, 0, 10);
+
+ int selectedX = Math.min(selectedItemGroupX, width - getBoxPadding() - 18 * selectedItemGroup.size());
+
+ GlStateManager.enableDepth();
+ GlStateManager.depthFunc(GL11.GL_LESS);
+ drawRect(selectedX, selectedItemGroupY + 18,
+ selectedX - 2 + 18 * selectedItemGroup.size(), selectedItemGroupY + 34, fgCustomOpacity.getRGB()
+ );
+ drawRect(selectedX - 1, selectedItemGroupY + 17,
+ selectedX - 2 + 18 * selectedItemGroup.size(), selectedItemGroupY + 34, new Color(180, 180, 180).getRGB()
+ );
+ drawRect(selectedX, selectedItemGroupY + 18,
+ selectedX - 1 + 18 * selectedItemGroup.size(), selectedItemGroupY + 35, new Color(30, 30, 30).getRGB()
+ );
+ drawRect(selectedX - 1 + 2, selectedItemGroupY + 17 + 2,
+ selectedX - 1 + 18 * selectedItemGroup.size() + 2, selectedItemGroupY + 35 + 2, 0xa0000000
+ );
+ GlStateManager.depthFunc(GL11.GL_LEQUAL);
+
+ GL11.glTranslatef(0, 0, 10);
+
+ tooltipToDisplay.set(null);
+ if (mouseY > selectedItemGroupY + 17 && mouseY < selectedItemGroupY + 35) {
+ for (int i = 0; i < selectedItemGroup.size(); i++) {
+ if (mouseX >= selectedX - 1 + 18 * i && mouseX <= selectedX + 17 + 18 * i) {
+ tooltipToDisplay.set(selectedItemGroup.get(i));
+ }
+ }
+ }
+ for (int i = 0; i < selectedItemGroup.size(); i++) {
+ JsonObject item = selectedItemGroup.get(i);
+ Utils.drawItemStack(manager.jsonToStack(item), selectedX + 18 * i, selectedItemGroupY + 18);
+ }
+
+ GL11.glTranslatef(0, 0, -20);
+ }
+
+ GlStateManager.enableBlend();
+ GL14.glBlendFuncSeparate(
+ GL11.GL_SRC_ALPHA,
+ GL11.GL_ONE_MINUS_SRC_ALPHA,
+ GL11.GL_ONE,
+ GL11.GL_ONE_MINUS_SRC_ALPHA
+ );
+ GlStateManager.enableAlpha();
+ GlStateManager.alphaFunc(516, 0.1F);
+ GlStateManager.disableLighting();
+ }
+
+ /*
+ * Search bar & quickcommand elements
+ */
+ guiGroup.render(0, 0);
+ resetAnchors(true);
+
+ /*
+ * Item info (left) gui element rendering
+ */
+
+ rightSide = (int) (width * getInfoPaneOffsetFactor());
+ leftSide = rightSide - paneWidth;
+
+ if (activeInfoPane != null) {
+ activeInfoPane.tick();
+ activeInfoPane.render(width, height, bg, fg, Utils.peekGuiScale(), mouseX, mouseY);
+
+ GlStateManager.color(1f, 1f, 1f, 1f);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(close);
+ Utils.drawTexturedRect(rightSide - getBoxPadding() - 8, getBoxPadding() - 8, 16, 16);
+ GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
+ }
+
+ //Render tooltip
+ JsonObject json = tooltipToDisplay.get();
+ if (json != null) {
+
+ ItemStack stack = manager.jsonToStack(json);
+ {
+ NBTTagCompound tag = stack.getTagCompound();
+ tag.setBoolean("DisablePetExp", true);
+ stack.setTagCompound(tag);
+ }
+
+ List<String> text = stack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
+
+ String internalname = json.get("internalname").getAsString();
+ if (!NotEnoughUpdates.INSTANCE.config.tooltipTweaks.showPriceInfoInvItem) {
+ ItemPriceInformation.addToTooltip(text, internalname, stack);
+ }
+
+ boolean hasClick =
+ (json.has("clickcommand") && !json.get("clickcommand").getAsString().isEmpty())
+ || !manager.getAvailableRecipesFor(internalname).isEmpty();
+ boolean hasInfo = json.has("info") && json.get("info").getAsJsonArray().size() > 0;
+
+ if (hasClick || hasInfo) text.add("");
+ if (hasClick)
+ text.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "LMB/R : View recipe!");
+ if (hasInfo)
+ text.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "RMB : View additional information!");
+
+ textToDisplay = text;
+ }
+ if (textToDisplay != null) {
+ Utils.drawHoveringText(textToDisplay, mouseX, mouseY, width, height, -1, fr);
+ textToDisplay = null;
+ }
+
+ GlStateManager.enableBlend();
+ GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ GlStateManager.enableAlpha();
+ GlStateManager.alphaFunc(516, 0.1F);
+ GlStateManager.disableLighting();
+
+ Utils.pushGuiScale(-1);
+
+ if (System.currentTimeMillis() - lastSearchMode > 120000 &&
+ NotEnoughUpdates.INSTANCE.config.toolbar.autoTurnOffSearchMode
+ || !NotEnoughUpdates.INSTANCE.config.toolbar.searchBar) {
+ searchMode = false;
+ }
+ }
+
+ /**
+ * Used in SettingsInfoPane to redraw the items when a setting changes.
+ */
+ public void redrawItems() {
+ redrawItems = true;
+ }
+
+ /**
+ * Sets the current page and marks that the itemsPane should be redrawn
+ */
+ public void setPage(int page) {
+ this.page = page;
+ redrawItems = true;
+ }
+
+ private final Framebuffer[] itemFramebuffers = new Framebuffer[2];
+
+ /**
+ * Checks whether the screen size has changed, if so it reconstructs the itemPane framebuffer and marks that the
+ * itemPane should be redrawn.
+ */
+ private void checkFramebufferSizes(int width, int height) {
+ int sw = width * Utils.peekGuiScale().getScaleFactor();
+ int sh = height * Utils.peekGuiScale().getScaleFactor();
+ for (int i = 0; i < itemFramebuffers.length; i++) {
+ if (itemFramebuffers[i] == null ||
+ itemFramebuffers[i].framebufferWidth != sw ||
+ itemFramebuffers[i].framebufferHeight != sh) {
+ if (itemFramebuffers[i] == null) {
+ itemFramebuffers[i] = new Framebuffer(sw, sh, true);
+ } else {
+ itemFramebuffers[i].createBindFramebuffer(sw, sh);
+ }
+ itemFramebuffers[i].setFramebufferFilter(GL11.GL_NEAREST);
+ redrawItems = true;
+ }
+ }
+ }
+
+ private void prepareFramebuffer(Framebuffer buffer, int sw, int sh) {
+ buffer.framebufferClear();
+ buffer.bindFramebuffer(false);
+ GL11.glViewport(0, 0, sw, sh);
+ }
+
+ private void cleanupFramebuffer(Framebuffer buffer, int sw, int sh) {
+ buffer.unbindFramebuffer();
+ Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true);
+ }
+
+ /**
+ * Renders all items to a framebuffer so that it can be reused later, drastically improving performance.
+ * Unfortunately using this feature will mean that animated textures will not work, but oh well.
+ * Mojang please optimize item rendering thanks.
+ */
+ private void renderItemsToImage(
+ int width, int height, Color fgFavourite2,
+ Color fgFavourite, Color fgCustomOpacity, boolean items, boolean entities
+ ) {
+ int sw = width * Utils.peekGuiScale().getScaleFactor();
+ int sh = height * Utils.peekGuiScale().getScaleFactor();
+
+ GL11.glPushMatrix();
+ prepareFramebuffer(itemFramebuffers[0], sw, sh);
+ renderItems(10, items, entities, false);
+ cleanupFramebuffer(itemFramebuffers[0], sw, sh);
+ GL11.glPopMatrix();
+
+ GL11.glPushMatrix();
+ prepareFramebuffer(itemFramebuffers[1], sw, sh);
+ renderItemBackgrounds(fgFavourite2, fgFavourite, fgCustomOpacity);
+ cleanupFramebuffer(itemFramebuffers[1], sw, sh);
+ GL11.glPopMatrix();
+ }
+
+ private static final ResourceLocation RES_ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png");
+
+ /**
+ * Renders the framebuffer created by #renderItemsToImage to the screen.
+ * itemRenderOffset is a magic number that makes the z-level of the rendered items equal to the z-level of
+ * the item glint overlay model, meaning that a depthFunc of GL_EQUAL can correctly render on to the item.
+ */
+ float itemRenderOffset = 7.5001f;
+
+ private void renderItemsFromImage(int xOffset, int width, int height) {
+ if (itemFramebuffers[0] != null && itemFramebuffers[1] != null) {
+ itemFramebuffers[1].bindFramebufferTexture();
+ GlStateManager.color(1f, 1f, 1f, 1f);
+ Utils.drawTexturedRect(xOffset - 10, 0, width, height, 0, 1, 1, 0);
+ itemFramebuffers[1].unbindFramebufferTexture();
+
+ GL11.glTranslatef(0, 0, itemRenderOffset);
+ itemFramebuffers[0].bindFramebufferTexture();
+ GlStateManager.color(1f, 1f, 1f, 1f);
+ Utils.drawTexturedRect(xOffset - 10, 0, width, height, 0, 1, 1, 0);
+ itemFramebuffers[0].unbindFramebufferTexture();
+ GL11.glTranslatef(0, 0, -itemRenderOffset);
+ }
+ }
+
+ /**
+ * Renders the enchant overlay, since only the items have the specific z-offset of 7.5001, this will only apply
+ * the enchant overlay to the actual items and not anything else.
+ * <p>
+ * (I tried very hard to replicate the enchant rendering overlay code from vanilla, but I couldn't get it to
+ * work without rendering with the "ITEM" vertex model like in vanilla, so I choose to render an arbitrary 2D
+ * item. If a texture pack sets a custom 3D model for an apple, this will probably break.)
+ */
+ private void renderEnchOverlay() {
+ ItemStack stack = new ItemStack(Items.apple);
+ IBakedModel model = Minecraft.getMinecraft().getRenderItem().getItemModelMesher()
+ .getItemModel(stack);
+ float f = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F / 8.0F;
+ float f1 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F / 8.0F;
+ Minecraft.getMinecraft().getTextureManager().bindTexture(RES_ITEM_GLINT);
+
+ GL11.glPushMatrix();
+ GL11.glTranslatef(0, 0, -7.5001f + itemRenderOffset);
+ iterateItemSlots(new ItemSlotConsumer() {
+ public void consume(int x, int y, int id) {
+ JsonObject json = getSearchedItemPage(id);
+ if (json == null) {
+ return;
+ }
+ ItemStack stack = manager.jsonToStack(json, true, true, false);
+ if (stack == null || !stack.hasEffect()) {
+ return;
+ }
+
+ GlStateManager.pushMatrix();
+ GlStateManager.enableRescaleNormal();
+ GlStateManager.enableAlpha();
+ GlStateManager.alphaFunc(516, 0.1F);
+ GlStateManager.enableBlend();
+
+ GlStateManager.disableLighting();
+
+ GlStateManager.translate(x, y, 0);
+ GlStateManager.scale(16f, 16f, 16f);
+
+ GlStateManager.depthMask(false);
+ GlStateManager.depthFunc(GL11.GL_EQUAL);
+ GlStateManager.blendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
+ GlStateManager.matrixMode(5890);
+ GlStateManager.pushMatrix();
+ GlStateManager.scale(8.0F, 8.0F, 8.0F);
+ GlStateManager.translate(f, 0.0F, 0.0F);
+ GlStateManager.rotate(-50.0F, 0.0F, 0.0F, 1.0F);
+
+ renderModel(model, -8372020, null);
+
+ GlStateManager.popMatrix();
+ GlStateManager.pushMatrix();
+ GlStateManager.scale(8.0F, 8.0F, 8.0F);
+ GlStateManager.translate(-f1, 0.0F, 0.0F);
+ GlStateManager.rotate(10.0F, 0.0F, 0.0F, 1.0F);
+
+ renderModel(model, -8372020, null);
+
+ GlStateManager.popMatrix();
+ GlStateManager.matrixMode(5888);
+ GlStateManager.blendFunc(770, 771);
+ GlStateManager.depthFunc(515);
+ GlStateManager.depthMask(true);
+
+ GlStateManager.popMatrix();
+ }
+ });
+ GlStateManager.disableBlend();
+ GlStateManager.disableAlpha();
+ GlStateManager.disableRescaleNormal();
+ GL11.glTranslatef(0, 0, 7.5001f - itemRenderOffset);
+ GL11.glPopMatrix();
+
+ GlStateManager.bindTexture(0);
+ }
+
+ private void renderModel(IBakedModel model, int color, ItemStack stack) {
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+ worldrenderer.begin(7, DefaultVertexFormats.ITEM);
+
+ for (EnumFacing enumfacing : EnumFacing.values()) {
+ this.renderQuads(worldrenderer, model.getFaceQuads(enumfacing), color);
+ }
+
+ this.renderQuads(worldrenderer, model.getGeneralQuads(), color);
+
+ tessellator.draw();
+ }
+
+ private void renderQuads(WorldRenderer renderer, List<BakedQuad> quads, int color) {
+ if (quads == null) return;
+
+ for (BakedQuad quad : quads) {
+ renderer.addVertexData(quad.getVertexData());
+ renderer.putColor4(color);
+ }
+ }
+
+ /**
+ * Renders all the item backgrounds, either squares or squircles.
+ */
+ private void renderItemBackgrounds(Color fgFavourite2, Color fgFavourite, Color fgCustomOpacity) {
+ if (fgCustomOpacity.getAlpha() == 0) return;
+ iterateItemSlots(new ItemSlotConsumer() {
+ public void consume(int x, int y, int id) {
+ JsonObject json = getSearchedItemPage(id);
+ if (json == null) {
+ return;
+ }
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(item_mask);
+ if (getFavourites().contains(json.get("internalname").getAsString())) {
+ if (NotEnoughUpdates.INSTANCE.config.itemlist.itemStyle == 0) {
+ GlStateManager.color(fgFavourite2.getRed() / 255f, fgFavourite2.getGreen() / 255f,
+ fgFavourite2.getBlue() / 255f, fgFavourite2.getAlpha() / 255f
+ );
+ Utils.drawTexturedRect(x - 1, y - 1, ITEM_SIZE + 2, ITEM_SIZE + 2, GL11.GL_NEAREST);
+
+ GlStateManager.color(fgFavourite.getRed() / 255f, fgFavourite.getGreen() / 255f,
+ fgFavourite.getBlue() / 255f, fgFavourite.getAlpha() / 255f
+ );
+ Utils.drawTexturedRect(x, y, ITEM_SIZE, ITEM_SIZE, GL11.GL_NEAREST);
+ } else {
+ drawRect(x - 1, y - 1, x + ITEM_SIZE + 1, y + ITEM_SIZE + 1, fgFavourite2.getRGB());
+ drawRect(x, y, x + ITEM_SIZE, y + ITEM_SIZE, fgFavourite.getRGB());
+ }
+ } else {
+ if (NotEnoughUpdates.INSTANCE.config.itemlist.itemStyle == 0) {
+ GlStateManager.color(fgCustomOpacity.getRed() / 255f, fgCustomOpacity.getGreen() / 255f,
+ fgCustomOpacity.getBlue() / 255f, fgCustomOpacity.getAlpha() / 255f
+ );
+ Utils.drawTexturedRect(x - 1, y - 1, ITEM_SIZE + 2, ITEM_SIZE + 2, GL11.GL_NEAREST);
+ } else {
+ drawRect(x - 1, y - 1, x + ITEM_SIZE + 1, y + ITEM_SIZE + 1, fgCustomOpacity.getRGB());
+ }
+ }
+ GlStateManager.bindTexture(0);
+ }
+ }, 10);
+ }
+
+ private void renderItems(int xStart, boolean items, boolean entities, boolean glint) {
+ iterateItemSlots(new ItemSlotConsumer() {
+ public void consume(int x, int y, int id) {
+ JsonObject json = getSearchedItemPage(id);
+ if (json == null) {
+ return;
+ }
+
+ if (json.has("entityrender")) {
+ if (!entities) return;
+ String name = json.get("displayname").getAsString();
+ String[] split = name.split(" \\(");
+ name = name.substring(0, name.length() - split[split.length - 1].length() - 2);
+
+ Class<? extends EntityLivingBase>[] entities = new Class[1];
+ if (json.get("entityrender").isJsonArray()) {
+ JsonArray entityrender = json.get("entityrender").getAsJsonArray();
+ entities = new Class[entityrender.size()];
+ for (int i = 0; i < entityrender.size(); i++) {
+ Class<? extends Entity> clazz = EntityList.stringToClassMapping.get(entityrender.get(i).getAsString());
+ if (clazz != null && EntityLivingBase.class.isAssignableFrom(clazz)) {
+ entities[i] = (Class<? extends EntityLivingBase>) clazz;
+ }
+ }
+ } else if (json.get("entityrender").isJsonPrimitive()) {
+ Class<? extends Entity> clazz = EntityList.stringToClassMapping.get(json.get("entityrender").getAsString());
+ if (clazz != null && EntityLivingBase.class.isAssignableFrom(clazz)) {
+ entities[0] = (Class<? extends EntityLivingBase>) clazz;
+ }
+ }
+
+ float scale = 8;
+ if (json.has("entityscale")) {
+ scale *= json.get("entityscale").getAsFloat();
+ }
+
+ renderEntity(x + ITEM_SIZE / 2, y + ITEM_SIZE, scale, name, entities);
+ } else {
+ if (!items) return;
+ ItemStack stack = manager.jsonToStack(json, true, true, false);
+ if (stack != null) {
+ if (glint) {
+ Utils.drawItemStack(stack, x, y);
+ } else {
+ Utils.drawItemStackWithoutGlint(stack, x, y);
+ }
+ }
+ }
+
+ GlStateManager.translate(0, 0, 50);
+ if (searchedItemsSubgroup.containsKey(json.get("internalname").getAsString())) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(item_haschild);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(x - 1, y - 1, ITEM_SIZE + 2, ITEM_SIZE + 2, GL11.GL_NEAREST);
+ }
+ GlStateManager.translate(0, 0, -50);
+ }
+ }, xStart);
+ }
+
+ public float getItemPaneOffsetFactor() {
+ return itemPaneOffsetFactor.getValue() * getWidthMult() + (1 - getWidthMult());
+ }
+
+ public float getInfoPaneOffsetFactor() {
+ return infoPaneOffsetFactor.getValue() * getWidthMult();
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
index 6a0d3ab4..b6ac71a4 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
@@ -1,372 +1,408 @@
package io.github.moulberry.notenoughupdates;
-import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
-import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
-import io.github.moulberry.notenoughupdates.auction.CustomAHGui;
-import io.github.moulberry.notenoughupdates.collectionlog.GuiCollectionLog;
import io.github.moulberry.notenoughupdates.commands.Commands;
-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.config.GuiPositionEditor;
-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;
-import io.github.moulberry.notenoughupdates.dungeons.DungeonWin;
-import io.github.moulberry.notenoughupdates.dungeons.GuiDungeonMapEditor;
-import io.github.moulberry.notenoughupdates.gamemodes.GuiGamemodes;
import io.github.moulberry.notenoughupdates.miscfeatures.*;
-import io.github.moulberry.notenoughupdates.miscgui.*;
-import io.github.moulberry.notenoughupdates.miscgui.tutorials.NeuTutorial;
+import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.CustomBiomes;
+import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.CustomBlockSounds;
+import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.DwarvenMinesTextures;
+import io.github.moulberry.notenoughupdates.miscgui.CalendarOverlay;
+import io.github.moulberry.notenoughupdates.miscgui.InventoryStorageSelector;
import io.github.moulberry.notenoughupdates.options.NEUConfig;
-import io.github.moulberry.notenoughupdates.options.NEUConfigEditor;
import io.github.moulberry.notenoughupdates.overlays.FuelBar;
import io.github.moulberry.notenoughupdates.overlays.OverlayManager;
-import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer;
-import io.github.moulberry.notenoughupdates.profileviewer.PlayerStats;
import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer;
+import io.github.moulberry.notenoughupdates.recipes.RecipeGenerator;
import io.github.moulberry.notenoughupdates.util.SBInfo;
-import io.github.moulberry.notenoughupdates.util.Constants;
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.renderer.OpenGlHelper;
import net.minecraft.client.resources.IReloadableResourceManager;
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.item.ItemMap;
-import net.minecraft.item.ItemStack;
import net.minecraft.scoreboard.ScoreObjective;
import net.minecraft.scoreboard.Scoreboard;
-import net.minecraft.util.*;
-import net.minecraft.world.storage.MapData;
-import net.minecraftforge.client.ClientCommandHandler;
-import net.minecraftforge.common.ForgeVersion;
+import net.minecraft.util.ChatComponentText;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.world.biome.*;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.client.registry.ClientRegistry;
-import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
-import net.minecraftforge.fml.common.ModContainer;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
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.lwjgl.opengl.Display;
-import org.lwjgl.opengl.GL11;
import java.awt.*;
-import java.awt.datatransfer.StringSelection;
import java.io.*;
-import java.lang.management.ManagementFactory;
-import java.net.URI;
-import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
-import java.util.*;
-import java.util.List;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
+import java.util.HashMap;
+import java.util.Set;
@Mod(modid = NotEnoughUpdates.MODID, version = NotEnoughUpdates.VERSION, clientSideOnly = true)
public class NotEnoughUpdates {
- public static final String MODID = "notenoughupdates";
- public static final String VERSION = "2.0.0-REL";
- public static final String PRE_VERSION = "30.2";
- public static final int VERSION_ID = 20000;
- public static final int PRE_VERSION_ID = 3002;
-
- public static NotEnoughUpdates INSTANCE = null;
-
- public NEUManager manager;
- public NEUOverlay overlay;
- public NEUConfig config;
-
- private File configFile;
-
- public File getConfigFile(){
- return this.configFile;
- }
- public void newConfigFile(){
- this.configFile = new File(NotEnoughUpdates.INSTANCE.getNeuDir(), "configNew.json");
- }
-
- private static final long CHAT_MSG_COOLDOWN = 200;
- private long lastChatMessage = 0;
- private long secondLastChatMessage = 0;
- private String currChatMessage = null;
-
- //Stolen from Biscut and used for detecting whether in skyblock
- private static final Set<String> SKYBLOCK_IN_ALL_LANGUAGES = Sets.newHashSet("SKYBLOCK","\u7A7A\u5C9B\u751F\u5B58", "\u7A7A\u5CF6\u751F\u5B58");
-
- public GuiScreen openGui = null;
- public long lastOpenedGui = 0;
-
- public Commands commands;
-
-
-
- public static HashMap<String, String> petRarityToColourMap = new HashMap<>();
- static {
- petRarityToColourMap.put("UNKNOWN", EnumChatFormatting.RED.toString());
-
- petRarityToColourMap.put("COMMON", EnumChatFormatting.WHITE.toString());
- petRarityToColourMap.put("UNCOMMON", EnumChatFormatting.GREEN.toString());
- petRarityToColourMap.put("RARE", EnumChatFormatting.BLUE.toString());
- petRarityToColourMap.put("EPIC", EnumChatFormatting.DARK_PURPLE.toString());
- petRarityToColourMap.put("LEGENDARY", EnumChatFormatting.GOLD.toString());
- petRarityToColourMap.put("MYTHIC", EnumChatFormatting.LIGHT_PURPLE.toString());
- }
-
- public static ProfileViewer profileViewer;
-
- public boolean packDevEnabled = false;
-
- private Gson gson = new GsonBuilder().setPrettyPrinting().excludeFieldsWithoutExposeAnnotation().create();
- private File neuDir;
-
- public File getNeuDir(){ return this.neuDir;}
-
- public Color[][] colourMap = null;
-
- /**
- * Instantiates NEUIo, NEUManager and NEUOverlay instances. Registers keybinds and adds a shutdown hook to clear tmp folder.
- * @param event
- */
- @EventHandler
- public void preinit(FMLPreInitializationEvent event) {
- INSTANCE = this;
-
- neuDir = new File(event.getModConfigurationDirectory(), "notenoughupdates");
- neuDir.mkdirs();
-
- configFile = new File(neuDir, "configNew.json");
-
- if(configFile.exists()) {
- try(BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(configFile), StandardCharsets.UTF_8))) {
- config = gson.fromJson(reader, NEUConfig.class);
- } 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"));
- SlotLocking.getInstance().loadConfig(new File(neuDir, "slotLocking.json"));
-
- if(config == null) {
- config = new NEUConfig();
- saveConfig();
- }
-
- MinecraftForge.EVENT_BUS.register(this);
- MinecraftForge.EVENT_BUS.register(new NEUEventListener(this));
- MinecraftForge.EVENT_BUS.register(CapeManager.getInstance());
- //MinecraftForge.EVENT_BUS.register(new SBGamemodes());
- MinecraftForge.EVENT_BUS.register(new EnchantingSolvers());
- MinecraftForge.EVENT_BUS.register(new CalendarOverlay());
- MinecraftForge.EVENT_BUS.register(SBInfo.getInstance());
- MinecraftForge.EVENT_BUS.register(CustomItemEffects.INSTANCE);
- MinecraftForge.EVENT_BUS.register(new DungeonMap());
- MinecraftForge.EVENT_BUS.register(new SunTzu());
- MinecraftForge.EVENT_BUS.register(new MiningStuff());
- MinecraftForge.EVENT_BUS.register(new FairySouls());
- MinecraftForge.EVENT_BUS.register(new CrystalOverlay());
- MinecraftForge.EVENT_BUS.register(new ItemCooldowns());
- MinecraftForge.EVENT_BUS.register(new DwarvenMinesTextures());
- MinecraftForge.EVENT_BUS.register(new DwarvenMinesWaypoints());
- MinecraftForge.EVENT_BUS.register(new FuelBar());
- //MinecraftForge.EVENT_BUS.register(new FancyPortals());
- MinecraftForge.EVENT_BUS.register(XPInformation.getInstance());
- 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());
- MinecraftForge.EVENT_BUS.register(FishingHelper.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());
- }
-
- this.commands = new Commands();
-
- BackgroundBlur.registerListener();
-
- manager = new NEUManager(this, neuDir);
- manager.loadItemInformation();
- overlay = new NEUOverlay(manager);
- profileViewer = new ProfileViewer(manager);
-
- for(KeyBinding kb : manager.keybinds) {
- ClientRegistry.registerKeyBinding(kb);
- }
-
- Runtime.getRuntime().addShutdownHook(new Thread(() -> {
- File tmp = new File(neuDir, "tmp");
- if(tmp.exists()) {
- for(File tmpFile : tmp.listFiles()) {
- tmpFile.delete();
- }
- tmp.delete();
- }
- //saveConfig();
- }));
- }
-
- public void saveConfig() {
- try {
- configFile.createNewFile();
-
- try(BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(configFile), StandardCharsets.UTF_8))) {
- writer.write(gson.toJson(config));
- }
- } catch(Exception 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) {}
- try { SlotLocking.getInstance().saveConfig(new File(neuDir, "slotLocking.json")); } catch(Exception ignored) {}
- }
-
- /**
- * If the last chat messages was sent >200ms ago, sends the message.
- * If the last chat message was sent <200 ago, will cache the message for #onTick to handle.
- */
- public void sendChatMessage(String message) {
- if(System.currentTimeMillis() - lastChatMessage > CHAT_MSG_COOLDOWN) {
- secondLastChatMessage = lastChatMessage;
- lastChatMessage = System.currentTimeMillis();
- Minecraft.getMinecraft().thePlayer.sendChatMessage(message);
- currChatMessage = null;
- } else {
- currChatMessage = message;
- }
- }
-
- public void displayLinks(JsonObject update) {
- String discord_link = update.get("discord_link").getAsString();
- String youtube_link = update.get("youtube_link").getAsString();
- String twitch_link = update.get("twitch_link").getAsString();
- String update_link = update.get("update_link").getAsString();
- String github_link = update.get("github_link").getAsString();
- String other_text = update.get("other_text").getAsString();
- String other_link = update.get("other_link").getAsString();
-
- ChatComponentText other = null;
- if(other_text.length() > 0) {
- other = new ChatComponentText(EnumChatFormatting.GRAY+"["+EnumChatFormatting.BLUE+other_text+EnumChatFormatting.GRAY+"]");
- other.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, other_link));
- }
- ChatComponentText links = new ChatComponentText("");
- ChatComponentText separator = new ChatComponentText(
- EnumChatFormatting.GRAY+EnumChatFormatting.BOLD.toString()+EnumChatFormatting.STRIKETHROUGH+(other==null?"--":"-"));
- ChatComponentText discord = new ChatComponentText(EnumChatFormatting.GRAY+"["+EnumChatFormatting.BLUE+"Discord"+EnumChatFormatting.GRAY+"]");
- discord.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, discord_link));
- ChatComponentText youtube = new ChatComponentText(EnumChatFormatting.GRAY+"["+EnumChatFormatting.RED+"YouTube"+EnumChatFormatting.GRAY+"]");
- youtube.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, youtube_link));
- ChatComponentText twitch = new ChatComponentText(EnumChatFormatting.GRAY+"["+EnumChatFormatting.DARK_PURPLE+"Twitch"+EnumChatFormatting.GRAY+"]");
- twitch.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, twitch_link));
- ChatComponentText release = new ChatComponentText(EnumChatFormatting.GRAY+"["+EnumChatFormatting.GREEN+"Release"+EnumChatFormatting.GRAY+"]");
- release.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, update_link));
- ChatComponentText github = new ChatComponentText(EnumChatFormatting.GRAY+"["+EnumChatFormatting.DARK_PURPLE+"GitHub"+EnumChatFormatting.GRAY+"]");
- github.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, github_link));
-
- links.appendSibling(separator);
- links.appendSibling(discord);
- links.appendSibling(separator);
- links.appendSibling(youtube);
- links.appendSibling(separator);
- links.appendSibling(twitch);
- links.appendSibling(separator);
- links.appendSibling(release);
- links.appendSibling(separator);
- links.appendSibling(github);
- links.appendSibling(separator);
- if(other != null) {
- links.appendSibling(other);
- links.appendSibling(separator);
- }
-
- Minecraft.getMinecraft().thePlayer.addChatMessage(links);
- }
-
- @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) {
- if(Minecraft.getMinecraft().thePlayer.openContainer != null) {
- Minecraft.getMinecraft().thePlayer.closeScreen();
- }
- Minecraft.getMinecraft().displayGuiScreen(openGui);
- openGui = null;
- lastOpenedGui = System.currentTimeMillis();
- }
- if(currChatMessage != null && currentTime - lastChatMessage > CHAT_MSG_COOLDOWN) {
- lastChatMessage = currentTime;
- Minecraft.getMinecraft().thePlayer.sendChatMessage(currChatMessage);
- currChatMessage = null;
- }
- }
-
- public boolean isOnSkyblock() {
- if(!config.misc.onlyShowOnSkyblock) return true;
- return hasSkyblockScoreboard();
- }
-
- private boolean hasSkyblockScoreboard;
-
- public boolean hasSkyblockScoreboard() {
- return hasSkyblockScoreboard;
- }
-
- public void updateSkyblockScoreboard() {
- Minecraft mc = Minecraft.getMinecraft();
-
- if (mc != null && mc.theWorld != null && mc.thePlayer != null) {
- if (mc.isSingleplayer() || mc.thePlayer.getClientBrand() == null ||
- !mc.thePlayer.getClientBrand().toLowerCase().contains("hypixel")) {
- hasSkyblockScoreboard = false;
- return;
- }
-
- Scoreboard scoreboard = mc.theWorld.getScoreboard();
- ScoreObjective sidebarObjective = scoreboard.getObjectiveInDisplaySlot(1);
- if (sidebarObjective != null) {
- String objectiveName = sidebarObjective.getDisplayName().replaceAll("(?i)\\u00A7.", "");
- for (String skyblock : SKYBLOCK_IN_ALL_LANGUAGES) {
- if (objectiveName.startsWith(skyblock)) {
- hasSkyblockScoreboard = true;
- return;
- }
- }
- }
-
- hasSkyblockScoreboard = false;
- }
-
- }
+ public static final String MODID = "notenoughupdates";
+ public static final String VERSION = "2.1.0-REL";
+ public static final String PRE_VERSION = "0.0";
+ public static final int VERSION_ID = 20100;
+ public static final int PRE_VERSION_ID = 0;
+
+ public static NotEnoughUpdates INSTANCE = null;
+
+ public NEUManager manager;
+ public NEUOverlay overlay;
+ public NEUConfig config;
+
+ private File configFile;
+
+ public File getConfigFile() {
+ return this.configFile;
+ }
+
+ public void newConfigFile() {
+ this.configFile = new File(NotEnoughUpdates.INSTANCE.getNeuDir(), "configNew.json");
+ }
+
+ private static final long CHAT_MSG_COOLDOWN = 200;
+ private long lastChatMessage = 0;
+ private long secondLastChatMessage = 0;
+ private String currChatMessage = null;
+
+ //Stolen from Biscut and used for detecting whether in skyblock
+ private static final Set<String> SKYBLOCK_IN_ALL_LANGUAGES =
+ Sets.newHashSet("SKYBLOCK", "\u7A7A\u5C9B\u751F\u5B58", "\u7A7A\u5CF6\u751F\u5B58");
+
+ public GuiScreen openGui = null;
+ public long lastOpenedGui = 0;
+
+ public Commands commands;
+
+ public static HashMap<String, String> petRarityToColourMap = new HashMap<String, String>() {{
+ put("UNKNOWN", EnumChatFormatting.RED.toString());
+ put("COMMON", EnumChatFormatting.WHITE.toString());
+ put("UNCOMMON", EnumChatFormatting.GREEN.toString());
+ put("RARE", EnumChatFormatting.BLUE.toString());
+ put("EPIC", EnumChatFormatting.DARK_PURPLE.toString());
+ put("LEGENDARY", EnumChatFormatting.GOLD.toString());
+ put("MYTHIC", EnumChatFormatting.LIGHT_PURPLE.toString());
+ }};
+
+ public static ProfileViewer profileViewer;
+
+ public boolean packDevEnabled = false;
+
+ private final Gson gson = new GsonBuilder().setPrettyPrinting().excludeFieldsWithoutExposeAnnotation().create();
+ private File neuDir;
+
+ public File getNeuDir() {
+ return this.neuDir;
+ }
+
+ public Color[][] colourMap = null;
+
+ /**
+ * Registers the biomes for the crystal hollows here so optifine knows they exists
+ */
+ public static final BiomeGenBase crystalHollowsJungle =
+ (new BiomeGenJungle(101, true))
+ .setColor(5470985)
+ .setBiomeName("NeuCrystalHollowsJungle")
+ .setFillerBlockMetadata(5470985)
+ .setTemperatureRainfall(0.95F, 0.9F);
+ public static final BiomeGenBase crystalHollowsMagmaFields =
+ (new BiomeGenHell(102))
+ .setColor(16711680)
+ .setBiomeName("NeuCrystalHollowsMagmaFields")
+ .setDisableRain()
+ .setTemperatureRainfall(2.0F, 0.0F);
+ public static final BiomeGenBase crystalHollowsGoblinHoldout =
+ (new BiomeGenMesa(103, false, false))
+ .setColor(13274213)
+ .setBiomeName("NeuCrystalHollowsGoblinHoldout");
+ public static final BiomeGenBase crystalHollowsPrecursorRemnants =
+ (new BiomeGenMesa(104, false, true))
+ .setColor(11573093)
+ .setBiomeName("NeuCrystalHollowsPrecursorRemnants");
+ public static final BiomeGenBase crystalHollowsMithrilDeposit =
+ (new BiomeGenSnow(105, false))
+ .setColor(16777215)
+ .setBiomeName("NeuCrystalHollowsMithrilDeposits");
+ public static final BiomeGenBase crystalHollowsCrystalNucleus =
+ (new BiomeGenJungle(106, true))
+ .setColor(5470985)
+ .setBiomeName("NeuCrystalHollowsCrystalNucleus")
+ .setFillerBlockMetadata(5470985)
+ .setTemperatureRainfall(0.95F, 0.9F);
+
+ /**
+ * Instantiates NEUIo, NEUManager and NEUOverlay instances. Registers keybinds and adds a shutdown hook to clear tmp folder.
+ */
+ @EventHandler
+ public void preinit(FMLPreInitializationEvent event) {
+ INSTANCE = this;
+
+ neuDir = new File(event.getModConfigurationDirectory(), "notenoughupdates");
+ neuDir.mkdirs();
+
+ configFile = new File(neuDir, "configNew.json");
+
+ if (configFile.exists()) {
+ try (
+ BufferedReader reader = new BufferedReader(new InputStreamReader(
+ new FileInputStream(configFile),
+ StandardCharsets.UTF_8
+ ))
+ ) {
+ config = gson.fromJson(reader, NEUConfig.class);
+ } catch (Exception ignored) {
+ }
+ }
+
+ 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"));
+ SlotLocking.getInstance().loadConfig(new File(neuDir, "slotLocking.json"));
+ ItemPriceInformation.init(new File(neuDir, "auctionable_items.json"), gson);
+
+ if (config == null) {
+ config = new NEUConfig();
+ saveConfig();
+ }
+
+ MinecraftForge.EVENT_BUS.register(this);
+ MinecraftForge.EVENT_BUS.register(new NEUEventListener(this));
+ MinecraftForge.EVENT_BUS.register(new RecipeGenerator(this));
+ MinecraftForge.EVENT_BUS.register(CapeManager.getInstance());
+ //MinecraftForge.EVENT_BUS.register(new SBGamemodes());
+ MinecraftForge.EVENT_BUS.register(new EnchantingSolvers());
+ MinecraftForge.EVENT_BUS.register(new CalendarOverlay());
+ MinecraftForge.EVENT_BUS.register(SBInfo.getInstance());
+ MinecraftForge.EVENT_BUS.register(CustomItemEffects.INSTANCE);
+ MinecraftForge.EVENT_BUS.register(new DungeonMap());
+ MinecraftForge.EVENT_BUS.register(new SunTzu());
+ MinecraftForge.EVENT_BUS.register(new MiningStuff());
+ MinecraftForge.EVENT_BUS.register(new FairySouls());
+ MinecraftForge.EVENT_BUS.register(new CrystalOverlay());
+ MinecraftForge.EVENT_BUS.register(new ItemCooldowns());
+ MinecraftForge.EVENT_BUS.register(new DwarvenMinesWaypoints());
+ MinecraftForge.EVENT_BUS.register(new FuelBar());
+ //MinecraftForge.EVENT_BUS.register(new FancyPortals());
+ MinecraftForge.EVENT_BUS.register(XPInformation.getInstance());
+ 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());
+ MinecraftForge.EVENT_BUS.register(FishingHelper.getInstance());
+ MinecraftForge.EVENT_BUS.register(new DwarvenMinesTextures());
+ MinecraftForge.EVENT_BUS.register(CustomBiomes.INSTANCE);
+
+ if (Minecraft.getMinecraft().getResourceManager() instanceof IReloadableResourceManager) {
+ IReloadableResourceManager manager = (IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager();
+ manager.registerReloadListener(CustomSkulls.getInstance());
+ manager.registerReloadListener(NPCRetexturing.getInstance());
+ manager.registerReloadListener(new ItemCustomizeManager.ReloadListener());
+ manager.registerReloadListener(new CustomBlockSounds.ReloaderListener());
+ }
+
+ this.commands = new Commands();
+
+ BackgroundBlur.registerListener();
+
+ manager = new NEUManager(this, neuDir);
+ manager.loadItemInformation();
+ overlay = new NEUOverlay(manager);
+ profileViewer = new ProfileViewer(manager);
+
+ for (KeyBinding kb : manager.keybinds) {
+ ClientRegistry.registerKeyBinding(kb);
+ }
+
+ Runtime.getRuntime().addShutdownHook(new Thread(() -> {
+ File tmp = new File(neuDir, "tmp");
+ if (tmp.exists()) {
+ for (File tmpFile : tmp.listFiles()) {
+ tmpFile.delete();
+ }
+ tmp.delete();
+ }
+ //saveConfig();
+ }));
+ }
+
+ public void saveConfig() {
+ try {
+ configFile.createNewFile();
+
+ try (
+ BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
+ new FileOutputStream(configFile),
+ StandardCharsets.UTF_8
+ ))
+ ) {
+ writer.write(gson.toJson(config));
+ }
+ } catch (Exception 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) {
+ }
+ try {
+ SlotLocking.getInstance().saveConfig(new File(neuDir, "slotLocking.json"));
+ } catch (Exception ignored) {
+ }
+ }
+
+ /**
+ * If the last chat messages was sent >200ms ago, sends the message.
+ * If the last chat message was sent <200 ago, will cache the message for #onTick to handle.
+ */
+ public void sendChatMessage(String message) {
+ if (System.currentTimeMillis() - lastChatMessage > CHAT_MSG_COOLDOWN) {
+ secondLastChatMessage = lastChatMessage;
+ lastChatMessage = System.currentTimeMillis();
+ Minecraft.getMinecraft().thePlayer.sendChatMessage(message);
+ currChatMessage = null;
+ } else {
+ currChatMessage = message;
+ }
+ }
+
+ public void displayLinks(JsonObject update) {
+ String discord_link = update.get("discord_link").getAsString();
+ String youtube_link = update.get("youtube_link").getAsString();
+ String twitch_link = update.get("twitch_link").getAsString();
+ String update_link = update.get("update_link").getAsString();
+ String github_link = update.get("github_link").getAsString();
+ String other_text = update.get("other_text").getAsString();
+ String other_link = update.get("other_link").getAsString();
+
+ ChatComponentText other = null;
+ if (other_text.length() > 0) {
+ other = new ChatComponentText(
+ EnumChatFormatting.GRAY + "[" + EnumChatFormatting.BLUE + other_text + EnumChatFormatting.GRAY + "]");
+ other.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, other_link));
+ }
+ ChatComponentText links = new ChatComponentText("");
+ ChatComponentText separator = new ChatComponentText(
+ EnumChatFormatting.GRAY + EnumChatFormatting.BOLD.toString() + EnumChatFormatting.STRIKETHROUGH +
+ (other == null ? "--" : "-"));
+ ChatComponentText discord = new ChatComponentText(
+ EnumChatFormatting.GRAY + "[" + EnumChatFormatting.BLUE + "Discord" + EnumChatFormatting.GRAY + "]");
+ discord.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, discord_link));
+ ChatComponentText youtube = new ChatComponentText(
+ EnumChatFormatting.GRAY + "[" + EnumChatFormatting.RED + "YouTube" + EnumChatFormatting.GRAY + "]");
+ youtube.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, youtube_link));
+ ChatComponentText twitch = new ChatComponentText(
+ EnumChatFormatting.GRAY + "[" + EnumChatFormatting.DARK_PURPLE + "Twitch" + EnumChatFormatting.GRAY + "]");
+ twitch.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, twitch_link));
+ ChatComponentText release = new ChatComponentText(
+ EnumChatFormatting.GRAY + "[" + EnumChatFormatting.GREEN + "Release" + EnumChatFormatting.GRAY + "]");
+ release.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, update_link));
+ ChatComponentText github = new ChatComponentText(
+ EnumChatFormatting.GRAY + "[" + EnumChatFormatting.DARK_PURPLE + "GitHub" + EnumChatFormatting.GRAY + "]");
+ github.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, github_link));
+
+ links.appendSibling(separator);
+ links.appendSibling(discord);
+ links.appendSibling(separator);
+ links.appendSibling(youtube);
+ links.appendSibling(separator);
+ links.appendSibling(twitch);
+ links.appendSibling(separator);
+ links.appendSibling(release);
+ links.appendSibling(separator);
+ links.appendSibling(github);
+ links.appendSibling(separator);
+ if (other != null) {
+ links.appendSibling(other);
+ links.appendSibling(separator);
+ }
+
+ Minecraft.getMinecraft().thePlayer.addChatMessage(links);
+ }
+
+ @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) {
+ if (Minecraft.getMinecraft().thePlayer.openContainer != null) {
+ Minecraft.getMinecraft().thePlayer.closeScreen();
+ }
+ Minecraft.getMinecraft().displayGuiScreen(openGui);
+ openGui = null;
+ lastOpenedGui = System.currentTimeMillis();
+ }
+ if (currChatMessage != null && currentTime - lastChatMessage > CHAT_MSG_COOLDOWN) {
+ lastChatMessage = currentTime;
+ Minecraft.getMinecraft().thePlayer.sendChatMessage(currChatMessage);
+ currChatMessage = null;
+ }
+ }
+
+ public boolean isOnSkyblock() {
+ if (!config.misc.onlyShowOnSkyblock) return true;
+ return hasSkyblockScoreboard();
+ }
+
+ private boolean hasSkyblockScoreboard;
+
+ public boolean hasSkyblockScoreboard() {
+ return hasSkyblockScoreboard;
+ }
+
+ public void updateSkyblockScoreboard() {
+ Minecraft mc = Minecraft.getMinecraft();
+
+ if (mc != null && mc.theWorld != null && mc.thePlayer != null) {
+ if (mc.isSingleplayer() || mc.thePlayer.getClientBrand() == null ||
+ !mc.thePlayer.getClientBrand().toLowerCase().contains("hypixel")) {
+ hasSkyblockScoreboard = false;
+ return;
+ }
+
+ Scoreboard scoreboard = mc.theWorld.getScoreboard();
+ ScoreObjective sidebarObjective = scoreboard.getObjectiveInDisplaySlot(1);
+ if (sidebarObjective != null) {
+ String objectiveName = sidebarObjective.getDisplayName().replaceAll("(?i)\\u00A7.", "");
+ for (String skyblock : SKYBLOCK_IN_ALL_LANGUAGES) {
+ if (objectiveName.startsWith(skyblock)) {
+ hasSkyblockScoreboard = true;
+ return;
+ }
+ }
+ }
+
+ hasSkyblockScoreboard = false;
+ }
+ }
}
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 9351b208..c47e0844 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java
@@ -3,8 +3,12 @@ package io.github.moulberry.notenoughupdates.auction;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
+import io.github.moulberry.notenoughupdates.ItemPriceInformation;
import io.github.moulberry.notenoughupdates.NEUManager;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.miscgui.GuiPriceGraph;
+import io.github.moulberry.notenoughupdates.recipes.Ingredient;
+import io.github.moulberry.notenoughupdates.recipes.NeuRecipe;
import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
@@ -26,885 +30,920 @@ import java.io.IOException;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
public class APIManager {
-
- private NEUManager manager;
- public final CustomAH customAH;
-
- private TreeMap<String, Auction> auctionMap = new TreeMap<>();
- public HashMap<String, HashSet<String>> internalnameToAucIdMap = new HashMap<>();
- private HashSet<String> playerBids = new HashSet<>();
- private HashSet<String> playerBidsNotified = new HashSet<>();
- private HashSet<String> playerBidsFinishedNotified = new HashSet<>();
-
- private JsonObject lowestBins = null;
- private JsonObject auctionPricesAvgLowestBinJson = null;
-
- private LinkedList<Integer> pagesToDownload = null;
-
- private JsonObject bazaarJson = null;
- private JsonObject auctionPricesJson = null;
- private HashMap<String, CraftInfo> craftCost = new HashMap<>();
-
- public TreeMap<String, HashMap<Integer, HashSet<String>>> extrasToAucIdMap = new TreeMap<>();
-
- private long lastAuctionUpdate = 0;
- private long lastShortAuctionUpdate = 0;
- private long lastCustomAHSearch = 0;
- private long lastCleanup = 0;
- private long lastAuctionAvgUpdate = 0;
- private long lastBazaarUpdate = 0;
- private long lastLowestBinUpdate = 0;
-
- private long lastApiUpdate = 0;
- private long firstHypixelApiUpdate = 0;
-
- public int activeAuctions = 0;
- public int uniqueItems = 0;
- public int totalTags = 0;
- public int internalnameTaggedAuctions = 0;
- public int taggedAuctions = 0;
- public int processMillis = 0;
-
- public APIManager(NEUManager manager) {
- this.manager = manager;
- customAH = new CustomAH(manager);
- }
-
- public TreeMap<String, Auction> getAuctionItems() {
- return auctionMap;
- }
-
- public HashSet<String> getPlayerBids() {
- return playerBids;
- }
-
- public HashSet<String> getAuctionsForInternalname(String internalname) {
- return internalnameToAucIdMap.computeIfAbsent(internalname, k -> new HashSet<>());
- }
-
- public class Auction {
- public String auctioneerUuid;
- public long end;
- public int starting_bid;
- public int highest_bid_amount;
- public int bid_count;
- public boolean bin;
- public String category;
- public String rarity;
- public int dungeonTier;
- public String item_tag_str;
- public NBTTagCompound item_tag = null;
- private ItemStack stack;
-
- public int enchLevel = 0; //0 = clean, 1 = ench, 2 = ench/hpb
-
- public Auction(String auctioneerUuid, long end, int starting_bid, int highest_bid_amount, int bid_count,
- boolean bin, String category, String rarity, int dungeonTier, String item_tag_str) {
- this.auctioneerUuid = auctioneerUuid;
- this.end = end;
- this.starting_bid = starting_bid;
- this.highest_bid_amount = highest_bid_amount;
- this.bid_count = bid_count;
- this.bin = bin;
- this.category = category;
- this.dungeonTier = dungeonTier;
- this.rarity = rarity;
- this.item_tag_str = item_tag_str;
- }
-
- public ItemStack getStack() {
- if(item_tag == null && item_tag_str != null) {
- try {
- item_tag = CompressedStreamTools.readCompressed(
- new ByteArrayInputStream(Base64.getDecoder().decode(item_tag_str)));
- item_tag_str = null;
- } catch(IOException e) {
- return null;
- }
- }
- if(stack != null) {
- return stack;
- } else {
- JsonObject item = manager.getJsonFromNBT(item_tag);
- ItemStack stack = manager.jsonToStack(item, false);
-
- JsonObject itemDefault = manager.getItemInformation().get(item.get("internalname").getAsString());
-
- if(stack != null && itemDefault != null) {
- ItemStack stackDefault = manager.jsonToStack(itemDefault, true);
- if(stack.isItemEqual(stackDefault)) {
- //Item types are the same, compare lore
-
- String[] stackLore = manager.getLoreFromNBT(stack.getTagCompound());
- String[] defaultLore = manager.getLoreFromNBT(stackDefault.getTagCompound());
-
- boolean loreMatches = stackLore != null && defaultLore != null && stackLore.length == defaultLore.length;
- if(loreMatches) {
- for(int i=0; i<stackLore.length; i++) {
- if(!stackLore[i].equals(defaultLore[i])) {
- loreMatches = false;
- break;
- }
- }
- }
- if(loreMatches) {
- stack = stackDefault;
- }
- }
- }
- this.stack = stack;
- return stack;
- }
- }
- }
-
- public void markNeedsUpdate() {
- firstHypixelApiUpdate = 0;
- pagesToDownload = null;
-
- auctionMap.clear();
- internalnameToAucIdMap.clear();
- extrasToAucIdMap.clear();
- }
-
- public void tick() {
- customAH.tick();
- long currentTime = System.currentTimeMillis();
- if(NotEnoughUpdates.INSTANCE.config.neuAuctionHouse.enableNeuAuctionHouse &&
- NotEnoughUpdates.INSTANCE.config.apiKey.apiKey != null &&
- !NotEnoughUpdates.INSTANCE.config.apiKey.apiKey.isEmpty()) {
- if(currentTime - lastAuctionUpdate > 60*1000) {
- lastAuctionUpdate = currentTime;
- updatePageTick();
- }
- if(currentTime - lastShortAuctionUpdate > 10*1000) {
- lastShortAuctionUpdate = currentTime;
- updatePageTickShort();
- ahNotification();
- }
- if(currentTime - lastCleanup > 60*1000) {
- lastCleanup = currentTime;
- cleanup();
- }
- if(currentTime - lastCustomAHSearch > 60*1000) {
- lastCustomAHSearch = currentTime;
- if(Minecraft.getMinecraft().currentScreen instanceof CustomAHGui || customAH.isRenderOverAuctionView()) {
- customAH.updateSearch();
- calculateStats();
- }
- }
- }
- if(currentTime - lastAuctionAvgUpdate > 5*60*1000) { //5 minutes
- lastAuctionAvgUpdate = currentTime - 4*60*1000; //Try again in 1 minute if updateAvgPrices doesn't succeed
- updateAvgPrices();
- }
- if(currentTime - lastBazaarUpdate > 5*60*1000) { //5 minutes
- lastBazaarUpdate = currentTime;
- updateBazaar();
- }
- if(currentTime - lastLowestBinUpdate > 2*60*1000) {
- lastLowestBinUpdate = currentTime;
- updateLowestBin();
- }
- }
-
- private String niceAucId(String aucId) {
- if(aucId.length()!=32) return aucId;
-
- StringBuilder niceAucId = new StringBuilder();
- niceAucId.append(aucId, 0, 8);
- niceAucId.append("-");
- niceAucId.append(aucId, 8, 12);
- niceAucId.append("-");
- niceAucId.append(aucId, 12, 16);
- niceAucId.append("-");
- niceAucId.append(aucId, 16, 20);
- niceAucId.append("-");
- niceAucId.append(aucId, 20, 32);
- return niceAucId.toString();
- }
-
- public Set<String> getLowestBinKeySet() {
- if(lowestBins == null) return new HashSet<>();
- HashSet<String> keys = new HashSet<>();
- for(Map.Entry<String, JsonElement> entry : lowestBins.entrySet()) {
- keys.add(entry.getKey());
- }
- return keys;
- }
-
- public int getLowestBin(String internalname) {
- if(lowestBins != null && lowestBins.has(internalname)) {
- JsonElement e = lowestBins.get(internalname);
- if(e.isJsonPrimitive() && e.getAsJsonPrimitive().isNumber()) {
- return e.getAsInt();
- }
- }
- return -1;
- }
-
- public void updateLowestBin() {
- manager.hypixelApi.getMyApiGZIPAsync("lowestbin.json.gz", (jsonObject) -> {
- if(lowestBins == null) {
- lowestBins = new JsonObject();
- }
- for(Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) {
- lowestBins.add(entry.getKey(), entry.getValue());
- }
- }, () -> {});
- }
-
- private void ahNotification() {
- playerBidsNotified.retainAll(playerBids);
- playerBidsFinishedNotified.retainAll(playerBids);
- if(NotEnoughUpdates.INSTANCE.config.neuAuctionHouse.ahNotification <= 0) {
- return;
- }
- for(String aucid : playerBids) {
- Auction auc = auctionMap.get(aucid);
- if(!playerBidsNotified.contains(aucid)) {
- if(auc != null && auc.end - System.currentTimeMillis() < 1000*60*NotEnoughUpdates.INSTANCE.config.neuAuctionHouse.ahNotification) {
- ChatComponentText message = new ChatComponentText(
- EnumChatFormatting.YELLOW+"The " + auc.getStack().getDisplayName() + EnumChatFormatting.YELLOW + " you have bid on is ending soon! Click here to view.");
- ChatStyle clickEvent = new ChatStyle().setChatClickEvent(
- new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/viewauction " + niceAucId(aucid)));
- clickEvent.setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(EnumChatFormatting.YELLOW+"View auction")));
- message.setChatStyle(clickEvent);
- Minecraft.getMinecraft().thePlayer.addChatMessage(message);
-
- playerBidsNotified.add(aucid);
- }
- }
- if(!playerBidsFinishedNotified.contains(aucid)) {
- if(auc != null && auc.end < System.currentTimeMillis()) {
- ChatComponentText message = new ChatComponentText(
- EnumChatFormatting.YELLOW+"The " + auc.getStack().getDisplayName() + EnumChatFormatting.YELLOW + " you have bid on (might) have ended! Click here to view.");
- ChatStyle clickEvent = new ChatStyle().setChatClickEvent(
- new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/viewauction " + niceAucId(aucid)));
- clickEvent.setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(EnumChatFormatting.YELLOW+"View auction")));
- message.setChatStyle(clickEvent);
- Minecraft.getMinecraft().thePlayer.addChatMessage(message);
-
- playerBidsFinishedNotified.add(aucid);
- }
- }
- }
- }
-
- private ExecutorService es = Executors.newSingleThreadExecutor();
- private void cleanup() {
- es.submit(() -> {
- try {
- long currTime = System.currentTimeMillis();
- Set<String> toRemove = new HashSet<>();
- for(Map.Entry<String, Auction> entry : auctionMap.entrySet()) {
- long timeToEnd = entry.getValue().end - currTime;
- if(timeToEnd < -120*1000) { //2 minutes
- toRemove.add(entry.getKey());
- }
- }
- toRemove.removeAll(playerBids);
- remove(toRemove);
- } catch(ConcurrentModificationException e) {
- lastCleanup = System.currentTimeMillis() - 110*1000;
- }
- });
- }
-
- private void remove(Set<String> toRemove) {
- for(String aucid : toRemove) {
- auctionMap.remove(aucid);
- }
- for(HashMap<Integer, HashSet<String>> extrasMap : extrasToAucIdMap.values()) {
- for(HashSet<String> aucids : extrasMap.values()) {
- for(String aucid : toRemove) {
- aucids.remove(aucid);
- }
- }
- }
- for(HashSet<String> aucids : internalnameToAucIdMap.values()) {
- aucids.removeAll(toRemove);
- }
- }
-
- private void updatePageTickShort() {
- if(pagesToDownload == null || pagesToDownload.isEmpty()) return;
-
- if(firstHypixelApiUpdate == 0 || (System.currentTimeMillis() - firstHypixelApiUpdate)%(60*1000) > 15*1000) return;
-
- JsonObject disable = Constants.DISABLE;
- if(disable != null && disable.has("auctions_new") && disable.get("auctions_new").getAsBoolean()) return;
-
- while(!pagesToDownload.isEmpty()) {
- try {
- int page = pagesToDownload.pop();
- getPageFromAPI(page);
- } catch(NoSuchElementException ignored) {} //Weird race condition?
- }
- }
-
- private void updatePageTick() {
- JsonObject disable = Constants.DISABLE;
- if(disable != null && disable.has("auctions_new") && disable.get("auctions_new").getAsBoolean()) return;
-
- if(pagesToDownload == null) {
- getPageFromAPI(0);
- }
-
- Consumer<JsonObject> process = jsonObject -> {
- if(jsonObject.get("success").getAsBoolean()) {
- JsonArray new_auctions = jsonObject.get("new_auctions").getAsJsonArray();
- for(JsonElement auctionElement : new_auctions) {
- JsonObject auction = auctionElement.getAsJsonObject();
- //System.out.println("New auction " + auction);
- processAuction(auction);
- }
- JsonArray new_bids = jsonObject.get("new_bids").getAsJsonArray();
- for(JsonElement newBidElement : new_bids) {
- JsonObject newBid = newBidElement.getAsJsonObject();
- String newBidUUID = newBid.get("uuid").getAsString();
- //System.out.println("new bid" + newBidUUID);
- int newBidAmount = newBid.get("highest_bid_amount").getAsInt();
- int end = newBid.get("end").getAsInt();
- int bid_count = newBid.get("bid_count").getAsInt();
-
- Auction auc = auctionMap.get(newBidUUID);
- if(auc != null) {
- //System.out.println("Setting auction " + newBidUUID + " price to " + newBidAmount);
- auc.highest_bid_amount = newBidAmount;
- auc.end = end;
- auc.bid_count = bid_count;
- }
- }
- Set<String> toRemove = new HashSet<>();
- JsonArray removed_auctions = jsonObject.get("removed_auctions").getAsJsonArray();
- for(JsonElement removedAuctionsElement : removed_auctions) {
- String removed = removedAuctionsElement.getAsString();
- toRemove.add(removed);
- }
- remove(toRemove);
- }
- };
-
- manager.hypixelApi.getMyApiGZIPAsync("auctionLast.json.gz", process, () -> {
- System.out.println("Error downloading auction from Moulberry's jank API. :(");
- });
-
- manager.hypixelApi.getMyApiGZIPAsync("auction.json.gz", jsonObject -> {
- if(jsonObject.get("success").getAsBoolean()) {
- long apiUpdate = (long) jsonObject.get("time").getAsFloat();
- if (lastApiUpdate == apiUpdate) {
- lastAuctionUpdate -= 30 * 1000;
- }
- lastApiUpdate = apiUpdate;
-
- process.accept(jsonObject);
- }
- }, () -> {
- System.out.println("Error downloading auction from Moulberry's jank API. :(");
- });
-
- }
-
- public void calculateStats() {
- try {
- uniqueItems = internalnameToAucIdMap.size();
- Set<String> aucs = new HashSet<>();
- for(HashSet<String> aucids : internalnameToAucIdMap.values()) {
- aucs.addAll(aucids);
- }
- internalnameTaggedAuctions = aucs.size();
- totalTags = extrasToAucIdMap.size();
- aucs = new HashSet<>();
- for(HashMap<Integer, HashSet<String>> extrasMap : extrasToAucIdMap.values()) {
- for(HashSet<String> aucids : extrasMap.values()) {
- aucs.addAll(aucids);
- }
- }
- taggedAuctions = aucs.size();
- } catch(Exception e) {}
- }
-
-// String[] rarityArr = new String[] {
-// "COMMON", "UNCOMMON", "RARE", "EPIC", "LEGENDARY", "MYTHIC", "SPECIAL", "VERY SPECIAL", "SUPREME",
-// };
-
- public int checkItemType(String lore, boolean contains, String... typeMatches) {
- String[] split = lore.split("\n");
- for(int i=split.length-1; i>=0; i--) {
- String line = split[i];
- for(String rarity : Utils.rarityArr) {
- for(int j=0; j<typeMatches.length; j++) {
- if(contains) {
- if(line.trim().contains(rarity + " " + typeMatches[j])) {
- return j;
- } else if(line.trim().contains(rarity + " DUNGEON " + typeMatches[j])) {
- return j;
- }
- } else {
- if(line.trim().endsWith(rarity + " " + typeMatches[j])) {
- return j;
- } else if(line.trim().endsWith(rarity + " DUNGEON " + typeMatches[j])) {
- return j;
- }
- }
- }
- }
- }
- return -1;
- }
-
- private String[] romans = new String[]{"I","II","III","IV","V","VI","VII","VIII","IX","X","XI",
- "XII","XIII","XIV","XV","XVI","XVII","XIX","XX"};
-
-
- String[] categoryItemType = new String[]{"sword","fishingrod","pickaxe","axe",
- "shovel","petitem","travelscroll","reforgestone","bow"};
- String playerUUID = null;
- private void processAuction(JsonObject auction) {
- if(playerUUID == null) playerUUID = Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replaceAll("-","");
-
- String auctionUuid = auction.get("uuid").getAsString();
- String auctioneerUuid = auction.get("auctioneer").getAsString();
- long end = auction.get("end").getAsLong();
- int starting_bid = auction.get("starting_bid").getAsInt();
- int highest_bid_amount = auction.get("highest_bid_amount").getAsInt();
- int bid_count = auction.get("bids").getAsJsonArray().size();
- boolean bin = false;
- if(auction.has("bin")) {
- bin = auction.get("bin").getAsBoolean();
- }
- String sbCategory = auction.get("category").getAsString();
- String extras = auction.get("extra").getAsString().toLowerCase();
- String item_name = auction.get("item_name").getAsString();
- String item_lore = Utils.fixBrokenAPIColour(auction.get("item_lore").getAsString());
- String item_bytes = auction.get("item_bytes").getAsString();
- String rarity = auction.get("tier").getAsString();
- JsonArray bids = auction.get("bids").getAsJsonArray();
-
- try {
- NBTTagCompound item_tag;
- try {
- item_tag = CompressedStreamTools.readCompressed(
- new ByteArrayInputStream(Base64.getDecoder().decode(item_bytes)));
- } catch(IOException e) { return; }
-
- NBTTagCompound tag = item_tag.getTagList("i", 10).getCompoundTagAt(0).getCompoundTag("tag");
- String internalname = manager.getInternalnameFromNBT(tag);
-
- NBTTagCompound display = tag.getCompoundTag("display");
- if(display.hasKey("Lore", 9)) {
- NBTTagList loreList = new NBTTagList();
- for(String line : item_lore.split("\n")) {
- loreList.appendTag(new NBTTagString(line));
- }
- display.setTag("Lore", loreList);
- }
- tag.setTag("display", display);
- item_tag.getTagList("i", 10).getCompoundTagAt(0).setTag("tag", tag);
-
- if(tag.hasKey("ExtraAttributes", 10)) {
- NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
-
- if(ea.hasKey("enchantments", 10)) {
- NBTTagCompound enchantments = ea.getCompoundTag("enchantments");
- for(String key : enchantments.getKeySet()) {
- String enchantname = key.toLowerCase().replace("ultimate_", "").replace("_", " ");
- int enchantlevel = enchantments.getInteger(key);
- String enchantLevelStr;
- if(enchantlevel >= 1 && enchantlevel <= 20) {
- enchantLevelStr = romans[enchantlevel-1];
- } else {
- enchantLevelStr = String.valueOf(enchantlevel);
- }
- extras = extras.replace(enchantname, enchantname + " " + enchantLevelStr);
- }
- }
- }
-
- int index=0;
- for(String str : extras.split(" ")) {
- str = Utils.cleanColour(str).toLowerCase();
- if(str.length() > 0) {
- HashMap<Integer, HashSet<String>> extrasMap = extrasToAucIdMap.computeIfAbsent(str, k -> new HashMap<>());
- HashSet<String> aucids = extrasMap.computeIfAbsent(index, k -> new HashSet<>());
- aucids.add(auctionUuid);
- }
- index++;
- }
-
- for(int j=0; j<bids.size(); j++) {
- JsonObject bid = bids.get(j).getAsJsonObject();
- if(bid.get("bidder").getAsString().equalsIgnoreCase(playerUUID)) {
- playerBids.add(auctionUuid);
- }
- }
-
- int dungeonTier = -1;
- if(checkItemType(item_lore, true, "DUNGEON") >= 0) {
- dungeonTier = 0;
- for(int i=0; i<item_name.length(); i++) {
- char c = item_name.charAt(i);
- if(c == 0x272A) {
- dungeonTier++;
- }
- }
- }
-
- //Categories
- String category = sbCategory;
- int itemType = checkItemType(item_lore, true,"SWORD", "FISHING ROD", "PICKAXE",
- "AXE", "SHOVEL", "PET ITEM", "TRAVEL SCROLL", "REFORGE STONE", "BOW");
- if(itemType >= 0 && itemType < categoryItemType.length) {
- category = categoryItemType[itemType];
- }
- if(category.equals("consumables") && extras.contains("enchanted book")) category = "ebook";
- if(category.equals("consumables") && extras.endsWith("potion")) category = "potion";
- if(category.equals("misc") && extras.contains("rune")) category = "rune";
- if(category.equals("misc") && item_lore.split("\n")[0].endsWith("Furniture")) category = "furniture";
- if(item_lore.split("\n")[0].endsWith("Pet") ||
- item_lore.split("\n")[0].endsWith("Mount")) category = "pet";
-
- Auction auction1 = new Auction(auctioneerUuid, end, starting_bid, highest_bid_amount,
- bid_count, bin, category, rarity, dungeonTier, item_bytes);
-
- if(tag.hasKey("ench")) {
- auction1.enchLevel = 1;
- if(tag.hasKey("ExtraAttributes", 10)) {
- NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
-
- int hotpotatocount = ea.getInteger("hot_potato_count");
- if(hotpotatocount == 10) {
- auction1.enchLevel = 2;
- }
- }
- }
-
- auctionMap.put(auctionUuid, auction1);
- internalnameToAucIdMap.computeIfAbsent(internalname, k -> new HashSet<>()).add(auctionUuid);
- } catch(Exception e) {e.printStackTrace();}
- }
-
- private void getPageFromAPI(int page) {
- //System.out.println("downloading page:"+page);
- //System.out.println("Trying to update page: " + page);
- HashMap<String, String> args = new HashMap<>();
- args.put("page", ""+page);
- manager.hypixelApi.getHypixelApiAsync(null, "skyblock/auctions",
- args, jsonObject -> {
- if(jsonObject == null) return;
-
- if (jsonObject.get("success").getAsBoolean()) {
- if(pagesToDownload == null) {
- int totalPages = jsonObject.get("totalPages").getAsInt();
- pagesToDownload = new LinkedList<>();
- for(int i=0; i<totalPages+2; i++) {
- pagesToDownload.add(i);
- }
- }
- if(firstHypixelApiUpdate == 0) {
- firstHypixelApiUpdate = jsonObject.get("lastUpdated").getAsLong();
- }
- activeAuctions = jsonObject.get("totalAuctions").getAsInt();
-
- long startProcess = System.currentTimeMillis();
- JsonArray auctions = jsonObject.get("auctions").getAsJsonArray();
- for (int i = 0; i < auctions.size(); i++) {
- JsonObject auction = auctions.get(i).getAsJsonObject();
-
- processAuction(auction);
- }
- processMillis = (int)(System.currentTimeMillis() - startProcess);
- } else {
- pagesToDownload.addLast(page);
- }
- }, () -> {
- pagesToDownload.addLast(page);
- }
- );
- }
-
- public void updateBazaar() {
- manager.hypixelApi.getHypixelApiAsync(NotEnoughUpdates.INSTANCE.config.apiKey.apiKey, "skyblock/bazaar", new HashMap<>(), (jsonObject) -> {
- if(!jsonObject.get("success").getAsBoolean()) return;
-
- craftCost.clear();
- bazaarJson = new JsonObject();
- JsonObject products = jsonObject.get("products").getAsJsonObject();
- for(Map.Entry<String, JsonElement> entry : products.entrySet()) {
- if(entry.getValue().isJsonObject()) {
- JsonObject productInfo = new JsonObject();
-
- JsonObject product = entry.getValue().getAsJsonObject();
- JsonObject quickStatus = product.get("quick_status").getAsJsonObject();
- productInfo.addProperty("avg_buy", quickStatus.get("buyPrice").getAsFloat());
- productInfo.addProperty("avg_sell", quickStatus.get("sellPrice").getAsFloat());
-
- for(JsonElement element : product.get("sell_summary").getAsJsonArray()) {
- if(element.isJsonObject()) {
- JsonObject sellSummaryFirst = element.getAsJsonObject();
- productInfo.addProperty("curr_sell", sellSummaryFirst.get("pricePerUnit").getAsFloat());
- break;
- }
- }
-
- for(JsonElement element : product.get("buy_summary").getAsJsonArray()) {
- if(element.isJsonObject()) {
- JsonObject sellSummaryFirst = element.getAsJsonObject();
- productInfo.addProperty("curr_buy", sellSummaryFirst.get("pricePerUnit").getAsFloat());
- break;
- }
- }
-
- bazaarJson.add(entry.getKey().replace(":", "-"), productInfo);
- }
- }
- });
- }
-
- public void updateAvgPrices() {
- manager.hypixelApi.getMyApiGZIPAsync("auction_averages/3day.json.gz", (jsonObject) -> {
- craftCost.clear();
- auctionPricesJson = jsonObject;
- lastAuctionAvgUpdate = System.currentTimeMillis();
- }, () -> {});
- manager.hypixelApi.getMyApiGZIPAsync("auction_averages_lbin/1day.json.gz", (jsonObject) -> {
- auctionPricesAvgLowestBinJson = jsonObject;
- }, () -> {});
- }
-
- public Set<String> getItemAuctionInfoKeySet() {
- if(auctionPricesJson == null) return new HashSet<>();
- HashSet<String> keys = new HashSet<>();
- for(Map.Entry<String, JsonElement> entry : auctionPricesJson.entrySet()) {
- keys.add(entry.getKey());
- }
- return keys;
- }
-
- public JsonObject getItemAuctionInfo(String internalname) {
- if(auctionPricesJson == null) return null;
- JsonElement e = auctionPricesJson.get(internalname);
- if(e == null) {
- return null;
- }
- return e.getAsJsonObject();
- }
-
- public float getItemAvgBin(String internalname) {
- if(auctionPricesAvgLowestBinJson == null) return -1;
- JsonElement e = auctionPricesAvgLowestBinJson.get(internalname);
- if(e == null) {
- return -1;
- }
- return Math.round(e.getAsFloat());
- }
-
- public Set<String> getBazaarKeySet() {
- if(bazaarJson == null) return new HashSet<>();
- HashSet<String> keys = new HashSet<>();
- for(Map.Entry<String, JsonElement> entry : bazaarJson.entrySet()) {
- keys.add(entry.getKey());
- }
- return keys;
- }
-
- public JsonObject getBazaarInfo(String internalname) {
- if(bazaarJson == null) return null;
- JsonElement e = bazaarJson.get(internalname);
- if(e == null) {
- return null;
- }
- return e.getAsJsonObject();
- }
-
- private static final List<String> hardcodedVanillaItems = Utils.createList(
- "WOOD_AXE", "WOOD_HOE", "WOOD_PICKAXE","WOOD_SPADE", "WOOD_SWORD",
- "GOLD_AXE", "GOLD_HOE", "GOLD_PICKAXE", "GOLD_SPADE", "GOLD_SWORD",
- "ROOKIE_HOE"
- );
- public boolean isVanillaItem(String internalname) {
- if(hardcodedVanillaItems.contains(internalname)) return true;
-
- //Removes trailing numbers and underscores, eg. LEAVES_2-3 -> LEAVES
- String vanillaName = internalname.split("-")[0];
- if(manager.getItemInformation().containsKey(vanillaName)) {
- JsonObject json = manager.getItemInformation().get(vanillaName);
- if(json != null && json.has("vanilla") && json.get("vanilla").getAsBoolean()) return true;
- }
- return Item.itemRegistry.getObject(new ResourceLocation(vanillaName)) != null;
- }
-
- public class CraftInfo {
- public boolean fromRecipe = false;
- public boolean vanillaItem = false;
- public float craftCost = -1;
- }
-
- public CraftInfo getCraftCost(String internalname) {
- return getCraftCost(internalname, 0);
- }
-
- /**
- * Recursively calculates the cost of crafting an item from raw materials.
- */
- public CraftInfo getCraftCost(String internalname, int depth) {
- if(craftCost.containsKey(internalname)) {
- return craftCost.get(internalname);
- } else {
- CraftInfo ci = new CraftInfo();
-
- ci.vanillaItem = isVanillaItem(internalname);
-
- JsonObject auctionInfo = getItemAuctionInfo(internalname);
- float lowestBin = getLowestBin(internalname);
- JsonObject bazaarInfo = getBazaarInfo(internalname);
-
- if(bazaarInfo != null && bazaarInfo.get("curr_buy") != null) {
- float bazaarInstantBuyPrice = bazaarInfo.get("curr_buy").getAsFloat();
- 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(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;
- }
- }
-
- if(depth > 16) {
- craftCost.put(internalname, ci);
- return ci;
- }
-
- JsonObject item = manager.getItemInformation().get(internalname);
- if(item != null && item.has("recipe")) {
- float craftPrice = 0;
- JsonObject recipe = item.get("recipe").getAsJsonObject();
-
- String[] x = {"1","2","3"};
- String[] y = {"A","B","C"};
- for(int i=0; i<9; i++) {
- String name = y[i/3]+x[i%3];
- String itemS = recipe.get(name).getAsString();
- if(itemS == null || itemS.length() == 0) continue;
-
- int count = 1;
- if(itemS.split(":").length == 2) {
- count = Integer.parseInt(itemS.split(":")[1]);
- itemS = itemS.split(":")[0];
- }
- if(itemS.equals(internalname)) { //if item is used a crafting component in its own recipe, return
- craftCost.put(internalname, ci);
- return ci;
- }
-
- float compCost = getCraftCost(itemS, depth+1).craftCost * count;
- if(compCost < 0) {
- //If it's a custom item without a cost, return
- if(!getCraftCost(itemS).vanillaItem) {
- craftCost.put(internalname, ci);
- return ci;
- }
- } else {
- craftPrice += compCost;
- }
- }
-
- if(ci.craftCost < 0 || craftPrice < ci.craftCost) {
- ci.craftCost = craftPrice;
- ci.fromRecipe = true;
- }
- }
- craftCost.put(internalname, ci);
- return ci;
- }
- }
-
- /**
- * Calculates the cost of enchants + other price modifiers such as pet xp, midas price, etc.
- */
- public float getCostOfEnchants(String internalname, NBTTagCompound tag) {
- float costOfEnchants = 0;
- if(true) return 0;
-
- JsonObject info = getItemAuctionInfo(internalname);
- if(info == null || !info.has("price")) {
- return 0;
- }
- if(auctionPricesJson == null || !auctionPricesJson.has("ench_prices") || !auctionPricesJson.has("ench_maximums")) {
- return 0;
- }
- JsonObject ench_prices = auctionPricesJson.getAsJsonObject("ench_prices");
- JsonObject ench_maximums = auctionPricesJson.getAsJsonObject("ench_maximums");
- if(!ench_prices.has(internalname) || !ench_maximums.has(internalname)) {
- return 0;
- }
- JsonObject iid_variables = ench_prices.getAsJsonObject(internalname);
- float ench_maximum = ench_maximums.get(internalname).getAsFloat();
-
- int enchants = 0;
- float price = getItemAuctionInfo(internalname).get("price").getAsFloat();
- if(tag.hasKey("ExtraAttributes")) {
- NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
- if(ea.hasKey("enchantments")) {
-
- NBTTagCompound enchs = ea.getCompoundTag("enchantments");
- for(String ench : enchs.getKeySet()) {
- enchants++;
- int level = enchs.getInteger(ench);
-
- for(Map.Entry<String, JsonElement> entry : iid_variables.entrySet()) {
- if(matchEnch(ench, level, entry.getKey())) {
- costOfEnchants += entry.getValue().getAsJsonObject().get("A").getAsFloat()*price +
- entry.getValue().getAsJsonObject().get("B").getAsFloat();
- break;
- }
- }
- }
- }
- }
- return costOfEnchants;
- }
-
- /**
- * Checks whether a certain enchant (ench name + lvl) matches an enchant id
- * eg. PROTECTION_GE6 will match -> ench_name = PROTECTION, lvl >= 6
- */
- private boolean matchEnch(String ench, int level, String id) {
- if(!id.contains(":")) {
- return false;
- }
-
- String idEnch = id.split(":")[0];
- String idLevel = id.split(":")[1];
-
- if(!ench.equalsIgnoreCase(idEnch)) {
- return false;
- }
-
- if(String.valueOf(level).equalsIgnoreCase(idLevel)) {
- return true;
- }
-
- if(idLevel.startsWith("LE")) {
- int idLevelI = Integer.valueOf(idLevel.substring(2));
- return level <= idLevelI;
- } else if(idLevel.startsWith("GE")) {
- int idLevelI = Integer.valueOf(idLevel.substring(2));
- return level >= idLevelI;
- }
-
- return false;
- }
+ private final NEUManager manager;
+ public final CustomAH customAH;
+
+ private final TreeMap<String, Auction> auctionMap = new TreeMap<>();
+ public HashMap<String, HashSet<String>> internalnameToAucIdMap = new HashMap<>();
+ private final HashSet<String> playerBids = new HashSet<>();
+ private final HashSet<String> playerBidsNotified = new HashSet<>();
+ private final HashSet<String> playerBidsFinishedNotified = new HashSet<>();
+
+ private JsonObject lowestBins = null;
+ private JsonObject auctionPricesAvgLowestBinJson = null;
+
+ private LinkedList<Integer> pagesToDownload = null;
+
+ private JsonObject bazaarJson = null;
+ private JsonObject auctionPricesJson = null;
+ private final HashMap<String, CraftInfo> craftCost = new HashMap<>();
+
+ public TreeMap<String, HashMap<Integer, HashSet<String>>> extrasToAucIdMap = new TreeMap<>();
+
+ private boolean didFirstUpdate = false;
+ private long lastAuctionUpdate = 0;
+ private long lastShortAuctionUpdate = 0;
+ private long lastCustomAHSearch = 0;
+ private long lastCleanup = 0;
+ private long lastAuctionAvgUpdate = 0;
+ private long lastBazaarUpdate = 0;
+ private long lastLowestBinUpdate = 0;
+
+ private long lastApiUpdate = 0;
+ private long firstHypixelApiUpdate = 0;
+
+ public int activeAuctions = 0;
+ public int uniqueItems = 0;
+ public int totalTags = 0;
+ public int internalnameTaggedAuctions = 0;
+ public int taggedAuctions = 0;
+ public int processMillis = 0;
+
+ public APIManager(NEUManager manager) {
+ this.manager = manager;
+ customAH = new CustomAH(manager);
+ }
+
+ public TreeMap<String, Auction> getAuctionItems() {
+ return auctionMap;
+ }
+
+ public HashSet<String> getPlayerBids() {
+ return playerBids;
+ }
+
+ public HashSet<String> getAuctionsForInternalname(String internalname) {
+ return internalnameToAucIdMap.computeIfAbsent(internalname, k -> new HashSet<>());
+ }
+
+ public class Auction {
+ public String auctioneerUuid;
+ public long end;
+ public int starting_bid;
+ public int highest_bid_amount;
+ public int bid_count;
+ public boolean bin;
+ public String category;
+ public String rarity;
+ public int dungeonTier;
+ public String item_tag_str;
+ public NBTTagCompound item_tag = null;
+ private ItemStack stack;
+
+ public int enchLevel = 0; //0 = clean, 1 = ench, 2 = ench/hpb
+
+ public Auction(
+ String auctioneerUuid, long end, int starting_bid, int highest_bid_amount, int bid_count,
+ boolean bin, String category, String rarity, int dungeonTier, String item_tag_str
+ ) {
+ this.auctioneerUuid = auctioneerUuid;
+ this.end = end;
+ this.starting_bid = starting_bid;
+ this.highest_bid_amount = highest_bid_amount;
+ this.bid_count = bid_count;
+ this.bin = bin;
+ this.category = category;
+ this.dungeonTier = dungeonTier;
+ this.rarity = rarity;
+ this.item_tag_str = item_tag_str;
+ }
+
+ public ItemStack getStack() {
+ if (item_tag == null && item_tag_str != null) {
+ try {
+ item_tag = CompressedStreamTools.readCompressed(
+ new ByteArrayInputStream(Base64.getDecoder().decode(item_tag_str)));
+ item_tag_str = null;
+ } catch (IOException e) {
+ return null;
+ }
+ }
+ if (stack != null) {
+ return stack;
+ } else {
+ JsonObject item = manager.getJsonFromNBT(item_tag);
+ ItemStack stack = manager.jsonToStack(item, false);
+
+ JsonObject itemDefault = manager.getItemInformation().get(item.get("internalname").getAsString());
+
+ if (stack != null && itemDefault != null) {
+ ItemStack stackDefault = manager.jsonToStack(itemDefault, true);
+ if (stack.isItemEqual(stackDefault)) {
+ //Item types are the same, compare lore
+
+ String[] stackLore = manager.getLoreFromNBT(stack.getTagCompound());
+ String[] defaultLore = manager.getLoreFromNBT(stackDefault.getTagCompound());
+
+ boolean loreMatches = stackLore != null && defaultLore != null && stackLore.length == defaultLore.length;
+ if (loreMatches) {
+ for (int i = 0; i < stackLore.length; i++) {
+ if (!stackLore[i].equals(defaultLore[i])) {
+ loreMatches = false;
+ break;
+ }
+ }
+ }
+ if (loreMatches) {
+ stack = stackDefault;
+ }
+ }
+ }
+ this.stack = stack;
+ return stack;
+ }
+ }
+ }
+
+ public void markNeedsUpdate() {
+ firstHypixelApiUpdate = 0;
+ pagesToDownload = null;
+
+ auctionMap.clear();
+ internalnameToAucIdMap.clear();
+ extrasToAucIdMap.clear();
+ }
+
+ public void tick() {
+ customAH.tick();
+ long currentTime = System.currentTimeMillis();
+ if (NotEnoughUpdates.INSTANCE.config.neuAuctionHouse.enableNeuAuctionHouse &&
+ NotEnoughUpdates.INSTANCE.config.apiKey.apiKey != null &&
+ !NotEnoughUpdates.INSTANCE.config.apiKey.apiKey.isEmpty()) {
+ if (currentTime - lastAuctionUpdate > 60 * 1000) {
+ lastAuctionUpdate = currentTime;
+ updatePageTick();
+ }
+ if (currentTime - lastShortAuctionUpdate > 10 * 1000) {
+ lastShortAuctionUpdate = currentTime;
+ updatePageTickShort();
+ ahNotification();
+ }
+ if (currentTime - lastCleanup > 60 * 1000) {
+ lastCleanup = currentTime;
+ cleanup();
+ }
+ if (currentTime - lastCustomAHSearch > 60 * 1000) {
+ lastCustomAHSearch = currentTime;
+ if (Minecraft.getMinecraft().currentScreen instanceof CustomAHGui || customAH.isRenderOverAuctionView()) {
+ customAH.updateSearch();
+ calculateStats();
+ }
+ }
+ }
+ if (currentTime - lastAuctionAvgUpdate > 5 * 60 * 1000) { //5 minutes
+ lastAuctionAvgUpdate = currentTime - 4 * 60 * 1000; //Try again in 1 minute if updateAvgPrices doesn't succeed
+ updateAvgPrices();
+ }
+ if (currentTime - lastBazaarUpdate > 5 * 60 * 1000) { //5 minutes
+ lastBazaarUpdate = currentTime;
+ updateBazaar();
+ }
+ if (currentTime - lastLowestBinUpdate > 2 * 60 * 1000) {
+ updateLowestBin();
+ }
+ }
+
+ private String niceAucId(String aucId) {
+ if (aucId.length() != 32) return aucId;
+
+ StringBuilder niceAucId = new StringBuilder();
+ niceAucId.append(aucId, 0, 8);
+ niceAucId.append("-");
+ niceAucId.append(aucId, 8, 12);
+ niceAucId.append("-");
+ niceAucId.append(aucId, 12, 16);
+ niceAucId.append("-");
+ niceAucId.append(aucId, 16, 20);
+ niceAucId.append("-");
+ niceAucId.append(aucId, 20, 32);
+ return niceAucId.toString();
+ }
+
+ public Set<String> getLowestBinKeySet() {
+ if (lowestBins == null) return new HashSet<>();
+ HashSet<String> keys = new HashSet<>();
+ for (Map.Entry<String, JsonElement> entry : lowestBins.entrySet()) {
+ keys.add(entry.getKey());
+ }
+ return keys;
+ }
+
+ public int getLowestBin(String internalname) {
+ if (lowestBins != null && lowestBins.has(internalname)) {
+ JsonElement e = lowestBins.get(internalname);
+ if (e.isJsonPrimitive() && e.getAsJsonPrimitive().isNumber()) {
+ return e.getAsInt();
+ }
+ }
+ return -1;
+ }
+
+ public void updateLowestBin() {
+ manager.hypixelApi.getMyApiGZIPAsync("lowestbin.json.gz", (jsonObject) -> {
+ if (lowestBins == null) {
+ lowestBins = new JsonObject();
+ }
+ if (!jsonObject.entrySet().isEmpty()) {
+ lastLowestBinUpdate = System.currentTimeMillis();
+ }
+ for (Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) {
+ lowestBins.add(entry.getKey(), entry.getValue());
+ }
+ if (!didFirstUpdate) {
+ ItemPriceInformation.updateAuctionableItemsList();
+ didFirstUpdate = true;
+ }
+ GuiPriceGraph.addToCache(lowestBins, false);
+ }, () -> {
+ });
+ }
+
+ private void ahNotification() {
+ playerBidsNotified.retainAll(playerBids);
+ playerBidsFinishedNotified.retainAll(playerBids);
+ if (NotEnoughUpdates.INSTANCE.config.neuAuctionHouse.ahNotification <= 0) {
+ return;
+ }
+ for (String aucid : playerBids) {
+ Auction auc = auctionMap.get(aucid);
+ if (!playerBidsNotified.contains(aucid)) {
+ if (auc != null &&
+ auc.end - System.currentTimeMillis() <
+ 1000 * 60 * NotEnoughUpdates.INSTANCE.config.neuAuctionHouse.ahNotification) {
+ ChatComponentText message = new ChatComponentText(
+ EnumChatFormatting.YELLOW +
+ "The " +
+ auc.getStack().getDisplayName() +
+ EnumChatFormatting.YELLOW +
+ " you have bid on is ending soon! Click here to view.");
+ ChatStyle clickEvent = new ChatStyle().setChatClickEvent(
+ new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/viewauction " + niceAucId(aucid)));
+ clickEvent.setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(
+ EnumChatFormatting.YELLOW +
+ "View auction")));
+ message.setChatStyle(clickEvent);
+ Minecraft.getMinecraft().thePlayer.addChatMessage(message);
+
+ playerBidsNotified.add(aucid);
+ }
+ }
+ if (!playerBidsFinishedNotified.contains(aucid)) {
+ if (auc != null && auc.end < System.currentTimeMillis()) {
+ ChatComponentText message = new ChatComponentText(
+ EnumChatFormatting.YELLOW +
+ "The " +
+ auc.getStack().getDisplayName() +
+ EnumChatFormatting.YELLOW +
+ " you have bid on (might) have ended! Click here to view.");
+ ChatStyle clickEvent = new ChatStyle().setChatClickEvent(
+ new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/viewauction " + niceAucId(aucid)));
+ clickEvent.setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(
+ EnumChatFormatting.YELLOW +
+ "View auction")));
+ message.setChatStyle(clickEvent);
+ Minecraft.getMinecraft().thePlayer.addChatMessage(message);
+
+ playerBidsFinishedNotified.add(aucid);
+ }
+ }
+ }
+ }
+
+ public long getLastLowestBinUpdateTime() {
+ return lastLowestBinUpdate;
+ }
+
+ private final ExecutorService es = Executors.newSingleThreadExecutor();
+
+ private void cleanup() {
+ es.submit(() -> {
+ try {
+ long currTime = System.currentTimeMillis();
+ Set<String> toRemove = new HashSet<>();
+ for (Map.Entry<String, Auction> entry : auctionMap.entrySet()) {
+ long timeToEnd = entry.getValue().end - currTime;
+ if (timeToEnd < -120 * 1000) { //2 minutes
+ toRemove.add(entry.getKey());
+ }
+ }
+ toRemove.removeAll(playerBids);
+ remove(toRemove);
+ } catch (ConcurrentModificationException e) {
+ lastCleanup = System.currentTimeMillis() - 110 * 1000;
+ }
+ });
+ }
+
+ private void remove(Set<String> toRemove) {
+ for (String aucid : toRemove) {
+ auctionMap.remove(aucid);
+ }
+ for (HashMap<Integer, HashSet<String>> extrasMap : extrasToAucIdMap.values()) {
+ for (HashSet<String> aucids : extrasMap.values()) {
+ for (String aucid : toRemove) {
+ aucids.remove(aucid);
+ }
+ }
+ }
+ for (HashSet<String> aucids : internalnameToAucIdMap.values()) {
+ aucids.removeAll(toRemove);
+ }
+ }
+
+ private void updatePageTickShort() {
+ if (pagesToDownload == null || pagesToDownload.isEmpty()) return;
+
+ if (firstHypixelApiUpdate == 0 || (System.currentTimeMillis() - firstHypixelApiUpdate) % (60 * 1000) > 15 * 1000)
+ return;
+
+ JsonObject disable = Constants.DISABLE;
+ if (disable != null && disable.has("auctions_new") && disable.get("auctions_new").getAsBoolean()) return;
+
+ while (!pagesToDownload.isEmpty()) {
+ try {
+ int page = pagesToDownload.pop();
+ getPageFromAPI(page);
+ } catch (NoSuchElementException ignored) {
+ } //Weird race condition?
+ }
+ }
+
+ private void updatePageTick() {
+ JsonObject disable = Constants.DISABLE;
+ if (disable != null && disable.has("auctions_new") && disable.get("auctions_new").getAsBoolean()) return;
+
+ if (pagesToDownload == null) {
+ getPageFromAPI(0);
+ }
+
+ Consumer<JsonObject> process = jsonObject -> {
+ if (jsonObject.get("success").getAsBoolean()) {
+ JsonArray new_auctions = jsonObject.get("new_auctions").getAsJsonArray();
+ for (JsonElement auctionElement : new_auctions) {
+ JsonObject auction = auctionElement.getAsJsonObject();
+ //System.out.println("New auction " + auction);
+ processAuction(auction);
+ }
+ JsonArray new_bids = jsonObject.get("new_bids").getAsJsonArray();
+ for (JsonElement newBidElement : new_bids) {
+ JsonObject newBid = newBidElement.getAsJsonObject();
+ String newBidUUID = newBid.get("uuid").getAsString();
+ //System.out.println("new bid" + newBidUUID);
+ int newBidAmount = newBid.get("highest_bid_amount").getAsInt();
+ int end = newBid.get("end").getAsInt();
+ int bid_count = newBid.get("bid_count").getAsInt();
+
+ Auction auc = auctionMap.get(newBidUUID);
+ if (auc != null) {
+ //System.out.println("Setting auction " + newBidUUID + " price to " + newBidAmount);
+ auc.highest_bid_amount = newBidAmount;
+ auc.end = end;
+ auc.bid_count = bid_count;
+ }
+ }
+ Set<String> toRemove = new HashSet<>();
+ JsonArray removed_auctions = jsonObject.get("removed_auctions").getAsJsonArray();
+ for (JsonElement removedAuctionsElement : removed_auctions) {
+ String removed = removedAuctionsElement.getAsString();
+ toRemove.add(removed);
+ }
+ remove(toRemove);
+ }
+ };
+
+ manager.hypixelApi.getMyApiGZIPAsync("auctionLast.json.gz", process, () ->
+ System.out.println("Error downloading auction from Moulberry's jank API. :("));
+
+ manager.hypixelApi.getMyApiGZIPAsync("auction.json.gz", jsonObject -> {
+ if (jsonObject.get("success").getAsBoolean()) {
+ long apiUpdate = (long) jsonObject.get("time").getAsFloat();
+ if (lastApiUpdate == apiUpdate) {
+ lastAuctionUpdate -= 30 * 1000;
+ }
+ lastApiUpdate = apiUpdate;
+
+ process.accept(jsonObject);
+ }
+ }, () -> System.out.println("Error downloading auction from Moulberry's jank API. :("));
+
+ }
+
+ public void calculateStats() {
+ try {
+ uniqueItems = internalnameToAucIdMap.size();
+ Set<String> aucs = new HashSet<>();
+ for (HashSet<String> aucids : internalnameToAucIdMap.values()) {
+ aucs.addAll(aucids);
+ }
+ internalnameTaggedAuctions = aucs.size();
+ totalTags = extrasToAucIdMap.size();
+ aucs = new HashSet<>();
+ for (HashMap<Integer, HashSet<String>> extrasMap : extrasToAucIdMap.values()) {
+ for (HashSet<String> aucids : extrasMap.values()) {
+ aucs.addAll(aucids);
+ }
+ }
+ taggedAuctions = aucs.size();
+ } catch (Exception ignored) {
+ }
+ }
+
+ //String[] rarityArr = new String[] {
+ // "COMMON", "UNCOMMON", "RARE", "EPIC", "LEGENDARY", "MYTHIC", "SPECIAL", "VERY SPECIAL", "SUPREME",
+ //};
+
+ public int checkItemType(String lore, boolean contains, String... typeMatches) {
+ String[] split = lore.split("\n");
+ for (int i = split.length - 1; i >= 0; i--) {
+ String line = split[i];
+ for (String rarity : Utils.rarityArr) {
+ for (int j = 0; j < typeMatches.length; j++) {
+ if (contains) {
+ if (line.trim().contains(rarity + " " + typeMatches[j])) {
+ return j;
+ } else if (line.trim().contains(rarity + " DUNGEON " + typeMatches[j])) {
+ return j;
+ }
+ } else {
+ if (line.trim().endsWith(rarity + " " + typeMatches[j])) {
+ return j;
+ } else if (line.trim().endsWith(rarity + " DUNGEON " + typeMatches[j])) {
+ return j;
+ }
+ }
+ }
+ }
+ }
+ return -1;
+ }
+
+ private final String[] romans = new String[]{
+ "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI",
+ "XII", "XIII", "XIV", "XV", "XVI", "XVII", "XIX", "XX"
+ };
+
+ String[] categoryItemType = new String[]{
+ "sword", "fishingrod", "pickaxe", "axe",
+ "shovel", "petitem", "travelscroll", "reforgestone", "bow"
+ };
+ String playerUUID = null;
+
+ private void processAuction(JsonObject auction) {
+ if (playerUUID == null)
+ playerUUID = Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replaceAll("-", "");
+
+ String auctionUuid = auction.get("uuid").getAsString();
+ String auctioneerUuid = auction.get("auctioneer").getAsString();
+ long end = auction.get("end").getAsLong();
+ int starting_bid = auction.get("starting_bid").getAsInt();
+ int highest_bid_amount = auction.get("highest_bid_amount").getAsInt();
+ int bid_count = auction.get("bids").getAsJsonArray().size();
+ boolean bin = false;
+ if (auction.has("bin")) {
+ bin = auction.get("bin").getAsBoolean();
+ }
+ String sbCategory = auction.get("category").getAsString();
+ String extras = auction.get("extra").getAsString().toLowerCase();
+ String item_name = auction.get("item_name").getAsString();
+ String item_lore = Utils.fixBrokenAPIColour(auction.get("item_lore").getAsString());
+ String item_bytes = auction.get("item_bytes").getAsString();
+ String rarity = auction.get("tier").getAsString();
+ JsonArray bids = auction.get("bids").getAsJsonArray();
+
+ try {
+ NBTTagCompound item_tag;
+ try {
+ item_tag = CompressedStreamTools.readCompressed(
+ new ByteArrayInputStream(Base64.getDecoder().decode(item_bytes)));
+ } catch (IOException e) {
+ return;
+ }
+
+ NBTTagCompound tag = item_tag.getTagList("i", 10).getCompoundTagAt(0).getCompoundTag("tag");
+ String internalname = manager.getInternalnameFromNBT(tag);
+
+ NBTTagCompound display = tag.getCompoundTag("display");
+ if (display.hasKey("Lore", 9)) {
+ NBTTagList loreList = new NBTTagList();
+ for (String line : item_lore.split("\n")) {
+ loreList.appendTag(new NBTTagString(line));
+ }
+ display.setTag("Lore", loreList);
+ }
+ tag.setTag("display", display);
+ item_tag.getTagList("i", 10).getCompoundTagAt(0).setTag("tag", tag);
+
+ if (tag.hasKey("ExtraAttributes", 10)) {
+ NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
+
+ if (ea.hasKey("enchantments", 10)) {
+ NBTTagCompound enchantments = ea.getCompoundTag("enchantments");
+ for (String key : enchantments.getKeySet()) {
+ String enchantname = key.toLowerCase().replace("ultimate_", "").replace("_", " ");
+ int enchantlevel = enchantments.getInteger(key);
+ String enchantLevelStr;
+ if (enchantlevel >= 1 && enchantlevel <= 20) {
+ enchantLevelStr = romans[enchantlevel - 1];
+ } else {
+ enchantLevelStr = String.valueOf(enchantlevel);
+ }
+ extras = extras.replace(enchantname, enchantname + " " + enchantLevelStr);
+ }
+ }
+ }
+
+ int index = 0;
+ for (String str : extras.split(" ")) {
+ str = Utils.cleanColour(str).toLowerCase();
+ if (str.length() > 0) {
+ HashMap<Integer, HashSet<String>> extrasMap = extrasToAucIdMap.computeIfAbsent(str, k -> new HashMap<>());
+ HashSet<String> aucids = extrasMap.computeIfAbsent(index, k -> new HashSet<>());
+ aucids.add(auctionUuid);
+ }
+ index++;
+ }
+
+ for (int j = 0; j < bids.size(); j++) {
+ JsonObject bid = bids.get(j).getAsJsonObject();
+ if (bid.get("bidder").getAsString().equalsIgnoreCase(playerUUID)) {
+ playerBids.add(auctionUuid);
+ }
+ }
+
+ int dungeonTier = -1;
+ if (checkItemType(item_lore, true, "DUNGEON") >= 0) {
+ dungeonTier = 0;
+ for (int i = 0; i < item_name.length(); i++) {
+ char c = item_name.charAt(i);
+ if (c == 0x272A) {
+ dungeonTier++;
+ }
+ }
+ }
+
+ //Categories
+ String category = sbCategory;
+ int itemType = checkItemType(item_lore, true, "SWORD", "FISHING ROD", "PICKAXE",
+ "AXE", "SHOVEL", "PET ITEM", "TRAVEL SCROLL", "REFORGE STONE", "BOW"
+ );
+ if (itemType >= 0 && itemType < categoryItemType.length) {
+ category = categoryItemType[itemType];
+ }
+ if (category.equals("consumables") && extras.contains("enchanted book")) category = "ebook";
+ if (category.equals("consumables") && extras.endsWith("potion")) category = "potion";
+ if (category.equals("misc") && extras.contains("rune")) category = "rune";
+ if (category.equals("misc") && item_lore.split("\n")[0].endsWith("Furniture")) category = "furniture";
+ if (item_lore.split("\n")[0].endsWith("Pet") ||
+ item_lore.split("\n")[0].endsWith("Mount")) category = "pet";
+
+ Auction auction1 = new Auction(auctioneerUuid, end, starting_bid, highest_bid_amount,
+ bid_count, bin, category, rarity, dungeonTier, item_bytes
+ );
+
+ if (tag.hasKey("ench")) {
+ auction1.enchLevel = 1;
+ if (tag.hasKey("ExtraAttributes", 10)) {
+ NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
+
+ int hotpotatocount = ea.getInteger("hot_potato_count");
+ if (hotpotatocount == 10) {
+ auction1.enchLevel = 2;
+ }
+ }
+ }
+
+ auctionMap.put(auctionUuid, auction1);
+ internalnameToAucIdMap.computeIfAbsent(internalname, k -> new HashSet<>()).add(auctionUuid);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void getPageFromAPI(int page) {
+ //System.out.println("downloading page:"+page);
+ //System.out.println("Trying to update page: " + page);
+ HashMap<String, String> args = new HashMap<>();
+ args.put("page", "" + page);
+ manager.hypixelApi.getHypixelApiAsync(null, "skyblock/auctions",
+ args, jsonObject -> {
+ if (jsonObject == null) return;
+
+ if (jsonObject.get("success").getAsBoolean()) {
+ if (pagesToDownload == null) {
+ int totalPages = jsonObject.get("totalPages").getAsInt();
+ pagesToDownload = new LinkedList<>();
+ for (int i = 0; i < totalPages + 2; i++) {
+ pagesToDownload.add(i);
+ }
+ }
+ if (firstHypixelApiUpdate == 0) {
+ firstHypixelApiUpdate = jsonObject.get("lastUpdated").getAsLong();
+ }
+ activeAuctions = jsonObject.get("totalAuctions").getAsInt();
+
+ long startProcess = System.currentTimeMillis();
+ JsonArray auctions = jsonObject.get("auctions").getAsJsonArray();
+ for (int i = 0; i < auctions.size(); i++) {
+ JsonObject auction = auctions.get(i).getAsJsonObject();
+
+ processAuction(auction);
+ }
+ processMillis = (int) (System.currentTimeMillis() - startProcess);
+ } else {
+ pagesToDownload.addLast(page);
+ }
+ }, () -> pagesToDownload.addLast(page)
+ );
+ }
+
+ public void updateBazaar() {
+ manager.hypixelApi.getHypixelApiAsync(
+ NotEnoughUpdates.INSTANCE.config.apiKey.apiKey,
+ "skyblock/bazaar",
+ new HashMap<>(),
+ (jsonObject) -> {
+ if (!jsonObject.get("success").getAsBoolean()) return;
+
+ craftCost.clear();
+ bazaarJson = new JsonObject();
+ JsonObject products = jsonObject.get("products").getAsJsonObject();
+ for (Map.Entry<String, JsonElement> entry : products.entrySet()) {
+ if (entry.getValue().isJsonObject()) {
+ JsonObject productInfo = new JsonObject();
+
+ JsonObject product = entry.getValue().getAsJsonObject();
+ JsonObject quickStatus = product.get("quick_status").getAsJsonObject();
+ productInfo.addProperty("avg_buy", quickStatus.get("buyPrice").getAsFloat());
+ productInfo.addProperty("avg_sell", quickStatus.get("sellPrice").getAsFloat());
+
+ for (JsonElement element : product.get("sell_summary").getAsJsonArray()) {
+ if (element.isJsonObject()) {
+ JsonObject sellSummaryFirst = element.getAsJsonObject();
+ productInfo.addProperty("curr_sell", sellSummaryFirst.get("pricePerUnit").getAsFloat());
+ break;
+ }
+ }
+
+ for (JsonElement element : product.get("buy_summary").getAsJsonArray()) {
+ if (element.isJsonObject()) {
+ JsonObject sellSummaryFirst = element.getAsJsonObject();
+ productInfo.addProperty("curr_buy", sellSummaryFirst.get("pricePerUnit").getAsFloat());
+ break;
+ }
+ }
+
+ bazaarJson.add(entry.getKey().replace(":", "-"), productInfo);
+ }
+ }
+ GuiPriceGraph.addToCache(bazaarJson, true);
+ }
+ );
+ }
+
+ public void updateAvgPrices() {
+ manager.hypixelApi.getMyApiGZIPAsync("auction_averages/3day.json.gz", (jsonObject) -> {
+ craftCost.clear();
+ auctionPricesJson = jsonObject;
+ lastAuctionAvgUpdate = System.currentTimeMillis();
+ }, () -> {
+ });
+ manager.hypixelApi.getMyApiGZIPAsync("auction_averages_lbin/1day.json.gz", (jsonObject) ->
+ auctionPricesAvgLowestBinJson = jsonObject, () -> {
+ });
+ }
+
+ public Set<String> getItemAuctionInfoKeySet() {
+ if (auctionPricesJson == null) return new HashSet<>();
+ HashSet<String> keys = new HashSet<>();
+ for (Map.Entry<String, JsonElement> entry : auctionPricesJson.entrySet()) {
+ keys.add(entry.getKey());
+ }
+ return keys;
+ }
+
+ public JsonObject getItemAuctionInfo(String internalname) {
+ if (auctionPricesJson == null) return null;
+ JsonElement e = auctionPricesJson.get(internalname);
+ if (e == null) {
+ return null;
+ }
+ return e.getAsJsonObject();
+ }
+
+ public float getItemAvgBin(String internalname) {
+ if (auctionPricesAvgLowestBinJson == null) return -1;
+ JsonElement e = auctionPricesAvgLowestBinJson.get(internalname);
+ if (e == null) {
+ return -1;
+ }
+ return Math.round(e.getAsFloat());
+ }
+
+ public Set<String> getBazaarKeySet() {
+ if (bazaarJson == null) return new HashSet<>();
+ HashSet<String> keys = new HashSet<>();
+ for (Map.Entry<String, JsonElement> entry : bazaarJson.entrySet()) {
+ keys.add(entry.getKey());
+ }
+ return keys;
+ }
+
+ public JsonObject getBazaarInfo(String internalname) {
+ if (bazaarJson == null) return null;
+ JsonElement e = bazaarJson.get(internalname);
+ if (e == null) {
+ return null;
+ }
+ return e.getAsJsonObject();
+ }
+
+ private static final List<String> hardcodedVanillaItems = Utils.createList(
+ "WOOD_AXE", "WOOD_HOE", "WOOD_PICKAXE", "WOOD_SPADE", "WOOD_SWORD",
+ "GOLD_AXE", "GOLD_HOE", "GOLD_PICKAXE", "GOLD_SPADE", "GOLD_SWORD",
+ "ROOKIE_HOE"
+ );
+
+ public boolean isVanillaItem(String internalname) {
+ if (hardcodedVanillaItems.contains(internalname)) return true;
+
+ //Removes trailing numbers and underscores, eg. LEAVES_2-3 -> LEAVES
+ String vanillaName = internalname.split("-")[0];
+ if (manager.getItemInformation().containsKey(vanillaName)) {
+ JsonObject json = manager.getItemInformation().get(vanillaName);
+ if (json != null && json.has("vanilla") && json.get("vanilla").getAsBoolean()) return true;
+ }
+ return Item.itemRegistry.getObject(new ResourceLocation(vanillaName)) != null;
+ }
+
+ public static class CraftInfo {
+ public boolean fromRecipe = false;
+ public boolean vanillaItem = false;
+ public float craftCost = -1;
+ }
+
+ public CraftInfo getCraftCost(String internalname) {
+ return getCraftCost(internalname, new HashSet<>());
+ }
+
+ /**
+ * Recursively calculates the cost of crafting an item from raw materials.
+ */
+ private CraftInfo getCraftCost(String internalname, Set<String> visited) {
+ if (craftCost.containsKey(internalname)) return craftCost.get(internalname);
+ if (visited.contains(internalname)) return null;
+ visited.add(internalname);
+
+ boolean vanillaItem = isVanillaItem(internalname);
+ float craftCost = Float.POSITIVE_INFINITY;
+
+ JsonObject auctionInfo = getItemAuctionInfo(internalname);
+ float lowestBin = getLowestBin(internalname);
+ JsonObject bazaarInfo = getBazaarInfo(internalname);
+
+ if (bazaarInfo != null && bazaarInfo.get("curr_buy") != null) {
+ craftCost = bazaarInfo.get("curr_buy").getAsFloat();
+ }
+ //Don't use auction prices for vanilla items cuz people like to transfer money, messing up the cost of vanilla items.
+ if (!vanillaItem) {
+ if (lowestBin > 0) {
+ craftCost = Math.min(lowestBin, craftCost);
+ } else if (auctionInfo != null) {
+ float auctionPrice = auctionInfo.get("price").getAsFloat() / auctionInfo.get("count").getAsInt();
+ craftCost = Math.min(auctionPrice, craftCost);
+ }
+ }
+
+ Set<NeuRecipe> recipes = manager.getRecipesFor(internalname);
+ boolean fromRecipe = false;
+ if (recipes != null)
+ RECIPE_ITER:
+ for (NeuRecipe recipe : recipes) {
+ if (recipe.hasVariableCost() || !recipe.shouldUseForCraftCost()) continue;
+ float craftPrice = 0;
+ for (Ingredient i : recipe.getIngredients()) {
+ if (i.isCoins()) {
+ craftPrice += i.getCount();
+ continue;
+ }
+ CraftInfo ingredientCraftCost = getCraftCost(i.getInternalItemId(), visited);
+ if (ingredientCraftCost == null)
+ continue RECIPE_ITER; // Skip recipes with items further up the chain
+ craftPrice += ingredientCraftCost.craftCost * i.getCount();
+ }
+ int resultCount = 0;
+ for (Ingredient item : recipe.getOutputs())
+ if (item.getInternalItemId().equals(internalname))
+ resultCount += item.getCount();
+
+ if (resultCount == 0)
+ continue;
+ float craftPricePer = craftPrice / resultCount;
+ if (craftPricePer < craftCost) {
+ fromRecipe = true;
+ craftCost = craftPricePer;
+ }
+ }
+ visited.remove(internalname);
+ if (Float.isInfinite(craftCost)) {
+ return null;
+ }
+ CraftInfo craftInfo = new CraftInfo();
+ craftInfo.vanillaItem = vanillaItem;
+ craftInfo.craftCost = craftCost;
+ craftInfo.fromRecipe = fromRecipe;
+ this.craftCost.put(internalname, craftInfo);
+ return craftInfo;
+ }
+
+ /**
+ * Calculates the cost of enchants + other price modifiers such as pet xp, midas price, etc.
+ */
+ public float getCostOfEnchants(String internalname, NBTTagCompound tag) {
+ float costOfEnchants = 0;
+ if (true) return 0;
+
+ JsonObject info = getItemAuctionInfo(internalname);
+ if (info == null || !info.has("price")) {
+ return 0;
+ }
+ if (auctionPricesJson == null || !auctionPricesJson.has("ench_prices") || !auctionPricesJson.has("ench_maximums")) {
+ return 0;
+ }
+ JsonObject ench_prices = auctionPricesJson.getAsJsonObject("ench_prices");
+ JsonObject ench_maximums = auctionPricesJson.getAsJsonObject("ench_maximums");
+ if (!ench_prices.has(internalname) || !ench_maximums.has(internalname)) {
+ return 0;
+ }
+ JsonObject iid_variables = ench_prices.getAsJsonObject(internalname);
+ float ench_maximum = ench_maximums.get(internalname).getAsFloat();
+
+ int enchants = 0;
+ float price = getItemAuctionInfo(internalname).get("price").getAsFloat();
+ if (tag.hasKey("ExtraAttributes")) {
+ NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
+ if (ea.hasKey("enchantments")) {
+
+ NBTTagCompound enchs = ea.getCompoundTag("enchantments");
+ for (String ench : enchs.getKeySet()) {
+ enchants++;
+ int level = enchs.getInteger(ench);
+
+ for (Map.Entry<String, JsonElement> entry : iid_variables.entrySet()) {
+ if (matchEnch(ench, level, entry.getKey())) {
+ costOfEnchants += entry.getValue().getAsJsonObject().get("A").getAsFloat() * price +
+ entry.getValue().getAsJsonObject().get("B").getAsFloat();
+ break;
+ }
+ }
+ }
+ }
+ }
+ return costOfEnchants;
+ }
+
+ /**
+ * Checks whether a certain enchant (ench name + lvl) matches an enchant id
+ * eg. PROTECTION_GE6 will match -> ench_name = PROTECTION, lvl >= 6
+ */
+ private boolean matchEnch(String ench, int level, String id) {
+ if (!id.contains(":")) {
+ return false;
+ }
+
+ String idEnch = id.split(":")[0];
+ String idLevel = id.split(":")[1];
+
+ if (!ench.equalsIgnoreCase(idEnch)) {
+ return false;
+ }
+
+ if (String.valueOf(level).equalsIgnoreCase(idLevel)) {
+ return true;
+ }
+
+ if (idLevel.startsWith("LE")) {
+ int idLevelI = Integer.parseInt(idLevel.substring(2));
+ return level <= idLevelI;
+ } else if (idLevel.startsWith("GE")) {
+ int idLevelI = Integer.parseInt(idLevel.substring(2));
+ return level >= idLevelI;
+ }
+
+ return false;
+ }
/*ScheduledExecutorService auctionUpdateSES = Executors.newSingleThreadScheduledExecutor();
private AtomicInteger auctionUpdateId = new AtomicInteger(0);
@@ -989,5 +1028,4 @@ public class APIManager {
}
}, 3000L, TimeUnit.MILLISECONDS);
}*/
-
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java b/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java
index 25d4d03b..123da60a 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java
@@ -35,8 +35,8 @@ import org.lwjgl.opengl.GL14;
import java.awt.*;
import java.awt.datatransfer.StringSelection;
import java.text.NumberFormat;
-import java.util.*;
import java.util.List;
+import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.regex.Matcher;
@@ -45,861 +45,921 @@ import java.util.regex.Pattern;
import static io.github.moulberry.notenoughupdates.util.GuiTextures.*;
public class CustomAH extends Gui {
-
- private enum PriceFilter {
- Greater,
- Less,
- Equal
- }
-
- private static final ResourceLocation creativeTabSearch =
- new ResourceLocation("textures/gui/container/creative_inventory/tab_item_search.png");
- private static final ResourceLocation creativeInventoryTabs =
- new ResourceLocation("textures/gui/container/creative_inventory/tabs.png");
-
- private HashSet<String> auctionIds = new HashSet<>();
- private List<String> sortedAuctionIds = new ArrayList<>();
-
- private boolean scrollClicked = false;
-
- private long lastUpdateSearch;
- private long lastSearchFieldUpdate;
- private boolean shouldUpdateSearch = false;
- private boolean shouldSortItems = false;
-
- private int startingBid = 0;
- private String currentAucId = null;
-
- private int clickedMainCategory = -1;
- private int clickedSubCategory = -1;
-
- private GuiTextField searchField = null;
- private GuiTextField priceField = null;
- private GuiTextField priceFilterField = null;
- private GuiTextField binPriceFilterField = null;
-
- private final int binPriceFilterYOffset = 86;
-
- private boolean renderOverAuctionView = false;
- private long lastRenderDisable = 0;
-
- private long currAucIdSetTimer = 0;
- private long resetCurrAucIdTimer = 0;
-
- private int eventButton;
- private long lastMouseEvent;
- public long lastOpen;
- public long lastGuiScreenSwitch;
- private PriceFilter currentPriceFilterType = PriceFilter.Greater;
- private PriceFilter currentBinPriceFilterType = PriceFilter.Greater;
-
- private final int splits = 2;
-
- public String latestBid;
- public long latestBidMillis;
-
- private final int ySplit = 35;
- private final int ySplitSize = 18;
-
- private float scrollAmount;
-
- public int guiLeft = -1;
- public int guiTop = -1;
-
- private Category CATEGORY_SWORD = new Category("sword", "Swords", "diamond_sword");
- private Category CATEGORY_ARMOR = new Category("armor", "Armor", "diamond_chestplate");
- private Category CATEGORY_BOWS = new Category("bow", "Bows", "bow");
- private Category CATEGORY_ACCESSORIES = new Category("accessories", "Accessories", "diamond");
-
- private Category CATEGORY_FISHING_ROD = new Category("fishingrod", "Fishing Rods", "fishing_rod");
- private Category CATEGORY_PICKAXE = new Category("pickaxe", "Pickaxes", "iron_pickaxe");
- private Category CATEGORY_AXE = new Category("axe", "Axes", "iron_axe");
- private Category CATEGORY_SHOVEL = new Category("shovel", "Shovels", "iron_shovel");
-
- private Category CATEGORY_PET_ITEM = new Category("petitem", "Pet Items", "lead");
-
- private Category CATEGORY_EBOOKS = new Category("ebook", "Enchanted Books", "enchanted_book");
- private Category CATEGORY_POTIONS = new Category("potion", "Potions", "potion");
- private Category CATEGORY_TRAVEL_SCROLLS = new Category("travelscroll", "Travel Scrolls", "map");
-
- private Category CATEGORY_REFORGE_STONES = new Category("reforgestone", "Reforge Stones", "anvil");
- private Category CATEGORY_RUNES = new Category("rune", "Runes", "magma_cream");
- private Category CATEGORY_FURNITURE = new Category("furniture", "Furniture", "armor_stand");
-
- private Category CATEGORY_COMBAT = new Category("weapon", "Combat", "golden_sword", CATEGORY_SWORD,
- CATEGORY_BOWS, CATEGORY_ARMOR, CATEGORY_ACCESSORIES);
- private Category CATEGORY_TOOL = new Category("", "Tools", "diamond_pickaxe", CATEGORY_FISHING_ROD, CATEGORY_PICKAXE,
- CATEGORY_AXE, CATEGORY_SHOVEL);
- private Category CATEGORY_PET = new Category("pet", "Pets", "bone", CATEGORY_PET_ITEM);
- private Category CATEGORY_CONSUMABLES = new Category("consumables", "Consumables", "apple", CATEGORY_EBOOKS, CATEGORY_POTIONS,
- CATEGORY_TRAVEL_SCROLLS);
- private Category CATEGORY_BLOCKS = new Category("blocks", "Blocks", "cobblestone");
- private Category CATEGORY_MISC = new Category("misc", "Misc", "stick", CATEGORY_REFORGE_STONES, CATEGORY_RUNES,
- CATEGORY_FURNITURE);
-
- private Category[] mainCategories = new Category[]{CATEGORY_COMBAT, CATEGORY_TOOL, CATEGORY_PET,
- CATEGORY_CONSUMABLES, CATEGORY_BLOCKS, CATEGORY_MISC};
-
- private static final int SORT_MODE_HIGH = 0;
- private static final int SORT_MODE_LOW = 1;
- private static final int SORT_MODE_SOON = 2;
-
-// private static final String[] rarities = {"COMMON", "UNCOMMON", "RARE", "EPIC",
-// "LEGENDARY", "MYTHIC", "SPECIAL", "VERY SPECIAL", "SUPREME"};
- private static final String[] rarityColours = {"" + EnumChatFormatting.WHITE,
- "" + EnumChatFormatting.GREEN, "" + EnumChatFormatting.BLUE, "" + EnumChatFormatting.DARK_PURPLE,
- "" + EnumChatFormatting.GOLD, "" + EnumChatFormatting.LIGHT_PURPLE, "" + EnumChatFormatting.RED,
- "" + EnumChatFormatting.RED, "" + EnumChatFormatting.DARK_RED};
-
- private static final int BIN_FILTER_ALL = 0;
- private static final int BIN_FILTER_BIN = 1;
- private static final int BIN_FILTER_AUC = 2;
-
- private static final int ENCH_FILTER_ALL = 0;
- private static final int ENCH_FILTER_CLEAN = 1;
- private static final int ENCH_FILTER_ENCH = 2;
- private static final int ENCH_FILTER_ENCHHPB = 3;
-
- private static final int DUNGEON_FILTER_ALL = 0;
- private static final int DUNGEON_FILTER_DUNGEON = 1;
- private static final int DUNGEON_FILTER_1 = 2;
- private static final int DUNGEON_FILTER_2 = 3;
- private static final int DUNGEON_FILTER_3 = 4;
- private static final int DUNGEON_FILTER_4 = 5;
- private static final int DUNGEON_FILTER_5 = 6;
-
- private int dungeonFilter = DUNGEON_FILTER_ALL;
- private int sortMode = SORT_MODE_HIGH;
- private int rarityFilter = -1;
- private boolean filterMyAuctions = false;
- private int binFilter = BIN_FILTER_ALL;
- private int enchFilter = ENCH_FILTER_ALL;
-
- private static ItemStack DUNGEON_SORT = Utils.createItemStack(Item.getItemFromBlock(Blocks.deadbush),
- EnumChatFormatting.GREEN + "Dungeon Sorting");
- private static ItemStack CONTROL_SORT = Utils.createItemStack(Item.getItemFromBlock(Blocks.hopper),
- EnumChatFormatting.GREEN + "Sort");
- private static ItemStack CONTROL_TIER = Utils.createItemStack(Items.ender_eye,
- EnumChatFormatting.GREEN + "Item Tier");
- private static ItemStack CONTROL_MYAUC = Utils.createItemStack(Items.gold_ingot,
- EnumChatFormatting.GREEN + "My Auctions");
- private static ItemStack CONTROL_BIN = Utils.createItemStack(Item.getItemFromBlock(Blocks.golden_rail),
- EnumChatFormatting.GREEN + "BIN Filter");
- private static ItemStack CONTROL_ENCH = Utils.createItemStack(Items.enchanted_book,
- EnumChatFormatting.GREEN + "Enchant Filter");
- private static ItemStack CONTROL_STATS = Utils.createItemStack(Item.getItemFromBlock(Blocks.command_block),
- EnumChatFormatting.GREEN + "Stats for nerds");
- private ItemStack[] controls = {DUNGEON_SORT, CONTROL_SORT, CONTROL_TIER, null, CONTROL_MYAUC, null, CONTROL_BIN, CONTROL_ENCH, CONTROL_STATS};
-
- private NEUManager manager;
-
- public CustomAH(NEUManager manager) {
- this.manager = manager;
- }
-
- public void clearSearch() {
- if (searchField == null || priceField == null) init();
- if (System.currentTimeMillis() - lastOpen < 1000) Mouse.setGrabbed(false);
-
- //sortMode = SORT_MODE_HIGH;
- rarityFilter = -1;
- filterMyAuctions = false;
- //binFilter = BIN_FILTER_ALL;
- enchFilter = ENCH_FILTER_ALL;
- dungeonFilter = DUNGEON_FILTER_ALL;
-
- searchField.setText("");
- searchField.setFocused(true);
- priceField.setText("");
- }
-
- public void setSearch(String search) {
- searchField.setText(search);
- updateSearch();
- }
-
- public void tick() {
- if (!NotEnoughUpdates.INSTANCE.config.neuAuctionHouse.enableNeuAuctionHouse) return;
- if (Minecraft.getMinecraft().currentScreen instanceof CustomAHGui || renderOverAuctionView) {
- if (shouldUpdateSearch) updateSearch();
- if (shouldSortItems) {
- sortItems();
- shouldSortItems = false;
- }
- }
- }
-
- public class Category {
- public String categoryMatch;
- public Category[] subcategories;
- public String displayName;
- public ItemStack displayItem;
-
- public Category(String categoryMatch, String displayName, String displayItem, Category... subcategories) {
- this.categoryMatch = categoryMatch;
- this.subcategories = subcategories;
- this.displayName = displayName;
- this.displayItem = new ItemStack(Item.getByNameOrId(displayItem));
- }
-
- public String[] getTotalCategories() {
- String[] categories = new String[1 + subcategories.length];
- categories[0] = categoryMatch;
-
- for (int i = 0; i < subcategories.length; i++) {
- categories[i + 1] = subcategories[i].categoryMatch;
- }
- return categories;
- }
- }
-
- private void init() {
- FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
- this.searchField = new GuiTextField(0, fr, this.guiLeft + 82, this.guiTop + 6,
- 84, fr.FONT_HEIGHT);
- this.priceField = new GuiTextField(1, fr, this.guiLeft + 82, this.guiTop + 6,
- 84, fr.FONT_HEIGHT);
- this.priceFilterField = new GuiTextField(2, fr, this.guiLeft + 82, this.guiTop + 6,
- 84, fr.FONT_HEIGHT);
- this.binPriceFilterField = new GuiTextField(3, fr, this.guiLeft + 82, this.guiTop - 6, 84, fr.FONT_HEIGHT);
-
- this.searchField.setMaxStringLength(30);
- this.searchField.setEnableBackgroundDrawing(false);
- this.searchField.setTextColor(16777215);
- this.searchField.setVisible(true);
- this.searchField.setCanLoseFocus(true);
- this.searchField.setFocused(true);
- this.searchField.setText("");
-
- this.priceField.setMaxStringLength(10);
- this.priceField.setEnableBackgroundDrawing(false);
- this.priceField.setTextColor(16777215);
- this.priceField.setVisible(true);
- this.priceField.setCanLoseFocus(true);
- this.priceField.setFocused(false);
- this.priceField.setText("");
-
- this.priceFilterField.setMaxStringLength(10);
- this.priceFilterField.setEnableBackgroundDrawing(false);
- this.priceFilterField.setTextColor(16777215);
- this.priceFilterField.setVisible(true);
- this.priceFilterField.setCanLoseFocus(true);
- this.priceFilterField.setFocused(false);
- this.priceFilterField.setText("");
-
- this.binPriceFilterField.setMaxStringLength(10);
- this.binPriceFilterField.setEnableBackgroundDrawing(false);
- this.binPriceFilterField.setTextColor(16777215);
- this.binPriceFilterField.setVisible(true);
- this.binPriceFilterField.setCanLoseFocus(true);
- this.binPriceFilterField.setFocused(false);
- this.binPriceFilterField.setText("");
- }
-
- public boolean isRenderOverAuctionView() {
- return renderOverAuctionView || (System.currentTimeMillis() - lastRenderDisable) < 500;
- }
-
- public void setRenderOverAuctionView(boolean renderOverAuctionView) {
- if (this.renderOverAuctionView && !renderOverAuctionView) lastRenderDisable = System.currentTimeMillis();
- this.renderOverAuctionView = renderOverAuctionView;
- }
-
- public int getXSize() {
- return 195;
- }
-
- public int getYSize() {
- return 136 + ySplitSize * splits;
- }
-
- private String prettyTime(long millis) {
- long seconds = millis / 1000 % 60;
- long minutes = (millis / 1000 / 60) % 60;
- long hours = (millis / 1000 / 60 / 60) % 24;
- long days = (millis / 1000 / 60 / 60 / 24);
-
- String endsIn = "";
- if (millis < 0) {
- endsIn += "Ended!";
- } else if (minutes == 0 && hours == 0 && days == 0) {
- endsIn += seconds + "s";
- } else if (hours == 0 && days == 0) {
- endsIn += minutes + "m" + seconds + "s";
- } else if (days == 0) {
- if (hours <= 6) {
- endsIn += hours + "h" + minutes + "m" + seconds + "s";
- } else {
- endsIn += hours + "h";
- }
- } else {
- endsIn += days + "d" + hours + "h";
- }
-
- return endsIn;
- }
-
- public List<String> getTooltipForAucId(String aucId) {
- APIManager.Auction auc = manager.auctionManager.getAuctionItems().get(aucId);
-
- List<String> tooltip = new ArrayList<>();
-
- for (String line : auc.getStack().getTooltip(Minecraft.getMinecraft().thePlayer, false)) {
- tooltip.add(EnumChatFormatting.GRAY + line);
- }
-
- long timeUntilEnd = auc.end - System.currentTimeMillis();
- String endsIn = EnumChatFormatting.YELLOW + prettyTime(timeUntilEnd);
-
- NumberFormat format = NumberFormat.getInstance(Locale.US);
-
- tooltip.add(EnumChatFormatting.DARK_GRAY + "" + EnumChatFormatting.STRIKETHROUGH + "-----------------");
- tooltip.add(EnumChatFormatting.GRAY + "Seller: [CLICK TO SEE]");
-
- if (auc.bin) {
- tooltip.add(EnumChatFormatting.GRAY + "Buy it now: " +
- EnumChatFormatting.GOLD + format.format(auc.starting_bid));
- } else {
- if (auc.bid_count > 0) {
- tooltip.add(EnumChatFormatting.GRAY + "Bids: " + EnumChatFormatting.GREEN + auc.bid_count + " bids");
- tooltip.add("");
- tooltip.add(EnumChatFormatting.GRAY + "Top bid: " +
- EnumChatFormatting.GOLD + format.format(auc.highest_bid_amount));
- tooltip.add(EnumChatFormatting.GRAY + "Bidder: [CLICK TO SEE]");
- } else {
- tooltip.add(EnumChatFormatting.GRAY + "Starting bid: " +
- EnumChatFormatting.GOLD + format.format(auc.starting_bid));
- }
- }
-
- if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.showPriceInfoAucItem) {
- String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(auc.getStack());
- if (internalname != null) {
- if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && !Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
- tooltip.add("");
- tooltip.add(EnumChatFormatting.GRAY + "[SHIFT for Price Info]");
- } else {
- ItemPriceInformation.addToTooltip(tooltip, internalname, auc.getStack());
- }
- }
- }
-
- tooltip.add("");
- tooltip.add(EnumChatFormatting.GRAY + "Ends in: " + endsIn);
- tooltip.add("");
- tooltip.add(EnumChatFormatting.YELLOW + "Click to inspect!");
-
- return tooltip;
- }
-
- public boolean isEditingPrice() {
- return Minecraft.getMinecraft().currentScreen instanceof GuiEditSign;
- }
-
- private boolean isGuiFiller(ItemStack stack) {
- return stack == null || !stack.hasTagCompound() || !stack.getTagCompound().hasKey("AttributeModifiers");
- }
-
- private void drawCategorySide(int i) {
- boolean clicked = i == clickedSubCategory;
-
- int x = guiLeft - 28;
- int y = guiTop + 17 + 28 * (i + 1);
- float uMin = 28 / 256f;
- float uMax = 56 / 256f;
- float vMin = 0 + (clicked ? 32 / 256f : 0);
- float vMax = 32 / 256f + (clicked ? 32 / 256f : 0);
- float catWidth = 32;
- float catHeight = 28;
-
- GlStateManager.enableTexture2D();
- GlStateManager.enableBlend();
- GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
-
- GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
- GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
-
- Tessellator tessellator = Tessellator.getInstance();
- WorldRenderer worldrenderer = tessellator.getWorldRenderer();
- worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
- worldrenderer
- .pos(x, y + catHeight, 0.0D)
- .tex(uMax, vMin).endVertex();
- worldrenderer
- .pos(x + catWidth, y + catHeight, 0.0D)
- .tex(uMax, vMax).endVertex();
- worldrenderer
- .pos(x + catWidth, y, 0.0D)
- .tex(uMin, vMax).endVertex();
- worldrenderer
- .pos(x, y, 0.0D)
- .tex(uMin, vMin).endVertex();
- tessellator.draw();
-
- GlStateManager.disableBlend();
- }
-
- private HashMap<Pattern, Long> timeParseMap = new HashMap<>();
-
- public long prettyTimeToMillis(String endsInStr) {
- if (timeParseMap.isEmpty()) {
- Pattern dayPattern = Pattern.compile("([0-9]+)d");
- Pattern hourPattern = Pattern.compile("([0-9]+)h");
- Pattern minutePattern = Pattern.compile("([0-9]+)m");
- Pattern secondPattern = Pattern.compile("([0-9]+)s");
-
- timeParseMap.put(dayPattern, 24 * 60 * 60 * 1000L);
- timeParseMap.put(hourPattern, 60 * 60 * 1000L);
- timeParseMap.put(minutePattern, 60 * 1000L);
- timeParseMap.put(secondPattern, 1000L);
- }
-
- if (endsInStr != null) {
- long timeUntilEnd = 0;
-
- String timeStr = Utils.cleanColour(endsInStr);
-
- for (Map.Entry<Pattern, Long> timeEntry : timeParseMap.entrySet()) {
- Matcher matcher = timeEntry.getKey().matcher(timeStr);
- if (matcher.find()) {
- String days = matcher.group(1);
- timeUntilEnd += Long.parseLong(days) * timeEntry.getValue();
- }
- }
-
- return timeUntilEnd;
- }
-
- return -1;
- }
-
- public String findStrStart(ItemStack stack, String toFind) {
- if (stack.hasTagCompound()) {
- //§7Ends in:
- for (String line : manager.getLoreFromNBT(stack.getTagCompound())) {
- if (line.trim().startsWith(toFind)) {
- return line.substring(toFind.length());
- }
- }
- }
-
- return null;
- }
-
- public String findEndsInStr(ItemStack stack) {
- return findStrStart(stack, EnumChatFormatting.GRAY + "Ends in: ");
- }
-
- public void drawScreen(int mouseX, int mouseY) {
- if (System.currentTimeMillis() - lastOpen < 1000) Mouse.setGrabbed(false);
-
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- int width = scaledResolution.getScaledWidth();
- int height = scaledResolution.getScaledHeight();
-
- boolean hasPopup = false;
-
- if (searchField == null || priceField == null || priceFilterField == null) init();
-
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
-
- guiLeft = (width - getXSize()) / 2;
- guiTop = (height - getYSize()) / 2;
- this.searchField.xPosition = guiLeft + 82;
- this.searchField.yPosition = guiTop + 6;
-
- if (!isEditingPrice()) priceField.setText("IAUSHDIUAH");
-
- if ((Minecraft.getMinecraft().currentScreen instanceof GuiChest ||
- Minecraft.getMinecraft().currentScreen instanceof GuiEditSign) && currentAucId == null) {
- Minecraft.getMinecraft().displayGuiScreen(null);
- }
-
- List<String> tooltipToRender = null;
- if (Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
- resetCurrAucIdTimer = System.currentTimeMillis();
- GuiChest auctionView = (GuiChest) Minecraft.getMinecraft().currentScreen;
- ContainerChest container = (ContainerChest) auctionView.inventorySlots;
- String containerName = container.getLowerChestInventory().getDisplayName().getUnformattedText();
-
- float slideAmount = 1 - Math.max(0, Math.min(1, (System.currentTimeMillis() - lastGuiScreenSwitch) / 200f));
- int auctionViewLeft = guiLeft + getXSize() + 4 - (int) (slideAmount * (78 + 4));
- if (containerName.trim().equals("Auction View") || containerName.trim().equals("BIN Auction View")) {
- hasPopup = true;
- Minecraft.getMinecraft().getTextureManager().bindTexture(auction_view);
- this.drawTexturedModalRect(auctionViewLeft, guiTop, 0, 0, 78, 172);
-
- if (auctionViewLeft + 31 > guiLeft + getXSize()) {
- try {
- ItemStack topStack = auctionView.inventorySlots.getSlot(13).getStack();
- ItemStack leftStack = auctionView.inventorySlots.getSlot(29).getStack();
- ItemStack middleStack = auctionView.inventorySlots.getSlot(31).getStack();
- ItemStack rightStack = auctionView.inventorySlots.getSlot(33).getStack();
-
- boolean isBin = isGuiFiller(leftStack) || isGuiFiller(leftStack);
-
- if (isBin) {
- leftStack = middleStack;
- middleStack = null;
- }
-
- String endsInStr = findEndsInStr(topStack);
- if (endsInStr != null) {
- long auctionViewEndsIn = prettyTimeToMillis(endsInStr);
- if (auctionViewEndsIn > 0) {
- if (System.currentTimeMillis() - currAucIdSetTimer > 1000) {
- APIManager.Auction auc = manager.auctionManager.getAuctionItems().get(currentAucId);
- if (auc != null) {
- auc.end = auctionViewEndsIn + lastGuiScreenSwitch;
- }
- }
- endsInStr = EnumChatFormatting.DARK_PURPLE + prettyTime(
- auctionViewEndsIn + lastGuiScreenSwitch - System.currentTimeMillis());
- }
- Utils.drawStringCenteredScaledMaxWidth(endsInStr, Minecraft.getMinecraft().fontRendererObj,
- auctionViewLeft + 39, guiTop + 20, false, 70, 4210752);
- }
-
- Utils.drawItemStack(leftStack, auctionViewLeft + 31, guiTop + 100);
-
- if (!isGuiFiller(leftStack)) {
- NBTTagCompound tag = leftStack.getTagCompound();
- NBTTagCompound display = tag.getCompoundTag("display");
- if (display.hasKey("Lore", 9)) {
- NBTTagList list = display.getTagList("Lore", 8);
- String line2 = list.getStringTagAt(1);
- line2 = Utils.cleanColour(line2);
- StringBuilder priceNumbers = new StringBuilder();
- for (int i = 0; i < line2.length(); i++) {
- char c = line2.charAt(i);
- if ((int) c >= 48 && (int) c <= 57) {
- priceNumbers.append(c);
- }
- }
- if (priceNumbers.length() > 0) {
- startingBid = Integer.parseInt(priceNumbers.toString());
- }
- }
- }
-
- Utils.drawItemStack(topStack, auctionViewLeft + 31, guiTop + 35);
-
- if (!isGuiFiller(middleStack)) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(auction_view_buttons);
- boolean hover = mouseX > auctionViewLeft + 31 && mouseX < auctionViewLeft + 31 + 16 &&
- mouseY > guiTop + 126 && mouseY < guiTop + 126 + 16;
- this.drawTexturedModalRect(auctionViewLeft + 31, guiTop + 126, hover ? 16 : 0, 0, 16, 16);
- } else {
- middleStack = null;
- }
-
- if (mouseX > auctionViewLeft + 31 && mouseX < auctionViewLeft + 31 + 16) {
- if (mouseY > guiTop + 35 && mouseY < guiTop + 35 + 16) {
- if (topStack != null) {
- tooltipToRender = topStack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
- tooltipToRender.add("");
- tooltipToRender.add(EnumChatFormatting.YELLOW + "Click to copy seller name!");
- }
- } else if (mouseY > guiTop + 100 && mouseY < guiTop + 100 + 16) {
- if (leftStack != null)
- tooltipToRender = leftStack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
- } else if (mouseY > guiTop + 61 && mouseY < guiTop + 61 + 16) {
- tooltipToRender = new ArrayList<>();
- APIManager.Auction auc = manager.auctionManager.getAuctionItems().get(currentAucId);
- if (auc != null) {
- tooltipToRender.add(EnumChatFormatting.WHITE + "Price Info");
-
- String internalname = manager.getInternalNameForItem(auc.getStack());
- JsonObject auctionInfo = manager.auctionManager.getItemAuctionInfo(internalname);
- JsonObject bazaarInfo = manager.auctionManager.getBazaarInfo(internalname);
-
- boolean hasAuctionPrice = auctionInfo != null;
- boolean hasBazaarPrice = bazaarInfo != null;
-
- int lowestBin = manager.auctionManager.getLowestBin(internalname);
-
- NumberFormat format = NumberFormat.getInstance(Locale.US);
-
- APIManager.CraftInfo craftCost = manager.auctionManager.getCraftCost(internalname);
-
- if (lowestBin > 0) {
- tooltipToRender.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "Lowest BIN: " +
- EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + format.format(lowestBin) + " coins");
- }
- if (hasBazaarPrice) {
- int bazaarBuyPrice = (int) bazaarInfo.get("avg_buy").getAsFloat();
- tooltipToRender.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "Bazaar Buy: " +
- EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + format.format(bazaarBuyPrice) + " coins");
- int bazaarSellPrice = (int) bazaarInfo.get("avg_sell").getAsFloat();
- tooltipToRender.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "Bazaar Sell: " +
- EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + format.format(bazaarSellPrice) + " coins");
- int bazaarInstantBuyPrice = (int) bazaarInfo.get("curr_buy").getAsFloat();
- tooltipToRender.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "Bazaar Insta-Buy: " +
- EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + format.format(bazaarInstantBuyPrice) + " coins");
- int bazaarInstantSellPrice = (int) bazaarInfo.get("curr_sell").getAsFloat();
- tooltipToRender.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "Bazaar Insta-Sell: " +
- EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + format.format(bazaarInstantSellPrice) + " coins");
- }
- if (hasAuctionPrice) {
- int auctionPrice = (int) (auctionInfo.get("price").getAsFloat() / auctionInfo.get("count").getAsFloat());
- tooltipToRender.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "AH Price: " +
- EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + format.format(auctionPrice) + " coins");
- tooltipToRender.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "AH Sales: " +
- EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + format.format(auctionInfo.get("sales").getAsFloat()) + " sales/day");
- if (auctionInfo.has("clean_price")) {
- tooltipToRender.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "AH Price (Clean): " +
- EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + format.format((int) auctionInfo.get("clean_price").getAsFloat()) + " coins");
- tooltipToRender.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "AH Sales (Clean): " +
- EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + format.format(auctionInfo.get("clean_sales").getAsFloat()) + " sales/day");
- }
-
- }
- if (craftCost.fromRecipe) {
- tooltipToRender.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "Raw Craft Cost: " +
- EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + format.format((int) craftCost.craftCost) + " coins");
- }
- tooltipToRender.add("");
- }
- if (rightStack != null)
- tooltipToRender.addAll(rightStack.getTooltip(Minecraft.getMinecraft().thePlayer, false));
- } else if (mouseY > guiTop + 126 && mouseY < guiTop + 126 + 16) {
- if (middleStack != null)
- tooltipToRender = middleStack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
- }
- }
- } catch (NullPointerException e) { //i cant be bothered
- }
- }
- } else if (containerName.trim().equals("Confirm Bid") || containerName.trim().equals("Confirm Purchase")) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(auction_accept);
- this.drawTexturedModalRect(auctionViewLeft, guiTop, 0, 0, 78, 172);
-
- if (auctionViewLeft + 31 > guiLeft + getXSize()) {
- try {
- ItemStack leftStack = auctionView.inventorySlots.getSlot(11).getStack();
- ItemStack middleStack = auctionView.inventorySlots.getSlot(13).getStack();
- ItemStack rightStack = auctionView.inventorySlots.getSlot(15).getStack();
-
- Utils.drawItemStack(middleStack, auctionViewLeft + 31, guiTop + 78);
-
- boolean topHovered = false;
- boolean bottomHovered = false;
-
- if (mouseX > auctionViewLeft + 31 && mouseX < auctionViewLeft + 31 + 16) {
- if (mouseY > guiTop + 31 && mouseY < guiTop + 31 + 16) {
- if (leftStack != null) {
- topHovered = true;
- tooltipToRender = leftStack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
- }
- } else if (mouseY > guiTop + 125 && mouseY < guiTop + 125 + 16) {
- if (rightStack != null) {
- bottomHovered = true;
- tooltipToRender = rightStack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
- }
- } else if (mouseY > guiTop + 78 && mouseY < guiTop + 78 + 16) {
- if (middleStack != null)
- tooltipToRender = middleStack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
- }
- }
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
- Minecraft.getMinecraft().getTextureManager().bindTexture(auction_view_buttons);
- this.drawTexturedModalRect(auctionViewLeft + 31, guiTop + 31, topHovered ? 16 : 0, 48, 16, 16);
- this.drawTexturedModalRect(auctionViewLeft + 31, guiTop + 125, bottomHovered ? 16 : 0, 64, 16, 16);
- } catch (NullPointerException blah) { //i cant be bothered
- }
- }
- }
-
- Utils.drawStringCenteredScaledMaxWidth(containerName, Minecraft.getMinecraft().fontRendererObj,
- auctionViewLeft + 39, guiTop + 10, false, 70, 4210752);
- } else if (isEditingPrice()) {
- hasPopup = true;
- resetCurrAucIdTimer = System.currentTimeMillis();
- float slideAmount = 1 - Math.max(0, Math.min(1, (System.currentTimeMillis() - lastGuiScreenSwitch) / 200f));
- int auctionViewLeft = guiLeft + getXSize() + 4 - (int) (slideAmount * (96 + 4));
-
- if (priceField.getText().equals("IAUSHDIUAH")) priceField.setText("" + startingBid);
-
- searchField.setFocused(false);
- priceField.setFocused(true);
- priceField.xPosition = auctionViewLeft + 18;
- priceField.yPosition = guiTop + 18;
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(auction_price);
- this.drawTexturedModalRect(auctionViewLeft, guiTop, 0, 0, 96, 99);
- priceField.drawTextBox();
-
- Utils.drawStringCenteredScaledMaxWidth("Bid Amount", Minecraft.getMinecraft().fontRendererObj,
- auctionViewLeft + 39, guiTop + 10, false, 70, 4210752);
-
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
- Minecraft.getMinecraft().getTextureManager().bindTexture(auction_view_buttons);
- this.drawTexturedModalRect(auctionViewLeft + 16, guiTop + 32, 0, 16, 30, 16);
- this.drawTexturedModalRect(auctionViewLeft + 16 + 34, guiTop + 32, 0, 16, 30, 16);
- this.drawTexturedModalRect(auctionViewLeft + 16, guiTop + 50, 0, 16, 30, 16);
- this.drawTexturedModalRect(auctionViewLeft + 16 + 34, guiTop + 50, 0, 16, 30, 16);
- this.drawTexturedModalRect(auctionViewLeft + 16, guiTop + 68, 0, 32, 64, 16);
-
- FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
- Utils.drawStringCentered("x2", fr, auctionViewLeft + 16 + 15, guiTop + 32 + 8, false,
- Color.BLACK.getRGB());
- Utils.drawStringCentered("+50%", fr, auctionViewLeft + 16 + 34 + 15, guiTop + 32 + 8, false,
- Color.BLACK.getRGB());
- Utils.drawStringCentered("+25%", fr, auctionViewLeft + 16 + 15, guiTop + 50 + 8, false,
- Color.BLACK.getRGB());
- Utils.drawStringCentered("+10%", fr, auctionViewLeft + 16 + 34 + 15, guiTop + 50 + 8, false,
- Color.BLACK.getRGB());
- Utils.drawStringCentered("Set Amount", fr, auctionViewLeft + 16 + 32, guiTop + 68 + 8, false,
- Color.BLACK.getRGB());
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
-
- GuiEditSign editSign = (GuiEditSign) Minecraft.getMinecraft().currentScreen;
- TileEntitySign tes = (TileEntitySign) Utils.getField(GuiEditSign.class, editSign,
- "tileSign", "field_146848_f");
- tes.lineBeingEdited = 0;
- tes.signText[0] = new ChatComponentText(priceField.getText());
- } else {
- if (System.currentTimeMillis() - resetCurrAucIdTimer > 500 &&
- System.currentTimeMillis() - currAucIdSetTimer > 500) {
- currentAucId = null;
- currAucIdSetTimer = System.currentTimeMillis();
- }
- }
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(creativeInventoryTabs);
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
- if (mouseY > guiTop - 28 && mouseY < guiTop + 4) {
- if (mouseX > guiLeft && mouseX < guiLeft + 168) {
- int offset = mouseX - guiLeft;
- int hoveredCat = offset / 28;
- if (hoveredCat >= 0 && hoveredCat < mainCategories.length) {
- tooltipToRender = Utils.createList(mainCategories[hoveredCat].displayName);
- }
- }
- }
- if (clickedMainCategory == -1) {
- this.drawTexturedModalRect(guiLeft, guiTop - 28, 0, 0, 168, 32);
- } else {
- int selStart = clickedMainCategory * 28;
- this.drawTexturedModalRect(guiLeft, guiTop - 28, 0, 0, selStart, 32);
- this.drawTexturedModalRect(guiLeft + selStart + 28, guiTop - 28, selStart + 28, 0,
- 168 - selStart - 28, 32);
-
- if (clickedMainCategory >= 0 && clickedMainCategory < mainCategories.length) {
- Category mainCategory = mainCategories[clickedMainCategory];
-
- if (mouseX > guiLeft - 28 && mouseX < guiLeft) {
- int offset = mouseY - (guiTop + 17);
- if (offset > 0) {
- int hovered = offset / 28 - 1;
- if (hovered < 0) {
- tooltipToRender = Utils.createList(mainCategory.displayName);
- } else if (hovered < mainCategory.subcategories.length) {
- tooltipToRender = Utils.createList(mainCategory.subcategories[hovered].displayName);
- }
- }
- }
-
- for (int i = -1; i < mainCategory.subcategories.length; i++) {
- if (i != clickedSubCategory) drawCategorySide(i);
- }
- }
- }
-
- //Main GUI
- Minecraft.getMinecraft().getTextureManager().bindTexture(creativeTabSearch);
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
- this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, getXSize(), ySplit);
- int y = guiTop + ySplit;
- for (int i = 0; i < splits; i++) {
- this.drawTexturedModalRect(guiLeft, y, 0, ySplit, getXSize(), ySplit + ySplitSize);
- y += ySplitSize;
- }
- this.drawTexturedModalRect(guiLeft, y, 0, ySplit, getXSize(), 136 - ySplit);
-
- //GUI Name
- Utils.drawStringCenteredScaledMaxWidth("Auction House", Minecraft.getMinecraft().fontRendererObj, guiLeft + 42,
- guiTop + 10, false, 68, 4210752);
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
-
- //Categories
- Minecraft.getMinecraft().getTextureManager().bindTexture(creativeInventoryTabs);
- GlStateManager.enableBlend();
- GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
- if (clickedMainCategory != -1) {
- int selStart = clickedMainCategory * 28;
-
- this.drawTexturedModalRect(guiLeft + selStart, guiTop - 28, clickedMainCategory == 0 ? 0 : 28, 32, 28, 32);
-
- if (clickedMainCategory >= 0 && clickedMainCategory < mainCategories.length) {
- Category mainCategory = mainCategories[clickedMainCategory];
-
- if (clickedSubCategory >= -1 && clickedSubCategory < mainCategory.subcategories.length) {
- drawCategorySide(clickedSubCategory);
- }
- }
- }
-
- //Category icons
- for (int i = 0; i < mainCategories.length; i++) {
- Category category = mainCategories[i];
- Utils.drawItemStack(category.displayItem, guiLeft + 28 * i + 6, guiTop - 28 + 9);
- }
- if (clickedMainCategory >= 0 && clickedMainCategory < mainCategories.length) {
- Category mainCategory = mainCategories[clickedMainCategory];
-
- Utils.drawItemStack(mainCategory.displayItem, guiLeft - 19, guiTop + 23);
- for (int i = 0; i < mainCategory.subcategories.length; i++) {
- Utils.drawItemStack(mainCategory.subcategories[i].displayItem, guiLeft - 19, guiTop + 23 + 28 * (i + 1));
- }
- }
-
- for (int i = 0; i < controls.length; i++) {
- Utils.drawItemStack(controls[i], guiLeft + 9 + 18 * i, guiTop + 112 + 18 * splits);
- if (mouseX > guiLeft + 9 + 18 * i && mouseX < guiLeft + 9 + 18 * i + 16) {
- if (mouseY > guiTop + 112 + 18 * splits && mouseY < guiTop + 112 + 18 * splits + 16) {
- tooltipToRender = getTooltipForControl(i);
- }
- }
- }
-
- int totalItems = auctionIds.size();
- int itemsScroll = (int) Math.floor((totalItems * scrollAmount) / 9f) * 9;
-
- int maxItemScroll = Math.max(0, totalItems - (5 + splits) * 9);
- itemsScroll = Math.min(itemsScroll, maxItemScroll);
-
- if (NotEnoughUpdates.INSTANCE.config.neuAuctionHouse.enableNeuAuctionHouse) {
- out:
- for (int i = 0; i < 5 + splits; i++) {
- int itemY = guiTop + i * 18 + 18;
- for (int j = 0; j < 9; j++) {
- int itemX = guiLeft + j * 18 + 9;
- int id = itemsScroll + i * 9 + j;
- if (auctionIds.size() <= id) break out;
-
- try {
- String aucid = sortedAuctionIds.get(id);
-
- GL11.glTranslatef(0, 0, 100);
- ItemStack stack = manager.auctionManager.getAuctionItems().get(aucid).getStack();
- Utils.drawItemStack(stack, itemX, itemY);
- GL11.glTranslatef(0, 0, -100);
-
- if (mouseX > itemX && mouseX < itemX + 16) {
- if (mouseY > itemY && mouseY < itemY + 16) {
- tooltipToRender = getTooltipForAucId(aucid);
- }
- }
- } catch (Exception e) {
- }
- }
- }
- }
-
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
- searchField.drawTextBox();
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ private enum PriceFilter {
+ Greater,
+ Less,
+ Equal
+ }
+
+ private static final ResourceLocation creativeTabSearch =
+ new ResourceLocation("textures/gui/container/creative_inventory/tab_item_search.png");
+ private static final ResourceLocation creativeInventoryTabs =
+ new ResourceLocation("textures/gui/container/creative_inventory/tabs.png");
+
+ private HashSet<String> auctionIds = new HashSet<>();
+ private List<String> sortedAuctionIds = new ArrayList<>();
+
+ private boolean scrollClicked = false;
+
+ private long lastUpdateSearch;
+ private long lastSearchFieldUpdate;
+ private boolean shouldUpdateSearch = false;
+ private boolean shouldSortItems = false;
+
+ private int startingBid = 0;
+ private String currentAucId = null;
+
+ private int clickedMainCategory = -1;
+ private int clickedSubCategory = -1;
+
+ private GuiTextField searchField = null;
+ private GuiTextField priceField = null;
+ private GuiTextField priceFilterField = null;
+ private GuiTextField binPriceFilterField = null;
+
+ private final int binPriceFilterYOffset = 86;
+
+ private boolean renderOverAuctionView = false;
+ private long lastRenderDisable = 0;
+
+ private long currAucIdSetTimer = 0;
+ private long resetCurrAucIdTimer = 0;
+
+ private int eventButton;
+ private long lastMouseEvent;
+ public long lastOpen;
+ public long lastGuiScreenSwitch;
+ private PriceFilter currentPriceFilterType = PriceFilter.Greater;
+ private PriceFilter currentBinPriceFilterType = PriceFilter.Greater;
+
+ private final int splits = 2;
+
+ public String latestBid;
+ public long latestBidMillis;
+
+ private final int ySplit = 35;
+ private final int ySplitSize = 18;
+
+ private float scrollAmount;
+
+ public int guiLeft = -1;
+ public int guiTop = -1;
+
+ private final Category CATEGORY_SWORD = new Category("sword", "Swords", "diamond_sword");
+ private final Category CATEGORY_ARMOR = new Category("armor", "Armor", "diamond_chestplate");
+ private final Category CATEGORY_BOWS = new Category("bow", "Bows", "bow");
+ private final Category CATEGORY_ACCESSORIES = new Category("accessories", "Accessories", "diamond");
+
+ private final Category CATEGORY_FISHING_ROD = new Category("fishingrod", "Fishing Rods", "fishing_rod");
+ private final Category CATEGORY_PICKAXE = new Category("pickaxe", "Pickaxes", "iron_pickaxe");
+ private final Category CATEGORY_AXE = new Category("axe", "Axes", "iron_axe");
+ private final Category CATEGORY_SHOVEL = new Category("shovel", "Shovels", "iron_shovel");
+
+ private final Category CATEGORY_PET_ITEM = new Category("petitem", "Pet Items", "lead");
+
+ private final Category CATEGORY_EBOOKS = new Category("ebook", "Enchanted Books", "enchanted_book");
+ private final Category CATEGORY_POTIONS = new Category("potion", "Potions", "potion");
+ private final Category CATEGORY_TRAVEL_SCROLLS = new Category("travelscroll", "Travel Scrolls", "map");
+
+ private final Category CATEGORY_REFORGE_STONES = new Category("reforgestone", "Reforge Stones", "anvil");
+ private final Category CATEGORY_RUNES = new Category("rune", "Runes", "magma_cream");
+ private final Category CATEGORY_FURNITURE = new Category("furniture", "Furniture", "armor_stand");
+
+ private final Category CATEGORY_COMBAT = new Category("weapon", "Combat", "golden_sword", CATEGORY_SWORD,
+ CATEGORY_BOWS, CATEGORY_ARMOR, CATEGORY_ACCESSORIES
+ );
+ private final Category CATEGORY_TOOL = new Category(
+ "",
+ "Tools",
+ "diamond_pickaxe",
+ CATEGORY_FISHING_ROD,
+ CATEGORY_PICKAXE,
+ CATEGORY_AXE,
+ CATEGORY_SHOVEL
+ );
+ private final Category CATEGORY_PET = new Category("pet", "Pets", "bone", CATEGORY_PET_ITEM);
+ private final Category CATEGORY_CONSUMABLES = new Category(
+ "consumables",
+ "Consumables",
+ "apple",
+ CATEGORY_EBOOKS,
+ CATEGORY_POTIONS,
+ CATEGORY_TRAVEL_SCROLLS
+ );
+ private final Category CATEGORY_BLOCKS = new Category("blocks", "Blocks", "cobblestone");
+ private final Category CATEGORY_MISC = new Category("misc", "Misc", "stick", CATEGORY_REFORGE_STONES, CATEGORY_RUNES,
+ CATEGORY_FURNITURE
+ );
+
+ private final Category[] mainCategories = new Category[]{
+ CATEGORY_COMBAT, CATEGORY_TOOL, CATEGORY_PET,
+ CATEGORY_CONSUMABLES, CATEGORY_BLOCKS, CATEGORY_MISC
+ };
+
+ private static final int SORT_MODE_HIGH = 0;
+ private static final int SORT_MODE_LOW = 1;
+ private static final int SORT_MODE_SOON = 2;
+
+ // private static final String[] rarities = {"COMMON", "UNCOMMON", "RARE", "EPIC",
+// "LEGENDARY", "MYTHIC", "SPECIAL", "VERY SPECIAL", "SUPREME", "DIVINE"};
+ private static final String[] rarityColours = {
+ "" + EnumChatFormatting.WHITE,
+ "" + EnumChatFormatting.GREEN, "" + EnumChatFormatting.BLUE, "" + EnumChatFormatting.DARK_PURPLE,
+ "" + EnumChatFormatting.GOLD, "" + EnumChatFormatting.LIGHT_PURPLE, "" + EnumChatFormatting.RED,
+ "" + EnumChatFormatting.RED, "" + EnumChatFormatting.AQUA, "" + EnumChatFormatting.AQUA
+ };
+
+ private static final int BIN_FILTER_ALL = 0;
+ private static final int BIN_FILTER_BIN = 1;
+ private static final int BIN_FILTER_AUC = 2;
+
+ private static final int ENCH_FILTER_ALL = 0;
+ private static final int ENCH_FILTER_CLEAN = 1;
+ private static final int ENCH_FILTER_ENCH = 2;
+ private static final int ENCH_FILTER_ENCHHPB = 3;
+
+ private static final int DUNGEON_FILTER_ALL = 0;
+ private static final int DUNGEON_FILTER_DUNGEON = 1;
+ private static final int DUNGEON_FILTER_1 = 2;
+ private static final int DUNGEON_FILTER_2 = 3;
+ private static final int DUNGEON_FILTER_3 = 4;
+ private static final int DUNGEON_FILTER_4 = 5;
+ private static final int DUNGEON_FILTER_5 = 6;
+
+ private int dungeonFilter = DUNGEON_FILTER_ALL;
+ private int sortMode = SORT_MODE_HIGH;
+ private int rarityFilter = -1;
+ private boolean filterMyAuctions = false;
+ private int binFilter = BIN_FILTER_ALL;
+ private int enchFilter = ENCH_FILTER_ALL;
+
+ private static final ItemStack DUNGEON_SORT = Utils.createItemStack(
+ Item.getItemFromBlock(Blocks.deadbush),
+ EnumChatFormatting.GREEN + "Dungeon Sorting"
+ );
+ private static final ItemStack CONTROL_SORT = Utils.createItemStack(
+ Item.getItemFromBlock(Blocks.hopper),
+ EnumChatFormatting.GREEN + "Sort"
+ );
+ private static final ItemStack CONTROL_TIER = Utils.createItemStack(
+ Items.ender_eye,
+ EnumChatFormatting.GREEN + "Item Tier"
+ );
+ private static final ItemStack CONTROL_MYAUC = Utils.createItemStack(
+ Items.gold_ingot,
+ EnumChatFormatting.GREEN + "My Auctions"
+ );
+ private static final ItemStack CONTROL_BIN = Utils.createItemStack(
+ Item.getItemFromBlock(Blocks.golden_rail),
+ EnumChatFormatting.GREEN + "BIN Filter"
+ );
+ private static final ItemStack CONTROL_ENCH = Utils.createItemStack(
+ Items.enchanted_book,
+ EnumChatFormatting.GREEN + "Enchant Filter"
+ );
+ private static final ItemStack CONTROL_STATS = Utils.createItemStack(
+ Item.getItemFromBlock(Blocks.command_block),
+ EnumChatFormatting.GREEN + "Stats for nerds"
+ );
+ private final ItemStack[] controls =
+ {DUNGEON_SORT, CONTROL_SORT, CONTROL_TIER, null, CONTROL_MYAUC, null, CONTROL_BIN, CONTROL_ENCH, CONTROL_STATS};
+
+ private final NEUManager manager;
+
+ public CustomAH(NEUManager manager) {
+ this.manager = manager;
+ }
+
+ public void clearSearch() {
+ if (searchField == null || priceField == null) init();
+ if (System.currentTimeMillis() - lastOpen < 1000) Mouse.setGrabbed(false);
+
+ //sortMode = SORT_MODE_HIGH;
+ rarityFilter = -1;
+ filterMyAuctions = false;
+ //binFilter = BIN_FILTER_ALL;
+ enchFilter = ENCH_FILTER_ALL;
+ dungeonFilter = DUNGEON_FILTER_ALL;
+
+ searchField.setText("");
+ searchField.setFocused(true);
+ priceField.setText("");
+ }
+
+ public void setSearch(String search) {
+ searchField.setText(search);
+ updateSearch();
+ }
+
+ public void tick() {
+ if (!NotEnoughUpdates.INSTANCE.config.neuAuctionHouse.enableNeuAuctionHouse) return;
+ if (Minecraft.getMinecraft().currentScreen instanceof CustomAHGui || renderOverAuctionView) {
+ if (shouldUpdateSearch) updateSearch();
+ if (shouldSortItems) {
+ sortItems();
+ shouldSortItems = false;
+ }
+ }
+ }
+
+ public static class Category {
+ public String categoryMatch;
+ public Category[] subcategories;
+ public String displayName;
+ public ItemStack displayItem;
+
+ public Category(String categoryMatch, String displayName, String displayItem, Category... subcategories) {
+ this.categoryMatch = categoryMatch;
+ this.subcategories = subcategories;
+ this.displayName = displayName;
+ this.displayItem = new ItemStack(Item.getByNameOrId(displayItem));
+ }
+
+ public String[] getTotalCategories() {
+ String[] categories = new String[1 + subcategories.length];
+ categories[0] = categoryMatch;
+
+ for (int i = 0; i < subcategories.length; i++) {
+ categories[i + 1] = subcategories[i].categoryMatch;
+ }
+ return categories;
+ }
+ }
+
+ private void init() {
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+ this.searchField = new GuiTextField(0, fr, this.guiLeft + 82, this.guiTop + 6,
+ 84, fr.FONT_HEIGHT
+ );
+ this.priceField = new GuiTextField(1, fr, this.guiLeft + 82, this.guiTop + 6,
+ 84, fr.FONT_HEIGHT
+ );
+ this.priceFilterField = new GuiTextField(2, fr, this.guiLeft + 82, this.guiTop + 6,
+ 84, fr.FONT_HEIGHT
+ );
+ this.binPriceFilterField = new GuiTextField(3, fr, this.guiLeft + 82, this.guiTop - 6, 84, fr.FONT_HEIGHT);
+
+ this.searchField.setMaxStringLength(30);
+ this.searchField.setEnableBackgroundDrawing(false);
+ this.searchField.setTextColor(16777215);
+ this.searchField.setVisible(true);
+ this.searchField.setCanLoseFocus(true);
+ this.searchField.setFocused(true);
+ this.searchField.setText("");
+
+ this.priceField.setMaxStringLength(10);
+ this.priceField.setEnableBackgroundDrawing(false);
+ this.priceField.setTextColor(16777215);
+ this.priceField.setVisible(true);
+ this.priceField.setCanLoseFocus(true);
+ this.priceField.setFocused(false);
+ this.priceField.setText("");
+
+ this.priceFilterField.setMaxStringLength(10);
+ this.priceFilterField.setEnableBackgroundDrawing(false);
+ this.priceFilterField.setTextColor(16777215);
+ this.priceFilterField.setVisible(true);
+ this.priceFilterField.setCanLoseFocus(true);
+ this.priceFilterField.setFocused(false);
+ this.priceFilterField.setText("");
+
+ this.binPriceFilterField.setMaxStringLength(10);
+ this.binPriceFilterField.setEnableBackgroundDrawing(false);
+ this.binPriceFilterField.setTextColor(16777215);
+ this.binPriceFilterField.setVisible(true);
+ this.binPriceFilterField.setCanLoseFocus(true);
+ this.binPriceFilterField.setFocused(false);
+ this.binPriceFilterField.setText("");
+ }
+
+ public boolean isRenderOverAuctionView() {
+ return renderOverAuctionView || (System.currentTimeMillis() - lastRenderDisable) < 500;
+ }
+
+ public void setRenderOverAuctionView(boolean renderOverAuctionView) {
+ if (this.renderOverAuctionView && !renderOverAuctionView) lastRenderDisable = System.currentTimeMillis();
+ this.renderOverAuctionView = renderOverAuctionView;
+ }
+
+ public int getXSize() {
+ return 195;
+ }
+
+ public int getYSize() {
+ return 136 + ySplitSize * splits;
+ }
+
+ private String prettyTime(long millis) {
+ long seconds = millis / 1000 % 60;
+ long minutes = (millis / 1000 / 60) % 60;
+ long hours = (millis / 1000 / 60 / 60) % 24;
+ long days = (millis / 1000 / 60 / 60 / 24);
+
+ String endsIn = "";
+ if (millis < 0) {
+ endsIn += "Ended!";
+ } else if (minutes == 0 && hours == 0 && days == 0) {
+ endsIn += seconds + "s";
+ } else if (hours == 0 && days == 0) {
+ endsIn += minutes + "m" + seconds + "s";
+ } else if (days == 0) {
+ if (hours <= 6) {
+ endsIn += hours + "h" + minutes + "m" + seconds + "s";
+ } else {
+ endsIn += hours + "h";
+ }
+ } else {
+ endsIn += days + "d" + hours + "h";
+ }
+
+ return endsIn;
+ }
+
+ public List<String> getTooltipForAucId(String aucId) {
+ APIManager.Auction auc = manager.auctionManager.getAuctionItems().get(aucId);
+
+ List<String> tooltip = new ArrayList<>();
+
+ for (String line : auc.getStack().getTooltip(Minecraft.getMinecraft().thePlayer, false)) {
+ tooltip.add(EnumChatFormatting.GRAY + line);
+ }
+
+ long timeUntilEnd = auc.end - System.currentTimeMillis();
+ String endsIn = EnumChatFormatting.YELLOW + prettyTime(timeUntilEnd);
+
+ NumberFormat format = NumberFormat.getInstance(Locale.US);
+
+ tooltip.add(EnumChatFormatting.DARK_GRAY + "" + EnumChatFormatting.STRIKETHROUGH + "-----------------");
+ tooltip.add(EnumChatFormatting.GRAY + "Seller: [CLICK TO SEE]");
+
+ if (auc.bin) {
+ tooltip.add(EnumChatFormatting.GRAY + "Buy it now: " +
+ EnumChatFormatting.GOLD + format.format(auc.starting_bid));
+ } else {
+ if (auc.bid_count > 0) {
+ tooltip.add(EnumChatFormatting.GRAY + "Bids: " + EnumChatFormatting.GREEN + auc.bid_count + " bids");
+ tooltip.add("");
+ tooltip.add(EnumChatFormatting.GRAY + "Top bid: " +
+ EnumChatFormatting.GOLD + format.format(auc.highest_bid_amount));
+ tooltip.add(EnumChatFormatting.GRAY + "Bidder: [CLICK TO SEE]");
+ } else {
+ tooltip.add(EnumChatFormatting.GRAY + "Starting bid: " +
+ EnumChatFormatting.GOLD + format.format(auc.starting_bid));
+ }
+ }
+
+ if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.showPriceInfoAucItem) {
+ String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(auc.getStack());
+ if (internalname != null) {
+ if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && !Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
+ tooltip.add("");
+ tooltip.add(EnumChatFormatting.GRAY + "[SHIFT for Price Info]");
+ } else {
+ ItemPriceInformation.addToTooltip(tooltip, internalname, auc.getStack());
+ }
+ }
+ }
+
+ tooltip.add("");
+ tooltip.add(EnumChatFormatting.GRAY + "Ends in: " + endsIn);
+ tooltip.add("");
+ tooltip.add(EnumChatFormatting.YELLOW + "Click to inspect!");
+
+ return tooltip;
+ }
+
+ public boolean isEditingPrice() {
+ return Minecraft.getMinecraft().currentScreen instanceof GuiEditSign;
+ }
+
+ private boolean isGuiFiller(ItemStack stack) {
+ return stack == null || !stack.hasTagCompound() || !stack.getTagCompound().hasKey("AttributeModifiers");
+ }
+
+ private void drawCategorySide(int i) {
+ boolean clicked = i == clickedSubCategory;
+
+ int x = guiLeft - 28;
+ int y = guiTop + 17 + 28 * (i + 1);
+ float uMin = 28 / 256f;
+ float uMax = 56 / 256f;
+ float vMin = 0 + (clicked ? 32 / 256f : 0);
+ float vMax = 32 / 256f + (clicked ? 32 / 256f : 0);
+ float catWidth = 32;
+ float catHeight = 28;
+
+ GlStateManager.enableTexture2D();
+ GlStateManager.enableBlend();
+ GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
+
+ GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
+ GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
+
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+ worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
+ worldrenderer
+ .pos(x, y + catHeight, 0.0D)
+ .tex(uMax, vMin).endVertex();
+ worldrenderer
+ .pos(x + catWidth, y + catHeight, 0.0D)
+ .tex(uMax, vMax).endVertex();
+ worldrenderer
+ .pos(x + catWidth, y, 0.0D)
+ .tex(uMin, vMax).endVertex();
+ worldrenderer
+ .pos(x, y, 0.0D)
+ .tex(uMin, vMin).endVertex();
+ tessellator.draw();
+
+ GlStateManager.disableBlend();
+ }
+
+ private final HashMap<Pattern, Long> timeParseMap = new HashMap<Pattern, Long>() {{
+ Pattern dayPattern = Pattern.compile("([0-9]+)d");
+ Pattern hourPattern = Pattern.compile("([0-9]+)h");
+ Pattern minutePattern = Pattern.compile("([0-9]+)m");
+ Pattern secondPattern = Pattern.compile("([0-9]+)s");
+
+ put(dayPattern, 24 * 60 * 60 * 1000L);
+ put(hourPattern, 60 * 60 * 1000L);
+ put(minutePattern, 60 * 1000L);
+ put(secondPattern, 1000L);
+ }};
+
+ public long prettyTimeToMillis(String endsInStr) {
+ if (endsInStr != null) {
+ long timeUntilEnd = 0;
+
+ String timeStr = Utils.cleanColour(endsInStr);
+
+ for (Map.Entry<Pattern, Long> timeEntry : timeParseMap.entrySet()) {
+ Matcher matcher = timeEntry.getKey().matcher(timeStr);
+ if (matcher.find()) {
+ String days = matcher.group(1);
+ timeUntilEnd += Long.parseLong(days) * timeEntry.getValue();
+ }
+ }
+
+ return timeUntilEnd;
+ }
+
+ return -1;
+ }
+
+ public String findStrStart(ItemStack stack, String toFind) {
+ if (stack.hasTagCompound()) {
+ //§7Ends in:
+ for (String line : manager.getLoreFromNBT(stack.getTagCompound())) {
+ if (line.trim().startsWith(toFind)) {
+ return line.substring(toFind.length());
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public String findEndsInStr(ItemStack stack) {
+ return findStrStart(stack, EnumChatFormatting.GRAY + "Ends in: ");
+ }
+
+ public void drawScreen(int mouseX, int mouseY) {
+ if (System.currentTimeMillis() - lastOpen < 1000) Mouse.setGrabbed(false);
+
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ int width = scaledResolution.getScaledWidth();
+ int height = scaledResolution.getScaledHeight();
+
+ boolean hasPopup = false;
+
+ if (searchField == null || priceField == null || priceFilterField == null) init();
+
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+
+ guiLeft = (width - getXSize()) / 2;
+ guiTop = (height - getYSize()) / 2;
+ this.searchField.xPosition = guiLeft + 82;
+ this.searchField.yPosition = guiTop + 6;
+
+ if (!isEditingPrice()) priceField.setText("IAUSHDIUAH");
+
+ if ((Minecraft.getMinecraft().currentScreen instanceof GuiChest ||
+ Minecraft.getMinecraft().currentScreen instanceof GuiEditSign) && currentAucId == null) {
+ Minecraft.getMinecraft().displayGuiScreen(null);
+ }
+
+ List<String> tooltipToRender = null;
+ if (Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
+ resetCurrAucIdTimer = System.currentTimeMillis();
+ GuiChest auctionView = (GuiChest) Minecraft.getMinecraft().currentScreen;
+ ContainerChest container = (ContainerChest) auctionView.inventorySlots;
+ String containerName = container.getLowerChestInventory().getDisplayName().getUnformattedText();
+
+ float slideAmount = 1 - Math.max(0, Math.min(1, (System.currentTimeMillis() - lastGuiScreenSwitch) / 200f));
+ int auctionViewLeft = guiLeft + getXSize() + 4 - (int) (slideAmount * (78 + 4));
+ if (containerName.trim().equals("Auction View") || containerName.trim().equals("BIN Auction View")) {
+ hasPopup = true;
+ Minecraft.getMinecraft().getTextureManager().bindTexture(auction_view);
+ this.drawTexturedModalRect(auctionViewLeft, guiTop, 0, 0, 78, 172);
+
+ if (auctionViewLeft + 31 > guiLeft + getXSize()) {
+ try {
+ ItemStack topStack = auctionView.inventorySlots.getSlot(13).getStack();
+ ItemStack leftStack = auctionView.inventorySlots.getSlot(29).getStack();
+ ItemStack middleStack = auctionView.inventorySlots.getSlot(31).getStack();
+ ItemStack rightStack = auctionView.inventorySlots.getSlot(33).getStack();
+
+ boolean isBin = isGuiFiller(leftStack) || isGuiFiller(leftStack);
+
+ if (isBin) {
+ leftStack = middleStack;
+ middleStack = null;
+ }
+
+ String endsInStr = findEndsInStr(topStack);
+ if (endsInStr != null) {
+ long auctionViewEndsIn = prettyTimeToMillis(endsInStr);
+ if (auctionViewEndsIn > 0) {
+ if (System.currentTimeMillis() - currAucIdSetTimer > 1000) {
+ APIManager.Auction auc = manager.auctionManager.getAuctionItems().get(currentAucId);
+ if (auc != null) {
+ auc.end = auctionViewEndsIn + lastGuiScreenSwitch;
+ }
+ }
+ endsInStr = EnumChatFormatting.DARK_PURPLE + prettyTime(
+ auctionViewEndsIn + lastGuiScreenSwitch - System.currentTimeMillis());
+ }
+ Utils.drawStringCenteredScaledMaxWidth(endsInStr, Minecraft.getMinecraft().fontRendererObj,
+ auctionViewLeft + 39, guiTop + 20, false, 70, 4210752
+ );
+ }
+
+ Utils.drawItemStack(leftStack, auctionViewLeft + 31, guiTop + 100);
+
+ if (!isGuiFiller(leftStack)) {
+ NBTTagCompound tag = leftStack.getTagCompound();
+ NBTTagCompound display = tag.getCompoundTag("display");
+ if (display.hasKey("Lore", 9)) {
+ NBTTagList list = display.getTagList("Lore", 8);
+ String line2 = list.getStringTagAt(1);
+ line2 = Utils.cleanColour(line2);
+ StringBuilder priceNumbers = new StringBuilder();
+ for (int i = 0; i < line2.length(); i++) {
+ char c = line2.charAt(i);
+ if ((int) c >= 48 && (int) c <= 57) {
+ priceNumbers.append(c);
+ }
+ }
+ if (priceNumbers.length() > 0) {
+ startingBid = Integer.parseInt(priceNumbers.toString());
+ }
+ }
+ }
+
+ Utils.drawItemStack(topStack, auctionViewLeft + 31, guiTop + 35);
+
+ if (!isGuiFiller(middleStack)) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(auction_view_buttons);
+ boolean hover = mouseX > auctionViewLeft + 31 && mouseX < auctionViewLeft + 31 + 16 &&
+ mouseY > guiTop + 126 && mouseY < guiTop + 126 + 16;
+ this.drawTexturedModalRect(auctionViewLeft + 31, guiTop + 126, hover ? 16 : 0, 0, 16, 16);
+ } else {
+ middleStack = null;
+ }
+
+ if (mouseX > auctionViewLeft + 31 && mouseX < auctionViewLeft + 31 + 16) {
+ if (mouseY > guiTop + 35 && mouseY < guiTop + 35 + 16) {
+ if (topStack != null) {
+ tooltipToRender = topStack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ tooltipToRender.add("");
+ tooltipToRender.add(EnumChatFormatting.YELLOW + "Click to copy seller name!");
+ }
+ } else if (mouseY > guiTop + 100 && mouseY < guiTop + 100 + 16) {
+ if (leftStack != null)
+ tooltipToRender = leftStack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ } else if (mouseY > guiTop + 61 && mouseY < guiTop + 61 + 16) {
+ tooltipToRender = new ArrayList<>();
+ APIManager.Auction auc = manager.auctionManager.getAuctionItems().get(currentAucId);
+ if (auc != null) {
+ tooltipToRender.add(EnumChatFormatting.WHITE + "Price Info");
+
+ String internalname = manager.getInternalNameForItem(auc.getStack());
+ JsonObject auctionInfo = manager.auctionManager.getItemAuctionInfo(internalname);
+ JsonObject bazaarInfo = manager.auctionManager.getBazaarInfo(internalname);
+
+ boolean hasAuctionPrice = auctionInfo != null;
+ boolean hasBazaarPrice = bazaarInfo != null;
+
+ int lowestBin = manager.auctionManager.getLowestBin(internalname);
+
+ NumberFormat format = NumberFormat.getInstance(Locale.US);
+
+ APIManager.CraftInfo craftCost = manager.auctionManager.getCraftCost(internalname);
+
+ if (lowestBin > 0) {
+ tooltipToRender.add(
+ EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "Lowest BIN: " +
+ EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + format.format(lowestBin) + " coins");
+ }
+ if (hasBazaarPrice) {
+ int bazaarBuyPrice = (int) bazaarInfo.get("avg_buy").getAsFloat();
+ tooltipToRender.add(
+ EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "Bazaar Buy: " +
+ EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + format.format(bazaarBuyPrice) + " coins");
+ int bazaarSellPrice = (int) bazaarInfo.get("avg_sell").getAsFloat();
+ tooltipToRender.add(
+ EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "Bazaar Sell: " +
+ EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + format.format(bazaarSellPrice) + " coins");
+ int bazaarInstantBuyPrice = (int) bazaarInfo.get("curr_buy").getAsFloat();
+ tooltipToRender.add(
+ EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "Bazaar Insta-Buy: " +
+ EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + format.format(bazaarInstantBuyPrice) +
+ " coins");
+ int bazaarInstantSellPrice = (int) bazaarInfo.get("curr_sell").getAsFloat();
+ tooltipToRender.add(
+ EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "Bazaar Insta-Sell: " +
+ EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + format.format(bazaarInstantSellPrice) +
+ " coins");
+ }
+ if (hasAuctionPrice) {
+ int auctionPrice =
+ (int) (auctionInfo.get("price").getAsFloat() / auctionInfo.get("count").getAsFloat());
+ tooltipToRender.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "AH Price: " +
+ EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + format.format(auctionPrice) + " coins");
+ tooltipToRender.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "AH Sales: " +
+ EnumChatFormatting.GOLD + EnumChatFormatting.BOLD +
+ format.format(auctionInfo.get("sales").getAsFloat()) + " sales/day");
+ if (auctionInfo.has("clean_price")) {
+ tooltipToRender.add(
+ EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "AH Price (Clean): " +
+ EnumChatFormatting.GOLD + EnumChatFormatting.BOLD +
+ format.format((int) auctionInfo.get("clean_price").getAsFloat()) + " coins");
+ tooltipToRender.add(
+ EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "AH Sales (Clean): " +
+ EnumChatFormatting.GOLD + EnumChatFormatting.BOLD +
+ format.format(auctionInfo.get("clean_sales").getAsFloat()) + " sales/day");
+ }
+
+ }
+ if (craftCost.fromRecipe) {
+ tooltipToRender.add(
+ EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "Raw Craft Cost: " +
+ EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + format.format((int) craftCost.craftCost) +
+ " coins");
+ }
+ tooltipToRender.add("");
+ }
+ if (rightStack != null)
+ tooltipToRender.addAll(rightStack.getTooltip(Minecraft.getMinecraft().thePlayer, false));
+ } else if (mouseY > guiTop + 126 && mouseY < guiTop + 126 + 16) {
+ if (middleStack != null)
+ tooltipToRender = middleStack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ }
+ }
+ } catch (NullPointerException e) { //i cant be bothered
+ }
+ }
+ } else if (containerName.trim().equals("Confirm Bid") || containerName.trim().equals("Confirm Purchase")) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(auction_accept);
+ this.drawTexturedModalRect(auctionViewLeft, guiTop, 0, 0, 78, 172);
+
+ if (auctionViewLeft + 31 > guiLeft + getXSize()) {
+ try {
+ ItemStack leftStack = auctionView.inventorySlots.getSlot(11).getStack();
+ ItemStack middleStack = auctionView.inventorySlots.getSlot(13).getStack();
+ ItemStack rightStack = auctionView.inventorySlots.getSlot(15).getStack();
+
+ Utils.drawItemStack(middleStack, auctionViewLeft + 31, guiTop + 78);
+
+ boolean topHovered = false;
+ boolean bottomHovered = false;
+
+ if (mouseX > auctionViewLeft + 31 && mouseX < auctionViewLeft + 31 + 16) {
+ if (mouseY > guiTop + 31 && mouseY < guiTop + 31 + 16) {
+ if (leftStack != null) {
+ topHovered = true;
+ tooltipToRender = leftStack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ }
+ } else if (mouseY > guiTop + 125 && mouseY < guiTop + 125 + 16) {
+ if (rightStack != null) {
+ bottomHovered = true;
+ tooltipToRender = rightStack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ }
+ } else if (mouseY > guiTop + 78 && mouseY < guiTop + 78 + 16) {
+ if (middleStack != null)
+ tooltipToRender = middleStack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ }
+ }
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(auction_view_buttons);
+ this.drawTexturedModalRect(auctionViewLeft + 31, guiTop + 31, topHovered ? 16 : 0, 48, 16, 16);
+ this.drawTexturedModalRect(auctionViewLeft + 31, guiTop + 125, bottomHovered ? 16 : 0, 64, 16, 16);
+ } catch (NullPointerException blah) { //i cant be bothered
+ }
+ }
+ }
+
+ Utils.drawStringCenteredScaledMaxWidth(containerName, Minecraft.getMinecraft().fontRendererObj,
+ auctionViewLeft + 39, guiTop + 10, false, 70, 4210752
+ );
+ } else if (isEditingPrice()) {
+ hasPopup = true;
+ resetCurrAucIdTimer = System.currentTimeMillis();
+ float slideAmount = 1 - Math.max(0, Math.min(1, (System.currentTimeMillis() - lastGuiScreenSwitch) / 200f));
+ int auctionViewLeft = guiLeft + getXSize() + 4 - (int) (slideAmount * (96 + 4));
+
+ if (priceField.getText().equals("IAUSHDIUAH")) priceField.setText("" + startingBid);
+
+ searchField.setFocused(false);
+ priceField.setFocused(true);
+ priceField.xPosition = auctionViewLeft + 18;
+ priceField.yPosition = guiTop + 18;
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(auction_price);
+ this.drawTexturedModalRect(auctionViewLeft, guiTop, 0, 0, 96, 99);
+ priceField.drawTextBox();
+
+ Utils.drawStringCenteredScaledMaxWidth("Bid Amount", Minecraft.getMinecraft().fontRendererObj,
+ auctionViewLeft + 39, guiTop + 10, false, 70, 4210752
+ );
+
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(auction_view_buttons);
+ this.drawTexturedModalRect(auctionViewLeft + 16, guiTop + 32, 0, 16, 30, 16);
+ this.drawTexturedModalRect(auctionViewLeft + 16 + 34, guiTop + 32, 0, 16, 30, 16);
+ this.drawTexturedModalRect(auctionViewLeft + 16, guiTop + 50, 0, 16, 30, 16);
+ this.drawTexturedModalRect(auctionViewLeft + 16 + 34, guiTop + 50, 0, 16, 30, 16);
+ this.drawTexturedModalRect(auctionViewLeft + 16, guiTop + 68, 0, 32, 64, 16);
+
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+ Utils.drawStringCentered("x2", fr, auctionViewLeft + 16 + 15, guiTop + 32 + 8, false,
+ Color.BLACK.getRGB()
+ );
+ Utils.drawStringCentered("+50%", fr, auctionViewLeft + 16 + 34 + 15, guiTop + 32 + 8, false,
+ Color.BLACK.getRGB()
+ );
+ Utils.drawStringCentered("+25%", fr, auctionViewLeft + 16 + 15, guiTop + 50 + 8, false,
+ Color.BLACK.getRGB()
+ );
+ Utils.drawStringCentered("+10%", fr, auctionViewLeft + 16 + 34 + 15, guiTop + 50 + 8, false,
+ Color.BLACK.getRGB()
+ );
+ Utils.drawStringCentered("Set Amount", fr, auctionViewLeft + 16 + 32, guiTop + 68 + 8, false,
+ Color.BLACK.getRGB()
+ );
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+
+ GuiEditSign editSign = (GuiEditSign) Minecraft.getMinecraft().currentScreen;
+ TileEntitySign tes = (TileEntitySign) Utils.getField(GuiEditSign.class, editSign,
+ "tileSign", "field_146848_f"
+ );
+ tes.lineBeingEdited = 0;
+ tes.signText[0] = new ChatComponentText(priceField.getText());
+ } else {
+ if (System.currentTimeMillis() - resetCurrAucIdTimer > 500 &&
+ System.currentTimeMillis() - currAucIdSetTimer > 500) {
+ currentAucId = null;
+ currAucIdSetTimer = System.currentTimeMillis();
+ }
+ }
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(creativeInventoryTabs);
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ if (mouseY > guiTop - 28 && mouseY < guiTop + 4) {
+ if (mouseX > guiLeft && mouseX < guiLeft + 168) {
+ int offset = mouseX - guiLeft;
+ int hoveredCat = offset / 28;
+ if (hoveredCat >= 0 && hoveredCat < mainCategories.length) {
+ tooltipToRender = Utils.createList(mainCategories[hoveredCat].displayName);
+ }
+ }
+ }
+ if (clickedMainCategory == -1) {
+ this.drawTexturedModalRect(guiLeft, guiTop - 28, 0, 0, 168, 32);
+ } else {
+ int selStart = clickedMainCategory * 28;
+ this.drawTexturedModalRect(guiLeft, guiTop - 28, 0, 0, selStart, 32);
+ this.drawTexturedModalRect(guiLeft + selStart + 28, guiTop - 28, selStart + 28, 0,
+ 168 - selStart - 28, 32
+ );
+
+ if (clickedMainCategory >= 0 && clickedMainCategory < mainCategories.length) {
+ Category mainCategory = mainCategories[clickedMainCategory];
+
+ if (mouseX > guiLeft - 28 && mouseX < guiLeft) {
+ int offset = mouseY - (guiTop + 17);
+ if (offset > 0) {
+ int hovered = offset / 28 - 1;
+ if (hovered < 0) {
+ tooltipToRender = Utils.createList(mainCategory.displayName);
+ } else if (hovered < mainCategory.subcategories.length) {
+ tooltipToRender = Utils.createList(mainCategory.subcategories[hovered].displayName);
+ }
+ }
+ }
+
+ for (int i = -1; i < mainCategory.subcategories.length; i++) {
+ if (i != clickedSubCategory) drawCategorySide(i);
+ }
+ }
+ }
+
+ //Main GUI
+ Minecraft.getMinecraft().getTextureManager().bindTexture(creativeTabSearch);
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, getXSize(), ySplit);
+ int y = guiTop + ySplit;
+ for (int i = 0; i < splits; i++) {
+ this.drawTexturedModalRect(guiLeft, y, 0, ySplit, getXSize(), ySplit + ySplitSize);
+ y += ySplitSize;
+ }
+ this.drawTexturedModalRect(guiLeft, y, 0, ySplit, getXSize(), 136 - ySplit);
+
+ //GUI Name
+ Utils.drawStringCenteredScaledMaxWidth("Auction House", Minecraft.getMinecraft().fontRendererObj, guiLeft + 42,
+ guiTop + 10, false, 68, 4210752
+ );
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+
+ //Categories
+ Minecraft.getMinecraft().getTextureManager().bindTexture(creativeInventoryTabs);
+ GlStateManager.enableBlend();
+ GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ if (clickedMainCategory != -1) {
+ int selStart = clickedMainCategory * 28;
+
+ this.drawTexturedModalRect(guiLeft + selStart, guiTop - 28, clickedMainCategory == 0 ? 0 : 28, 32, 28, 32);
+
+ if (clickedMainCategory >= 0 && clickedMainCategory < mainCategories.length) {
+ Category mainCategory = mainCategories[clickedMainCategory];
+
+ if (clickedSubCategory >= -1 && clickedSubCategory < mainCategory.subcategories.length) {
+ drawCategorySide(clickedSubCategory);
+ }
+ }
+ }
+
+ //Category icons
+ for (int i = 0; i < mainCategories.length; i++) {
+ Category category = mainCategories[i];
+ Utils.drawItemStack(category.displayItem, guiLeft + 28 * i + 6, guiTop - 28 + 9);
+ }
+ if (clickedMainCategory >= 0 && clickedMainCategory < mainCategories.length) {
+ Category mainCategory = mainCategories[clickedMainCategory];
+
+ Utils.drawItemStack(mainCategory.displayItem, guiLeft - 19, guiTop + 23);
+ for (int i = 0; i < mainCategory.subcategories.length; i++) {
+ Utils.drawItemStack(mainCategory.subcategories[i].displayItem, guiLeft - 19, guiTop + 23 + 28 * (i + 1));
+ }
+ }
+
+ for (int i = 0; i < controls.length; i++) {
+ Utils.drawItemStack(controls[i], guiLeft + 9 + 18 * i, guiTop + 112 + 18 * splits);
+ if (mouseX > guiLeft + 9 + 18 * i && mouseX < guiLeft + 9 + 18 * i + 16) {
+ if (mouseY > guiTop + 112 + 18 * splits && mouseY < guiTop + 112 + 18 * splits + 16) {
+ tooltipToRender = getTooltipForControl(i);
+ }
+ }
+ }
+
+ int totalItems = auctionIds.size();
+ int itemsScroll = (int) Math.floor((totalItems * scrollAmount) / 9f) * 9;
+
+ int maxItemScroll = Math.max(0, totalItems - (5 + splits) * 9);
+ itemsScroll = Math.min(itemsScroll, maxItemScroll);
+
+ if (NotEnoughUpdates.INSTANCE.config.neuAuctionHouse.enableNeuAuctionHouse) {
+ out:
+ for (int i = 0; i < 5 + splits; i++) {
+ int itemY = guiTop + i * 18 + 18;
+ for (int j = 0; j < 9; j++) {
+ int itemX = guiLeft + j * 18 + 9;
+ int id = itemsScroll + i * 9 + j;
+ if (auctionIds.size() <= id) break out;
+
+ try {
+ String aucid = sortedAuctionIds.get(id);
+
+ GL11.glTranslatef(0, 0, 100);
+ ItemStack stack = manager.auctionManager.getAuctionItems().get(aucid).getStack();
+ Utils.drawItemStack(stack, itemX, itemY);
+ GL11.glTranslatef(0, 0, -100);
+
+ if (mouseX > itemX && mouseX < itemX + 16) {
+ if (mouseY > itemY && mouseY < itemY + 16) {
+ tooltipToRender = getTooltipForAucId(aucid);
+ }
+ }
+ } catch (Exception ignored) {
+ }
+ }
+ }
+ }
+
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ searchField.drawTextBox();
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
/*if(auctionIds.size() == 0 && searchField.getText().length() == 0) {
drawRect(guiLeft+8, guiTop+17, guiLeft+170, guiTop+107+18*splits,
@@ -910,1020 +970,1041 @@ public class CustomAH extends Gui {
fr.drawString("Loading items...", guiLeft+(8+170-strWidth)/2, guiTop+(17+107+18*splits)/2, Color.BLACK.getRGB());
}*/
- Minecraft.getMinecraft().getTextureManager().bindTexture(creativeInventoryTabs);
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
- this.drawTexturedModalRect(guiLeft + 175, guiTop + 18 + (int) ((95 + ySplitSize * 2) * scrollAmount),
- 256 - (scrollClicked ? 12 : 24), 0, 12, 15);
-
- if (!NotEnoughUpdates.INSTANCE.config.neuAuctionHouse.enableNeuAuctionHouse) {
- Utils.drawStringCentered(EnumChatFormatting.RED + "NEUAH is DISABLED! Enable in /neusettings.",
- Minecraft.getMinecraft().fontRendererObj, guiLeft + getXSize() / 2, guiTop + getYSize() / 2 - 5, true, 0);
- }
-
- if (tooltipToRender != null) {
- List<String> tooltipGray = new ArrayList<>();
- for (String line : tooltipToRender) {
- tooltipGray.add(EnumChatFormatting.GRAY + line);
- }
- Utils.drawHoveringText(tooltipGray, mouseX, mouseY, width,
- height, -1, Minecraft.getMinecraft().fontRendererObj);
- }
- float slideAmount = 1 - Math.max(0, Math.min(1, (System.currentTimeMillis() - lastGuiScreenSwitch) / 200f));
- int auctionViewLeft = guiLeft + getXSize() + 4 - (int) (slideAmount * (78 + 4));
-
- // Price filter
- if (!hasPopup && NotEnoughUpdates.INSTANCE.config.neuAuctionHouse.priceFiltering) {
- // Price bid filter
- priceFilterField.xPosition = auctionViewLeft + 18;
- priceFilterField.yPosition = guiTop + 18;
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(auction_price);
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
- this.drawTexturedModalRect(auctionViewLeft, guiTop, 0, 0, 96, 83);
- if (getPriceFilterAmount() == -1) {
- priceFilterField.setTextColor(Color.RED.getRGB());
- } else {
- priceFilterField.setTextColor(16777215);
- }
- priceFilterField.drawTextBox();
-
- Utils.drawStringCenteredScaledMaxWidth("Price Filter", Minecraft.getMinecraft().fontRendererObj,
- auctionViewLeft + 39, guiTop + 10, false, 70, 4210752);
-
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
- Minecraft.getMinecraft().getTextureManager().bindTexture(auction_view_buttons);
- if (currentPriceFilterType == PriceFilter.Less) {
- this.drawTexturedModalRect(auctionViewLeft + 16, guiTop + 32, 30, 16, 30, 16);
- } else {
- this.drawTexturedModalRect(auctionViewLeft + 16, guiTop + 32, 0, 16, 30, 16);
- }
- if (currentPriceFilterType == PriceFilter.Greater) {
- this.drawTexturedModalRect(auctionViewLeft + 16 + 34, guiTop + 32, 30, 16, 30, 16);
- } else {
- this.drawTexturedModalRect(auctionViewLeft + 16 + 34, guiTop + 32, 0, 16, 30, 16);
- }
- if (currentPriceFilterType == PriceFilter.Equal) {
- this.drawTexturedModalRect(auctionViewLeft + 16, guiTop + 50, 64, 32, 64, 16);
- } else {
- this.drawTexturedModalRect(auctionViewLeft + 16, guiTop + 50, 0, 32, 64, 16);
- }
-
- FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
- Utils.drawStringCentered("<=", fr, auctionViewLeft + 16 + 15, guiTop + 32 + 8, false,
- Color.BLACK.getRGB());
- Utils.drawStringCentered(">=", fr, auctionViewLeft + 16 + 34 + 15, guiTop + 32 + 8, false,
- Color.BLACK.getRGB());
- Utils.drawStringCentered("==", fr, auctionViewLeft + 16 + 32, guiTop + 50 + 8, false,
- Color.BLACK.getRGB());
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
-
- // Bin average price filter
- binPriceFilterField.xPosition = auctionViewLeft + 18;
- binPriceFilterField.yPosition = guiTop + 18 + binPriceFilterYOffset;
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(auction_price);
- this.drawTexturedModalRect(auctionViewLeft, guiTop + binPriceFilterYOffset, 0, 0, 96, 83);
- if (getBinPriceFilterAmount() == -1) {
- binPriceFilterField.setTextColor(Color.RED.getRGB());
- } else {
- binPriceFilterField.setTextColor(16777215);
- }
- binPriceFilterField.drawTextBox();
-
- Utils.drawStringCenteredScaledMaxWidth("BIN Average Filter", Minecraft.getMinecraft().fontRendererObj,
- auctionViewLeft + 39, guiTop + 10 + binPriceFilterYOffset, false, 70, 4210752);
-
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
- Minecraft.getMinecraft().getTextureManager().bindTexture(auction_view_buttons);
- if (currentBinPriceFilterType == PriceFilter.Less) {
- this.drawTexturedModalRect(auctionViewLeft + 16, guiTop + 32 + binPriceFilterYOffset, 30, 16, 30, 16);
- } else {
- this.drawTexturedModalRect(auctionViewLeft + 16, guiTop + 32 + binPriceFilterYOffset, 0, 16, 30, 16);
- }
- if (currentBinPriceFilterType == PriceFilter.Greater) {
- this.drawTexturedModalRect(auctionViewLeft + 16 + 34, guiTop + 32 + binPriceFilterYOffset, 30, 16, 30, 16);
- } else {
- this.drawTexturedModalRect(auctionViewLeft + 16 + 34, guiTop + 32 + binPriceFilterYOffset, 0, 16, 30, 16);
- }
- if (currentBinPriceFilterType == PriceFilter.Equal) {
- this.drawTexturedModalRect(auctionViewLeft + 16, guiTop + 50 + binPriceFilterYOffset, 64, 32, 64, 16);
- } else {
- this.drawTexturedModalRect(auctionViewLeft + 16, guiTop + 50 + binPriceFilterYOffset, 0, 32, 64, 16);
- }
-
- Utils.drawStringCentered("<=", fr, auctionViewLeft + 16 + 15, guiTop + 32 + 8 + binPriceFilterYOffset, false,
- Color.BLACK.getRGB());
- Utils.drawStringCentered(">=", fr, auctionViewLeft + 16 + 34 + 15, guiTop + 32 + 8 + binPriceFilterYOffset, false,
- Color.BLACK.getRGB());
- Utils.drawStringCentered("==", fr, auctionViewLeft + 16 + 32, guiTop + 50 + 8 + binPriceFilterYOffset, false,
- Color.BLACK.getRGB());
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
- }
- }
-
- public List<String> getTooltipForControl(int index) {
- List<String> lore = new ArrayList<>();
- if (index < 0 || index >= controls.length) return lore;
- if (controls[index] == null) return lore;
-
- lore.add(controls[index].getDisplayName());
- String arrow = "\u25b6";
- String selPrefixNC = " " + arrow + " ";
- String selPrefix = EnumChatFormatting.DARK_AQUA + selPrefixNC;
- String unselPrefix = EnumChatFormatting.GRAY.toString();
- switch (index) {
- case 0:
- lore.add("");
- String gold = EnumChatFormatting.GOLD.toString();
- String gray = EnumChatFormatting.GRAY.toString();
- char s = 0x272A;
- String[] linesDung = {"Show All", "Any Dungeon",
- gold + s + gray + s + s + s + s,
- gold + s + s + gray + s + s + s,
- gold + s + s + s + gray + s + s,
- gold + s + s + s + s + gray + s,
- gold + s + s + s + s + s};
- for (int i = 0; i < linesDung.length; i++) {
- String line = linesDung[i];
- if (i == dungeonFilter) {
- line = selPrefix + line.replace(gray, EnumChatFormatting.DARK_AQUA.toString());
- } else {
- line = unselPrefix + line;
- }
- lore.add(line);
- }
- lore.add("");
- lore.add(EnumChatFormatting.AQUA + "Right-Click to go backwards!");
- lore.add(EnumChatFormatting.YELLOW + "Click to switch sort!");
- return lore;
- case 1:
- lore.add("");
- String[] linesSort = {"Highest Bid", "Lowest Bid", "Ending soon"};
- for (int i = 0; i < linesSort.length; i++) {
- String line = linesSort[i];
- if (i == sortMode) {
- line = selPrefix + line;
- } else {
- line = unselPrefix + line;
- }
- lore.add(line);
- }
- lore.add("");
- lore.add(EnumChatFormatting.YELLOW + "Click to switch sort!");
- return lore;
- case 2:
- lore.add("");
- lore.add((rarityFilter == -1 ? EnumChatFormatting.DARK_GRAY + selPrefixNC : unselPrefix) + "No Filter");
-
- for (int i = 0; i < Utils.rarityArr.length; i++) {
- lore.add((rarityFilter == i ? rarityColours[i] + selPrefixNC : unselPrefix) +
- Utils.prettyCase(Utils.rarityArr[i]));
- }
- lore.add("");
- lore.add(EnumChatFormatting.AQUA + "Right-Click to go backwards!");
- lore.add(EnumChatFormatting.YELLOW + "Click to switch filter!");
- return lore;
- case 3:
- break;
- case 4:
- lore.add("");
- String off = EnumChatFormatting.RED + "OFF";
- String on = EnumChatFormatting.GREEN + "ON";
- lore.add(unselPrefix + "Filter Own Auctions: " + (filterMyAuctions ? on : off));
- lore.add("");
- lore.add(EnumChatFormatting.YELLOW + "Click to toggle!");
- return lore;
- case 5:
- break;
- case 6:
- lore.add("");
- String[] linesBin = {"Show All", "BIN Only", "Auctions Only"};
- for (int i = 0; i < linesBin.length; i++) {
- String line = linesBin[i];
- if (i == binFilter) {
- line = selPrefix + line;
- } else {
- line = unselPrefix + line;
- }
- lore.add(line);
- }
- lore.add("");
- lore.add(EnumChatFormatting.AQUA + "Right-Click to go backwards!");
- lore.add(EnumChatFormatting.YELLOW + "Click to switch filter!");
- return lore;
- case 7:
- lore.add("");
- String[] linesEnch = {"Show All", "Clean Only", "Ench Only", "Ench/HPB Only"};
- for (int i = 0; i < linesEnch.length; i++) {
- String line = linesEnch[i];
- if (i == enchFilter) {
- line = selPrefix + line;
- } else {
- line = unselPrefix + line;
- }
- lore.add(line);
- }
- lore.add("");
- lore.add(EnumChatFormatting.AQUA + "Right-Click to go backwards!");
- lore.add(EnumChatFormatting.YELLOW + "Click to switch filter!");
- return lore;
- case 8:
- lore.add("");
- lore.add("Current aucid: " + currentAucId);
- if (currentAucId != null) {
- APIManager.Auction auc = manager.auctionManager.getAuctionItems().get(currentAucId);
- if (auc != null) {
- lore.add("Current auc category: " + auc.category);
- }
- }
- lore.add(" --- Processing");
- lore.add("Page Process Millis: " + manager.auctionManager.processMillis);
- lore.add(" --- Auction Stats");
- lore.add("Active Auctions: " + manager.auctionManager.activeAuctions);
- lore.add("Tracked Auctions: " + manager.auctionManager.getAuctionItems().size());
- lore.add("Displayed Auctions: " + auctionIds.size());
- lore.add("Tracked Player Auctions: " + manager.auctionManager.getPlayerBids().size());
- lore.add("Unique Items: " + manager.auctionManager.uniqueItems);
- lore.add("ID Tagged Auctions: " + manager.auctionManager.internalnameTaggedAuctions);
- lore.add("Total Tags: " + manager.auctionManager.totalTags);
- lore.add("Tagged Auctions: " + manager.auctionManager.taggedAuctions);
- lore.add("");
- lore.add(EnumChatFormatting.AQUA + "Right-Click to copy current aucid to clipboard!");
- lore.add(EnumChatFormatting.YELLOW + "Click to refresh!");
- return lore;
- }
- return new ArrayList<>();
- }
-
- public void handleMouseInput() {
- if (!NotEnoughUpdates.INSTANCE.config.neuAuctionHouse.enableNeuAuctionHouse) {
- return;
- }
-
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- int width = scaledResolution.getScaledWidth();
- int height = scaledResolution.getScaledHeight();
-
- int mouseX = Mouse.getEventX() * width / Minecraft.getMinecraft().displayWidth;
- int mouseY = height - Mouse.getEventY() * height / Minecraft.getMinecraft().displayHeight - 1;
- int mouseButton = Mouse.getEventButton();
-
- if (Mouse.getEventButtonState()) {
- this.eventButton = mouseButton;
- this.lastMouseEvent = Minecraft.getSystemTime();
- mouseClicked(mouseX, mouseY, this.eventButton);
- } else if (mouseButton != -1) {
- this.eventButton = -1;
- mouseReleased(mouseX, mouseY, mouseButton);
- } else if (this.eventButton != -1 && this.lastMouseEvent > 0L) {
- long l = Minecraft.getSystemTime() - this.lastMouseEvent;
- mouseClickMove(mouseX, mouseY, this.eventButton, l);
- }
-
- if (!NotEnoughUpdates.INSTANCE.config.neuAuctionHouse.disableAhScroll) {
- int dWheel = Mouse.getEventDWheel();
- dWheel = Math.max(-1, Math.min(1, dWheel));
-
- scrollAmount = scrollAmount - dWheel / (float) (auctionIds.size() / 9 - (5 + splits));
- scrollAmount = Math.max(0, Math.min(1, scrollAmount));
- }
- }
-
- public String niceAucId(String aucId) {
- if (aucId.length() != 32) return aucId;
-
- StringBuilder niceAucId = new StringBuilder();
- niceAucId.append(aucId, 0, 8);
- niceAucId.append("-");
- niceAucId.append(aucId, 8, 12);
- niceAucId.append("-");
- niceAucId.append(aucId, 12, 16);
- niceAucId.append("-");
- niceAucId.append(aucId, 16, 20);
- niceAucId.append("-");
- niceAucId.append(aucId, 20, 32);
- return niceAucId.toString();
- }
-
- public Category getCurrentCategory() {
- if (clickedMainCategory < 0 || clickedMainCategory >= mainCategories.length) {
- return null;
- }
- Category mainCategory = mainCategories[clickedMainCategory];
- if (clickedSubCategory < 0 || clickedSubCategory >= mainCategory.subcategories.length) {
- return mainCategory;
- }
- return mainCategory.subcategories[clickedSubCategory];
- }
-
- private boolean doesAucMatch(APIManager.Auction auc) {
- if (auc == null) return false;
-
- Category currentCategory = getCurrentCategory();
-
- boolean match = true;
- if (currentCategory != null) {
- match = false;
- String[] categories = currentCategory.getTotalCategories();
- for (String category : categories) {
- match |= category.equalsIgnoreCase(auc.category);
- }
- }
-
- if (rarityFilter >= 0 && rarityFilter < Utils.rarityArr.length) {
- match &= Utils.rarityArr[rarityFilter].equals(auc.rarity);
- }
-
- if (binFilter == BIN_FILTER_BIN) {
- match &= auc.bin;
- } else if (binFilter == BIN_FILTER_AUC) {
- match &= !auc.bin;
- }
-
- if (enchFilter > ENCH_FILTER_ALL) {
- switch (enchFilter) {
- case ENCH_FILTER_CLEAN:
- match &= auc.enchLevel == 0;
- break;
- case ENCH_FILTER_ENCH:
- match &= auc.enchLevel >= 1;
- break;
- case ENCH_FILTER_ENCHHPB:
- match &= auc.enchLevel == 2;
- break;
- }
- }
-
- if (dungeonFilter > DUNGEON_FILTER_ALL) {
- if (dungeonFilter == DUNGEON_FILTER_DUNGEON && auc.dungeonTier < 0) {
- match = false;
- } else {
- match &= dungeonFilter == auc.dungeonTier + 1;
- }
- }
-
- if (getPriceFilterAmount() > -1) {
- if (currentPriceFilterType == PriceFilter.Greater) {
- match &= auc.highest_bid_amount != 0 ? (auc.highest_bid_amount >= getPriceFilterAmount()) : auc.starting_bid >= getPriceFilterAmount();
- }
- if (currentPriceFilterType == PriceFilter.Less) {
- match &= auc.highest_bid_amount != 0 ? (auc.highest_bid_amount <= getPriceFilterAmount()) : auc.starting_bid <= getPriceFilterAmount();
- }
- if (currentPriceFilterType == PriceFilter.Equal) {
- match &= auc.highest_bid_amount != 0 ? (auc.highest_bid_amount == getPriceFilterAmount()) : auc.starting_bid == getPriceFilterAmount();
- }
- }
- if (getBinPriceFilterAmount() > -1) {
- int lowestBin = NotEnoughUpdates.INSTANCE.manager.auctionManager.getLowestBin(NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(auc.getStack()));
- if (lowestBin > 0) {
- if (currentBinPriceFilterType == PriceFilter.Greater) {
- match &= lowestBin >= getBinPriceFilterAmount();
- }
- if (currentBinPriceFilterType == PriceFilter.Less) {
- match &= lowestBin <= getBinPriceFilterAmount();
- }
- if (currentBinPriceFilterType == PriceFilter.Equal) {
- match &= lowestBin == getBinPriceFilterAmount();
- }
- } else {
- match = false;
- }
- }
- return match;
- }
-
- private HashSet<String> search(String query, Set<String> dontMatch) {
- query = query.trim();
- HashSet<String> matches = new HashSet<>();
-
- Set<String> itemMatches = manager.search(query);
- for (String internalname : itemMatches) {
- for (String aucid : manager.auctionManager.getAuctionsForInternalname(internalname)) {
- APIManager.Auction auc = manager.auctionManager.getAuctionItems().get(aucid);
- if (doesAucMatch(auc)) {
- //matches.add(aucid);
- } else {
- dontMatch.add(aucid);
- }
- }
- }
-
- HashMap<String, List<Integer>> extrasMatches = new HashMap<>();
- HashMap<String, List<Integer>> extrasMatchesCurrent = new HashMap<>();
- boolean first = true;
- for (String subQuery : query.split(" ")) {
- for (HashMap<Integer, HashSet<String>> extrasMap : manager.subMapWithKeysThatAreSuffixes(subQuery.toLowerCase(),
- manager.auctionManager.extrasToAucIdMap).values()) {
- for (int index : extrasMap.keySet()) {
- for (String aucid : extrasMap.get(index)) {
- APIManager.Auction auc = manager.auctionManager.getAuctionItems().get(aucid);
- if (!dontMatch.contains(aucid) && doesAucMatch(auc)) {
- if (first) {
- List<Integer> indexList = extrasMatchesCurrent.computeIfAbsent(aucid, k -> new ArrayList<>());
- indexList.add(index);
- } else {
- List<Integer> indexList = extrasMatches.computeIfAbsent(aucid, k -> new ArrayList<>());
- if (indexList.contains(index - 1)) {
- List<Integer> indexListCurrent = extrasMatchesCurrent.computeIfAbsent(aucid, k -> new ArrayList<>());
- indexListCurrent.add(index);
- }
- }
- } else {
- dontMatch.add(aucid);
- }
- }
- }
-
- }
-
- extrasMatches = (HashMap<String, List<Integer>>) extrasMatchesCurrent.clone();
- extrasMatchesCurrent.clear();
- first = false;
- }
- matches.addAll(extrasMatches.keySet());
-
- return matches;
- }
-
- private ExecutorService es = Executors.newSingleThreadExecutor();
-
- public void updateSearch() {
- if (!NotEnoughUpdates.INSTANCE.config.neuAuctionHouse.enableNeuAuctionHouse) {
- return;
- }
-
- if (searchField == null || priceField == null || priceFilterField == null || binPriceFilterField == null)
- init();
- long currentTime = System.currentTimeMillis();
-
- es.submit(() -> {
- if (currentTime - lastUpdateSearch < 100) {
- shouldUpdateSearch = true;
- return;
- }
-
- lastUpdateSearch = currentTime;
- shouldUpdateSearch = false;
-
- scrollAmount = 0;
- try {
- HashSet<String> auctionIdsNew = new HashSet<>();
- auctionIdsNew.clear();
- if (filterMyAuctions) {
- for (String aucid : manager.auctionManager.getPlayerBids()) {
- APIManager.Auction auc = manager.auctionManager.getAuctionItems().get(aucid);
- if (doesAucMatch(auc)) {
- auctionIdsNew.add(aucid);
- }
- }
- } else if (searchField.getText().length() == 0) {
- for (Map.Entry<String, APIManager.Auction> entry : manager.auctionManager.getAuctionItems().entrySet()) {
- if (doesAucMatch(entry.getValue())) {
- auctionIdsNew.add(entry.getKey());
- }
- }
- } else {
- String query = searchField.getText();
- Set<String> dontMatch = new HashSet<>();
-
- HashSet<String> allMatch = new HashSet<>();
- if (query.contains("!")) { //only used for inverted queries, so dont need to populate unless ! in query
- for (Map.Entry<String, APIManager.Auction> entry : manager.auctionManager.getAuctionItems().entrySet()) {
- if (doesAucMatch(entry.getValue())) {
- allMatch.add(entry.getKey());
- } else {
- dontMatch.add(entry.getKey());
- }
- }
- }
-
- boolean invert = false;
-
- StringBuilder query2 = new StringBuilder();
- char lastOp = '|';
- for (char c : query.toCharArray()) {
- if (query2.toString().trim().isEmpty() && c == '!') {
- invert = true;
- } else if (c == '|' || c == '&') {
- if (lastOp == '|') {
- HashSet<String> result = search(query2.toString(), dontMatch);
- if (!invert) {
- auctionIdsNew.addAll(result);
- } else {
- HashSet<String> allClone = (HashSet<String>) allMatch.clone();
- allClone.removeAll(result);
- auctionIdsNew.addAll(allClone);
- }
- } else if (lastOp == '&') {
- HashSet<String> result = search(query2.toString(), dontMatch);
- if (!invert) {
- auctionIdsNew.retainAll(result);
- } else {
- auctionIdsNew.removeAll(result);
- }
- }
-
- query2 = new StringBuilder();
- invert = false;
- lastOp = c;
- } else {
- query2.append(c);
- }
- }
- if (lastOp == '|') {
- HashSet<String> result = search(query2.toString(), dontMatch);
- if (!invert) {
- auctionIdsNew.addAll(result);
- } else {
- HashSet<String> allClone = (HashSet<String>) allMatch.clone();
- allClone.removeAll(result);
- auctionIdsNew.addAll(allClone);
- }
- } else if (lastOp == '&') {
- HashSet<String> result = search(query2.toString(), dontMatch);
- if (!invert) {
- auctionIdsNew.retainAll(result);
- } else {
- auctionIdsNew.removeAll(result);
- }
- }
- }
- auctionIds = auctionIdsNew;
- sortItems();
- } catch (Exception e) {
- shouldUpdateSearch = true;
- }
- });
- }
-
- public void sortItems() throws ConcurrentModificationException {
- if (!NotEnoughUpdates.INSTANCE.config.neuAuctionHouse.enableNeuAuctionHouse) {
- return;
- }
-
- try {
- List<String> sortedAuctionIdsNew = new ArrayList<>();
-
- sortedAuctionIdsNew.addAll(auctionIds);
- sortedAuctionIdsNew.sort((o1, o2) -> {
- APIManager.Auction auc1 = manager.auctionManager.getAuctionItems().get(o1);
- APIManager.Auction auc2 = manager.auctionManager.getAuctionItems().get(o2);
-
- if (auc1 == null) return 1;
- if (auc2 == null) return -1;
-
- if (sortMode == SORT_MODE_HIGH) {
- int price1 = Math.max(auc1.highest_bid_amount, auc1.starting_bid);
- int price2 = Math.max(auc2.highest_bid_amount, auc2.starting_bid);
- int diff = price2 - price1;
- if (diff != 0) {
- return diff;
- }
- } else if (sortMode == SORT_MODE_LOW) {
- int price1 = Math.max(auc1.highest_bid_amount, auc1.starting_bid);
- int price2 = Math.max(auc2.highest_bid_amount, auc2.starting_bid);
- int diff = price1 - price2;
- if (diff != 0) {
- return diff;
- }
- } else {
- long end1 = auc1.end;
- long end2 = auc2.end;
-
- if (end1 < System.currentTimeMillis()) return 999999;
- if (end2 < System.currentTimeMillis()) return -999999;
-
- int diff = (int) (end1 - end2);
- if (diff != 0) {
- return diff;
- }
- }
- return o1.compareTo(o2);
- });
-
- sortedAuctionIds = sortedAuctionIdsNew;
- } catch (Exception e) {
- shouldSortItems = true;
- }
- }
-
- public boolean keyboardInput() {
- if (!NotEnoughUpdates.INSTANCE.config.neuAuctionHouse.enableNeuAuctionHouse) {
- return false;
- }
-
- Keyboard.enableRepeatEvents(true);
- if (isEditingPrice() && Keyboard.getEventKey() == Keyboard.KEY_RETURN) {
- Minecraft.getMinecraft().displayGuiScreen(null);
- } else if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
- if (Minecraft.getMinecraft().currentScreen instanceof GuiEditSign) {
- priceField.setText("");
- GuiEditSign editSign = (GuiEditSign) Minecraft.getMinecraft().currentScreen;
- TileEntitySign tes = (TileEntitySign) Utils.getField(GuiEditSign.class, editSign,
- "tileSign", "field_146848_f");
- tes.lineBeingEdited = 0;
- tes.signText[0] = new ChatComponentText(priceField.getText());
- }
- return false;
- }
- if (Keyboard.getEventKeyState()) return keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey());
- return true;
- }
-
- public boolean keyTyped(char typedChar, int keyCode) {
- if (searchField == null || priceField == null || priceFilterField == null || binPriceFilterField == null)
- init();
-
- if (!isEditingPrice()) {
- if (this.priceFilterField.textboxKeyTyped(typedChar, keyCode)) {
- this.updateSearch();
- return true;
- }
- if (this.binPriceFilterField.textboxKeyTyped(typedChar, keyCode)) {
- this.updateSearch();
- return true;
- }
- if (this.searchField.textboxKeyTyped(typedChar, keyCode)) {
- lastSearchFieldUpdate = System.currentTimeMillis();
- this.updateSearch();
- return true;
- }
- } else {
- if (!priceField.isFocused()) priceField.setFocused(searchField.isFocused() && priceFilterField.isFocused());
- return priceField.textboxKeyTyped(typedChar, keyCode);
- }
- return false;
- }
-
- private void increasePriceByFactor(float factor) {
- String price = priceField.getText().trim();
- StringBuilder priceNumbers = new StringBuilder();
- for (int i = 0; i < price.length(); i++) {
- char c = price.charAt(i);
- if ((int) c >= 48 && (int) c <= 57) {
- priceNumbers.append(c);
- } else {
- break;
- }
- }
- int priceI = 0;
- if (priceNumbers.length() > 0) {
- priceI = Integer.parseInt(priceNumbers.toString());
- }
- String end = price.substring(priceNumbers.length());
- priceField.setText((int) (priceI * factor) + end);
- }
-
- private int getPriceFilterAmount() {
- return getNumberFromTextBox(priceFilterField);
- }
-
- private int getNumberFromTextBox(GuiTextField textField) {
- if (textField.getText().equals("")) {
- return -2;
- }
- try {
- int parsed = Integer.parseInt(textField.getText());
- if (parsed < 0) {
- return -1;
- }
- return parsed;
- } catch (NumberFormatException e) {
- return -1;
- }
- }
-
- private int getBinPriceFilterAmount() {
- return getNumberFromTextBox(binPriceFilterField);
- }
-
- protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
- boolean wasFocused = searchField.isFocused();
- searchField.mouseClicked(mouseX, mouseY, mouseButton);
- if (mouseButton == 1 && !wasFocused && searchField.isFocused()) {
- searchField.setText("");
- }
- priceField.mouseClicked(mouseX, mouseY, mouseButton);
- priceFilterField.mouseClicked(mouseX, mouseY, mouseButton);
- binPriceFilterField.mouseClicked(mouseX, mouseY, mouseButton);
-
- int totalItems = auctionIds.size();
- int itemsScroll = (int) Math.floor((totalItems * scrollAmount) / 9f) * 9;
-
- int maxItemScroll = Math.max(0, totalItems - (5 + splits) * 9);
- itemsScroll = Math.min(itemsScroll, maxItemScroll);
-
- //Categories
- if (mouseY > guiTop - 28 && mouseY < guiTop + 4) {
- if (mouseX > guiLeft && mouseX < guiLeft + 168) {
- int offset = mouseX - guiLeft;
- int clickedCat = offset / 28;
- if (clickedMainCategory == clickedCat) {
- clickedMainCategory = -1;
- } else {
- clickedMainCategory = clickedCat;
- }
- clickedSubCategory = -1;
- updateSearch();
- Utils.playPressSound();
- return;
- }
- }
-
- if (clickedMainCategory >= 0 && clickedMainCategory < mainCategories.length) {
- Category mainCategory = mainCategories[clickedMainCategory];
-
- if (mouseX > guiLeft - 28 && mouseX < guiLeft) {
- int offset = mouseY - (guiTop + 17);
- if (offset > 0) {
- int clicked = offset / 28 - 1;
- if (clicked != clickedSubCategory && clicked < mainCategory.subcategories.length) {
- clickedSubCategory = clicked;
- updateSearch();
- Utils.playPressSound();
- return;
- }
- }
- }
- }
-
- if (mouseY > guiTop + 112 + 18 * splits && mouseY < guiTop + 112 + 18 * splits + 16) {
- if (mouseX > guiLeft + 9 && mouseX < guiLeft + 9 + controls.length * 18 - 2) {
- int offset = mouseX - (guiLeft + 9);
- int index = offset / 18;
- boolean rightClicked = Mouse.getEventButton() == 1;
- switch (index) {
- case 0:
- if (rightClicked) {
- dungeonFilter--;
- if (dungeonFilter < DUNGEON_FILTER_ALL) dungeonFilter = DUNGEON_FILTER_5;
- } else {
- dungeonFilter++;
- if (dungeonFilter > DUNGEON_FILTER_5) dungeonFilter = DUNGEON_FILTER_ALL;
- }
- break;
- case 1:
- if (rightClicked) {
- sortMode--;
- if (sortMode < SORT_MODE_HIGH) sortMode = SORT_MODE_SOON;
- } else {
- sortMode++;
- if (sortMode > SORT_MODE_SOON) sortMode = SORT_MODE_HIGH;
- }
- break;
- case 2:
- if (rightClicked) {
- rarityFilter--;
- if (rarityFilter < -1) rarityFilter = Utils.rarityArr.length - 1;
- } else {
- rarityFilter++;
- if (rarityFilter >= Utils.rarityArr.length) rarityFilter = -1;
- }
- break;
- case 3:
- break;
- case 4:
- filterMyAuctions = !filterMyAuctions;
- break;
- case 5:
- break;
- case 6:
- if (rightClicked) {
- binFilter--;
- if (binFilter < BIN_FILTER_ALL) binFilter = BIN_FILTER_AUC;
- } else {
- binFilter++;
- if (binFilter > BIN_FILTER_AUC) binFilter = BIN_FILTER_ALL;
- }
- break;
- case 7:
- if (rightClicked) {
- enchFilter--;
- if (enchFilter < ENCH_FILTER_ALL) enchFilter = ENCH_FILTER_ENCHHPB;
- } else {
- enchFilter++;
- if (enchFilter > ENCH_FILTER_ENCHHPB) enchFilter = ENCH_FILTER_ALL;
- }
- break;
- case 8:
- if (rightClicked) {
- if (currentAucId != null) {
- StringSelection selection = new StringSelection(niceAucId(currentAucId));
- Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, selection);
- }
- } else {
- manager.auctionManager.calculateStats();
- }
- }
- updateSearch();
- Utils.playPressSound();
- }
- }
- boolean hasPopup = false;
- if (mouseButton == 0 && Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
- hasPopup = true;
- GuiChest auctionView = (GuiChest) Minecraft.getMinecraft().currentScreen;
- ContainerChest container = (ContainerChest) auctionView.inventorySlots;
- String containerName = container.getLowerChestInventory().getDisplayName().getUnformattedText();
-
-
- if (containerName.trim().equals("Auction View") || containerName.trim().equals("BIN Auction View")) {
-
- if (mouseX > guiLeft + getXSize() + 4 + 31 && mouseX < guiLeft + getXSize() + 4 + 31 + 16) {
- boolean leftFiller = isGuiFiller(auctionView.inventorySlots.getSlot(29).getStack());//isBin
- if (mouseY > guiTop + 35 && mouseY < guiTop + 35 + 16) {
- ItemStack topStack = auctionView.inventorySlots.getSlot(13).getStack();
- if (topStack != null) {
- String line = findStrStart(topStack, EnumChatFormatting.GRAY + "Seller: ");
- String[] split = line.split(" ");
- String seller = split[split.length - 1];
- StringSelection selection = new StringSelection(seller);
- Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, selection);
- }
- } else if (mouseY > guiTop + 100 && mouseY < guiTop + 100 + 16) {
- int slotClick = leftFiller ? 31 : 29;
- Minecraft.getMinecraft().playerController.windowClick(auctionView.inventorySlots.windowId,
- slotClick, 2, 3, Minecraft.getMinecraft().thePlayer);
-
- if (!leftFiller) {
- if (auctionView.inventorySlots.getSlot(29).getStack()
- .getDisplayName().trim().equals(EnumChatFormatting.GOLD + "Collect Auction")) {
- manager.auctionManager.getPlayerBids().remove(currentAucId);
- auctionIds.remove(currentAucId);
- }
- }
-
- Utils.playPressSound();
- } else if (mouseY > guiTop + 126 && mouseY < guiTop + 126 + 16 && !leftFiller) {
- priceField.setFocused(true);
- Minecraft.getMinecraft().playerController.windowClick(auctionView.inventorySlots.windowId,
- 31, 2, 3, Minecraft.getMinecraft().thePlayer);
- Utils.playPressSound();
- }
- }
- } else if (containerName.trim().equals("Confirm Bid") || containerName.trim().equals("Confirm Purchase")) {
- if (mouseX > guiLeft + getXSize() + 4 + 31 && mouseX < guiLeft + getXSize() + 4 + 31 + 16) {
- if (mouseY > guiTop + 31 && mouseY < guiTop + 31 + 16) {
- if (currentAucId != null) {
- manager.auctionManager.getPlayerBids().add(currentAucId);
- latestBid = currentAucId;
- latestBidMillis = System.currentTimeMillis();
- //reset timer to 2m if below
- if (manager.auctionManager.getAuctionItems().get(currentAucId) != null &&
- manager.auctionManager.getAuctionItems().get(currentAucId).end -
- System.currentTimeMillis() < 2 * 60 * 1000) {
- manager.auctionManager.getAuctionItems().get(currentAucId).end =
- System.currentTimeMillis() + 2 * 60 * 1000;
- }
- }
- Minecraft.getMinecraft().playerController.windowClick(auctionView.inventorySlots.windowId,
- 11, 2, 3, Minecraft.getMinecraft().thePlayer);
- } else if (mouseY > guiTop + 125 && mouseY < guiTop + 125 + 16) {
- Minecraft.getMinecraft().playerController.windowClick(auctionView.inventorySlots.windowId,
- 15, 2, 3, Minecraft.getMinecraft().thePlayer);
- }
- Utils.playPressSound();
- }
- }
- }
- int auctionViewLeft = guiLeft + getXSize() + 4;
-
- if (mouseButton == 0 && isEditingPrice()) {
-
- if (mouseX > auctionViewLeft + 16 && mouseX < auctionViewLeft + 16 + 64) {
- if (mouseY > guiTop + 32 && mouseY < guiTop + 32 + 16) {
- if (mouseX < auctionViewLeft + 16 + 32) {
- //top left
- increasePriceByFactor(2);
- Utils.playPressSound();
- } else {
- //top right
- increasePriceByFactor(1.5f);
- Utils.playPressSound();
- }
- } else if (mouseY > guiTop + 50 && mouseY < guiTop + 50 + 16) {
- if (mouseX < auctionViewLeft + 16 + 32) {
- //mid left
- increasePriceByFactor(1.25f);
- Utils.playPressSound();
- } else {
- //mid right
- increasePriceByFactor(1.1f);
- Utils.playPressSound();
- }
- } else if (mouseY > guiTop + 68 && mouseY < guiTop + 68 + 16) {
- //bottom
- Utils.playPressSound();
- Minecraft.getMinecraft().displayGuiScreen(null);
- }
- }
-
- this.drawTexturedModalRect(auctionViewLeft + 16, guiTop + 32, 0, 16, 30, 16);
- this.drawTexturedModalRect(auctionViewLeft + 16 + 34, guiTop + 32, 0, 16, 30, 16);
- this.drawTexturedModalRect(auctionViewLeft + 16, guiTop + 50, 0, 16, 30, 16);
- this.drawTexturedModalRect(auctionViewLeft + 16 + 34, guiTop + 50, 0, 16, 30, 16);
- this.drawTexturedModalRect(auctionViewLeft + 16, guiTop + 68, 0, 32, 64, 16);
- } else if (!hasPopup && NotEnoughUpdates.INSTANCE.config.neuAuctionHouse.priceFiltering) {
-
- if (mouseX > auctionViewLeft + 16 && mouseX < auctionViewLeft + 16 + 64) {
- if (mouseY > guiTop + 32 && mouseY < guiTop + 32 + 16) {
- if (mouseX < auctionViewLeft + 16 + 32) {
- //top left
- currentPriceFilterType = PriceFilter.Less;
- } else {
- //top right
- currentPriceFilterType = PriceFilter.Greater;
- }
- Utils.playPressSound();
- updateSearch();
- } else if (mouseY > guiTop + 50 && mouseY < guiTop + 50 + 16) {
- //middle
- currentPriceFilterType = PriceFilter.Equal;
- Utils.playPressSound();
- updateSearch();
- }
- }
-
- if (mouseX > auctionViewLeft + 16 && mouseX < auctionViewLeft + 16 + 64) {
- if (mouseY > guiTop + 32 + binPriceFilterYOffset && mouseY < guiTop + 32 + 16 + binPriceFilterYOffset) {
- if (mouseX < auctionViewLeft + 16 + 32) {
- //top left
- currentBinPriceFilterType = PriceFilter.Less;
- } else {
- //top right
- currentBinPriceFilterType = PriceFilter.Greater;
- }
- Utils.playPressSound();
- updateSearch();
- } else if (mouseY > guiTop + 50 + binPriceFilterYOffset && mouseY < guiTop + 50 + 16 + binPriceFilterYOffset) {
- //middle
- currentBinPriceFilterType = PriceFilter.Equal;
- Utils.playPressSound();
- updateSearch();
- }
- }
- }
- out:
- for (int i = 0; i < 5 + splits; i++) {
- int itemY = guiTop + i * 18 + 18;
- for (int j = 0; j < 9; j++) {
- int itemX = guiLeft + j * 18 + 9;
- int id = itemsScroll + i * 9 + j;
- if (auctionIds.size() <= id) break out;
-
- String aucid;
- try {
- aucid = sortedAuctionIds.get(id);
- } catch (IndexOutOfBoundsException e) {
- break out;
- }
-
- if (aucid == null) continue;
- APIManager.Auction auc = manager.auctionManager.getAuctionItems().get(aucid);
- if (auc != null) {
- if (mouseX > itemX && mouseX < itemX + 16) {
- if (mouseY > itemY && mouseY < itemY + 16) {
- if (Minecraft.getMinecraft().currentScreen instanceof GuiEditSign) {
- priceField.setText("");
- GuiEditSign editSign = (GuiEditSign) Minecraft.getMinecraft().currentScreen;
- TileEntitySign tes = (TileEntitySign) Utils.getField(GuiEditSign.class, editSign,
- "tileSign", "field_146848_f");
- tes.lineBeingEdited = 0;
- tes.signText[0] = new ChatComponentText(priceField.getText());
- }
- startingBid = Math.max(auc.starting_bid, auc.highest_bid_amount);
- currAucIdSetTimer = System.currentTimeMillis();
- currentAucId = aucid;
-
- Minecraft.getMinecraft().thePlayer.sendChatMessage("/viewauction " + niceAucId(aucid));
- Utils.playPressSound();
- }
- }
- }
- }
- }
-
- int y = guiTop + 18 + (int) ((95 + ySplitSize * 2) * scrollAmount);
- if (mouseX > guiLeft + 175 && mouseX < guiLeft + 175 + 12) {
- if (mouseY > y && mouseY < y + 15) {
- scrollClicked = true;
- return;
- }
- }
- scrollClicked = false;
- }
-
- protected void mouseReleased(int mouseX, int mouseY, int state) {
- scrollClicked = false;
- }
-
- protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
- if (scrollClicked) {
- int yMin = guiTop + 18 + 8;
- int yMax = guiTop + 18 + (95 + ySplitSize * 2) + 8;
-
- scrollAmount = (mouseY - yMin) / (float) (yMax - yMin);
- scrollAmount = Math.max(0, Math.min(1, scrollAmount));
- }
- }
+ Minecraft.getMinecraft().getTextureManager().bindTexture(creativeInventoryTabs);
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ this.drawTexturedModalRect(guiLeft + 175, guiTop + 18 + (int) ((95 + ySplitSize * 2) * scrollAmount),
+ 256 - (scrollClicked ? 12 : 24), 0, 12, 15
+ );
+
+ if (!NotEnoughUpdates.INSTANCE.config.neuAuctionHouse.enableNeuAuctionHouse) {
+ Utils.drawStringCentered(EnumChatFormatting.RED + "NEUAH is DISABLED! Enable in /neu.",
+ Minecraft.getMinecraft().fontRendererObj, guiLeft + getXSize() / 2, guiTop + getYSize() / 2 - 5, true, 0
+ );
+ }
+
+ if (tooltipToRender != null) {
+ List<String> tooltipGray = new ArrayList<>();
+ for (String line : tooltipToRender) {
+ tooltipGray.add(EnumChatFormatting.GRAY + line);
+ }
+ Utils.drawHoveringText(tooltipGray, mouseX, mouseY, width,
+ height, -1, Minecraft.getMinecraft().fontRendererObj
+ );
+ }
+ float slideAmount = 1 - Math.max(0, Math.min(1, (System.currentTimeMillis() - lastGuiScreenSwitch) / 200f));
+ int auctionViewLeft = guiLeft + getXSize() + 4 - (int) (slideAmount * (78 + 4));
+
+ // Price filter
+ if (!hasPopup && NotEnoughUpdates.INSTANCE.config.neuAuctionHouse.priceFiltering) {
+ // Price bid filter
+ priceFilterField.xPosition = auctionViewLeft + 18;
+ priceFilterField.yPosition = guiTop + 18;
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(auction_price);
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ this.drawTexturedModalRect(auctionViewLeft, guiTop, 0, 0, 96, 83);
+ if (getPriceFilterAmount() == -1) {
+ priceFilterField.setTextColor(Color.RED.getRGB());
+ } else {
+ priceFilterField.setTextColor(16777215);
+ }
+ priceFilterField.drawTextBox();
+
+ Utils.drawStringCenteredScaledMaxWidth("Price Filter", Minecraft.getMinecraft().fontRendererObj,
+ auctionViewLeft + 39, guiTop + 10, false, 70, 4210752
+ );
+
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(auction_view_buttons);
+ if (currentPriceFilterType == PriceFilter.Less) {
+ this.drawTexturedModalRect(auctionViewLeft + 16, guiTop + 32, 30, 16, 30, 16);
+ } else {
+ this.drawTexturedModalRect(auctionViewLeft + 16, guiTop + 32, 0, 16, 30, 16);
+ }
+ if (currentPriceFilterType == PriceFilter.Greater) {
+ this.drawTexturedModalRect(auctionViewLeft + 16 + 34, guiTop + 32, 30, 16, 30, 16);
+ } else {
+ this.drawTexturedModalRect(auctionViewLeft + 16 + 34, guiTop + 32, 0, 16, 30, 16);
+ }
+ if (currentPriceFilterType == PriceFilter.Equal) {
+ this.drawTexturedModalRect(auctionViewLeft + 16, guiTop + 50, 64, 32, 64, 16);
+ } else {
+ this.drawTexturedModalRect(auctionViewLeft + 16, guiTop + 50, 0, 32, 64, 16);
+ }
+
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+ Utils.drawStringCentered("<=", fr, auctionViewLeft + 16 + 15, guiTop + 32 + 8, false,
+ Color.BLACK.getRGB()
+ );
+ Utils.drawStringCentered(">=", fr, auctionViewLeft + 16 + 34 + 15, guiTop + 32 + 8, false,
+ Color.BLACK.getRGB()
+ );
+ Utils.drawStringCentered("==", fr, auctionViewLeft + 16 + 32, guiTop + 50 + 8, false,
+ Color.BLACK.getRGB()
+ );
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+
+ // Bin average price filter
+ binPriceFilterField.xPosition = auctionViewLeft + 18;
+ binPriceFilterField.yPosition = guiTop + 18 + binPriceFilterYOffset;
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(auction_price);
+ this.drawTexturedModalRect(auctionViewLeft, guiTop + binPriceFilterYOffset, 0, 0, 96, 83);
+ if (getBinPriceFilterAmount() == -1) {
+ binPriceFilterField.setTextColor(Color.RED.getRGB());
+ } else {
+ binPriceFilterField.setTextColor(16777215);
+ }
+ binPriceFilterField.drawTextBox();
+
+ Utils.drawStringCenteredScaledMaxWidth("BIN Average Filter", Minecraft.getMinecraft().fontRendererObj,
+ auctionViewLeft + 39, guiTop + 10 + binPriceFilterYOffset, false, 70, 4210752
+ );
+
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(auction_view_buttons);
+ if (currentBinPriceFilterType == PriceFilter.Less) {
+ this.drawTexturedModalRect(auctionViewLeft + 16, guiTop + 32 + binPriceFilterYOffset, 30, 16, 30, 16);
+ } else {
+ this.drawTexturedModalRect(auctionViewLeft + 16, guiTop + 32 + binPriceFilterYOffset, 0, 16, 30, 16);
+ }
+ if (currentBinPriceFilterType == PriceFilter.Greater) {
+ this.drawTexturedModalRect(auctionViewLeft + 16 + 34, guiTop + 32 + binPriceFilterYOffset, 30, 16, 30, 16);
+ } else {
+ this.drawTexturedModalRect(auctionViewLeft + 16 + 34, guiTop + 32 + binPriceFilterYOffset, 0, 16, 30, 16);
+ }
+ if (currentBinPriceFilterType == PriceFilter.Equal) {
+ this.drawTexturedModalRect(auctionViewLeft + 16, guiTop + 50 + binPriceFilterYOffset, 64, 32, 64, 16);
+ } else {
+ this.drawTexturedModalRect(auctionViewLeft + 16, guiTop + 50 + binPriceFilterYOffset, 0, 32, 64, 16);
+ }
+
+ Utils.drawStringCentered("<=", fr, auctionViewLeft + 16 + 15, guiTop + 32 + 8 + binPriceFilterYOffset, false,
+ Color.BLACK.getRGB()
+ );
+ Utils.drawStringCentered(">=", fr, auctionViewLeft + 16 + 34 + 15, guiTop + 32 + 8 + binPriceFilterYOffset, false,
+ Color.BLACK.getRGB()
+ );
+ Utils.drawStringCentered("==", fr, auctionViewLeft + 16 + 32, guiTop + 50 + 8 + binPriceFilterYOffset, false,
+ Color.BLACK.getRGB()
+ );
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ }
+ }
+
+ public List<String> getTooltipForControl(int index) {
+ List<String> lore = new ArrayList<>();
+ if (index < 0 || index >= controls.length) return lore;
+ if (controls[index] == null) return lore;
+
+ lore.add(controls[index].getDisplayName());
+ String arrow = "\u25b6";
+ String selPrefixNC = " " + arrow + " ";
+ String selPrefix = EnumChatFormatting.DARK_AQUA + selPrefixNC;
+ String unselPrefix = EnumChatFormatting.GRAY.toString();
+ switch (index) {
+ case 0:
+ lore.add("");
+ String gold = EnumChatFormatting.GOLD.toString();
+ String gray = EnumChatFormatting.GRAY.toString();
+ char s = 0x272A;
+ String[] linesDung = {
+ "Show All", "Any Dungeon",
+ gold + s + gray + s + s + s + s,
+ gold + s + s + gray + s + s + s,
+ gold + s + s + s + gray + s + s,
+ gold + s + s + s + s + gray + s,
+ gold + s + s + s + s + s
+ };
+ for (int i = 0; i < linesDung.length; i++) {
+ String line = linesDung[i];
+ if (i == dungeonFilter) {
+ line = selPrefix + line.replace(gray, EnumChatFormatting.DARK_AQUA.toString());
+ } else {
+ line = unselPrefix + line;
+ }
+ lore.add(line);
+ }
+ lore.add("");
+ lore.add(EnumChatFormatting.AQUA + "Right-Click to go backwards!");
+ lore.add(EnumChatFormatting.YELLOW + "Click to switch sort!");
+ return lore;
+ case 1:
+ lore.add("");
+ String[] linesSort = {"Highest Bid", "Lowest Bid", "Ending soon"};
+ for (int i = 0; i < linesSort.length; i++) {
+ String line = linesSort[i];
+ if (i == sortMode) {
+ line = selPrefix + line;
+ } else {
+ line = unselPrefix + line;
+ }
+ lore.add(line);
+ }
+ lore.add("");
+ lore.add(EnumChatFormatting.YELLOW + "Click to switch sort!");
+ return lore;
+ case 2:
+ lore.add("");
+ lore.add((rarityFilter == -1 ? EnumChatFormatting.DARK_GRAY + selPrefixNC : unselPrefix) + "No Filter");
+
+ for (int i = 0; i < Utils.rarityArr.length; i++) {
+ lore.add((rarityFilter == i ? rarityColours[i] + selPrefixNC : unselPrefix) +
+ Utils.prettyCase(Utils.rarityArr[i]));
+ }
+ lore.add("");
+ lore.add(EnumChatFormatting.AQUA + "Right-Click to go backwards!");
+ lore.add(EnumChatFormatting.YELLOW + "Click to switch filter!");
+ return lore;
+ case 3:
+ break;
+ case 4:
+ lore.add("");
+ String off = EnumChatFormatting.RED + "OFF";
+ String on = EnumChatFormatting.GREEN + "ON";
+ lore.add(unselPrefix + "Filter Own Auctions: " + (filterMyAuctions ? on : off));
+ lore.add("");
+ lore.add(EnumChatFormatting.YELLOW + "Click to toggle!");
+ return lore;
+ case 5:
+ break;
+ case 6:
+ lore.add("");
+ String[] linesBin = {"Show All", "BIN Only", "Auctions Only"};
+ for (int i = 0; i < linesBin.length; i++) {
+ String line = linesBin[i];
+ if (i == binFilter) {
+ line = selPrefix + line;
+ } else {
+ line = unselPrefix + line;
+ }
+ lore.add(line);
+ }
+ lore.add("");
+ lore.add(EnumChatFormatting.AQUA + "Right-Click to go backwards!");
+ lore.add(EnumChatFormatting.YELLOW + "Click to switch filter!");
+ return lore;
+ case 7:
+ lore.add("");
+ String[] linesEnch = {"Show All", "Clean Only", "Ench Only", "Ench/HPB Only"};
+ for (int i = 0; i < linesEnch.length; i++) {
+ String line = linesEnch[i];
+ if (i == enchFilter) {
+ line = selPrefix + line;
+ } else {
+ line = unselPrefix + line;
+ }
+ lore.add(line);
+ }
+ lore.add("");
+ lore.add(EnumChatFormatting.AQUA + "Right-Click to go backwards!");
+ lore.add(EnumChatFormatting.YELLOW + "Click to switch filter!");
+ return lore;
+ case 8:
+ lore.add("");
+ lore.add("Current aucid: " + currentAucId);
+ if (currentAucId != null) {
+ APIManager.Auction auc = manager.auctionManager.getAuctionItems().get(currentAucId);
+ if (auc != null) {
+ lore.add("Current auc category: " + auc.category);
+ }
+ }
+ lore.add(" --- Processing");
+ lore.add("Page Process Millis: " + manager.auctionManager.processMillis);
+ lore.add(" --- Auction Stats");
+ lore.add("Active Auctions: " + manager.auctionManager.activeAuctions);
+ lore.add("Tracked Auctions: " + manager.auctionManager.getAuctionItems().size());
+ lore.add("Displayed Auctions: " + auctionIds.size());
+ lore.add("Tracked Player Auctions: " + manager.auctionManager.getPlayerBids().size());
+ lore.add("Unique Items: " + manager.auctionManager.uniqueItems);
+ lore.add("ID Tagged Auctions: " + manager.auctionManager.internalnameTaggedAuctions);
+ lore.add("Total Tags: " + manager.auctionManager.totalTags);
+ lore.add("Tagged Auctions: " + manager.auctionManager.taggedAuctions);
+ lore.add("");
+ lore.add(EnumChatFormatting.AQUA + "Right-Click to copy current aucid to clipboard!");
+ lore.add(EnumChatFormatting.YELLOW + "Click to refresh!");
+ return lore;
+ }
+ return new ArrayList<>();
+ }
+
+ public void handleMouseInput() {
+ if (!NotEnoughUpdates.INSTANCE.config.neuAuctionHouse.enableNeuAuctionHouse) {
+ return;
+ }
+
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ int width = scaledResolution.getScaledWidth();
+ int height = scaledResolution.getScaledHeight();
+
+ int mouseX = Mouse.getEventX() * width / Minecraft.getMinecraft().displayWidth;
+ int mouseY = height - Mouse.getEventY() * height / Minecraft.getMinecraft().displayHeight - 1;
+ int mouseButton = Mouse.getEventButton();
+
+ if (Mouse.getEventButtonState()) {
+ this.eventButton = mouseButton;
+ this.lastMouseEvent = Minecraft.getSystemTime();
+ mouseClicked(mouseX, mouseY, this.eventButton);
+ } else if (mouseButton != -1) {
+ this.eventButton = -1;
+ mouseReleased(mouseX, mouseY, mouseButton);
+ } else if (this.eventButton != -1 && this.lastMouseEvent > 0L) {
+ long l = Minecraft.getSystemTime() - this.lastMouseEvent;
+ mouseClickMove(mouseX, mouseY, this.eventButton, l);
+ }
+
+ if (!NotEnoughUpdates.INSTANCE.config.neuAuctionHouse.disableAhScroll) {
+ int dWheel = Mouse.getEventDWheel();
+ dWheel = Math.max(-1, Math.min(1, dWheel));
+
+ scrollAmount = scrollAmount - dWheel / (float) (auctionIds.size() / 9 - (5 + splits));
+ scrollAmount = Math.max(0, Math.min(1, scrollAmount));
+ }
+ }
+
+ public String niceAucId(String aucId) {
+ if (aucId.length() != 32) return aucId;
+
+ return aucId.substring(0, 8) +
+ "-" + aucId.substring(8, 12) +
+ "-" + aucId.substring(12, 16) +
+ "-" + aucId.substring(16, 20) +
+ "-" + aucId.substring(20, 32);
+ }
+
+ public Category getCurrentCategory() {
+ if (clickedMainCategory < 0 || clickedMainCategory >= mainCategories.length) {
+ return null;
+ }
+ Category mainCategory = mainCategories[clickedMainCategory];
+ if (clickedSubCategory < 0 || clickedSubCategory >= mainCategory.subcategories.length) {
+ return mainCategory;
+ }
+ return mainCategory.subcategories[clickedSubCategory];
+ }
+
+ private boolean doesAucMatch(APIManager.Auction auc) {
+ if (auc == null) return false;
+
+ Category currentCategory = getCurrentCategory();
+
+ boolean match = true;
+ if (currentCategory != null) {
+ match = false;
+ String[] categories = currentCategory.getTotalCategories();
+ for (String category : categories) {
+ match |= category.equalsIgnoreCase(auc.category);
+ }
+ }
+
+ if (rarityFilter >= 0 && rarityFilter < Utils.rarityArr.length) {
+ match &= Utils.rarityArr[rarityFilter].equals(auc.rarity);
+ }
+
+ if (binFilter == BIN_FILTER_BIN) {
+ match &= auc.bin;
+ } else if (binFilter == BIN_FILTER_AUC) {
+ match &= !auc.bin;
+ }
+
+ if (enchFilter > ENCH_FILTER_ALL) {
+ switch (enchFilter) {
+ case ENCH_FILTER_CLEAN:
+ match &= auc.enchLevel == 0;
+ break;
+ case ENCH_FILTER_ENCH:
+ match &= auc.enchLevel >= 1;
+ break;
+ case ENCH_FILTER_ENCHHPB:
+ match &= auc.enchLevel == 2;
+ break;
+ }
+ }
+
+ if (dungeonFilter > DUNGEON_FILTER_ALL) {
+ if (dungeonFilter == DUNGEON_FILTER_DUNGEON && auc.dungeonTier < 0) {
+ match = false;
+ } else {
+ match &= dungeonFilter == auc.dungeonTier + 1;
+ }
+ }
+
+ if (getPriceFilterAmount() > -1) {
+ if (currentPriceFilterType == PriceFilter.Greater) {
+ match &= auc.highest_bid_amount != 0
+ ? (auc.highest_bid_amount >= getPriceFilterAmount())
+ : auc.starting_bid >= getPriceFilterAmount();
+ }
+ if (currentPriceFilterType == PriceFilter.Less) {
+ match &= auc.highest_bid_amount != 0
+ ? (auc.highest_bid_amount <= getPriceFilterAmount())
+ : auc.starting_bid <= getPriceFilterAmount();
+ }
+ if (currentPriceFilterType == PriceFilter.Equal) {
+ match &= auc.highest_bid_amount != 0
+ ? (auc.highest_bid_amount == getPriceFilterAmount())
+ : auc.starting_bid == getPriceFilterAmount();
+ }
+ }
+ if (getBinPriceFilterAmount() > -1) {
+ int lowestBin =
+ NotEnoughUpdates.INSTANCE.manager.auctionManager.getLowestBin(NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(
+ auc.getStack()));
+ if (lowestBin > 0) {
+ if (currentBinPriceFilterType == PriceFilter.Greater) {
+ match &= lowestBin >= getBinPriceFilterAmount();
+ }
+ if (currentBinPriceFilterType == PriceFilter.Less) {
+ match &= lowestBin <= getBinPriceFilterAmount();
+ }
+ if (currentBinPriceFilterType == PriceFilter.Equal) {
+ match &= lowestBin == getBinPriceFilterAmount();
+ }
+ } else {
+ match = false;
+ }
+ }
+ return match;
+ }
+
+ private HashSet<String> search(String query, Set<String> dontMatch) {
+ query = query.trim();
+ HashSet<String> matches = new HashSet<>();
+
+ Set<String> itemMatches = manager.search(query);
+ for (String internalname : itemMatches) {
+ for (String aucid : manager.auctionManager.getAuctionsForInternalname(internalname)) {
+ APIManager.Auction auc = manager.auctionManager.getAuctionItems().get(aucid);
+ if (doesAucMatch(auc)) {
+ //matches.add(aucid);
+ } else {
+ dontMatch.add(aucid);
+ }
+ }
+ }
+
+ HashMap<String, List<Integer>> extrasMatches = new HashMap<>();
+ HashMap<String, List<Integer>> extrasMatchesCurrent = new HashMap<>();
+ boolean first = true;
+ for (String subQuery : query.split(" ")) {
+ for (HashMap<Integer, HashSet<String>> extrasMap : manager.subMapWithKeysThatAreSuffixes(
+ subQuery.toLowerCase(),
+ manager.auctionManager.extrasToAucIdMap
+ ).values()) {
+ for (int index : extrasMap.keySet()) {
+ for (String aucid : extrasMap.get(index)) {
+ APIManager.Auction auc = manager.auctionManager.getAuctionItems().get(aucid);
+ if (!dontMatch.contains(aucid) && doesAucMatch(auc)) {
+ if (first) {
+ List<Integer> indexList = extrasMatchesCurrent.computeIfAbsent(aucid, k -> new ArrayList<>());
+ indexList.add(index);
+ } else {
+ List<Integer> indexList = extrasMatches.computeIfAbsent(aucid, k -> new ArrayList<>());
+ if (indexList.contains(index - 1)) {
+ List<Integer> indexListCurrent = extrasMatchesCurrent.computeIfAbsent(aucid, k -> new ArrayList<>());
+ indexListCurrent.add(index);
+ }
+ }
+ } else {
+ dontMatch.add(aucid);
+ }
+ }
+ }
+
+ }
+
+ extrasMatches = (HashMap<String, List<Integer>>) extrasMatchesCurrent.clone();
+ extrasMatchesCurrent.clear();
+ first = false;
+ }
+ matches.addAll(extrasMatches.keySet());
+
+ return matches;
+ }
+
+ private final ExecutorService es = Executors.newSingleThreadExecutor();
+
+ public void updateSearch() {
+ if (!NotEnoughUpdates.INSTANCE.config.neuAuctionHouse.enableNeuAuctionHouse) {
+ return;
+ }
+
+ if (searchField == null || priceField == null || priceFilterField == null || binPriceFilterField == null)
+ init();
+ long currentTime = System.currentTimeMillis();
+
+ es.submit(() -> {
+ if (currentTime - lastUpdateSearch < 100) {
+ shouldUpdateSearch = true;
+ return;
+ }
+
+ lastUpdateSearch = currentTime;
+ shouldUpdateSearch = false;
+
+ scrollAmount = 0;
+ try {
+ HashSet<String> auctionIdsNew = new HashSet<>();
+ auctionIdsNew.clear();
+ if (filterMyAuctions) {
+ for (String aucid : manager.auctionManager.getPlayerBids()) {
+ APIManager.Auction auc = manager.auctionManager.getAuctionItems().get(aucid);
+ if (doesAucMatch(auc)) {
+ auctionIdsNew.add(aucid);
+ }
+ }
+ } else if (searchField.getText().length() == 0) {
+ for (Map.Entry<String, APIManager.Auction> entry : manager.auctionManager.getAuctionItems().entrySet()) {
+ if (doesAucMatch(entry.getValue())) {
+ auctionIdsNew.add(entry.getKey());
+ }
+ }
+ } else {
+ String query = searchField.getText();
+ Set<String> dontMatch = new HashSet<>();
+
+ HashSet<String> allMatch = new HashSet<>();
+ if (query.contains("!")) { //only used for inverted queries, so dont need to populate unless ! in query
+ for (Map.Entry<String, APIManager.Auction> entry : manager.auctionManager.getAuctionItems().entrySet()) {
+ if (doesAucMatch(entry.getValue())) {
+ allMatch.add(entry.getKey());
+ } else {
+ dontMatch.add(entry.getKey());
+ }
+ }
+ }
+
+ boolean invert = false;
+
+ StringBuilder query2 = new StringBuilder();
+ char lastOp = '|';
+ for (char c : query.toCharArray()) {
+ if (query2.toString().trim().isEmpty() && c == '!') {
+ invert = true;
+ } else if (c == '|' || c == '&') {
+ if (lastOp == '|') {
+ HashSet<String> result = search(query2.toString(), dontMatch);
+ if (!invert) {
+ auctionIdsNew.addAll(result);
+ } else {
+ HashSet<String> allClone = (HashSet<String>) allMatch.clone();
+ allClone.removeAll(result);
+ auctionIdsNew.addAll(allClone);
+ }
+ } else if (lastOp == '&') {
+ HashSet<String> result = search(query2.toString(), dontMatch);
+ if (!invert) {
+ auctionIdsNew.retainAll(result);
+ } else {
+ auctionIdsNew.removeAll(result);
+ }
+ }
+
+ query2 = new StringBuilder();
+ invert = false;
+ lastOp = c;
+ } else {
+ query2.append(c);
+ }
+ }
+ if (lastOp == '|') {
+ HashSet<String> result = search(query2.toString(), dontMatch);
+ if (!invert) {
+ auctionIdsNew.addAll(result);
+ } else {
+ HashSet<String> allClone = (HashSet<String>) allMatch.clone();
+ allClone.removeAll(result);
+ auctionIdsNew.addAll(allClone);
+ }
+ } else if (lastOp == '&') {
+ HashSet<String> result = search(query2.toString(), dontMatch);
+ if (!invert) {
+ auctionIdsNew.retainAll(result);
+ } else {
+ auctionIdsNew.removeAll(result);
+ }
+ }
+ }
+ auctionIds = auctionIdsNew;
+ sortItems();
+ } catch (Exception e) {
+ shouldUpdateSearch = true;
+ }
+ });
+ }
+
+ public void sortItems() throws ConcurrentModificationException {
+ if (!NotEnoughUpdates.INSTANCE.config.neuAuctionHouse.enableNeuAuctionHouse) {
+ return;
+ }
+
+ try {
+ List<String> sortedAuctionIdsNew = new ArrayList<>();
+
+ sortedAuctionIdsNew.addAll(auctionIds);
+ sortedAuctionIdsNew.sort((o1, o2) -> {
+ APIManager.Auction auc1 = manager.auctionManager.getAuctionItems().get(o1);
+ APIManager.Auction auc2 = manager.auctionManager.getAuctionItems().get(o2);
+
+ if (auc1 == null) return 1;
+ if (auc2 == null) return -1;
+
+ if (sortMode == SORT_MODE_HIGH) {
+ int price1 = Math.max(auc1.highest_bid_amount, auc1.starting_bid);
+ int price2 = Math.max(auc2.highest_bid_amount, auc2.starting_bid);
+ int diff = price2 - price1;
+ if (diff != 0) {
+ return diff;
+ }
+ } else if (sortMode == SORT_MODE_LOW) {
+ int price1 = Math.max(auc1.highest_bid_amount, auc1.starting_bid);
+ int price2 = Math.max(auc2.highest_bid_amount, auc2.starting_bid);
+ int diff = price1 - price2;
+ if (diff != 0) {
+ return diff;
+ }
+ } else {
+ long end1 = auc1.end;
+ long end2 = auc2.end;
+
+ if (end1 < System.currentTimeMillis()) return 999999;
+ if (end2 < System.currentTimeMillis()) return -999999;
+
+ int diff = (int) (end1 - end2);
+ if (diff != 0) {
+ return diff;
+ }
+ }
+ return o1.compareTo(o2);
+ });
+
+ sortedAuctionIds = sortedAuctionIdsNew;
+ } catch (Exception e) {
+ shouldSortItems = true;
+ }
+ }
+
+ public boolean keyboardInput() {
+ if (!NotEnoughUpdates.INSTANCE.config.neuAuctionHouse.enableNeuAuctionHouse) {
+ return false;
+ }
+
+ Keyboard.enableRepeatEvents(true);
+ if (isEditingPrice() && Keyboard.getEventKey() == Keyboard.KEY_RETURN) {
+ Minecraft.getMinecraft().displayGuiScreen(null);
+ } else if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
+ if (Minecraft.getMinecraft().currentScreen instanceof GuiEditSign) {
+ priceField.setText("");
+ GuiEditSign editSign = (GuiEditSign) Minecraft.getMinecraft().currentScreen;
+ TileEntitySign tes = (TileEntitySign) Utils.getField(GuiEditSign.class, editSign,
+ "tileSign", "field_146848_f"
+ );
+ tes.lineBeingEdited = 0;
+ tes.signText[0] = new ChatComponentText(priceField.getText());
+ }
+ return false;
+ }
+ if (Keyboard.getEventKeyState()) return keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey());
+ return true;
+ }
+
+ public boolean keyTyped(char typedChar, int keyCode) {
+ if (searchField == null || priceField == null || priceFilterField == null || binPriceFilterField == null)
+ init();
+
+ if (!isEditingPrice()) {
+ if (this.priceFilterField.textboxKeyTyped(typedChar, keyCode)) {
+ this.updateSearch();
+ return true;
+ }
+ if (this.binPriceFilterField.textboxKeyTyped(typedChar, keyCode)) {
+ this.updateSearch();
+ return true;
+ }
+ if (this.searchField.textboxKeyTyped(typedChar, keyCode)) {
+ lastSearchFieldUpdate = System.currentTimeMillis();
+ this.updateSearch();
+ return true;
+ }
+ } else {
+ if (!priceField.isFocused()) priceField.setFocused(searchField.isFocused() && priceFilterField.isFocused());
+ return priceField.textboxKeyTyped(typedChar, keyCode);
+ }
+ return false;
+ }
+
+ private void increasePriceByFactor(float factor) {
+ String price = priceField.getText().trim();
+ StringBuilder priceNumbers = new StringBuilder();
+ for (int i = 0; i < price.length(); i++) {
+ char c = price.charAt(i);
+ if ((int) c >= 48 && (int) c <= 57) {
+ priceNumbers.append(c);
+ } else {
+ break;
+ }
+ }
+ int priceI = 0;
+ if (priceNumbers.length() > 0) {
+ priceI = Integer.parseInt(priceNumbers.toString());
+ }
+ String end = price.substring(priceNumbers.length());
+ priceField.setText((int) (priceI * factor) + end);
+ }
+
+ private int getPriceFilterAmount() {
+ return getNumberFromTextBox(priceFilterField);
+ }
+
+ private int getNumberFromTextBox(GuiTextField textField) {
+ if (textField.getText().equals("")) {
+ return -2;
+ }
+ try {
+ int parsed = Integer.parseInt(textField.getText());
+ if (parsed < 0) {
+ return -1;
+ }
+ return parsed;
+ } catch (NumberFormatException e) {
+ return -1;
+ }
+ }
+
+ private int getBinPriceFilterAmount() {
+ return getNumberFromTextBox(binPriceFilterField);
+ }
+
+ protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
+ boolean wasFocused = searchField.isFocused();
+ searchField.mouseClicked(mouseX, mouseY, mouseButton);
+ if (mouseButton == 1 && !wasFocused && searchField.isFocused()) {
+ searchField.setText("");
+ }
+ priceField.mouseClicked(mouseX, mouseY, mouseButton);
+ priceFilterField.mouseClicked(mouseX, mouseY, mouseButton);
+ binPriceFilterField.mouseClicked(mouseX, mouseY, mouseButton);
+
+ int totalItems = auctionIds.size();
+ int itemsScroll = (int) Math.floor((totalItems * scrollAmount) / 9f) * 9;
+
+ int maxItemScroll = Math.max(0, totalItems - (5 + splits) * 9);
+ itemsScroll = Math.min(itemsScroll, maxItemScroll);
+
+ //Categories
+ if (mouseY > guiTop - 28 && mouseY < guiTop + 4) {
+ if (mouseX > guiLeft && mouseX < guiLeft + 168) {
+ int offset = mouseX - guiLeft;
+ int clickedCat = offset / 28;
+ if (clickedMainCategory == clickedCat) {
+ clickedMainCategory = -1;
+ } else {
+ clickedMainCategory = clickedCat;
+ }
+ clickedSubCategory = -1;
+ updateSearch();
+ Utils.playPressSound();
+ return;
+ }
+ }
+
+ if (clickedMainCategory >= 0 && clickedMainCategory < mainCategories.length) {
+ Category mainCategory = mainCategories[clickedMainCategory];
+
+ if (mouseX > guiLeft - 28 && mouseX < guiLeft) {
+ int offset = mouseY - (guiTop + 17);
+ if (offset > 0) {
+ int clicked = offset / 28 - 1;
+ if (clicked != clickedSubCategory && clicked < mainCategory.subcategories.length) {
+ clickedSubCategory = clicked;
+ updateSearch();
+ Utils.playPressSound();
+ return;
+ }
+ }
+ }
+ }
+
+ if (mouseY > guiTop + 112 + 18 * splits && mouseY < guiTop + 112 + 18 * splits + 16) {
+ if (mouseX > guiLeft + 9 && mouseX < guiLeft + 9 + controls.length * 18 - 2) {
+ int offset = mouseX - (guiLeft + 9);
+ int index = offset / 18;
+ boolean rightClicked = Mouse.getEventButton() == 1;
+ switch (index) {
+ case 0:
+ if (rightClicked) {
+ dungeonFilter--;
+ if (dungeonFilter < DUNGEON_FILTER_ALL) dungeonFilter = DUNGEON_FILTER_5;
+ } else {
+ dungeonFilter++;
+ if (dungeonFilter > DUNGEON_FILTER_5) dungeonFilter = DUNGEON_FILTER_ALL;
+ }
+ break;
+ case 1:
+ if (rightClicked) {
+ sortMode--;
+ if (sortMode < SORT_MODE_HIGH) sortMode = SORT_MODE_SOON;
+ } else {
+ sortMode++;
+ if (sortMode > SORT_MODE_SOON) sortMode = SORT_MODE_HIGH;
+ }
+ break;
+ case 2:
+ if (rightClicked) {
+ rarityFilter--;
+ if (rarityFilter < -1) rarityFilter = Utils.rarityArr.length - 1;
+ } else {
+ rarityFilter++;
+ if (rarityFilter >= Utils.rarityArr.length) rarityFilter = -1;
+ }
+ break;
+ case 3:
+ break;
+ case 4:
+ filterMyAuctions = !filterMyAuctions;
+ break;
+ case 5:
+ break;
+ case 6:
+ if (rightClicked) {
+ binFilter--;
+ if (binFilter < BIN_FILTER_ALL) binFilter = BIN_FILTER_AUC;
+ } else {
+ binFilter++;
+ if (binFilter > BIN_FILTER_AUC) binFilter = BIN_FILTER_ALL;
+ }
+ break;
+ case 7:
+ if (rightClicked) {
+ enchFilter--;
+ if (enchFilter < ENCH_FILTER_ALL) enchFilter = ENCH_FILTER_ENCHHPB;
+ } else {
+ enchFilter++;
+ if (enchFilter > ENCH_FILTER_ENCHHPB) enchFilter = ENCH_FILTER_ALL;
+ }
+ break;
+ case 8:
+ if (rightClicked) {
+ if (currentAucId != null) {
+ StringSelection selection = new StringSelection(niceAucId(currentAucId));
+ Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, selection);
+ }
+ } else {
+ manager.auctionManager.calculateStats();
+ }
+ }
+ updateSearch();
+ Utils.playPressSound();
+ }
+ }
+ boolean hasPopup = false;
+ if (mouseButton == 0 && Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
+ hasPopup = true;
+ GuiChest auctionView = (GuiChest) Minecraft.getMinecraft().currentScreen;
+ ContainerChest container = (ContainerChest) auctionView.inventorySlots;
+ String containerName = container.getLowerChestInventory().getDisplayName().getUnformattedText();
+
+ if (containerName.trim().equals("Auction View") || containerName.trim().equals("BIN Auction View")) {
+
+ if (mouseX > guiLeft + getXSize() + 4 + 31 && mouseX < guiLeft + getXSize() + 4 + 31 + 16) {
+ boolean leftFiller = isGuiFiller(auctionView.inventorySlots.getSlot(29).getStack());//isBin
+ if (mouseY > guiTop + 35 && mouseY < guiTop + 35 + 16) {
+ ItemStack topStack = auctionView.inventorySlots.getSlot(13).getStack();
+ if (topStack != null) {
+ String line = findStrStart(topStack, EnumChatFormatting.GRAY + "Seller: ");
+ String[] split = line.split(" ");
+ String seller = split[split.length - 1];
+ StringSelection selection = new StringSelection(seller);
+ Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, selection);
+ }
+ } else if (mouseY > guiTop + 100 && mouseY < guiTop + 100 + 16) {
+ int slotClick = leftFiller ? 31 : 29;
+ Minecraft.getMinecraft().playerController.windowClick(auctionView.inventorySlots.windowId,
+ slotClick, 2, 3, Minecraft.getMinecraft().thePlayer
+ );
+
+ if (!leftFiller) {
+ if (auctionView.inventorySlots.getSlot(29).getStack()
+ .getDisplayName().trim().equals(
+ EnumChatFormatting.GOLD + "Collect Auction")) {
+ manager.auctionManager.getPlayerBids().remove(currentAucId);
+ auctionIds.remove(currentAucId);
+ }
+ }
+
+ Utils.playPressSound();
+ } else if (mouseY > guiTop + 126 && mouseY < guiTop + 126 + 16 && !leftFiller) {
+ priceField.setFocused(true);
+ Minecraft.getMinecraft().playerController.windowClick(auctionView.inventorySlots.windowId,
+ 31, 2, 3, Minecraft.getMinecraft().thePlayer
+ );
+ Utils.playPressSound();
+ }
+ }
+ } else if (containerName.trim().equals("Confirm Bid") || containerName.trim().equals("Confirm Purchase")) {
+ if (mouseX > guiLeft + getXSize() + 4 + 31 && mouseX < guiLeft + getXSize() + 4 + 31 + 16) {
+ if (mouseY > guiTop + 31 && mouseY < guiTop + 31 + 16) {
+ if (currentAucId != null) {
+ manager.auctionManager.getPlayerBids().add(currentAucId);
+ latestBid = currentAucId;
+ latestBidMillis = System.currentTimeMillis();
+ //reset timer to 2m if below
+ if (manager.auctionManager.getAuctionItems().get(currentAucId) != null &&
+ manager.auctionManager.getAuctionItems().get(currentAucId).end -
+ System.currentTimeMillis() < 2 * 60 * 1000) {
+ manager.auctionManager.getAuctionItems().get(currentAucId).end =
+ System.currentTimeMillis() + 2 * 60 * 1000;
+ }
+ }
+ Minecraft.getMinecraft().playerController.windowClick(auctionView.inventorySlots.windowId,
+ 11, 2, 3, Minecraft.getMinecraft().thePlayer
+ );
+ } else if (mouseY > guiTop + 125 && mouseY < guiTop + 125 + 16) {
+ Minecraft.getMinecraft().playerController.windowClick(auctionView.inventorySlots.windowId,
+ 15, 2, 3, Minecraft.getMinecraft().thePlayer
+ );
+ }
+ Utils.playPressSound();
+ }
+ }
+ }
+ int auctionViewLeft = guiLeft + getXSize() + 4;
+
+ if (mouseButton == 0 && isEditingPrice()) {
+
+ if (mouseX > auctionViewLeft + 16 && mouseX < auctionViewLeft + 16 + 64) {
+ if (mouseY > guiTop + 32 && mouseY < guiTop + 32 + 16) {
+ if (mouseX < auctionViewLeft + 16 + 32) {
+ //top left
+ increasePriceByFactor(2);
+ } else {
+ //top right
+ increasePriceByFactor(1.5f);
+ }
+ Utils.playPressSound();
+ } else if (mouseY > guiTop + 50 && mouseY < guiTop + 50 + 16) {
+ if (mouseX < auctionViewLeft + 16 + 32) {
+ //mid left
+ increasePriceByFactor(1.25f);
+ } else {
+ //mid right
+ increasePriceByFactor(1.1f);
+ }
+ Utils.playPressSound();
+ } else if (mouseY > guiTop + 68 && mouseY < guiTop + 68 + 16) {
+ //bottom
+ Utils.playPressSound();
+ Minecraft.getMinecraft().displayGuiScreen(null);
+ }
+ }
+
+ this.drawTexturedModalRect(auctionViewLeft + 16, guiTop + 32, 0, 16, 30, 16);
+ this.drawTexturedModalRect(auctionViewLeft + 16 + 34, guiTop + 32, 0, 16, 30, 16);
+ this.drawTexturedModalRect(auctionViewLeft + 16, guiTop + 50, 0, 16, 30, 16);
+ this.drawTexturedModalRect(auctionViewLeft + 16 + 34, guiTop + 50, 0, 16, 30, 16);
+ this.drawTexturedModalRect(auctionViewLeft + 16, guiTop + 68, 0, 32, 64, 16);
+ } else if (!hasPopup && NotEnoughUpdates.INSTANCE.config.neuAuctionHouse.priceFiltering) {
+
+ if (mouseX > auctionViewLeft + 16 && mouseX < auctionViewLeft + 16 + 64) {
+ if (mouseY > guiTop + 32 && mouseY < guiTop + 32 + 16) {
+ if (mouseX < auctionViewLeft + 16 + 32) {
+ //top left
+ currentPriceFilterType = PriceFilter.Less;
+ } else {
+ //top right
+ currentPriceFilterType = PriceFilter.Greater;
+ }
+ Utils.playPressSound();
+ updateSearch();
+ } else if (mouseY > guiTop + 50 && mouseY < guiTop + 50 + 16) {
+ //middle
+ currentPriceFilterType = PriceFilter.Equal;
+ Utils.playPressSound();
+ updateSearch();
+ }
+ }
+
+ if (mouseX > auctionViewLeft + 16 && mouseX < auctionViewLeft + 16 + 64) {
+ if (mouseY > guiTop + 32 + binPriceFilterYOffset && mouseY < guiTop + 32 + 16 + binPriceFilterYOffset) {
+ if (mouseX < auctionViewLeft + 16 + 32) {
+ //top left
+ currentBinPriceFilterType = PriceFilter.Less;
+ } else {
+ //top right
+ currentBinPriceFilterType = PriceFilter.Greater;
+ }
+ Utils.playPressSound();
+ updateSearch();
+ } else if (mouseY > guiTop + 50 + binPriceFilterYOffset && mouseY < guiTop + 50 + 16 + binPriceFilterYOffset) {
+ //middle
+ currentBinPriceFilterType = PriceFilter.Equal;
+ Utils.playPressSound();
+ updateSearch();
+ }
+ }
+ }
+ out:
+ for (int i = 0; i < 5 + splits; i++) {
+ int itemY = guiTop + i * 18 + 18;
+ for (int j = 0; j < 9; j++) {
+ int itemX = guiLeft + j * 18 + 9;
+ int id = itemsScroll + i * 9 + j;
+ if (auctionIds.size() <= id) break out;
+
+ String aucid;
+ try {
+ aucid = sortedAuctionIds.get(id);
+ } catch (IndexOutOfBoundsException e) {
+ break out;
+ }
+
+ if (aucid == null) continue;
+ APIManager.Auction auc = manager.auctionManager.getAuctionItems().get(aucid);
+ if (auc != null) {
+ if (mouseX > itemX && mouseX < itemX + 16) {
+ if (mouseY > itemY && mouseY < itemY + 16) {
+ if (Minecraft.getMinecraft().currentScreen instanceof GuiEditSign) {
+ priceField.setText("");
+ GuiEditSign editSign = (GuiEditSign) Minecraft.getMinecraft().currentScreen;
+ TileEntitySign tes = (TileEntitySign) Utils.getField(GuiEditSign.class, editSign,
+ "tileSign", "field_146848_f"
+ );
+ tes.lineBeingEdited = 0;
+ tes.signText[0] = new ChatComponentText(priceField.getText());
+ }
+ startingBid = Math.max(auc.starting_bid, auc.highest_bid_amount);
+ currAucIdSetTimer = System.currentTimeMillis();
+ currentAucId = aucid;
+
+ Minecraft.getMinecraft().thePlayer.sendChatMessage("/viewauction " + niceAucId(aucid));
+ Utils.playPressSound();
+ }
+ }
+ }
+ }
+ }
+
+ int y = guiTop + 18 + (int) ((95 + ySplitSize * 2) * scrollAmount);
+ if (mouseX > guiLeft + 175 && mouseX < guiLeft + 175 + 12) {
+ if (mouseY > y && mouseY < y + 15) {
+ scrollClicked = true;
+ return;
+ }
+ }
+ scrollClicked = false;
+ }
+
+ protected void mouseReleased(int mouseX, int mouseY, int state) {
+ scrollClicked = false;
+ }
+
+ protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
+ if (scrollClicked) {
+ int yMin = guiTop + 18 + 8;
+ int yMax = guiTop + 18 + (95 + ySplitSize * 2) + 8;
+
+ scrollAmount = (mouseY - yMin) / (float) (yMax - yMin);
+ scrollAmount = Math.max(0, Math.min(1, scrollAmount));
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAHGui.java b/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAHGui.java
index bb36d363..9311040d 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAHGui.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAHGui.java
@@ -1,16 +1,13 @@
package io.github.moulberry.notenoughupdates.auction;
import net.minecraft.client.gui.GuiScreen;
-import org.lwjgl.input.Mouse;
public class CustomAHGui extends GuiScreen {
+ public CustomAHGui() {
+ this.allowUserInput = true;
+ }
- public CustomAHGui() {
- this.allowUserInput = true;
- }
-
- public boolean doesGuiPauseGame() {
- return false;
- }
-
+ public boolean doesGuiPauseGame() {
+ return false;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/collectionlog/CollectionConstant.java b/src/main/java/io/github/moulberry/notenoughupdates/collectionlog/CollectionConstant.java
index 25f6cfca..e789e882 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/collectionlog/CollectionConstant.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/collectionlog/CollectionConstant.java
@@ -5,13 +5,11 @@ import java.util.List;
import java.util.regex.Pattern;
public class CollectionConstant {
+ public static class DropEntry {
+ public String type;
+ public Pattern regex;
+ public HashMap<String, String> items;
+ }
- public static class DropEntry {
- public String type;
- public Pattern regex;
- public HashMap<String, String> items;
- }
-
- public List<DropEntry> dropdata;
-
+ public List<DropEntry> dropdata;
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/collectionlog/GuiCollectionLog.java b/src/main/java/io/github/moulberry/notenoughupdates/collectionlog/GuiCollectionLog.java
index a2c8bfa9..dac104c6 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/collectionlog/GuiCollectionLog.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/collectionlog/GuiCollectionLog.java
@@ -12,92 +12,100 @@ import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
public class GuiCollectionLog extends GuiScreen {
-
- private static final ResourceLocation COLLECTION_LOG_TEX = new ResourceLocation("notenoughupdates:collectionlog.png");
-
- @Override
- public void drawScreen(int mouseX, int mouseY, float partialTicks) {
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- int width = scaledResolution.getScaledWidth();
- int height = scaledResolution.getScaledHeight();
-
- int colwidth = 307;
- int colheight = 187;
-
- int left = width/2 - colwidth/2;
- int top = height/2 - colheight/2;
-
- BackgroundBlur.renderBlurredBackground(10, width, height, left, top, colwidth, colheight);
- super.drawDefaultBackground();
-
- Utils.drawStringCentered("\u00a7lCollection Log", fontRendererObj, width/2, top - 27, true, 0xfff5aa00);
-
- String[] cats = {"Bosses", "Dragons", "Slayer", "Dungeons"};
-
- GlStateManager.enableDepth();
-
- GlStateManager.translate(0, 0, 2);
- for(int i=0; i<4; i++) {
- if(i == 0) {
- int offset = i == 0 ? 1 : 2;
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(COLLECTION_LOG_TEX);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(left+i*71, top-21, 71, 25,
- (71*offset)/512f, (71+71*offset)/512f, 211/512f, (211+25)/512f, GL11.GL_NEAREST);
-
- Utils.drawStringCentered(cats[i], fontRendererObj, left+i*71+71/2, top - 8, true, 0xfff5aa00);
- }
- }
-
- GlStateManager.translate(0, 0, -1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(COLLECTION_LOG_TEX);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(left, top, colwidth, colheight,
- 0, colwidth/512f, 0, colheight/512f, GL11.GL_NEAREST);
-
- GlScissorStack.push(0, top+3, width, top+colheight-6, scaledResolution);
- int catIndex = 0;
- for(int h=top+3; h<top+colheight-6; h+=24) {
- catIndex += 2;
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(COLLECTION_LOG_TEX);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(left, h, 100, 24,
- 0, 100/512f, 187/512f, 211/512f, GL11.GL_NEAREST);
-
- fontRendererObj.drawString("Thing "+catIndex, left+5, h+2, 0xfff5aa00, true);
- fontRendererObj.drawString("Thing "+(catIndex+1), left+5, h+14, 0xfff5aa00, true);
- }
- GlScissorStack.pop(scaledResolution);
-
- fontRendererObj.drawString("\u00a7lSuperior Dragon", left+119, top+8, 0xfff5aa00, true);
- fontRendererObj.drawString("Obtained: "+ EnumChatFormatting.YELLOW+"3/5", left+122, top+23, 0xfff5aa00, true);
-
- String killCountText = "Kills: " + EnumChatFormatting.WHITE + "3";
- //int killCountLen = fontRendererObj.getStringWidth(killCountText);
- fontRendererObj.drawString(killCountText, left+122, top+68, 0xfff5aa00, true);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(COLLECTION_LOG_TEX);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(left+colwidth-196, top, 196, colheight,
- (512-196)/512f, 1, 0/512f, colheight/512f, GL11.GL_NEAREST);
-
- GlStateManager.translate(0, 0, -1);
-
- for(int i=0; i<4; i++) {
- if(i != 0) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(COLLECTION_LOG_TEX);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(left+i*71, top-21, 71, 25,
- 0, 71/512f, 211/512f, (211+25)/512f, GL11.GL_NEAREST);
-
- Utils.drawStringCentered(cats[i], fontRendererObj, left+i*71+71/2, top - 8, true, 0xfff5aa00);
- }
- }
-
-
-
- super.drawScreen(mouseX, mouseY, partialTicks);
- }
+ private static final ResourceLocation COLLECTION_LOG_TEX = new ResourceLocation("notenoughupdates:collectionlog.png");
+
+ @Override
+ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ int width = scaledResolution.getScaledWidth();
+ int height = scaledResolution.getScaledHeight();
+
+ int colwidth = 307;
+ int colheight = 187;
+
+ int left = width / 2 - colwidth / 2;
+ int top = height / 2 - colheight / 2;
+
+ BackgroundBlur.renderBlurredBackground(10, width, height, left, top, colwidth, colheight);
+ super.drawDefaultBackground();
+
+ Utils.drawStringCentered("\u00a7lCollection Log", fontRendererObj, width / 2, top - 27, true, 0xfff5aa00);
+
+ String[] cats = {"Bosses", "Dragons", "Slayer", "Dungeons"};
+
+ GlStateManager.enableDepth();
+
+ GlStateManager.translate(0, 0, 2);
+ for (int i = 0; i < 4; i++) {
+ if (i == 0) {
+ int offset = i == 0 ? 1 : 2;
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(COLLECTION_LOG_TEX);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(left + i * 71, top - 21, 71, 25,
+ (71 * offset) / 512f, (71 + 71 * offset) / 512f, 211 / 512f, (211 + 25) / 512f, GL11.GL_NEAREST
+ );
+
+ Utils.drawStringCentered(cats[i], fontRendererObj, left + i * 71 + 71 / 2, top - 8, true, 0xfff5aa00);
+ }
+ }
+
+ GlStateManager.translate(0, 0, -1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(COLLECTION_LOG_TEX);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(left, top, colwidth, colheight,
+ 0, colwidth / 512f, 0, colheight / 512f, GL11.GL_NEAREST
+ );
+
+ GlScissorStack.push(0, top + 3, width, top + colheight - 6, scaledResolution);
+ int catIndex = 0;
+ for (int h = top + 3; h < top + colheight - 6; h += 24) {
+ catIndex += 2;
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(COLLECTION_LOG_TEX);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(left, h, 100, 24,
+ 0, 100 / 512f, 187 / 512f, 211 / 512f, GL11.GL_NEAREST
+ );
+
+ fontRendererObj.drawString("Thing " + catIndex, left + 5, h + 2, 0xfff5aa00, true);
+ fontRendererObj.drawString("Thing " + (catIndex + 1), left + 5, h + 14, 0xfff5aa00, true);
+ }
+ GlScissorStack.pop(scaledResolution);
+
+ fontRendererObj.drawString("\u00a7lSuperior Dragon", left + 119, top + 8, 0xfff5aa00, true);
+ fontRendererObj.drawString(
+ "Obtained: " + EnumChatFormatting.YELLOW + "3/5",
+ left + 122,
+ top + 23,
+ 0xfff5aa00,
+ true
+ );
+
+ String killCountText = "Kills: " + EnumChatFormatting.WHITE + "3";
+ //int killCountLen = fontRendererObj.getStringWidth(killCountText);
+ fontRendererObj.drawString(killCountText, left + 122, top + 68, 0xfff5aa00, true);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(COLLECTION_LOG_TEX);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(left + colwidth - 196, top, 196, colheight,
+ (512 - 196) / 512f, 1, 0 / 512f, colheight / 512f, GL11.GL_NEAREST
+ );
+
+ GlStateManager.translate(0, 0, -1);
+
+ for (int i = 0; i < 4; i++) {
+ if (i != 0) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(COLLECTION_LOG_TEX);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(left + i * 71, top - 21, 71, 25,
+ 0, 71 / 512f, 211 / 512f, (211 + 25) / 512f, GL11.GL_NEAREST
+ );
+
+ Utils.drawStringCentered(cats[i], fontRendererObj, left + i * 71 + 71 / 2, top - 8, true, 0xfff5aa00);
+ }
+ }
+
+ super.drawScreen(mouseX, mouseY, partialTicks);
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/ClientCommandBase.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/ClientCommandBase.java
index 47174f32..8ba87ecd 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/commands/ClientCommandBase.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/ClientCommandBase.java
@@ -4,25 +4,24 @@ import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
public abstract class ClientCommandBase extends CommandBase {
+ private final String name;
- private final String name;
+ protected ClientCommandBase(String name) {
+ this.name = name;
+ }
- protected ClientCommandBase(String name) {
- this.name = name;
- }
+ @Override
+ public String getCommandName() {
+ return name;
+ }
- @Override
- public String getCommandName() {
- return name;
- }
+ @Override
+ public String getCommandUsage(ICommandSender sender) {
+ return "/" + name;
+ }
- @Override
- public String getCommandUsage(ICommandSender sender) {
- return "/"+name;
- }
-
- @Override
- public boolean canCommandSenderUseCommand(ICommandSender sender) {
- return true;
- }
+ @Override
+ public boolean canCommandSenderUseCommand(ICommandSender sender) {
+ return true;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/Commands.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/Commands.java
index 9fbe27dd..de017cb5 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/commands/Commands.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/Commands.java
@@ -1,1104 +1,74 @@
package io.github.moulberry.notenoughupdates.commands;
-import com.google.common.collect.Lists;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import io.github.moulberry.notenoughupdates.NEUEventListener;
-import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
-import io.github.moulberry.notenoughupdates.auction.CustomAHGui;
-import io.github.moulberry.notenoughupdates.collectionlog.GuiCollectionLog;
-import io.github.moulberry.notenoughupdates.core.GuiScreenElementWrapper;
-import io.github.moulberry.notenoughupdates.core.config.GuiPositionEditor;
-import io.github.moulberry.notenoughupdates.core.util.MiscUtils;
-import io.github.moulberry.notenoughupdates.cosmetics.GuiCosmetics;
-import io.github.moulberry.notenoughupdates.dungeons.DungeonWin;
-import io.github.moulberry.notenoughupdates.dungeons.GuiDungeonMapEditor;
-import io.github.moulberry.notenoughupdates.gamemodes.GuiGamemodes;
+import io.github.moulberry.notenoughupdates.commands.dev.*;
+import io.github.moulberry.notenoughupdates.commands.dungeon.DhCommand;
+import io.github.moulberry.notenoughupdates.commands.dungeon.DnCommand;
+import io.github.moulberry.notenoughupdates.commands.dungeon.JoinDungeonCommand;
+import io.github.moulberry.notenoughupdates.commands.dungeon.MapCommand;
+import io.github.moulberry.notenoughupdates.commands.help.*;
+import io.github.moulberry.notenoughupdates.commands.misc.AhCommand;
+import io.github.moulberry.notenoughupdates.commands.misc.CalendarCommand;
+import io.github.moulberry.notenoughupdates.commands.misc.CosmeticsCommand;
+import io.github.moulberry.notenoughupdates.commands.misc.CustomizeCommand;
+import io.github.moulberry.notenoughupdates.commands.profile.CataCommand;
+import io.github.moulberry.notenoughupdates.commands.profile.PeekCommand;
+import io.github.moulberry.notenoughupdates.commands.profile.PvCommand;
+import io.github.moulberry.notenoughupdates.commands.profile.ViewProfileCommand;
+import io.github.moulberry.notenoughupdates.commands.repo.ReloadRepoCommand;
+import io.github.moulberry.notenoughupdates.commands.repo.RepoModeCommand;
+import io.github.moulberry.notenoughupdates.commands.repo.ResetRepoCommand;
import io.github.moulberry.notenoughupdates.miscfeatures.FairySouls;
-import io.github.moulberry.notenoughupdates.miscfeatures.FancyPortals;
-import io.github.moulberry.notenoughupdates.miscfeatures.FishingHelper;
-import io.github.moulberry.notenoughupdates.miscfeatures.NullzeeSphere;
-import io.github.moulberry.notenoughupdates.miscgui.*;
-import io.github.moulberry.notenoughupdates.miscgui.tutorials.NeuTutorial;
-import io.github.moulberry.notenoughupdates.options.NEUConfig;
-import io.github.moulberry.notenoughupdates.options.NEUConfigEditor;
-import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer;
-import io.github.moulberry.notenoughupdates.profileviewer.PlayerStats;
-import io.github.moulberry.notenoughupdates.util.Constants;
-import io.github.moulberry.notenoughupdates.util.SBInfo;
-import io.github.moulberry.notenoughupdates.util.Utils;
-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.renderer.OpenGlHelper;
-import net.minecraft.command.ICommandSender;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.event.ClickEvent;
-import net.minecraft.item.ItemMap;
-import net.minecraft.item.ItemStack;
-import net.minecraft.util.*;
-import net.minecraft.world.storage.MapData;
+import io.github.moulberry.notenoughupdates.miscgui.GuiEnchantColour;
+import io.github.moulberry.notenoughupdates.miscgui.GuiInvButtonEditor;
+import io.github.moulberry.notenoughupdates.miscgui.NEUOverlayPlacements;
import net.minecraftforge.client.ClientCommandHandler;
-import net.minecraftforge.common.ForgeVersion;
import net.minecraftforge.fml.common.Loader;
-import net.minecraftforge.fml.common.ModContainer;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.text.WordUtils;
-import org.lwjgl.opengl.Display;
-import org.lwjgl.opengl.GL11;
-
-import java.awt.*;
-import java.awt.datatransfer.StringSelection;
-import java.io.*;
-import java.lang.management.ManagementFactory;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.nio.charset.StandardCharsets;
-import java.util.*;
-import java.util.List;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
public class Commands {
-
- public Commands(){
- //ClientCommandHandler.instance.registerCommand(collectionLogCommand);
- //ClientCommandHandler.instance.registerCommand(collectionLogCommand2);
- ClientCommandHandler.instance.registerCommand(nullzeeSphereCommand);
- ClientCommandHandler.instance.registerCommand(cosmeticsCommand);
- ClientCommandHandler.instance.registerCommand(linksCommand);
- //ClientCommandHandler.instance.registerCommand(gamemodesCommand);
- ClientCommandHandler.instance.registerCommand(stWhyCommand);
- ClientCommandHandler.instance.registerCommand(buttonsCommand);
- ClientCommandHandler.instance.registerCommand(resetRepoCommand);
- ClientCommandHandler.instance.registerCommand(reloadRepoCommand);
- //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(customizeCommand2);
- ClientCommandHandler.instance.registerCommand(devTestCommand);
- ClientCommandHandler.instance.registerCommand(packDevCommand);
- if(!Loader.isModLoaded("skyblockextras")) ClientCommandHandler.instance.registerCommand(viewCataCommand);
- ClientCommandHandler.instance.registerCommand(peekCommand);
-// ClientCommandHandler.instance.registerCommand(tutorialCommand);
- ClientCommandHandler.instance.registerCommand(overlayPlacementsCommand);
- ClientCommandHandler.instance.registerCommand(enchantColourCommand);
- ClientCommandHandler.instance.registerCommand(neuAhCommand);
- ClientCommandHandler.instance.registerCommand(new StatsCommand());
- ClientCommandHandler.instance.registerCommand(neumapCommand);
- ClientCommandHandler.instance.registerCommand(settingsCommand);
- ClientCommandHandler.instance.registerCommand(settingsCommand2);
- ClientCommandHandler.instance.registerCommand(settingsCommand3);
- ClientCommandHandler.instance.registerCommand(dungeonWinTest);
- ClientCommandHandler.instance.registerCommand(calendarCommand);
- ClientCommandHandler.instance.registerCommand(new FairySouls.FairySoulsCommand());
- ClientCommandHandler.instance.registerCommand(new FairySouls.FairySoulsCommandAlt());
- ClientCommandHandler.instance.registerCommand(neuHelp);
- ClientCommandHandler.instance.registerCommand(neuFeatures);
- }
-
- SimpleCommand.ProcessCommandRunnable collectionLogRun = new SimpleCommand.ProcessCommandRunnable() {
- public void processCommand(ICommandSender sender, String[] args) {
- NotEnoughUpdates.INSTANCE.openGui = new GuiCollectionLog();
- }
- };
-
- SimpleCommand collectionLogCommand = new SimpleCommand("neucl", collectionLogRun);
- SimpleCommand collectionLogCommand2 = new SimpleCommand("collectionlog", collectionLogRun);
-
- SimpleCommand nullzeeSphereCommand = new SimpleCommand("neuzeesphere", new SimpleCommand.ProcessCommandRunnable() {
- public void processCommand(ICommandSender sender, String[] args) {
- if(args.length != 1) {
- sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED+"Usage: /neuzeesphere [on/off] or /neuzeesphere (radius) or /neuzeesphere setCenter"));
- return;
- }
- if(args[0].equalsIgnoreCase("on")) {
- NullzeeSphere.enabled = true;
- } else if(args[0].equalsIgnoreCase("off")) {
- NullzeeSphere.enabled = false;
- } else if(args[0].equalsIgnoreCase("setCenter")) {
- EntityPlayerSP p = ((EntityPlayerSP)sender);
- NullzeeSphere.centerPos = new BlockPos(p.posX, p.posY, p.posZ);
- NullzeeSphere.overlayVBO = null;
- } else {
- try {
- float radius = Float.parseFloat(args[0]);
- NullzeeSphere.size = radius;
- NullzeeSphere.overlayVBO = null;
- } catch(Exception e) {
- sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED+"Can't parse radius: " + args[0]));
- }
- }
- }
- });
-
- /*SimpleCommand itemRenameCommand = new SimpleCommand("neurename", new SimpleCommand.ProcessCommandRunnable() {
- public void processCommand(ICommandSender sender, String[] args) {
- if(args.length == 0) {
- args = new String[]{"help"};
- }
- String heldUUID = NotEnoughUpdates.INSTANCE.manager.getUUIDForItem(Minecraft.getMinecraft().thePlayer.getHeldItem());
- switch(args[0].toLowerCase()) {
- case "clearall":
- NotEnoughUpdates.INSTANCE.manager.itemRenameJson = new JsonObject();
- NotEnoughUpdates.INSTANCE.manager.saveItemRenameConfig();
- sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "[NEU] Cleared custom name for all items"));
- break;
- case "clear":
- if(heldUUID == null) {
- sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "[NEU] Can't clear rename - no UUID"));
- return;
- }
- NotEnoughUpdates.INSTANCE.manager.itemRenameJson.remove(heldUUID);
- NotEnoughUpdates.INSTANCE.manager.saveItemRenameConfig();
- sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "[NEU] Cleared custom name for held item"));
- break;
- case "copyuuid":
- if(heldUUID == null) {
- sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "[NEU] Can't clear rename - no UUID"));
- return;
- }
- StringSelection selection = new StringSelection(heldUUID);
- Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, selection);
- sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "[NEU] UUID copied to clipboard"));
- break;
- case "uuid":
- if(heldUUID == null) {
- sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "[NEU] Can't get UUID - no UUID"));
- return;
- }
- ChatStyle style = new ChatStyle();
- style.setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
- new ChatComponentText(EnumChatFormatting.GRAY+"Click to copy to clipboard")));
- style.setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/neurename copyuuid"));
-
- ChatComponentText text = new ChatComponentText(EnumChatFormatting.YELLOW+"[NEU] The UUID of your currently held item is: " +
- EnumChatFormatting.GREEN + heldUUID);
- text.setChatStyle(style);
- sender.addChatMessage(text);
- break;
- case "set":
- if(heldUUID == null) {
- sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "[NEU] Can't rename item - no UUID"));
- return;
- }
- if(args.length == 1) {
- sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "[NEU] Usage: /neurename set [name...]"));
- return;
- }
- StringBuilder sb = new StringBuilder();
- for(int i=1; i<args.length; i++) {
- sb.append(args[i]);
- if(i<args.length-1) sb.append(" ");
- }
- String name = sb.toString()
- .replace("\\&", "{amp}")
- .replace("&", "\u00a7")
- .replace("{amp}", "&");
- name = new UnicodeUnescaper().translate(name);
- NotEnoughUpdates.INSTANCE.manager.itemRenameJson.addProperty(heldUUID, name);
- NotEnoughUpdates.INSTANCE.manager.saveItemRenameConfig();
- sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "[NEU] Set custom name for held item"));
- break;
- default:
- sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "[NEU] Unknown subcommand \""+args[0]+"\""));
- case "help":
- sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "[NEU] Available commands:"));
- sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "help: Print this message"));
- sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "clearall: Clears all custom names "
- + EnumChatFormatting.BOLD + "(Cannot be undone)"));
- sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "clear: Clears held item name "
- + EnumChatFormatting.BOLD + "(Cannot be undone)"));
- sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "uuid: Returns the UUID of the currently held item"));
- sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "set: Sets the custom name of the currently held item"));
- sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Usage: /neurename set [name...]"));
-
- }
- }
- });*/
-
- SimpleCommand neuHelp = new SimpleCommand("neuhelp", new SimpleCommand.ProcessCommandRunnable() {
- public void processCommand(ICommandSender sender, String[] args) {
- ArrayList<String> neuHelpMessages = Lists.newArrayList(
- "\u00a75\u00a7lNotEnoughUpdates commands",
- "\u00a76/neu \u00a77- Opens the main neu GUI.",
- "\u00a76/pv \u00a7b?{name} \u00a72\u2D35 \u00a7r\u00a77- Opens the profile viewer",
- "\u00a76/neusouls {on/off/clear/unclear} \u00a7r\u00a77- Shows waypoints to fairy souls.",
- "\u00a76/neubuttons \u00a7r\u00a77- Opens a GUI which allows you to customize inventory buttons.",
- "\u00a76/neuec \u00a7r\u00a77- Opens the enchant colour GUI.",
-
- "\u00a76/join {floor} \u00a7r\u00a77- Short Command to join a Dungeon. \u00a7lNeed a Party of 5 People\u00a7r\u00a77 {4/f7/m5}.",
- "\u00a76/neucosmetics \u00a7r\u00a77- Opens the cosmetic GUI.",
- "\u00a76/neurename \u00a7r\u00a77- Opens the NEU Item Customizer.",
- "\u00a76/cata \u00a7b?{name} \u00a72\u2D35 \u00a7r\u00a77- Opens the profile viewer's catacombs page.",
- "\u00a76/neulinks \u00a7r\u00a77- Shows links to neu/moulberry.",
- "\u00a76/neuoverlay \u00a7r\u00a77- Opens GUI Editor for quickcommands and searchbar.",
- "\u00a76/neuah \u00a7r\u00a77- Opens neu's custom ah GUI.",
- "\u00a76/neumap \u00a7r\u00a77- Opens the dungeon map GUI.",
- "\u00a76/neucalendar \u00a7r\u00a77- Opens neu's custom calendar GUI.",
- "",
- "\u00a76\u00a7lOld commands:",
- "\u00a76/peek \u00a7b?{user} \u00a72\u2D35 \u00a7r\u00a77- Shows quickly stats for a user.",
- "",
- "\u00a76\u00a7lDebug commands:",
- "\u00a76/neustats \u00a7r\u00a77- Copies helpful info to the clipboard.",
- "\u00a76/neustats modlist \u00a7r\u00a77- Copies modlist info to clipboard.",
- "\u00a76/neuresetrepo \u00a7r\u00a77- Deletes all repo files.",
- "\u00a76/neureloadrepo \u00a7r\u00a77- Debug command with repo.",
- "",
- "\u00a76\u00a7lDev commands:",
- "\u00a76/neupackdev \u00a7r\u00a77- pack creator command - getnpc");
- for (int i = 0; i < neuHelpMessages.size(); i++) {
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(neuHelpMessages.get(i)
- ));
-
- }
- if(NotEnoughUpdates.INSTANCE.config.hidden.dev) {
- ArrayList<String> neuDevHelpMessages = Lists.newArrayList(
- "\u00a76/neudevtest \u00a7r\u00a77- dev test command",
- "\u00a76/neuzeephere \u00a7r\u00a77- sphere",
- "\u00a76/neudungeonwintest \u00a7r\u00a77- displays the dungeon win screen");
-
- for (int i = 0; i < neuDevHelpMessages.size(); i++) {
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(neuDevHelpMessages.get(i)
- ));
-
- }
- }
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("\u00a77Commands marked with a \u00a72\"\u2D35\"\u00a77 require are api key. You can set your api key via \"/api new\" or by manually putting it in the api field in \"/neu\""));
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("\u00a77Arguments marked with a \u00a7b\"?\"\u00a77 are optional."));
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("\u00a76\u00a7lScroll up to see everything"));
- }
- });
-
- SimpleCommand neuFeatures = new SimpleCommand("neufeatures", new SimpleCommand.ProcessCommandRunnable() {
- public void processCommand(ICommandSender sender, String[] args) {
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
- if(Constants.MISC == null || !Constants.MISC.has("featureslist")){
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""+EnumChatFormatting.DARK_RED+EnumChatFormatting.BOLD+"WARNING: "+EnumChatFormatting.RESET+EnumChatFormatting.RED+"Could not load URL from repo."));
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""+EnumChatFormatting.RED+ "Please run "+EnumChatFormatting.BOLD+"/neuresetrepo"+EnumChatFormatting.RESET+EnumChatFormatting.RED+" and "+EnumChatFormatting.BOLD+"restart your game"+EnumChatFormatting.RESET+EnumChatFormatting.RED+" in order to fix. "+EnumChatFormatting.DARK_RED+EnumChatFormatting.BOLD+"If that doesn't fix it"+EnumChatFormatting.RESET+EnumChatFormatting.RED+", please join discord.gg/moulberry and post in #neu-support"));
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
- return;
- }
- String url = Constants.MISC.get("featureslist").getAsString();
-
- Desktop desk = Desktop.getDesktop();
- try {
- desk.browse(new URI(url));
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.DARK_PURPLE+""+EnumChatFormatting.BOLD+"NEU"+EnumChatFormatting.RESET+EnumChatFormatting.GOLD+"> Opening Feature List in browser."));
- } catch (URISyntaxException | IOException ignored){
-
- ChatComponentText clickTextFeatures = new ChatComponentText(
- EnumChatFormatting.DARK_PURPLE+""+EnumChatFormatting.BOLD+"NEU"+EnumChatFormatting.RESET+EnumChatFormatting.GOLD+"> Click here to open the Feature List in your browser.");
- clickTextFeatures.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, url));
- Minecraft.getMinecraft().thePlayer.addChatMessage(clickTextFeatures);
-
- }
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
-
- }
- });
-
-
- SimpleCommand stWhyCommand = new SimpleCommand("neustwhy", new SimpleCommand.ProcessCommandRunnable() {
- public void processCommand(ICommandSender sender, String[] args) {
- NEUEventListener.displayNotification(Lists.newArrayList(
- "\u00a7eStorage Viewer",
- "\u00a77Currently, the storage viewer requires you to click twice",
- "\u00a77in order to switch between pages. This is because Hypixel",
- "\u00a77has not yet added a shortcut command to go to any enderchest/",
- "\u00a77storage page.",
- "\u00a77While it is possible to send the second click",
- "\u00a77automatically, doing so violates Hypixel's new mod rules."), true);
- }
- });
-
- SimpleCommand gamemodesCommand = new SimpleCommand("neugamemodes", new SimpleCommand.ProcessCommandRunnable() {
- public void processCommand(ICommandSender sender, String[] args) {
- boolean upgradeOverride = args.length == 1 && args[0].equals("upgradeOverride");
- NotEnoughUpdates.INSTANCE.openGui = new GuiGamemodes(upgradeOverride);
- }
- });
-
- SimpleCommand buttonsCommand = new SimpleCommand("neubuttons", new SimpleCommand.ProcessCommandRunnable() {
- public void processCommand(ICommandSender sender, String[] args) {
- NotEnoughUpdates.INSTANCE.openGui = new GuiInvButtonEditor();
- }
- });
-
- SimpleCommand enchantColourCommand = new SimpleCommand("neuec", new SimpleCommand.ProcessCommandRunnable() {
- public void processCommand(ICommandSender sender, String[] args) {
- NotEnoughUpdates.INSTANCE.openGui = new GuiEnchantColour();
- }
- });
-
- SimpleCommand resetRepoCommand = new SimpleCommand("neuresetrepo", new SimpleCommand.ProcessCommandRunnable() {
- public void processCommand(ICommandSender sender, String[] args) {
- NotEnoughUpdates.INSTANCE.manager.resetRepo();
- }
- });
-
- SimpleCommand dungeonWinTest = new SimpleCommand("neudungeonwintest", new SimpleCommand.ProcessCommandRunnable() {
- public void processCommand(ICommandSender sender, String[] args) {
- if(args.length > 0) {
- DungeonWin.TEAM_SCORE = new ResourceLocation("notenoughupdates:dungeon_win/"+args[0].toLowerCase()+".png");
- }
-
- DungeonWin.displayWin();
- }
- });
-
- SimpleCommand reloadRepoCommand = new SimpleCommand("neureloadrepo", new SimpleCommand.ProcessCommandRunnable() {
- public void processCommand(ICommandSender sender, String[] args) {
- File items = new File(NotEnoughUpdates.INSTANCE.manager.repoLocation, "items");
- if(items.exists()) {
- File[] itemFiles = new File(NotEnoughUpdates.INSTANCE.manager.repoLocation, "items").listFiles();
- if(itemFiles != null) {
- for(File f : itemFiles) {
- String internalname = f.getName().substring(0, f.getName().length()-5);
- NotEnoughUpdates.INSTANCE.manager.loadItem(internalname);
- }
- }
- }
- Constants.reload();
-
- NotEnoughUpdates.INSTANCE.newConfigFile();
- if(NotEnoughUpdates.INSTANCE.getConfigFile().exists()) {
- try(BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(NotEnoughUpdates.INSTANCE.getConfigFile()), StandardCharsets.UTF_8))) {
- NotEnoughUpdates.INSTANCE.config = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(reader, NEUConfig.class);
- } catch(Exception e) { }
- }
- }
- });
-
- ScheduledExecutorService peekCommandExecutorService = null;
-
- SimpleCommand peekCommand = new SimpleCommand("peek", new SimpleCommand.ProcessCommandRunnable() {
- public void processCommand(ICommandSender sender, String[] args) {
- String name;
- if(args.length == 0) {
- name = Minecraft.getMinecraft().thePlayer.getName();
- } else {
- name = args[0];
- }
- int id = new Random().nextInt(Integer.MAX_VALUE/2)+Integer.MAX_VALUE/2;
-
- Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(new ChatComponentText(
- EnumChatFormatting.YELLOW+"[PEEK] Getting player information..."), id);
- NotEnoughUpdates.INSTANCE.profileViewer.getProfileByName(name, profile -> {
- if (profile == null) {
- Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(new ChatComponentText(
- EnumChatFormatting.RED+"[PEEK] Unknown player or api is down."), id);
- } else {
- profile.resetCache();
-
- if(peekCommandExecutorService == null || peekCommandExecutorService.isShutdown()) {
- peekCommandExecutorService = Executors.newSingleThreadScheduledExecutor();
- } else {
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
- EnumChatFormatting.RED+"[PEEK] New peek command run, cancelling old one."));
- peekCommandExecutorService.shutdownNow();
- peekCommandExecutorService = Executors.newSingleThreadScheduledExecutor();
- }
-
- Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(new ChatComponentText(
- EnumChatFormatting.YELLOW+"[PEEK] Getting player skyblock profiles..."), id);
-
- long startTime = System.currentTimeMillis();
- peekCommandExecutorService.schedule(new Runnable() {
- public void run() {
- if(System.currentTimeMillis() - startTime > 10*1000) {
-
- Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(new ChatComponentText(
- EnumChatFormatting.RED+"[PEEK] Getting profile info took too long, aborting."), id);
- return;
- }
-
- String g = EnumChatFormatting.GRAY.toString();
-
- JsonObject profileInfo = profile.getProfileInformation(null);
- if(profileInfo != null) {
- float overallScore = 0;
-
- boolean isMe = name.equalsIgnoreCase("moulberry");
-
- PlayerStats.Stats stats = profile.getStats(null);
- JsonObject skill = profile.getSkillInfo(null);
-
- Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(new ChatComponentText(EnumChatFormatting.GREEN+" "+
- EnumChatFormatting.STRIKETHROUGH+"-=-" +EnumChatFormatting.RESET+EnumChatFormatting.GREEN+" "+
- Utils.getElementAsString(profile.getHypixelProfile().get("displayname"), name) + "'s Info " +
- EnumChatFormatting.STRIKETHROUGH+"-=-"), id);
-
- if(skill == null) {
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW+"Skills api disabled!"));
- } else {
- float totalSkillLVL = 0;
- float totalSkillCount = 0;
-
- for(Map.Entry<String, JsonElement> entry : skill.entrySet()) {
- if(entry.getKey().startsWith("level_skill")) {
- if(entry.getKey().contains("runecrafting")) continue;
- if(entry.getKey().contains("carpentry")) continue;
- totalSkillLVL += entry.getValue().getAsFloat();
- totalSkillCount++;
- }
- }
-
- float combat = Utils.getElementAsFloat(skill.get("level_skill_combat"), 0);
- float zombie = Utils.getElementAsFloat(skill.get("level_slayer_zombie"), 0);
- float spider = Utils.getElementAsFloat(skill.get("level_slayer_spider"), 0);
- float wolf = Utils.getElementAsFloat(skill.get("level_slayer_wolf"), 0);
- float enderman = Utils.getElementAsFloat(skill.get("level_slayer_enderman"), 0);
-
- float avgSkillLVL = totalSkillLVL/totalSkillCount;
-
- if(isMe) {
- avgSkillLVL = 6;
- combat = 4;
- zombie = 2;
- spider = 1;
- wolf = 2;
- enderman = 0;
- }
-
- EnumChatFormatting combatPrefix = combat>20?(combat>35?EnumChatFormatting.GREEN:EnumChatFormatting.YELLOW):EnumChatFormatting.RED;
- EnumChatFormatting zombiePrefix = zombie>3?(zombie>6?EnumChatFormatting.GREEN:EnumChatFormatting.YELLOW):EnumChatFormatting.RED;
- EnumChatFormatting spiderPrefix = spider>3?(spider>6?EnumChatFormatting.GREEN:EnumChatFormatting.YELLOW):EnumChatFormatting.RED;
- EnumChatFormatting wolfPrefix = wolf>3?(wolf>6?EnumChatFormatting.GREEN:EnumChatFormatting.YELLOW):EnumChatFormatting.RED;
- EnumChatFormatting endermanPrefix = enderman>3?(enderman>6?EnumChatFormatting.GREEN:EnumChatFormatting.YELLOW):EnumChatFormatting.RED;
- EnumChatFormatting avgPrefix = avgSkillLVL>20?(avgSkillLVL>35?EnumChatFormatting.GREEN:EnumChatFormatting.YELLOW):EnumChatFormatting.RED;
-
- overallScore += zombie*zombie/81f;
- overallScore += spider*spider/81f;
- overallScore += wolf*wolf/81f;
- overallScore += enderman*enderman/81f;
- overallScore += avgSkillLVL/20f;
-
- int cata = (int)Utils.getElementAsFloat(skill.get("level_skill_catacombs"), 0);
- EnumChatFormatting cataPrefix = cata>15?(cata>25?EnumChatFormatting.GREEN:EnumChatFormatting.YELLOW):EnumChatFormatting.RED;
-
- overallScore += cata*cata/2000f;
-
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
- g+"Combat: "+combatPrefix+(int)Math.floor(combat) +
- (cata > 0 ? g+" - Cata: "+cataPrefix+cata : "")+
- g+" - AVG: " + avgPrefix+(int)Math.floor(avgSkillLVL)));
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
- g+"Slayer: "+zombiePrefix+(int)Math.floor(zombie)+g+"-"+
- spiderPrefix+(int)Math.floor(spider)+g+"-"+
- wolfPrefix+(int)Math.floor(wolf)+"-"+
- endermanPrefix+(int)Math.floor(enderman)));
- }
- if (stats == null) {
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
- EnumChatFormatting.YELLOW+"Skills, collection and/or inventory apis disabled!"));
- } else {
- int health = (int)stats.get("health");
- int defence = (int)stats.get("defence");
- int strength = (int)stats.get("strength");
- int intelligence = (int)stats.get("intelligence");
-
- EnumChatFormatting healthPrefix = health>800?(health>1600?EnumChatFormatting.GREEN:EnumChatFormatting.YELLOW):EnumChatFormatting.RED;
- EnumChatFormatting defencePrefix = defence>200?(defence>600?EnumChatFormatting.GREEN:EnumChatFormatting.YELLOW):EnumChatFormatting.RED;
- EnumChatFormatting strengthPrefix = strength>100?(strength>300?EnumChatFormatting.GREEN:EnumChatFormatting.YELLOW):EnumChatFormatting.RED;
- EnumChatFormatting intelligencePrefix = intelligence>300?(intelligence>900?EnumChatFormatting.GREEN:EnumChatFormatting.YELLOW):EnumChatFormatting.RED;
-
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
- g+"Stats : "+healthPrefix+health+EnumChatFormatting.RED+"\u2764 "+
- defencePrefix+defence+EnumChatFormatting.GREEN+"\u2748 "+
- strengthPrefix+strength+EnumChatFormatting.RED+"\u2741 "+
- intelligencePrefix+intelligence+EnumChatFormatting.AQUA+"\u270e "));
- }
- float bankBalance = Utils.getElementAsFloat(Utils.getElement(profileInfo, "banking.balance"), -1);
- float purseBalance = Utils.getElementAsFloat(Utils.getElement(profileInfo, "coin_purse"), 0);
-
- long networth = profile.getNetWorth(null);
- float money = Math.max(bankBalance+purseBalance, networth);
- EnumChatFormatting moneyPrefix = money>50*1000*1000?
- (money>200*1000*1000?EnumChatFormatting.GREEN:EnumChatFormatting.YELLOW):EnumChatFormatting.RED;
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
- g+"Purse: "+moneyPrefix+Utils.shortNumberFormat(purseBalance, 0) + g+" - Bank: " +
- (bankBalance == -1 ? EnumChatFormatting.YELLOW+"N/A" : moneyPrefix+
- (isMe?"4.8b":Utils.shortNumberFormat(bankBalance, 0))) +
- (networth > 0 ? g+" - Net: "+moneyPrefix+Utils.shortNumberFormat(networth, 0) : "")));
-
- overallScore += Math.min(2, money/(100f*1000*1000));
-
- String activePet = Utils.getElementAsString(Utils.getElement(profile.getPetsInfo(null), "active_pet.type"),
- "None Active");
- String activePetTier = Utils.getElementAsString(Utils.getElement(profile.getPetsInfo(null), "active_pet.tier"), "UNKNOWN");
-
- String col = NotEnoughUpdates.petRarityToColourMap.get(activePetTier);
- if(col == null) col = EnumChatFormatting.LIGHT_PURPLE.toString();
-
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(g+"Pet : " +
- col + WordUtils.capitalizeFully(activePet.replace("_", " "))));
-
- String overall = "Skywars Main";
- if(isMe) {
- overall = Utils.chromaString("Literally the best player to exist"); // ego much
- } else if(overallScore < 5 && (bankBalance+purseBalance) > 500*1000*1000) {
- overall = EnumChatFormatting.GOLD+"Bill Gates";
- } else if(overallScore > 9) {
- overall = Utils.chromaString("Didn't even think this score was possible");
- } else if(overallScore > 8) {
- overall = Utils.chromaString("Mentally unstable");
- } else if(overallScore > 7) {
- overall = EnumChatFormatting.GOLD+"Why though 0.0";
- } else if(overallScore > 5.5) {
- overall = EnumChatFormatting.GOLD+"Bro stop playing";
- } else if(overallScore > 4) {
- overall = EnumChatFormatting.GREEN+"Kinda sweaty";
- } else if(overallScore > 3) {
- overall = EnumChatFormatting.YELLOW+"Alright I guess";
- } else if(overallScore > 2) {
- overall = EnumChatFormatting.YELLOW+"Ender Non";
- } else if(overallScore > 1) {
- overall = EnumChatFormatting.RED+"Played Skyblock";
- }
-
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(g+"Overall score: " +
- overall + g + " (" + Math.round(overallScore*10)/10f + ")"));
-
- peekCommandExecutorService.shutdownNow();
- } else {
- peekCommandExecutorService.schedule(this, 200, TimeUnit.MILLISECONDS);
- }
- }
- }, 200, TimeUnit.MILLISECONDS);
- }
- });
- }
- }, new SimpleCommand.TabCompleteRunnable() {
- @Override
- public java.util.List<String> tabComplete(ICommandSender sender, String[] args, BlockPos pos) {
- if (args.length != 1) return null;
-
- String lastArg = args[args.length - 1];
- List<String> playerMatches = new ArrayList<>();
- for (EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) {
- String playerName = player.getName();
- if (playerName.toLowerCase().startsWith(lastArg.toLowerCase())) {
- playerMatches.add(playerName);
- }
- }
- return playerMatches;
- }
- });
-
- public SimpleCommand.ProcessCommandRunnable viewProfileRunnable = new SimpleCommand.ProcessCommandRunnable() {
- public void processCommand(ICommandSender sender, String[] args) {
- if(!OpenGlHelper.isFramebufferEnabled()) {
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED +
- "Some parts of the profile viewer do not work with OF Fast Render. Go to ESC > Options > Video Settings > Performance > Fast Render to disable it."));
-
- }
- if (NotEnoughUpdates.INSTANCE.config.apiKey.apiKey == null || NotEnoughUpdates.INSTANCE.config.apiKey.apiKey.trim().isEmpty()) {
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED +
- "Can't view profile, apikey is not set. Run /api new and put the result in settings."));
- } else if (args.length == 0) {
- NotEnoughUpdates.INSTANCE.profileViewer.getProfileByName(Minecraft.getMinecraft().thePlayer.getName(), profile -> {
- if(profile == null) {
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED +
- "Invalid player name/api key. Maybe api is down? Try /api new."));
- } else {
- profile.resetCache();
- NotEnoughUpdates.INSTANCE.openGui = new GuiProfileViewer(profile);
- }
- });
- } else if (args.length > 1) {
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED +
- "Too many arguments. Usage: /neuprofile [name]"));
- } else {
- NotEnoughUpdates.INSTANCE.profileViewer.getProfileByName(args[0], profile -> {
- if(profile == null) {
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED +
- "Invalid player name/api key. Maybe api is down? Try /api new."));
- } else {
- profile.resetCache();
- NotEnoughUpdates.INSTANCE.openGui = new GuiProfileViewer(profile);
- }
- });
- }
- }
- };
-
-
- SimpleCommand joinDungeonCommand = new SimpleCommand("join", new SimpleCommand.ProcessCommandRunnable() {
- @Override
- public void processCommand(ICommandSender sender, String[] args) {
- if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
- Minecraft.getMinecraft().thePlayer.sendChatMessage("/join " + StringUtils.join(args, " "));
- } else {
- if(args.length != 1) {
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
- EnumChatFormatting.RED+"Example Usage: /join f7, /join m6 or /join 7"));
- } else {
- String cataPrefix = "catacombs";
- if(args[0].startsWith("m")){
- cataPrefix = "master_catacombs";
- }
- String cmd = "/joindungeon "+cataPrefix+" " + args[0].charAt(args[0].length()-1);
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
- EnumChatFormatting.YELLOW+"Running command: "+cmd));
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
- EnumChatFormatting.YELLOW+"The dungeon should start soon. If it doesn't, make sure you have a party of 5 people"));
- Minecraft.getMinecraft().thePlayer.sendChatMessage(cmd);
- }
- }
- }
- });
-
- SimpleCommand viewProfileCommand = new SimpleCommand("neuprofile", viewProfileRunnable, new SimpleCommand.TabCompleteRunnable() {
- @Override
- public List<String> tabComplete(ICommandSender sender, String[] args, BlockPos pos) {
- if(args.length != 1) return null;
-
- String lastArg = args[args.length-1];
- List<String> playerMatches = new ArrayList<>();
- for(EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) {
- String playerName = player.getName();
- if(playerName.toLowerCase().startsWith(lastArg.toLowerCase())) {
- playerMatches.add(playerName);
- }
- }
- return playerMatches;
- }
- });
-
- SimpleCommand viewProfileShortCommand = new SimpleCommand("pv", new SimpleCommand.ProcessCommandRunnable() {
- @Override
- public void processCommand(ICommandSender sender, String[] args) {
- if(!NotEnoughUpdates.INSTANCE.isOnSkyblock()) {
- Minecraft.getMinecraft().thePlayer.sendChatMessage("/pv " + StringUtils.join(args, " "));
- } else {
- viewProfileRunnable.processCommand(sender, args);
- }
- }
- }, new SimpleCommand.TabCompleteRunnable() {
- @Override
- public List<String> tabComplete(ICommandSender sender, String[] args, BlockPos pos) {
- if (args.length != 1) return null;
-
- String lastArg = args[args.length - 1];
- List<String> playerMatches = new ArrayList<>();
- for (EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) {
- String playerName = player.getName();
- if (playerName.toLowerCase().startsWith(lastArg.toLowerCase())) {
- playerMatches.add(playerName);
- }
- }
- return playerMatches;
- }
- });
-
- SimpleCommand dhCommand = new SimpleCommand("dh", new SimpleCommand.ProcessCommandRunnable() {
- @Override
- public void processCommand(ICommandSender sender, String[] args) {
- Minecraft.getMinecraft().thePlayer.sendChatMessage("/warp dungeon_hub");
- }
- });
-
- private ScheduledExecutorService devES = Executors.newSingleThreadScheduledExecutor();
- private static final String[] devFailStrings = {"No.", "I said no.", "You aren't allowed to use this.",
- "Are you sure you want to use this? Type 'Yes' in chat.", "Are you sure you want to use this? Type 'Yes' in chat.",
- "Lmao you thought", "Ok please stop", "What do you want from me?",
- "This command almost certainly does nothing useful for you",
- "Ok, this is the last message, after this it will repeat", "No.", "I said no.", "Dammit. I thought that would work. Uhh...",
- "\u00a7dFrom \u00a7c[ADMIN] Minikloon\u00a77: If you use that command again, I'll have to ban you", "",
- "Ok, this is actually the last message, use the command again and you'll crash I promise"};
- private int devFailIndex = 0;
-
- private static final List<String> devTestUsers = new ArrayList<>(Arrays.asList("moulberry", "lucycoconut", "ironm00n", "ariyio"));
- SimpleCommand devTestCommand = new SimpleCommand("neudevtest", new SimpleCommand.ProcessCommandRunnable() {
- @Override
- public void processCommand(ICommandSender sender, String[] args) {
- if(!devTestUsers.contains(Minecraft.getMinecraft().thePlayer.getName().toLowerCase())) {
- if(devFailIndex >= devFailStrings.length) {
- throw new Error("L") {
- @Override
- public void printStackTrace() {
- throw new Error("L");
- }
- };
- }
- 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;
- }
- /*if(args.length == 1) {
- DupePOC.doDupe(args[0]);
- return;
- }*/
- if(args.length == 1 && args[0].equalsIgnoreCase("positiontest")) {
- NotEnoughUpdates.INSTANCE.openGui = new GuiPositionEditor();
- return;
- }
-
- if(args.length == 2 && args[0].equalsIgnoreCase("pt")) {
- EnumParticleTypes t = EnumParticleTypes.valueOf(args[1]);
- FishingHelper.type = t;
- return;
- }
- if(args.length == 1 && args[0].equalsIgnoreCase("dev")) {
- NotEnoughUpdates.INSTANCE.config.hidden.dev = true;
- return;
- }
- if(args.length == 1 && args[0].equalsIgnoreCase("saveconfig")) {
- NotEnoughUpdates.INSTANCE.saveConfig();
- return;
- }
- if(args.length == 1 && args[0].equalsIgnoreCase("center")) {
- double x = Math.floor(Minecraft.getMinecraft().thePlayer.posX) + 0.5f;
- double z = Math.floor(Minecraft.getMinecraft().thePlayer.posZ) + 0.5f;
- Minecraft.getMinecraft().thePlayer.setPosition(x, Minecraft.getMinecraft().thePlayer.posY, z);
- return;
- }
- if(args.length == 1 && args[0].equalsIgnoreCase("pansc")) {
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN+"Taking panorama screenshot"));
-
- AtomicInteger perspective = new AtomicInteger(0);
- FancyPortals.perspectiveId = 0;
-
- EntityPlayerSP p = Minecraft.getMinecraft().thePlayer;
- p.prevRotationYaw = p.rotationYaw = 0;
- p.prevRotationPitch = p.rotationPitch = 90;
- devES.schedule(new Runnable() {
- @Override
- public void run() {
- Minecraft.getMinecraft().addScheduledTask(() -> {
- ScreenShotHelper.saveScreenshot(new File("C:/Users/James/Desktop/"), "pansc-"+perspective.get()+".png",
- Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight,
- Minecraft.getMinecraft().getFramebuffer());
- });
- if(perspective.incrementAndGet() >= 6) {
- FancyPortals.perspectiveId = -1;
- return;
- }
- devES.schedule(() -> {
- FancyPortals.perspectiveId = perspective.get();
- if(FancyPortals.perspectiveId == 5) {
- p.prevRotationYaw = p.rotationYaw = 0;
- p.prevRotationPitch = p.rotationPitch = -90;
- } else if(FancyPortals.perspectiveId >= 1 && FancyPortals.perspectiveId <= 4) {
- float yaw = 90*FancyPortals.perspectiveId-180;
- if(yaw > 180) yaw -= 360;
- p.prevRotationYaw = p.rotationYaw = yaw;
- p.prevRotationPitch = p.rotationPitch = 0;
- }
- devES.schedule(this, 3000L, TimeUnit.MILLISECONDS);
- }, 100L, TimeUnit.MILLISECONDS);
- }
- }, 3000L, TimeUnit.MILLISECONDS);
-
- return;
- }
-
- /* if(args.length == 1 && args[0].equalsIgnoreCase("update")) {
- NEUEventListener.displayUpdateMessageIfOutOfDate();
- } */
-
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN+"Executing dubious code"));
- /*Minecraft.getMinecraft().thePlayer.rotationYaw = 0;
- Minecraft.getMinecraft().thePlayer.rotationPitch = 0;
- Minecraft.getMinecraft().thePlayer.setPosition(
- Math.floor(Minecraft.getMinecraft().thePlayer.posX) + Float.parseFloat(args[0]),
- Minecraft.getMinecraft().thePlayer.posY,
- Minecraft.getMinecraft().thePlayer.posZ);*/
- //Hot reload me yay!
- }
- });
-
- 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;
- }
- NotEnoughUpdates.INSTANCE.packDevEnabled = !NotEnoughUpdates.INSTANCE.packDevEnabled;
- if(NotEnoughUpdates.INSTANCE.packDevEnabled) {
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN+"Enabled pack developer mode."));
- } else {
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED+"Disabled pack developer mode."));
- }
- }
- });
-
- SimpleCommand dnCommand = new SimpleCommand("dn", new SimpleCommand.ProcessCommandRunnable() {
- @Override
- public void processCommand(ICommandSender sender, String[] args) {
- Minecraft.getMinecraft().thePlayer.sendChatMessage("/warp dungeon_hub");
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA+"Warping to:"+EnumChatFormatting.YELLOW+" Deez Nuts lmao"));
- }
- });
-
- SimpleCommand viewCataCommand = new SimpleCommand("cata", new SimpleCommand.ProcessCommandRunnable() {
- @Override
- public void processCommand(ICommandSender sender, String[] args) {
- GuiProfileViewer.currentPage = GuiProfileViewer.ProfileViewerPage.DUNG;
- viewProfileRunnable.processCommand(sender, args);
- }
- }, new SimpleCommand.TabCompleteRunnable() {
- @Override
- public List<String> tabComplete(ICommandSender sender, String[] args, BlockPos pos) {
- if (args.length != 1) return null;
-
- String lastArg = args[args.length - 1];
- List<String> playerMatches = new ArrayList<>();
- for (EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) {
- String playerName = player.getName();
- if (playerName.toLowerCase().startsWith(lastArg.toLowerCase())) {
- playerMatches.add(playerName);
- }
- }
- return playerMatches;
- }
- });
-
- SimpleCommand linksCommand = new SimpleCommand("neulinks", new SimpleCommand.ProcessCommandRunnable() {
- public void processCommand(ICommandSender sender, String[] args) {
- File repo = NotEnoughUpdates.INSTANCE.manager.repoLocation;
- if(repo.exists()) {
- File updateJson = new File(repo, "update.json");
- try {
- JsonObject update = NotEnoughUpdates.INSTANCE.manager.getJsonFromFile(updateJson);
-
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
- NotEnoughUpdates.INSTANCE.displayLinks(update);
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
- } catch (Exception ignored) {
- }
- }
- }
- });
-
- SimpleCommand overlayPlacementsCommand = new SimpleCommand("neuoverlay", new SimpleCommand.ProcessCommandRunnable() {
- public void processCommand(ICommandSender sender, String[] args) {
- NotEnoughUpdates.INSTANCE.openGui = new NEUOverlayPlacements();
- }
- });
-
- SimpleCommand tutorialCommand = new SimpleCommand("neututorial", new SimpleCommand.ProcessCommandRunnable() {
- public void processCommand(ICommandSender sender, String[] args) {
- NotEnoughUpdates.INSTANCE.openGui = new NeuTutorial();
- }
- });
-
-
- SimpleCommand neumapCommand = new SimpleCommand("neumap", new SimpleCommand.ProcessCommandRunnable() {
- public void processCommand(ICommandSender sender, String[] args) {
- if(NotEnoughUpdates.INSTANCE.colourMap == null) {
- try(BufferedReader reader = new BufferedReader(new InputStreamReader(Minecraft.getMinecraft().getResourceManager().getResource(
- new ResourceLocation("notenoughupdates:maps/F1Full.json")).getInputStream(), StandardCharsets.UTF_8))) {
- JsonObject json = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(reader, JsonObject.class);
-
- NotEnoughUpdates.INSTANCE.colourMap = new Color[128][128];
- for(int x=0; x<128; x++) {
- for(int y=0; y<128; y++) {
- NotEnoughUpdates.INSTANCE.colourMap[x][y] = new Color(0, 0, 0, 0);
- }
- }
- for(Map.Entry<String, JsonElement> entry : json.entrySet()) {
- int x = Integer.parseInt(entry.getKey().split(":")[0]);
- int y = Integer.parseInt(entry.getKey().split(":")[1]);
-
- NotEnoughUpdates.INSTANCE.colourMap[x][y] = new Color(entry.getValue().getAsInt(), true);
- }
- } catch(Exception ignored) { }
- }
-
- if(!NotEnoughUpdates.INSTANCE.config.hidden.dev) {
- NotEnoughUpdates.INSTANCE.openGui = new GuiDungeonMapEditor();
- return;
- }
-
- if(args.length == 1 && args[0].equals("reset")) {
- NotEnoughUpdates.INSTANCE.colourMap = null;
- return;
- }
-
- if(args.length != 2) {
- NotEnoughUpdates.INSTANCE.openGui = new GuiDungeonMapEditor();
- return;
- }
-
- if(args[0].equals("save")) {
- ItemStack stack = Minecraft.getMinecraft().thePlayer.getHeldItem();
- if(stack != null && stack.getItem() instanceof ItemMap) {
- ItemMap map = (ItemMap) stack.getItem();
- MapData mapData = map.getMapData(stack, Minecraft.getMinecraft().theWorld);
-
- if (mapData == null) return;
-
- JsonObject json = new JsonObject();
- for (int i = 0; i < 16384; ++i) {
- int x = i % 128;
- int y = i / 128;
-
- int j = mapData.colors[i] & 255;
-
- Color c;
- if (j / 4 == 0) {
- c = new Color((i + i / 128 & 1) * 8 + 16 << 24, true);
- } else {
- c = new Color(MapColor.mapColorArray[j / 4].getMapColor(j & 3), true);
- }
-
- json.addProperty(x+":"+y, c.getRGB());
- }
-
- try {
- new File(NotEnoughUpdates.INSTANCE.manager.configLocation, "maps").mkdirs();
- NotEnoughUpdates.INSTANCE.manager.writeJson(json, new File(NotEnoughUpdates.INSTANCE.manager.configLocation, "maps/"+args[1]+".json"));
- } catch(Exception e) {
- e.printStackTrace();
- }
-
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN+
- "Saved to file."));
- }
-
- return;
- }
-
- if(args[0].equals("load")) {
- JsonObject json = NotEnoughUpdates.INSTANCE.manager.getJsonFromFile(new File(NotEnoughUpdates.INSTANCE.manager.configLocation, "maps/"+args[1]+".json"));
-
- NotEnoughUpdates.INSTANCE.colourMap = new Color[128][128];
- for(int x=0; x<128; x++) {
- for(int y=0; y<128; y++) {
- NotEnoughUpdates.INSTANCE.colourMap[x][y] = new Color(0, 0, 0, 0);
- }
- }
- for(Map.Entry<String, JsonElement> entry : json.entrySet()) {
- int x = Integer.parseInt(entry.getKey().split(":")[0]);
- int y = Integer.parseInt(entry.getKey().split(":")[1]);
-
- NotEnoughUpdates.INSTANCE.colourMap[x][y] = new Color(entry.getValue().getAsInt(), true);
- }
-
- return;
- }
-
- NotEnoughUpdates.INSTANCE.openGui = new GuiDungeonMapEditor();
- }
- });
-
- SimpleCommand cosmeticsCommand = new SimpleCommand("neucosmetics", new SimpleCommand.ProcessCommandRunnable() {
- public void processCommand(ICommandSender sender, String[] args) {
- if(!OpenGlHelper.isFramebufferEnabled()) {
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED +
- "NEU cosmetics do not work with OF Fast Render. Go to ESC > Options > Video Settings > Performance > Fast Render to disable it."));
-
- }
-
- NotEnoughUpdates.INSTANCE.openGui = new GuiCosmetics();
- }
- });
-
- SimpleCommand.ProcessCommandRunnable customizeRunnable = 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 = NotEnoughUpdates.INSTANCE.manager.getUUIDForItem(held);
-
- if(heldUUID == null) {
- sender.addChatMessage(new ChatComponentText("\u00a7cHeld item does not have UUID, cannot be customized"));
- return;
- }
-
- NotEnoughUpdates.INSTANCE.openGui = new GuiItemCustomize(held, heldUUID);
- }
- };
-
- SimpleCommand customizeCommand = new SimpleCommand("neucustomize", customizeRunnable);
- SimpleCommand customizeCommand2 = new SimpleCommand("neurename", customizeRunnable);
-
- SimpleCommand.ProcessCommandRunnable settingsRunnable = new SimpleCommand.ProcessCommandRunnable() {
- public void processCommand(ICommandSender sender, String[] args) {
- if(args.length > 0) {
- NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper(new NEUConfigEditor(NotEnoughUpdates.INSTANCE.config, StringUtils.join(args, " ")));
- } else {
- NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper(NEUConfigEditor.editor);
- }
- }
- };
-
- SimpleCommand settingsCommand = new SimpleCommand("neu", settingsRunnable);
- SimpleCommand settingsCommand2 = new SimpleCommand("neusettings", settingsRunnable);
- SimpleCommand settingsCommand3 = new SimpleCommand("neuconfig", settingsRunnable);
-
- SimpleCommand calendarCommand = new SimpleCommand("neucalendar", new SimpleCommand.ProcessCommandRunnable() {
- public void processCommand(ICommandSender sender, String[] args) {
- Minecraft.getMinecraft().thePlayer.closeScreen();
- CalendarOverlay.setEnabled(true);
- NotEnoughUpdates.INSTANCE.sendChatMessage("/calendar");
- }
- });
-
- SimpleCommand neuAhCommand = new SimpleCommand("neuah", new SimpleCommand.ProcessCommandRunnable() {
- public void processCommand(ICommandSender sender, String[] args) {
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED+
- "You must be on Skyblock to use this feature."));
- } else if(NotEnoughUpdates.INSTANCE.config.apiKey.apiKey == null || NotEnoughUpdates.INSTANCE.config.apiKey.apiKey.trim().isEmpty()) {
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED+
- "Can't open NeuAH, apikey is not set. Run /api new and put the result in settings."));
- } else {
- NotEnoughUpdates.INSTANCE.openGui = new CustomAHGui();
- NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.lastOpen = System.currentTimeMillis();
- NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.clearSearch();
- NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.updateSearch();
-
- if(args.length > 0) NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.setSearch(StringUtils.join(args, " "));
- }
- }
- });
+ public Commands() {
+
+ // Help Commands
+ ClientCommandHandler.instance.registerCommand(new LinksCommand());
+ ClientCommandHandler.instance.registerCommand(new HelpCommand());
+ ClientCommandHandler.instance.registerCommand(new StorageViewerWhyCommand());
+ ClientCommandHandler.instance.registerCommand(new FeaturesCommand());
+ ClientCommandHandler.instance.registerCommand(new SettingsCommand());
+
+ // Dev Commands
+ ClientCommandHandler.instance.registerCommand(new PackDevCommand());
+ ClientCommandHandler.instance.registerCommand(new DungeonWinTestCommand());
+ ClientCommandHandler.instance.registerCommand(new StatsCommand());
+ ClientCommandHandler.instance.registerCommand(new DevTestCommand());
+ ClientCommandHandler.instance.registerCommand(new NullzeeSphereCommand());
+
+ // Repo Commands
+ ClientCommandHandler.instance.registerCommand(new ResetRepoCommand());
+ ClientCommandHandler.instance.registerCommand(new RepoModeCommand());
+ ClientCommandHandler.instance.registerCommand(new ReloadRepoCommand());
+
+ // Profile Commands
+ ClientCommandHandler.instance.registerCommand(new PeekCommand());
+ ClientCommandHandler.instance.registerCommand(new ViewProfileCommand());
+ ClientCommandHandler.instance.registerCommand(new PvCommand());
+ if (!Loader.isModLoaded("skyblockextras")) ClientCommandHandler.instance.registerCommand(new CataCommand());
+
+ // Dungeon Commands
+ ClientCommandHandler.instance.registerCommand(new MapCommand());
+ ClientCommandHandler.instance.registerCommand(new JoinDungeonCommand());
+ ClientCommandHandler.instance.registerCommand(new DnCommand());
+ ClientCommandHandler.instance.registerCommand(new DhCommand());
+
+ // Misc Commands
+ ClientCommandHandler.instance.registerCommand(new CosmeticsCommand());
+ ClientCommandHandler.instance.registerCommand(new CustomizeCommand());
+ ClientCommandHandler.instance.registerCommand(new ScreenCommand("neubuttons", GuiInvButtonEditor::new));
+ ClientCommandHandler.instance.registerCommand(new ScreenCommand("neuec", GuiEnchantColour::new));
+ ClientCommandHandler.instance.registerCommand(new ScreenCommand("neuoverlay", NEUOverlayPlacements::new));
+ //ClientCommandHandler.instance.registerCommand(new ScreenCommand("neututorial", NeuTutorial::new));
+ ClientCommandHandler.instance.registerCommand(new AhCommand());
+ ClientCommandHandler.instance.registerCommand(new CalendarCommand());
+
+ // Fairy Soul Commands
+ ClientCommandHandler.instance.registerCommand(new FairySouls.FairySoulsCommand());
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/ScreenCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/ScreenCommand.java
new file mode 100644
index 00000000..29dd9d55
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/ScreenCommand.java
@@ -0,0 +1,26 @@
+package io.github.moulberry.notenoughupdates.commands;
+
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.command.CommandException;
+import net.minecraft.command.ICommandSender;
+
+public class ScreenCommand extends ClientCommandBase {
+
+ private final ScreenOpener opener;
+
+ protected ScreenCommand(String name, ScreenOpener opener) {
+ super(name);
+ this.opener = opener;
+ }
+
+ @Override
+ public void processCommand(ICommandSender sender, String[] args) throws CommandException {
+ NotEnoughUpdates.INSTANCE.openGui = opener.open();
+ }
+
+ @FunctionalInterface
+ public interface ScreenOpener {
+ GuiScreen open();
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/SimpleCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/SimpleCommand.java
deleted file mode 100644
index 029e24db..00000000
--- a/src/main/java/io/github/moulberry/notenoughupdates/commands/SimpleCommand.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package io.github.moulberry.notenoughupdates.commands;
-
-import net.minecraft.command.CommandBase;
-import net.minecraft.command.CommandException;
-import net.minecraft.command.ICommandSender;
-import net.minecraft.util.BlockPos;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class SimpleCommand extends CommandBase {
-
- private String commandName;
- private ProcessCommandRunnable runnable;
- private TabCompleteRunnable tabRunnable;
-
- public SimpleCommand(String commandName, ProcessCommandRunnable runnable) {
- this.commandName = commandName;
- this.runnable = runnable;
- }
-
- public SimpleCommand(String commandName, ProcessCommandRunnable runnable, TabCompleteRunnable tabRunnable) {
- this.commandName = commandName;
- this.runnable = runnable;
- this.tabRunnable = tabRunnable;
- }
-
- public abstract static class ProcessCommandRunnable {
- public abstract void processCommand(ICommandSender sender, String[] args);
- }
-
- public abstract static class TabCompleteRunnable {
- public abstract List<String> tabComplete(ICommandSender sender, String[] args, BlockPos pos);
- }
-
- public boolean canCommandSenderUseCommand(ICommandSender sender) {
- return true;
- }
-
- public String getCommandName() {
- return commandName;
- }
-
- public String getCommandUsage(ICommandSender sender) {
- return "/" + commandName;
- }
-
- public void processCommand(ICommandSender sender, String[] args) throws CommandException {
- runnable.processCommand(sender, args);
- }
-
- public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) {
- if(tabRunnable != null) return tabRunnable.tabComplete(sender, args, pos);
- return null;
- }
-}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/StatsCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/StatsCommand.java
deleted file mode 100644
index b61c58ed..00000000
--- a/src/main/java/io/github/moulberry/notenoughupdates/commands/StatsCommand.java
+++ /dev/null
@@ -1,146 +0,0 @@
-package io.github.moulberry.notenoughupdates.commands;
-
-import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
-import io.github.moulberry.notenoughupdates.util.DiscordMarkdownBuilder;
-import io.github.moulberry.notenoughupdates.util.HastebinUploader;
-import io.github.moulberry.notenoughupdates.util.SBInfo;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.renderer.OpenGlHelper;
-import net.minecraft.command.ICommandSender;
-import net.minecraft.util.BlockPos;
-import net.minecraft.util.ChatComponentText;
-import net.minecraft.util.EnumChatFormatting;
-import net.minecraftforge.common.ForgeVersion;
-import net.minecraftforge.fml.common.Loader;
-import org.lwjgl.opengl.Display;
-import org.lwjgl.opengl.GL11;
-
-import javax.management.JMX;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import java.awt.*;
-import java.awt.datatransfer.StringSelection;
-import java.lang.management.ManagementFactory;
-import java.util.List;
-import java.util.Locale;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-public class StatsCommand extends ClientCommandBase {
-
- private final ExecutorService threadPool = Executors.newFixedThreadPool(1);
-
- public StatsCommand() {
- super("neustats");
- }
-
- @Override
- public void processCommand(ICommandSender sender, String[] args) {
- if (args.length > 0){
- switch (args[0].toLowerCase(Locale.ROOT)) {
- case "modlist":
- clipboardAndSendMessage(createModList(new DiscordMarkdownBuilder()).toString());
- break;
- case "dump":
- modPrefixedMessage(EnumChatFormatting.GREEN + "This will upload a dump of the java classes your game has loaded how big they are and how many there are. This can take a few seconds as it is uploading to HasteBin.");
- threadPool.submit(() -> {
- try {
- final MBeanServer server = ManagementFactory.getPlatformMBeanServer();
- final ObjectName objectName = ObjectName.getInstance("com.sun.management:type=DiagnosticCommand");
- final DiagnosticCommandMXBean proxy = JMX.newMXBeanProxy(server, objectName, DiagnosticCommandMXBean.class);
- clipboardAndSendMessage(HastebinUploader.upload(proxy.gcClassHistogram(new String[0]).replace("[", "[]"), HastebinUploader.Mode.NORMAL));
- }catch (Exception e){
- clipboardAndSendMessage(null);
- }
- });
- break;
- }
- } else {
- clipboardAndSendMessage(createStats());
- }
-
- }
-
- @Override
- public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) {
- return args.length == 1 ? getListOfStringsMatchingLastWord(args, "modlist", "dump") : null;
- }
-
- public interface DiagnosticCommandMXBean {
- String gcClassHistogram(String[] array);
- }
-
- private static void clipboardAndSendMessage(String data) {
- if (data == null) {
- modPrefixedMessage(EnumChatFormatting.DARK_RED + "Error occurred trying to perform command.");
- return;
- }
- try {
- StringSelection clipboard = new StringSelection(data);
- Toolkit.getDefaultToolkit().getSystemClipboard().setContents(clipboard, clipboard);
- modPrefixedMessage(EnumChatFormatting.GREEN + "Dev info copied to clipboard.");
- } catch (Exception ignored) {
- modPrefixedMessage(EnumChatFormatting.DARK_RED + "Could not copy to clipboard.");
- }
- }
-
- private static void modPrefixedMessage(String message) {
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GOLD + "[" + EnumChatFormatting.RED + "NotEnoughUpdates" + EnumChatFormatting.GOLD + "]: " + message));
-
- }
-
- private static String createStats() {
- DiscordMarkdownBuilder builder = new DiscordMarkdownBuilder();
- long maxMemory = Runtime.getRuntime().maxMemory();
- long totalMemory = Runtime.getRuntime().totalMemory();
- long freeMemory = Runtime.getRuntime().freeMemory();
- long currentMemory = totalMemory - freeMemory;
- int activeModCount = Loader.instance().getActiveModList().size();
-
- builder.category("System Stats");
- builder.append("OS", System.getProperty("os.name"));
- builder.append("CPU", OpenGlHelper.getCpu());
- builder.append("Display", String.format("%dx%d (%s)", Display.getWidth(), Display.getHeight(), GL11.glGetString(GL11.GL_VENDOR)));
- builder.append("GPU", GL11.glGetString(GL11.GL_RENDERER));
- builder.append("GPU Driver", GL11.glGetString(GL11.GL_VERSION));
- if(getMemorySize() > 0) builder.append("Maximum Memory", (getMemorySize() / 1024L / 1024L) + "MB");
- builder.append("Shaders", (""+OpenGlHelper.isFramebufferEnabled()).toUpperCase());
- builder.category("Java Stats");
- builder.append("Java", String.format("%s %dbit", System.getProperty("java.version"), Minecraft.getMinecraft().isJava64bit() ? 64 : 32));
- builder.append("Memory", String.format("% 2d%% %03d/%03dMB", currentMemory * 100L / maxMemory, currentMemory / 1024L / 1024L, maxMemory / 1024L / 1024L));
- builder.append("Memory Allocated", String.format("% 2d%% %03dMB", totalMemory * 100L / maxMemory, totalMemory / 1024L / 1024L));
- builder.category("Game Stats");
- builder.append("FPS", String.valueOf(Minecraft.getDebugFPS()));
- builder.append("Loaded Mods", String.valueOf(activeModCount));
- builder.append("Forge", ForgeVersion.getVersion());
- builder.category("Neu Settings");
- builder.append("API Key", NotEnoughUpdates.INSTANCE.config.apiKey.apiKey.isEmpty() ? "FALSE" : "TRUE");
- builder.append("On Skyblock", NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() ? "TRUE" : "FALSE");
- builder.append("Mod Version", Loader.instance().getIndexedModList().get(NotEnoughUpdates.MODID).getSource().getName());
- builder.append("SB Profile", SBInfo.getInstance().currentProfile);
- builder.category("Repo Stats");
- builder.append("Last Commit", NotEnoughUpdates.INSTANCE.manager.latestRepoCommit);
- builder.append("Loaded Items", String.valueOf(NotEnoughUpdates.INSTANCE.manager.getItemInformation().size()));
- if (activeModCount <= 15) createModList(builder);
-
- return builder.toString();
- }
-
- private static DiscordMarkdownBuilder createModList(DiscordMarkdownBuilder builder) {
- builder.category("Mods Loaded");
- Loader.instance().getActiveModList().forEach(mod -> builder.append(mod.getName(), mod.getSource().getName()));
- return builder;
- }
-
- private static long getMemorySize(){
- try {
- return ((com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean()).getTotalPhysicalMemorySize();
- } catch(Exception e){
- try {
- return ((com.sun.management.UnixOperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean()).getTotalPhysicalMemorySize();
- } catch(Exception ignored){/*IGNORE*/}
- }
- return -1;
- }
-
-}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java
new file mode 100644
index 00000000..66da4f9f
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.java
@@ -0,0 +1,207 @@
+package io.github.moulberry.notenoughupdates.commands.dev;
+
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.commands.ClientCommandBase;
+import io.github.moulberry.notenoughupdates.core.config.GuiPositionEditor;
+import io.github.moulberry.notenoughupdates.miscfeatures.FancyPortals;
+import io.github.moulberry.notenoughupdates.miscfeatures.FishingHelper;
+import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.CustomBiomes;
+import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.LocationChangeEvent;
+import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.SpecialBlockZone;
+import io.github.moulberry.notenoughupdates.miscgui.GuiPriceGraph;
+import io.github.moulberry.notenoughupdates.util.SBInfo;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.entity.EntityPlayerSP;
+import net.minecraft.command.CommandException;
+import net.minecraft.command.ICommandSender;
+import net.minecraft.util.*;
+import net.minecraftforge.common.MinecraftForge;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
+public class DevTestCommand extends ClientCommandBase {
+
+ private static final List<String> DEV_TESTERS =
+ Arrays.asList("moulberry", "lucycoconut", "ironm00n", "ariyio", "throwpo", "lrg89", "dediamondpro");
+
+ private static final String[] DEV_FAIL_STRINGS = {
+ "No.",
+ "I said no.",
+ "You aren't allowed to use this.",
+ "Are you sure you want to use this? Type 'Yes' in chat.",
+ "Are you sure you want to use this? Type 'Yes' in chat.",
+ "Lmao you thought",
+ "Ok please stop",
+ "What do you want from me?",
+ "This command almost certainly does nothing useful for you",
+ "Ok, this is the last message, after this it will repeat",
+ "No.",
+ "I said no.",
+ "Dammit. I thought that would work. Uhh...",
+ "\u00a7dFrom \u00a7c[ADMIN] Minikloon\u00a77: If you use that command again, I'll have to ban you",
+ "",
+ "Ok, this is actually the last message, use the command again and you'll crash I promise"
+ };
+
+ private int devFailIndex = 0;
+ private final ScheduledExecutorService devES = Executors.newSingleThreadScheduledExecutor();
+
+ public DevTestCommand() {
+ super("neudevtest");
+ }
+
+ @Override
+ public void processCommand(ICommandSender sender, String[] args) throws CommandException {
+ if (!DEV_TESTERS.contains(Minecraft.getMinecraft().thePlayer.getName().toLowerCase())) {
+ if (devFailIndex >= DEV_FAIL_STRINGS.length) {
+ throw new Error("L") {
+ @Override
+ public void printStackTrace() {
+ throw new Error("L");
+ }
+ };
+ }
+ if (devFailIndex == DEV_FAIL_STRINGS.length - 2) {
+ devFailIndex++;
+
+ ChatComponentText component = new ChatComponentText("\u00a7cYou are permanently banned from this server!");
+ component.appendText("\n");
+ component.appendText("\n\u00a77Reason: \u00a7rI told you not to run the command - Moulberry");
+ component.appendText("\n\u00a77Find out more: \u00a7b\u00a7nhttps://www.hypixel.net/appeal");
+ component.appendText("\n");
+ component.appendText("\n\u00a77Ban ID: \u00a7r#49871982");
+ component.appendText("\n\u00a77Sharing your Ban ID may affect the processing of your appeal!");
+ Minecraft.getMinecraft().getNetHandler().getNetworkManager().closeChannel(component);
+ return;
+ }
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED +
+ DEV_FAIL_STRINGS[devFailIndex++]));
+ return;
+ }
+ /*if(args.length == 1) {
+ DupePOC.doDupe(args[0]);
+ return;
+ }*/
+ if (args.length >= 1 && args[0].equalsIgnoreCase("profileinfo")) {
+ String currentProfile = SBInfo.getInstance().currentProfile;
+ SBInfo.Gamemode gamemode = SBInfo.getInstance().getGamemodeForProfile(currentProfile);
+ sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GOLD +
+ "You are on Profile " +
+ currentProfile +
+ " with the mode " +
+ gamemode));
+ }
+ if (args.length >= 1 && args[0].equalsIgnoreCase("pricetest")) {
+ if (args.length == 1) {
+ NotEnoughUpdates.INSTANCE.manager.auctionManager.updateBazaar();
+ } else {
+ NotEnoughUpdates.INSTANCE.openGui = new GuiPriceGraph(args[1]);
+ }
+ }
+ if (args.length == 1 && args[0].equalsIgnoreCase("zone")) {
+ BlockPos target = Minecraft.getMinecraft().objectMouseOver.getBlockPos();
+ if (target == null) target = Minecraft.getMinecraft().thePlayer.getPosition();
+ SpecialBlockZone zone = CustomBiomes.INSTANCE.getSpecialZone(target);
+ Arrays.asList(
+ new ChatComponentText("Showing Zone Info for: " + target),
+ new ChatComponentText("Zone: " + (zone != null ? zone.name() : "null")),
+ new ChatComponentText("Location: " + SBInfo.getInstance().getLocation()),
+ new ChatComponentText("Biome: " + CustomBiomes.INSTANCE.getCustomBiome(target))
+ ).forEach(Minecraft.getMinecraft().thePlayer::addChatMessage);
+ MinecraftForge.EVENT_BUS.post(new LocationChangeEvent(SBInfo.getInstance().getLocation(), SBInfo
+ .getInstance()
+ .getLocation()));
+ }
+ if (args.length == 1 && args[0].equalsIgnoreCase("positiontest")) {
+ NotEnoughUpdates.INSTANCE.openGui = new GuiPositionEditor();
+ return;
+ }
+
+ if (args.length == 2 && args[0].equalsIgnoreCase("pt")) {
+ EnumParticleTypes t = EnumParticleTypes.valueOf(args[1]);
+ FishingHelper.type = t;
+ return;
+ }
+ if (args.length == 1 && args[0].equalsIgnoreCase("dev")) {
+ NotEnoughUpdates.INSTANCE.config.hidden.dev = true;
+ return;
+ }
+ if (args.length == 1 && args[0].equalsIgnoreCase("saveconfig")) {
+ NotEnoughUpdates.INSTANCE.saveConfig();
+ return;
+ }
+ if (args.length == 1 && args[0].equalsIgnoreCase("searchmode")) {
+ NotEnoughUpdates.INSTANCE.config.hidden.firstTimeSearchFocus = true;
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA +
+ "I would never search"));
+ return;
+ }
+ if (args.length == 1 && args[0].equalsIgnoreCase("center")) {
+ double x = Math.floor(Minecraft.getMinecraft().thePlayer.posX) + 0.5f;
+ double z = Math.floor(Minecraft.getMinecraft().thePlayer.posZ) + 0.5f;
+ Minecraft.getMinecraft().thePlayer.setPosition(x, Minecraft.getMinecraft().thePlayer.posY, z);
+ return;
+ }
+ if (args.length == 1 && args[0].equalsIgnoreCase("pansc")) {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN +
+ "Taking panorama screenshot"));
+
+ AtomicInteger perspective = new AtomicInteger(0);
+ FancyPortals.perspectiveId = 0;
+
+ EntityPlayerSP p = Minecraft.getMinecraft().thePlayer;
+ p.prevRotationYaw = p.rotationYaw = 0;
+ p.prevRotationPitch = p.rotationPitch = 90;
+ devES.schedule(new Runnable() {
+ @Override
+ public void run() {
+ Minecraft.getMinecraft().addScheduledTask(() -> {
+ ScreenShotHelper.saveScreenshot(new File("C:/Users/James/Desktop/"), "pansc-" + perspective.get() + ".png",
+ Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight,
+ Minecraft.getMinecraft().getFramebuffer()
+ );
+ });
+ if (perspective.incrementAndGet() >= 6) {
+ FancyPortals.perspectiveId = -1;
+ return;
+ }
+ devES.schedule(() -> {
+ FancyPortals.perspectiveId = perspective.get();
+ if (FancyPortals.perspectiveId == 5) {
+ p.prevRotationYaw = p.rotationYaw = 0;
+ p.prevRotationPitch = p.rotationPitch = -90;
+ } else if (FancyPortals.perspectiveId >= 1 && FancyPortals.perspectiveId <= 4) {
+ float yaw = 90 * FancyPortals.perspectiveId - 180;
+ if (yaw > 180) yaw -= 360;
+ p.prevRotationYaw = p.rotationYaw = yaw;
+ p.prevRotationPitch = p.rotationPitch = 0;
+ }
+ devES.schedule(this, 3000L, TimeUnit.MILLISECONDS);
+ }, 100L, TimeUnit.MILLISECONDS);
+ }
+ }, 3000L, TimeUnit.MILLISECONDS);
+
+ return;
+ }
+
+ /* if(args.length == 1 && args[0].equalsIgnoreCase("update")) {
+ NEUEventListener.displayUpdateMessageIfOutOfDate();
+ } */
+
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN +
+ "Executing dubious code"));
+ /*Minecraft.getMinecraft().thePlayer.rotationYaw = 0;
+ Minecraft.getMinecraft().thePlayer.rotationPitch = 0;
+ Minecraft.getMinecraft().thePlayer.setPosition(
+ Math.floor(Minecraft.getMinecraft().thePlayer.posX) + Float.parseFloat(args[0]),
+ Minecraft.getMinecraft().thePlayer.posY,
+ Minecraft.getMinecraft().thePlayer.posZ);*/
+ //Hot reload me yay!
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DungeonWinTestCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DungeonWinTestCommand.java
new file mode 100644
index 00000000..223e154a
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/DungeonWinTestCommand.java
@@ -0,0 +1,23 @@
+package io.github.moulberry.notenoughupdates.commands.dev;
+
+import io.github.moulberry.notenoughupdates.commands.ClientCommandBase;
+import io.github.moulberry.notenoughupdates.dungeons.DungeonWin;
+import net.minecraft.command.CommandException;
+import net.minecraft.command.ICommandSender;
+import net.minecraft.util.ResourceLocation;
+
+public class DungeonWinTestCommand extends ClientCommandBase {
+
+ public DungeonWinTestCommand() {
+ super("neudungeonwintest");
+ }
+
+ @Override
+ public void processCommand(ICommandSender sender, String[] args) throws CommandException {
+ if (args.length > 0) {
+ DungeonWin.TEAM_SCORE = new ResourceLocation("notenoughupdates:dungeon_win/" + args[0].toLowerCase() + ".png");
+ }
+
+ DungeonWin.displayWin();
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/NullzeeSphereCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/NullzeeSphereCommand.java
new file mode 100644
index 00000000..64d64545
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/NullzeeSphereCommand.java
@@ -0,0 +1,42 @@
+package io.github.moulberry.notenoughupdates.commands.dev;
+
+import io.github.moulberry.notenoughupdates.commands.ClientCommandBase;
+import io.github.moulberry.notenoughupdates.miscfeatures.NullzeeSphere;
+import net.minecraft.client.entity.EntityPlayerSP;
+import net.minecraft.command.CommandException;
+import net.minecraft.command.ICommandSender;
+import net.minecraft.util.BlockPos;
+import net.minecraft.util.ChatComponentText;
+import net.minecraft.util.EnumChatFormatting;
+
+public class NullzeeSphereCommand extends ClientCommandBase {
+
+ public NullzeeSphereCommand() {
+ super("neuzeesphere");
+ }
+
+ @Override
+ public void processCommand(ICommandSender sender, String[] args) throws CommandException {
+ if (args.length != 1) {
+ sender.addChatMessage(new ChatComponentText(
+ EnumChatFormatting.RED + "Usage: /neuzeesphere [on/off] or /neuzeesphere (radius) or /neuzeesphere setCenter"));
+ return;
+ }
+ if (args[0].equalsIgnoreCase("on")) {
+ NullzeeSphere.enabled = true;
+ } else if (args[0].equalsIgnoreCase("off")) {
+ NullzeeSphere.enabled = false;
+ } else if (args[0].equalsIgnoreCase("setCenter")) {
+ EntityPlayerSP p = ((EntityPlayerSP) sender);
+ NullzeeSphere.centerPos = new BlockPos(p.posX, p.posY, p.posZ);
+ NullzeeSphere.overlayVBO = null;
+ } else {
+ try {
+ NullzeeSphere.size = Float.parseFloat(args[0]);
+ NullzeeSphere.overlayVBO = null;
+ } catch (Exception e) {
+ sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Can't parse radius: " + args[0]));
+ }
+ }
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/PackDevCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/PackDevCommand.java
new file mode 100644
index 00000000..e809ed72
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/PackDevCommand.java
@@ -0,0 +1,59 @@
+package io.github.moulberry.notenoughupdates.commands.dev;
+
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.commands.ClientCommandBase;
+import io.github.moulberry.notenoughupdates.core.util.MiscUtils;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.entity.AbstractClientPlayer;
+import net.minecraft.client.entity.EntityPlayerSP;
+import net.minecraft.command.CommandException;
+import net.minecraft.command.ICommandSender;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.util.ChatComponentText;
+import net.minecraft.util.EnumChatFormatting;
+
+public class PackDevCommand extends ClientCommandBase {
+
+ public PackDevCommand() {
+ super("neupackdev");
+ }
+
+ @Override
+ public void processCommand(ICommandSender sender, String[] args) throws CommandException {
+ 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;
+ }
+ NotEnoughUpdates.INSTANCE.packDevEnabled = !NotEnoughUpdates.INSTANCE.packDevEnabled;
+ if (NotEnoughUpdates.INSTANCE.packDevEnabled) {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
+ EnumChatFormatting.GREEN + "Enabled pack developer mode."));
+ } else {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
+ EnumChatFormatting.RED + "Disabled pack developer mode."));
+ }
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/StatsCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/StatsCommand.java
new file mode 100644
index 00000000..38eafe39
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/dev/StatsCommand.java
@@ -0,0 +1,181 @@
+package io.github.moulberry.notenoughupdates.commands.dev;
+
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.commands.ClientCommandBase;
+import io.github.moulberry.notenoughupdates.util.DiscordMarkdownBuilder;
+import io.github.moulberry.notenoughupdates.util.HastebinUploader;
+import io.github.moulberry.notenoughupdates.util.SBInfo;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.renderer.OpenGlHelper;
+import net.minecraft.command.ICommandSender;
+import net.minecraft.util.BlockPos;
+import net.minecraft.util.ChatComponentText;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraftforge.common.ForgeVersion;
+import net.minecraftforge.fml.common.Loader;
+import org.lwjgl.opengl.Display;
+import org.lwjgl.opengl.GL11;
+
+import javax.management.JMX;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import java.awt.*;
+import java.awt.datatransfer.StringSelection;
+import java.lang.management.ManagementFactory;
+import java.util.List;
+import java.util.Locale;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+public class StatsCommand extends ClientCommandBase {
+ private final ExecutorService threadPool = Executors.newFixedThreadPool(1);
+
+ public StatsCommand() {
+ super("neustats");
+ }
+
+ private static final int activeModCount = Loader.instance().getActiveModList().size();
+
+ @Override
+ public void processCommand(ICommandSender sender, String[] args) {
+ if (args.length > 0) {
+ switch (args[0].toLowerCase(Locale.ROOT)) {
+ case "modlist":
+ if (activeModCount > 15) {
+ clipboardAndSendMessage(createModList(new DiscordMarkdownBuilder()).toString());
+ } else {
+ clipboardAndSendMessage(createStats());
+ }
+ break;
+ case "dump":
+ modPrefixedMessage(EnumChatFormatting.GREEN +
+ "This will upload a dump of the java classes your game has loaded how big they are and how many there are. This can take a few seconds as it is uploading to HasteBin.");
+ threadPool.submit(() -> {
+ try {
+ final MBeanServer server = ManagementFactory.getPlatformMBeanServer();
+ final ObjectName objectName = ObjectName.getInstance("com.sun.management:type=DiagnosticCommand");
+ final DiagnosticCommandMXBean proxy = JMX.newMXBeanProxy(
+ server,
+ objectName,
+ DiagnosticCommandMXBean.class
+ );
+ clipboardAndSendMessage(HastebinUploader.upload(
+ proxy.gcClassHistogram(new String[0]).replace("[", "[]"),
+ HastebinUploader.Mode.NORMAL
+ ));
+ } catch (Exception e) {
+ clipboardAndSendMessage(null);
+ }
+ });
+ break;
+ }
+ } else {
+ clipboardAndSendMessage(createStats());
+ }
+
+ }
+
+ @Override
+ public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) {
+ return args.length == 1 ? getListOfStringsMatchingLastWord(args, "modlist", "dump") : null;
+ }
+
+ public interface DiagnosticCommandMXBean {
+ String gcClassHistogram(String[] array);
+ }
+
+ private static void clipboardAndSendMessage(String data) {
+ if (data == null) {
+ modPrefixedMessage(EnumChatFormatting.DARK_RED + "Error occurred trying to perform command.");
+ return;
+ }
+ try {
+ StringSelection clipboard = new StringSelection(data);
+ Toolkit.getDefaultToolkit().getSystemClipboard().setContents(clipboard, clipboard);
+ modPrefixedMessage(EnumChatFormatting.GREEN + "Dev info copied to clipboard.");
+ } catch (Exception ignored) {
+ modPrefixedMessage(EnumChatFormatting.DARK_RED + "Could not copy to clipboard.");
+ }
+ }
+
+ private static void modPrefixedMessage(String message) {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
+ EnumChatFormatting.GOLD + "[" + EnumChatFormatting.RED + "NotEnoughUpdates" + EnumChatFormatting.GOLD + "]: " +
+ message));
+
+ }
+
+ private static String createStats() {
+ DiscordMarkdownBuilder builder = new DiscordMarkdownBuilder();
+ long maxMemory = Runtime.getRuntime().maxMemory();
+ long totalMemory = Runtime.getRuntime().totalMemory();
+ long freeMemory = Runtime.getRuntime().freeMemory();
+ long currentMemory = totalMemory - freeMemory;
+
+ builder.category("System Stats");
+ builder.append("OS", System.getProperty("os.name"));
+ builder.append("CPU", OpenGlHelper.getCpu());
+ builder.append(
+ "Display",
+ String.format("%dx%d (%s)", Display.getWidth(), Display.getHeight(), GL11.glGetString(GL11.GL_VENDOR))
+ );
+ builder.append("GPU", GL11.glGetString(GL11.GL_RENDERER));
+ builder.append("GPU Driver", GL11.glGetString(GL11.GL_VERSION));
+ if (getMemorySize() > 0) builder.append("Maximum Memory", (getMemorySize() / 1024L / 1024L) + "MB");
+ builder.append("Shaders", ("" + OpenGlHelper.isFramebufferEnabled()).toUpperCase());
+ builder.category("Java Stats");
+ builder.append(
+ "Java",
+ String.format("%s %dbit", System.getProperty("java.version"), Minecraft.getMinecraft().isJava64bit() ? 64 : 32)
+ );
+ builder.append(
+ "Memory",
+ String.format(
+ "% 2d%% %03d/%03dMB",
+ currentMemory * 100L / maxMemory,
+ currentMemory / 1024L / 1024L,
+ maxMemory / 1024L / 1024L
+ )
+ );
+ builder.append(
+ "Memory Allocated",
+ String.format("% 2d%% %03dMB", totalMemory * 100L / maxMemory, totalMemory / 1024L / 1024L)
+ );
+ builder.category("Game Stats");
+ builder.append("FPS", String.valueOf(Minecraft.getDebugFPS()));
+ builder.append("Loaded Mods", String.valueOf(activeModCount));
+ builder.append("Forge", ForgeVersion.getVersion());
+ builder.category("Neu Settings");
+ builder.append("API Key", NotEnoughUpdates.INSTANCE.config.apiKey.apiKey.isEmpty() ? "FALSE" : "TRUE");
+ builder.append("On Skyblock", NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() ? "TRUE" : "FALSE");
+ builder.append(
+ "Mod Version",
+ Loader.instance().getIndexedModList().get(NotEnoughUpdates.MODID).getDisplayVersion()
+ );
+ builder.append("SB Profile", SBInfo.getInstance().currentProfile);
+ builder.append("Has Advanced Tab", SBInfo.getInstance().hasNewTab ? "TRUE" : "FALSE");
+ builder.category("Repo Stats");
+ builder.append("Last Commit", NotEnoughUpdates.INSTANCE.manager.latestRepoCommit);
+ builder.append("Loaded Items", String.valueOf(NotEnoughUpdates.INSTANCE.manager.getItemInformation().size()));
+ if (activeModCount <= 15) createModList(builder);
+
+ return builder.toString();
+ }
+
+ private static DiscordMarkdownBuilder createModList(DiscordMarkdownBuilder builder) {
+ builder.category("Mods Loaded");
+ Loader.instance().getActiveModList().forEach(mod -> builder.append(mod.getName(), mod.getSource().getName()));
+ return builder;
+ }
+
+ private static long getMemorySize() {
+ try {
+ return ((com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean()).getTotalPhysicalMemorySize();
+ } catch (Exception e) {
+ try {
+ return ((com.sun.management.UnixOperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean()).getTotalPhysicalMemorySize();
+ } catch (Exception ignored) {/*IGNORE*/}
+ }
+ return -1;
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/DhCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/DhCommand.java
new file mode 100644
index 00000000..89299a36
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/DhCommand.java
@@ -0,0 +1,18 @@
+package io.github.moulberry.notenoughupdates.commands.dungeon;
+
+import io.github.moulberry.notenoughupdates.commands.ClientCommandBase;
+import net.minecraft.client.Minecraft;
+import net.minecraft.command.CommandException;
+import net.minecraft.command.ICommandSender;
+
+public class DhCommand extends ClientCommandBase {
+
+ public DhCommand() {
+ super("dh");
+ }
+
+ @Override
+ public void processCommand(ICommandSender sender, String[] args) throws CommandException {
+ Minecraft.getMinecraft().thePlayer.sendChatMessage("/warp dungeon_hub");
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/DnCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/DnCommand.java
new file mode 100644
index 00000000..8fbbceba
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/DnCommand.java
@@ -0,0 +1,22 @@
+package io.github.moulberry.notenoughupdates.commands.dungeon;
+
+import io.github.moulberry.notenoughupdates.commands.ClientCommandBase;
+import net.minecraft.client.Minecraft;
+import net.minecraft.command.CommandException;
+import net.minecraft.command.ICommandSender;
+import net.minecraft.util.ChatComponentText;
+import net.minecraft.util.EnumChatFormatting;
+
+public class DnCommand extends ClientCommandBase {
+
+ public DnCommand() {
+ super("dn");
+ }
+
+ @Override
+ public void processCommand(ICommandSender sender, String[] args) throws CommandException {
+ Minecraft.getMinecraft().thePlayer.sendChatMessage("/warp dungeon_hub");
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
+ EnumChatFormatting.AQUA + "Warping to:" + EnumChatFormatting.YELLOW + " Deez Nuts lmao"));
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/JoinDungeonCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/JoinDungeonCommand.java
new file mode 100644
index 00000000..874e81db
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/JoinDungeonCommand.java
@@ -0,0 +1,41 @@
+package io.github.moulberry.notenoughupdates.commands.dungeon;
+
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.commands.ClientCommandBase;
+import net.minecraft.client.Minecraft;
+import net.minecraft.command.CommandException;
+import net.minecraft.command.ICommandSender;
+import net.minecraft.util.ChatComponentText;
+import net.minecraft.util.EnumChatFormatting;
+import org.apache.commons.lang3.StringUtils;
+
+public class JoinDungeonCommand extends ClientCommandBase {
+
+ public JoinDungeonCommand() {
+ super("join");
+ }
+
+ @Override
+ public void processCommand(ICommandSender sender, String[] args) throws CommandException {
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
+ Minecraft.getMinecraft().thePlayer.sendChatMessage("/join " + StringUtils.join(args, " "));
+ } else {
+ if (args.length != 1) {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
+ EnumChatFormatting.RED + "Example Usage: /join f7, /join m6 or /join 7"));
+ } else {
+ String cataPrefix = "catacombs";
+ if (args[0].startsWith("m")) {
+ cataPrefix = "master_catacombs";
+ }
+ String cmd = "/joindungeon " + cataPrefix + " " + args[0].charAt(args[0].length() - 1);
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
+ EnumChatFormatting.YELLOW + "Running command: " + cmd));
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
+ EnumChatFormatting.YELLOW +
+ "The dungeon should start soon. If it doesn't, make sure you have a party of 5 people"));
+ Minecraft.getMinecraft().thePlayer.sendChatMessage(cmd);
+ }
+ }
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/MapCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/MapCommand.java
new file mode 100644
index 00000000..ae06a346
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/MapCommand.java
@@ -0,0 +1,142 @@
+package io.github.moulberry.notenoughupdates.commands.dungeon;
+
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.commands.ClientCommandBase;
+import io.github.moulberry.notenoughupdates.dungeons.GuiDungeonMapEditor;
+import net.minecraft.block.material.MapColor;
+import net.minecraft.client.Minecraft;
+import net.minecraft.command.CommandException;
+import net.minecraft.command.ICommandSender;
+import net.minecraft.item.ItemMap;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.ChatComponentText;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.world.storage.MapData;
+
+import java.awt.*;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
+import java.util.Map;
+
+public class MapCommand extends ClientCommandBase {
+
+ public MapCommand() {
+ super("neumap");
+ }
+
+ @Override
+ public void processCommand(ICommandSender sender, String[] args) throws CommandException {
+ if (NotEnoughUpdates.INSTANCE.colourMap == null) {
+ try (
+ BufferedReader reader = new BufferedReader(new InputStreamReader(Minecraft
+ .getMinecraft()
+ .getResourceManager()
+ .getResource(
+ new ResourceLocation("notenoughupdates:maps/F1Full.json"))
+ .getInputStream(), StandardCharsets.UTF_8))
+ ) {
+ JsonObject json = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(reader, JsonObject.class);
+
+ NotEnoughUpdates.INSTANCE.colourMap = new Color[128][128];
+ for (int x = 0; x < 128; x++) {
+ for (int y = 0; y < 128; y++) {
+ NotEnoughUpdates.INSTANCE.colourMap[x][y] = new Color(0, 0, 0, 0);
+ }
+ }
+ for (Map.Entry<String, JsonElement> entry : json.entrySet()) {
+ int x = Integer.parseInt(entry.getKey().split(":")[0]);
+ int y = Integer.parseInt(entry.getKey().split(":")[1]);
+
+ NotEnoughUpdates.INSTANCE.colourMap[x][y] = new Color(entry.getValue().getAsInt(), true);
+ }
+ } catch (Exception ignored) {
+ }
+ }
+
+ if (!NotEnoughUpdates.INSTANCE.config.hidden.dev) {
+ NotEnoughUpdates.INSTANCE.openGui = new GuiDungeonMapEditor();
+ return;
+ }
+
+ if (args.length == 1 && args[0].equals("reset")) {
+ NotEnoughUpdates.INSTANCE.colourMap = null;
+ return;
+ }
+
+ if (args.length != 2) {
+ NotEnoughUpdates.INSTANCE.openGui = new GuiDungeonMapEditor();
+ return;
+ }
+
+ if (args[0].equals("save")) {
+ ItemStack stack = Minecraft.getMinecraft().thePlayer.getHeldItem();
+ if (stack != null && stack.getItem() instanceof ItemMap) {
+ ItemMap map = (ItemMap) stack.getItem();
+ MapData mapData = map.getMapData(stack, Minecraft.getMinecraft().theWorld);
+
+ if (mapData == null) return;
+
+ JsonObject json = new JsonObject();
+ for (int i = 0; i < 16384; ++i) {
+ int x = i % 128;
+ int y = i / 128;
+
+ int j = mapData.colors[i] & 255;
+
+ Color c;
+ if (j / 4 == 0) {
+ c = new Color((i + i / 128 & 1) * 8 + 16 << 24, true);
+ } else {
+ c = new Color(MapColor.mapColorArray[j / 4].getMapColor(j & 3), true);
+ }
+
+ json.addProperty(x + ":" + y, c.getRGB());
+ }
+
+ try {
+ new File(NotEnoughUpdates.INSTANCE.manager.configLocation, "maps").mkdirs();
+ NotEnoughUpdates.INSTANCE.manager.writeJson(
+ json,
+ new File(NotEnoughUpdates.INSTANCE.manager.configLocation, "maps/" + args[1] + ".json")
+ );
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN +
+ "Saved to file."));
+ }
+
+ return;
+ }
+
+ if (args[0].equals("load")) {
+ JsonObject json = NotEnoughUpdates.INSTANCE.manager.getJsonFromFile(new File(
+ NotEnoughUpdates.INSTANCE.manager.configLocation,
+ "maps/" + args[1] + ".json"
+ ));
+
+ NotEnoughUpdates.INSTANCE.colourMap = new Color[128][128];
+ for (int x = 0; x < 128; x++) {
+ for (int y = 0; y < 128; y++) {
+ NotEnoughUpdates.INSTANCE.colourMap[x][y] = new Color(0, 0, 0, 0);
+ }
+ }
+ for (Map.Entry<String, JsonElement> entry : json.entrySet()) {
+ int x = Integer.parseInt(entry.getKey().split(":")[0]);
+ int y = Integer.parseInt(entry.getKey().split(":")[1]);
+
+ NotEnoughUpdates.INSTANCE.colourMap[x][y] = new Color(entry.getValue().getAsInt(), true);
+ }
+
+ return;
+ }
+
+ NotEnoughUpdates.INSTANCE.openGui = new GuiDungeonMapEditor();
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/help/FeaturesCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/help/FeaturesCommand.java
new file mode 100644
index 00000000..593f2575
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/help/FeaturesCommand.java
@@ -0,0 +1,58 @@
+package io.github.moulberry.notenoughupdates.commands.help;
+
+import io.github.moulberry.notenoughupdates.commands.ClientCommandBase;
+import io.github.moulberry.notenoughupdates.util.Constants;
+import io.github.moulberry.notenoughupdates.util.Utils;
+import net.minecraft.client.Minecraft;
+import net.minecraft.command.CommandException;
+import net.minecraft.command.ICommandSender;
+import net.minecraft.event.ClickEvent;
+import net.minecraft.util.ChatComponentText;
+import net.minecraft.util.EnumChatFormatting;
+
+import java.awt.*;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+public class FeaturesCommand extends ClientCommandBase {
+ public FeaturesCommand() {
+ super("neufeatures");
+ }
+
+ @Override
+ public void processCommand(ICommandSender sender, String[] args) throws CommandException {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
+ if (Constants.MISC == null || !Constants.MISC.has("featureslist")) {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
+ "" + EnumChatFormatting.DARK_RED + EnumChatFormatting.BOLD + "WARNING: " + EnumChatFormatting.RESET +
+ EnumChatFormatting.RED + "Could not load URL from repo."));
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
+ "" + EnumChatFormatting.RED + "Please run " + EnumChatFormatting.BOLD + "/neuresetrepo" +
+ EnumChatFormatting.RESET + EnumChatFormatting.RED + " and " + EnumChatFormatting.BOLD + "restart your game" +
+ EnumChatFormatting.RESET + EnumChatFormatting.RED + " in order to fix. " + EnumChatFormatting.DARK_RED +
+ EnumChatFormatting.BOLD + "If that doesn't fix it" + EnumChatFormatting.RESET + EnumChatFormatting.RED +
+ ", please join discord.gg/moulberry and post in #neu-support"));
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
+ return;
+ }
+ String url = Constants.MISC.get("featureslist").getAsString();
+
+ Desktop desk = Desktop.getDesktop();
+ try {
+ desk.browse(new URI(url));
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
+ EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.BOLD + "NEU" + EnumChatFormatting.RESET +
+ EnumChatFormatting.GOLD + "> Opening Feature List in browser."));
+ } catch (URISyntaxException | IOException ignored) {
+
+ ChatComponentText clickTextFeatures = new ChatComponentText(
+ EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.BOLD + "NEU" + EnumChatFormatting.RESET +
+ EnumChatFormatting.GOLD + "> Click here to open the Feature List in your browser.");
+ clickTextFeatures.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, url));
+ Minecraft.getMinecraft().thePlayer.addChatMessage(clickTextFeatures);
+
+ }
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/help/HelpCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/help/HelpCommand.java
new file mode 100644
index 00000000..9669be60
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/help/HelpCommand.java
@@ -0,0 +1,79 @@
+package io.github.moulberry.notenoughupdates.commands.help;
+
+import com.google.common.collect.Lists;
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.commands.ClientCommandBase;
+import net.minecraft.client.Minecraft;
+import net.minecraft.command.CommandException;
+import net.minecraft.command.ICommandSender;
+import net.minecraft.util.ChatComponentText;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class HelpCommand extends ClientCommandBase {
+
+ public HelpCommand() {
+ super("neuhelp");
+ }
+
+ @Override
+ public void processCommand(ICommandSender sender, String[] args) {
+ ArrayList<String> neuHelpMessages = Lists.newArrayList(
+ "\u00a75\u00a7lNotEnoughUpdates commands",
+ "\u00a76/neu \u00a77- Opens the main neu GUI.",
+ "\u00a76/pv \u00a7b?{name} \u00a72\u2D35 \u00a7r\u00a77- Opens the profile viewer",
+ "\u00a76/neusouls {on/off/clear/unclear} \u00a7r\u00a77- Shows waypoints to fairy souls.",
+ "\u00a76/neubuttons \u00a7r\u00a77- Opens a GUI which allows you to customize inventory buttons.",
+ "\u00a76/neuec \u00a7r\u00a77- Opens the enchant colour GUI.",
+ "\u00a76/join {floor} \u00a7r\u00a77- Short Command to join a Dungeon. \u00a7lNeed a Party of 5 People\u00a7r\u00a77 {4/f7/m5}.",
+ "\u00a76/neucosmetics \u00a7r\u00a77- Opens the cosmetic GUI.",
+ "\u00a76/neurename \u00a7r\u00a77- Opens the NEU Item Customizer.",
+ "\u00a76/cata \u00a7b?{name} \u00a72\u2D35 \u00a7r\u00a77- Opens the profile viewer's catacombs page.",
+ "\u00a76/neulinks \u00a7r\u00a77- Shows links to neu/moulberry.",
+ "\u00a76/neuoverlay \u00a7r\u00a77- Opens GUI Editor for quickcommands and searchbar.",
+ "\u00a76/neuah \u00a7r\u00a77- Opens neu's custom ah GUI.",
+ "\u00a76/neumap \u00a7r\u00a77- Opens the dungeon map GUI.",
+ "\u00a76/neucalendar \u00a7r\u00a77- Opens neu's custom calendar GUI.",
+ "",
+ "\u00a76\u00a7lOld commands:",
+ "\u00a76/peek \u00a7b?{user} \u00a72\u2D35 \u00a7r\u00a77- Shows quickly stats for a user.",
+ "",
+ "\u00a76\u00a7lDebug commands:",
+ "\u00a76/neustats \u00a7r\u00a77- Copies helpful info to the clipboard.",
+ "\u00a76/neustats modlist \u00a7r\u00a77- Copies modlist info to clipboard.",
+ "\u00a76/neuresetrepo \u00a7r\u00a77- Deletes all repo files.",
+ "\u00a76/neureloadrepo \u00a7r\u00a77- Debug command with repo.",
+ "",
+ "\u00a76\u00a7lDev commands:",
+ "\u00a76/neupackdev \u00a7r\u00a77- pack creator command - getnpc"
+ );
+ for (String neuHelpMessage : neuHelpMessages) {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(neuHelpMessage));
+ }
+ if (NotEnoughUpdates.INSTANCE.config.hidden.dev) {
+ ArrayList<String> neuDevHelpMessages = Lists.newArrayList(
+ "\u00a76/neudevtest \u00a7r\u00a77- dev test command",
+ "\u00a76/neuzeephere \u00a7r\u00a77- sphere",
+ "\u00a76/neudungeonwintest \u00a7r\u00a77- displays the dungeon win screen"
+ );
+
+ for (String neuDevHelpMessage : neuDevHelpMessages) {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(neuDevHelpMessage));
+ }
+ }
+ String[] helpInfo = {
+ "",
+ "\u00a77Commands marked with a \u00a72\"\u2D35\"\u00a77 require are api key. You can set your api key via \"/api new\" or by manually putting it in the api field in \"/neu\"",
+ "",
+ "\u00a77Arguments marked with a \u00a7b\"?\"\u00a77 are optional.",
+ "",
+ "\u00a76\u00a7lScroll up to see everything"
+ };
+
+ for (String message : helpInfo) {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(message));
+ }
+
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/help/LinksCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/help/LinksCommand.java
new file mode 100644
index 00000000..c81f44a8
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/help/LinksCommand.java
@@ -0,0 +1,34 @@
+package io.github.moulberry.notenoughupdates.commands.help;
+
+import com.google.gson.JsonObject;
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.commands.ClientCommandBase;
+import net.minecraft.client.Minecraft;
+import net.minecraft.command.CommandException;
+import net.minecraft.command.ICommandSender;
+import net.minecraft.util.ChatComponentText;
+
+import java.io.File;
+
+public class LinksCommand extends ClientCommandBase {
+
+ public LinksCommand() {
+ super("neulinks");
+ }
+
+ @Override
+ public void processCommand(ICommandSender sender, String[] args) throws CommandException {
+ File repo = NotEnoughUpdates.INSTANCE.manager.repoLocation;
+ if (repo.exists()) {
+ File updateJson = new File(repo, "update.json");
+ try {
+ JsonObject update = NotEnoughUpdates.INSTANCE.manager.getJsonFromFile(updateJson);
+
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
+ NotEnoughUpdates.INSTANCE.displayLinks(update);
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
+ } catch (Exception ignored) {
+ }
+ }
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/help/SettingsCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/help/SettingsCommand.java
new file mode 100644
index 00000000..08350be9
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/help/SettingsCommand.java
@@ -0,0 +1,34 @@
+package io.github.moulberry.notenoughupdates.commands.help;
+
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.commands.ClientCommandBase;
+import io.github.moulberry.notenoughupdates.core.GuiScreenElementWrapper;
+import io.github.moulberry.notenoughupdates.options.NEUConfigEditor;
+import net.minecraft.command.CommandException;
+import net.minecraft.command.ICommandSender;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class SettingsCommand extends ClientCommandBase {
+
+ public SettingsCommand() {
+ super("neu");
+ }
+
+ @Override
+ public List<String> getCommandAliases() {
+ return Arrays.asList("neusettings", "neuconfig");
+ }
+
+ @Override
+ public void processCommand(ICommandSender sender, String[] args) throws CommandException {
+ if (args.length > 0) {
+ NotEnoughUpdates.INSTANCE.openGui =
+ new GuiScreenElementWrapper(new NEUConfigEditor(NotEnoughUpdates.INSTANCE.config, StringUtils.join(args, " ")));
+ } else {
+ NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper(NEUConfigEditor.editor);
+ }
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/help/StorageViewerWhyCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/help/StorageViewerWhyCommand.java
new file mode 100644
index 00000000..4f85c26e
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/help/StorageViewerWhyCommand.java
@@ -0,0 +1,26 @@
+package io.github.moulberry.notenoughupdates.commands.help;
+
+import com.google.common.collect.Lists;
+import io.github.moulberry.notenoughupdates.NEUEventListener;
+import io.github.moulberry.notenoughupdates.commands.ClientCommandBase;
+import net.minecraft.command.ICommandSender;
+
+public class StorageViewerWhyCommand extends ClientCommandBase {
+
+ public StorageViewerWhyCommand() {
+ super("neustwhy");
+ }
+
+ @Override
+ public void processCommand(ICommandSender sender, String[] args) {
+ NEUEventListener.displayNotification(Lists.newArrayList(
+ "\u00a7eStorage Viewer",
+ "\u00a77Currently, the storage viewer requires you to click twice",
+ "\u00a77in order to switch between pages. This is because Hypixel",
+ "\u00a77has not yet added a shortcut command to go to any enderchest/",
+ "\u00a77storage page.",
+ "\u00a77While it is possible to send the second click",
+ "\u00a77automatically, doing so violates Hypixel's new mod rules."
+ ), true);
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/AhCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/AhCommand.java
new file mode 100644
index 00000000..0b2c155e
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/AhCommand.java
@@ -0,0 +1,38 @@
+package io.github.moulberry.notenoughupdates.commands.misc;
+
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.auction.CustomAHGui;
+import io.github.moulberry.notenoughupdates.commands.ClientCommandBase;
+import net.minecraft.client.Minecraft;
+import net.minecraft.command.CommandException;
+import net.minecraft.command.ICommandSender;
+import net.minecraft.util.ChatComponentText;
+import net.minecraft.util.EnumChatFormatting;
+import org.apache.commons.lang3.StringUtils;
+
+public class AhCommand extends ClientCommandBase {
+
+ public AhCommand() {
+ super("neuah");
+ }
+
+ @Override
+ public void processCommand(ICommandSender sender, String[] args) throws CommandException {
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED +
+ "You must be on Skyblock to use this feature."));
+ } else if (NotEnoughUpdates.INSTANCE.config.apiKey.apiKey == null ||
+ NotEnoughUpdates.INSTANCE.config.apiKey.apiKey.trim().isEmpty()) {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED +
+ "Can't open NeuAH, apikey is not set. Run /api new and put the result in settings."));
+ } else {
+ NotEnoughUpdates.INSTANCE.openGui = new CustomAHGui();
+ NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.lastOpen = System.currentTimeMillis();
+ NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.clearSearch();
+ NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.updateSearch();
+
+ if (args.length > 0)
+ NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.setSearch(StringUtils.join(args, " "));
+ }
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/ButtonsCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/ButtonsCommand.java
new file mode 100644
index 00000000..63d5c327
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/ButtonsCommand.java
@@ -0,0 +1,16 @@
+package io.github.moulberry.notenoughupdates.commands.misc;
+
+import io.github.moulberry.notenoughupdates.commands.ClientCommandBase;
+import net.minecraft.command.CommandException;
+import net.minecraft.command.ICommandSender;
+
+public class ButtonsCommand extends ClientCommandBase {
+ protected ButtonsCommand(String name) {
+ super(name);
+ }
+
+ @Override
+ public void processCommand(ICommandSender sender, String[] args) throws CommandException {
+
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/CalendarCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/CalendarCommand.java
new file mode 100644
index 00000000..d3c472bd
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/CalendarCommand.java
@@ -0,0 +1,22 @@
+package io.github.moulberry.notenoughupdates.commands.misc;
+
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.commands.ClientCommandBase;
+import io.github.moulberry.notenoughupdates.miscgui.CalendarOverlay;
+import net.minecraft.client.Minecraft;
+import net.minecraft.command.CommandException;
+import net.minecraft.command.ICommandSender;
+
+public class CalendarCommand extends ClientCommandBase {
+
+ public CalendarCommand() {
+ super("neucalendar");
+ }
+
+ @Override
+ public void processCommand(ICommandSender sender, String[] args) throws CommandException {
+ Minecraft.getMinecraft().thePlayer.closeScreen();
+ CalendarOverlay.setEnabled(true);
+ NotEnoughUpdates.INSTANCE.sendChatMessage("/calendar");
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/CollectionLogCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/CollectionLogCommand.java
new file mode 100644
index 00000000..1bde7631
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/CollectionLogCommand.java
@@ -0,0 +1,20 @@
+package io.github.moulberry.notenoughupdates.commands.misc;
+
+import io.github.moulberry.notenoughupdates.collectionlog.GuiCollectionLog;
+import io.github.moulberry.notenoughupdates.commands.ScreenCommand;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+public class CollectionLogCommand extends ScreenCommand {
+
+ public CollectionLogCommand() {
+ super("neucl", GuiCollectionLog::new);
+ }
+
+ @Override
+ public List<String> getCommandAliases() {
+ return Collections.singletonList("collectionlog");
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/CosmeticsCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/CosmeticsCommand.java
new file mode 100644
index 00000000..9ccb7cf0
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/CosmeticsCommand.java
@@ -0,0 +1,29 @@
+package io.github.moulberry.notenoughupdates.commands.misc;
+
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.commands.ClientCommandBase;
+import io.github.moulberry.notenoughupdates.cosmetics.GuiCosmetics;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.renderer.OpenGlHelper;
+import net.minecraft.command.CommandException;
+import net.minecraft.command.ICommandSender;
+import net.minecraft.util.ChatComponentText;
+import net.minecraft.util.EnumChatFormatting;
+
+public class CosmeticsCommand extends ClientCommandBase {
+
+ public CosmeticsCommand() {
+ super("neucosmetics");
+ }
+
+ @Override
+ public void processCommand(ICommandSender sender, String[] args) throws CommandException {
+ if (!OpenGlHelper.isFramebufferEnabled()) {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED +
+ "NEU cosmetics do not work with OF Fast Render. Go to ESC > Options > Video Settings > Performance > Fast Render to disable it."));
+
+ }
+
+ NotEnoughUpdates.INSTANCE.openGui = new GuiCosmetics();
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/CustomizeCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/CustomizeCommand.java
new file mode 100644
index 00000000..6bce4f5a
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/CustomizeCommand.java
@@ -0,0 +1,130 @@
+package io.github.moulberry.notenoughupdates.commands.misc;
+
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.commands.ClientCommandBase;
+import io.github.moulberry.notenoughupdates.miscgui.GuiItemCustomize;
+import net.minecraft.client.Minecraft;
+import net.minecraft.command.CommandException;
+import net.minecraft.command.ICommandSender;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.ChatComponentText;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+public class CustomizeCommand extends ClientCommandBase {
+
+ public CustomizeCommand() {
+ super("neucustomize");
+ }
+
+ @Override
+ public List<String> getCommandAliases() {
+ return Collections.singletonList("neurename");
+ }
+
+ @Override
+ public void processCommand(ICommandSender sender, String[] args) throws CommandException {
+ ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem();
+
+ if (held == null) {
+ sender.addChatMessage(new ChatComponentText("\u00a7cYou can't customize your hand..."));
+ return;
+ }
+
+ String heldUUID = NotEnoughUpdates.INSTANCE.manager.getUUIDForItem(held);
+
+ if (heldUUID == null) {
+ sender.addChatMessage(new ChatComponentText("\u00a7cHeld item does not have UUID, cannot be customized"));
+ return;
+ }
+
+ NotEnoughUpdates.INSTANCE.openGui = new GuiItemCustomize(held, heldUUID);
+ }
+
+ /*SimpleCommand itemRenameCommand = new SimpleCommand("neurename", new SimpleCommand.ProcessCommandRunnable() {
+ public void processCommand(ICommandSender sender, String[] args) {
+ if (args.length == 0) {
+ args = new String[]{"help"};
+ }
+ String heldUUID = NotEnoughUpdates.INSTANCE.manager.getUUIDForItem(Minecraft.getMinecraft().thePlayer.getHeldItem());
+ switch (args[0].toLowerCase()) {
+ case "clearall":
+ NotEnoughUpdates.INSTANCE.manager.itemRenameJson = new JsonObject();
+ NotEnoughUpdates.INSTANCE.manager.saveItemRenameConfig();
+ sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "[NEU] Cleared custom name for all items"));
+ break;
+ case "clear":
+ if (heldUUID == null) {
+ sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "[NEU] Can't clear rename - no UUID"));
+ return;
+ }
+ NotEnoughUpdates.INSTANCE.manager.itemRenameJson.remove(heldUUID);
+ NotEnoughUpdates.INSTANCE.manager.saveItemRenameConfig();
+ sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "[NEU] Cleared custom name for held item"));
+ break;
+ case "copyuuid":
+ if (heldUUID == null) {
+ sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "[NEU] Can't clear rename - no UUID"));
+ return;
+ }
+ StringSelection selection = new StringSelection(heldUUID);
+ Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, selection);
+ sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "[NEU] UUID copied to clipboard"));
+ break;
+ case "uuid":
+ if (heldUUID == null) {
+ sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "[NEU] Can't get UUID - no UUID"));
+ return;
+ }
+ ChatStyle style = new ChatStyle();
+ style.setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
+ new ChatComponentText(EnumChatFormatting.GRAY + "Click to copy to clipboard")));
+ style.setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/neurename copyuuid"));
+
+ ChatComponentText text = new ChatComponentText(EnumChatFormatting.YELLOW + "[NEU] The UUID of your currently held item is: " +
+ EnumChatFormatting.GREEN + heldUUID);
+ text.setChatStyle(style);
+ sender.addChatMessage(text);
+ break;
+ case "set":
+ if (heldUUID == null) {
+ sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "[NEU] Can't rename item - no UUID"));
+ return;
+ }
+ if (args.length == 1) {
+ sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "[NEU] Usage: /neurename set [name...]"));
+ return;
+ }
+ StringBuilder sb = new StringBuilder();
+ for (int i = 1; i < args.length; i++) {
+ sb.append(args[i]);
+ if (i < args.length - 1) sb.append(" ");
+ }
+ String name = sb.toString()
+ .replace("\\&", "{amp}")
+ .replace("&", "\u00a7")
+ .replace("{amp}", "&");
+ name = new UnicodeUnescaper().translate(name);
+ NotEnoughUpdates.INSTANCE.manager.itemRenameJson.addProperty(heldUUID, name);
+ NotEnoughUpdates.INSTANCE.manager.saveItemRenameConfig();
+ sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "[NEU] Set custom name for held item"));
+ break;
+ default:
+ sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "[NEU] Unknown subcommand \"" + args[0] + "\""));
+ case "help":
+ sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "[NEU] Available commands:"));
+ sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "help: Print this message"));
+ sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "clearall: Clears all custom names "
+ + EnumChatFormatting.BOLD + "(Cannot be undone)"));
+ sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "clear: Clears held item name "
+ + EnumChatFormatting.BOLD + "(Cannot be undone)"));
+ sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "uuid: Returns the UUID of the currently held item"));
+ sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "set: Sets the custom name of the currently held item"));
+ sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Usage: /neurename set [name...]"));
+
+ }
+ }
+ });*/
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/GamemodesCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/GamemodesCommand.java
new file mode 100644
index 00000000..d33e560a
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/GamemodesCommand.java
@@ -0,0 +1,20 @@
+package io.github.moulberry.notenoughupdates.commands.misc;
+
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.commands.ClientCommandBase;
+import io.github.moulberry.notenoughupdates.gamemodes.GuiGamemodes;
+import net.minecraft.command.CommandException;
+import net.minecraft.command.ICommandSender;
+
+public class GamemodesCommand extends ClientCommandBase {
+
+ public GamemodesCommand() {
+ super("neugamemodes");
+ }
+
+ @Override
+ public void processCommand(ICommandSender sender, String[] args) throws CommandException {
+ boolean upgradeOverride = args.length == 1 && args[0].equals("upgradeOverride");
+ NotEnoughUpdates.INSTANCE.openGui = new GuiGamemodes(upgradeOverride);
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/profile/CataCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/profile/CataCommand.java
new file mode 100644
index 00000000..09253e50
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/profile/CataCommand.java
@@ -0,0 +1,17 @@
+package io.github.moulberry.notenoughupdates.commands.profile;
+
+import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer;
+import net.minecraft.command.ICommandSender;
+
+public class CataCommand extends ViewProfileCommand {
+
+ public CataCommand() {
+ super("cata");
+ }
+
+ @Override
+ public void processCommand(ICommandSender sender, String[] args) {
+ GuiProfileViewer.currentPage = GuiProfileViewer.ProfileViewerPage.DUNG;
+ super.processCommand(sender, args);
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/profile/PeekCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/profile/PeekCommand.java
new file mode 100644
index 00000000..d69139aa
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/profile/PeekCommand.java
@@ -0,0 +1,291 @@
+package io.github.moulberry.notenoughupdates.commands.profile;
+
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.commands.ClientCommandBase;
+import io.github.moulberry.notenoughupdates.profileviewer.PlayerStats;
+import io.github.moulberry.notenoughupdates.util.Utils;
+import net.minecraft.client.Minecraft;
+import net.minecraft.command.CommandException;
+import net.minecraft.command.ICommandSender;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.util.BlockPos;
+import net.minecraft.util.ChatComponentText;
+import net.minecraft.util.EnumChatFormatting;
+import org.apache.commons.lang3.text.WordUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+public class PeekCommand extends ClientCommandBase {
+
+ private ScheduledExecutorService peekCommandExecutorService = null;
+
+ public PeekCommand() {
+ super("peek");
+ }
+
+ @Override
+ public void processCommand(ICommandSender sender, String[] args) throws CommandException {
+ String name;
+ if (args.length == 0) {
+ name = Minecraft.getMinecraft().thePlayer.getName();
+ } else {
+ name = args[0];
+ }
+ int id = new Random().nextInt(Integer.MAX_VALUE / 2) + Integer.MAX_VALUE / 2;
+
+ Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(new ChatComponentText(
+ EnumChatFormatting.YELLOW + "[PEEK] Getting player information..."), id);
+ NotEnoughUpdates.profileViewer.getProfileByName(name, profile -> {
+ if (profile == null) {
+ Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(new ChatComponentText(
+ EnumChatFormatting.RED + "[PEEK] Unknown player or the api is down."), id);
+ } else {
+ profile.resetCache();
+
+ if (peekCommandExecutorService == null || peekCommandExecutorService.isShutdown()) {
+ peekCommandExecutorService = Executors.newSingleThreadScheduledExecutor();
+ } else {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
+ EnumChatFormatting.RED + "[PEEK] New peek command run, cancelling old one."));
+ peekCommandExecutorService.shutdownNow();
+ peekCommandExecutorService = Executors.newSingleThreadScheduledExecutor();
+ }
+
+ Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(new ChatComponentText(
+ EnumChatFormatting.YELLOW + "[PEEK] Getting the player's Skyblock profile(s)..."), id);
+
+ long startTime = System.currentTimeMillis();
+ peekCommandExecutorService.schedule(new Runnable() {
+ public void run() {
+ if (System.currentTimeMillis() - startTime > 10 * 1000) {
+
+ Minecraft.getMinecraft().ingameGUI
+ .getChatGUI()
+ .printChatMessageWithOptionalDeletion(new ChatComponentText(
+ EnumChatFormatting.RED + "[PEEK] Getting profile info took too long, aborting."), id);
+ return;
+ }
+
+ String g = EnumChatFormatting.GRAY.toString();
+
+ JsonObject profileInfo = profile.getProfileInformation(null);
+ if (profileInfo != null) {
+ float overallScore = 0;
+
+ boolean isMe = name.equalsIgnoreCase("moulberry");
+
+ PlayerStats.Stats stats = profile.getStats(null);
+ JsonObject skill = profile.getSkillInfo(null);
+
+ Minecraft.getMinecraft().ingameGUI
+ .getChatGUI()
+ .printChatMessageWithOptionalDeletion(new ChatComponentText(EnumChatFormatting.GREEN + " " +
+ EnumChatFormatting.STRIKETHROUGH + "-=-" + EnumChatFormatting.RESET + EnumChatFormatting.GREEN + " " +
+ Utils.getElementAsString(profile.getHypixelProfile().get("displayname"), name) + "'s Info " +
+ EnumChatFormatting.STRIKETHROUGH + "-=-"), id);
+
+ if (skill == null) {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
+ EnumChatFormatting.YELLOW + "Skills api disabled!"));
+ } else {
+ float totalSkillLVL = 0;
+ float totalSkillCount = 0;
+
+ for (Map.Entry<String, JsonElement> entry : skill.entrySet()) {
+ if (entry.getKey().startsWith("level_skill")) {
+ if (entry.getKey().contains("runecrafting")) continue;
+ if (entry.getKey().contains("carpentry")) continue;
+ totalSkillLVL += entry.getValue().getAsFloat();
+ totalSkillCount++;
+ }
+ }
+
+ float combat = Utils.getElementAsFloat(skill.get("level_skill_combat"), 0);
+ float zombie = Utils.getElementAsFloat(skill.get("level_slayer_zombie"), 0);
+ float spider = Utils.getElementAsFloat(skill.get("level_slayer_spider"), 0);
+ float wolf = Utils.getElementAsFloat(skill.get("level_slayer_wolf"), 0);
+ float enderman = Utils.getElementAsFloat(skill.get("level_slayer_enderman"), 0);
+
+ float avgSkillLVL = totalSkillLVL / totalSkillCount;
+
+ if (isMe) {
+ avgSkillLVL = 6;
+ combat = 4;
+ zombie = 2;
+ spider = 1;
+ wolf = 2;
+ enderman = 0;
+ }
+
+ EnumChatFormatting combatPrefix = combat > 20
+ ? (combat > 35 ? EnumChatFormatting.GREEN : EnumChatFormatting.YELLOW)
+ : EnumChatFormatting.RED;
+ EnumChatFormatting zombiePrefix = zombie > 3
+ ? (zombie > 6 ? EnumChatFormatting.GREEN : EnumChatFormatting.YELLOW)
+ : EnumChatFormatting.RED;
+ EnumChatFormatting spiderPrefix = spider > 3
+ ? (spider > 6 ? EnumChatFormatting.GREEN : EnumChatFormatting.YELLOW)
+ : EnumChatFormatting.RED;
+ EnumChatFormatting wolfPrefix =
+ wolf > 3 ? (wolf > 6 ? EnumChatFormatting.GREEN : EnumChatFormatting.YELLOW) : EnumChatFormatting.RED;
+ EnumChatFormatting endermanPrefix = enderman > 3
+ ? (enderman > 6
+ ? EnumChatFormatting.GREEN
+ : EnumChatFormatting.YELLOW)
+ : EnumChatFormatting.RED;
+ EnumChatFormatting avgPrefix = avgSkillLVL > 20
+ ? (avgSkillLVL > 35
+ ? EnumChatFormatting.GREEN
+ : EnumChatFormatting.YELLOW)
+ : EnumChatFormatting.RED;
+
+ overallScore += zombie * zombie / 81f;
+ overallScore += spider * spider / 81f;
+ overallScore += wolf * wolf / 81f;
+ overallScore += enderman * enderman / 81f;
+ overallScore += avgSkillLVL / 20f;
+
+ int cata = (int) Utils.getElementAsFloat(skill.get("level_skill_catacombs"), 0);
+ EnumChatFormatting cataPrefix = cata > 15
+ ? (cata > 25 ? EnumChatFormatting.GREEN : EnumChatFormatting.YELLOW)
+ : EnumChatFormatting.RED;
+
+ overallScore += cata * cata / 2000f;
+
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
+ g + "Combat: " + combatPrefix + (int) Math.floor(combat) +
+ (cata > 0 ? g + " - Cata: " + cataPrefix + cata : "") +
+ g + " - AVG: " + avgPrefix + (int) Math.floor(avgSkillLVL)));
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
+ g + "Slayer: " + zombiePrefix + (int) Math.floor(zombie) + g + "-" +
+ spiderPrefix + (int) Math.floor(spider) + g + "-" +
+ wolfPrefix + (int) Math.floor(wolf) + "-" +
+ endermanPrefix + (int) Math.floor(enderman)));
+ }
+ if (stats == null) {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
+ EnumChatFormatting.YELLOW + "Skills, collection and/or inventory apis disabled!"));
+ } else {
+ int health = (int) stats.get("health");
+ int defence = (int) stats.get("defence");
+ int strength = (int) stats.get("strength");
+ int intelligence = (int) stats.get("intelligence");
+
+ EnumChatFormatting healthPrefix = health > 800
+ ? (health > 1600
+ ? EnumChatFormatting.GREEN
+ : EnumChatFormatting.YELLOW)
+ : EnumChatFormatting.RED;
+ EnumChatFormatting defencePrefix = defence > 200
+ ? (defence > 600
+ ? EnumChatFormatting.GREEN
+ : EnumChatFormatting.YELLOW)
+ : EnumChatFormatting.RED;
+ EnumChatFormatting strengthPrefix = strength > 100
+ ? (strength > 300
+ ? EnumChatFormatting.GREEN
+ : EnumChatFormatting.YELLOW)
+ : EnumChatFormatting.RED;
+ EnumChatFormatting intelligencePrefix = intelligence > 300
+ ? (intelligence > 900
+ ? EnumChatFormatting.GREEN
+ : EnumChatFormatting.YELLOW)
+ : EnumChatFormatting.RED;
+
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
+ g + "Stats : " + healthPrefix + health + EnumChatFormatting.RED + "\u2764 " +
+ defencePrefix + defence + EnumChatFormatting.GREEN + "\u2748 " +
+ strengthPrefix + strength + EnumChatFormatting.RED + "\u2741 " +
+ intelligencePrefix + intelligence + EnumChatFormatting.AQUA + "\u270e "));
+ }
+ float bankBalance = Utils.getElementAsFloat(Utils.getElement(profileInfo, "banking.balance"), -1);
+ float purseBalance = Utils.getElementAsFloat(Utils.getElement(profileInfo, "coin_purse"), 0);
+
+ long networth = profile.getNetWorth(null);
+ float money = Math.max(bankBalance + purseBalance, networth);
+ EnumChatFormatting moneyPrefix = money > 50 * 1000 * 1000 ?
+ (money > 200 * 1000 * 1000
+ ? EnumChatFormatting.GREEN
+ : EnumChatFormatting.YELLOW) : EnumChatFormatting.RED;
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
+ g + "Purse: " + moneyPrefix + Utils.shortNumberFormat(purseBalance, 0) + g + " - Bank: " +
+ (bankBalance == -1 ? EnumChatFormatting.YELLOW + "N/A" : moneyPrefix +
+ (isMe ? "4.8b" : Utils.shortNumberFormat(bankBalance, 0))) +
+ (networth > 0 ? g + " - Net: " + moneyPrefix + Utils.shortNumberFormat(networth, 0) : "")));
+
+ overallScore += Math.min(2, money / (100f * 1000 * 1000));
+
+ String activePet = Utils.getElementAsString(
+ Utils.getElement(profile.getPetsInfo(null), "active_pet.type"),
+ "None Active"
+ );
+ String activePetTier = Utils.getElementAsString(Utils.getElement(
+ profile.getPetsInfo(null),
+ "active_pet.tier"
+ ), "UNKNOWN");
+
+ String col = NotEnoughUpdates.petRarityToColourMap.get(activePetTier);
+ if (col == null) col = EnumChatFormatting.LIGHT_PURPLE.toString();
+
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(g + "Pet : " +
+ col + WordUtils.capitalizeFully(activePet.replace("_", " "))));
+
+ String overall = "Skywars Main";
+ if (isMe) {
+ overall = Utils.chromaString("Literally the best player to exist"); // ego much
+ } else if (overallScore < 5 && (bankBalance + purseBalance) > 500 * 1000 * 1000) {
+ overall = EnumChatFormatting.GOLD + "Bill Gates";
+ } else if (overallScore > 9) {
+ overall = Utils.chromaString("Didn't even think this score was possible");
+ } else if (overallScore > 8) {
+ overall = Utils.chromaString("Mentally unstable");
+ } else if (overallScore > 7) {
+ overall = EnumChatFormatting.GOLD + "Why though 0.0";
+ } else if (overallScore > 5.5) {
+ overall = EnumChatFormatting.GOLD + "Bro stop playing";
+ } else if (overallScore > 4) {
+ overall = EnumChatFormatting.GREEN + "Kinda sweaty";
+ } else if (overallScore > 3) {
+ overall = EnumChatFormatting.YELLOW + "Alright I guess";
+ } else if (overallScore > 2) {
+ overall = EnumChatFormatting.YELLOW + "Ender Non";
+ } else if (overallScore > 1) {
+ overall = EnumChatFormatting.RED + "Played Skyblock";
+ }
+
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(g + "Overall score: " +
+ overall + g + " (" + Math.round(overallScore * 10) / 10f + ")"));
+
+ peekCommandExecutorService.shutdownNow();
+ } else {
+ peekCommandExecutorService.schedule(this, 200, TimeUnit.MILLISECONDS);
+ }
+ }
+ }, 200, TimeUnit.MILLISECONDS);
+ }
+ });
+ }
+
+ @Override
+ public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) {
+ if (args.length != 1) return null;
+
+ String lastArg = args[args.length - 1];
+ List<String> playerMatches = new ArrayList<>();
+ for (EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) {
+ String playerName = player.getName();
+ if (playerName.toLowerCase().startsWith(lastArg.toLowerCase())) {
+ playerMatches.add(playerName);
+ }
+ }
+ return playerMatches;
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/profile/PvCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/profile/PvCommand.java
new file mode 100644
index 00000000..07394ffd
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/profile/PvCommand.java
@@ -0,0 +1,22 @@
+package io.github.moulberry.notenoughupdates.commands.profile;
+
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import net.minecraft.client.Minecraft;
+import net.minecraft.command.ICommandSender;
+import org.apache.commons.lang3.StringUtils;
+
+public class PvCommand extends ViewProfileCommand {
+
+ public PvCommand() {
+ super("pv");
+ }
+
+ @Override
+ public void processCommand(ICommandSender sender, String[] args) {
+ if (!NotEnoughUpdates.INSTANCE.isOnSkyblock()) {
+ Minecraft.getMinecraft().thePlayer.sendChatMessage("/pv " + StringUtils.join(args, " "));
+ } else {
+ super.processCommand(sender, args);
+ }
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/profile/ViewProfileCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/profile/ViewProfileCommand.java
new file mode 100644
index 00000000..371db394
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/profile/ViewProfileCommand.java
@@ -0,0 +1,83 @@
+package io.github.moulberry.notenoughupdates.commands.profile;
+
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.commands.ClientCommandBase;
+import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.renderer.OpenGlHelper;
+import net.minecraft.command.ICommandSender;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.util.BlockPos;
+import net.minecraft.util.ChatComponentText;
+import net.minecraft.util.EnumChatFormatting;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.function.Consumer;
+
+public class ViewProfileCommand extends ClientCommandBase {
+
+ public static final Consumer<String[]> RUNNABLE = (args) -> {
+ if (!OpenGlHelper.isFramebufferEnabled()) {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED +
+ "Some parts of the profile viewer do not work with OF Fast Render. Go to ESC > Options > Video Settings > Performance > Fast Render to disable it."));
+
+ }
+ if (NotEnoughUpdates.INSTANCE.config.apiKey.apiKey == null ||
+ NotEnoughUpdates.INSTANCE.config.apiKey.apiKey.trim().isEmpty()) {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED +
+ "Can't view profile, apikey is not set. Run /api new and put the result in settings."));
+ } else if (args.length == 0) {
+ NotEnoughUpdates.profileViewer.getProfileByName(Minecraft.getMinecraft().thePlayer.getName(), profile -> {
+ if (profile == null) {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED +
+ "Invalid player name/api key. Maybe api is down? Try /api new."));
+ } else {
+ profile.resetCache();
+ NotEnoughUpdates.INSTANCE.openGui = new GuiProfileViewer(profile);
+ }
+ });
+ } else if (args.length > 1) {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED +
+ "Too many arguments. Usage: /neuprofile [name]"));
+ } else {
+ NotEnoughUpdates.profileViewer.getProfileByName(args[0], profile -> {
+ if (profile == null) {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED +
+ "Invalid player name/api key. Maybe api is down? Try /api new."));
+ } else {
+ profile.resetCache();
+ NotEnoughUpdates.INSTANCE.openGui = new GuiProfileViewer(profile);
+ }
+ });
+ }
+ };
+
+ public ViewProfileCommand() {
+ this("neuprofile");
+ }
+
+ public ViewProfileCommand(String name) {
+ super(name);
+ }
+
+ @Override
+ public void processCommand(ICommandSender sender, String[] args) {
+ RUNNABLE.accept(args);
+ }
+
+ @Override
+ public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) {
+ if (args.length != 1) return null;
+
+ String lastArg = args[args.length - 1];
+ List<String> playerMatches = new ArrayList<>();
+ for (EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) {
+ String playerName = player.getName();
+ if (playerName.toLowerCase().startsWith(lastArg.toLowerCase())) {
+ playerMatches.add(playerName);
+ }
+ }
+ return playerMatches;
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/repo/ReloadRepoCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/repo/ReloadRepoCommand.java
new file mode 100644
index 00000000..e363b59f
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/repo/ReloadRepoCommand.java
@@ -0,0 +1,39 @@
+package io.github.moulberry.notenoughupdates.commands.repo;
+
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.commands.ClientCommandBase;
+import io.github.moulberry.notenoughupdates.options.NEUConfig;
+import io.github.moulberry.notenoughupdates.util.Constants;
+import net.minecraft.command.CommandException;
+import net.minecraft.command.ICommandSender;
+
+import java.io.BufferedReader;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
+
+public class ReloadRepoCommand extends ClientCommandBase {
+
+ public ReloadRepoCommand() {
+ super("neureloadrepo");
+ }
+
+ @Override
+ public void processCommand(ICommandSender sender, String[] args) throws CommandException {
+ NotEnoughUpdates.INSTANCE.manager.reloadRepository();
+ Constants.reload();
+
+ NotEnoughUpdates.INSTANCE.newConfigFile();
+ if (NotEnoughUpdates.INSTANCE.getConfigFile().exists()) {
+ try (
+ BufferedReader reader = new BufferedReader(new InputStreamReader(
+ new FileInputStream(NotEnoughUpdates.INSTANCE.getConfigFile()),
+ StandardCharsets.UTF_8
+ ))
+ ) {
+ NotEnoughUpdates.INSTANCE.config = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(reader, NEUConfig.class);
+ } catch (Exception ignored) {
+ }
+ }
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/repo/RepoModeCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/repo/RepoModeCommand.java
new file mode 100644
index 00000000..bb6e1675
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/repo/RepoModeCommand.java
@@ -0,0 +1,23 @@
+package io.github.moulberry.notenoughupdates.commands.repo;
+
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.commands.ClientCommandBase;
+import net.minecraft.client.Minecraft;
+import net.minecraft.command.CommandException;
+import net.minecraft.command.ICommandSender;
+import net.minecraft.util.ChatComponentText;
+
+public class RepoModeCommand extends ClientCommandBase {
+
+ public RepoModeCommand() {
+ super("neurepomode");
+ }
+
+ @Override
+ public void processCommand(ICommandSender sender, String[] args) throws CommandException {
+ NotEnoughUpdates.INSTANCE.config.hidden.dev = !NotEnoughUpdates.INSTANCE.config.hidden.dev;
+ NotEnoughUpdates.INSTANCE.config.hidden.enableItemEditing =
+ !NotEnoughUpdates.INSTANCE.config.hidden.enableItemEditing;
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("\u00a75Toggled NEU repo dev mode."));
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/repo/ResetRepoCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/repo/ResetRepoCommand.java
new file mode 100644
index 00000000..b9a0d7cd
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/repo/ResetRepoCommand.java
@@ -0,0 +1,18 @@
+package io.github.moulberry.notenoughupdates.commands.repo;
+
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.commands.ClientCommandBase;
+import net.minecraft.command.CommandException;
+import net.minecraft.command.ICommandSender;
+
+public class ResetRepoCommand extends ClientCommandBase {
+
+ public ResetRepoCommand() {
+ super("neuresetrepo");
+ }
+
+ @Override
+ public void processCommand(ICommandSender sender, String[] args) throws CommandException {
+ NotEnoughUpdates.INSTANCE.manager.resetRepo();
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/BackgroundBlur.java b/src/main/java/io/github/moulberry/notenoughupdates/core/BackgroundBlur.java
index 8a8655f9..c85841b3 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/BackgroundBlur.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/BackgroundBlur.java
@@ -2,7 +2,6 @@ package io.github.moulberry.notenoughupdates.core;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils;
-import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.GlStateManager;
@@ -15,8 +14,6 @@ import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
-import net.minecraftforge.fml.common.gameevent.TickEvent;
-import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL30;
@@ -26,240 +23,249 @@ import java.util.Map;
import java.util.Set;
public class BackgroundBlur {
-
- private static class OutputStuff {
- public Framebuffer framebuffer;
- public Shader blurShaderHorz = null;
- public Shader blurShaderVert = null;
-
- public OutputStuff(Framebuffer framebuffer, Shader blurShaderHorz, Shader blurShaderVert) {
- this.framebuffer = framebuffer;
- this.blurShaderHorz = blurShaderHorz;
- this.blurShaderVert = blurShaderVert;
- }
- }
-
- private static HashMap<Float, OutputStuff> blurOutput = new HashMap<>();
- private static HashMap<Float, Long> lastBlurUse = new HashMap<>();
- private static long lastBlur = 0;
- private static HashSet<Float> requestedBlurs = new HashSet<>();
-
- private static int fogColour = 0;
- private static boolean registered = false;
- public static void registerListener() {
- if(!registered) {
- registered = true;
- MinecraftForge.EVENT_BUS.register(new BackgroundBlur());
- }
- }
-
- private static boolean shouldBlur = true;
-
- public static void markDirty() {
- if(Minecraft.getMinecraft().theWorld != null) {
- shouldBlur = true;
- }
- }
-
- public static void processBlurs() {
- if(shouldBlur) {
- shouldBlur = false;
-
- long currentTime = System.currentTimeMillis();
-
- for(float blur : requestedBlurs) {
- lastBlur = currentTime;
- lastBlurUse.put(blur, currentTime);
-
- int width = Minecraft.getMinecraft().displayWidth;
- int height = Minecraft.getMinecraft().displayHeight;
-
- OutputStuff output = blurOutput.computeIfAbsent(blur, k -> {
- Framebuffer fb = new Framebuffer(width, height, false);
- fb.setFramebufferFilter(GL11.GL_NEAREST);
- return new OutputStuff(fb, null, null);
- });
-
- if(output.framebuffer.framebufferWidth != width || output.framebuffer.framebufferHeight != height) {
- output.framebuffer.createBindFramebuffer(width, height);
- if(output.blurShaderHorz != null) {
- output.blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height));
- }
- if(output.blurShaderVert != null) {
- output.blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height));
- }
- }
-
- blurBackground(output, blur);
- }
-
- Set<Float> remove = new HashSet<>();
- for(Map.Entry<Float, Long> entry : lastBlurUse.entrySet()) {
- if(currentTime - entry.getValue() > 30*1000) {
- remove.add(entry.getKey());
- }
- }
- remove.remove((float)NotEnoughUpdates.INSTANCE.config.itemlist.bgBlurFactor);
-
- for(Map.Entry<Float, OutputStuff> entry : blurOutput.entrySet()) {
- if(remove.contains(entry.getKey())) {
- entry.getValue().framebuffer.deleteFramebuffer();
- entry.getValue().blurShaderHorz.deleteShader();
- entry.getValue().blurShaderVert.deleteShader();
- }
- }
-
- lastBlurUse.keySet().removeAll(remove);
- blurOutput.keySet().removeAll(remove);
-
- requestedBlurs.clear();
- }
- }
-
- @SubscribeEvent(priority = EventPriority.HIGHEST)
- public void onScreenRender(RenderGameOverlayEvent.Pre event) {
- if(event.type == RenderGameOverlayEvent.ElementType.ALL) {
- processBlurs();
- }
- Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
- }
-
- @SubscribeEvent
- public void onFogColour(EntityViewRenderEvent.FogColors event) {
- fogColour = 0xff000000;
- fogColour |= ((int)(event.red*255) & 0xFF) << 16;
- fogColour |= ((int)(event.green*255) & 0xFF) << 8;
- fogColour |= (int)(event.blue*255) & 0xFF;
- }
-
- private static Framebuffer blurOutputHorz = null;
-
- /**
- * Creates a projection matrix that projects from our coordinate space [0->width; 0->height] to OpenGL coordinate
- * space [-1 -> 1; 1 -> -1] (Note: flipped y-axis).
- *
- * This is so that we can render to and from the framebuffer in a way that is familiar to us, instead of needing to
- * apply scales and translations manually.
- */
- private static Matrix4f createProjectionMatrix(int width, int height) {
- Matrix4f projMatrix = new Matrix4f();
- projMatrix.setIdentity();
- projMatrix.m00 = 2.0F / (float)width;
- projMatrix.m11 = 2.0F / (float)(-height);
- projMatrix.m22 = -0.0020001999F;
- projMatrix.m33 = 1.0F;
- projMatrix.m03 = -1.0F;
- projMatrix.m13 = 1.0F;
- projMatrix.m23 = -1.0001999F;
- return projMatrix;
- }
-
- private static double lastBgBlurFactor = -1;
- private static void blurBackground(OutputStuff output, float blurFactor) {
- if(!OpenGlHelper.isFramebufferEnabled() || !OpenGlHelper.areShadersSupported()) return;
-
- int width = Minecraft.getMinecraft().displayWidth;
- int height = Minecraft.getMinecraft().displayHeight;
-
- GlStateManager.matrixMode(GL11.GL_PROJECTION);
- GlStateManager.loadIdentity();
- GlStateManager.ortho(0.0D, width, height, 0.0D, 1000.0D, 3000.0D);
- GlStateManager.matrixMode(GL11.GL_MODELVIEW);
- GlStateManager.loadIdentity();
- GlStateManager.translate(0.0F, 0.0F, -2000.0F);
-
- if(blurOutputHorz == null) {
- blurOutputHorz = new Framebuffer(width, height, false);
- blurOutputHorz.setFramebufferFilter(GL11.GL_NEAREST);
- }
- if(blurOutputHorz == null || output == null) {
- return;
- }
- if(blurOutputHorz.framebufferWidth != width || blurOutputHorz.framebufferHeight != height) {
- blurOutputHorz.createBindFramebuffer(width, height);
- Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
- }
-
- if(output.blurShaderHorz == null) {
- try {
- output.blurShaderHorz = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur",
- output.framebuffer, blurOutputHorz);
- output.blurShaderHorz.getShaderManager().getShaderUniform("BlurDir").set(1, 0);
- output.blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height));
- } catch(Exception e) { }
- }
- if(output.blurShaderVert == null) {
- try {
- output.blurShaderVert = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur",
- blurOutputHorz, output.framebuffer);
- output.blurShaderVert.getShaderManager().getShaderUniform("BlurDir").set(0, 1);
- output.blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height));
- } catch(Exception e) { }
- }
- if(output.blurShaderHorz != null && output.blurShaderVert != null) {
- if(output.blurShaderHorz.getShaderManager().getShaderUniform("Radius") == null) {
- //Corrupted shader?
- return;
- }
-
- output.blurShaderHorz.getShaderManager().getShaderUniform("Radius").set(blurFactor);
- output.blurShaderVert.getShaderManager().getShaderUniform("Radius").set(blurFactor);
-
- GL11.glPushMatrix();
- GL30.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, Minecraft.getMinecraft().getFramebuffer().framebufferObject);
- GL30.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, output.framebuffer.framebufferObject);
- GL30.glBlitFramebuffer(0, 0, width, height,
- 0, 0, output.framebuffer.framebufferWidth, output.framebuffer.framebufferHeight,
- GL11.GL_COLOR_BUFFER_BIT, GL11.GL_NEAREST);
-
- output.blurShaderHorz.loadShader(0);
- output.blurShaderVert.loadShader(0);
- GlStateManager.enableDepth();
- GL11.glPopMatrix();
- }
- Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
- }
-
- public static void renderBlurredBackground(float blurStrength, int screenWidth, int screenHeight,
- int x, int y, int blurWidth, int blurHeight) {
- renderBlurredBackground(blurStrength, screenWidth, screenHeight, x, y, blurWidth, blurHeight, false);
- }
-
- /**
- * Renders a subsection of the blurred framebuffer on to the corresponding section of the screen.
- * Essentially, this method will "blur" the background inside the bounds specified by [x->x+blurWidth, y->y+blurHeight]
- */
- public static void renderBlurredBackground(float blurStrength, int screenWidth, int screenHeight,
- int x, int y, int blurWidth, int blurHeight, boolean forcedUpdate) {
- if(!OpenGlHelper.isFramebufferEnabled() || !OpenGlHelper.areShadersSupported()) return;
- if(blurStrength < 0.5) return;
- requestedBlurs.add(blurStrength);
-
- long currentTime = System.currentTimeMillis();
- if(currentTime - lastBlur > 300) {
- shouldBlur = true;
- if(currentTime - lastBlur > 400 && forcedUpdate) return;
- }
-
- if(blurOutput.isEmpty()) return;
-
- OutputStuff out = blurOutput.get(blurStrength);
- if(out == null) {
- out = blurOutput.values().iterator().next();
- }
-
- float uMin = x/(float)screenWidth;
- float uMax = (x+blurWidth)/(float)screenWidth;
- float vMin = (screenHeight-y)/(float)screenHeight;
- float vMax = (screenHeight-y-blurHeight)/(float)screenHeight;
-
- GlStateManager.depthMask(false);
- Gui.drawRect(x, y, x+blurWidth, y+blurHeight, fogColour);
- out.framebuffer.bindFramebufferTexture();
- GlStateManager.color(1f, 1f, 1f, 1f);
- RenderUtils.drawTexturedRect(x, y, blurWidth, blurHeight, uMin, uMax, vMin, vMax);
- out.framebuffer.unbindFramebufferTexture();
- GlStateManager.depthMask(true);
- }
-
+ private static class OutputStuff {
+ public Framebuffer framebuffer;
+ public Shader blurShaderHorz = null;
+ public Shader blurShaderVert = null;
+
+ public OutputStuff(Framebuffer framebuffer, Shader blurShaderHorz, Shader blurShaderVert) {
+ this.framebuffer = framebuffer;
+ this.blurShaderHorz = blurShaderHorz;
+ this.blurShaderVert = blurShaderVert;
+ }
+ }
+
+ private static final HashMap<Float, OutputStuff> blurOutput = new HashMap<>();
+ private static final HashMap<Float, Long> lastBlurUse = new HashMap<>();
+ private static long lastBlur = 0;
+ private static final HashSet<Float> requestedBlurs = new HashSet<>();
+
+ private static int fogColour = 0;
+ private static boolean registered = false;
+
+ public static void registerListener() {
+ if (!registered) {
+ registered = true;
+ MinecraftForge.EVENT_BUS.register(new BackgroundBlur());
+ }
+ }
+
+ private static boolean shouldBlur = true;
+
+ public static void markDirty() {
+ if (Minecraft.getMinecraft().theWorld != null) {
+ shouldBlur = true;
+ }
+ }
+
+ public static void processBlurs() {
+ if (shouldBlur) {
+ shouldBlur = false;
+
+ long currentTime = System.currentTimeMillis();
+
+ for (float blur : requestedBlurs) {
+ lastBlur = currentTime;
+ lastBlurUse.put(blur, currentTime);
+
+ int width = Minecraft.getMinecraft().displayWidth;
+ int height = Minecraft.getMinecraft().displayHeight;
+
+ OutputStuff output = blurOutput.computeIfAbsent(blur, k -> {
+ Framebuffer fb = new Framebuffer(width, height, false);
+ fb.setFramebufferFilter(GL11.GL_NEAREST);
+ return new OutputStuff(fb, null, null);
+ });
+
+ if (output.framebuffer.framebufferWidth != width || output.framebuffer.framebufferHeight != height) {
+ output.framebuffer.createBindFramebuffer(width, height);
+ if (output.blurShaderHorz != null) {
+ output.blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height));
+ }
+ if (output.blurShaderVert != null) {
+ output.blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height));
+ }
+ }
+
+ blurBackground(output, blur);
+ }
+
+ Set<Float> remove = new HashSet<>();
+ for (Map.Entry<Float, Long> entry : lastBlurUse.entrySet()) {
+ if (currentTime - entry.getValue() > 30 * 1000) {
+ remove.add(entry.getKey());
+ }
+ }
+ remove.remove((float) NotEnoughUpdates.INSTANCE.config.itemlist.bgBlurFactor);
+
+ for (Map.Entry<Float, OutputStuff> entry : blurOutput.entrySet()) {
+ if (remove.contains(entry.getKey())) {
+ entry.getValue().framebuffer.deleteFramebuffer();
+ entry.getValue().blurShaderHorz.deleteShader();
+ entry.getValue().blurShaderVert.deleteShader();
+ }
+ }
+
+ lastBlurUse.keySet().removeAll(remove);
+ blurOutput.keySet().removeAll(remove);
+
+ requestedBlurs.clear();
+ }
+ }
+
+ @SubscribeEvent(priority = EventPriority.HIGHEST)
+ public void onScreenRender(RenderGameOverlayEvent.Pre event) {
+ if (event.type == RenderGameOverlayEvent.ElementType.ALL) {
+ processBlurs();
+ }
+ Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
+ }
+
+ @SubscribeEvent
+ public void onFogColour(EntityViewRenderEvent.FogColors event) {
+ fogColour = 0xff000000;
+ fogColour |= ((int) (event.red * 255) & 0xFF) << 16;
+ fogColour |= ((int) (event.green * 255) & 0xFF) << 8;
+ fogColour |= (int) (event.blue * 255) & 0xFF;
+ }
+
+ private static Framebuffer blurOutputHorz = null;
+
+ /**
+ * Creates a projection matrix that projects from our coordinate space [0->width; 0->height] to OpenGL coordinate
+ * space [-1 -> 1; 1 -> -1] (Note: flipped y-axis).
+ * <p>
+ * This is so that we can render to and from the framebuffer in a way that is familiar to us, instead of needing to
+ * apply scales and translations manually.
+ */
+ private static Matrix4f createProjectionMatrix(int width, int height) {
+ Matrix4f projMatrix = new Matrix4f();
+ projMatrix.setIdentity();
+ projMatrix.m00 = 2.0F / (float) width;
+ projMatrix.m11 = 2.0F / (float) (-height);
+ projMatrix.m22 = -0.0020001999F;
+ projMatrix.m33 = 1.0F;
+ projMatrix.m03 = -1.0F;
+ projMatrix.m13 = 1.0F;
+ projMatrix.m23 = -1.0001999F;
+ return projMatrix;
+ }
+
+ private static final double lastBgBlurFactor = -1;
+
+ private static void blurBackground(OutputStuff output, float blurFactor) {
+ if (!OpenGlHelper.isFramebufferEnabled() || !OpenGlHelper.areShadersSupported()) return;
+
+ int width = Minecraft.getMinecraft().displayWidth;
+ int height = Minecraft.getMinecraft().displayHeight;
+
+ GlStateManager.matrixMode(GL11.GL_PROJECTION);
+ GlStateManager.loadIdentity();
+ GlStateManager.ortho(0.0D, width, height, 0.0D, 1000.0D, 3000.0D);
+ GlStateManager.matrixMode(GL11.GL_MODELVIEW);
+ GlStateManager.loadIdentity();
+ GlStateManager.translate(0.0F, 0.0F, -2000.0F);
+
+ if (blurOutputHorz == null) {
+ blurOutputHorz = new Framebuffer(width, height, false);
+ blurOutputHorz.setFramebufferFilter(GL11.GL_NEAREST);
+ }
+ if (blurOutputHorz == null || output == null) {
+ return;
+ }
+ if (blurOutputHorz.framebufferWidth != width || blurOutputHorz.framebufferHeight != height) {
+ blurOutputHorz.createBindFramebuffer(width, height);
+ Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
+ }
+
+ if (output.blurShaderHorz == null) {
+ try {
+ output.blurShaderHorz = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur",
+ output.framebuffer, blurOutputHorz
+ );
+ output.blurShaderHorz.getShaderManager().getShaderUniform("BlurDir").set(1, 0);
+ output.blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height));
+ } catch (Exception ignored) {
+ }
+ }
+ if (output.blurShaderVert == null) {
+ try {
+ output.blurShaderVert = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur",
+ blurOutputHorz, output.framebuffer
+ );
+ output.blurShaderVert.getShaderManager().getShaderUniform("BlurDir").set(0, 1);
+ output.blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height));
+ } catch (Exception ignored) {
+ }
+ }
+ if (output.blurShaderHorz != null && output.blurShaderVert != null) {
+ if (output.blurShaderHorz.getShaderManager().getShaderUniform("Radius") == null) {
+ //Corrupted shader?
+ return;
+ }
+
+ output.blurShaderHorz.getShaderManager().getShaderUniform("Radius").set(blurFactor);
+ output.blurShaderVert.getShaderManager().getShaderUniform("Radius").set(blurFactor);
+
+ GL11.glPushMatrix();
+ GL30.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, Minecraft.getMinecraft().getFramebuffer().framebufferObject);
+ GL30.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, output.framebuffer.framebufferObject);
+ GL30.glBlitFramebuffer(0, 0, width, height,
+ 0, 0, output.framebuffer.framebufferWidth, output.framebuffer.framebufferHeight,
+ GL11.GL_COLOR_BUFFER_BIT, GL11.GL_NEAREST
+ );
+
+ output.blurShaderHorz.loadShader(0);
+ output.blurShaderVert.loadShader(0);
+ GlStateManager.enableDepth();
+ GL11.glPopMatrix();
+ }
+ Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
+ }
+
+ public static void renderBlurredBackground(
+ float blurStrength, int screenWidth, int screenHeight,
+ int x, int y, int blurWidth, int blurHeight
+ ) {
+ renderBlurredBackground(blurStrength, screenWidth, screenHeight, x, y, blurWidth, blurHeight, false);
+ }
+
+ /**
+ * Renders a subsection of the blurred framebuffer on to the corresponding section of the screen.
+ * Essentially, this method will "blur" the background inside the bounds specified by [x->x+blurWidth, y->y+blurHeight]
+ */
+ public static void renderBlurredBackground(
+ float blurStrength, int screenWidth, int screenHeight,
+ int x, int y, int blurWidth, int blurHeight, boolean forcedUpdate
+ ) {
+ if (!OpenGlHelper.isFramebufferEnabled() || !OpenGlHelper.areShadersSupported()) return;
+ if (blurStrength < 0.5) return;
+ requestedBlurs.add(blurStrength);
+
+ long currentTime = System.currentTimeMillis();
+ if (currentTime - lastBlur > 300) {
+ shouldBlur = true;
+ if (currentTime - lastBlur > 400 && forcedUpdate) return;
+ }
+
+ if (blurOutput.isEmpty()) return;
+
+ OutputStuff out = blurOutput.get(blurStrength);
+ if (out == null) {
+ out = blurOutput.values().iterator().next();
+ }
+
+ float uMin = x / (float) screenWidth;
+ float uMax = (x + blurWidth) / (float) screenWidth;
+ float vMin = (screenHeight - y) / (float) screenHeight;
+ float vMax = (screenHeight - y - blurHeight) / (float) screenHeight;
+
+ GlStateManager.depthMask(false);
+ Gui.drawRect(x, y, x + blurWidth, y + blurHeight, fogColour);
+ out.framebuffer.bindFramebufferTexture();
+ GlStateManager.color(1f, 1f, 1f, 1f);
+ RenderUtils.drawTexturedRect(x, y, blurWidth, blurHeight, uMin, uMax, vMin, vMax);
+ out.framebuffer.unbindFramebufferTexture();
+ GlStateManager.depthMask(true);
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/ChromaColour.java b/src/main/java/io/github/moulberry/notenoughupdates/core/ChromaColour.java
index 9509c332..8f4dd87d 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/ChromaColour.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/ChromaColour.java
@@ -3,93 +3,90 @@ package io.github.moulberry.notenoughupdates.core;
import java.awt.*;
public class ChromaColour {
-
- public static String special(int chromaSpeed, int alpha, int rgb) {
- return special(chromaSpeed, alpha, (rgb & 0xFF0000) >> 16, (rgb & 0x00FF00) >> 8, (rgb & 0x0000FF));
- }
-
- private static final int RADIX = 10;
-
- public static String special(int chromaSpeed, int alpha, int r, int g, int b) {
- StringBuilder sb = new StringBuilder();
- sb.append(Integer.toString(chromaSpeed, RADIX)).append(":");
- sb.append(Integer.toString(alpha, RADIX)).append(":");
- sb.append(Integer.toString(r, RADIX)).append(":");
- sb.append(Integer.toString(g, RADIX)).append(":");
- sb.append(Integer.toString(b, RADIX));
- return sb.toString();
- }
-
- private static int[] decompose(String csv) {
- String[] split = csv.split(":");
-
- int[] arr = new int[split.length];
-
-
- for(int i=0; i<split.length; i++) {
- arr[i] = Integer.parseInt(split[split.length-1-i], RADIX);
- }
- return arr;
- }
-
- public static int specialToSimpleRGB(String special) {
- int[] d = decompose(special);
- int r = d[2];
- int g = d[1];
- int b = d[0];
- int a = d[3];
- int chr = d[4];
-
- return (a & 0xFF) << 24 | (r & 0xFF) << 16 | (g & 0xFF) << 8 | (b & 0xFF);
- }
-
- public static int getSpeed(String special) {
- return decompose(special)[4];
- }
-
- public static float getSecondsForSpeed(int speed) {
- return (255-speed)/254f*(MAX_CHROMA_SECS-MIN_CHROMA_SECS)+MIN_CHROMA_SECS;
- }
-
- private static final int MIN_CHROMA_SECS = 1;
- private static final int MAX_CHROMA_SECS = 60;
-
- public static long startTime = -1;
- public static int specialToChromaRGB(String special) {
- if(startTime < 0) startTime = System.currentTimeMillis();
-
- int[] d = decompose(special);
- int chr = d[4];
- int a = d[3];
- int r = d[2];
- int g = d[1];
- int b = d[0];
-
- float[] hsv = Color.RGBtoHSB(r, g, b, null);
-
- if(chr > 0) {
- float seconds = getSecondsForSpeed(chr);
- hsv[0] += (System.currentTimeMillis()-startTime)/1000f/seconds;
- hsv[0] %= 1;
- if(hsv[0] < 0) hsv[0] += 1;
- }
-
- return (a & 0xFF) << 24 | (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF);
- }
-
- public static int rotateHue(int argb, int degrees) {
- int a = (argb >> 24) & 0xFF;
- int r = (argb >> 16) & 0xFF;
- int g = (argb >> 8) & 0xFF;
- int b = (argb) & 0xFF;
-
- float[] hsv = Color.RGBtoHSB(r, g, b, null);
-
- hsv[0] += degrees/360f;
- hsv[0] %= 1;
-
- return (a & 0xFF) << 24 | (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF);
- }
-
-
+ public static String special(int chromaSpeed, int alpha, int rgb) {
+ return special(chromaSpeed, alpha, (rgb & 0xFF0000) >> 16, (rgb & 0x00FF00) >> 8, (rgb & 0x0000FF));
+ }
+
+ private static final int RADIX = 10;
+
+ public static String special(int chromaSpeed, int alpha, int r, int g, int b) {
+ StringBuilder sb = new StringBuilder();
+ sb.append(Integer.toString(chromaSpeed, RADIX)).append(":");
+ sb.append(Integer.toString(alpha, RADIX)).append(":");
+ sb.append(Integer.toString(r, RADIX)).append(":");
+ sb.append(Integer.toString(g, RADIX)).append(":");
+ sb.append(Integer.toString(b, RADIX));
+ return sb.toString();
+ }
+
+ private static int[] decompose(String csv) {
+ String[] split = csv.split(":");
+
+ int[] arr = new int[split.length];
+
+ for (int i = 0; i < split.length; i++) {
+ arr[i] = Integer.parseInt(split[split.length - 1 - i], RADIX);
+ }
+ return arr;
+ }
+
+ public static int specialToSimpleRGB(String special) {
+ int[] d = decompose(special);
+ int r = d[2];
+ int g = d[1];
+ int b = d[0];
+ int a = d[3];
+ int chr = d[4];
+
+ return (a & 0xFF) << 24 | (r & 0xFF) << 16 | (g & 0xFF) << 8 | (b & 0xFF);
+ }
+
+ public static int getSpeed(String special) {
+ return decompose(special)[4];
+ }
+
+ public static float getSecondsForSpeed(int speed) {
+ return (255 - speed) / 254f * (MAX_CHROMA_SECS - MIN_CHROMA_SECS) + MIN_CHROMA_SECS;
+ }
+
+ private static final int MIN_CHROMA_SECS = 1;
+ private static final int MAX_CHROMA_SECS = 60;
+
+ public static long startTime = -1;
+
+ public static int specialToChromaRGB(String special) {
+ if (startTime < 0) startTime = System.currentTimeMillis();
+
+ int[] d = decompose(special);
+ int chr = d[4];
+ int a = d[3];
+ int r = d[2];
+ int g = d[1];
+ int b = d[0];
+
+ float[] hsv = Color.RGBtoHSB(r, g, b, null);
+
+ if (chr > 0) {
+ float seconds = getSecondsForSpeed(chr);
+ hsv[0] += (System.currentTimeMillis() - startTime) / 1000f / seconds;
+ hsv[0] %= 1;
+ if (hsv[0] < 0) hsv[0] += 1;
+ }
+
+ return (a & 0xFF) << 24 | (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF);
+ }
+
+ public static int rotateHue(int argb, int degrees) {
+ int a = (argb >> 24) & 0xFF;
+ int r = (argb >> 16) & 0xFF;
+ int g = (argb >> 8) & 0xFF;
+ int b = (argb) & 0xFF;
+
+ float[] hsv = Color.RGBtoHSB(r, g, b, null);
+
+ hsv[0] += degrees / 360f;
+ hsv[0] %= 1;
+
+ return (a & 0xFF) << 24 | (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF);
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/GlScissorStack.java b/src/main/java/io/github/moulberry/notenoughupdates/core/GlScissorStack.java
index f70bec40..7cc8893f 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/GlScissorStack.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/GlScissorStack.java
@@ -7,81 +7,79 @@ import org.lwjgl.opengl.GL11;
import java.util.LinkedList;
public class GlScissorStack {
+ private static class Bounds {
+ int left;
+ int top;
+ int right;
+ int bottom;
- private static class Bounds {
- int left;
- int top;
- int right;
- int bottom;
+ public Bounds(int left, int top, int right, int bottom) {
+ this.left = left;
+ this.top = top;
+ this.right = right;
+ this.bottom = bottom;
+ }
- public Bounds(int left, int top, int right, int bottom) {
- this.left = left;
- this.top = top;
- this.right = right;
- this.bottom = bottom;
- }
+ public Bounds createSubBound(int left, int top, int right, int bottom) {
+ left = Math.max(left, this.left);
+ top = Math.max(top, this.top);
+ right = Math.min(right, this.right);
+ bottom = Math.min(bottom, this.bottom);
- public Bounds createSubBound(int left, int top, int right, int bottom) {
- left = Math.max(left, this.left);
- top = Math.max(top, this.top);
- right = Math.min(right, this.right);
- bottom = Math.min(bottom, this.bottom);
+ if (top > bottom) {
+ top = bottom;
+ }
+ if (left > right) {
+ left = right;
+ }
- if(top > bottom) {
- top = bottom;
- }
- if(left > right) {
- left = right;
- }
+ return new Bounds(left, top, right, bottom);
+ }
- return new Bounds(left, top, right, bottom);
- }
+ public void set(ScaledResolution scaledResolution) {
+ int height = Minecraft.getMinecraft().displayHeight;
+ int scale = scaledResolution.getScaleFactor();
+ GL11.glScissor(left * scale, height - bottom * scale, (right - left) * scale, (bottom - top) * scale);
+ }
+ }
- public void set(ScaledResolution scaledResolution) {
- int height = Minecraft.getMinecraft().displayHeight;
- int scale = scaledResolution.getScaleFactor();
- GL11.glScissor(left*scale, height-bottom*scale, (right-left)*scale, (bottom-top)*scale);
- }
- }
+ private static final LinkedList<Bounds> boundsStack = new LinkedList<>();
- private static LinkedList<Bounds> boundsStack = new LinkedList<>();
+ public static void push(int left, int top, int right, int bottom, ScaledResolution scaledResolution) {
+ if (right < left) {
+ int temp = right;
+ right = left;
+ left = temp;
+ }
+ if (bottom < top) {
+ int temp = bottom;
+ bottom = top;
+ top = temp;
+ }
+ if (boundsStack.isEmpty()) {
+ boundsStack.push(new Bounds(left, top, right, bottom));
+ } else {
+ boundsStack.push(boundsStack.peek().createSubBound(left, top, right, bottom));
+ }
+ if (!boundsStack.isEmpty()) {
+ boundsStack.peek().set(scaledResolution);
+ }
+ GL11.glEnable(GL11.GL_SCISSOR_TEST);
+ }
- public static void push(int left, int top, int right, int bottom, ScaledResolution scaledResolution) {
- if(right < left) {
- int temp = right;
- right = left;
- left = temp;
- }
- if(bottom < top) {
- int temp = bottom;
- bottom = top;
- top = temp;
- }
- if(boundsStack.isEmpty()) {
- boundsStack.push(new Bounds(left, top, right, bottom));
- } else {
- boundsStack.push(boundsStack.peek().createSubBound(left, top, right, bottom));
- }
- if(!boundsStack.isEmpty()) {
- boundsStack.peek().set(scaledResolution);
- }
- GL11.glEnable(GL11.GL_SCISSOR_TEST);
- }
-
- public static void pop(ScaledResolution scaledResolution) {
- if(!boundsStack.isEmpty()) {
- boundsStack.pop();
- }
- if(boundsStack.isEmpty()) {
- GL11.glDisable(GL11.GL_SCISSOR_TEST);
- } else {
- boundsStack.peek().set(scaledResolution);
- }
- }
-
- public static void clear() {
- boundsStack.clear();
- GL11.glDisable(GL11.GL_SCISSOR_TEST);
- }
+ public static void pop(ScaledResolution scaledResolution) {
+ if (!boundsStack.isEmpty()) {
+ boundsStack.pop();
+ }
+ if (boundsStack.isEmpty()) {
+ GL11.glDisable(GL11.GL_SCISSOR_TEST);
+ } else {
+ boundsStack.peek().set(scaledResolution);
+ }
+ }
+ public static void clear() {
+ boundsStack.clear();
+ GL11.glDisable(GL11.GL_SCISSOR_TEST);
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElement.java b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElement.java
index 5969c691..c1c76675 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElement.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElement.java
@@ -2,9 +2,10 @@ package io.github.moulberry.notenoughupdates.core;
import net.minecraft.client.gui.Gui;
-public abstract class GuiElement extends Gui {
+public abstract class GuiElement extends Gui {
+ public abstract void render();
- public abstract void render();
- public abstract boolean mouseInput(int mouseX, int mouseY);
- public abstract boolean keyboardInput();
+ public abstract boolean mouseInput(int mouseX, int mouseY);
+
+ public abstract boolean keyboardInput();
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementBoolean.java b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementBoolean.java
index bfd95612..d5cbb3ad 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementBoolean.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementBoolean.java
@@ -7,115 +7,122 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Mouse;
+import org.lwjgl.opengl.GL11;
import java.util.function.Consumer;
public class GuiElementBoolean extends GuiElement {
-
- public int x;
- public int y;
- private boolean value;
- private int clickRadius;
- private Consumer<Boolean> toggleCallback;
-
- private boolean previewValue;
- private int animation = 0;
- private long lastMillis = 0;
-
- private static final int xSize = 48;
- private static final int ySize = 14;
-
- public GuiElementBoolean(int x, int y, boolean value, Consumer<Boolean> toggleCallback) {
- this(x, y, value, 0, toggleCallback);
- }
-
- public GuiElementBoolean(int x, int y, boolean value, int clickRadius, Consumer<Boolean> toggleCallback) {
- this.x = x;
- this.y = y;
- this.value = value;
- this.previewValue = value;
- this.clickRadius = clickRadius;
- this.toggleCallback = toggleCallback;
- this.lastMillis = System.currentTimeMillis();
-
- if(value) animation = 36;
- }
-
- @Override
- public void render() {
- GlStateManager.color(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(GuiTextures.BAR);
- RenderUtils.drawTexturedRect(x, y, xSize, ySize);
-
- ResourceLocation buttonLoc = GuiTextures.ON;
- long currentMillis = System.currentTimeMillis();
- long deltaMillis = currentMillis - lastMillis;
- lastMillis = currentMillis;
- boolean passedLimit = false;
- if(previewValue != value) {
- if((previewValue && animation > 12) ||
- (!previewValue && animation < 24)) {
- passedLimit = true;
- }
- }
- if(previewValue != passedLimit) {
- animation += deltaMillis/10;
- } else {
- animation -= deltaMillis/10;
- }
- lastMillis -= deltaMillis%10;
-
- if(previewValue == value) {
- animation = Math.max(0, Math.min(36, animation));
- } else if(!passedLimit) {
- if(previewValue) {
- animation = Math.max(0, Math.min(12, animation));
- } else {
- animation = Math.max(24, Math.min(36, animation));
- }
- } else {
- if(previewValue) {
- animation = Math.max(12, animation);
- } else {
- animation = Math.min(24, animation);
- }
- }
-
- int animation = (int)(LerpUtils.sigmoidZeroOne(this.animation/36f)*36);
- if(animation < 3) {
- buttonLoc = GuiTextures.OFF;
- } else if(animation < 13) {
- buttonLoc = GuiTextures.ONE;
- } else if(animation < 23) {
- buttonLoc = GuiTextures.TWO;
- } else if(animation < 33) {
- buttonLoc = GuiTextures.THREE;
- }
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(buttonLoc);
- RenderUtils.drawTexturedRect(x+animation, y, 12, 14);
- }
-
- @Override
- public boolean mouseInput(int mouseX, int mouseY) {
- if(mouseX > x-clickRadius && mouseX < x+xSize+clickRadius &&
- mouseY > y-clickRadius && mouseY < y+ySize+clickRadius) {
- if(Mouse.getEventButton() == 0) {
- if(Mouse.getEventButtonState()) {
- previewValue = !value;
- } else if(previewValue == !value) {
- value = !value;
- toggleCallback.accept(value);
- }
- }
- } else {
- previewValue = value;
- }
- return false;
- }
-
- @Override
- public boolean keyboardInput() {
- return false;
- }
+ public int x;
+ public int y;
+ private boolean value;
+ private final int clickRadius;
+ private final Consumer<Boolean> toggleCallback;
+
+ private boolean previewValue;
+ private int animation = 0;
+ private long lastMillis = 0;
+
+ private static final int xSize = 48;
+ private static final int ySize = 14;
+
+ public GuiElementBoolean(int x, int y, boolean value, Consumer<Boolean> toggleCallback) {
+ this(x, y, value, 0, toggleCallback);
+ }
+
+ public GuiElementBoolean(int x, int y, boolean value, int clickRadius, Consumer<Boolean> toggleCallback) {
+ this.x = x;
+ this.y = y;
+ this.value = value;
+ this.previewValue = value;
+ this.clickRadius = clickRadius;
+ this.toggleCallback = toggleCallback;
+ this.lastMillis = System.currentTimeMillis();
+
+ if (value) animation = 36;
+ }
+
+ @Override
+ public void render() {
+ GlStateManager.color(1, 1, 1, 1);
+ ResourceLocation buttonLoc = GuiTextures.ON;
+ ResourceLocation barLoc = GuiTextures.BAR_ON;
+ long currentMillis = System.currentTimeMillis();
+ long deltaMillis = currentMillis - lastMillis;
+ lastMillis = currentMillis;
+ boolean passedLimit = false;
+ if (previewValue != value) {
+ if ((previewValue && animation > 12) ||
+ (!previewValue && animation < 24)) {
+ passedLimit = true;
+ }
+ }
+ if (previewValue != passedLimit) {
+ animation += deltaMillis / 10;
+ } else {
+ animation -= deltaMillis / 10;
+ }
+ lastMillis -= deltaMillis % 10;
+
+ if (previewValue == value) {
+ animation = Math.max(0, Math.min(36, animation));
+ } else if (!passedLimit) {
+ if (previewValue) {
+ animation = Math.max(0, Math.min(12, animation));
+ } else {
+ animation = Math.max(24, Math.min(36, animation));
+ }
+ } else {
+ if (previewValue) {
+ animation = Math.max(12, animation);
+ } else {
+ animation = Math.min(24, animation);
+ }
+ }
+
+ int animation = (int) (LerpUtils.sigmoidZeroOne(this.animation / 36f) * 36);
+ if (animation < 3) {
+ buttonLoc = GuiTextures.OFF;
+ barLoc = GuiTextures.BAR;
+ } else if (animation < 13) {
+ buttonLoc = GuiTextures.ONE;
+ barLoc = GuiTextures.BAR_ONE;
+ } else if (animation < 23) {
+ buttonLoc = GuiTextures.TWO;
+ barLoc = GuiTextures.BAR_TWO;
+ } else if (animation < 33) {
+ buttonLoc = GuiTextures.THREE;
+ barLoc = GuiTextures.BAR_THREE;
+ }
+
+ GL11.glTranslatef(0, 0, 100);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(buttonLoc);
+ RenderUtils.drawTexturedRect(x + animation, y, 12, 14);
+ GL11.glTranslatef(0, 0, -100);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(barLoc);
+ RenderUtils.drawTexturedRect(x, y, xSize, ySize);
+ }
+
+ @Override
+ public boolean mouseInput(int mouseX, int mouseY) {
+ if (mouseX > x - clickRadius && mouseX < x + xSize + clickRadius &&
+ mouseY > y - clickRadius && mouseY < y + ySize + clickRadius) {
+ if (Mouse.getEventButton() == 0) {
+ if (Mouse.getEventButtonState()) {
+ previewValue = !value;
+ } else if (previewValue == !value) {
+ value = !value;
+ toggleCallback.accept(value);
+ }
+ }
+ } else {
+ previewValue = value;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean keyboardInput() {
+ return false;
+ }
}
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 3ab47531..48996c8d 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementColour.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementColour.java
@@ -18,383 +18,413 @@ import java.awt.image.BufferedImage;
import java.util.function.Consumer;
public class GuiElementColour extends GuiElement {
-
- public static final ResourceLocation colour_selector_dot = new ResourceLocation("notenoughupdates:core/colour_selector_dot.png");
- public static final ResourceLocation colour_selector_bar = new ResourceLocation("notenoughupdates:core/colour_selector_bar.png");
- public static final ResourceLocation colour_selector_bar_alpha = new ResourceLocation("notenoughupdates:core/colour_selector_bar_alpha.png");
- public static final ResourceLocation colour_selector_chroma = new ResourceLocation("notenoughupdates:core/colour_selector_chroma.png");
-
- private static final ResourceLocation colourPickerLocation = new ResourceLocation("mbcore:dynamic/colourpicker");
- private static final ResourceLocation colourPickerBarValueLocation = new ResourceLocation("mbcore:dynamic/colourpickervalue");
- private static final ResourceLocation colourPickerBarOpacityLocation = new ResourceLocation("mbcore:dynamic/colourpickeropacity");
- private final GuiElementTextField hexField = new GuiElementTextField("",
- GuiElementTextField.SCALE_TEXT | GuiElementTextField.FORCE_CAPS | GuiElementTextField.NO_SPACE);
-
- private int x;
- private int y;
- private int xSize = 119;
- private int ySize = 89;
-
- private float wheelAngle = 0;
- private float wheelRadius = 0;
-
- private int clickedComponent = -1;
-
- private Consumer<String> colourChangedCallback;
- private Runnable closeCallback;
- private String colour;
-
- private final boolean opacitySlider;
- private final boolean valueSlider;
-
- public GuiElementColour(int x, int y, String initialColour, Consumer<String> colourChangedCallback,
- Runnable closeCallback) {
- this(x, y, initialColour, colourChangedCallback, closeCallback, true, true);
- }
-
- public GuiElementColour(int x, int y, String initialColour, Consumer<String> 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));
- this.x = Math.max(10, Math.min(scaledResolution.getScaledWidth()-xSize-10, x));
-
- this.colour = initialColour;
- this.colourChangedCallback = colourChangedCallback;
- this.closeCallback = closeCallback;
-
- int colour = ChromaColour.specialToSimpleRGB(initialColour);
- 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) {
- this.wheelRadius = hsv[1];
- this.wheelAngle = hsv[0]*360;
- }
-
- public void render() {
- RenderUtils.drawFloatingRectDark(x, y, xSize, ySize);
-
- int currentColour = ChromaColour.specialToSimpleRGB(colour);
- Color c = new Color(currentColour, true);
- float[] hsv = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null);
-
- BufferedImage bufferedImage = new BufferedImage(288, 288, BufferedImage.TYPE_INT_ARGB);
- float borderRadius = 0.05f;
- if(Keyboard.isKeyDown(Keyboard.KEY_N)) borderRadius = 0;
- for(int x=-16; x<272; x++) {
- for(int y=-16; y<272; y++) {
- float radius = (float) Math.sqrt(((x-128)*(x-128)+(y-128)*(y-128))/16384f);
- float angle = (float) Math.toDegrees(Math.atan((128-x)/(y-128+1E-5))+Math.PI/2);
- if(y < 128) angle += 180;
- if(radius <= 1) {
- int rgb = Color.getHSBColor(angle/360f, (float)Math.pow(radius, 1.5f), hsv[2]).getRGB();
- bufferedImage.setRGB(x+16, y+16, rgb);
- } else if(radius <= 1+borderRadius) {
- float invBlackAlpha = Math.abs(radius-1-borderRadius/2)/borderRadius*2;
- float blackAlpha = 1-invBlackAlpha;
-
- if(radius > 1+borderRadius/2) {
- bufferedImage.setRGB(x+16, y+16, (int)(blackAlpha*255) << 24);
- } else {
- Color col = Color.getHSBColor(angle/360f, 1, hsv[2]);
- int rgb = (int)(col.getRed()*invBlackAlpha) << 16 |
- (int)(col.getGreen()*invBlackAlpha) << 8 |
- (int)(col.getBlue()*invBlackAlpha);
- bufferedImage.setRGB(x+16, y+16, 0xff000000 | rgb);
- }
-
- }
- }
- }
-
- BufferedImage bufferedImageValue = new BufferedImage(10, 64, BufferedImage.TYPE_INT_ARGB);
- for(int x=0; x<10; x++) {
- for(int y=0; y<64; y++) {
- if((x == 0 || x == 9) && (y == 0 || y == 63)) continue;
-
- int rgb = Color.getHSBColor(wheelAngle/360, wheelRadius, (64-y)/64f).getRGB();
- bufferedImageValue.setRGB(x, y, rgb);
- }
- }
-
- BufferedImage bufferedImageOpacity = new BufferedImage(10, 64, BufferedImage.TYPE_INT_ARGB);
- for(int x=0; x<10; x++) {
- for(int y=0; y<64; y++) {
- if((x == 0 || x == 9) && (y == 0 || y == 63)) continue;
-
- int rgb = (currentColour & 0x00FFFFFF) | (Math.min(255, (64-y)*4) << 24);
- bufferedImageOpacity.setRGB(x, y, rgb);
- }
- }
-
- float selradius = (float)Math.pow(wheelRadius, 1/1.5f)*32;
- int selx = (int)(Math.cos(Math.toRadians(wheelAngle))*selradius);
- int sely = (int)(Math.sin(Math.toRadians(wheelAngle))*selradius);
-
- 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);
- }
-
- 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);
- Color cChroma = new Color(currentColourChroma, true);
- float hsvChroma[] = Color.RGBtoHSB(cChroma.getRed(), cChroma.getGreen(), cChroma.getBlue(), null);
-
- if(chromaSpeed > 0) {
- 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+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);
- 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+valueOffset+opacityOffset+5, y+5, 10, 64, GL11.GL_NEAREST);
- } else {
- Minecraft.getMinecraft().getTextureManager().bindTexture(colour_selector_chroma);
- RenderUtils.drawTexturedRect(x+5+64+valueOffset+opacityOffset+5, y+5+27, 10, 10, GL11.GL_NEAREST);
- }
-
- 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+valueOffset+opacityOffset+5,
- y+5+64-(int)(chromaSpeed/255f*64),
- x+5+64+valueOffset+opacityOffset+5+10,
- y+5+64-(int)(chromaSpeed/255f*64)+1, 0xFF000000);
- }
-
- Minecraft.getMinecraft().getTextureManager().loadTexture(colourPickerLocation, new DynamicTexture(bufferedImage));
- Minecraft.getMinecraft().getTextureManager().bindTexture(colourPickerLocation);
- GlStateManager.color(1, 1, 1, 1);
- RenderUtils.drawTexturedRect(x+1, y+1, 72, 72, GL11.GL_LINEAR);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(colour_selector_dot);
- GlStateManager.color(1, 1, 1, 1);
- RenderUtils.drawTexturedRect(x+5+32+selx-4, y+5+32+sely-4, 8, 8, GL11.GL_NEAREST);
-
- TextRenderUtils.drawStringCenteredScaledMaxWidth(EnumChatFormatting.GRAY.toString()+Math.round(hsv[2]*100)+"",
- Minecraft.getMinecraft().fontRendererObj,
- x+5+64+5+5-(Math.round(hsv[2]*100)==100?1:0), y+5+64+5+5, true, 13, -1);
- if(opacitySlider) {
- TextRenderUtils.drawStringCenteredScaledMaxWidth(EnumChatFormatting.GRAY.toString()+Math.round(c.getAlpha()/255f*100)+"",
- Minecraft.getMinecraft().fontRendererObj,
- x+5+64+5+valueOffset+5, y+5+64+5+5, true, 13, -1);
- }
- if(chromaSpeed > 0) {
- TextRenderUtils.drawStringCenteredScaledMaxWidth(EnumChatFormatting.GRAY.toString()+
- (int)ChromaColour.getSecondsForSpeed(chromaSpeed)+"s",
- Minecraft.getMinecraft().fontRendererObj,
- x+5+64+5+valueOffset+opacityOffset+6, y+5+64+5+5, true, 13, -1);
- }
-
- hexField.setSize(48, 10);
- if(!hexField.getFocus()) hexField.setText(Integer.toHexString(c.getRGB() & 0xFFFFFF).toUpperCase());
-
- StringBuilder sb = new StringBuilder(EnumChatFormatting.GRAY+"#");
- for(int i=0; i<6-hexField.getText().length(); i++) {
- sb.append("0");
- }
- sb.append(EnumChatFormatting.WHITE);
-
- hexField.setPrependText(sb.toString());
- hexField.render(x+5+8, y+5+64+5);
- }
-
- public boolean mouseInput(int mouseX, int mouseY) {
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- float mouseXF = (float)(Mouse.getX() * scaledResolution.getScaledWidth_double() /
- Minecraft.getMinecraft().displayWidth);
- float mouseYF = (float)(scaledResolution.getScaledHeight_double() - Mouse.getY() *
- scaledResolution.getScaledHeight_double() / Minecraft.getMinecraft().displayHeight - 1);
-
- if((Mouse.getEventButton() == 0 || Mouse.getEventButton() == 1) && Mouse.getEventButtonState()) {
- if(mouseX > x+5+8 && mouseX < x+5+8+48) {
- if(mouseY > y+5+64+5 && mouseY < y+5+64+5+10) {
- hexField.mouseClicked(mouseX, mouseY, Mouse.getEventButton());
- clickedComponent = -1;
- return true;
- }
- }
- }
- if(!Mouse.getEventButtonState() && Mouse.getEventButton() == 0) {
- clickedComponent = -1;
- }
- if(Mouse.getEventButtonState() && Mouse.getEventButton() == 0) {
- if(mouseX >= x && mouseX <= x+119 &&
- mouseY >= y && mouseY <= y+89) {
- hexField.unfocus();
-
- int xWheel = mouseX - x - 5;
- int yWheel = mouseY - y - 5;
-
- if(xWheel > 0 && xWheel < 64) {
- if(yWheel > 0 && yWheel < 64) {
- clickedComponent = 0;
- }
- }
-
- 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(valueSlider) {
- if(xValue > 0 && xValue < 10) {
- clickedComponent = 1;
- }
- }
-
- if(opacitySlider) {
- int xOpacity = mouseX - (x+5+64+5+valueOffset);
-
- if(xOpacity > 0 && xOpacity < 10) {
- clickedComponent = 2;
- }
- }
- }
-
- int chromaSpeed = ChromaColour.getSpeed(colour);
- int xChroma = mouseX - (x+5+64+valueOffset+opacityOffset+5);
- if(xChroma > 0 && xChroma < 10) {
- if(chromaSpeed > 0) {
- if(y > -5 && y <= 69) {
- clickedComponent = 3;
- }
- } else if(mouseY > this.y+5+27 && mouseY < this.y+5+37) {
- int currentColour = ChromaColour.specialToSimpleRGB(colour);
- Color c = new Color(currentColour, true);
- colour = ChromaColour.special(200, c.getAlpha(), currentColour);
- colourChangedCallback.accept(colour);
- }
- }
- } else {
- hexField.unfocus();
- closeCallback.run();
- return false;
- }
- }
- if(Mouse.isButtonDown(0) && clickedComponent >= 0) {
- int currentColour = ChromaColour.specialToSimpleRGB(colour);
- Color c = new Color(currentColour, true);
- float[] hsv = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null);
-
- float xWheel = mouseXF - x - 5;
- float yWheel = mouseYF - y - 5;
-
- if(clickedComponent == 0) {
- float angle = (float) Math.toDegrees(Math.atan((32-xWheel)/(yWheel-32+1E-5))+Math.PI/2);
- xWheel = Math.max(0, Math.min(64, xWheel));
- yWheel = Math.max(0, Math.min(64, yWheel));
- float radius = (float) Math.sqrt(((xWheel-32)*(xWheel-32)+(yWheel-32)*(yWheel-32))/1024f);
- if(yWheel < 32) angle += 180;
-
- this.wheelAngle = angle;
- this.wheelRadius = (float)Math.pow(Math.min(1, radius), 1.5f);
- int rgb = Color.getHSBColor(angle/360f, wheelRadius, hsv[2]).getRGB();
- colour = ChromaColour.special(ChromaColour.getSpeed(colour), c.getAlpha(), rgb);
- colourChangedCallback.accept(colour);
- return true;
- }
-
- float y = mouseYF - this.y - 5;
- y = Math.max(0, Math.min(64, y));
- System.out.println(y);
-
- if(clickedComponent == 1) {
- int rgb = Color.getHSBColor(wheelAngle/360, wheelRadius, 1-y/64f).getRGB();
- colour = ChromaColour.special(ChromaColour.getSpeed(colour), c.getAlpha(), rgb);
- colourChangedCallback.accept(colour);
- return true;
- }
-
- if(clickedComponent == 2) {
- colour = ChromaColour.special(ChromaColour.getSpeed(colour),
- 255-Math.round(y/64f*255), currentColour);
- colourChangedCallback.accept(colour);
- return true;
- }
-
- if(clickedComponent == 3) {
- colour = ChromaColour.special(255-Math.round(y/64f*255), c.getAlpha(), currentColour);
- colourChangedCallback.accept(colour);
- }
- return true;
- }
- return false;
- }
-
- public boolean keyboardInput() {
- if(Keyboard.getEventKeyState() && hexField.getFocus()) {
- if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
- hexField.unfocus();
- return true;
- }
- String old = hexField.getText();
-
- hexField.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey());
-
- if(hexField.getText().length() > 6) {
- hexField.setText(old);
- } else {
- try {
- String text = hexField.getText().toLowerCase();
-
- int rgb = Integer.parseInt(text, 16);
- int alpha = (ChromaColour.specialToSimpleRGB(colour) >> 24) & 0xFF;
- colour = ChromaColour.special(ChromaColour.getSpeed(colour), alpha, rgb);
- colourChangedCallback.accept(colour);
-
- Color c = new Color(rgb);
- float[] hsv = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null);
- updateAngleAndRadius(hsv);
- } catch(Exception e) {};
- }
-
- return true;
- }
- return false;
- }
-
-
+ public static final ResourceLocation colour_selector_dot = new ResourceLocation(
+ "notenoughupdates:core/colour_selector_dot.png");
+ public static final ResourceLocation colour_selector_bar = new ResourceLocation(
+ "notenoughupdates:core/colour_selector_bar.png");
+ public static final ResourceLocation colour_selector_bar_alpha = new ResourceLocation(
+ "notenoughupdates:core/colour_selector_bar_alpha.png");
+ public static final ResourceLocation colour_selector_chroma = new ResourceLocation(
+ "notenoughupdates:core/colour_selector_chroma.png");
+
+ private static final ResourceLocation colourPickerLocation = new ResourceLocation("mbcore:dynamic/colourpicker");
+ private static final ResourceLocation colourPickerBarValueLocation = new ResourceLocation(
+ "mbcore:dynamic/colourpickervalue");
+ private static final ResourceLocation colourPickerBarOpacityLocation = new ResourceLocation(
+ "mbcore:dynamic/colourpickeropacity");
+ private final GuiElementTextField hexField = new GuiElementTextField(
+ "",
+ GuiElementTextField.SCALE_TEXT | GuiElementTextField.FORCE_CAPS | GuiElementTextField.NO_SPACE
+ );
+
+ private final int x;
+ private final int y;
+ private int xSize = 119;
+ private final int ySize = 89;
+
+ private float wheelAngle = 0;
+ private float wheelRadius = 0;
+
+ private int clickedComponent = -1;
+
+ private final Consumer<String> colourChangedCallback;
+ private final Runnable closeCallback;
+ private String colour;
+
+ private final boolean opacitySlider;
+ private final boolean valueSlider;
+
+ public GuiElementColour(
+ int x, int y, String initialColour, Consumer<String> colourChangedCallback,
+ Runnable closeCallback
+ ) {
+ this(x, y, initialColour, colourChangedCallback, closeCallback, true, true);
+ }
+
+ public GuiElementColour(
+ int x, int y, String initialColour, Consumer<String> 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));
+ this.x = Math.max(10, Math.min(scaledResolution.getScaledWidth() - xSize - 10, x));
+
+ this.colour = initialColour;
+ this.colourChangedCallback = colourChangedCallback;
+ this.closeCallback = closeCallback;
+
+ int colour = ChromaColour.specialToSimpleRGB(initialColour);
+ 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) {
+ this.wheelRadius = hsv[1];
+ this.wheelAngle = hsv[0] * 360;
+ }
+
+ public void render() {
+ RenderUtils.drawFloatingRectDark(x, y, xSize, ySize);
+
+ int currentColour = ChromaColour.specialToSimpleRGB(colour);
+ Color c = new Color(currentColour, true);
+ float[] hsv = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null);
+
+ BufferedImage bufferedImage = new BufferedImage(288, 288, BufferedImage.TYPE_INT_ARGB);
+ float borderRadius = 0.05f;
+ if (Keyboard.isKeyDown(Keyboard.KEY_N)) borderRadius = 0;
+ for (int x = -16; x < 272; x++) {
+ for (int y = -16; y < 272; y++) {
+ float radius = (float) Math.sqrt(((x - 128) * (x - 128) + (y - 128) * (y - 128)) / 16384f);
+ float angle = (float) Math.toDegrees(Math.atan((128 - x) / (y - 128 + 1E-5)) + Math.PI / 2);
+ if (y < 128) angle += 180;
+ if (radius <= 1) {
+ int rgb = Color.getHSBColor(angle / 360f, (float) Math.pow(radius, 1.5f), hsv[2]).getRGB();
+ bufferedImage.setRGB(x + 16, y + 16, rgb);
+ } else if (radius <= 1 + borderRadius) {
+ float invBlackAlpha = Math.abs(radius - 1 - borderRadius / 2) / borderRadius * 2;
+ float blackAlpha = 1 - invBlackAlpha;
+
+ if (radius > 1 + borderRadius / 2) {
+ bufferedImage.setRGB(x + 16, y + 16, (int) (blackAlpha * 255) << 24);
+ } else {
+ Color col = Color.getHSBColor(angle / 360f, 1, hsv[2]);
+ int rgb = (int) (col.getRed() * invBlackAlpha) << 16 |
+ (int) (col.getGreen() * invBlackAlpha) << 8 |
+ (int) (col.getBlue() * invBlackAlpha);
+ bufferedImage.setRGB(x + 16, y + 16, 0xff000000 | rgb);
+ }
+
+ }
+ }
+ }
+
+ BufferedImage bufferedImageValue = new BufferedImage(10, 64, BufferedImage.TYPE_INT_ARGB);
+ for (int x = 0; x < 10; x++) {
+ for (int y = 0; y < 64; y++) {
+ if ((x == 0 || x == 9) && (y == 0 || y == 63)) continue;
+
+ int rgb = Color.getHSBColor(wheelAngle / 360, wheelRadius, (64 - y) / 64f).getRGB();
+ bufferedImageValue.setRGB(x, y, rgb);
+ }
+ }
+
+ BufferedImage bufferedImageOpacity = new BufferedImage(10, 64, BufferedImage.TYPE_INT_ARGB);
+ for (int x = 0; x < 10; x++) {
+ for (int y = 0; y < 64; y++) {
+ if ((x == 0 || x == 9) && (y == 0 || y == 63)) continue;
+
+ int rgb = (currentColour & 0x00FFFFFF) | (Math.min(255, (64 - y) * 4) << 24);
+ bufferedImageOpacity.setRGB(x, y, rgb);
+ }
+ }
+
+ float selradius = (float) Math.pow(wheelRadius, 1 / 1.5f) * 32;
+ int selx = (int) (Math.cos(Math.toRadians(wheelAngle)) * selradius);
+ int sely = (int) (Math.sin(Math.toRadians(wheelAngle)) * selradius);
+
+ 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);
+ }
+
+ 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);
+ Color cChroma = new Color(currentColourChroma, true);
+ float[] hsvChroma = Color.RGBtoHSB(cChroma.getRed(), cChroma.getGreen(), cChroma.getBlue(), null);
+
+ if (chromaSpeed > 0) {
+ 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 + 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);
+ 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 + valueOffset + opacityOffset + 5, y + 5, 10, 64, GL11.GL_NEAREST);
+ } else {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(colour_selector_chroma);
+ RenderUtils.drawTexturedRect(x + 5 + 64 + valueOffset + opacityOffset + 5, y + 5 + 27, 10, 10, GL11.GL_NEAREST);
+ }
+
+ 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 + valueOffset + opacityOffset + 5,
+ y + 5 + 64 - (int) (chromaSpeed / 255f * 64),
+ x + 5 + 64 + valueOffset + opacityOffset + 5 + 10,
+ y + 5 + 64 - (int) (chromaSpeed / 255f * 64) + 1, 0xFF000000
+ );
+ }
+
+ Minecraft.getMinecraft().getTextureManager().loadTexture(colourPickerLocation, new DynamicTexture(bufferedImage));
+ Minecraft.getMinecraft().getTextureManager().bindTexture(colourPickerLocation);
+ GlStateManager.color(1, 1, 1, 1);
+ RenderUtils.drawTexturedRect(x + 1, y + 1, 72, 72, GL11.GL_LINEAR);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(colour_selector_dot);
+ GlStateManager.color(1, 1, 1, 1);
+ RenderUtils.drawTexturedRect(x + 5 + 32 + selx - 4, y + 5 + 32 + sely - 4, 8, 8, GL11.GL_NEAREST);
+
+ TextRenderUtils.drawStringCenteredScaledMaxWidth(EnumChatFormatting.GRAY.toString() + Math.round(hsv[2] * 100) + "",
+ Minecraft.getMinecraft().fontRendererObj,
+ x + 5 + 64 + 5 + 5 - (Math.round(hsv[2] * 100) == 100 ? 1 : 0), y + 5 + 64 + 5 + 5, true, 13, -1
+ );
+ if (opacitySlider) {
+ TextRenderUtils.drawStringCenteredScaledMaxWidth(
+ EnumChatFormatting.GRAY.toString() + Math.round(c.getAlpha() / 255f * 100) + "",
+ Minecraft.getMinecraft().fontRendererObj,
+ x + 5 + 64 + 5 + valueOffset + 5,
+ y + 5 + 64 + 5 + 5,
+ true,
+ 13,
+ -1
+ );
+ }
+ if (chromaSpeed > 0) {
+ TextRenderUtils.drawStringCenteredScaledMaxWidth(EnumChatFormatting.GRAY.toString() +
+ (int) ChromaColour.getSecondsForSpeed(chromaSpeed) + "s",
+ Minecraft.getMinecraft().fontRendererObj,
+ x + 5 + 64 + 5 + valueOffset + opacityOffset + 6, y + 5 + 64 + 5 + 5, true, 13, -1
+ );
+ }
+
+ hexField.setSize(48, 10);
+ if (!hexField.getFocus()) hexField.setText(Integer.toHexString(c.getRGB() & 0xFFFFFF).toUpperCase());
+
+ StringBuilder sb = new StringBuilder(EnumChatFormatting.GRAY + "#");
+ for (int i = 0; i < 6 - hexField.getText().length(); i++) {
+ sb.append("0");
+ }
+ sb.append(EnumChatFormatting.WHITE);
+
+ hexField.setPrependText(sb.toString());
+ hexField.render(x + 5 + 8, y + 5 + 64 + 5);
+ }
+
+ public boolean mouseInput(int mouseX, int mouseY) {
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ float mouseXF = (float) (Mouse.getX() * scaledResolution.getScaledWidth_double() /
+ Minecraft.getMinecraft().displayWidth);
+ float mouseYF = (float) (scaledResolution.getScaledHeight_double() - Mouse.getY() *
+ scaledResolution.getScaledHeight_double() / Minecraft.getMinecraft().displayHeight - 1);
+
+ if ((Mouse.getEventButton() == 0 || Mouse.getEventButton() == 1) && Mouse.getEventButtonState()) {
+ if (mouseX > x + 5 + 8 && mouseX < x + 5 + 8 + 48) {
+ if (mouseY > y + 5 + 64 + 5 && mouseY < y + 5 + 64 + 5 + 10) {
+ hexField.mouseClicked(mouseX, mouseY, Mouse.getEventButton());
+ clickedComponent = -1;
+ return true;
+ }
+ }
+ }
+ if (!Mouse.getEventButtonState() && Mouse.getEventButton() == 0) {
+ clickedComponent = -1;
+ }
+ if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0) {
+ if (mouseX >= x && mouseX <= x + 119 &&
+ mouseY >= y && mouseY <= y + 89) {
+ hexField.unfocus();
+
+ int xWheel = mouseX - x - 5;
+ int yWheel = mouseY - y - 5;
+
+ if (xWheel > 0 && xWheel < 64) {
+ if (yWheel > 0 && yWheel < 64) {
+ clickedComponent = 0;
+ }
+ }
+
+ 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 (valueSlider) {
+ if (xValue > 0 && xValue < 10) {
+ clickedComponent = 1;
+ }
+ }
+
+ if (opacitySlider) {
+ int xOpacity = mouseX - (x + 5 + 64 + 5 + valueOffset);
+
+ if (xOpacity > 0 && xOpacity < 10) {
+ clickedComponent = 2;
+ }
+ }
+ }
+
+ int chromaSpeed = ChromaColour.getSpeed(colour);
+ int xChroma = mouseX - (x + 5 + 64 + valueOffset + opacityOffset + 5);
+ if (xChroma > 0 && xChroma < 10) {
+ if (chromaSpeed > 0) {
+ if (y > -5 && y <= 69) {
+ clickedComponent = 3;
+ }
+ } else if (mouseY > this.y + 5 + 27 && mouseY < this.y + 5 + 37) {
+ int currentColour = ChromaColour.specialToSimpleRGB(colour);
+ Color c = new Color(currentColour, true);
+ colour = ChromaColour.special(200, c.getAlpha(), currentColour);
+ colourChangedCallback.accept(colour);
+ }
+ }
+ } else {
+ hexField.unfocus();
+ closeCallback.run();
+ return false;
+ }
+ }
+ if (Mouse.isButtonDown(0) && clickedComponent >= 0) {
+ int currentColour = ChromaColour.specialToSimpleRGB(colour);
+ Color c = new Color(currentColour, true);
+ float[] hsv = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null);
+
+ float xWheel = mouseXF - x - 5;
+ float yWheel = mouseYF - y - 5;
+
+ if (clickedComponent == 0) {
+ float angle = (float) Math.toDegrees(Math.atan((32 - xWheel) / (yWheel - 32 + 1E-5)) + Math.PI / 2);
+ xWheel = Math.max(0, Math.min(64, xWheel));
+ yWheel = Math.max(0, Math.min(64, yWheel));
+ float radius = (float) Math.sqrt(((xWheel - 32) * (xWheel - 32) + (yWheel - 32) * (yWheel - 32)) / 1024f);
+ if (yWheel < 32) angle += 180;
+
+ this.wheelAngle = angle;
+ this.wheelRadius = (float) Math.pow(Math.min(1, radius), 1.5f);
+ int rgb = Color.getHSBColor(angle / 360f, wheelRadius, hsv[2]).getRGB();
+ colour = ChromaColour.special(ChromaColour.getSpeed(colour), c.getAlpha(), rgb);
+ colourChangedCallback.accept(colour);
+ return true;
+ }
+
+ float y = mouseYF - this.y - 5;
+ y = Math.max(0, Math.min(64, y));
+ System.out.println(y);
+
+ if (clickedComponent == 1) {
+ int rgb = Color.getHSBColor(wheelAngle / 360, wheelRadius, 1 - y / 64f).getRGB();
+ colour = ChromaColour.special(ChromaColour.getSpeed(colour), c.getAlpha(), rgb);
+ colourChangedCallback.accept(colour);
+ return true;
+ }
+
+ if (clickedComponent == 2) {
+ colour = ChromaColour.special(ChromaColour.getSpeed(colour),
+ 255 - Math.round(y / 64f * 255), currentColour
+ );
+ colourChangedCallback.accept(colour);
+ return true;
+ }
+
+ if (clickedComponent == 3) {
+ colour = ChromaColour.special(255 - Math.round(y / 64f * 255), c.getAlpha(), currentColour);
+ colourChangedCallback.accept(colour);
+ }
+ return true;
+ }
+ return false;
+ }
+
+ public boolean keyboardInput() {
+ if (Keyboard.getEventKeyState() && hexField.getFocus()) {
+ if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
+ hexField.unfocus();
+ return true;
+ }
+ String old = hexField.getText();
+
+ hexField.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey());
+
+ if (hexField.getText().length() > 6) {
+ hexField.setText(old);
+ } else {
+ try {
+ String text = hexField.getText().toLowerCase();
+
+ int rgb = Integer.parseInt(text, 16);
+ int alpha = (ChromaColour.specialToSimpleRGB(colour) >> 24) & 0xFF;
+ colour = ChromaColour.special(ChromaColour.getSpeed(colour), alpha, rgb);
+ colourChangedCallback.accept(colour);
+
+ Color c = new Color(rgb);
+ float[] hsv = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null);
+ updateAngleAndRadius(hsv);
+ } catch (Exception ignored) {
+ }
+ }
+
+ return true;
+ }
+ return false;
+ }
}
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 d221b37e..51a4654c 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementTextField.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementTextField.java
@@ -15,569 +15,601 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class GuiElementTextField {
-
- public static final int SCISSOR_TEXT = 0b10000000;
- 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;
- public static final int FORCE_CAPS = 0b00100;
- public static final int COLOUR = 0b00010;
- public static final int MULTILINE = 0b00001;
-
- private int searchBarYSize;
- private int searchBarXSize;
- private static final int searchBarPadding = 2;
-
- private int options;
-
- private boolean focus = false;
-
- private int x;
- private int y;
-
- private String prependText = "";
- private int customTextColour = 0xffffffff;
-
- private final GuiTextField textField = new GuiTextField(0, Minecraft.getMinecraft().fontRendererObj,
- 0 , 0, 0, 0);
-
- private int customBorderColour = -1;
-
- public GuiElementTextField(String initialText, int options) {
- this(initialText, 100, 20, options);
- }
-
- public GuiElementTextField(String initialText, int sizeX, int sizeY, int options) {
- textField.setFocused(true);
- textField.setCanLoseFocus(false);
- textField.setMaxStringLength(999);
- textField.setText(initialText);
- this.searchBarXSize = sizeX;
- this.searchBarYSize = sizeY;
- this.options = options;
- }
-
- public void setMaxStringLength(int len) {
- textField.setMaxStringLength(len);
- }
-
- public void setCustomBorderColour(int colour) {
- this.customBorderColour = colour;
- }
-
- public void setCustomTextColour(int colour) {
- this.customTextColour = colour;
- }
-
- public String getText() {
- return textField.getText();
- }
-
- public String getTextDisplay() {
- String textNoColour = getText();
- while(true) {
- Matcher matcher = PATTERN_CONTROL_CODE.matcher(textNoColour);
- if(!matcher.find()) break;
- String code = matcher.group(1);
- textNoColour = matcher.replaceFirst("\u00B6"+code);
- }
-
- return textNoColour;
- }
-
- public void setPrependText(String text) {
- this.prependText = text;
- }
-
- public void setText(String text) {
- if(textField.getText() == null || !textField.getText().equals(text)) {
- textField.setText(text);
- }
- }
-
- public void setSize(int searchBarXSize, int searchBarYSize) {
- this.searchBarXSize = searchBarXSize;
- this.searchBarYSize = searchBarYSize;
- }
-
- public void setOptions(int options) {
- this.options = options;
- }
-
- @Override
- public String toString() {
- return textField.getText();
- }
-
- public void setFocus(boolean focus) {
- this.focus = focus;
- if(!focus) {
- textField.setCursorPosition(textField.getCursorPosition());
- }
- }
- public boolean getFocus() {
- return focus;
- }
-
- public int getHeight() {
- ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
- int paddingUnscaled = searchBarPadding/scaledresolution.getScaleFactor();
-
- int numLines = org.apache.commons.lang3.StringUtils.countMatches(textField.getText(), "\n")+1;
- int extraSize = (searchBarYSize-8)/2+8;
- int bottomTextBox = searchBarYSize + extraSize*(numLines-1);
-
- return bottomTextBox + paddingUnscaled*2;
- }
-
- public int getWidth() {
- ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
- int paddingUnscaled = searchBarPadding/scaledresolution.getScaleFactor();
-
- return searchBarXSize + paddingUnscaled*2;
- }
-
- private float getScaleFactor(String str) {
- return Math.min(1, (searchBarXSize-2)/(float)Minecraft.getMinecraft().fontRendererObj.getStringWidth(str));
- }
-
- private boolean isScaling() {
- return (options & SCALE_TEXT) != 0;
- }
-
- private static final Pattern PATTERN_CONTROL_CODE = Pattern.compile("(?i)\\u00A7([^\\u00B6]|$)(?!\\u00B6)");
-
- public int getCursorPos(int mouseX, int mouseY) {
- int xComp = mouseX - x;
- int yComp = mouseY - y;
-
- int extraSize = (searchBarYSize-8)/2+8;
-
- String renderText = prependText + textField.getText();
-
- int lineNum = Math.round(((yComp - (searchBarYSize-8)/2))/extraSize);
-
- String text = renderText;
- String textNoColour = renderText;
- if((options & COLOUR) != 0) {
- while(true) {
- Matcher matcher = PATTERN_CONTROL_CODE.matcher(text);
- if(!matcher.find() || matcher.groupCount() < 1) break;
- String code = matcher.group(1);
- if(code.isEmpty()) {
- text = matcher.replaceFirst("\u00A7r\u00B6");
- } else {
- text = matcher.replaceFirst("\u00A7"+code+"\u00B6"+code);
- }
- }
- }
- while(true) {
- Matcher matcher = PATTERN_CONTROL_CODE.matcher(textNoColour);
- if(!matcher.find() || matcher.groupCount() < 1) break;
- String code = matcher.group(1);
- textNoColour = matcher.replaceFirst("\u00B6"+code);
- }
-
- int currentLine = 0;
- int cursorIndex = 0;
- for(; cursorIndex<textNoColour.length(); cursorIndex++) {
- if(currentLine == lineNum) break;
- if(textNoColour.charAt(cursorIndex) == '\n') {
- currentLine++;
- }
- }
-
- 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];
- int padding = Math.min(5, searchBarXSize-strLenNoColor(line))/2;
- String trimmed = Minecraft.getMinecraft().fontRendererObj.trimStringToWidth(line, xComp-padding);
- int linePos = strLenNoColor(trimmed);
- if(linePos != strLenNoColor(line)) {
- char after = line.charAt(linePos);
- int trimmedWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(trimmed);
- int charWidth = Minecraft.getMinecraft().fontRendererObj.getCharWidth(after);
- if(trimmedWidth + charWidth/2 < xComp-padding) {
- linePos++;
- }
- }
- cursorIndex += linePos;
-
- int pre = StringUtils.cleanColour(prependText).length();
- if(cursorIndex < pre) {
- cursorIndex = 0;
- } else {
- cursorIndex -= pre;
- }
-
- return cursorIndex;
- }
-
- public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
- if(mouseButton == 1) {
- textField.setText("");
- } else {
- textField.setCursorPosition(getCursorPos(mouseX, mouseY));
- }
- focus = true;
- }
-
- public void unfocus() {
- focus = false;
- textField.setSelectionPos(textField.getCursorPosition());
- }
-
- public int strLenNoColor(String str) {
- return str.replaceAll("(?i)\\u00A7.", "").length();
- }
-
- public void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
- if(focus) {
- textField.setSelectionPos(getCursorPos(mouseX, mouseY));
- }
- }
-
- public void keyTyped(char typedChar, int keyCode) {
- if(focus) {
- if((options & MULTILINE) != 0) { //Carriage return
- Pattern patternControlCode = Pattern.compile("(?i)\\u00A7([^\\u00B6\n]|$)(?!\\u00B6)");
-
- String text = textField.getText();
- String textNoColour = textField.getText();
- while(true) {
- Matcher matcher = patternControlCode.matcher(text);
- if(!matcher.find() || matcher.groupCount() < 1) break;
- String code = matcher.group(1);
- if(code.isEmpty()) {
- text = matcher.replaceFirst("\u00A7r\u00B6");
- } else {
- text = matcher.replaceFirst("\u00A7"+code+"\u00B6"+code);
- }
- }
- while(true) {
- Matcher matcher = patternControlCode.matcher(textNoColour);
- if(!matcher.find() || matcher.groupCount() < 1) break;
- String code = matcher.group(1);
- textNoColour = matcher.replaceFirst("\u00B6"+code);
- }
-
- if(keyCode == 28) {
- String before = textField.getText().substring(0, textField.getCursorPosition());
- String after = textField.getText().substring(textField.getCursorPosition());
- int pos = textField.getCursorPosition();
- textField.setText(before + "\n" + after);
- textField.setCursorPosition(pos+1);
- return;
- } else if(keyCode == 200) { //Up
- String textNCBeforeCursor = textNoColour.substring(0, textField.getSelectionEnd());
- int colorCodes = org.apache.commons.lang3.StringUtils.countMatches(textNCBeforeCursor, "\u00B6");
- String textBeforeCursor = text.substring(0, textField.getSelectionEnd()+colorCodes*2);
-
- int numLinesBeforeCursor = org.apache.commons.lang3.StringUtils.countMatches(textBeforeCursor, "\n");
-
- String[] split = textBeforeCursor.split("\n");
- int textBeforeCursorWidth;
- String lineBefore;
- String thisLineBeforeCursor;
- if(split.length == numLinesBeforeCursor && split.length > 0) {
- textBeforeCursorWidth = 0;
- lineBefore = split[split.length-1];
- thisLineBeforeCursor = "";
- } else if(split.length > 1) {
- thisLineBeforeCursor = split[split.length-1];
- lineBefore = split[split.length-2];
- textBeforeCursorWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(thisLineBeforeCursor);
- } else {
- return;
- }
- String trimmed = Minecraft.getMinecraft().fontRendererObj
- .trimStringToWidth(lineBefore, textBeforeCursorWidth);
- int linePos = strLenNoColor(trimmed);
- if(linePos != strLenNoColor(lineBefore)) {
- char after = lineBefore.charAt(linePos);
- int trimmedWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(trimmed);
- int charWidth = Minecraft.getMinecraft().fontRendererObj.getCharWidth(after);
- if(trimmedWidth + charWidth/2 < textBeforeCursorWidth) {
- linePos++;
- }
- }
- int newPos = textField.getSelectionEnd()-strLenNoColor(thisLineBeforeCursor)
- -strLenNoColor(lineBefore)-1+linePos;
-
- if(GuiScreen.isShiftKeyDown()) {
- textField.setSelectionPos(newPos);
- } else {
- textField.setCursorPosition(newPos);
- }
- } else if(keyCode == 208) { //Down
- String textNCBeforeCursor = textNoColour.substring(0, textField.getSelectionEnd());
- int colorCodes = org.apache.commons.lang3.StringUtils.countMatches(textNCBeforeCursor, "\u00B6");
- String textBeforeCursor = text.substring(0, textField.getSelectionEnd()+colorCodes*2);
-
- int numLinesBeforeCursor = org.apache.commons.lang3.StringUtils.countMatches(textBeforeCursor, "\n");
-
- String[] split = textBeforeCursor.split("\n");
- String thisLineBeforeCursor;
- int textBeforeCursorWidth;
- if(split.length == numLinesBeforeCursor) {
- thisLineBeforeCursor = "";
- textBeforeCursorWidth = 0;
- } else if(split.length > 0) {
- thisLineBeforeCursor = split[split.length-1];
- textBeforeCursorWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(thisLineBeforeCursor);
- } else {
- return;
- }
-
- String[] split2 = textNoColour.split("\n");
- if(split2.length > numLinesBeforeCursor+1) {
- String lineAfter = split2[numLinesBeforeCursor+1];
- String trimmed = Minecraft.getMinecraft().fontRendererObj
- .trimStringToWidth(lineAfter, textBeforeCursorWidth);
- int linePos = strLenNoColor(trimmed);
- if(linePos != strLenNoColor(lineAfter)) {
- char after = lineAfter.charAt(linePos);
- int trimmedWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(trimmed);
- int charWidth = Minecraft.getMinecraft().fontRendererObj.getCharWidth(after);
- if(trimmedWidth + charWidth/2 < textBeforeCursorWidth) {
- linePos++;
- }
- }
- int newPos = textField.getSelectionEnd()-strLenNoColor(thisLineBeforeCursor)
- +strLenNoColor(split2[numLinesBeforeCursor])+1+linePos;
-
- if(GuiScreen.isShiftKeyDown()) {
- textField.setSelectionPos(newPos);
- } else {
- textField.setCursorPosition(newPos);
- }
- }
- }
- }
-
- String old = textField.getText();
- if((options & FORCE_CAPS) != 0) typedChar = Character.toUpperCase(typedChar);
- if((options & NO_SPACE) != 0 && typedChar == ' ') return;
-
- if(typedChar == '\u00B6') {
- typedChar = '\u00A7';
- }
-
- textField.setFocused(true);
- textField.textboxKeyTyped(typedChar, keyCode);
-
- if((options & COLOUR) != 0) {
- if(typedChar == '&') {
- int pos = textField.getCursorPosition()-2;
- if(pos >= 0 && pos < textField.getText().length()) {
- if(textField.getText().charAt(pos) == '&') {
- String before = textField.getText().substring(0, pos);
- String after = "";
- if(pos+2 < textField.getText().length()) {
- after = textField.getText().substring(pos+2);
- }
- textField.setText(before + "\u00A7" + after);
- textField.setCursorPosition(pos+1);
- }
- }
- } else if(typedChar == '*') {
- int pos = textField.getCursorPosition()-2;
- if(pos >= 0 && pos < textField.getText().length()) {
- if(textField.getText().charAt(pos) == '*') {
- String before = textField.getText().substring(0, pos);
- String after = "";
- if(pos+2 < textField.getText().length()) {
- after = textField.getText().substring(pos+2);
- }
- textField.setText(before + "\u272A" + after);
- textField.setCursorPosition(pos+1);
- }
- }
- }
- }
-
- if((options & NUM_ONLY) != 0 && textField.getText().matches("[^0-9.]")) textField.setText(old);
- }
- }
-
- public void render(int x, int y) {
- this.x = x;
- this.y = y;
- drawTextbox(x, y, searchBarXSize, searchBarYSize, searchBarPadding, textField, focus);
- }
-
- private void drawTextbox(int x, int y, int searchBarXSize, int searchBarYSize, int searchBarPadding,
- GuiTextField textField, boolean focus) {
- ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
- String renderText = prependText + textField.getText();
-
- GlStateManager.disableLighting();
-
- /**
- * Search bar
- */
- int paddingUnscaled = searchBarPadding/scaledresolution.getScaleFactor();
- if(paddingUnscaled < 1) paddingUnscaled = 1;
-
- int numLines = org.apache.commons.lang3.StringUtils.countMatches(renderText, "\n")+1;
- int extraSize = (searchBarYSize-8)/2+8;
- int bottomTextBox = y + searchBarYSize + extraSize*(numLines-1);
-
- int borderColour = focus ? Color.GREEN.getRGB() : Color.WHITE.getRGB();
- if(customBorderColour != -1) {
- borderColour = customBorderColour;
- }
- if((options & DISABLE_BG) == 0) {
- //bar background
- Gui.drawRect(x - paddingUnscaled,
- y - paddingUnscaled,
- x + searchBarXSize + paddingUnscaled,
- bottomTextBox + paddingUnscaled, borderColour);
- Gui.drawRect(x,
- y,
- x + searchBarXSize,
- bottomTextBox, Color.BLACK.getRGB());
- }
-
- //bar text
- String text = renderText;
- String textNoColor = renderText;
- if((options & COLOUR) != 0) {
- while(true) {
- Matcher matcher = PATTERN_CONTROL_CODE.matcher(text);
- if(!matcher.find() || matcher.groupCount() < 1) break;
- String code = matcher.group(1);
- if(code.isEmpty()) {
- text = matcher.replaceFirst("\u00A7r\u00B6");
- } else {
- text = matcher.replaceFirst("\u00A7"+code+"\u00B6"+code);
- }
- }
- }
- while(true) {
- Matcher matcher = PATTERN_CONTROL_CODE.matcher(textNoColor);
- if(!matcher.find() || matcher.groupCount() < 1) break;
- String code = matcher.group(1);
- textNoColor = matcher.replaceFirst("\u00B6"+code);
- }
-
- int xStartOffset = 5;
- float scale = 1;
- String[] texts = text.split("\n");
- for(int yOffI = 0; yOffI < texts.length; yOffI++) {
- int yOff = yOffI*extraSize;
-
- if(isScaling() && Minecraft.getMinecraft().fontRendererObj.getStringWidth(texts[yOffI])>searchBarXSize-10) {
- scale = (searchBarXSize-2)/(float)Minecraft.getMinecraft().fontRendererObj.getStringWidth(texts[yOffI]);
- if(scale > 1) scale=1;
- float newLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(texts[yOffI])*scale;
- xStartOffset = (int)((searchBarXSize-newLen)/2f);
-
- TextRenderUtils.drawStringCenteredScaledMaxWidth(Utils.chromaStringByColourCode(texts[yOffI]), Minecraft.getMinecraft().fontRendererObj, x+searchBarXSize/2f,
- y+searchBarYSize/2f+yOff, false,
- searchBarXSize-2, customTextColour);
- } else {
- if((options & SCISSOR_TEXT) != 0) {
- GlScissorStack.push(x+5, 0, x+searchBarXSize, scaledresolution.getScaledHeight(), scaledresolution);
- Minecraft.getMinecraft().fontRendererObj.drawString(Utils.chromaStringByColourCode(texts[yOffI]), x + 5,
- y+(searchBarYSize-8)/2+yOff, customTextColour);
- GlScissorStack.pop(scaledresolution);
- } else {
- String toRender = Minecraft.getMinecraft().fontRendererObj.trimStringToWidth(Utils.chromaStringByColourCode(texts[yOffI]), searchBarXSize-10);
- Minecraft.getMinecraft().fontRendererObj.drawString(toRender, x + 5,
- y+(searchBarYSize-8)/2+yOff, customTextColour);
- }
-
- }
- }
-
- if(focus && System.currentTimeMillis()%1000>500) {
- String textNCBeforeCursor = textNoColor.substring(0, textField.getCursorPosition()+prependText.length());
- int colorCodes = org.apache.commons.lang3.StringUtils.countMatches(textNCBeforeCursor, "\u00B6");
- String textBeforeCursor = text.substring(0, Math.min(text.length(), textField.getCursorPosition()+prependText.length()+(((options & COLOUR) != 0) ? colorCodes*2 : 0)));
-
- int numLinesBeforeCursor = org.apache.commons.lang3.StringUtils.countMatches(textBeforeCursor, "\n");
- int yOff = numLinesBeforeCursor*extraSize;
-
- String[] split = textBeforeCursor.split("\n");
- int textBeforeCursorWidth;
- if(split.length <= numLinesBeforeCursor || split.length == 0) {
- textBeforeCursorWidth = 0;
- } else {
- textBeforeCursorWidth = (int)(Minecraft.getMinecraft().fontRendererObj.getStringWidth(split[split.length-1])*scale);
- }
- Gui.drawRect(x + xStartOffset + textBeforeCursorWidth,
- y+(searchBarYSize-8)/2-1 + yOff,
- x + xStartOffset + textBeforeCursorWidth+1,
- y+(searchBarYSize-8)/2+9 + yOff, Color.WHITE.getRGB());
- }
-
- String selectedText = textField.getSelectedText();
- if(!selectedText.isEmpty()) {
- int leftIndex = Math.min(textField.getCursorPosition()+prependText.length(), textField.getSelectionEnd()+prependText.length());
- int rightIndex = Math.max(textField.getCursorPosition()+prependText.length(), textField.getSelectionEnd()+prependText.length());
-
- float texX = 0;
- int texY = 0;
- boolean sectionSignPrev = false;
- boolean ignoreNext = false;
- boolean bold = false;
- for(int i=0; i<textNoColor.length(); i++) {
- if(ignoreNext) {
- ignoreNext = false;
- continue;
- }
-
- char c = textNoColor.charAt(i);
- if(sectionSignPrev) {
- if(c != 'k' && c != 'K'
- && c != 'm' && c != 'M'
- && c != 'n' && c != 'N'
- && c != 'o' && c != 'O') {
- bold = c == 'l' || c == 'L';
- }
- sectionSignPrev = false;
- if(i < prependText.length()) continue;
- }
- if(c == '\u00B6') {
- sectionSignPrev = true;
- if(i < prependText.length()) continue;
- }
-
- if(c == '\n') {
- if(i >= leftIndex && i < rightIndex) {
- Gui.drawRect(x + xStartOffset + (int)texX,
- y+(searchBarYSize-8)/2-1 + texY,
- x + xStartOffset + (int)texX + 3,
- y+(searchBarYSize-8)/2+9 + texY, Color.LIGHT_GRAY.getRGB());
- }
-
- texX = 0;
- texY += extraSize;
- continue;
- }
-
- int len = Minecraft.getMinecraft().fontRendererObj.getStringWidth(String.valueOf(c));
- if(bold) len++;
- if(i >= leftIndex && i < rightIndex) {
- Gui.drawRect(x + xStartOffset + (int)texX,
- y+(searchBarYSize-8)/2-1 + texY,
- x + xStartOffset + (int)(texX + len*scale),
- y+(searchBarYSize-8)/2+9 + texY, Color.LIGHT_GRAY.getRGB());
-
- TextRenderUtils.drawStringScaled(String.valueOf(c), Minecraft.getMinecraft().fontRendererObj,
- x + xStartOffset + texX,
- y+searchBarYSize/2f-scale*8/2f + texY, false, Color.BLACK.getRGB(), scale);
- if(bold) {
- TextRenderUtils.drawStringScaled(String.valueOf(c), Minecraft.getMinecraft().fontRendererObj,
- x + xStartOffset + texX + 1,
- y+searchBarYSize/2f-scale*8/2f + texY, false, Color.BLACK.getRGB(), scale);
- }
- }
-
- texX += len*scale;
- }
- }
- }
+ public static final int SCISSOR_TEXT = 0b10000000;
+ 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;
+ public static final int FORCE_CAPS = 0b00100;
+ public static final int COLOUR = 0b00010;
+ public static final int MULTILINE = 0b00001;
+
+ private int searchBarYSize;
+ private int searchBarXSize;
+ private static final int searchBarPadding = 2;
+
+ private int options;
+
+ private boolean focus = false;
+
+ private int x;
+ private int y;
+
+ private String prependText = "";
+ private int customTextColour = 0xffffffff;
+
+ private final GuiTextField textField = new GuiTextField(0, Minecraft.getMinecraft().fontRendererObj,
+ 0, 0, 0, 0
+ );
+
+ private int customBorderColour = -1;
+
+ public GuiElementTextField(String initialText, int options) {
+ this(initialText, 100, 20, options);
+ }
+
+ public GuiElementTextField(String initialText, int sizeX, int sizeY, int options) {
+ textField.setFocused(true);
+ textField.setCanLoseFocus(false);
+ textField.setMaxStringLength(999);
+ textField.setText(initialText);
+ this.searchBarXSize = sizeX;
+ this.searchBarYSize = sizeY;
+ this.options = options;
+ }
+
+ public void setMaxStringLength(int len) {
+ textField.setMaxStringLength(len);
+ }
+
+ public void setCustomBorderColour(int colour) {
+ this.customBorderColour = colour;
+ }
+
+ public void setCustomTextColour(int colour) {
+ this.customTextColour = colour;
+ }
+
+ public String getText() {
+ return textField.getText();
+ }
+
+ public String getTextDisplay() {
+ String textNoColour = getText();
+ while (true) {
+ Matcher matcher = PATTERN_CONTROL_CODE.matcher(textNoColour);
+ if (!matcher.find()) break;
+ String code = matcher.group(1);
+ textNoColour = matcher.replaceFirst("\u00B6" + code);
+ }
+
+ return textNoColour;
+ }
+
+ public void setPrependText(String text) {
+ this.prependText = text;
+ }
+
+ public void setText(String text) {
+ if (textField.getText() == null || !textField.getText().equals(text)) {
+ textField.setText(text);
+ }
+ }
+
+ public void setSize(int searchBarXSize, int searchBarYSize) {
+ this.searchBarXSize = searchBarXSize;
+ this.searchBarYSize = searchBarYSize;
+ }
+
+ public void setOptions(int options) {
+ this.options = options;
+ }
+
+ @Override
+ public String toString() {
+ return textField.getText();
+ }
+
+ public void setFocus(boolean focus) {
+ this.focus = focus;
+ if (!focus) {
+ textField.setCursorPosition(textField.getCursorPosition());
+ }
+ }
+
+ public boolean getFocus() {
+ return focus;
+ }
+
+ public int getHeight() {
+ ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
+ int paddingUnscaled = searchBarPadding / scaledresolution.getScaleFactor();
+
+ int numLines = org.apache.commons.lang3.StringUtils.countMatches(textField.getText(), "\n") + 1;
+ int extraSize = (searchBarYSize - 8) / 2 + 8;
+ int bottomTextBox = searchBarYSize + extraSize * (numLines - 1);
+
+ return bottomTextBox + paddingUnscaled * 2;
+ }
+
+ public int getWidth() {
+ ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
+ int paddingUnscaled = searchBarPadding / scaledresolution.getScaleFactor();
+
+ return searchBarXSize + paddingUnscaled * 2;
+ }
+
+ private float getScaleFactor(String str) {
+ return Math.min(1, (searchBarXSize - 2) / (float) Minecraft.getMinecraft().fontRendererObj.getStringWidth(str));
+ }
+
+ private boolean isScaling() {
+ return (options & SCALE_TEXT) != 0;
+ }
+
+ private static final Pattern PATTERN_CONTROL_CODE = Pattern.compile("(?i)\\u00A7([^\\u00B6]|$)(?!\\u00B6)");
+
+ public int getCursorPos(int mouseX, int mouseY) {
+ int xComp = mouseX - x;
+ int yComp = mouseY - y;
+
+ int extraSize = (searchBarYSize - 8) / 2 + 8;
+
+ String renderText = prependText + textField.getText();
+
+ int lineNum = Math.round(((yComp - (searchBarYSize - 8) / 2)) / extraSize);
+
+ String text = renderText;
+ String textNoColour = renderText;
+ if ((options & COLOUR) != 0) {
+ while (true) {
+ Matcher matcher = PATTERN_CONTROL_CODE.matcher(text);
+ if (!matcher.find() || matcher.groupCount() < 1) break;
+ String code = matcher.group(1);
+ if (code.isEmpty()) {
+ text = matcher.replaceFirst("\u00A7r\u00B6");
+ } else {
+ text = matcher.replaceFirst("\u00A7" + code + "\u00B6" + code);
+ }
+ }
+ }
+ while (true) {
+ Matcher matcher = PATTERN_CONTROL_CODE.matcher(textNoColour);
+ if (!matcher.find() || matcher.groupCount() < 1) break;
+ String code = matcher.group(1);
+ textNoColour = matcher.replaceFirst("\u00B6" + code);
+ }
+
+ int currentLine = 0;
+ int cursorIndex = 0;
+ for (; cursorIndex < textNoColour.length(); cursorIndex++) {
+ if (currentLine == lineNum) break;
+ if (textNoColour.charAt(cursorIndex) == '\n') {
+ currentLine++;
+ }
+ }
+
+ 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];
+ int padding = Math.min(5, searchBarXSize - strLenNoColor(line)) / 2;
+ String trimmed = Minecraft.getMinecraft().fontRendererObj.trimStringToWidth(line, xComp - padding);
+ int linePos = strLenNoColor(trimmed);
+ if (linePos != strLenNoColor(line)) {
+ char after = line.charAt(linePos);
+ int trimmedWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(trimmed);
+ int charWidth = Minecraft.getMinecraft().fontRendererObj.getCharWidth(after);
+ if (trimmedWidth + charWidth / 2 < xComp - padding) {
+ linePos++;
+ }
+ }
+ cursorIndex += linePos;
+
+ int pre = StringUtils.cleanColour(prependText).length();
+ if (cursorIndex < pre) {
+ cursorIndex = 0;
+ } else {
+ cursorIndex -= pre;
+ }
+
+ return cursorIndex;
+ }
+
+ public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
+ if (mouseButton == 1) {
+ textField.setText("");
+ } else {
+ textField.setCursorPosition(getCursorPos(mouseX, mouseY));
+ }
+ focus = true;
+ }
+
+ public void unfocus() {
+ focus = false;
+ textField.setSelectionPos(textField.getCursorPosition());
+ }
+
+ public int strLenNoColor(String str) {
+ return str.replaceAll("(?i)\\u00A7.", "").length();
+ }
+
+ public void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
+ if (focus) {
+ textField.setSelectionPos(getCursorPos(mouseX, mouseY));
+ }
+ }
+
+ public void keyTyped(char typedChar, int keyCode) {
+ if (focus) {
+ if ((options & MULTILINE) != 0) { //Carriage return
+ Pattern patternControlCode = Pattern.compile("(?i)\\u00A7([^\\u00B6\n]|$)(?!\\u00B6)");
+
+ String text = textField.getText();
+ String textNoColour = textField.getText();
+ while (true) {
+ Matcher matcher = patternControlCode.matcher(text);
+ if (!matcher.find() || matcher.groupCount() < 1) break;
+ String code = matcher.group(1);
+ if (code.isEmpty()) {
+ text = matcher.replaceFirst("\u00A7r\u00B6");
+ } else {
+ text = matcher.replaceFirst("\u00A7" + code + "\u00B6" + code);
+ }
+ }
+ while (true) {
+ Matcher matcher = patternControlCode.matcher(textNoColour);
+ if (!matcher.find() || matcher.groupCount() < 1) break;
+ String code = matcher.group(1);
+ textNoColour = matcher.replaceFirst("\u00B6" + code);
+ }
+
+ if (keyCode == 28) {
+ String before = textField.getText().substring(0, textField.getCursorPosition());
+ String after = textField.getText().substring(textField.getCursorPosition());
+ int pos = textField.getCursorPosition();
+ textField.setText(before + "\n" + after);
+ textField.setCursorPosition(pos + 1);
+ return;
+ } else if (keyCode == 200) { //Up
+ String textNCBeforeCursor = textNoColour.substring(0, textField.getSelectionEnd());
+ int colorCodes = org.apache.commons.lang3.StringUtils.countMatches(textNCBeforeCursor, "\u00B6");
+ String textBeforeCursor = text.substring(0, textField.getSelectionEnd() + colorCodes * 2);
+
+ int numLinesBeforeCursor = org.apache.commons.lang3.StringUtils.countMatches(textBeforeCursor, "\n");
+
+ String[] split = textBeforeCursor.split("\n");
+ int textBeforeCursorWidth;
+ String lineBefore;
+ String thisLineBeforeCursor;
+ if (split.length == numLinesBeforeCursor && split.length > 0) {
+ textBeforeCursorWidth = 0;
+ lineBefore = split[split.length - 1];
+ thisLineBeforeCursor = "";
+ } else if (split.length > 1) {
+ thisLineBeforeCursor = split[split.length - 1];
+ lineBefore = split[split.length - 2];
+ textBeforeCursorWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(thisLineBeforeCursor);
+ } else {
+ return;
+ }
+ String trimmed = Minecraft.getMinecraft().fontRendererObj
+ .trimStringToWidth(lineBefore, textBeforeCursorWidth);
+ int linePos = strLenNoColor(trimmed);
+ if (linePos != strLenNoColor(lineBefore)) {
+ char after = lineBefore.charAt(linePos);
+ int trimmedWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(trimmed);
+ int charWidth = Minecraft.getMinecraft().fontRendererObj.getCharWidth(after);
+ if (trimmedWidth + charWidth / 2 < textBeforeCursorWidth) {
+ linePos++;
+ }
+ }
+ int newPos = textField.getSelectionEnd() - strLenNoColor(thisLineBeforeCursor)
+ - strLenNoColor(lineBefore) - 1 + linePos;
+
+ if (GuiScreen.isShiftKeyDown()) {
+ textField.setSelectionPos(newPos);
+ } else {
+ textField.setCursorPosition(newPos);
+ }
+ } else if (keyCode == 208) { //Down
+ String textNCBeforeCursor = textNoColour.substring(0, textField.getSelectionEnd());
+ int colorCodes = org.apache.commons.lang3.StringUtils.countMatches(textNCBeforeCursor, "\u00B6");
+ String textBeforeCursor = text.substring(0, textField.getSelectionEnd() + colorCodes * 2);
+
+ int numLinesBeforeCursor = org.apache.commons.lang3.StringUtils.countMatches(textBeforeCursor, "\n");
+
+ String[] split = textBeforeCursor.split("\n");
+ String thisLineBeforeCursor;
+ int textBeforeCursorWidth;
+ if (split.length == numLinesBeforeCursor) {
+ thisLineBeforeCursor = "";
+ textBeforeCursorWidth = 0;
+ } else if (split.length > 0) {
+ thisLineBeforeCursor = split[split.length - 1];
+ textBeforeCursorWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(thisLineBeforeCursor);
+ } else {
+ return;
+ }
+
+ String[] split2 = textNoColour.split("\n");
+ if (split2.length > numLinesBeforeCursor + 1) {
+ String lineAfter = split2[numLinesBeforeCursor + 1];
+ String trimmed = Minecraft.getMinecraft().fontRendererObj
+ .trimStringToWidth(lineAfter, textBeforeCursorWidth);
+ int linePos = strLenNoColor(trimmed);
+ if (linePos != strLenNoColor(lineAfter)) {
+ char after = lineAfter.charAt(linePos);
+ int trimmedWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(trimmed);
+ int charWidth = Minecraft.getMinecraft().fontRendererObj.getCharWidth(after);
+ if (trimmedWidth + charWidth / 2 < textBeforeCursorWidth) {
+ linePos++;
+ }
+ }
+ int newPos = textField.getSelectionEnd() - strLenNoColor(thisLineBeforeCursor)
+ + strLenNoColor(split2[numLinesBeforeCursor]) + 1 + linePos;
+
+ if (GuiScreen.isShiftKeyDown()) {
+ textField.setSelectionPos(newPos);
+ } else {
+ textField.setCursorPosition(newPos);
+ }
+ }
+ }
+ }
+
+ String old = textField.getText();
+ if ((options & FORCE_CAPS) != 0) typedChar = Character.toUpperCase(typedChar);
+ if ((options & NO_SPACE) != 0 && typedChar == ' ') return;
+
+ if (typedChar == '\u00B6') {
+ typedChar = '\u00A7';
+ }
+
+ textField.setFocused(true);
+ textField.textboxKeyTyped(typedChar, keyCode);
+
+ if ((options & COLOUR) != 0) {
+ if (typedChar == '&') {
+ int pos = textField.getCursorPosition() - 2;
+ if (pos >= 0 && pos < textField.getText().length()) {
+ if (textField.getText().charAt(pos) == '&') {
+ String before = textField.getText().substring(0, pos);
+ String after = "";
+ if (pos + 2 < textField.getText().length()) {
+ after = textField.getText().substring(pos + 2);
+ }
+ textField.setText(before + "\u00A7" + after);
+ textField.setCursorPosition(pos + 1);
+ }
+ }
+ } else if (typedChar == '*') {
+ int pos = textField.getCursorPosition() - 2;
+ if (pos >= 0 && pos < textField.getText().length()) {
+ if (textField.getText().charAt(pos) == '*') {
+ String before = textField.getText().substring(0, pos);
+ String after = "";
+ if (pos + 2 < textField.getText().length()) {
+ after = textField.getText().substring(pos + 2);
+ }
+ textField.setText(before + "\u272A" + after);
+ textField.setCursorPosition(pos + 1);
+ }
+ }
+ }
+ }
+
+ if ((options & NUM_ONLY) != 0 && textField.getText().matches("[^0-9.]")) textField.setText(old);
+ }
+ }
+
+ public void render(int x, int y) {
+ this.x = x;
+ this.y = y;
+ drawTextbox(x, y, searchBarXSize, searchBarYSize, searchBarPadding, textField, focus);
+ }
+
+ private void drawTextbox(
+ int x, int y, int searchBarXSize, int searchBarYSize, int searchBarPadding,
+ GuiTextField textField, boolean focus
+ ) {
+ ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
+ String renderText = prependText + textField.getText();
+
+ GlStateManager.disableLighting();
+
+ /*
+ * Search bar
+ */
+ int paddingUnscaled = searchBarPadding / scaledresolution.getScaleFactor();
+ if (paddingUnscaled < 1) paddingUnscaled = 1;
+
+ int numLines = org.apache.commons.lang3.StringUtils.countMatches(renderText, "\n") + 1;
+ int extraSize = (searchBarYSize - 8) / 2 + 8;
+ int bottomTextBox = y + searchBarYSize + extraSize * (numLines - 1);
+
+ int borderColour = focus ? Color.GREEN.getRGB() : Color.WHITE.getRGB();
+ if (customBorderColour != -1) {
+ borderColour = customBorderColour;
+ }
+ if ((options & DISABLE_BG) == 0) {
+ //bar background
+ Gui.drawRect(x - paddingUnscaled,
+ y - paddingUnscaled,
+ x + searchBarXSize + paddingUnscaled,
+ bottomTextBox + paddingUnscaled, borderColour
+ );
+ Gui.drawRect(x,
+ y,
+ x + searchBarXSize,
+ bottomTextBox, Color.BLACK.getRGB()
+ );
+ }
+
+ //bar text
+ String text = renderText;
+ String textNoColor = renderText;
+ if ((options & COLOUR) != 0) {
+ while (true) {
+ Matcher matcher = PATTERN_CONTROL_CODE.matcher(text);
+ if (!matcher.find() || matcher.groupCount() < 1) break;
+ String code = matcher.group(1);
+ if (code.isEmpty()) {
+ text = matcher.replaceFirst("\u00A7r\u00B6");
+ } else {
+ text = matcher.replaceFirst("\u00A7" + code + "\u00B6" + code);
+ }
+ }
+ }
+ while (true) {
+ Matcher matcher = PATTERN_CONTROL_CODE.matcher(textNoColor);
+ if (!matcher.find() || matcher.groupCount() < 1) break;
+ String code = matcher.group(1);
+ textNoColor = matcher.replaceFirst("\u00B6" + code);
+ }
+
+ int xStartOffset = 5;
+ float scale = 1;
+ String[] texts = text.split("\n");
+ for (int yOffI = 0; yOffI < texts.length; yOffI++) {
+ int yOff = yOffI * extraSize;
+
+ if (isScaling() && Minecraft.getMinecraft().fontRendererObj.getStringWidth(texts[yOffI]) > searchBarXSize - 10) {
+ scale = (searchBarXSize - 2) / (float) Minecraft.getMinecraft().fontRendererObj.getStringWidth(texts[yOffI]);
+ if (scale > 1) scale = 1;
+ float newLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(texts[yOffI]) * scale;
+ xStartOffset = (int) ((searchBarXSize - newLen) / 2f);
+
+ TextRenderUtils.drawStringCenteredScaledMaxWidth(
+ Utils.chromaStringByColourCode(texts[yOffI]),
+ Minecraft.getMinecraft().fontRendererObj,
+ x + searchBarXSize / 2f,
+ y + searchBarYSize / 2f + yOff,
+ false,
+ searchBarXSize - 2,
+ customTextColour
+ );
+ } else {
+ if ((options & SCISSOR_TEXT) != 0) {
+ GlScissorStack.push(x + 5, 0, x + searchBarXSize, scaledresolution.getScaledHeight(), scaledresolution);
+ Minecraft.getMinecraft().fontRendererObj.drawString(Utils.chromaStringByColourCode(texts[yOffI]), x + 5,
+ y + (searchBarYSize - 8) / 2 + yOff, customTextColour
+ );
+ GlScissorStack.pop(scaledresolution);
+ } else {
+ String toRender = Minecraft.getMinecraft().fontRendererObj.trimStringToWidth(Utils.chromaStringByColourCode(
+ texts[yOffI]), searchBarXSize - 10);
+ Minecraft.getMinecraft().fontRendererObj.drawString(toRender, x + 5,
+ y + (searchBarYSize - 8) / 2 + yOff, customTextColour
+ );
+ }
+
+ }
+ }
+
+ if (focus && System.currentTimeMillis() % 1000 > 500) {
+ String textNCBeforeCursor = textNoColor.substring(0, textField.getCursorPosition() + prependText.length());
+ int colorCodes = org.apache.commons.lang3.StringUtils.countMatches(textNCBeforeCursor, "\u00B6");
+ String textBeforeCursor = text.substring(
+ 0,
+ Math.min(
+ text.length(),
+ textField.getCursorPosition() + prependText.length() + (((options & COLOUR) != 0) ? colorCodes * 2 : 0)
+ )
+ );
+
+ int numLinesBeforeCursor = org.apache.commons.lang3.StringUtils.countMatches(textBeforeCursor, "\n");
+ int yOff = numLinesBeforeCursor * extraSize;
+
+ String[] split = textBeforeCursor.split("\n");
+ int textBeforeCursorWidth;
+ if (split.length <= numLinesBeforeCursor || split.length == 0) {
+ textBeforeCursorWidth = 0;
+ } else {
+ textBeforeCursorWidth = (int) (Minecraft.getMinecraft().fontRendererObj.getStringWidth(split[split.length -
+ 1]) * scale);
+ }
+ Gui.drawRect(x + xStartOffset + textBeforeCursorWidth,
+ y + (searchBarYSize - 8) / 2 - 1 + yOff,
+ x + xStartOffset + textBeforeCursorWidth + 1,
+ y + (searchBarYSize - 8) / 2 + 9 + yOff, Color.WHITE.getRGB()
+ );
+ }
+
+ String selectedText = textField.getSelectedText();
+ if (!selectedText.isEmpty()) {
+ int leftIndex = Math.min(
+ textField.getCursorPosition() + prependText.length(),
+ textField.getSelectionEnd() + prependText.length()
+ );
+ int rightIndex = Math.max(
+ textField.getCursorPosition() + prependText.length(),
+ textField.getSelectionEnd() + prependText.length()
+ );
+
+ float texX = 0;
+ int texY = 0;
+ boolean sectionSignPrev = false;
+ boolean ignoreNext = false;
+ boolean bold = false;
+ for (int i = 0; i < textNoColor.length(); i++) {
+ if (ignoreNext) {
+ ignoreNext = false;
+ continue;
+ }
+
+ char c = textNoColor.charAt(i);
+ if (sectionSignPrev) {
+ if (c != 'k' && c != 'K'
+ && c != 'm' && c != 'M'
+ && c != 'n' && c != 'N'
+ && c != 'o' && c != 'O') {
+ bold = c == 'l' || c == 'L';
+ }
+ sectionSignPrev = false;
+ if (i < prependText.length()) continue;
+ }
+ if (c == '\u00B6') {
+ sectionSignPrev = true;
+ if (i < prependText.length()) continue;
+ }
+
+ if (c == '\n') {
+ if (i >= leftIndex && i < rightIndex) {
+ Gui.drawRect(x + xStartOffset + (int) texX,
+ y + (searchBarYSize - 8) / 2 - 1 + texY,
+ x + xStartOffset + (int) texX + 3,
+ y + (searchBarYSize - 8) / 2 + 9 + texY, Color.LIGHT_GRAY.getRGB()
+ );
+ }
+
+ texX = 0;
+ texY += extraSize;
+ continue;
+ }
+
+ int len = Minecraft.getMinecraft().fontRendererObj.getStringWidth(String.valueOf(c));
+ if (bold) len++;
+ if (i >= leftIndex && i < rightIndex) {
+ Gui.drawRect(x + xStartOffset + (int) texX,
+ y + (searchBarYSize - 8) / 2 - 1 + texY,
+ x + xStartOffset + (int) (texX + len * scale),
+ y + (searchBarYSize - 8) / 2 + 9 + texY, Color.LIGHT_GRAY.getRGB()
+ );
+
+ TextRenderUtils.drawStringScaled(String.valueOf(c), Minecraft.getMinecraft().fontRendererObj,
+ x + xStartOffset + texX,
+ y + searchBarYSize / 2f - scale * 8 / 2f + texY, false, Color.BLACK.getRGB(), scale
+ );
+ if (bold) {
+ TextRenderUtils.drawStringScaled(String.valueOf(c), Minecraft.getMinecraft().fontRendererObj,
+ x + xStartOffset + texX + 1,
+ y + searchBarYSize / 2f - scale * 8 / 2f + texY, false, Color.BLACK.getRGB(), scale
+ );
+ }
+ }
+
+ texX += len * scale;
+ }
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiScreenElementWrapper.java b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiScreenElementWrapper.java
index 8d32d6c3..c7c4517b 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiScreenElementWrapper.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiScreenElementWrapper.java
@@ -6,30 +6,29 @@ import org.lwjgl.input.Mouse;
import java.io.IOException;
public class GuiScreenElementWrapper extends GuiScreen {
-
- public final GuiElement element;
-
- public GuiScreenElementWrapper(GuiElement element) {
- this.element = element;
- }
-
- @Override
- public void drawScreen(int mouseX, int mouseY, float partialTicks) {
- super.drawScreen(mouseX, mouseY, partialTicks);
- element.render();
- }
-
- @Override
- public void handleMouseInput() throws IOException {
- super.handleMouseInput();
- int i = Mouse.getEventX() * this.width / this.mc.displayWidth;
- int j = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
- element.mouseInput(i, j);
- }
-
- @Override
- public void handleKeyboardInput() throws IOException {
- super.handleKeyboardInput();
- element.keyboardInput();
- }
+ public final GuiElement element;
+
+ public GuiScreenElementWrapper(GuiElement element) {
+ this.element = element;
+ }
+
+ @Override
+ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
+ super.drawScreen(mouseX, mouseY, partialTicks);
+ element.render();
+ }
+
+ @Override
+ public void handleMouseInput() throws IOException {
+ super.handleMouseInput();
+ int i = Mouse.getEventX() * this.width / this.mc.displayWidth;
+ int j = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
+ element.mouseInput(i, j);
+ }
+
+ @Override
+ public void handleKeyboardInput() throws IOException {
+ super.handleKeyboardInput();
+ element.keyboardInput();
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/Config.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/Config.java
index 8be828bd..2a696a44 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/Config.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/Config.java
@@ -1,8 +1,5 @@
package io.github.moulberry.notenoughupdates.core.config;
public class Config {
-
- public void executeRunnable(int runnableId) {
- }
-
+ public void executeRunnable(int runnableId) {}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/GuiPositionEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/GuiPositionEditor.java
index a48f3f1a..9d0133cb 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/GuiPositionEditor.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/GuiPositionEditor.java
@@ -8,108 +8,113 @@ import net.minecraft.client.gui.ScaledResolution;
import java.io.IOException;
public class GuiPositionEditor extends GuiScreen {
-
- public PositionNew position = new PositionNew();
-
- public int clickedX;
- public int clickedY;
-
- @Override
- public void drawScreen(int mouseX, int mouseY, float partialTicks) {
- super.drawDefaultBackground();
-
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- int width = scaledResolution.getScaledWidth();
- int height = scaledResolution.getScaledHeight();
-
- int x = position.resolveX(scaledResolution, 200);
- int y = position.resolveY(scaledResolution, 100);
-
- int centerWidth = 176;
- int centerHeight = 166;
-
- float centerWF = centerWidth/2f / (float)width;
- float centerHF = centerHeight/2f / (float)height;
-
- float left = 0;
- float top = 0;
- float right = 0;
- float bottom = 0;
-
- switch(position.getAnchorX()) {
- case MIN: {
- left = 0;
- right = 0.5f - centerWF;
- break;
- }
- case MID: {
- left = 0.5f - centerWF;
- right = 0.5f + centerWF;
- break;
- }
- case MAX: {
- left = 0.5f + centerWF;
- right = 1;
- break;
- }
- }
- switch(position.getAnchorY()) {
- case MIN: {
- top = 0;
- bottom = 0.5f - centerHF;
- break;
- }
- case MID: {
- top = 0.5f - centerHF;
- bottom = 0.5f + centerHF;
- break;
- }
- case MAX: {
- top = 0.5f + centerHF;
- bottom = 1;
- break;
- }
- }
-
- Gui.drawRect((int)(left*width), (int)(top*height), (int)(right*width), (int)(bottom*height), 0x40404040);
- Gui.drawRect(x, y, x+200, y+100, 0x80404040);
- }
-
- @Override
- protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- int x = position.resolveX(scaledResolution, 200);
- int y = position.resolveY(scaledResolution, 100);
-
- if(mouseX > x && mouseX < x+200 &&
- mouseY > y && mouseY < y+100) {
- clickedX = mouseX;
- clickedY = mouseY;
- } else {
- clickedX = -1;
- clickedY = -1;
- }
- }
-
- @Override
- protected void mouseReleased(int mouseX, int mouseY, int state) {
- clickedX = -1;
- clickedY = -1;
- }
-
- @Override
- protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
- if(clickedX >= 0 && clickedY >= 0) {
- int deltaX = mouseX - clickedX;
- int deltaY = mouseY - clickedY;
-
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
-
- deltaX = position.moveX(scaledResolution, deltaX, 200);
- deltaY = position.moveY(scaledResolution, deltaY, 100);
-
- clickedX += deltaX;
- clickedY += deltaY;
- }
- }
+ public PositionNew position = new PositionNew();
+
+ public int clickedX;
+ public int clickedY;
+
+ @Override
+ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
+ super.drawDefaultBackground();
+
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ int width = scaledResolution.getScaledWidth();
+ int height = scaledResolution.getScaledHeight();
+
+ int x = position.resolveX(scaledResolution, 200);
+ int y = position.resolveY(scaledResolution, 100);
+
+ int centerWidth = 176;
+ int centerHeight = 166;
+
+ float centerWF = centerWidth / 2f / (float) width;
+ float centerHF = centerHeight / 2f / (float) height;
+
+ float left = 0;
+ float top = 0;
+ float right = 0;
+ float bottom = 0;
+
+ switch (position.getAnchorX()) {
+ case MIN: {
+ left = 0;
+ right = 0.5f - centerWF;
+ break;
+ }
+ case MID: {
+ left = 0.5f - centerWF;
+ right = 0.5f + centerWF;
+ break;
+ }
+ case MAX: {
+ left = 0.5f + centerWF;
+ right = 1;
+ break;
+ }
+ }
+ switch (position.getAnchorY()) {
+ case MIN: {
+ top = 0;
+ bottom = 0.5f - centerHF;
+ break;
+ }
+ case MID: {
+ top = 0.5f - centerHF;
+ bottom = 0.5f + centerHF;
+ break;
+ }
+ case MAX: {
+ top = 0.5f + centerHF;
+ bottom = 1;
+ break;
+ }
+ }
+
+ Gui.drawRect(
+ (int) (left * width),
+ (int) (top * height),
+ (int) (right * width),
+ (int) (bottom * height),
+ 0x40404040
+ );
+ Gui.drawRect(x, y, x + 200, y + 100, 0x80404040);
+ }
+
+ @Override
+ protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ int x = position.resolveX(scaledResolution, 200);
+ int y = position.resolveY(scaledResolution, 100);
+
+ if (mouseX > x && mouseX < x + 200 &&
+ mouseY > y && mouseY < y + 100) {
+ clickedX = mouseX;
+ clickedY = mouseY;
+ } else {
+ clickedX = -1;
+ clickedY = -1;
+ }
+ }
+
+ @Override
+ protected void mouseReleased(int mouseX, int mouseY, int state) {
+ clickedX = -1;
+ clickedY = -1;
+ }
+
+ @Override
+ protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
+ if (clickedX >= 0 && clickedY >= 0) {
+ int deltaX = mouseX - clickedX;
+ int deltaY = mouseY - clickedY;
+
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+
+ deltaX = position.moveX(scaledResolution, deltaX, 200);
+ deltaY = position.moveY(scaledResolution, deltaY, 100);
+
+ clickedX += deltaX;
+ clickedY += deltaY;
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/KeybindHelper.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/KeybindHelper.java
index 7ebacac1..30226a22 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/KeybindHelper.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/KeybindHelper.java
@@ -1,51 +1,48 @@
package io.github.moulberry.notenoughupdates.core.config;
-import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
public class KeybindHelper {
+ public static String getKeyName(int keyCode) {
+ if (keyCode == 0) {
+ return "NONE";
+ } else if (keyCode < 0) {
+ return "Button " + (keyCode + 101);
+ } else {
+ String keyName = Keyboard.getKeyName(keyCode);
+ if (keyName == null) {
+ keyName = "???";
+ } else if (keyName.equalsIgnoreCase("LMENU")) {
+ keyName = "LALT";
+ } else if (keyName.equalsIgnoreCase("RMENU")) {
+ keyName = "RALT";
+ }
+ return keyName;
+ }
+ }
- public static String getKeyName(int keyCode) {
- if(keyCode == 0) {
- return "NONE";
- } else if(keyCode < 0) {
- return "Button "+(keyCode+101);
- } else {
- String keyName = Keyboard.getKeyName(keyCode);
- if(keyName == null) {
- keyName = "???";
- } else if(keyName.equalsIgnoreCase("LMENU")) {
- keyName = "LALT";
- } else if(keyName.equalsIgnoreCase("RMENU")) {
- keyName = "RALT";
- }
- return keyName;
- }
- }
+ public static boolean isKeyValid(int keyCode) {
+ return keyCode != 0;
+ }
- public static boolean isKeyValid(int keyCode) {
- return keyCode != 0;
- }
-
- public static boolean isKeyDown(int keyCode) {
- if(!isKeyValid(keyCode)) {
- return false;
- } else if(keyCode < 0) {
- return Mouse.isButtonDown(keyCode+100);
- } else {
- return Keyboard.isKeyDown(keyCode);
- }
- }
-
- public static boolean isKeyPressed(int keyCode) {
- if(!isKeyValid(keyCode)) {
- return false;
- } else if(keyCode < 0) {
- return Mouse.getEventButtonState() && Mouse.getEventButton() == keyCode+100;
- } else {
- return Keyboard.getEventKeyState() && Keyboard.getEventKey() == keyCode;
- }
- }
+ public static boolean isKeyDown(int keyCode) {
+ if (!isKeyValid(keyCode)) {
+ return false;
+ } else if (keyCode < 0) {
+ return Mouse.isButtonDown(keyCode + 100);
+ } else {
+ return Keyboard.isKeyDown(keyCode);
+ }
+ }
+ public static boolean isKeyPressed(int keyCode) {
+ if (!isKeyValid(keyCode)) {
+ return false;
+ } else if (keyCode < 0) {
+ return Mouse.getEventButtonState() && Mouse.getEventButton() == keyCode + 100;
+ } else {
+ return Keyboard.getEventKeyState() && Keyboard.getEventKey() == keyCode;
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/Position.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/Position.java
index 66df27c6..cf946649 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/Position.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/Position.java
@@ -4,188 +4,186 @@ import com.google.gson.annotations.Expose;
import net.minecraft.client.gui.ScaledResolution;
public class Position {
-
- @Expose
- private int x;
- @Expose
- private int y;
- @Expose
- private boolean centerX;
- @Expose
- private boolean centerY;
-
- private static final int EDGE_OFFSET = 0;
-
- public Position(int x, int y) {
- this(x, y, false, false);
- }
-
- public Position(int x, int y, boolean centerX, boolean centerY) {
- this.x = x;
- this.y = y;
- this.centerX = centerX;
- this.centerY = centerY;
- }
-
- public void set(Position other) {
- this.x = other.x;
- this.y = other.y;
- this.centerX = other.centerX;
- this.centerY = other.centerY;
- }
-
- public Position clone() {
- return new Position(x, y, centerX, centerY);
- }
-
- public boolean isCenterX() {
- return centerX;
- }
-
- public boolean isCenterY() {
- return centerY;
- }
-
- public int getRawX() {
- return x;
- }
-
- public int getRawY() {
- return y;
- }
-
- public int getAbsX(ScaledResolution scaledResolution, int objWidth) {
- int width = scaledResolution.getScaledWidth();
-
- if(centerX) {
- return width/2 + x;
- }
-
- int ret = x;
- if(x < 0) {
- ret = width + x - objWidth;
- }
-
- if(ret < 0) ret = 0;
- if(ret > width - objWidth) ret = width - objWidth;
-
- return ret;
- }
-
- public int getAbsY(ScaledResolution scaledResolution, int objHeight) {
- int height = scaledResolution.getScaledHeight();
-
- if(centerY) {
- return height/2 + y;
- }
-
- int ret = y;
- if(y < 0) {
- ret = height + y - objHeight;
- }
-
- if(ret < 0) ret = 0;
- if(ret > height - objHeight) ret = height - objHeight;
-
- return ret;
- }
-
- public int moveX(int deltaX, int objWidth, ScaledResolution scaledResolution) {
- int screenWidth = scaledResolution.getScaledWidth();
- boolean wasPositiveX = this.x >= 0;
- this.x += deltaX;
-
- if(centerX) {
- if(wasPositiveX) {
- if(this.x > screenWidth/2-objWidth/2) {
- deltaX += screenWidth/2-objWidth/2-this.x;
- this.x = screenWidth/2-objWidth/2;
- }
- } else {
- if(this.x < -screenWidth/2+objWidth/2) {
- deltaX += -screenWidth/2+objWidth/2-this.x;
- this.x = -screenWidth/2+objWidth/2;
- }
- }
- return deltaX;
- }
-
- if(wasPositiveX) {
- if(this.x < EDGE_OFFSET) {
- deltaX += EDGE_OFFSET-this.x;
- this.x = EDGE_OFFSET;
- }
- if(this.x > screenWidth-EDGE_OFFSET) {
- deltaX += screenWidth-EDGE_OFFSET-this.x;
- this.x = screenWidth-EDGE_OFFSET;
- }
- } else {
- if(this.x+1 > -EDGE_OFFSET) {
- deltaX += -EDGE_OFFSET-1-this.x;
- this.x = -EDGE_OFFSET-1;
- }
- if(this.x+screenWidth < EDGE_OFFSET) {
- deltaX += EDGE_OFFSET-screenWidth-this.x;
- this.x = EDGE_OFFSET-screenWidth;
- }
- }
-
- if(this.x >= 0 && this.x+objWidth/2 > screenWidth/2) {
- this.x -= screenWidth - objWidth;
- }
- if(this.x < 0 && this.x+objWidth/2 <= -screenWidth/2) {
- this.x += screenWidth - objWidth;
- }
- return deltaX;
- }
-
- public int moveY(int deltaY, int objHeight, ScaledResolution scaledResolution) {
- int screenHeight = scaledResolution.getScaledHeight();
- boolean wasPositiveY = this.y >= 0;
- this.y += deltaY;
-
- if(centerY) {
- if(wasPositiveY) {
- if(this.y > screenHeight/2-objHeight/2) {
- deltaY += screenHeight/2-objHeight/2-this.y;
- this.y = screenHeight/2-objHeight/2;
- }
- } else {
- if(this.y < -screenHeight/2+objHeight/2) {
- deltaY += -screenHeight/2+objHeight/2-this.y;
- this.y = -screenHeight/2+objHeight/2;
- }
- }
- return deltaY;
- }
-
- if(wasPositiveY) {
- if(this.y < EDGE_OFFSET) {
- deltaY += EDGE_OFFSET-this.y;
- this.y = EDGE_OFFSET;
- }
- if(this.y > screenHeight-EDGE_OFFSET) {
- deltaY += screenHeight-EDGE_OFFSET-this.y;
- this.y = screenHeight-EDGE_OFFSET;
- }
- } else {
- if(this.y+1 > -EDGE_OFFSET) {
- deltaY += -EDGE_OFFSET-1-this.y;
- this.y = -EDGE_OFFSET-1;
- }
- if(this.y+screenHeight < EDGE_OFFSET) {
- deltaY += EDGE_OFFSET-screenHeight-this.y;
- this.y = EDGE_OFFSET-screenHeight;
- }
- }
-
- if(this.y >= 0 && this.y-objHeight/2 > screenHeight/2) {
- this.y -= screenHeight - objHeight;
- }
- if(this.y < 0 && this.y-objHeight/2 <= -screenHeight/2) {
- this.y += screenHeight - objHeight;
- }
- return deltaY;
- }
-
+ @Expose
+ private int x;
+ @Expose
+ private int y;
+ @Expose
+ private boolean centerX;
+ @Expose
+ private boolean centerY;
+
+ private static final int EDGE_OFFSET = 0;
+
+ public Position(int x, int y) {
+ this(x, y, false, false);
+ }
+
+ public Position(int x, int y, boolean centerX, boolean centerY) {
+ this.x = x;
+ this.y = y;
+ this.centerX = centerX;
+ this.centerY = centerY;
+ }
+
+ public void set(Position other) {
+ this.x = other.x;
+ this.y = other.y;
+ this.centerX = other.centerX;
+ this.centerY = other.centerY;
+ }
+
+ public Position clone() {
+ return new Position(x, y, centerX, centerY);
+ }
+
+ public boolean isCenterX() {
+ return centerX;
+ }
+
+ public boolean isCenterY() {
+ return centerY;
+ }
+
+ public int getRawX() {
+ return x;
+ }
+
+ public int getRawY() {
+ return y;
+ }
+
+ public int getAbsX(ScaledResolution scaledResolution, int objWidth) {
+ int width = scaledResolution.getScaledWidth();
+
+ if (centerX) {
+ return width / 2 + x;
+ }
+
+ int ret = x;
+ if (x < 0) {
+ ret = width + x - objWidth;
+ }
+
+ if (ret < 0) ret = 0;
+ if (ret > width - objWidth) ret = width - objWidth;
+
+ return ret;
+ }
+
+ public int getAbsY(ScaledResolution scaledResolution, int objHeight) {
+ int height = scaledResolution.getScaledHeight();
+
+ if (centerY) {
+ return height / 2 + y;
+ }
+
+ int ret = y;
+ if (y < 0) {
+ ret = height + y - objHeight;
+ }
+
+ if (ret < 0) ret = 0;
+ if (ret > height - objHeight) ret = height - objHeight;
+
+ return ret;
+ }
+
+ public int moveX(int deltaX, int objWidth, ScaledResolution scaledResolution) {
+ int screenWidth = scaledResolution.getScaledWidth();
+ boolean wasPositiveX = this.x >= 0;
+ this.x += deltaX;
+
+ if (centerX) {
+ if (wasPositiveX) {
+ if (this.x > screenWidth / 2 - objWidth / 2) {
+ deltaX += screenWidth / 2 - objWidth / 2 - this.x;
+ this.x = screenWidth / 2 - objWidth / 2;
+ }
+ } else {
+ if (this.x < -screenWidth / 2 + objWidth / 2) {
+ deltaX += -screenWidth / 2 + objWidth / 2 - this.x;
+ this.x = -screenWidth / 2 + objWidth / 2;
+ }
+ }
+ return deltaX;
+ }
+
+ if (wasPositiveX) {
+ if (this.x < EDGE_OFFSET) {
+ deltaX += EDGE_OFFSET - this.x;
+ this.x = EDGE_OFFSET;
+ }
+ if (this.x > screenWidth - EDGE_OFFSET) {
+ deltaX += screenWidth - EDGE_OFFSET - this.x;
+ this.x = screenWidth - EDGE_OFFSET;
+ }
+ } else {
+ if (this.x + 1 > -EDGE_OFFSET) {
+ deltaX += -EDGE_OFFSET - 1 - this.x;
+ this.x = -EDGE_OFFSET - 1;
+ }
+ if (this.x + screenWidth < EDGE_OFFSET) {
+ deltaX += EDGE_OFFSET - screenWidth - this.x;
+ this.x = EDGE_OFFSET - screenWidth;
+ }
+ }
+
+ if (this.x >= 0 && this.x + objWidth / 2 > screenWidth / 2) {
+ this.x -= screenWidth - objWidth;
+ }
+ if (this.x < 0 && this.x + objWidth / 2 <= -screenWidth / 2) {
+ this.x += screenWidth - objWidth;
+ }
+ return deltaX;
+ }
+
+ public int moveY(int deltaY, int objHeight, ScaledResolution scaledResolution) {
+ int screenHeight = scaledResolution.getScaledHeight();
+ boolean wasPositiveY = this.y >= 0;
+ this.y += deltaY;
+
+ if (centerY) {
+ if (wasPositiveY) {
+ if (this.y > screenHeight / 2 - objHeight / 2) {
+ deltaY += screenHeight / 2 - objHeight / 2 - this.y;
+ this.y = screenHeight / 2 - objHeight / 2;
+ }
+ } else {
+ if (this.y < -screenHeight / 2 + objHeight / 2) {
+ deltaY += -screenHeight / 2 + objHeight / 2 - this.y;
+ this.y = -screenHeight / 2 + objHeight / 2;
+ }
+ }
+ return deltaY;
+ }
+
+ if (wasPositiveY) {
+ if (this.y < EDGE_OFFSET) {
+ deltaY += EDGE_OFFSET - this.y;
+ this.y = EDGE_OFFSET;
+ }
+ if (this.y > screenHeight - EDGE_OFFSET) {
+ deltaY += screenHeight - EDGE_OFFSET - this.y;
+ this.y = screenHeight - EDGE_OFFSET;
+ }
+ } else {
+ if (this.y + 1 > -EDGE_OFFSET) {
+ deltaY += -EDGE_OFFSET - 1 - this.y;
+ this.y = -EDGE_OFFSET - 1;
+ }
+ if (this.y + screenHeight < EDGE_OFFSET) {
+ deltaY += EDGE_OFFSET - screenHeight - this.y;
+ this.y = EDGE_OFFSET - screenHeight;
+ }
+ }
+
+ if (this.y >= 0 && this.y - objHeight / 2 > screenHeight / 2) {
+ this.y -= screenHeight - objHeight;
+ }
+ if (this.y < 0 && this.y - objHeight / 2 <= -screenHeight / 2) {
+ this.y += screenHeight - objHeight;
+ }
+ return deltaY;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/PositionNew.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/PositionNew.java
index 842df73d..8f2b02d8 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/PositionNew.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/PositionNew.java
@@ -7,154 +7,186 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
public class PositionNew {
-
- public enum Anchor {
- MIN(0, 0, 0),
- MID(0.5f, -0.5f, 0),
- MAX(1f, -1f, 0),
- GUI_MIN(0.5f, -1f, -0.5f),
- GUI_MAX(0.5f, 0, 0.5f);
-
- float screenMult;
- float elementMult;
- float guiMult;
-
- Anchor(float screenMult, float elementMult, float guiMult) {
- this.screenMult = screenMult;
- this.elementMult = elementMult;
- this.guiMult = guiMult;
- }
- }
-
- @Expose
- private int x = 0;
- @Expose
- private int y = 0;
- @Expose
- private float scaleX = 1;
- @Expose
- private float scaleY = 1;
-
- @Expose
- private Anchor anchorX = Anchor.MIN;
- @Expose
- private Anchor anchorY = Anchor.MIN;
-
- @Expose
- private boolean pinned = false;
- @Expose
- private boolean allowPinToggle = true;
- @Expose
- private boolean allowResize = true;
-
- public PositionNew(int x, int y, int scaleX, int scaleY, Anchor anchorX, Anchor anchorY, boolean pinned, boolean allowPinToggle, boolean allowResize) {
- this.x = x;
- this.y = y;
- this.scaleX = scaleX;
- this.scaleY = scaleY;
- this.anchorX = anchorX;
- this.anchorY = anchorY;
- this.pinned = pinned;
- this.allowPinToggle = allowPinToggle;
- this.allowResize = allowResize;
- }
-
- protected PositionNew() {
- }
-
- public int moveX(ScaledResolution scaledResolution, int deltaX, int sizeX) {
- int originalX = resolveX(scaledResolution, sizeX);
- AtomicInteger atomicInteger = new AtomicInteger(x+deltaX);
- AtomicReference<Anchor> atomicReference = new AtomicReference<>(anchorX);
- move(atomicInteger, atomicReference, anchorY, (int)Math.ceil(sizeX*scaleX), scaledResolution.getScaledWidth(), 176);
- x = atomicInteger.get();
- anchorX = atomicReference.get();
- return resolveX(scaledResolution, sizeX) - originalX;
- }
-
- public int moveY(ScaledResolution scaledResolution, int deltaY, int sizeY) {
- int originalY = resolveY(scaledResolution, sizeY);
- AtomicInteger atomicInteger = new AtomicInteger(y+deltaY);
- AtomicReference<Anchor> atomicReference = new AtomicReference<>(anchorY);
- move(atomicInteger, atomicReference, anchorY, (int)Math.ceil(sizeY*scaleY), scaledResolution.getScaledHeight(), 166);
- y = atomicInteger.get();
- anchorY = atomicReference.get();
- return resolveY(scaledResolution, sizeY) - originalY;
- }
-
- private void move(AtomicInteger coord, AtomicReference<Anchor> anchor, Anchor oppositeAnchor, int elementSize, int screenSize, int guiSize) {
- int centerCoord = resolve(coord.get(), anchor.get(), elementSize, screenSize, guiSize) + elementSize/2;
-
- if(centerCoord < screenSize/2-guiSize/2) {
- if(pinned && centerCoord > screenSize/4-guiSize/4 && oppositeAnchor == Anchor.MID) {
- anchor.set(Anchor.GUI_MIN);
- } else {
- anchor.set(Anchor.MIN);
- }
- } else if(centerCoord > screenSize/2+guiSize/2) {
- if(pinned && centerCoord < screenSize-(screenSize/4-guiSize/4) && oppositeAnchor == Anchor.MID) {
- anchor.set(Anchor.GUI_MAX);
- } else {
- anchor.set(Anchor.MAX);
- }
- } else {
- anchor.set(Anchor.MID);
- }
-
- if(centerCoord - elementSize/2 < 0) centerCoord = elementSize/2;
- if(centerCoord + elementSize/2 > screenSize) centerCoord = screenSize - elementSize/2;
-
- Anchor newAnchor = anchor.get();
- coord.set(Math.round(centerCoord - (elementSize*(newAnchor.elementMult+0.5f)) - screenSize*newAnchor.screenMult - guiSize*newAnchor.guiMult));
- }
-
- public int resolveX(ScaledResolution scaledResolution, int sizeX) {
- return resolve(x, anchorX, (int)Math.ceil(sizeX*scaleX), scaledResolution.getScaledWidth(), 176);
- }
-
- public int resolveY(ScaledResolution scaledResolution, int sizeY) {
- return resolve(y, anchorY, (int)Math.ceil(sizeY*scaleY), scaledResolution.getScaledHeight(), 166);
- }
-
- private int resolve(int coord, Anchor anchor, int elementSize, int screenSize, int guiSize) {
- return Math.round(screenSize*anchor.screenMult + elementSize*anchor.elementMult + guiSize*anchor.guiMult + coord);
- }
-
- public void setScaleX(float scaleX) {
- if(allowResize) {
- this.scaleX = scaleX;
- }
- }
-
- public void setScaleY(float scaleY) {
- if(allowResize) {
- this.scaleY = scaleY;
- }
- }
-
- public float getScaleX() {
- return scaleX;
- }
-
- public float getScaleY() {
- return scaleY;
- }
-
- public void setPinned(boolean pinned) {
- if(allowPinToggle) {
- this.pinned = pinned;
- }
- }
-
- public boolean isPinned() {
- return pinned;
- }
-
- public Anchor getAnchorX() {
- return anchorX;
- }
-
- public Anchor getAnchorY() {
- return anchorY;
- }
+ public enum Anchor {
+ MIN(0, 0, 0),
+ MID(0.5f, -0.5f, 0),
+ MAX(1f, -1f, 0),
+ GUI_MIN(0.5f, -1f, -0.5f),
+ GUI_MAX(0.5f, 0, 0.5f);
+
+ float screenMult;
+ float elementMult;
+ float guiMult;
+
+ Anchor(float screenMult, float elementMult, float guiMult) {
+ this.screenMult = screenMult;
+ this.elementMult = elementMult;
+ this.guiMult = guiMult;
+ }
+ }
+
+ @Expose
+ private int x = 0;
+ @Expose
+ private int y = 0;
+ @Expose
+ private float scaleX = 1;
+ @Expose
+ private float scaleY = 1;
+
+ @Expose
+ private Anchor anchorX = Anchor.MIN;
+ @Expose
+ private Anchor anchorY = Anchor.MIN;
+
+ @Expose
+ private boolean pinned = false;
+ @Expose
+ private boolean allowPinToggle = true;
+ @Expose
+ private boolean allowResize = true;
+
+ public PositionNew(
+ int x,
+ int y,
+ int scaleX,
+ int scaleY,
+ Anchor anchorX,
+ Anchor anchorY,
+ boolean pinned,
+ boolean allowPinToggle,
+ boolean allowResize
+ ) {
+ this.x = x;
+ this.y = y;
+ this.scaleX = scaleX;
+ this.scaleY = scaleY;
+ this.anchorX = anchorX;
+ this.anchorY = anchorY;
+ this.pinned = pinned;
+ this.allowPinToggle = allowPinToggle;
+ this.allowResize = allowResize;
+ }
+
+ protected PositionNew() {}
+
+ public int moveX(ScaledResolution scaledResolution, int deltaX, int sizeX) {
+ int originalX = resolveX(scaledResolution, sizeX);
+ AtomicInteger atomicInteger = new AtomicInteger(x + deltaX);
+ AtomicReference<Anchor> atomicReference = new AtomicReference<>(anchorX);
+ move(
+ atomicInteger,
+ atomicReference,
+ anchorY,
+ (int) Math.ceil(sizeX * scaleX),
+ scaledResolution.getScaledWidth(),
+ 176
+ );
+ x = atomicInteger.get();
+ anchorX = atomicReference.get();
+ return resolveX(scaledResolution, sizeX) - originalX;
+ }
+
+ public int moveY(ScaledResolution scaledResolution, int deltaY, int sizeY) {
+ int originalY = resolveY(scaledResolution, sizeY);
+ AtomicInteger atomicInteger = new AtomicInteger(y + deltaY);
+ AtomicReference<Anchor> atomicReference = new AtomicReference<>(anchorY);
+ move(
+ atomicInteger,
+ atomicReference,
+ anchorY,
+ (int) Math.ceil(sizeY * scaleY),
+ scaledResolution.getScaledHeight(),
+ 166
+ );
+ y = atomicInteger.get();
+ anchorY = atomicReference.get();
+ return resolveY(scaledResolution, sizeY) - originalY;
+ }
+
+ private void move(
+ AtomicInteger coord,
+ AtomicReference<Anchor> anchor,
+ Anchor oppositeAnchor,
+ int elementSize,
+ int screenSize,
+ int guiSize
+ ) {
+ int centerCoord = resolve(coord.get(), anchor.get(), elementSize, screenSize, guiSize) + elementSize / 2;
+
+ if (centerCoord < screenSize / 2 - guiSize / 2) {
+ if (pinned && centerCoord > screenSize / 4 - guiSize / 4 && oppositeAnchor == Anchor.MID) {
+ anchor.set(Anchor.GUI_MIN);
+ } else {
+ anchor.set(Anchor.MIN);
+ }
+ } else if (centerCoord > screenSize / 2 + guiSize / 2) {
+ if (pinned && centerCoord < screenSize - (screenSize / 4 - guiSize / 4) && oppositeAnchor == Anchor.MID) {
+ anchor.set(Anchor.GUI_MAX);
+ } else {
+ anchor.set(Anchor.MAX);
+ }
+ } else {
+ anchor.set(Anchor.MID);
+ }
+
+ if (centerCoord - elementSize / 2 < 0) centerCoord = elementSize / 2;
+ if (centerCoord + elementSize / 2 > screenSize) centerCoord = screenSize - elementSize / 2;
+
+ Anchor newAnchor = anchor.get();
+ coord.set(Math.round(
+ centerCoord - (elementSize * (newAnchor.elementMult + 0.5f)) - screenSize * newAnchor.screenMult -
+ guiSize * newAnchor.guiMult));
+ }
+
+ public int resolveX(ScaledResolution scaledResolution, int sizeX) {
+ return resolve(x, anchorX, (int) Math.ceil(sizeX * scaleX), scaledResolution.getScaledWidth(), 176);
+ }
+
+ public int resolveY(ScaledResolution scaledResolution, int sizeY) {
+ return resolve(y, anchorY, (int) Math.ceil(sizeY * scaleY), scaledResolution.getScaledHeight(), 166);
+ }
+
+ private int resolve(int coord, Anchor anchor, int elementSize, int screenSize, int guiSize) {
+ return Math.round(
+ screenSize * anchor.screenMult + elementSize * anchor.elementMult + guiSize * anchor.guiMult + coord);
+ }
+
+ public void setScaleX(float scaleX) {
+ if (allowResize) {
+ this.scaleX = scaleX;
+ }
+ }
+
+ public void setScaleY(float scaleY) {
+ if (allowResize) {
+ this.scaleY = scaleY;
+ }
+ }
+
+ public float getScaleX() {
+ return scaleX;
+ }
+
+ public float getScaleY() {
+ return scaleY;
+ }
+
+ public void setPinned(boolean pinned) {
+ if (allowPinToggle) {
+ this.pinned = pinned;
+ }
+ }
+
+ public boolean isPinned() {
+ return pinned;
+ }
+
+ public Anchor getAnchorX() {
+ return anchorX;
+ }
+
+ public Anchor getAnchorY() {
+ return anchorY;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/Category.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/Category.java
index 6a91cae5..b67d0383 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/Category.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/Category.java
@@ -8,8 +8,7 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface Category {
+ String name();
- String name();
- String desc();
-
+ String desc();
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigAccordionId.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigAccordionId.java
index 54d3e345..1c847851 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigAccordionId.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigAccordionId.java
@@ -8,7 +8,5 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface ConfigAccordionId {
-
- int id();
-
+ int id();
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorAccordion.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorAccordion.java
index 47948985..11b798f9 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorAccordion.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorAccordion.java
@@ -8,7 +8,5 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface ConfigEditorAccordion {
-
- int id();
-
+ int id();
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorBoolean.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorBoolean.java
index 3c6465e6..a0ca1f38 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorBoolean.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorBoolean.java
@@ -7,6 +7,4 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
-public @interface ConfigEditorBoolean {
-
-}
+public @interface ConfigEditorBoolean {}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorButton.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorButton.java
index 5fe7fcb4..455df65f 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorButton.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorButton.java
@@ -8,8 +8,7 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface ConfigEditorButton {
+ int runnableId();
- int runnableId();
- String buttonText() default "";
-
+ String buttonText() default "";
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorColour.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorColour.java
index d1dd5808..6640ade9 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorColour.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorColour.java
@@ -1,6 +1,5 @@
package io.github.moulberry.notenoughupdates.core.config.annotations;
-
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -8,6 +7,4 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
-public @interface ConfigEditorColour {
-
-}
+public @interface ConfigEditorColour {}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorDraggableList.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorDraggableList.java
index 8689bda8..e171e0ae 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorDraggableList.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorDraggableList.java
@@ -8,7 +8,5 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface ConfigEditorDraggableList {
-
- String[] exampleText();
-
+ String[] exampleText();
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorDropdown.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorDropdown.java
index d9d2235b..ac766e93 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorDropdown.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorDropdown.java
@@ -1,6 +1,5 @@
package io.github.moulberry.notenoughupdates.core.config.annotations;
-
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -9,8 +8,7 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface ConfigEditorDropdown {
+ String[] values();
- String[] values();
- int initialIndex() default 0;
-
+ int initialIndex() default 0;
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorFSR.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorFSR.java
new file mode 100644
index 00000000..217df0c5
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorFSR.java
@@ -0,0 +1,14 @@
+package io.github.moulberry.notenoughupdates.core.config.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.FIELD)
+public @interface ConfigEditorFSR {
+ int runnableId();
+
+ String buttonText() default "";
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorKeybind.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorKeybind.java
index 527171f2..8d8de2eb 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorKeybind.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorKeybind.java
@@ -8,7 +8,5 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface ConfigEditorKeybind {
-
- int defaultKey();
-
+ int defaultKey();
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorSlider.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorSlider.java
index d671f65c..abab37f9 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorSlider.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorSlider.java
@@ -1,6 +1,5 @@
package io.github.moulberry.notenoughupdates.core.config.annotations;
-
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -9,10 +8,9 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface ConfigEditorSlider {
+ float minValue();
- float minValue();
- float maxValue();
-
- float minStep();
+ float maxValue();
+ float minStep();
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorText.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorText.java
index 9227cf50..1ff7e39e 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorText.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorText.java
@@ -1,6 +1,5 @@
package io.github.moulberry.notenoughupdates.core.config.annotations;
-
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -8,6 +7,4 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
-public @interface ConfigEditorText {
-
-}
+public @interface ConfigEditorText {}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigOption.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigOption.java
index 63c3366a..2ee23dcf 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigOption.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigOption.java
@@ -1,6 +1,5 @@
package io.github.moulberry.notenoughupdates.core.config.annotations;
-
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -9,9 +8,9 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface ConfigOption {
+ String name();
- String name();
- String desc();
- int subcategoryId() default -1;
+ String desc();
+ int subcategoryId() default -1;
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditor.java
index e28c5a32..d62c7ec7 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditor.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditor.java
@@ -8,55 +8,56 @@ import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.GlStateManager;
public abstract class GuiOptionEditor {
+ protected final ConfigProcessor.ProcessedOption option;
+ private static final int HEIGHT = 45;
- protected final ConfigProcessor.ProcessedOption option;
- private static final int HEIGHT = 45;
+ public GuiOptionEditor(ConfigProcessor.ProcessedOption option) {
+ this.option = option;
+ }
- public GuiOptionEditor(ConfigProcessor.ProcessedOption option) {
- this.option = option;
- }
+ public void render(int x, int y, int width) {
+ int height = getHeight();
- public void render(int x, int y, int width) {
- int height = getHeight();
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+ RenderUtils.drawFloatingRectDark(x, y, width, height, true);
+ TextRenderUtils.drawStringCenteredScaledMaxWidth(option.name,
+ fr, x + width / 6, y + 13, true, width / 3 - 10, 0xc0c0c0
+ );
- FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
- RenderUtils.drawFloatingRectDark(x, y, width, height, true);
- TextRenderUtils.drawStringCenteredScaledMaxWidth(option.name,
- fr, x+width/6, y+13, true, width/3-10, 0xc0c0c0);
+ int maxLines = 5;
+ float scale = 1;
+ int lineCount = fr.listFormattedStringToWidth(option.desc, width * 2 / 3 - 10).size();
- int maxLines = 5;
- float scale = 1;
- int lineCount = fr.listFormattedStringToWidth(option.desc, width*2/3-10).size();
+ if (lineCount <= 0) return;
- if(lineCount <= 0) return;
+ float paraHeight = 9 * lineCount - 1;
- float paraHeight = 9 * lineCount - 1;
+ while (paraHeight >= HEIGHT - 10) {
+ scale -= 1 / 8f;
+ lineCount = fr.listFormattedStringToWidth(option.desc, (int) (width * 2 / 3 / scale - 10)).size();
+ paraHeight = (int) (9 * scale * lineCount - 1 * scale);
+ }
- while(paraHeight >= HEIGHT-10) {
- scale -= 1/8f;
- lineCount = fr.listFormattedStringToWidth(option.desc, (int)(width*2/3/scale-10)).size();
- paraHeight = (int)(9*scale * lineCount - 1*scale);
- }
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(x + 5 + width / 3f, y + HEIGHT / 2f - paraHeight / 2, 0);
+ GlStateManager.scale(scale, scale, 1);
- GlStateManager.pushMatrix();
- GlStateManager.translate(x+5+width/3f, y+HEIGHT/2f-paraHeight/2, 0);
- GlStateManager.scale(scale, scale, 1);
+ fr.drawSplitString(option.desc, 0, 0, (int) (width * 2 / 3 / scale - 10), 0xc0c0c0);
- fr.drawSplitString(option.desc, 0, 0, (int)(width*2/3/scale-10), 0xc0c0c0);
+ GlStateManager.popMatrix();
+ }
- GlStateManager.popMatrix();
- }
+ public int getHeight() {
+ return HEIGHT;
+ }
- public int getHeight() {
- return HEIGHT;
- }
+ public abstract boolean mouseInput(int x, int y, int width, int mouseX, int mouseY);
- public abstract boolean mouseInput(int x, int y, int width, int mouseX, int mouseY);
- public abstract boolean keyboardInput();
+ public abstract boolean keyboardInput();
- public boolean mouseInputOverlay(int x, int y, int width, int mouseX, int mouseY) {
- return false;
- }
- public void renderOverlay(int x, int y, int width) {};
+ public boolean mouseInputOverlay(int x, int y, int width, int mouseX, int mouseY) {
+ return false;
+ }
+ public void renderOverlay(int x, int y, int width) {}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorAccordion.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorAccordion.java
index 79667ff8..8877cd03 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorAccordion.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorAccordion.java
@@ -1,11 +1,9 @@
package io.github.moulberry.notenoughupdates.core.config.gui;
-import io.github.moulberry.notenoughupdates.core.config.Config;
import io.github.moulberry.notenoughupdates.core.config.struct.ConfigProcessor;
import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils;
import io.github.moulberry.notenoughupdates.core.util.render.TextRenderUtils;
import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
@@ -13,74 +11,72 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
-import static io.github.moulberry.notenoughupdates.util.GuiTextures.button_tex;
-
public class GuiOptionEditorAccordion extends GuiOptionEditor {
+ private final int accordionId;
+ private boolean accordionToggled;
- private int accordionId;
- private boolean accordionToggled;
-
- public GuiOptionEditorAccordion(ConfigProcessor.ProcessedOption option, int accordionId) {
- super(option);
- this.accordionToggled = (boolean) option.get();
- this.accordionId = accordionId;
- }
+ public GuiOptionEditorAccordion(ConfigProcessor.ProcessedOption option, int accordionId) {
+ super(option);
+ this.accordionToggled = (boolean) option.get();
+ this.accordionId = accordionId;
+ }
- @Override
- public int getHeight() {
- return 20;
- }
+ @Override
+ public int getHeight() {
+ return 20;
+ }
- public int getAccordionId() {
- return accordionId;
- }
+ public int getAccordionId() {
+ return accordionId;
+ }
- public boolean getToggled() {
- return accordionToggled;
- }
+ public boolean getToggled() {
+ return accordionToggled;
+ }
- @Override
- public void render(int x, int y, int width) {
- int height = getHeight();
- RenderUtils.drawFloatingRectDark(x, y, width, height, true);
+ @Override
+ public void render(int x, int y, int width) {
+ int height = getHeight();
+ RenderUtils.drawFloatingRectDark(x, y, width, height, true);
- Tessellator tessellator = Tessellator.getInstance();
- WorldRenderer worldrenderer = tessellator.getWorldRenderer();
- GlStateManager.enableBlend();
- GlStateManager.disableTexture2D();
- GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
- GlStateManager.color(1, 1, 1, 1);
- worldrenderer.begin(GL11.GL_TRIANGLES, DefaultVertexFormats.POSITION);
- if(accordionToggled) {
- worldrenderer.pos((double)x+6, (double)y+6, 0.0D).endVertex();
- worldrenderer.pos((double)x+9.75f, (double)y+13.5f, 0.0D).endVertex();
- worldrenderer.pos((double)x+13.5f, (double)y+6, 0.0D).endVertex();
- } else {
- worldrenderer.pos((double)x+6, (double)y+13.5f, 0.0D).endVertex();
- worldrenderer.pos((double)x+13.5f, (double)y+9.75f, 0.0D).endVertex();
- worldrenderer.pos((double)x+6, (double)y+6, 0.0D).endVertex();
- }
- tessellator.draw();
- GlStateManager.enableTexture2D();
- GlStateManager.disableBlend();
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+ GlStateManager.enableBlend();
+ GlStateManager.disableTexture2D();
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+ GlStateManager.color(1, 1, 1, 1);
+ worldrenderer.begin(GL11.GL_TRIANGLES, DefaultVertexFormats.POSITION);
+ if (accordionToggled) {
+ worldrenderer.pos((double) x + 6, (double) y + 6, 0.0D).endVertex();
+ worldrenderer.pos((double) x + 9.75f, (double) y + 13.5f, 0.0D).endVertex();
+ worldrenderer.pos((double) x + 13.5f, (double) y + 6, 0.0D).endVertex();
+ } else {
+ worldrenderer.pos((double) x + 6, (double) y + 13.5f, 0.0D).endVertex();
+ worldrenderer.pos((double) x + 13.5f, (double) y + 9.75f, 0.0D).endVertex();
+ worldrenderer.pos((double) x + 6, (double) y + 6, 0.0D).endVertex();
+ }
+ tessellator.draw();
+ GlStateManager.enableTexture2D();
+ GlStateManager.disableBlend();
- TextRenderUtils.drawStringScaledMaxWidth(option.name, Minecraft.getMinecraft().fontRendererObj,
- x+18, y+6, false, width-10, 0xc0c0c0);
- }
+ TextRenderUtils.drawStringScaledMaxWidth(option.name, Minecraft.getMinecraft().fontRendererObj,
+ x + 18, y + 6, false, width - 10, 0xc0c0c0
+ );
+ }
- @Override
- public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) {
- if(Mouse.getEventButtonState() && mouseX > x && mouseX < x+ width &&
- mouseY > y && mouseY < y+getHeight()) {
- accordionToggled = !accordionToggled;
- return true;
- }
+ @Override
+ public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) {
+ if (Mouse.getEventButtonState() && mouseX > x && mouseX < x + width &&
+ mouseY > y && mouseY < y + getHeight()) {
+ accordionToggled = !accordionToggled;
+ return true;
+ }
- return false;
- }
+ return false;
+ }
- @Override
- public boolean keyboardInput() {
- return false;
- }
+ @Override
+ public boolean keyboardInput() {
+ return false;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorBoolean.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorBoolean.java
index ba2c9be9..9e2c912a 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorBoolean.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorBoolean.java
@@ -4,35 +4,34 @@ import io.github.moulberry.notenoughupdates.core.GuiElementBoolean;
import io.github.moulberry.notenoughupdates.core.config.struct.ConfigProcessor;
public class GuiOptionEditorBoolean extends GuiOptionEditor {
-
- private final GuiElementBoolean bool;
-
- public GuiOptionEditorBoolean(ConfigProcessor.ProcessedOption option) {
- super(option);
-
- bool = new GuiElementBoolean(0, 0, (boolean)option.get(), 10, option::set);
- }
-
- @Override
- public void render(int x, int y, int width) {
- super.render(x, y, width);
- int height = getHeight();
-
- bool.x = x+width/6-24;
- bool.y = y+height-7-14;
- bool.render();
- }
-
- @Override
- public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) {
- int height = getHeight();
- bool.x = x+width/6-24;
- bool.y = y+height-7-14;
- return bool.mouseInput(mouseX, mouseY);
- }
-
- @Override
- public boolean keyboardInput() {
- return false;
- }
+ private final GuiElementBoolean bool;
+
+ public GuiOptionEditorBoolean(ConfigProcessor.ProcessedOption option) {
+ super(option);
+
+ bool = new GuiElementBoolean(0, 0, (boolean) option.get(), 10, option::set);
+ }
+
+ @Override
+ public void render(int x, int y, int width) {
+ super.render(x, y, width);
+ int height = getHeight();
+
+ bool.x = x + width / 6 - 24;
+ bool.y = y + height - 7 - 14;
+ bool.render();
+ }
+
+ @Override
+ public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) {
+ int height = getHeight();
+ bool.x = x + width / 6 - 24;
+ bool.y = y + height - 7 - 14;
+ return bool.mouseInput(mouseX, mouseY);
+ }
+
+ @Override
+ public boolean keyboardInput() {
+ return false;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorButton.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorButton.java
index 03a01ef2..76944efa 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorButton.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorButton.java
@@ -1,66 +1,68 @@
package io.github.moulberry.notenoughupdates.core.config.gui;
-import io.github.moulberry.notenoughupdates.core.ChromaColour;
import io.github.moulberry.notenoughupdates.core.config.Config;
import io.github.moulberry.notenoughupdates.core.config.struct.ConfigProcessor;
import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils;
import io.github.moulberry.notenoughupdates.core.util.render.TextRenderUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
-import net.minecraftforge.client.ClientCommandHandler;
import org.lwjgl.input.Mouse;
import static io.github.moulberry.notenoughupdates.util.GuiTextures.button_tex;
-import static io.github.moulberry.notenoughupdates.util.GuiTextures.button_white;
public class GuiOptionEditorButton extends GuiOptionEditor {
+ private final int runnableId;
+ private String buttonText;
+ private final Config config;
- private int runnableId;
- private String buttonText;
- private Config config;
+ public GuiOptionEditorButton(
+ ConfigProcessor.ProcessedOption option,
+ int runnableId,
+ String buttonText,
+ Config config
+ ) {
+ super(option);
+ this.runnableId = runnableId;
+ this.config = config;
- public GuiOptionEditorButton(ConfigProcessor.ProcessedOption option, int runnableId, String buttonText, Config config) {
- super(option);
- this.runnableId = runnableId;
- this.config = config;
+ this.buttonText = buttonText;
+ if (this.buttonText != null && this.buttonText.isEmpty()) this.buttonText = null;
+ }
- this.buttonText = buttonText;
- if(this.buttonText != null && this.buttonText.isEmpty()) this.buttonText = null;
- }
+ @Override
+ public void render(int x, int y, int width) {
+ super.render(x, y, width);
- @Override
- public void render(int x, int y, int width) {
- super.render(x, y, width);
+ int height = getHeight();
- int height = getHeight();
+ GlStateManager.color(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(button_tex);
+ RenderUtils.drawTexturedRect(x + width / 6 - 24, y + height - 7 - 14, 48, 16);
- GlStateManager.color(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(button_tex);
- RenderUtils.drawTexturedRect(x+width/6-24, y+height-7-14, 48, 16);
+ if (buttonText != null) {
+ TextRenderUtils.drawStringCenteredScaledMaxWidth(buttonText, Minecraft.getMinecraft().fontRendererObj,
+ x + width / 6, y + height - 7 - 6,
+ false, 44, 0xFF303030
+ );
+ }
+ }
- if(buttonText != null) {
- TextRenderUtils.drawStringCenteredScaledMaxWidth(buttonText, Minecraft.getMinecraft().fontRendererObj,
- x+width/6, y+height-7-6,
- false, 44, 0xFF303030);
- }
- }
+ @Override
+ public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) {
+ if (Mouse.getEventButtonState()) {
+ int height = getHeight();
+ if (mouseX > x + width / 6 - 24 && mouseX < x + width / 6 + 24 &&
+ mouseY > y + height - 7 - 14 && mouseY < y + height - 7 + 2) {
+ config.executeRunnable(runnableId);
+ return true;
+ }
+ }
- @Override
- public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) {
- if(Mouse.getEventButtonState()) {
- int height = getHeight();
- if(mouseX > x+width/6-24 && mouseX < x+width/6+24 &&
- mouseY > y+height-7-14 && mouseY < y+height-7+2) {
- config.executeRunnable(runnableId);
- return true;
- }
- }
+ return false;
+ }
- return false;
- }
-
- @Override
- public boolean keyboardInput() {
- return false;
- }
+ @Override
+ public boolean keyboardInput() {
+ return false;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorColour.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorColour.java
index d9e8f5a9..80d2af42 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorColour.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorColour.java
@@ -1,81 +1,69 @@
package io.github.moulberry.notenoughupdates.core.config.gui;
import io.github.moulberry.notenoughupdates.core.ChromaColour;
-import io.github.moulberry.notenoughupdates.core.GlScissorStack;
-import io.github.moulberry.notenoughupdates.core.GuiElementBoolean;
import io.github.moulberry.notenoughupdates.core.GuiElementColour;
import io.github.moulberry.notenoughupdates.core.config.struct.ConfigProcessor;
import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import org.lwjgl.input.Mouse;
-import org.lwjgl.opengl.GL11;
-import static io.github.moulberry.notenoughupdates.util.GuiTextures.*;
+import static io.github.moulberry.notenoughupdates.util.GuiTextures.button_white;
public class GuiOptionEditorColour extends GuiOptionEditor {
-
- private String chromaColour;
- private GuiElementColour colourElement = null;
-
- public GuiOptionEditorColour(ConfigProcessor.ProcessedOption option) {
- super(option);
-
- this.chromaColour = (String)option.get();
- }
-
- @Override
- public void render(int x, int y, int width) {
- super.render(x, y, width);
- int height = getHeight();
-
- int argb = ChromaColour.specialToChromaRGB(chromaColour);
- int r = (argb >> 16) & 0xFF;
- int g = (argb >> 8) & 0xFF;
- int b = argb & 0xFF;
- GlStateManager.color(r/255f, g/255f, b/255f, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(button_white);
- RenderUtils.drawTexturedRect(x+width/6-24, y+height-7-14, 48, 16);
- }
-
- @Override
- public void renderOverlay(int x, int y, int width) {
- if(colourElement != null) {
- colourElement.render();
- }
- }
-
- @Override
- public boolean mouseInputOverlay(int x, int y, int width, int mouseX, int mouseY) {
- if(colourElement != null && colourElement.mouseInput(mouseX, mouseY)) {
- return true;
- }
- return false;
- }
-
- @Override
- public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) {
- int height = getHeight();
-
- if(Mouse.getEventButtonState() && Mouse.getEventButton() == 0 &&
- mouseX > x+width/6-24 && mouseX < x+width/6+24 &&
- mouseY > y+height-7-14 && mouseY < y+height-7+2) {
- colourElement = new GuiElementColour(mouseX, mouseY, (String) option.get(), (val) -> {
- option.set(val);
- chromaColour = val;
- }, () -> colourElement = null);
- }
-
- return false;
- }
-
- @Override
- public boolean keyboardInput() {
- if(colourElement != null && colourElement.keyboardInput()) {
- return true;
- }
-
- return false;
- }
-
+ private String chromaColour;
+ private GuiElementColour colourElement = null;
+
+ public GuiOptionEditorColour(ConfigProcessor.ProcessedOption option) {
+ super(option);
+
+ this.chromaColour = (String) option.get();
+ }
+
+ @Override
+ public void render(int x, int y, int width) {
+ super.render(x, y, width);
+ int height = getHeight();
+
+ int argb = ChromaColour.specialToChromaRGB(chromaColour);
+ int r = (argb >> 16) & 0xFF;
+ int g = (argb >> 8) & 0xFF;
+ int b = argb & 0xFF;
+ GlStateManager.color(r / 255f, g / 255f, b / 255f, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(button_white);
+ RenderUtils.drawTexturedRect(x + width / 6 - 24, y + height - 7 - 14, 48, 16);
+ }
+
+ @Override
+ public void renderOverlay(int x, int y, int width) {
+ if (colourElement != null) {
+ colourElement.render();
+ }
+ }
+
+ @Override
+ public boolean mouseInputOverlay(int x, int y, int width, int mouseX, int mouseY) {
+ return colourElement != null && colourElement.mouseInput(mouseX, mouseY);
+ }
+
+ @Override
+ public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) {
+ int height = getHeight();
+
+ if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0 &&
+ mouseX > x + width / 6 - 24 && mouseX < x + width / 6 + 24 &&
+ mouseY > y + height - 7 - 14 && mouseY < y + height - 7 + 2) {
+ colourElement = new GuiElementColour(mouseX, mouseY, (String) option.get(), (val) -> {
+ option.set(val);
+ chromaColour = val;
+ }, () -> colourElement = null);
+ }
+
+ return false;
+ }
+
+ @Override
+ public boolean keyboardInput() {
+ return colourElement != null && colourElement.keyboardInput();
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDraggableList.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDraggableList.java
index 03c5bc6c..08a1024f 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDraggableList.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDraggableList.java
@@ -1,6 +1,5 @@
package io.github.moulberry.notenoughupdates.core.config.gui;
-import io.github.moulberry.notenoughupdates.core.config.Config;
import io.github.moulberry.notenoughupdates.core.config.struct.ConfigProcessor;
import io.github.moulberry.notenoughupdates.core.util.lerp.LerpUtils;
import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils;
@@ -13,7 +12,6 @@ import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
-import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
@@ -23,269 +21,292 @@ import java.util.List;
import static io.github.moulberry.notenoughupdates.util.GuiTextures.button_tex;
public class GuiOptionEditorDraggableList extends GuiOptionEditor {
-
- private static final ResourceLocation DELETE = new ResourceLocation("notenoughupdates:core/delete.png");
-
- private String[] exampleText;
- private List<Integer> activeText;
- private int currentDragging = -1;
- private int dragStartIndex = -1;
-
- private long trashHoverTime = -1;
-
- private int dragOffsetX = -1;
- private int dragOffsetY = -1;
-
- private boolean dropdownOpen = false;
-
- public GuiOptionEditorDraggableList(ConfigProcessor.ProcessedOption option, String[] exampleText) {
- super(option);
-
- this.exampleText = exampleText;
- this.activeText = (List<Integer>) option.get();
- }
-
- @Override
- public int getHeight() {
- int height = super.getHeight() + 13;
-
- for(int strIndex : activeText) {
- String str = exampleText[strIndex];
- height += 10 * str.split("\n").length;
- }
-
- return height;
- }
-
- @Override
- public void render(int x, int y, int width) {
- super.render(x, y, width);
-
- int height = getHeight();
-
- GlStateManager.color(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(button_tex);
- RenderUtils.drawTexturedRect(x+width/6-24, y+45-7-14, 48, 16);
-
- TextRenderUtils.drawStringCenteredScaledMaxWidth("Add", Minecraft.getMinecraft().fontRendererObj,
- x+width/6, y+45-7-6,
- false, 44, 0xFF303030);
-
- long currentTime = System.currentTimeMillis();
- if(trashHoverTime < 0) {
- float greenBlue = LerpUtils.clampZeroOne((currentTime + trashHoverTime)/250f);
- GlStateManager.color(1, greenBlue, greenBlue, 1);
- } else {
- float greenBlue = LerpUtils.clampZeroOne((250 + trashHoverTime - currentTime)/250f);
- GlStateManager.color(1, greenBlue, greenBlue, 1);
- }
- Minecraft.getMinecraft().getTextureManager().bindTexture(DELETE);
- Utils.drawTexturedRect(x+width/6+27, y+45-7-13, 11, 14, GL11.GL_NEAREST);
-
- Gui.drawRect(x+5, y+45, x+width-5, y+height-5, 0xffdddddd);
- Gui.drawRect(x+6, y+46, x+width-6, y+height-6, 0xff000000);
-
- int i = 0;
- int yOff=0;
- for(int strIndex : activeText) {
- String str = exampleText[strIndex];
-
- String[] multilines = str.split("\n");
-
- int ySize = multilines.length * 10;
-
- if(i++ != dragStartIndex) {
- for(int multilineIndex=0; multilineIndex<multilines.length; multilineIndex++) {
- String line = multilines[multilineIndex];
- Utils.drawStringScaledMaxWidth(line+EnumChatFormatting.RESET, Minecraft.getMinecraft().fontRendererObj,
- x+20, y+50+yOff+multilineIndex*10, true, width-20, 0xffffffff);
- }
- Minecraft.getMinecraft().fontRendererObj.drawString("\u2261", x+10, y+50+yOff + ySize/2 - 4, 0xffffff, true);
- }
-
- yOff += ySize;
- }
- }
-
- @Override
- public void renderOverlay(int x, int y, int width) {
- super.renderOverlay(x, y, width);
-
- if(dropdownOpen) {
- List<Integer> remaining = new ArrayList<>();
- for(int i=0; i<exampleText.length; i++) {
- remaining.add(i);
- }
- remaining.removeAll(activeText);
-
- FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
- int dropdownWidth = Math.min(width/2-10, 150);
- int left = dragOffsetX;
- int top = dragOffsetY;
-
- int dropdownHeight = -1 + 12*remaining.size();
-
- int main = 0xff202026;
- int outline = 0xff404046;
- Gui.drawRect(left, top, left+1, top+dropdownHeight, outline); //Left
- Gui.drawRect(left+1, top, left+dropdownWidth, top+1, outline); //Top
- Gui.drawRect(left+dropdownWidth-1, top+1, left+dropdownWidth, top+dropdownHeight, outline); //Right
- Gui.drawRect(left+1, top+dropdownHeight-1, left+dropdownWidth-1, top+dropdownHeight, outline); //Bottom
- Gui.drawRect(left+1, top+1, left+dropdownWidth-1, top+dropdownHeight-1, main); //Middle
-
- int dropdownY = -1;
- for(int strIndex : remaining) {
- String str = exampleText[strIndex];
- if(str.isEmpty()) {
- str = "<NONE>";
- }
- TextRenderUtils.drawStringScaledMaxWidth(str.replaceAll("(\n.*)+", " ..."),
- fr, left+3, top+3+dropdownY, false, dropdownWidth-6, 0xffa0a0a0);
- dropdownY += 12;
- }
- } else if(currentDragging >= 0) {
- int opacity = 0x80;
- long currentTime = System.currentTimeMillis();
- if(trashHoverTime < 0) {
- float greenBlue = LerpUtils.clampZeroOne((currentTime + trashHoverTime)/250f);
- opacity = (int)(opacity * greenBlue);
- } else {
- float greenBlue = LerpUtils.clampZeroOne((250 + trashHoverTime - currentTime)/250f);
- opacity = (int)(opacity * greenBlue);
- }
-
- if(opacity < 20) return;
-
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- int mouseX = Mouse.getX() * scaledResolution.getScaledWidth() / Minecraft.getMinecraft().displayWidth;
- int mouseY = scaledResolution.getScaledHeight() - Mouse.getY() * scaledResolution.getScaledHeight() / Minecraft.getMinecraft().displayHeight - 1;
-
- String str = exampleText[currentDragging];
-
- String[] multilines = str.split("\n");
-
- GlStateManager.enableBlend();
- for(int multilineIndex=0; multilineIndex<multilines.length; multilineIndex++) {
- String line = multilines[multilineIndex];
- Utils.drawStringScaledMaxWidth(line+EnumChatFormatting.RESET, Minecraft.getMinecraft().fontRendererObj,
- dragOffsetX + mouseX + 10, dragOffsetY + mouseY + multilineIndex*10, true, width-20, 0xffffff | (opacity << 24));
- }
-
- int ySize = multilines.length * 10;
-
- Minecraft.getMinecraft().fontRendererObj.drawString("\u2261",
- dragOffsetX + mouseX,
- dragOffsetY + mouseY + ySize/2 - 4, 0xffffff, true);
- }
- }
-
- @Override
- public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) {
- if(!Mouse.getEventButtonState() && !dropdownOpen &&
- dragStartIndex >= 0 && Mouse.getEventButton() == 0 &&
- mouseX >= x+width/6+27-3 && mouseX <= x+width/6+27+11+3 &&
- mouseY >= y+45-7-13-3 && mouseY <= y+45-7-13+14+3) {
- activeText.remove(dragStartIndex);
- currentDragging = -1;
- dragStartIndex = -1;
- return false;
- }
-
- if(!Mouse.isButtonDown(0) || dropdownOpen) {
- currentDragging = -1;
- dragStartIndex = -1;
- if(trashHoverTime > 0) trashHoverTime = -System.currentTimeMillis();
- } else if(currentDragging >= 0 &&
- mouseX >= x+width/6+27-3 && mouseX <= x+width/6+27+11+3 &&
- mouseY >= y+45-7-13-3 && mouseY <= y+45-7-13+14+3) {
- if(trashHoverTime < 0) trashHoverTime = System.currentTimeMillis();
- } else {
- if(trashHoverTime > 0) trashHoverTime = -System.currentTimeMillis();
- }
-
- if(Mouse.getEventButtonState()) {
- int height = getHeight();
-
- if(dropdownOpen) {
- List<Integer> remaining = new ArrayList<>();
- for(int i=0; i<exampleText.length; i++) {
- remaining.add(i);
- }
- remaining.removeAll(activeText);
-
- int dropdownWidth = Math.min(width/2-10, 150);
- int left = dragOffsetX;
- int top = dragOffsetY;
-
- int dropdownHeight = -1 + 12*remaining.size();
-
- if(mouseX > left && mouseX < left+dropdownWidth &&
- mouseY > top && mouseY < top + dropdownHeight) {
- int dropdownY = -1;
- for(int strIndex : remaining) {
- if(mouseY < top+dropdownY+12) {
- activeText.add(0, strIndex);
- if(remaining.size() == 1) dropdownOpen = false;
- return true;
- }
-
- dropdownY += 12;
- }
- }
-
- dropdownOpen = false;
- return true;
- }
-
- if(activeText.size() < exampleText.length &&
- mouseX > x+width/6-24 && mouseX < x+width/6+24 &&
- mouseY > y+45-7-14 && mouseY < y+45-7+2) {
- dropdownOpen = !dropdownOpen;
- dragOffsetX = mouseX;
- dragOffsetY = mouseY;
- return true;
- }
-
- if(Mouse.getEventButton() == 0 &&
- mouseX > x+5 && mouseX < x+width-5 &&
- mouseY > y+45 && mouseY < y+height-6) {
- int yOff=0;
- int i = 0;
- for(int strIndex : activeText) {
- int ySize = 10 * exampleText[strIndex].split("\n").length;
- if(mouseY < y+50+yOff+ySize) {
- dragOffsetX = x+10 - mouseX;
- dragOffsetY = y+50+yOff - mouseY;
-
- currentDragging = strIndex;
- dragStartIndex = i;
- break;
- }
- yOff += ySize;
- i++;
- }
- }
- } else if(Mouse.getEventButton() == -1 && currentDragging >= 0) {
- int yOff=0;
- int i = 0;
- for(int strIndex : activeText) {
- if(dragOffsetY + mouseY + 4 < y+50+yOff+10) {
- activeText.remove(dragStartIndex);
- activeText.add(i, currentDragging);
-
- dragStartIndex = i;
- break;
- }
- yOff += 10 * exampleText[strIndex].split("\n").length;
- i++;
- }
- }
-
- return false;
- }
-
- @Override
- public boolean keyboardInput() {
- return false;
- }
+ private static final ResourceLocation DELETE = new ResourceLocation("notenoughupdates:core/delete.png");
+
+ private final String[] exampleText;
+ private final List<Integer> activeText;
+ private int currentDragging = -1;
+ private int dragStartIndex = -1;
+
+ private long trashHoverTime = -1;
+
+ private int dragOffsetX = -1;
+ private int dragOffsetY = -1;
+
+ private boolean dropdownOpen = false;
+
+ public GuiOptionEditorDraggableList(ConfigProcessor.ProcessedOption option, String[] exampleText) {
+ super(option);
+
+ this.exampleText = exampleText;
+ this.activeText = (List<Integer>) option.get();
+ }
+
+ @Override
+ public int getHeight() {
+ int height = super.getHeight() + 13;
+
+ for (int strIndex : activeText) {
+ String str = exampleText[strIndex];
+ height += 10 * str.split("\n").length;
+ }
+
+ return height;
+ }
+
+ @Override
+ public void render(int x, int y, int width) {
+ super.render(x, y, width);
+
+ int height = getHeight();
+
+ GlStateManager.color(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(button_tex);
+ RenderUtils.drawTexturedRect(x + width / 6 - 24, y + 45 - 7 - 14, 48, 16);
+
+ TextRenderUtils.drawStringCenteredScaledMaxWidth("Add", Minecraft.getMinecraft().fontRendererObj,
+ x + width / 6, y + 45 - 7 - 6,
+ false, 44, 0xFF303030
+ );
+
+ long currentTime = System.currentTimeMillis();
+ if (trashHoverTime < 0) {
+ float greenBlue = LerpUtils.clampZeroOne((currentTime + trashHoverTime) / 250f);
+ GlStateManager.color(1, greenBlue, greenBlue, 1);
+ } else {
+ float greenBlue = LerpUtils.clampZeroOne((250 + trashHoverTime - currentTime) / 250f);
+ GlStateManager.color(1, greenBlue, greenBlue, 1);
+ }
+ Minecraft.getMinecraft().getTextureManager().bindTexture(DELETE);
+ Utils.drawTexturedRect(x + width / 6 + 27, y + 45 - 7 - 13, 11, 14, GL11.GL_NEAREST);
+
+ Gui.drawRect(x + 5, y + 45, x + width - 5, y + height - 5, 0xffdddddd);
+ Gui.drawRect(x + 6, y + 46, x + width - 6, y + height - 6, 0xff000000);
+
+ int i = 0;
+ int yOff = 0;
+ for (int strIndex : activeText) {
+ String str = exampleText[strIndex];
+
+ String[] multilines = str.split("\n");
+
+ int ySize = multilines.length * 10;
+
+ if (i++ != dragStartIndex) {
+ for (int multilineIndex = 0; multilineIndex < multilines.length; multilineIndex++) {
+ String line = multilines[multilineIndex];
+ Utils.drawStringScaledMaxWidth(line + EnumChatFormatting.RESET, Minecraft.getMinecraft().fontRendererObj,
+ x + 20, y + 50 + yOff + multilineIndex * 10, true, width - 20, 0xffffffff
+ );
+ }
+ Minecraft.getMinecraft().fontRendererObj.drawString(
+ "\u2261",
+ x + 10,
+ y + 50 + yOff + ySize / 2 - 4,
+ 0xffffff,
+ true
+ );
+ }
+
+ yOff += ySize;
+ }
+ }
+
+ @Override
+ public void renderOverlay(int x, int y, int width) {
+ super.renderOverlay(x, y, width);
+
+ if (dropdownOpen) {
+ List<Integer> remaining = new ArrayList<>();
+ for (int i = 0; i < exampleText.length; i++) {
+ remaining.add(i);
+ }
+ remaining.removeAll(activeText);
+
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+ int dropdownWidth = Math.min(width / 2 - 10, 150);
+ int left = dragOffsetX;
+ int top = dragOffsetY;
+
+ int dropdownHeight = -1 + 12 * remaining.size();
+
+ int main = 0xff202026;
+ int outline = 0xff404046;
+ Gui.drawRect(left, top, left + 1, top + dropdownHeight, outline); //Left
+ Gui.drawRect(left + 1, top, left + dropdownWidth, top + 1, outline); //Top
+ Gui.drawRect(left + dropdownWidth - 1, top + 1, left + dropdownWidth, top + dropdownHeight, outline); //Right
+ Gui.drawRect(
+ left + 1,
+ top + dropdownHeight - 1,
+ left + dropdownWidth - 1,
+ top + dropdownHeight,
+ outline
+ ); //Bottom
+ Gui.drawRect(left + 1, top + 1, left + dropdownWidth - 1, top + dropdownHeight - 1, main); //Middle
+
+ int dropdownY = -1;
+ for (int strIndex : remaining) {
+ String str = exampleText[strIndex];
+ if (str.isEmpty()) {
+ str = "<NONE>";
+ }
+ TextRenderUtils.drawStringScaledMaxWidth(str.replaceAll("(\n.*)+", " ..."),
+ fr, left + 3, top + 3 + dropdownY, false, dropdownWidth - 6, 0xffa0a0a0
+ );
+ dropdownY += 12;
+ }
+ } else if (currentDragging >= 0) {
+ int opacity = 0x80;
+ long currentTime = System.currentTimeMillis();
+ if (trashHoverTime < 0) {
+ float greenBlue = LerpUtils.clampZeroOne((currentTime + trashHoverTime) / 250f);
+ opacity = (int) (opacity * greenBlue);
+ } else {
+ float greenBlue = LerpUtils.clampZeroOne((250 + trashHoverTime - currentTime) / 250f);
+ opacity = (int) (opacity * greenBlue);
+ }
+
+ if (opacity < 20) return;
+
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ int mouseX = Mouse.getX() * scaledResolution.getScaledWidth() / Minecraft.getMinecraft().displayWidth;
+ int mouseY = scaledResolution.getScaledHeight() -
+ Mouse.getY() * scaledResolution.getScaledHeight() / Minecraft.getMinecraft().displayHeight - 1;
+
+ String str = exampleText[currentDragging];
+
+ String[] multilines = str.split("\n");
+
+ GlStateManager.enableBlend();
+ for (int multilineIndex = 0; multilineIndex < multilines.length; multilineIndex++) {
+ String line = multilines[multilineIndex];
+ Utils.drawStringScaledMaxWidth(
+ line + EnumChatFormatting.RESET,
+ Minecraft.getMinecraft().fontRendererObj,
+ dragOffsetX + mouseX + 10,
+ dragOffsetY + mouseY + multilineIndex * 10,
+ true,
+ width - 20,
+ 0xffffff | (opacity << 24)
+ );
+ }
+
+ int ySize = multilines.length * 10;
+
+ Minecraft.getMinecraft().fontRendererObj.drawString("\u2261",
+ dragOffsetX + mouseX,
+ dragOffsetY + mouseY + ySize / 2 - 4, 0xffffff, true
+ );
+ }
+ }
+
+ @Override
+ public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) {
+ if (!Mouse.getEventButtonState() && !dropdownOpen &&
+ dragStartIndex >= 0 && Mouse.getEventButton() == 0 &&
+ mouseX >= x + width / 6 + 27 - 3 && mouseX <= x + width / 6 + 27 + 11 + 3 &&
+ mouseY >= y + 45 - 7 - 13 - 3 && mouseY <= y + 45 - 7 - 13 + 14 + 3) {
+ activeText.remove(dragStartIndex);
+ currentDragging = -1;
+ dragStartIndex = -1;
+ return false;
+ }
+
+ if (!Mouse.isButtonDown(0) || dropdownOpen) {
+ currentDragging = -1;
+ dragStartIndex = -1;
+ if (trashHoverTime > 0) trashHoverTime = -System.currentTimeMillis();
+ } else if (currentDragging >= 0 &&
+ mouseX >= x + width / 6 + 27 - 3 && mouseX <= x + width / 6 + 27 + 11 + 3 &&
+ mouseY >= y + 45 - 7 - 13 - 3 && mouseY <= y + 45 - 7 - 13 + 14 + 3) {
+ if (trashHoverTime < 0) trashHoverTime = System.currentTimeMillis();
+ } else {
+ if (trashHoverTime > 0) trashHoverTime = -System.currentTimeMillis();
+ }
+
+ if (Mouse.getEventButtonState()) {
+ int height = getHeight();
+
+ if (dropdownOpen) {
+ List<Integer> remaining = new ArrayList<>();
+ for (int i = 0; i < exampleText.length; i++) {
+ remaining.add(i);
+ }
+ remaining.removeAll(activeText);
+
+ int dropdownWidth = Math.min(width / 2 - 10, 150);
+ int left = dragOffsetX;
+ int top = dragOffsetY;
+
+ int dropdownHeight = -1 + 12 * remaining.size();
+
+ if (mouseX > left && mouseX < left + dropdownWidth &&
+ mouseY > top && mouseY < top + dropdownHeight) {
+ int dropdownY = -1;
+ for (int strIndex : remaining) {
+ if (mouseY < top + dropdownY + 12) {
+ activeText.add(0, strIndex);
+ if (remaining.size() == 1) dropdownOpen = false;
+ return true;
+ }
+
+ dropdownY += 12;
+ }
+ }
+
+ dropdownOpen = false;
+ return true;
+ }
+
+ if (activeText.size() < exampleText.length &&
+ mouseX > x + width / 6 - 24 && mouseX < x + width / 6 + 24 &&
+ mouseY > y + 45 - 7 - 14 && mouseY < y + 45 - 7 + 2) {
+ dropdownOpen = !dropdownOpen;
+ dragOffsetX = mouseX;
+ dragOffsetY = mouseY;
+ return true;
+ }
+
+ if (Mouse.getEventButton() == 0 &&
+ mouseX > x + 5 && mouseX < x + width - 5 &&
+ mouseY > y + 45 && mouseY < y + height - 6) {
+ int yOff = 0;
+ int i = 0;
+ for (int strIndex : activeText) {
+ int ySize = 10 * exampleText[strIndex].split("\n").length;
+ if (mouseY < y + 50 + yOff + ySize) {
+ dragOffsetX = x + 10 - mouseX;
+ dragOffsetY = y + 50 + yOff - mouseY;
+
+ currentDragging = strIndex;
+ dragStartIndex = i;
+ break;
+ }
+ yOff += ySize;
+ i++;
+ }
+ }
+ } else if (Mouse.getEventButton() == -1 && currentDragging >= 0) {
+ int yOff = 0;
+ int i = 0;
+ for (int strIndex : activeText) {
+ if (dragOffsetY + mouseY + 4 < y + 50 + yOff + 10) {
+ activeText.remove(dragStartIndex);
+ activeText.add(i, currentDragging);
+
+ dragStartIndex = i;
+ break;
+ }
+ yOff += 10 * exampleText[strIndex].split("\n").length;
+ i++;
+ }
+ }
+
+ return false;
+ }
+
+ @Override
+ public boolean keyboardInput() {
+ return false;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDropdown.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDropdown.java
index 0451b459..a17737e3 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDropdown.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDropdown.java
@@ -11,142 +11,173 @@ import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
public class GuiOptionEditorDropdown extends GuiOptionEditor {
-
- private final String[] values;
- private final boolean useOrdinal;
- private int selected;
- private boolean open = false;
-
- public GuiOptionEditorDropdown(ConfigProcessor.ProcessedOption option, String[] values, int selected, boolean useOrdinal) {
- super(option);
- if(selected >= values.length) selected = values.length;
- this.values = values;
- this.selected = selected;
- this.useOrdinal = useOrdinal;
- }
-
- @Override
- public void render(int x, int y, int width) {
- super.render(x, y, width);
-
- if(!open) {
- int height = getHeight();
-
- FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
- int dropdownWidth = Math.min(width/3-10, 80);
- int left = x+width/6-dropdownWidth/2;
- int top = y+height-7-14;
-
- String selectedString = " - Select - ";
- if(selected >= 0 && selected < values.length) {
- selectedString = values[selected];
- }
-
- RenderUtils.drawFloatingRectDark(left, top, dropdownWidth, 14, false);
- TextRenderUtils.drawStringScaled("\u25BC", fr, left+dropdownWidth-10, y+height-7-15, false, 0xffa0a0a0, 2);
-
- TextRenderUtils.drawStringScaledMaxWidth(selectedString, fr, left+3, top+3, false,
- dropdownWidth-16, 0xffa0a0a0);
- }
- }
-
- @Override
- public void renderOverlay(int x, int y, int width) {
- if(open) {
- String selectedString = " - Select - ";
- if(selected >= 0 && selected < values.length) {
- selectedString = values[selected];
- }
-
- int height = getHeight();
-
- FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
- int dropdownWidth = Math.min(width/3-10, 80);
- int left = x+width/6-dropdownWidth/2;
- int top = y+height-7-14;
-
- int dropdownHeight = 13 + 12*values.length;
-
- int main = 0xff202026;
- int blue = 0xff2355ad;
- Gui.drawRect(left, top, left+1, top+dropdownHeight, blue); //Left
- Gui.drawRect(left+1, top, left+dropdownWidth, top+1, blue); //Top
- Gui.drawRect(left+dropdownWidth-1, top+1, left+dropdownWidth, top+dropdownHeight, blue); //Right
- Gui.drawRect(left+1, top+dropdownHeight-1, left+dropdownWidth-1, top+dropdownHeight, blue); //Bottom
- Gui.drawRect(left+1, top+1, left+dropdownWidth-1, top+dropdownHeight-1, main); //Middle
-
- Gui.drawRect(left+1, top+14-1, left+dropdownWidth-1, top+14, blue); //Bar
-
- int dropdownY = 13;
- for(String option : values) {
- if(option.isEmpty()) {
- option = "<NONE>";
- }
- TextRenderUtils.drawStringScaledMaxWidth(option, fr, left+3, top+3+dropdownY, false, dropdownWidth-6, 0xffa0a0a0);
- dropdownY += 12;
- }
-
- TextRenderUtils.drawStringScaled("\u25B2", fr, left+dropdownWidth-10, y+height-7-15, false, 0xffa0a0a0, 2);
-
-
- TextRenderUtils.drawStringScaledMaxWidth(selectedString, fr, left+3, top+3, false,
- dropdownWidth-16, 0xffa0a0a0);
- }
- }
-
- @Override
- public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) {
- int height = getHeight();
-
- int left = x+width/6-40;
- int top = y+height-7-14;
-
- if(Mouse.getEventButtonState() && Mouse.getEventButton() == 0) {
- if(mouseX >= left && mouseX <= left+80 &&
- mouseY >= top && mouseY <= top+14) {
- open = !open;
- return true;
- }
- }
-
- return false;
- }
-
- @Override
- public boolean mouseInputOverlay(int x, int y, int width, int mouseX, int mouseY) {
- int height = getHeight();
-
- int left = x+width/6-40;
- int top = y+height-7-14;
-
- if(Mouse.getEventButtonState() && Mouse.getEventButton() == 0) {
- if(!(mouseX >= left && mouseX <= left+80 &&
- mouseY >= top && mouseY <= top+14) && open) {
- open = false;
- if(mouseX >= left && mouseX <= left+80) {
- int dropdownY = 13;
- for(int ordinal=0; ordinal < values.length; ordinal++) {
- if(mouseY >= top+3+dropdownY && mouseY <= top+3+dropdownY+12) {
- selected = ordinal;
- if(useOrdinal) {
- option.set(selected);
- } else {
- option.set(values[selected]);
- }
- return true;
- }
- dropdownY += 12;
- }
- }
- return true;
- }
- }
-
- return false;
- }
-
- @Override
- public boolean keyboardInput() {
- return false;
- }
+ private final String[] values;
+ private final boolean useOrdinal;
+ private int selected;
+ private boolean open = false;
+
+ public GuiOptionEditorDropdown(
+ ConfigProcessor.ProcessedOption option,
+ String[] values,
+ int selected,
+ boolean useOrdinal
+ ) {
+ super(option);
+ if (selected >= values.length) selected = values.length;
+ this.values = values;
+ this.selected = selected;
+ this.useOrdinal = useOrdinal;
+ }
+
+ @Override
+ public void render(int x, int y, int width) {
+ super.render(x, y, width);
+ if (!open) {
+ int height = getHeight();
+
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+ int dropdownWidth = Math.min(width / 3 - 10, 80);
+ int left = x + width / 6 - dropdownWidth / 2;
+ int top = y + height - 7 - 14;
+
+ String selectedString = " - Select - ";
+ if (selected >= 0 && selected < values.length) {
+ selectedString = values[selected];
+ }
+
+ RenderUtils.drawFloatingRectDark(left, top, dropdownWidth, 14, false);
+ TextRenderUtils.drawStringScaled(
+ "\u25BC",
+ fr,
+ left + dropdownWidth - 10,
+ y + height - 7 - 15,
+ false,
+ 0xffa0a0a0,
+ 2
+ );
+
+ TextRenderUtils.drawStringScaledMaxWidth(selectedString, fr, left + 3, top + 3, false,
+ dropdownWidth - 16, 0xffa0a0a0
+ );
+ }
+ }
+
+ @Override
+ public void renderOverlay(int x, int y, int width) {
+ if (open) {
+ String selectedString = " - Select - ";
+ if (selected >= 0 && selected < values.length) {
+ selectedString = values[selected];
+ }
+
+ int height = getHeight();
+
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+ int dropdownWidth = Math.min(width / 3 - 10, 80);
+ int left = x + width / 6 - dropdownWidth / 2;
+ int top = y + height - 7 - 14;
+
+ int dropdownHeight = 13 + 12 * values.length;
+
+ int main = 0xff202026;
+ int blue = 0xff2355ad;
+
+ GlStateManager.pushMatrix();
+ GL11.glTranslated(0, 0, 100);
+ Gui.drawRect(left, top, left + 1, top + dropdownHeight, blue); //Left
+ Gui.drawRect(left + 1, top, left + dropdownWidth, top + 1, blue); //Top
+ Gui.drawRect(left + dropdownWidth - 1, top + 1, left + dropdownWidth, top + dropdownHeight, blue); //Right
+ Gui.drawRect(left + 1, top + dropdownHeight - 1, left + dropdownWidth - 1, top + dropdownHeight, blue); //Bottom
+ Gui.drawRect(left + 1, top + 1, left + dropdownWidth - 1, top + dropdownHeight - 1, main); //Middle
+
+ Gui.drawRect(left + 1, top + 14 - 1, left + dropdownWidth - 1, top + 14, blue); //Bar
+ int dropdownY = 13;
+ for (String option : values) {
+ if (option.isEmpty()) {
+ option = "<NONE>";
+ }
+ TextRenderUtils.drawStringScaledMaxWidth(
+ option,
+ fr,
+ left + 3,
+ top + 3 + dropdownY,
+ false,
+ dropdownWidth - 6,
+ 0xffa0a0a0
+ );
+ dropdownY += 12;
+ }
+
+ TextRenderUtils.drawStringScaled(
+ "\u25B2",
+ fr,
+ left + dropdownWidth - 10,
+ y + height - 7 - 15,
+ false,
+ 0xffa0a0a0,
+ 2
+ );
+
+ TextRenderUtils.drawStringScaledMaxWidth(selectedString, fr, left + 3, top + 3, false,
+ dropdownWidth - 16, 0xffa0a0a0
+ );
+ GlStateManager.popMatrix();
+ }
+ }
+
+ @Override
+ public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) {
+ int height = getHeight();
+
+ int left = x + width / 6 - 40;
+ int top = y + height - 7 - 14;
+
+ if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0) {
+ if (mouseX >= left && mouseX <= left + 80 &&
+ mouseY >= top && mouseY <= top + 14) {
+ open = !open;
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ @Override
+ public boolean mouseInputOverlay(int x, int y, int width, int mouseX, int mouseY) {
+ int height = getHeight();
+
+ int left = x + width / 6 - 40;
+ int top = y + height - 7 - 14;
+
+ if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0) {
+ if (!(mouseX >= left && mouseX <= left + 80 &&
+ mouseY >= top && mouseY <= top + 14) && open) {
+ open = false;
+ if (mouseX >= left && mouseX <= left + 80) {
+ int dropdownY = 13;
+ for (int ordinal = 0; ordinal < values.length; ordinal++) {
+ if (mouseY >= top + 3 + dropdownY && mouseY <= top + 3 + dropdownY + 12) {
+ selected = ordinal;
+ if (useOrdinal) {
+ option.set(selected);
+ } else {
+ option.set(values[selected]);
+ }
+ return true;
+ }
+ dropdownY += 12;
+ }
+ }
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ @Override
+ public boolean keyboardInput() {
+ return false;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorFSR.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorFSR.java
new file mode 100644
index 00000000..b443b5f6
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorFSR.java
@@ -0,0 +1,63 @@
+package io.github.moulberry.notenoughupdates.core.config.gui;
+
+import io.github.moulberry.notenoughupdates.core.config.Config;
+import io.github.moulberry.notenoughupdates.core.config.struct.ConfigProcessor;
+import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils;
+import io.github.moulberry.notenoughupdates.core.util.render.TextRenderUtils;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.renderer.GlStateManager;
+import org.lwjgl.input.Mouse;
+
+import static io.github.moulberry.notenoughupdates.util.GuiTextures.button_fsr;
+
+public class GuiOptionEditorFSR extends GuiOptionEditor {
+ private final int runnableId;
+ private String buttonText;
+ private final Config config;
+
+ public GuiOptionEditorFSR(ConfigProcessor.ProcessedOption option, int runnableId, String buttonText, Config config) {
+ super(option);
+ this.runnableId = runnableId;
+ this.config = config;
+
+ this.buttonText = buttonText;
+ if (this.buttonText != null && this.buttonText.isEmpty()) this.buttonText = null;
+ }
+
+ @Override
+ public void render(int x, int y, int width) {
+ super.render(x, y, width);
+
+ int height = getHeight();
+
+ GlStateManager.color(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(button_fsr);
+ RenderUtils.drawTexturedRect(x + width / 6 - 24, y + height - 7 - 14, 48, 16);
+
+ if (buttonText != null) {
+ TextRenderUtils.drawStringCenteredScaledMaxWidth(buttonText, Minecraft.getMinecraft().fontRendererObj,
+ x + width / 6, y + height - 7 - 6,
+ false, 44, 0xFF303030
+ );
+ }
+ }
+
+ @Override
+ public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) {
+ if (Mouse.getEventButtonState()) {
+ int height = getHeight();
+ if (mouseX > x + width / 6 - 24 && mouseX < x + width / 6 + 24 &&
+ mouseY > y + height - 7 - 14 && mouseY < y + height - 7 + 2) {
+ config.executeRunnable(runnableId);
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ @Override
+ public boolean keyboardInput() {
+ return false;
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorKeybind.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorKeybind.java
index 601cc6b1..5ff961a7 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorKeybind.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorKeybind.java
@@ -1,6 +1,5 @@
package io.github.moulberry.notenoughupdates.core.config.gui;
-import io.github.moulberry.notenoughupdates.core.config.Config;
import io.github.moulberry.notenoughupdates.core.config.KeybindHelper;
import io.github.moulberry.notenoughupdates.core.config.struct.ConfigProcessor;
import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils;
@@ -15,81 +14,81 @@ import org.lwjgl.opengl.GL11;
import static io.github.moulberry.notenoughupdates.util.GuiTextures.button_tex;
public class GuiOptionEditorKeybind extends GuiOptionEditor {
+ private static final ResourceLocation RESET = new ResourceLocation("notenoughupdates:itemcustomize/reset.png");
- private static final ResourceLocation RESET = new ResourceLocation("notenoughupdates:itemcustomize/reset.png");
+ private int keyCode;
+ private final int defaultKeyCode;
+ private boolean editingKeycode;
- private int keyCode;
- private int defaultKeyCode;
- private boolean editingKeycode;
+ public GuiOptionEditorKeybind(ConfigProcessor.ProcessedOption option, int keyCode, int defaultKeyCode) {
+ super(option);
+ this.keyCode = keyCode;
+ this.defaultKeyCode = defaultKeyCode;
+ }
- public GuiOptionEditorKeybind(ConfigProcessor.ProcessedOption option, int keyCode, int defaultKeyCode) {
- super(option);
- this.keyCode = keyCode;
- this.defaultKeyCode = defaultKeyCode;
- }
+ @Override
+ public void render(int x, int y, int width) {
+ super.render(x, y, width);
- @Override
- public void render(int x, int y, int width) {
- super.render(x, y, width);
+ int height = getHeight();
- int height = getHeight();
+ GlStateManager.color(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(button_tex);
+ RenderUtils.drawTexturedRect(x + width / 6 - 24, y + height - 7 - 14, 48, 16);
- GlStateManager.color(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(button_tex);
- RenderUtils.drawTexturedRect(x+width/6-24, y+height-7-14, 48, 16);
+ String keyName = KeybindHelper.getKeyName(keyCode);
+ String text = editingKeycode ? "> " + keyName + " <" : keyName;
+ TextRenderUtils.drawStringCenteredScaledMaxWidth(text,
+ Minecraft.getMinecraft().fontRendererObj,
+ x + width / 6, y + height - 7 - 6,
+ false, 40, 0xFF303030
+ );
- String keyName = KeybindHelper.getKeyName(keyCode);
- String text = editingKeycode ? "> "+keyName+" <" : keyName;
- TextRenderUtils.drawStringCenteredScaledMaxWidth(text,
- Minecraft.getMinecraft().fontRendererObj,
- x+width/6, y+height-7-6,
- false, 40, 0xFF303030);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(RESET);
+ GlStateManager.color(1, 1, 1, 1);
+ RenderUtils.drawTexturedRect(x + width / 6 - 24 + 48 + 3, y + height - 7 - 14 + 3, 10, 11, GL11.GL_NEAREST);
+ }
- Minecraft.getMinecraft().getTextureManager().bindTexture(RESET);
- GlStateManager.color(1, 1, 1, 1);
- RenderUtils.drawTexturedRect(x+width/6-24+48+3, y+height-7-14+3, 10, 11, GL11.GL_NEAREST);
- }
+ @Override
+ public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) {
+ if (Mouse.getEventButtonState() && Mouse.getEventButton() != -1 && editingKeycode) {
+ editingKeycode = false;
+ keyCode = Mouse.getEventButton() - 100;
+ option.set(keyCode);
+ return true;
+ }
- @Override
- public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) {
- if(Mouse.getEventButtonState() && Mouse.getEventButton() != -1 && editingKeycode) {
- editingKeycode = false;
- keyCode = Mouse.getEventButton()-100;
- option.set(keyCode);
- return true;
- }
+ if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0) {
+ int height = getHeight();
+ if (mouseX > x + width / 6 - 24 && mouseX < x + width / 6 + 24 &&
+ mouseY > y + height - 7 - 14 && mouseY < y + height - 7 + 2) {
+ editingKeycode = true;
+ return true;
+ }
+ if (mouseX > x + width / 6 - 24 + 48 + 3 && mouseX < x + width / 6 - 24 + 48 + 13 &&
+ mouseY > y + height - 7 - 14 + 3 && mouseY < y + height - 7 - 14 + 3 + 11) {
+ keyCode = defaultKeyCode;
+ option.set(keyCode);
+ return true;
+ }
+ }
- if(Mouse.getEventButtonState() && Mouse.getEventButton() == 0) {
- int height = getHeight();
- if(mouseX > x+width/6-24 && mouseX < x+width/6+24 &&
- mouseY > y+height-7-14 && mouseY < y+height-7+2) {
- editingKeycode = true;
- return true;
- }
- if(mouseX > x+width/6-24+48+3 && mouseX < x+width/6-24+48+13 &&
- mouseY > y+height-7-14+3 && mouseY < y+height-7-14+3+11) {
- keyCode = defaultKeyCode;
- option.set(keyCode);
- return true;
- }
- }
+ return false;
+ }
- return false;
- }
-
- @Override
- public boolean keyboardInput() {
- if(editingKeycode) {
- editingKeycode = false;
- if(Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
- keyCode = 0;
- } else if(Keyboard.getEventKey() != 0) {
- keyCode = Keyboard.getEventKey();
- }
- if(keyCode > 256) keyCode = 0;
- option.set(keyCode);
- return true;
- }
- return false;
- }
+ @Override
+ public boolean keyboardInput() {
+ if (editingKeycode) {
+ editingKeycode = false;
+ if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
+ keyCode = 0;
+ } else if (Keyboard.getEventKey() != 0) {
+ keyCode = Keyboard.getEventKey();
+ }
+ if (keyCode > 256) keyCode = 0;
+ option.set(keyCode);
+ return true;
+ }
+ return false;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorSlider.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorSlider.java
index a3665436..45ae70d9 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorSlider.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorSlider.java
@@ -1,6 +1,5 @@
package io.github.moulberry.notenoughupdates.core.config.gui;
-import io.github.moulberry.notenoughupdates.core.GuiElementBoolean;
import io.github.moulberry.notenoughupdates.core.GuiElementTextField;
import io.github.moulberry.notenoughupdates.core.config.struct.ConfigProcessor;
import io.github.moulberry.notenoughupdates.core.util.GuiElementSlider;
@@ -9,124 +8,126 @@ import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
public class GuiOptionEditorSlider extends GuiOptionEditor {
-
- private final GuiElementSlider slider;
- private final GuiElementTextField textField;
-
- public GuiOptionEditorSlider(ConfigProcessor.ProcessedOption option, float minValue, float maxValue, float minStep) {
- super(option);
- if(minStep < 0) minStep = 0.01f;
-
- float floatVal = ((Number)option.get()).floatValue();
- {
- String strVal;
- if(floatVal % 1 == 0) {
- strVal = Integer.toString((int)floatVal);
- } else {
- strVal = Float.toString(floatVal);
- }
- textField = new GuiElementTextField(strVal,
- GuiElementTextField.NO_SPACE | GuiElementTextField.NUM_ONLY | GuiElementTextField.SCALE_TEXT);
- }
-
- slider = new GuiElementSlider(0, 0, 80, minValue, maxValue, minStep, floatVal, (val) -> {
- option.set(val);
-
- String strVal;
- if(val % 1 == 0) {
- strVal = Integer.toString(val.intValue());
- } else {
- strVal = Float.toString(val);
- strVal = strVal.replaceAll("(\\.\\d\\d\\d)(?:\\d)+", "$1");
- strVal = strVal.replaceAll("0+$", "");
- }
- textField.setText(strVal);
- });
- }
-
- @Override
- public void render(int x, int y, int width) {
- super.render(x, y, width);
- int height = getHeight();
-
- int fullWidth = Math.min(width/3-10, 80);
- int sliderWidth = (fullWidth-5)*3/4;
- int textFieldWidth = (fullWidth-5)/4;
-
- slider.x = x+width/6-fullWidth/2;
- slider.y = y+height-7-14;
- slider.width = sliderWidth;
- slider.render();
-
- if(textField.getFocus()) {
- textField.setOptions(GuiElementTextField.NO_SPACE | GuiElementTextField.NUM_ONLY);
- textField.setSize(Minecraft.getMinecraft().fontRendererObj.getStringWidth(textField.getText())+10,
- 16);
- } else {
- textField.setSize(textFieldWidth, 16);
- textField.setOptions(GuiElementTextField.NO_SPACE | GuiElementTextField.NUM_ONLY | GuiElementTextField.SCALE_TEXT);
- }
-
- textField.render(x+width/6-fullWidth/2+sliderWidth+5, y+height-7-14);
- }
-
- @Override
- public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) {
- int height = getHeight();
-
- int fullWidth = Math.min(width/3-10, 80);
- int sliderWidth = (fullWidth-5)*3/4;
- int textFieldWidth = (fullWidth-5)/4;
-
- slider.x = x+width/6-fullWidth/2;
- slider.y = y+height-7-14;
- slider.width = sliderWidth;
- if(slider.mouseInput(mouseX, mouseY)) {
- textField.unfocus();
- return true;
- }
-
- if(textField.getFocus()) {
- textFieldWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(textField.getText())+10;
- }
-
- int textFieldX = x+width/6-fullWidth/2+sliderWidth+5;
- int textFieldY = y+height-7-14;
- textField.setSize(textFieldWidth, 16);
-
- if(Mouse.getEventButtonState() && (Mouse.getEventButton() == 0 || Mouse.getEventButton() == 1)) {
- if(mouseX > textFieldX && mouseX < textFieldX+textFieldWidth &&
- mouseY > textFieldY && mouseY < textFieldY+16) {
- textField.mouseClicked(mouseX, mouseY, Mouse.getEventButton());
- return true;
- }
- textField.unfocus();
- }
-
- return false;
- }
-
- @Override
- public boolean keyboardInput() {
- if(Keyboard.getEventKeyState() && textField.getFocus()) {
- textField.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey());
-
- try {
- textField.setCustomBorderColour(0xffffffff);
- float f = Float.parseFloat(textField.getText());
- if(option.set(f)) {
- slider.setValue(f);
- } else {
- textField.setCustomBorderColour(0xff0000ff);
- }
- } catch(Exception e) {
- textField.setCustomBorderColour(0xffff0000);
- }
-
- return true;
- }
- return false;
- }
-
-
+ private final GuiElementSlider slider;
+ private final GuiElementTextField textField;
+
+ public GuiOptionEditorSlider(ConfigProcessor.ProcessedOption option, float minValue, float maxValue, float minStep) {
+ super(option);
+ if (minStep < 0) minStep = 0.01f;
+
+ float floatVal = ((Number) option.get()).floatValue();
+ {
+ String strVal;
+ if (floatVal % 1 == 0) {
+ strVal = Integer.toString((int) floatVal);
+ } else {
+ strVal = Float.toString(floatVal);
+ }
+ textField = new GuiElementTextField(
+ strVal,
+ GuiElementTextField.NO_SPACE | GuiElementTextField.NUM_ONLY | GuiElementTextField.SCALE_TEXT
+ );
+ }
+
+ slider = new GuiElementSlider(0, 0, 80, minValue, maxValue, minStep, floatVal, (val) -> {
+ option.set(val);
+
+ String strVal;
+ if (val % 1 == 0) {
+ strVal = Integer.toString(val.intValue());
+ } else {
+ strVal = Float.toString(val);
+ strVal = strVal.replaceAll("(\\.\\d\\d\\d)(?:\\d)+", "$1");
+ strVal = strVal.replaceAll("0+$", "");
+ }
+ textField.setText(strVal);
+ });
+ }
+
+ @Override
+ public void render(int x, int y, int width) {
+ super.render(x, y, width);
+ int height = getHeight();
+
+ int fullWidth = Math.min(width / 3 - 10, 80);
+ int sliderWidth = (fullWidth - 5) * 3 / 4;
+ int textFieldWidth = (fullWidth - 5) / 4;
+
+ slider.x = x + width / 6 - fullWidth / 2;
+ slider.y = y + height - 7 - 14;
+ slider.width = sliderWidth;
+ slider.render();
+
+ if (textField.getFocus()) {
+ textField.setOptions(GuiElementTextField.NO_SPACE | GuiElementTextField.NUM_ONLY);
+ textField.setSize(
+ Minecraft.getMinecraft().fontRendererObj.getStringWidth(textField.getText()) + 10,
+ 16
+ );
+ } else {
+ textField.setSize(textFieldWidth, 16);
+ textField.setOptions(
+ GuiElementTextField.NO_SPACE | GuiElementTextField.NUM_ONLY | GuiElementTextField.SCALE_TEXT);
+ }
+
+ textField.render(x + width / 6 - fullWidth / 2 + sliderWidth + 5, y + height - 7 - 14);
+ }
+
+ @Override
+ public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) {
+ int height = getHeight();
+
+ int fullWidth = Math.min(width / 3 - 10, 80);
+ int sliderWidth = (fullWidth - 5) * 3 / 4;
+ int textFieldWidth = (fullWidth - 5) / 4;
+
+ slider.x = x + width / 6 - fullWidth / 2;
+ slider.y = y + height - 7 - 14;
+ slider.width = sliderWidth;
+ if (slider.mouseInput(mouseX, mouseY)) {
+ textField.unfocus();
+ return true;
+ }
+
+ if (textField.getFocus()) {
+ textFieldWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(textField.getText()) + 10;
+ }
+
+ int textFieldX = x + width / 6 - fullWidth / 2 + sliderWidth + 5;
+ int textFieldY = y + height - 7 - 14;
+ textField.setSize(textFieldWidth, 16);
+
+ if (Mouse.getEventButtonState() && (Mouse.getEventButton() == 0 || Mouse.getEventButton() == 1)) {
+ if (mouseX > textFieldX && mouseX < textFieldX + textFieldWidth &&
+ mouseY > textFieldY && mouseY < textFieldY + 16) {
+ textField.mouseClicked(mouseX, mouseY, Mouse.getEventButton());
+ return true;
+ }
+ textField.unfocus();
+ }
+
+ return false;
+ }
+
+ @Override
+ public boolean keyboardInput() {
+ if (Keyboard.getEventKeyState() && textField.getFocus()) {
+ textField.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey());
+
+ try {
+ textField.setCustomBorderColour(0xffffffff);
+ float f = Float.parseFloat(textField.getText());
+ if (option.set(f)) {
+ slider.setValue(f);
+ } else {
+ textField.setCustomBorderColour(0xff0000ff);
+ }
+ } catch (Exception e) {
+ textField.setCustomBorderColour(0xffff0000);
+ }
+
+ return true;
+ }
+ return false;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorText.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorText.java
index bf50bda8..f98c87ee 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorText.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorText.java
@@ -1,84 +1,85 @@
package io.github.moulberry.notenoughupdates.core.config.gui;
-import io.github.moulberry.notenoughupdates.core.GuiElementBoolean;
import io.github.moulberry.notenoughupdates.core.GuiElementTextField;
import io.github.moulberry.notenoughupdates.core.config.struct.ConfigProcessor;
-import io.github.moulberry.notenoughupdates.core.util.GuiElementSlider;
import net.minecraft.client.Minecraft;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
public class GuiOptionEditorText extends GuiOptionEditor {
-
- private final GuiElementTextField textField;
-
- public GuiOptionEditorText(ConfigProcessor.ProcessedOption option) {
- super(option);
-
- textField = new GuiElementTextField((String)option.get(), 0);
- }
-
- @Override
- public void render(int x, int y, int width) {
- super.render(x, y, width);
- int height = getHeight();
-
- int fullWidth = Math.min(width/3-10, 80);
-
- int textFieldX = x+width/6-fullWidth/2;
- if(textField.getFocus()) {
- fullWidth = Math.max(fullWidth, Minecraft.getMinecraft().fontRendererObj.getStringWidth(textField.getText())+10);
- }
-
- textField.setSize(fullWidth, 16);
-
- textField.render(textFieldX, y+height-7-14);
- }
-
- @Override
- public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) {
- int height = getHeight();
-
- int fullWidth = Math.min(width/3-10, 80);
-
- int textFieldX = x+width/6-fullWidth/2;
-
- if(textField.getFocus()) {
- fullWidth = Math.max(fullWidth, Minecraft.getMinecraft().fontRendererObj.getStringWidth(textField.getText())+10);
- }
-
- int textFieldY = y+height-7-14;
- textField.setSize(fullWidth, 16);
-
- if(Mouse.getEventButtonState() && (Mouse.getEventButton() == 0 || Mouse.getEventButton() == 1)) {
- if(mouseX > textFieldX && mouseX < textFieldX+fullWidth &&
- mouseY > textFieldY && mouseY < textFieldY+16) {
- textField.mouseClicked(mouseX, mouseY, Mouse.getEventButton());
- return true;
- }
- textField.unfocus();
- }
-
- return false;
- }
-
- @Override
- public boolean keyboardInput() {
- if(Keyboard.getEventKeyState() && textField.getFocus()) {
- Keyboard.enableRepeatEvents(true);
- textField.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey());
-
- try {
- textField.setCustomBorderColour(0xffffffff);
- option.set(textField.getText());
- } catch(Exception e) {
- textField.setCustomBorderColour(0xffff0000);
- }
-
- return true;
- }
- return false;
- }
-
-
+ private final GuiElementTextField textField;
+
+ public GuiOptionEditorText(ConfigProcessor.ProcessedOption option) {
+ super(option);
+
+ textField = new GuiElementTextField((String) option.get(), 0);
+ }
+
+ @Override
+ public void render(int x, int y, int width) {
+ super.render(x, y, width);
+ int height = getHeight();
+
+ int fullWidth = Math.min(width / 3 - 10, 80);
+
+ int textFieldX = x + width / 6 - fullWidth / 2;
+ if (textField.getFocus()) {
+ fullWidth = Math.max(
+ fullWidth,
+ Minecraft.getMinecraft().fontRendererObj.getStringWidth(textField.getText()) + 10
+ );
+ }
+
+ textField.setSize(fullWidth, 16);
+
+ textField.render(textFieldX, y + height - 7 - 14);
+ }
+
+ @Override
+ public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) {
+ int height = getHeight();
+
+ int fullWidth = Math.min(width / 3 - 10, 80);
+
+ int textFieldX = x + width / 6 - fullWidth / 2;
+
+ if (textField.getFocus()) {
+ fullWidth = Math.max(
+ fullWidth,
+ Minecraft.getMinecraft().fontRendererObj.getStringWidth(textField.getText()) + 10
+ );
+ }
+
+ int textFieldY = y + height - 7 - 14;
+ textField.setSize(fullWidth, 16);
+
+ if (Mouse.getEventButtonState() && (Mouse.getEventButton() == 0 || Mouse.getEventButton() == 1)) {
+ if (mouseX > textFieldX && mouseX < textFieldX + fullWidth &&
+ mouseY > textFieldY && mouseY < textFieldY + 16) {
+ textField.mouseClicked(mouseX, mouseY, Mouse.getEventButton());
+ return true;
+ }
+ textField.unfocus();
+ }
+
+ return false;
+ }
+
+ @Override
+ public boolean keyboardInput() {
+ if (Keyboard.getEventKeyState() && textField.getFocus()) {
+ Keyboard.enableRepeatEvents(true);
+ textField.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey());
+
+ try {
+ textField.setCustomBorderColour(0xffffffff);
+ option.set(textField.getText());
+ } catch (Exception e) {
+ textField.setCustomBorderColour(0xffff0000);
+ }
+
+ return true;
+ }
+ return false;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java
index e979e832..651335ed 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java
@@ -12,167 +12,170 @@ import org.lwjgl.input.Mouse;
import java.io.IOException;
public class GuiPositionEditor extends GuiScreen {
-
- private final Position position;
- private Position originalPosition;
- private final int elementWidth;
- private final int elementHeight;
- private final Runnable renderCallback;
- private final Runnable positionChangedCallback;
- private final Runnable closedCallback;
- private boolean clicked = false;
- private int grabbedX = 0;
- private int grabbedY = 0;
-
- private int guiScaleOverride = -1;
-
- public GuiPositionEditor(Position position, int elementWidth, int elementHeight,
- Runnable renderCallback,
- Runnable positionChangedCallback,
- Runnable closedCallback) {
- this.position = position;
- this.originalPosition = position.clone();
- this.elementWidth = elementWidth;
- this.elementHeight = elementHeight;
- this.renderCallback = renderCallback;
- this.positionChangedCallback = positionChangedCallback;
- this.closedCallback = closedCallback;
- }
-
- public GuiPositionEditor withScale(int scale) {
- this.guiScaleOverride = scale;
- return this;
- }
-
- @Override
- public void onGuiClosed() {
- super.onGuiClosed();
- closedCallback.run();
- }
-
- @Override
- public void drawScreen(int mouseX, int mouseY, float partialTicks) {
- super.drawScreen(mouseX, mouseY, partialTicks);
- ScaledResolution scaledResolution;
- if(guiScaleOverride >= 0) {
- scaledResolution = Utils.pushGuiScale(guiScaleOverride);
- } else {
- scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- }
-
- this.width = scaledResolution.getScaledWidth();
- this.height = scaledResolution.getScaledHeight();
- mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
- mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
-
- drawDefaultBackground();
-
- if(clicked) {
- grabbedX += position.moveX(mouseX - grabbedX, elementWidth, scaledResolution);
- grabbedY += position.moveY(mouseY - grabbedY, elementHeight, scaledResolution);
- }
-
- renderCallback.run();
-
- int x = position.getAbsX(scaledResolution, elementWidth);
- int y = position.getAbsY(scaledResolution, elementHeight);
-
- if(position.isCenterX()) x -= elementWidth/2;
- if(position.isCenterY()) y -= elementHeight/2;
- Gui.drawRect(x, y, x+elementWidth, y+elementHeight, 0x80404040);
-
- if(guiScaleOverride >= 0) {
- Utils.pushGuiScale(-1);
- }
-
- scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- Utils.drawStringCentered("Position Editor", Minecraft.getMinecraft().fontRendererObj,
- scaledResolution.getScaledWidth()/2, 8, true, 0xffffff);
- Utils.drawStringCentered("R to Reset - Arrow keys/mouse to move", Minecraft.getMinecraft().fontRendererObj,
- scaledResolution.getScaledWidth()/2, 18, true, 0xffffff);
- }
-
- @Override
- protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
- super.mouseClicked(mouseX, mouseY, mouseButton);
-
- if(mouseButton == 0) {
- ScaledResolution scaledResolution;
- if(guiScaleOverride >= 0) {
- scaledResolution = Utils.pushGuiScale(guiScaleOverride);
- } else {
- scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- }
- mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
- mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
-
- int x = position.getAbsX(scaledResolution, elementWidth);
- int y = position.getAbsY(scaledResolution, elementHeight);
- if(position.isCenterX()) x -= elementWidth/2;
- if(position.isCenterY()) y -= elementHeight/2;
-
- if(mouseX >= x && mouseY >= y &&
- mouseX <= x+elementWidth && mouseY <= y+elementHeight) {
- clicked = true;
- grabbedX = mouseX;
- grabbedY = mouseY;
- }
-
- if(guiScaleOverride >= 0) {
- Utils.pushGuiScale(-1);
- }
- }
- }
-
- @Override
- protected void keyTyped(char typedChar, int keyCode) throws IOException {
- Keyboard.enableRepeatEvents(true);
-
- if(keyCode == Keyboard.KEY_R) {
- position.set(originalPosition);
- } else if(!clicked) {
- boolean shiftHeld = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
- int dist = shiftHeld ? 10 : 1;
- if(keyCode == Keyboard.KEY_DOWN) {
- position.moveY(dist, elementHeight, new ScaledResolution(Minecraft.getMinecraft()));
- } else if(keyCode == Keyboard.KEY_UP) {
- position.moveY(-dist, elementHeight, new ScaledResolution(Minecraft.getMinecraft()));
- } else if(keyCode == Keyboard.KEY_LEFT) {
- position.moveX(-dist, elementWidth, new ScaledResolution(Minecraft.getMinecraft()));
- } else if(keyCode == Keyboard.KEY_RIGHT) {
- position.moveX(dist, elementWidth, new ScaledResolution(Minecraft.getMinecraft()));
- }
- }
- super.keyTyped(typedChar, keyCode);
- }
-
- @Override
- protected void mouseReleased(int mouseX, int mouseY, int state) {
- super.mouseReleased(mouseX, mouseY, state);
- clicked = false;
- }
-
- @Override
- protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
- super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
-
- if(clicked) {
- ScaledResolution scaledResolution;
- if(guiScaleOverride >= 0) {
- scaledResolution = Utils.pushGuiScale(guiScaleOverride);
- } else {
- scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- }
- mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
- mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
-
- grabbedX += position.moveX(mouseX - grabbedX, elementWidth, scaledResolution);
- grabbedY += position.moveY(mouseY - grabbedY, elementHeight, scaledResolution);
- positionChangedCallback.run();
-
- if(guiScaleOverride >= 0) {
- Utils.pushGuiScale(-1);
- }
- }
- }
+ private final Position position;
+ private final Position originalPosition;
+ private final int elementWidth;
+ private final int elementHeight;
+ private final Runnable renderCallback;
+ private final Runnable positionChangedCallback;
+ private final Runnable closedCallback;
+ private boolean clicked = false;
+ private int grabbedX = 0;
+ private int grabbedY = 0;
+
+ private int guiScaleOverride = -1;
+
+ public GuiPositionEditor(
+ Position position, int elementWidth, int elementHeight,
+ Runnable renderCallback,
+ Runnable positionChangedCallback,
+ Runnable closedCallback
+ ) {
+ this.position = position;
+ this.originalPosition = position.clone();
+ this.elementWidth = elementWidth;
+ this.elementHeight = elementHeight;
+ this.renderCallback = renderCallback;
+ this.positionChangedCallback = positionChangedCallback;
+ this.closedCallback = closedCallback;
+ }
+
+ public GuiPositionEditor withScale(int scale) {
+ this.guiScaleOverride = scale;
+ return this;
+ }
+
+ @Override
+ public void onGuiClosed() {
+ super.onGuiClosed();
+ closedCallback.run();
+ }
+
+ @Override
+ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
+ super.drawScreen(mouseX, mouseY, partialTicks);
+ ScaledResolution scaledResolution;
+ if (guiScaleOverride >= 0) {
+ scaledResolution = Utils.pushGuiScale(guiScaleOverride);
+ } else {
+ scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ }
+
+ this.width = scaledResolution.getScaledWidth();
+ this.height = scaledResolution.getScaledHeight();
+ mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
+ mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
+
+ drawDefaultBackground();
+
+ if (clicked) {
+ grabbedX += position.moveX(mouseX - grabbedX, elementWidth, scaledResolution);
+ grabbedY += position.moveY(mouseY - grabbedY, elementHeight, scaledResolution);
+ }
+
+ renderCallback.run();
+
+ int x = position.getAbsX(scaledResolution, elementWidth);
+ int y = position.getAbsY(scaledResolution, elementHeight);
+
+ if (position.isCenterX()) x -= elementWidth / 2;
+ if (position.isCenterY()) y -= elementHeight / 2;
+ Gui.drawRect(x, y, x + elementWidth, y + elementHeight, 0x80404040);
+
+ if (guiScaleOverride >= 0) {
+ Utils.pushGuiScale(-1);
+ }
+
+ scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ Utils.drawStringCentered("Position Editor", Minecraft.getMinecraft().fontRendererObj,
+ scaledResolution.getScaledWidth() / 2, 8, true, 0xffffff
+ );
+ Utils.drawStringCentered("R to Reset - Arrow keys/mouse to move", Minecraft.getMinecraft().fontRendererObj,
+ scaledResolution.getScaledWidth() / 2, 18, true, 0xffffff
+ );
+ }
+
+ @Override
+ protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
+ super.mouseClicked(mouseX, mouseY, mouseButton);
+
+ if (mouseButton == 0) {
+ ScaledResolution scaledResolution;
+ if (guiScaleOverride >= 0) {
+ scaledResolution = Utils.pushGuiScale(guiScaleOverride);
+ } else {
+ scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ }
+ mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
+ mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
+
+ int x = position.getAbsX(scaledResolution, elementWidth);
+ int y = position.getAbsY(scaledResolution, elementHeight);
+ if (position.isCenterX()) x -= elementWidth / 2;
+ if (position.isCenterY()) y -= elementHeight / 2;
+
+ if (mouseX >= x && mouseY >= y &&
+ mouseX <= x + elementWidth && mouseY <= y + elementHeight) {
+ clicked = true;
+ grabbedX = mouseX;
+ grabbedY = mouseY;
+ }
+
+ if (guiScaleOverride >= 0) {
+ Utils.pushGuiScale(-1);
+ }
+ }
+ }
+
+ @Override
+ protected void keyTyped(char typedChar, int keyCode) throws IOException {
+ Keyboard.enableRepeatEvents(true);
+
+ if (keyCode == Keyboard.KEY_R) {
+ position.set(originalPosition);
+ } else if (!clicked) {
+ boolean shiftHeld = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
+ int dist = shiftHeld ? 10 : 1;
+ if (keyCode == Keyboard.KEY_DOWN) {
+ position.moveY(dist, elementHeight, new ScaledResolution(Minecraft.getMinecraft()));
+ } else if (keyCode == Keyboard.KEY_UP) {
+ position.moveY(-dist, elementHeight, new ScaledResolution(Minecraft.getMinecraft()));
+ } else if (keyCode == Keyboard.KEY_LEFT) {
+ position.moveX(-dist, elementWidth, new ScaledResolution(Minecraft.getMinecraft()));
+ } else if (keyCode == Keyboard.KEY_RIGHT) {
+ position.moveX(dist, elementWidth, new ScaledResolution(Minecraft.getMinecraft()));
+ }
+ }
+ super.keyTyped(typedChar, keyCode);
+ }
+
+ @Override
+ protected void mouseReleased(int mouseX, int mouseY, int state) {
+ super.mouseReleased(mouseX, mouseY, state);
+ clicked = false;
+ }
+
+ @Override
+ protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
+ super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
+
+ if (clicked) {
+ ScaledResolution scaledResolution;
+ if (guiScaleOverride >= 0) {
+ scaledResolution = Utils.pushGuiScale(guiScaleOverride);
+ } else {
+ scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ }
+ mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
+ mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
+
+ grabbedX += position.moveX(mouseX - grabbedX, elementWidth, scaledResolution);
+ grabbedY += position.moveY(mouseY - grabbedY, elementHeight, scaledResolution);
+ positionChangedCallback.run();
+
+ if (guiScaleOverride >= 0) {
+ Utils.pushGuiScale(-1);
+ }
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/struct/ConfigProcessor.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/struct/ConfigProcessor.java
index 4ce10162..b5aa6ba8 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/struct/ConfigProcessor.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/struct/ConfigProcessor.java
@@ -4,178 +4,192 @@ import com.google.gson.annotations.Expose;
import io.github.moulberry.notenoughupdates.core.config.Config;
import io.github.moulberry.notenoughupdates.core.config.annotations.*;
import io.github.moulberry.notenoughupdates.core.config.gui.*;
-import io.github.moulberry.notenoughupdates.core.config.Config;
import java.lang.reflect.Field;
import java.util.LinkedHashMap;
import java.util.List;
public class ConfigProcessor {
-
- public static class ProcessedCategory {
- public final String name;
- public final String desc;
- public final LinkedHashMap<String, ProcessedOption> options = new LinkedHashMap<>();
-
- public ProcessedCategory(String name, String desc) {
- this.name = name;
- this.desc = desc;
- }
- }
-
- public static class ProcessedOption {
- public final String name;
- public final String desc;
- public final int subcategoryId;
- public GuiOptionEditor editor;
-
- public int accordionId = -1;
-
- private final Field field;
- private final Object container;
-
- public ProcessedOption(String name, String desc, int subcategoryId, Field field, Object container) {
- this.name = name;
- this.desc = desc;
- this.subcategoryId = subcategoryId;
-
- this.field = field;
- this.container = container;
- }
-
- public Object get() {
- try {
- return field.get(container);
- } catch(Exception e) {
- return null;
- }
- }
-
- public boolean set(Object value) {
- try {
- if(field.getType() == int.class && value instanceof Number) {
- field.set(container, ((Number)value).intValue());
- } else {
- field.set(container, value);
- }
- return true;
- } catch(Exception e) {
- e.printStackTrace();
- return false;
- }
- }
- }
-
- public static LinkedHashMap<String, ProcessedCategory> create(Config config) {
- LinkedHashMap<String, ProcessedCategory> processedConfig = new LinkedHashMap<>();
- for(Field categoryField : config.getClass().getDeclaredFields()) {
- boolean exposePresent = categoryField.isAnnotationPresent(Expose.class);
- boolean categoryPresent = categoryField.isAnnotationPresent(Category.class);
-
- if(exposePresent && categoryPresent) {
- Object categoryObj;
- try {
- categoryObj = categoryField.get(config);
- } catch(Exception e) {
- //System.err.printf("Failed to load config category %s. Field was not accessible.\n", categoryField.getName());
- continue;
- }
-
- Category categoryAnnotation = categoryField.getAnnotation(Category.class);
- ProcessedCategory cat = new ProcessedCategory(
- categoryAnnotation.name(),
- categoryAnnotation.desc()
- );
- processedConfig.put(categoryField.getName(), cat);
-
- for(Field optionField : categoryObj.getClass().getDeclaredFields()) {
- boolean optionPresent = optionField.isAnnotationPresent(ConfigOption.class);
-
- if(optionPresent) {
- ConfigOption optionAnnotation = optionField.getAnnotation(ConfigOption.class);
- ProcessedOption option = new ProcessedOption(
- optionAnnotation.name(),
- optionAnnotation.desc(),
- optionAnnotation.subcategoryId(),
- optionField,
- categoryObj
- );
- if(optionField.isAnnotationPresent(ConfigAccordionId.class)) {
- ConfigAccordionId annotation = optionField.getAnnotation(ConfigAccordionId.class);
- option.accordionId = annotation.id();
- }
-
- GuiOptionEditor editor = null;
- Class<?> optionType = optionField.getType();
- if(optionType.isAssignableFrom(int.class) &&
- optionField.isAnnotationPresent(ConfigEditorKeybind.class)) {
- ConfigEditorKeybind configEditorAnnotation = optionField.getAnnotation(ConfigEditorKeybind.class);
- editor = new GuiOptionEditorKeybind(option, (int)option.get(), configEditorAnnotation.defaultKey());
- }
- if(optionField.isAnnotationPresent(ConfigEditorButton.class)) {
- ConfigEditorButton configEditorAnnotation = optionField.getAnnotation(ConfigEditorButton.class);
- editor = new GuiOptionEditorButton(option, configEditorAnnotation.runnableId(), configEditorAnnotation.buttonText(), config);
- }
- if(optionType.isAssignableFrom(boolean.class) &&
- optionField.isAnnotationPresent(ConfigEditorBoolean.class)) {
- editor = new GuiOptionEditorBoolean(option);
- }
- if(optionType.isAssignableFrom(boolean.class) &&
- optionField.isAnnotationPresent(ConfigEditorAccordion.class)) {
- ConfigEditorAccordion configEditorAnnotation = optionField.getAnnotation(ConfigEditorAccordion.class);
- editor = new GuiOptionEditorAccordion(option, configEditorAnnotation.id());
- }
- if(optionType.isAssignableFrom(int.class)) {
- if(optionField.isAnnotationPresent(ConfigEditorDropdown.class)) {
- ConfigEditorDropdown configEditorAnnotation = optionField.getAnnotation(ConfigEditorDropdown.class);
- editor = new GuiOptionEditorDropdown(option, configEditorAnnotation.values(), (int)option.get(), true);
- }
- }
- if(optionType.isAssignableFrom(List.class)) {
- if(optionField.isAnnotationPresent(ConfigEditorDraggableList.class)) {
- ConfigEditorDraggableList configEditorAnnotation = optionField.getAnnotation(ConfigEditorDraggableList.class);
- editor = new GuiOptionEditorDraggableList(option, configEditorAnnotation.exampleText());
- }
- }
- if(optionType.isAssignableFrom(String.class)) {
- if(optionField.isAnnotationPresent(ConfigEditorDropdown.class)) {
- ConfigEditorDropdown configEditorAnnotation = optionField.getAnnotation(ConfigEditorDropdown.class);
- editor = new GuiOptionEditorDropdown(option, configEditorAnnotation.values(),
- configEditorAnnotation.initialIndex(), false);
- } else if(optionField.isAnnotationPresent(ConfigEditorColour.class)) {
- editor = new GuiOptionEditorColour(option);
- } else if(optionField.isAnnotationPresent(ConfigEditorText.class)) {
- editor = new GuiOptionEditorText(option);
- }
- }
- if(optionType.isAssignableFrom(int.class) ||
- optionType.isAssignableFrom(float.class) ||
- optionType.isAssignableFrom(double.class)) {
- if(optionField.isAnnotationPresent(ConfigEditorSlider.class)) {
- ConfigEditorSlider configEditorAnnotation = optionField.getAnnotation(ConfigEditorSlider.class);
- editor = new GuiOptionEditorSlider(option, configEditorAnnotation.minValue(),
- configEditorAnnotation.maxValue(), configEditorAnnotation.minStep());
- }
- }
- if(optionType.isAssignableFrom(String.class)) {
- if(optionField.isAnnotationPresent(ConfigEditorDropdown.class)) {
- ConfigEditorDropdown configEditorAnnotation = optionField.getAnnotation(ConfigEditorDropdown.class);
- editor = new GuiOptionEditorDropdown(option, configEditorAnnotation.values(), 0,false);
- }
- }
- if(editor == null) {
- //System.err.printf("Failed to load config option %s. Could not find suitable editor.\n", optionField.getName());
- continue;
- }
- option.editor = editor;
- cat.options.put(optionField.getName(), option);
- }
- }
- } else if(exposePresent || categoryPresent) {
- //System.err.printf("Failed to load config category %s. Both @Expose and @Category must be present.\n", categoryField.getName());
- }
- }
- return processedConfig;
- }
-
+ public static class ProcessedCategory {
+ public final String name;
+ public final String desc;
+ public final LinkedHashMap<String, ProcessedOption> options = new LinkedHashMap<>();
+
+ public ProcessedCategory(String name, String desc) {
+ this.name = name;
+ this.desc = desc;
+ }
+ }
+
+ public static class ProcessedOption {
+ public final String name;
+ public final String desc;
+ public final int subcategoryId;
+ public GuiOptionEditor editor;
+
+ public int accordionId = -1;
+
+ private final Field field;
+ private final Object container;
+
+ public ProcessedOption(String name, String desc, int subcategoryId, Field field, Object container) {
+ this.name = name;
+ this.desc = desc;
+ this.subcategoryId = subcategoryId;
+
+ this.field = field;
+ this.container = container;
+ }
+
+ public Object get() {
+ try {
+ return field.get(container);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ public boolean set(Object value) {
+ try {
+ if (field.getType() == int.class && value instanceof Number) {
+ field.set(container, ((Number) value).intValue());
+ } else {
+ field.set(container, value);
+ }
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+ }
+
+ public static LinkedHashMap<String, ProcessedCategory> create(Config config) {
+ LinkedHashMap<String, ProcessedCategory> processedConfig = new LinkedHashMap<>();
+ for (Field categoryField : config.getClass().getDeclaredFields()) {
+ boolean exposePresent = categoryField.isAnnotationPresent(Expose.class);
+ boolean categoryPresent = categoryField.isAnnotationPresent(Category.class);
+
+ if (exposePresent && categoryPresent) {
+ Object categoryObj;
+ try {
+ categoryObj = categoryField.get(config);
+ } catch (Exception e) {
+ //System.err.printf("Failed to load config category %s. Field was not accessible.\n", categoryField.getName());
+ continue;
+ }
+
+ Category categoryAnnotation = categoryField.getAnnotation(Category.class);
+ ProcessedCategory cat = new ProcessedCategory(
+ categoryAnnotation.name(),
+ categoryAnnotation.desc()
+ );
+ processedConfig.put(categoryField.getName(), cat);
+
+ for (Field optionField : categoryObj.getClass().getDeclaredFields()) {
+ boolean optionPresent = optionField.isAnnotationPresent(ConfigOption.class);
+
+ if (optionPresent) {
+ ConfigOption optionAnnotation = optionField.getAnnotation(ConfigOption.class);
+ ProcessedOption option = new ProcessedOption(
+ optionAnnotation.name(),
+ optionAnnotation.desc(),
+ optionAnnotation.subcategoryId(),
+ optionField,
+ categoryObj
+ );
+ if (optionField.isAnnotationPresent(ConfigAccordionId.class)) {
+ ConfigAccordionId annotation = optionField.getAnnotation(ConfigAccordionId.class);
+ option.accordionId = annotation.id();
+ }
+
+ GuiOptionEditor editor = null;
+ Class<?> optionType = optionField.getType();
+ if (optionType.isAssignableFrom(int.class) &&
+ optionField.isAnnotationPresent(ConfigEditorKeybind.class)) {
+ ConfigEditorKeybind configEditorAnnotation = optionField.getAnnotation(ConfigEditorKeybind.class);
+ editor = new GuiOptionEditorKeybind(option, (int) option.get(), configEditorAnnotation.defaultKey());
+ }
+ if (optionField.isAnnotationPresent(ConfigEditorButton.class)) {
+ ConfigEditorButton configEditorAnnotation = optionField.getAnnotation(ConfigEditorButton.class);
+ editor = new GuiOptionEditorButton(
+ option,
+ configEditorAnnotation.runnableId(),
+ configEditorAnnotation.buttonText(),
+ config
+ );
+ }
+ if (optionField.isAnnotationPresent(ConfigEditorFSR.class)) {
+ ConfigEditorFSR configEditorAnnotation = optionField.getAnnotation(ConfigEditorFSR.class);
+ editor = new GuiOptionEditorFSR(
+ option,
+ configEditorAnnotation.runnableId(),
+ configEditorAnnotation.buttonText(),
+ config
+ );
+ }
+ if (optionType.isAssignableFrom(boolean.class) &&
+ optionField.isAnnotationPresent(ConfigEditorBoolean.class)) {
+ editor = new GuiOptionEditorBoolean(option);
+ }
+ if (optionType.isAssignableFrom(boolean.class) &&
+ optionField.isAnnotationPresent(ConfigEditorAccordion.class)) {
+ ConfigEditorAccordion configEditorAnnotation = optionField.getAnnotation(ConfigEditorAccordion.class);
+ editor = new GuiOptionEditorAccordion(option, configEditorAnnotation.id());
+ }
+ if (optionType.isAssignableFrom(int.class)) {
+ if (optionField.isAnnotationPresent(ConfigEditorDropdown.class)) {
+ ConfigEditorDropdown configEditorAnnotation = optionField.getAnnotation(ConfigEditorDropdown.class);
+ editor = new GuiOptionEditorDropdown(option, configEditorAnnotation.values(), (int) option.get(), true);
+ }
+ }
+ if (optionType.isAssignableFrom(List.class)) {
+ if (optionField.isAnnotationPresent(ConfigEditorDraggableList.class)) {
+ ConfigEditorDraggableList configEditorAnnotation =
+ optionField.getAnnotation(ConfigEditorDraggableList.class);
+ editor = new GuiOptionEditorDraggableList(option, configEditorAnnotation.exampleText());
+ }
+ }
+ if (optionType.isAssignableFrom(String.class)) {
+ if (optionField.isAnnotationPresent(ConfigEditorDropdown.class)) {
+ ConfigEditorDropdown configEditorAnnotation = optionField.getAnnotation(ConfigEditorDropdown.class);
+ editor = new GuiOptionEditorDropdown(option, configEditorAnnotation.values(),
+ configEditorAnnotation.initialIndex(), false
+ );
+ } else if (optionField.isAnnotationPresent(ConfigEditorColour.class)) {
+ editor = new GuiOptionEditorColour(option);
+ } else if (optionField.isAnnotationPresent(ConfigEditorText.class)) {
+ editor = new GuiOptionEditorText(option);
+ }
+ }
+ if (optionType.isAssignableFrom(int.class) ||
+ optionType.isAssignableFrom(float.class) ||
+ optionType.isAssignableFrom(double.class)) {
+ if (optionField.isAnnotationPresent(ConfigEditorSlider.class)) {
+ ConfigEditorSlider configEditorAnnotation = optionField.getAnnotation(ConfigEditorSlider.class);
+ editor = new GuiOptionEditorSlider(option, configEditorAnnotation.minValue(),
+ configEditorAnnotation.maxValue(), configEditorAnnotation.minStep()
+ );
+ }
+ }
+ if (optionType.isAssignableFrom(String.class)) {
+ if (optionField.isAnnotationPresent(ConfigEditorDropdown.class)) {
+ ConfigEditorDropdown configEditorAnnotation = optionField.getAnnotation(ConfigEditorDropdown.class);
+ editor = new GuiOptionEditorDropdown(option, configEditorAnnotation.values(), 0, false);
+ }
+ }
+ if (editor == null) {
+ //System.err.printf("Failed to load config option %s. Could not find suitable editor.\n", optionField.getName());
+ continue;
+ }
+ option.editor = editor;
+ cat.options.put(optionField.getName(), option);
+ }
+ }
+ } else if (exposePresent || categoryPresent) {
+ //System.err.printf("Failed to load config category %s. Both @Expose and @Category must be present.\n", categoryField.getName());
+ }
+ }
+ return processedConfig;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/util/GuiElementSlider.java b/src/main/java/io/github/moulberry/notenoughupdates/core/util/GuiElementSlider.java
index 89feaf17..c2252a97 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/util/GuiElementSlider.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/util/GuiElementSlider.java
@@ -13,111 +13,112 @@ import java.util.function.Consumer;
import static io.github.moulberry.notenoughupdates.util.GuiTextures.*;
public class GuiElementSlider extends GuiElement {
-
- public int x;
- public int y;
- public int width;
- private static final int HEIGHT = 16;
-
- private float minValue;
- private float maxValue;
- private float minStep;
-
- private float value;
- private Consumer<Float> setCallback;
-
- private boolean clicked = false;
-
- public GuiElementSlider(int x, int y, int width, float minValue, float maxValue, float minStep,
- float value, Consumer<Float> setCallback) {
- if(minStep < 0) minStep = 0.01f;
-
- this.x = x;
- this.y = y;
- this.width = width;
- this.minValue = minValue;
- this.maxValue = maxValue;
- this.minStep = minStep;
- this.value = value;
- this.setCallback = setCallback;
- }
-
- public void setValue(float value) {
- this.value = value;
- }
-
- @Override
- public void render() {
- final ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- int mouseX = Mouse.getX() * scaledResolution.getScaledWidth() / Minecraft.getMinecraft().displayWidth;
-
- float value = this.value;
- if(clicked) {
- value = (mouseX-x)*(maxValue-minValue)/width+minValue;
- value = Math.max(minValue, Math.min(maxValue, value));
- value = Math.round(value/minStep)*minStep;
- }
-
- float sliderAmount = Math.max(0, Math.min(1, (value-minValue)/(maxValue-minValue)));
- int sliderAmountI = (int)(width*sliderAmount);
-
- GlStateManager.color(1f, 1f, 1f, 1f);
- Minecraft.getMinecraft().getTextureManager().bindTexture(slider_on_cap);
- Utils.drawTexturedRect(x, y, 4, HEIGHT, GL11.GL_NEAREST);
- Minecraft.getMinecraft().getTextureManager().bindTexture(slider_off_cap);
- Utils.drawTexturedRect(x+width-4, y, 4, HEIGHT, GL11.GL_NEAREST);
-
- if(sliderAmountI > 5) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(slider_on_segment);
- Utils.drawTexturedRect(x+4, y, sliderAmountI-4, HEIGHT, GL11.GL_NEAREST);
- }
-
- if(sliderAmountI < width-5) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(slider_off_segment);
- Utils.drawTexturedRect(x+sliderAmountI, y, width-4-sliderAmountI, HEIGHT, GL11.GL_NEAREST);
- }
-
- for(int i=1; i<4; i++) {
- int notchX = x+width*i/4-1;
- Minecraft.getMinecraft().getTextureManager().bindTexture(notchX > x+sliderAmountI ? slider_off_notch : slider_on_notch);
- Utils.drawTexturedRect(notchX, y+(HEIGHT-4)/2, 2, 4, GL11.GL_NEAREST);
- }
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(slider_button_new);
- Utils.drawTexturedRect(x+sliderAmountI-4, y, 8, HEIGHT, GL11.GL_NEAREST);
- }
-
- @Override
- public boolean mouseInput(int mouseX, int mouseY) {
- if(!Mouse.isButtonDown(0)) {
- clicked = false;
- }
-
- if(Mouse.getEventButton() == 0) {
- clicked = Mouse.getEventButtonState() && mouseX > x && mouseX < x+width && mouseY > y && mouseY < y+HEIGHT;
- if(clicked) {
- value = (mouseX-x)*(maxValue-minValue)/width+minValue;
- value = Math.max(minValue, Math.min(maxValue, value));
- value = (float)(Math.round(value/minStep)*(double)minStep);
- setCallback.accept(value);
- return true;
- }
- }
-
- if(!Mouse.getEventButtonState() && Mouse.getEventButton() == -1 && clicked) {
- value = (mouseX-x)*(maxValue-minValue)/width+minValue;
- value = Math.max(minValue, Math.min(maxValue, value));
- value = Math.round(value/minStep)*minStep;
- setCallback.accept(value);
- return true;
- }
-
- return false;
- }
-
- @Override
- public boolean keyboardInput() {
- return false;
- }
-
+ public int x;
+ public int y;
+ public int width;
+ private static final int HEIGHT = 16;
+
+ private final float minValue;
+ private final float maxValue;
+ private final float minStep;
+
+ private float value;
+ private final Consumer<Float> setCallback;
+
+ private boolean clicked = false;
+
+ public GuiElementSlider(
+ int x, int y, int width, float minValue, float maxValue, float minStep,
+ float value, Consumer<Float> setCallback
+ ) {
+ if (minStep < 0) minStep = 0.01f;
+
+ this.x = x;
+ this.y = y;
+ this.width = width;
+ this.minValue = minValue;
+ this.maxValue = maxValue;
+ this.minStep = minStep;
+ this.value = value;
+ this.setCallback = setCallback;
+ }
+
+ public void setValue(float value) {
+ this.value = value;
+ }
+
+ @Override
+ public void render() {
+ final ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ int mouseX = Mouse.getX() * scaledResolution.getScaledWidth() / Minecraft.getMinecraft().displayWidth;
+
+ float value = this.value;
+ if (clicked) {
+ value = (mouseX - x) * (maxValue - minValue) / width + minValue;
+ value = Math.max(minValue, Math.min(maxValue, value));
+ value = Math.round(value / minStep) * minStep;
+ }
+
+ float sliderAmount = Math.max(0, Math.min(1, (value - minValue) / (maxValue - minValue)));
+ int sliderAmountI = (int) (width * sliderAmount);
+
+ GlStateManager.color(1f, 1f, 1f, 1f);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(slider_on_cap);
+ Utils.drawTexturedRect(x, y, 4, HEIGHT, GL11.GL_NEAREST);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(slider_off_cap);
+ Utils.drawTexturedRect(x + width - 4, y, 4, HEIGHT, GL11.GL_NEAREST);
+
+ if (sliderAmountI > 5) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(slider_on_segment);
+ Utils.drawTexturedRect(x + 4, y, sliderAmountI - 4, HEIGHT, GL11.GL_NEAREST);
+ }
+
+ if (sliderAmountI < width - 5) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(slider_off_segment);
+ Utils.drawTexturedRect(x + sliderAmountI, y, width - 4 - sliderAmountI, HEIGHT, GL11.GL_NEAREST);
+ }
+
+ for (int i = 1; i < 4; i++) {
+ int notchX = x + width * i / 4 - 1;
+ Minecraft.getMinecraft().getTextureManager().bindTexture(
+ notchX > x + sliderAmountI ? slider_off_notch : slider_on_notch);
+ Utils.drawTexturedRect(notchX, y + (HEIGHT - 4) / 2, 2, 4, GL11.GL_NEAREST);
+ }
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(slider_button_new);
+ Utils.drawTexturedRect(x + sliderAmountI - 4, y, 8, HEIGHT, GL11.GL_NEAREST);
+ }
+
+ @Override
+ public boolean mouseInput(int mouseX, int mouseY) {
+ if (!Mouse.isButtonDown(0)) {
+ clicked = false;
+ }
+
+ if (Mouse.getEventButton() == 0) {
+ clicked = Mouse.getEventButtonState() && mouseX > x && mouseX < x + width && mouseY > y && mouseY < y + HEIGHT;
+ if (clicked) {
+ value = (mouseX - x) * (maxValue - minValue) / width + minValue;
+ value = Math.max(minValue, Math.min(maxValue, value));
+ value = (float) (Math.round(value / minStep) * (double) minStep);
+ setCallback.accept(value);
+ return true;
+ }
+ }
+
+ if (!Mouse.getEventButtonState() && Mouse.getEventButton() == -1 && clicked) {
+ value = (mouseX - x) * (maxValue - minValue) / width + minValue;
+ value = Math.max(minValue, Math.min(maxValue, value));
+ value = Math.round(value / minStep) * minStep;
+ setCallback.accept(value);
+ return true;
+ }
+
+ return false;
+ }
+
+ @Override
+ public boolean keyboardInput() {
+ return false;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/util/MiscUtils.java b/src/main/java/io/github/moulberry/notenoughupdates/core/util/MiscUtils.java
index 3e9fc4ca..03a9483b 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/util/MiscUtils.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/util/MiscUtils.java
@@ -20,85 +20,89 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
public class MiscUtils {
+ public static void copyToClipboard(String str) {
+ Toolkit.getDefaultToolkit().getSystemClipboard()
+ .setContents(new StringSelection(str), null);
+ }
- public static void copyToClipboard(String str) {
- Toolkit.getDefaultToolkit().getSystemClipboard()
- .setContents(new StringSelection(str), null);
- }
- private static void unzip(InputStream src, File dest) {
- //buffer for read and write data to file
- byte[] buffer = new byte[1024];
- try {
- ZipInputStream zis = new ZipInputStream(src);
- ZipEntry ze = zis.getNextEntry();
- while(ze != null){
- if(!ze.isDirectory()) {
- String fileName = ze.getName();
- File newFile = new File(dest, fileName);
- //create directories for sub directories in zip
- new File(newFile.getParent()).mkdirs();
- FileOutputStream fos = new FileOutputStream(newFile);
- int len;
- while ((len = zis.read(buffer)) > 0) {
- fos.write(buffer, 0, len);
- }
- fos.close();
- }
- //close this ZipEntry
- zis.closeEntry();
- ze = zis.getNextEntry();
- }
- //close last ZipEntry
- zis.closeEntry();
- zis.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
+ private static void unzip(InputStream src, File dest) {
+ //buffer for read and write data to file
+ byte[] buffer = new byte[1024];
+ try {
+ ZipInputStream zis = new ZipInputStream(src);
+ ZipEntry ze = zis.getNextEntry();
+ while (ze != null) {
+ if (!ze.isDirectory()) {
+ String fileName = ze.getName();
+ File newFile = new File(dest, fileName);
+ //create directories for sub directories in zip
+ new File(newFile.getParent()).mkdirs();
+ FileOutputStream fos = new FileOutputStream(newFile);
+ int len;
+ while ((len = zis.read(buffer)) > 0) {
+ fos.write(buffer, 0, len);
+ }
+ fos.close();
+ }
+ //close this ZipEntry
+ zis.closeEntry();
+ ze = zis.getNextEntry();
+ }
+ //close last ZipEntry
+ zis.closeEntry();
+ zis.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
- public static void recursiveDelete(File file) {
- if(file.isDirectory() && !Files.isSymbolicLink(file.toPath())) {
- for(File child : file.listFiles()) {
- recursiveDelete(child);
- }
- }
- file.delete();
- }
+ public static void recursiveDelete(File file) {
+ if (file.isDirectory() && !Files.isSymbolicLink(file.toPath())) {
+ for (File child : file.listFiles()) {
+ recursiveDelete(child);
+ }
+ }
+ file.delete();
+ }
- private static String currentCursor = null;
+ private static String currentCursor = null;
- public static void resetCursor() {
- if(currentCursor == null) {
- return;
- }
- currentCursor = null;
- try { Mouse.setNativeCursor(null); } catch(Exception ignored) {}
- }
+ public static void resetCursor() {
+ if (currentCursor == null) {
+ return;
+ }
+ currentCursor = null;
+ try {
+ Mouse.setNativeCursor(null);
+ } catch (Exception ignored) {
+ }
+ }
- public static void setCursor(ResourceLocation loc, int hotspotX, int hotspotY) {
- if(currentCursor != null && loc.getResourcePath().equals(currentCursor)) {
- return;
- }
- currentCursor = loc.getResourcePath();
- try {
- BufferedImage image = ImageIO.read(Minecraft.getMinecraft()
- .getResourceManager().getResource(loc).getInputStream());
- int maxSize = Cursor.getMaxCursorSize();
- IntBuffer buffer = BufferUtils.createIntBuffer(maxSize*maxSize);
- for(int i=0; i<maxSize*maxSize; i++) {
- int cursorX = i%maxSize;
- int cursorY = i/maxSize;
- if(cursorX >= image.getWidth() || cursorY >= image.getHeight()) {
- buffer.put(0x00000000);
- } else {
- buffer.put(image.getRGB(cursorX, image.getHeight()-1-cursorY));
- }
- }
- buffer.flip();
- Mouse.setNativeCursor(new Cursor(maxSize, maxSize, hotspotX, hotspotY, 1,
- buffer, null));
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
+ public static void setCursor(ResourceLocation loc, int hotspotX, int hotspotY) {
+ if (currentCursor != null && loc.getResourcePath().equals(currentCursor)) {
+ return;
+ }
+ currentCursor = loc.getResourcePath();
+ try {
+ BufferedImage image = ImageIO.read(Minecraft.getMinecraft()
+ .getResourceManager().getResource(loc).getInputStream());
+ int maxSize = Cursor.getMaxCursorSize();
+ IntBuffer buffer = BufferUtils.createIntBuffer(maxSize * maxSize);
+ for (int i = 0; i < maxSize * maxSize; i++) {
+ int cursorX = i % maxSize;
+ int cursorY = i / maxSize;
+ if (cursorX >= image.getWidth() || cursorY >= image.getHeight()) {
+ buffer.put(0x00000000);
+ } else {
+ buffer.put(image.getRGB(cursorX, image.getHeight() - 1 - cursorY));
+ }
+ }
+ buffer.flip();
+ Mouse.setNativeCursor(new Cursor(maxSize, maxSize, hotspotX, hotspotY, 1,
+ buffer, null
+ ));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/util/Splitters.java b/src/main/java/io/github/moulberry/notenoughupdates/core/util/Splitters.java
index 555e0d79..0bb858db 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/util/Splitters.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/util/Splitters.java
@@ -3,8 +3,5 @@ package io.github.moulberry.notenoughupdates.core.util;
import com.google.common.base.Splitter;
public class Splitters {
-
- public static final Splitter NEWLINE_SPLITTER = Splitter.on('\n');
-
-
+ public static final Splitter NEWLINE_SPLITTER = Splitter.on('\n');
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/util/StringUtils.java b/src/main/java/io/github/moulberry/notenoughupdates/core/util/StringUtils.java
index a3d8204a..b0deadd2 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/util/StringUtils.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/util/StringUtils.java
@@ -7,33 +7,31 @@ import net.minecraft.client.gui.FontRenderer;
import java.util.Set;
public class StringUtils {
-
- public static final Set<String> PROTOCOLS = Sets.newHashSet("http", "https");
-
- public static String cleanColour(String in) {
- return in.replaceAll("(?i)\\u00A7.", "");
- }
-
- public static String cleanColourNotModifiers(String in) {
- return in.replaceAll("(?i)\\u00A7[0-9a-f]", "\u00A7r");
- }
-
- public static String trimToWidth(String str, int len) {
- FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
- String trim = fr.trimStringToWidth(str, len);
-
- if(str.length() != trim.length() && !trim.endsWith(" ")) {
- char next = str.charAt(trim.length());
- if(next != ' ') {
- String[] split = trim.split(" ");
- String last = split[split.length-1];
- if(last.length() < 8) {
- trim = trim.substring(0, trim.length()-last.length());
- }
- }
- }
-
- return trim;
- }
-
+ public static final Set<String> PROTOCOLS = Sets.newHashSet("http", "https");
+
+ public static String cleanColour(String in) {
+ return in.replaceAll("(?i)\\u00A7.", "");
+ }
+
+ public static String cleanColourNotModifiers(String in) {
+ return in.replaceAll("(?i)\\u00A7[0-9a-f]", "\u00A7r");
+ }
+
+ public static String trimToWidth(String str, int len) {
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+ String trim = fr.trimStringToWidth(str, len);
+
+ if (str.length() != trim.length() && !trim.endsWith(" ")) {
+ char next = str.charAt(trim.length());
+ if (next != ' ') {
+ String[] split = trim.split(" ");
+ String last = split[split.length - 1];
+ if (last.length() < 8) {
+ trim = trim.substring(0, trim.length() - last.length());
+ }
+ }
+ }
+
+ return trim;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/util/lerp/LerpUtils.java b/src/main/java/io/github/moulberry/notenoughupdates/core/util/lerp/LerpUtils.java
index 73287f05..7e401959 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/util/lerp/LerpUtils.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/util/lerp/LerpUtils.java
@@ -1,26 +1,24 @@
package io.github.moulberry.notenoughupdates.core.util.lerp;
public class LerpUtils {
+ public static float clampZeroOne(float f) {
+ return Math.max(0, Math.min(1, f));
+ }
- public static float clampZeroOne(float f) {
- return Math.max(0, Math.min(1, f));
- }
+ public static float sigmoid(float val) {
+ return (float) (1 / (1 + Math.exp(-val)));
+ }
- public static float sigmoid(float val) {
- return (float)(1/(1 + Math.exp(-val)));
- }
-
- private static final float sigmoidStr = 8;
- private static final float sigmoidA = -1/(sigmoid(-0.5f * sigmoidStr) - sigmoid(0.5f * sigmoidStr));
- private static final float sigmoidB = sigmoidA*sigmoid(-0.5f * sigmoidStr);
- public static float sigmoidZeroOne(float f) {
- f = clampZeroOne(f);
- return sigmoidA*sigmoid(sigmoidStr*(f-0.5f))-sigmoidB;
- }
-
- public static float lerp(float a, float b, float amount) {
- return b + (a - b) * clampZeroOne(amount);
- }
+ private static final float sigmoidStr = 8;
+ private static final float sigmoidA = -1 / (sigmoid(-0.5f * sigmoidStr) - sigmoid(0.5f * sigmoidStr));
+ private static final float sigmoidB = sigmoidA * sigmoid(-0.5f * sigmoidStr);
+ public static float sigmoidZeroOne(float f) {
+ f = clampZeroOne(f);
+ return sigmoidA * sigmoid(sigmoidStr * (f - 0.5f)) - sigmoidB;
+ }
+ public static float lerp(float a, float b, float amount) {
+ return b + (a - b) * clampZeroOne(amount);
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/util/lerp/LerpingFloat.java b/src/main/java/io/github/moulberry/notenoughupdates/core/util/lerp/LerpingFloat.java
index 250facfc..3d9e7787 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/util/lerp/LerpingFloat.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/util/lerp/LerpingFloat.java
@@ -1,68 +1,67 @@
package io.github.moulberry.notenoughupdates.core.util.lerp;
public class LerpingFloat {
-
- private int timeSpent;
- private long lastMillis;
- private int timeToReachTarget;
-
- private float targetValue;
- private float lerpValue;
-
- public LerpingFloat(float initialValue, int timeToReachTarget) {
- this.targetValue = this.lerpValue = initialValue;
- this.timeToReachTarget = timeToReachTarget;
- }
-
- public LerpingFloat(int initialValue) {
- this(initialValue, 200);
- }
-
- public void tick() {
- int lastTimeSpent = timeSpent;
- this.timeSpent += System.currentTimeMillis() - lastMillis;
-
- float lastDistPercentToTarget = lastTimeSpent/(float)timeToReachTarget;
- float distPercentToTarget = timeSpent/(float)timeToReachTarget;
- float fac = (1-lastDistPercentToTarget)/lastDistPercentToTarget;
-
- float startValue = lerpValue - (targetValue - lerpValue)/fac;
-
- float dist = targetValue - startValue;
- if(dist == 0) return;
-
- float oldLerpValue = lerpValue;
- if(distPercentToTarget >= 1) {
- lerpValue = targetValue;
- } else {
- lerpValue = startValue + dist*distPercentToTarget;
- }
-
- if(lerpValue == oldLerpValue) {
- timeSpent = lastTimeSpent;
- } else {
- this.lastMillis = System.currentTimeMillis();
- }
- }
-
- public void resetTimer() {
- this.timeSpent = 0;
- this.lastMillis = System.currentTimeMillis();
- }
-
- public void setTarget(float targetValue) {
- this.targetValue = targetValue;
- }
-
- public void setValue(float value) {
- this.targetValue = this.lerpValue = value;
- }
-
- public float getValue() {
- return lerpValue;
- }
-
- public float getTarget() {
- return targetValue;
- }
+ private int timeSpent;
+ private long lastMillis;
+ private final int timeToReachTarget;
+
+ private float targetValue;
+ private float lerpValue;
+
+ public LerpingFloat(float initialValue, int timeToReachTarget) {
+ this.targetValue = this.lerpValue = initialValue;
+ this.timeToReachTarget = timeToReachTarget;
+ }
+
+ public LerpingFloat(int initialValue) {
+ this(initialValue, 200);
+ }
+
+ public void tick() {
+ int lastTimeSpent = timeSpent;
+ this.timeSpent += System.currentTimeMillis() - lastMillis;
+
+ float lastDistPercentToTarget = lastTimeSpent / (float) timeToReachTarget;
+ float distPercentToTarget = timeSpent / (float) timeToReachTarget;
+ float fac = (1 - lastDistPercentToTarget) / lastDistPercentToTarget;
+
+ float startValue = lerpValue - (targetValue - lerpValue) / fac;
+
+ float dist = targetValue - startValue;
+ if (dist == 0) return;
+
+ float oldLerpValue = lerpValue;
+ if (distPercentToTarget >= 1) {
+ lerpValue = targetValue;
+ } else {
+ lerpValue = startValue + dist * distPercentToTarget;
+ }
+
+ if (lerpValue == oldLerpValue) {
+ timeSpent = lastTimeSpent;
+ } else {
+ this.lastMillis = System.currentTimeMillis();
+ }
+ }
+
+ public void resetTimer() {
+ this.timeSpent = 0;
+ this.lastMillis = System.currentTimeMillis();
+ }
+
+ public void setTarget(float targetValue) {
+ this.targetValue = targetValue;
+ }
+
+ public void setValue(float value) {
+ this.targetValue = this.lerpValue = value;
+ }
+
+ public float getValue() {
+ return lerpValue;
+ }
+
+ public float getTarget() {
+ return targetValue;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/util/lerp/LerpingInteger.java b/src/main/java/io/github/moulberry/notenoughupdates/core/util/lerp/LerpingInteger.java
index b3dd9d6f..024455fd 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/util/lerp/LerpingInteger.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/util/lerp/LerpingInteger.java
@@ -1,76 +1,75 @@
package io.github.moulberry.notenoughupdates.core.util.lerp;
public class LerpingInteger {
-
- private int timeSpent;
- private long lastMillis;
- private int timeToReachTarget;
-
- private int targetValue;
- private int lerpValue;
-
- public LerpingInteger(int initialValue, int timeToReachTarget) {
- this.targetValue = this.lerpValue = initialValue;
- this.timeToReachTarget = timeToReachTarget;
- }
-
- public LerpingInteger(int initialValue) {
- this(initialValue, 200);
- }
-
- public void tick() {
- int lastTimeSpent = timeSpent;
- this.timeSpent += System.currentTimeMillis() - lastMillis;
-
- float lastDistPercentToTarget = lastTimeSpent/(float)timeToReachTarget;
- float distPercentToTarget = timeSpent/(float)timeToReachTarget;
- float fac = (1-lastDistPercentToTarget)/lastDistPercentToTarget;
-
- int startValue = lerpValue - (int)((targetValue - lerpValue)/fac);
-
- int dist = targetValue - startValue;
- if(dist == 0) return;
-
- int oldLerpValue = lerpValue;
- if(distPercentToTarget >= 1) {
- lerpValue = targetValue;
- } else {
- lerpValue = startValue + (int)(dist*distPercentToTarget);
- }
-
- if(lerpValue == oldLerpValue) {
- timeSpent = lastTimeSpent;
- } else {
- this.lastMillis = System.currentTimeMillis();
- }
- }
-
- public int getTimeSpent() {
- return timeSpent;
- }
-
- public void resetTimer() {
- this.timeSpent = 0;
- this.lastMillis = System.currentTimeMillis();
- }
-
- public void setTimeToReachTarget(int timeToReachTarget) {
- this.timeToReachTarget = timeToReachTarget;
- }
-
- public void setTarget(int targetValue) {
- this.targetValue = targetValue;
- }
-
- public void setValue(int value) {
- this.targetValue = this.lerpValue = value;
- }
-
- public int getValue() {
- return lerpValue;
- }
-
- public int getTarget() {
- return targetValue;
- }
+ private int timeSpent;
+ private long lastMillis;
+ private int timeToReachTarget;
+
+ private int targetValue;
+ private int lerpValue;
+
+ public LerpingInteger(int initialValue, int timeToReachTarget) {
+ this.targetValue = this.lerpValue = initialValue;
+ this.timeToReachTarget = timeToReachTarget;
+ }
+
+ public LerpingInteger(int initialValue) {
+ this(initialValue, 200);
+ }
+
+ public void tick() {
+ int lastTimeSpent = timeSpent;
+ this.timeSpent += System.currentTimeMillis() - lastMillis;
+
+ float lastDistPercentToTarget = lastTimeSpent / (float) timeToReachTarget;
+ float distPercentToTarget = timeSpent / (float) timeToReachTarget;
+ float fac = (1 - lastDistPercentToTarget) / lastDistPercentToTarget;
+
+ int startValue = lerpValue - (int) ((targetValue - lerpValue) / fac);
+
+ int dist = targetValue - startValue;
+ if (dist == 0) return;
+
+ int oldLerpValue = lerpValue;
+ if (distPercentToTarget >= 1) {
+ lerpValue = targetValue;
+ } else {
+ lerpValue = startValue + (int) (dist * distPercentToTarget);
+ }
+
+ if (lerpValue == oldLerpValue) {
+ timeSpent = lastTimeSpent;
+ } else {
+ this.lastMillis = System.currentTimeMillis();
+ }
+ }
+
+ public int getTimeSpent() {
+ return timeSpent;
+ }
+
+ public void resetTimer() {
+ this.timeSpent = 0;
+ this.lastMillis = System.currentTimeMillis();
+ }
+
+ public void setTimeToReachTarget(int timeToReachTarget) {
+ this.timeToReachTarget = timeToReachTarget;
+ }
+
+ public void setTarget(int targetValue) {
+ this.targetValue = targetValue;
+ }
+
+ public void setValue(int value) {
+ this.targetValue = this.lerpValue = value;
+ }
+
+ public int getValue() {
+ return lerpValue;
+ }
+
+ public int getTarget() {
+ return targetValue;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/RenderUtils.java b/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/RenderUtils.java
index 5f0ad94f..9a4607ed 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/RenderUtils.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/RenderUtils.java
@@ -19,376 +19,410 @@ import org.lwjgl.opengl.GL14;
import org.lwjgl.util.vector.Vector3f;
public class RenderUtils {
-
- public static void drawFloatingRectDark(int x, int y, int width, int height) {
- drawFloatingRectDark(x, y, width, height, true);
- }
-
- public static void drawFloatingRectDark(int x, int y, int width, int height, boolean shadow) {
- int alpha = 0xf0000000;
-
- if(OpenGlHelper.isFramebufferEnabled()) {
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- BackgroundBlur.renderBlurredBackground(15, scaledResolution.getScaledWidth(),
- scaledResolution.getScaledHeight(), x, y, width, height, true);
- } else {
- alpha = 0xff000000;
- }
-
- int main = alpha | 0x202026;
- int light = 0xff303036;
- int dark = 0xff101016;
- Gui.drawRect(x, y, x+1, y+height, light); //Left
- Gui.drawRect(x+1, y, x+width, y+1, light); //Top
- Gui.drawRect(x+width-1, y+1, x+width, y+height, dark); //Right
- Gui.drawRect(x+1, y+height-1, x+width-1, y+height, dark); //Bottom
- Gui.drawRect(x+1, y+1, x+width-1, y+height-1, main); //Middle
- if(shadow) {
- Gui.drawRect(x+width, y+2, x+width+2, y+height+2, 0x70000000); //Right shadow
- Gui.drawRect(x+2, y+height, x+width, y+height+2, 0x70000000); //Bottom shadow
- }
- }
-
- public static void drawFloatingRect(int x, int y, int width, int height) {
- drawFloatingRectWithAlpha(x, y, width, height, 0xFF, true);
- }
-
- public static void drawFloatingRectWithAlpha(int x, int y, int width, int height, int alpha, boolean shadow) {
- int main = (alpha << 24) | 0xc0c0c0;
- int light = (alpha << 24) | 0xf0f0f0;
- int dark = (alpha << 24) | 0x909090;
- Gui.drawRect(x, y, x+1, y+height, light); //Left
- Gui.drawRect(x+1, y, x+width, y+1, light); //Top
- Gui.drawRect(x+width-1, y+1, x+width, y+height, dark); //Right
- Gui.drawRect(x+1, y+height-1, x+width-1, y+height, dark); //Bottom
- Gui.drawRect(x+1, y+1, x+width-1, y+height-1, main); //Middle
- if(shadow) {
- Gui.drawRect(x+width, y+2, x+width+2, y+height+2, (alpha*3/5) << 24); //Right shadow
- Gui.drawRect(x+2, y+height, x+width, y+height+2, (alpha*3/5) << 24); //Bottom shadow
- }
- }
-
- public static void drawTexturedRect(float x, float y, float width, float height) {
- drawTexturedRect(x, y, width, height, 0, 1, 0 , 1);
- }
-
- public static void drawTexturedRect(float x, float y, float width, float height, int filter) {
- drawTexturedRect(x, y, width, height, 0, 1, 0 , 1, filter);
- }
-
- public static void drawTexturedRect(float x, float y, float width, float height, float uMin, float uMax, float vMin, float vMax) {
- drawTexturedRect(x, y, width, height, uMin, uMax, vMin , vMax, GL11.GL_NEAREST);
- }
-
- public static void drawTexturedRect(float x, float y, float width, float height, float uMin, float uMax, float vMin, float vMax, int filter) {
- GlStateManager.enableBlend();
- GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
-
- drawTexturedRectNoBlend(x, y, width, height, uMin, uMax, vMin, vMax, filter);
-
- GlStateManager.disableBlend();
- }
-
- public static void drawTexturedRectNoBlend(float x, float y, float width, float height, float uMin, float uMax, float vMin, float vMax, int filter) {
- GlStateManager.enableTexture2D();
-
- GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, filter);
- GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, filter);
-
- Tessellator tessellator = Tessellator.getInstance();
- WorldRenderer worldrenderer = tessellator.getWorldRenderer();
- worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
- worldrenderer
- .pos(x, y+height, 0.0D)
- .tex(uMin, vMax).endVertex();
- worldrenderer
- .pos(x+width, y+height, 0.0D)
- .tex(uMax, vMax).endVertex();
- worldrenderer
- .pos(x+width, y, 0.0D)
- .tex(uMax, vMin).endVertex();
- worldrenderer
- .pos(x, y, 0.0D)
- .tex(uMin, vMin).endVertex();
- tessellator.draw();
-
- GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
- GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
- }
-
- public static void drawGradientRect(int zLevel, int left, int top, int right, int bottom, int startColor, int endColor) {
- float startAlpha = (float)(startColor >> 24 & 255) / 255.0F;
- float startRed = (float)(startColor >> 16 & 255) / 255.0F;
- float startGreen = (float)(startColor >> 8 & 255) / 255.0F;
- float startBlue = (float)(startColor & 255) / 255.0F;
- float endAlpha = (float)(endColor >> 24 & 255) / 255.0F;
- float endRed = (float)(endColor >> 16 & 255) / 255.0F;
- float endGreen = (float)(endColor >> 8 & 255) / 255.0F;
- float endBlue = (float)(endColor & 255) / 255.0F;
-
- GlStateManager.disableTexture2D();
- GlStateManager.enableBlend();
- GlStateManager.disableAlpha();
- GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
- GlStateManager.shadeModel(7425);
-
- Tessellator tessellator = Tessellator.getInstance();
- WorldRenderer worldrenderer = tessellator.getWorldRenderer();
- worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
- worldrenderer.pos(right, top, zLevel).color(startRed, startGreen, startBlue, startAlpha).endVertex();
- worldrenderer.pos(left, top, zLevel).color(startRed, startGreen, startBlue, startAlpha).endVertex();
- worldrenderer.pos(left, bottom, zLevel).color(endRed, endGreen, endBlue, endAlpha).endVertex();
- worldrenderer.pos(right, bottom, zLevel).color(endRed, endGreen, endBlue, endAlpha).endVertex();
- tessellator.draw();
-
- GlStateManager.shadeModel(7424);
- GlStateManager.disableBlend();
- GlStateManager.enableAlpha();
- GlStateManager.enableTexture2D();
- }
-
- private static final ResourceLocation beaconBeam = new ResourceLocation("textures/entity/beacon_beam.png");
-
- private static void renderBeaconBeam(double x, double y, double z, int rgb, float alphaMult,
- float partialTicks, Boolean disableDepth) {
- int height = 300;
- int bottomOffset = 0;
- int topOffset = bottomOffset + height;
-
- Tessellator tessellator = Tessellator.getInstance();
- WorldRenderer worldrenderer = tessellator.getWorldRenderer();
-
- if (disableDepth) {
- GlStateManager.disableDepth();
- }
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(beaconBeam);
- GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
- GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);
- GlStateManager.disableLighting();
- GlStateManager.enableCull();
- GlStateManager.enableTexture2D();
- GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE, GL11.GL_ZERO);
- GlStateManager.enableBlend();
- GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
-
- double time = Minecraft.getMinecraft().theWorld.getTotalWorldTime() + (double)partialTicks;
- double d1 = MathHelper.func_181162_h(-time * 0.2D - (double)MathHelper.floor_double(-time * 0.1D));
-
- float r = ((rgb >> 16) & 0xFF) / 255f;
- float g = ((rgb >> 8) & 0xFF) / 255f;
- float b = (rgb & 0xFF) / 255f;
- double d2 = time * 0.025D * -1.5D;
- double d4 = 0.5D + Math.cos(d2 + 2.356194490192345D) * 0.2D;
- double d5 = 0.5D + Math.sin(d2 + 2.356194490192345D) * 0.2D;
- double d6 = 0.5D + Math.cos(d2 + (Math.PI / 4D)) * 0.2D;
- double d7 = 0.5D + Math.sin(d2 + (Math.PI / 4D)) * 0.2D;
- double d8 = 0.5D + Math.cos(d2 + 3.9269908169872414D) * 0.2D;
- double d9 = 0.5D + Math.sin(d2 + 3.9269908169872414D) * 0.2D;
- double d10 = 0.5D + Math.cos(d2 + 5.497787143782138D) * 0.2D;
- double d11 = 0.5D + Math.sin(d2 + 5.497787143782138D) * 0.2D;
- double d14 = -1.0D + d1;
- double d15 = (double)(height) * 2.5D + d14;
- worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
- worldrenderer.pos(x + d4, y + topOffset, z + d5).tex(1.0D, d15).color(r, g, b, 1.0F*alphaMult).endVertex();
- worldrenderer.pos(x + d4, y + bottomOffset, z + d5).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex();
- worldrenderer.pos(x + d6, y + bottomOffset, z + d7).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex();
- worldrenderer.pos(x + d6, y + topOffset, z + d7).tex(0.0D, d15).color(r, g, b, 1.0F*alphaMult).endVertex();
- worldrenderer.pos(x + d10, y + topOffset, z + d11).tex(1.0D, d15).color(r, g, b, 1.0F*alphaMult).endVertex();
- worldrenderer.pos(x + d10, y + bottomOffset, z + d11).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex();
- worldrenderer.pos(x + d8, y + bottomOffset, z + d9).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex();
- worldrenderer.pos(x + d8, y + topOffset, z + d9).tex(0.0D, d15).color(r, g, b, 1.0F*alphaMult).endVertex();
- worldrenderer.pos(x + d6, y + topOffset, z + d7).tex(1.0D, d15).color(r, g, b, 1.0F*alphaMult).endVertex();
- worldrenderer.pos(x + d6, y + bottomOffset, z + d7).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex();
- worldrenderer.pos(x + d10, y + bottomOffset, z + d11).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex();
- worldrenderer.pos(x + d10, y + topOffset, z + d11).tex(0.0D, d15).color(r, g, b, 1.0F*alphaMult).endVertex();
- worldrenderer.pos(x + d8, y + topOffset, z + d9).tex(1.0D, d15).color(r, g, b, 1.0F*alphaMult).endVertex();
- worldrenderer.pos(x + d8, y + bottomOffset, z + d9).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex();
- worldrenderer.pos(x + d4, y + bottomOffset, z + d5).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex();
- worldrenderer.pos(x + d4, y + topOffset, z + d5).tex(0.0D, d15).color(r, g, b, 1.0F*alphaMult).endVertex();
- tessellator.draw();
-
- GlStateManager.disableCull();
- double d12 = -1.0D + d1;
- double d13 = height + d12;
-
- worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
- worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.2D).tex(1.0D, d13).color(r, g, b, 0.25F*alphaMult).endVertex();
- worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.2D).tex(1.0D, d12).color(r, g, b, 0.25F).endVertex();
- worldrenderer.pos(x + 0.8D, y + bottomOffset, z + 0.2D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex();
- worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.2D).tex(0.0D, d13).color(r, g, b, 0.25F*alphaMult).endVertex();
- worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.8D).tex(1.0D, d13).color(r, g, b, 0.25F*alphaMult).endVertex();
- worldrenderer.pos(x + 0.8D, y + bottomOffset, z + 0.8D).tex(1.0D, d12).color(r, g, b, 0.25F).endVertex();
- worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.8D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex();
- worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.8D).tex(0.0D, d13).color(r, g, b, 0.25F*alphaMult).endVertex();
- worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.2D).tex(1.0D, d13).color(r, g, b, 0.25F*alphaMult).endVertex();
- worldrenderer.pos(x + 0.8D, y + bottomOffset, z + 0.2D).tex(1.0D, d12).color(r, g, b, 0.25F).endVertex();
- worldrenderer.pos(x + 0.8D, y + bottomOffset, z + 0.8D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex();
- worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.8D).tex(0.0D, d13).color(r, g, b, 0.25F*alphaMult).endVertex();
- worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.8D).tex(1.0D, d13).color(r, g, b, 0.25F*alphaMult).endVertex();
- worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.8D).tex(1.0D, d12).color(r, g, b, 0.25F).endVertex();
- worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.2D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex();
- worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.2D).tex(0.0D, d13).color(r, g, b, 0.25F*alphaMult).endVertex();
- tessellator.draw();
-
- GlStateManager.disableLighting();
- GlStateManager.enableTexture2D();
- if (disableDepth) {
- GlStateManager.enableDepth();
- }
- }
-
- private static void renderBoundingBox(double x, double y, double z, int rgb, float alphaMult, float partialTicks) {
- AxisAlignedBB bb = new AxisAlignedBB(x, y, z, x+1, y+1, z+1);
-
- GlStateManager.disableDepth();
- GlStateManager.disableCull();
- GlStateManager.disableTexture2D();
- CustomItemEffects.drawFilledBoundingBox(bb, 1f, SpecialColour.special(0, 100, rgb));
- GlStateManager.enableTexture2D();
- GlStateManager.enableCull();
- GlStateManager.enableDepth();
- }
-
- public static void renderBeaconBeam(BlockPos block, int rgb, float alphaMult, float partialTicks) {
- double viewerX;
- double viewerY;
- double viewerZ;
-
- Vector3f aoteInterpPos = CustomItemEffects.INSTANCE.getCurrentPosition();
- if(aoteInterpPos != null) {
- viewerX = aoteInterpPos.x;
- viewerY = aoteInterpPos.y;
- viewerZ = aoteInterpPos.z;
- } else {
- Entity viewer = Minecraft.getMinecraft().getRenderViewEntity();
- viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * partialTicks;
- viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * partialTicks;
- viewerZ = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * partialTicks;
- }
-
- double x = block.getX() - viewerX;
- double y = block.getY() - viewerY;
- double z = block.getZ() - viewerZ;
-
- double distSq = x*x + y*y + z*z;
-
- if(distSq > 10*10) {
- RenderUtils.renderBeaconBeam(x, y, z, rgb, 1.0f, partialTicks, true);
- } else {
- RenderUtils.renderBeaconBeam(x, y, z, rgb, 1.0f, partialTicks, false);
- }
- }
-
- public static void renderBeaconBeamOrBoundingBox(BlockPos block, int rgb, float alphaMult, float partialTicks) {
- double viewerX;
- double viewerY;
- double viewerZ;
-
- Vector3f aoteInterpPos = CustomItemEffects.INSTANCE.getCurrentPosition();
- if(aoteInterpPos != null) {
- viewerX = aoteInterpPos.x;
- viewerY = aoteInterpPos.y;
- viewerZ = aoteInterpPos.z;
- } else {
- Entity viewer = Minecraft.getMinecraft().getRenderViewEntity();
- viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * partialTicks;
- viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * partialTicks;
- viewerZ = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * partialTicks;
- }
-
- double x = block.getX() - viewerX;
- double y = block.getY() - viewerY;
- double z = block.getZ() - viewerZ;
-
- double distSq = x*x + y*y + z*z;
-
- if(distSq > 10*10) {
- RenderUtils.renderBeaconBeam(x, y, z, rgb, 1.0f, partialTicks, true);
- } else {
- RenderUtils.renderBoundingBox(x, y, z, rgb, 1.0f, partialTicks);
- }
- }
-
- public static void renderWayPoint(String str, BlockPos loc, float partialTicks) {
- renderWayPoint(str, new Vector3f(loc.getX(), loc.getY(), loc.getZ()), partialTicks);
- }
-
- public static void renderWayPoint(String str, Vector3f loc, float partialTicks) {
- GlStateManager.alphaFunc(516, 0.1F);
-
- GlStateManager.pushMatrix();
-
- Entity viewer = Minecraft.getMinecraft().getRenderViewEntity();
- double viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * partialTicks;
- double viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * partialTicks;
- double viewerZ = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * partialTicks;
-
- double x = loc.x-viewerX+0.5f;
- double y = loc.y-viewerY-viewer.getEyeHeight();
- double z = loc.z-viewerZ+0.5f;
-
- double distSq = x*x + y*y + z*z;
- double dist = Math.sqrt(distSq);
- if(distSq > 144) {
- x *= 12/dist;
- y *= 12/dist;
- z *= 12/dist;
- }
- GlStateManager.translate(x, y, z);
- GlStateManager.translate(0, viewer.getEyeHeight(), 0);
-
- renderNametag(str);
-
- GlStateManager.rotate(-Minecraft.getMinecraft().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F);
- GlStateManager.rotate(Minecraft.getMinecraft().getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F);
- GlStateManager.translate(0, -0.25f, 0);
- GlStateManager.rotate(-Minecraft.getMinecraft().getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F);
- GlStateManager.rotate(Minecraft.getMinecraft().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F);
-
- renderNametag(EnumChatFormatting.YELLOW.toString()+Math.round(dist)+"m");
-
- GlStateManager.popMatrix();
-
- GlStateManager.disableLighting();
- }
-
- public static void renderNametag(String str) {
- FontRenderer fontrenderer = Minecraft.getMinecraft().fontRendererObj;
- float f = 1.6F;
- float f1 = 0.016666668F * f;
- GlStateManager.pushMatrix();
- GL11.glNormal3f(0.0F, 1.0F, 0.0F);
- GlStateManager.rotate(-Minecraft.getMinecraft().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F);
- GlStateManager.rotate(Minecraft.getMinecraft().getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F);
- GlStateManager.scale(-f1, -f1, f1);
- GlStateManager.disableLighting();
- GlStateManager.depthMask(false);
- GlStateManager.disableDepth();
- GlStateManager.enableBlend();
- GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
- Tessellator tessellator = Tessellator.getInstance();
- WorldRenderer worldrenderer = tessellator.getWorldRenderer();
- int i = 0;
-
- int j = fontrenderer.getStringWidth(str) / 2;
- GlStateManager.disableTexture2D();
- worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
- worldrenderer.pos((double)(-j - 1), (double)(-1 + i), 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
- worldrenderer.pos((double)(-j - 1), (double)(8 + i), 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
- worldrenderer.pos((double)(j + 1), (double)(8 + i), 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
- worldrenderer.pos((double)(j + 1), (double)(-1 + i), 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
- tessellator.draw();
- GlStateManager.enableTexture2D();
- fontrenderer.drawString(str, -fontrenderer.getStringWidth(str) / 2, i, 553648127);
- GlStateManager.depthMask(true);
-
- fontrenderer.drawString(str, -fontrenderer.getStringWidth(str) / 2, i, -1);
-
- GlStateManager.enableDepth();
- GlStateManager.enableBlend();
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
- GlStateManager.popMatrix();
- }
-
+ public static void drawFloatingRectDark(int x, int y, int width, int height) {
+ drawFloatingRectDark(x, y, width, height, true);
+ }
+
+ public static void drawFloatingRectDark(int x, int y, int width, int height, boolean shadow) {
+ int alpha = 0xf0000000;
+
+ if (OpenGlHelper.isFramebufferEnabled()) {
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ BackgroundBlur.renderBlurredBackground(15, scaledResolution.getScaledWidth(),
+ scaledResolution.getScaledHeight(), x, y, width, height, true
+ );
+ } else {
+ alpha = 0xff000000;
+ }
+
+ int main = alpha | 0x202026;
+ int light = 0xff303036;
+ int dark = 0xff101016;
+ Gui.drawRect(x, y, x + 1, y + height, light); //Left
+ Gui.drawRect(x + 1, y, x + width, y + 1, light); //Top
+ Gui.drawRect(x + width - 1, y + 1, x + width, y + height, dark); //Right
+ Gui.drawRect(x + 1, y + height - 1, x + width - 1, y + height, dark); //Bottom
+ Gui.drawRect(x + 1, y + 1, x + width - 1, y + height - 1, main); //Middle
+ if (shadow) {
+ Gui.drawRect(x + width, y + 2, x + width + 2, y + height + 2, 0x70000000); //Right shadow
+ Gui.drawRect(x + 2, y + height, x + width, y + height + 2, 0x70000000); //Bottom shadow
+ }
+ }
+
+ public static void drawFloatingRect(int x, int y, int width, int height) {
+ drawFloatingRectWithAlpha(x, y, width, height, 0xFF, true);
+ }
+
+ public static void drawFloatingRectWithAlpha(int x, int y, int width, int height, int alpha, boolean shadow) {
+ int main = (alpha << 24) | 0xc0c0c0;
+ int light = (alpha << 24) | 0xf0f0f0;
+ int dark = (alpha << 24) | 0x909090;
+ Gui.drawRect(x, y, x + 1, y + height, light); //Left
+ Gui.drawRect(x + 1, y, x + width, y + 1, light); //Top
+ Gui.drawRect(x + width - 1, y + 1, x + width, y + height, dark); //Right
+ Gui.drawRect(x + 1, y + height - 1, x + width - 1, y + height, dark); //Bottom
+ Gui.drawRect(x + 1, y + 1, x + width - 1, y + height - 1, main); //Middle
+ if (shadow) {
+ Gui.drawRect(x + width, y + 2, x + width + 2, y + height + 2, (alpha * 3 / 5) << 24); //Right shadow
+ Gui.drawRect(x + 2, y + height, x + width, y + height + 2, (alpha * 3 / 5) << 24); //Bottom shadow
+ }
+ }
+
+ public static void drawTexturedRect(float x, float y, float width, float height) {
+ drawTexturedRect(x, y, width, height, 0, 1, 0, 1);
+ }
+
+ public static void drawTexturedRect(float x, float y, float width, float height, int filter) {
+ drawTexturedRect(x, y, width, height, 0, 1, 0, 1, filter);
+ }
+
+ public static void drawTexturedRect(
+ float x,
+ float y,
+ float width,
+ float height,
+ float uMin,
+ float uMax,
+ float vMin,
+ float vMax
+ ) {
+ drawTexturedRect(x, y, width, height, uMin, uMax, vMin, vMax, GL11.GL_NEAREST);
+ }
+
+ public static void drawTexturedRect(
+ float x,
+ float y,
+ float width,
+ float height,
+ float uMin,
+ float uMax,
+ float vMin,
+ float vMax,
+ int filter
+ ) {
+ GlStateManager.enableBlend();
+ GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
+
+ drawTexturedRectNoBlend(x, y, width, height, uMin, uMax, vMin, vMax, filter);
+
+ GlStateManager.disableBlend();
+ }
+
+ public static void drawTexturedRectNoBlend(
+ float x,
+ float y,
+ float width,
+ float height,
+ float uMin,
+ float uMax,
+ float vMin,
+ float vMax,
+ int filter
+ ) {
+ GlStateManager.enableTexture2D();
+
+ GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, filter);
+ GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, filter);
+
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+ worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
+ worldrenderer
+ .pos(x, y + height, 0.0D)
+ .tex(uMin, vMax).endVertex();
+ worldrenderer
+ .pos(x + width, y + height, 0.0D)
+ .tex(uMax, vMax).endVertex();
+ worldrenderer
+ .pos(x + width, y, 0.0D)
+ .tex(uMax, vMin).endVertex();
+ worldrenderer
+ .pos(x, y, 0.0D)
+ .tex(uMin, vMin).endVertex();
+ tessellator.draw();
+
+ GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
+ GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
+ }
+
+ public static void drawGradientRect(
+ int zLevel,
+ int left,
+ int top,
+ int right,
+ int bottom,
+ int startColor,
+ int endColor
+ ) {
+ float startAlpha = (float) (startColor >> 24 & 255) / 255.0F;
+ float startRed = (float) (startColor >> 16 & 255) / 255.0F;
+ float startGreen = (float) (startColor >> 8 & 255) / 255.0F;
+ float startBlue = (float) (startColor & 255) / 255.0F;
+ float endAlpha = (float) (endColor >> 24 & 255) / 255.0F;
+ float endRed = (float) (endColor >> 16 & 255) / 255.0F;
+ float endGreen = (float) (endColor >> 8 & 255) / 255.0F;
+ float endBlue = (float) (endColor & 255) / 255.0F;
+
+ GlStateManager.disableTexture2D();
+ GlStateManager.enableBlend();
+ GlStateManager.disableAlpha();
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+ GlStateManager.shadeModel(7425);
+
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+ worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
+ worldrenderer.pos(right, top, zLevel).color(startRed, startGreen, startBlue, startAlpha).endVertex();
+ worldrenderer.pos(left, top, zLevel).color(startRed, startGreen, startBlue, startAlpha).endVertex();
+ worldrenderer.pos(left, bottom, zLevel).color(endRed, endGreen, endBlue, endAlpha).endVertex();
+ worldrenderer.pos(right, bottom, zLevel).color(endRed, endGreen, endBlue, endAlpha).endVertex();
+ tessellator.draw();
+
+ GlStateManager.shadeModel(7424);
+ GlStateManager.disableBlend();
+ GlStateManager.enableAlpha();
+ GlStateManager.enableTexture2D();
+ }
+
+ private static final ResourceLocation beaconBeam = new ResourceLocation("textures/entity/beacon_beam.png");
+
+ private static void renderBeaconBeam(
+ double x, double y, double z, int rgb, float alphaMult,
+ float partialTicks, Boolean disableDepth
+ ) {
+ int height = 300;
+ int bottomOffset = 0;
+ int topOffset = bottomOffset + height;
+
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+
+ if (disableDepth) {
+ GlStateManager.disableDepth();
+ }
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(beaconBeam);
+ GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
+ GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);
+ GlStateManager.disableLighting();
+ GlStateManager.enableCull();
+ GlStateManager.enableTexture2D();
+ GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE, GL11.GL_ZERO);
+ GlStateManager.enableBlend();
+ GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
+
+ double time = Minecraft.getMinecraft().theWorld.getTotalWorldTime() + (double) partialTicks;
+ double d1 = MathHelper.func_181162_h(-time * 0.2D - (double) MathHelper.floor_double(-time * 0.1D));
+
+ float r = ((rgb >> 16) & 0xFF) / 255f;
+ float g = ((rgb >> 8) & 0xFF) / 255f;
+ float b = (rgb & 0xFF) / 255f;
+ double d2 = time * 0.025D * -1.5D;
+ double d4 = 0.5D + Math.cos(d2 + 2.356194490192345D) * 0.2D;
+ double d5 = 0.5D + Math.sin(d2 + 2.356194490192345D) * 0.2D;
+ double d6 = 0.5D + Math.cos(d2 + (Math.PI / 4D)) * 0.2D;
+ double d7 = 0.5D + Math.sin(d2 + (Math.PI / 4D)) * 0.2D;
+ double d8 = 0.5D + Math.cos(d2 + 3.9269908169872414D) * 0.2D;
+ double d9 = 0.5D + Math.sin(d2 + 3.9269908169872414D) * 0.2D;
+ double d10 = 0.5D + Math.cos(d2 + 5.497787143782138D) * 0.2D;
+ double d11 = 0.5D + Math.sin(d2 + 5.497787143782138D) * 0.2D;
+ double d14 = -1.0D + d1;
+ double d15 = (double) (height) * 2.5D + d14;
+ worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
+ worldrenderer.pos(x + d4, y + topOffset, z + d5).tex(1.0D, d15).color(r, g, b, 1.0F * alphaMult).endVertex();
+ worldrenderer.pos(x + d4, y + bottomOffset, z + d5).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex();
+ worldrenderer.pos(x + d6, y + bottomOffset, z + d7).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex();
+ worldrenderer.pos(x + d6, y + topOffset, z + d7).tex(0.0D, d15).color(r, g, b, 1.0F * alphaMult).endVertex();
+ worldrenderer.pos(x + d10, y + topOffset, z + d11).tex(1.0D, d15).color(r, g, b, 1.0F * alphaMult).endVertex();
+ worldrenderer.pos(x + d10, y + bottomOffset, z + d11).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex();
+ worldrenderer.pos(x + d8, y + bottomOffset, z + d9).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex();
+ worldrenderer.pos(x + d8, y + topOffset, z + d9).tex(0.0D, d15).color(r, g, b, 1.0F * alphaMult).endVertex();
+ worldrenderer.pos(x + d6, y + topOffset, z + d7).tex(1.0D, d15).color(r, g, b, 1.0F * alphaMult).endVertex();
+ worldrenderer.pos(x + d6, y + bottomOffset, z + d7).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex();
+ worldrenderer.pos(x + d10, y + bottomOffset, z + d11).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex();
+ worldrenderer.pos(x + d10, y + topOffset, z + d11).tex(0.0D, d15).color(r, g, b, 1.0F * alphaMult).endVertex();
+ worldrenderer.pos(x + d8, y + topOffset, z + d9).tex(1.0D, d15).color(r, g, b, 1.0F * alphaMult).endVertex();
+ worldrenderer.pos(x + d8, y + bottomOffset, z + d9).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex();
+ worldrenderer.pos(x + d4, y + bottomOffset, z + d5).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex();
+ worldrenderer.pos(x + d4, y + topOffset, z + d5).tex(0.0D, d15).color(r, g, b, 1.0F * alphaMult).endVertex();
+ tessellator.draw();
+
+ GlStateManager.disableCull();
+ double d12 = -1.0D + d1;
+ double d13 = height + d12;
+
+ worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
+ worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.2D).tex(1.0D, d13).color(r, g, b, 0.25F * alphaMult).endVertex();
+ worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.2D).tex(1.0D, d12).color(r, g, b, 0.25F).endVertex();
+ worldrenderer.pos(x + 0.8D, y + bottomOffset, z + 0.2D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex();
+ worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.2D).tex(0.0D, d13).color(r, g, b, 0.25F * alphaMult).endVertex();
+ worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.8D).tex(1.0D, d13).color(r, g, b, 0.25F * alphaMult).endVertex();
+ worldrenderer.pos(x + 0.8D, y + bottomOffset, z + 0.8D).tex(1.0D, d12).color(r, g, b, 0.25F).endVertex();
+ worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.8D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex();
+ worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.8D).tex(0.0D, d13).color(r, g, b, 0.25F * alphaMult).endVertex();
+ worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.2D).tex(1.0D, d13).color(r, g, b, 0.25F * alphaMult).endVertex();
+ worldrenderer.pos(x + 0.8D, y + bottomOffset, z + 0.2D).tex(1.0D, d12).color(r, g, b, 0.25F).endVertex();
+ worldrenderer.pos(x + 0.8D, y + bottomOffset, z + 0.8D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex();
+ worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.8D).tex(0.0D, d13).color(r, g, b, 0.25F * alphaMult).endVertex();
+ worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.8D).tex(1.0D, d13).color(r, g, b, 0.25F * alphaMult).endVertex();
+ worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.8D).tex(1.0D, d12).color(r, g, b, 0.25F).endVertex();
+ worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.2D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex();
+ worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.2D).tex(0.0D, d13).color(r, g, b, 0.25F * alphaMult).endVertex();
+ tessellator.draw();
+
+ GlStateManager.disableLighting();
+ GlStateManager.enableTexture2D();
+ if (disableDepth) {
+ GlStateManager.enableDepth();
+ }
+ }
+
+ private static void renderBoundingBox(double x, double y, double z, int rgb, float alphaMult, float partialTicks) {
+ AxisAlignedBB bb = new AxisAlignedBB(x, y, z, x + 1, y + 1, z + 1);
+
+ GlStateManager.disableDepth();
+ GlStateManager.disableCull();
+ GlStateManager.disableTexture2D();
+ CustomItemEffects.drawFilledBoundingBox(bb, 1f, SpecialColour.special(0, 100, rgb));
+ GlStateManager.enableTexture2D();
+ GlStateManager.enableCull();
+ GlStateManager.enableDepth();
+ }
+
+ public static void renderBeaconBeam(BlockPos block, int rgb, float alphaMult, float partialTicks) {
+ double viewerX;
+ double viewerY;
+ double viewerZ;
+
+ Vector3f aoteInterpPos = CustomItemEffects.INSTANCE.getCurrentPosition();
+ if (aoteInterpPos != null) {
+ viewerX = aoteInterpPos.x;
+ viewerY = aoteInterpPos.y;
+ viewerZ = aoteInterpPos.z;
+ } else {
+ Entity viewer = Minecraft.getMinecraft().getRenderViewEntity();
+ viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * partialTicks;
+ viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * partialTicks;
+ viewerZ = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * partialTicks;
+ }
+
+ double x = block.getX() - viewerX;
+ double y = block.getY() - viewerY;
+ double z = block.getZ() - viewerZ;
+
+ double distSq = x * x + y * y + z * z;
+
+ RenderUtils.renderBeaconBeam(x, y, z, rgb, 1.0f, partialTicks, distSq > 10 * 10);
+ }
+
+ public static void renderBeaconBeamOrBoundingBox(BlockPos block, int rgb, float alphaMult, float partialTicks) {
+ double viewerX;
+ double viewerY;
+ double viewerZ;
+
+ Vector3f aoteInterpPos = CustomItemEffects.INSTANCE.getCurrentPosition();
+ if (aoteInterpPos != null) {
+ viewerX = aoteInterpPos.x;
+ viewerY = aoteInterpPos.y;
+ viewerZ = aoteInterpPos.z;
+ } else {
+ Entity viewer = Minecraft.getMinecraft().getRenderViewEntity();
+ viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * partialTicks;
+ viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * partialTicks;
+ viewerZ = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * partialTicks;
+ }
+
+ double x = block.getX() - viewerX;
+ double y = block.getY() - viewerY;
+ double z = block.getZ() - viewerZ;
+
+ double distSq = x * x + y * y + z * z;
+
+ if (distSq > 10 * 10) {
+ RenderUtils.renderBeaconBeam(x, y, z, rgb, 1.0f, partialTicks, true);
+ } else {
+ RenderUtils.renderBoundingBox(x, y, z, rgb, 1.0f, partialTicks);
+ }
+ }
+
+ public static void renderWayPoint(String str, BlockPos loc, float partialTicks) {
+ renderWayPoint(str, new Vector3f(loc.getX(), loc.getY(), loc.getZ()), partialTicks);
+ }
+
+ public static void renderWayPoint(String str, Vector3f loc, float partialTicks) {
+ GlStateManager.alphaFunc(516, 0.1F);
+
+ GlStateManager.pushMatrix();
+
+ Entity viewer = Minecraft.getMinecraft().getRenderViewEntity();
+ double viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * partialTicks;
+ double viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * partialTicks;
+ double viewerZ = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * partialTicks;
+
+ double x = loc.x - viewerX + 0.5f;
+ double y = loc.y - viewerY - viewer.getEyeHeight();
+ double z = loc.z - viewerZ + 0.5f;
+
+ double distSq = x * x + y * y + z * z;
+ double dist = Math.sqrt(distSq);
+ if (distSq > 144) {
+ x *= 12 / dist;
+ y *= 12 / dist;
+ z *= 12 / dist;
+ }
+ GlStateManager.translate(x, y, z);
+ GlStateManager.translate(0, viewer.getEyeHeight(), 0);
+
+ renderNametag(str);
+
+ GlStateManager.rotate(-Minecraft.getMinecraft().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F);
+ GlStateManager.rotate(Minecraft.getMinecraft().getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F);
+ GlStateManager.translate(0, -0.25f, 0);
+ GlStateManager.rotate(-Minecraft.getMinecraft().getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F);
+ GlStateManager.rotate(Minecraft.getMinecraft().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F);
+
+ renderNametag(EnumChatFormatting.YELLOW.toString() + Math.round(dist) + "m");
+
+ GlStateManager.popMatrix();
+
+ GlStateManager.disableLighting();
+ }
+
+ public static void renderNametag(String str) {
+ FontRenderer fontrenderer = Minecraft.getMinecraft().fontRendererObj;
+ float f = 1.6F;
+ float f1 = 0.016666668F * f;
+ GlStateManager.pushMatrix();
+ GL11.glNormal3f(0.0F, 1.0F, 0.0F);
+ GlStateManager.rotate(-Minecraft.getMinecraft().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F);
+ GlStateManager.rotate(Minecraft.getMinecraft().getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F);
+ GlStateManager.scale(-f1, -f1, f1);
+ GlStateManager.disableLighting();
+ GlStateManager.depthMask(false);
+ GlStateManager.disableDepth();
+ GlStateManager.enableBlend();
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+ int i = 0;
+
+ int j = fontrenderer.getStringWidth(str) / 2;
+ GlStateManager.disableTexture2D();
+ worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
+ worldrenderer.pos(-j - 1, -1 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
+ worldrenderer.pos(-j - 1, 8 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
+ worldrenderer.pos(j + 1, 8 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
+ worldrenderer.pos(j + 1, -1 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
+ tessellator.draw();
+ GlStateManager.enableTexture2D();
+ fontrenderer.drawString(str, -fontrenderer.getStringWidth(str) / 2, i, 553648127);
+ GlStateManager.depthMask(true);
+
+ fontrenderer.drawString(str, -fontrenderer.getStringWidth(str) / 2, i, -1);
+
+ GlStateManager.enableDepth();
+ GlStateManager.enableBlend();
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ GlStateManager.popMatrix();
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/TextRenderUtils.java b/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/TextRenderUtils.java
index 541fd67a..ff7ac53a 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/TextRenderUtils.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/util/render/TextRenderUtils.java
@@ -13,203 +13,314 @@ import java.util.ArrayList;
import java.util.List;
public class TextRenderUtils {
-
- public static int getCharVertLen(char c) {
- if("acegmnopqrsuvwxyz".indexOf(c) >= 0) {
- return 5;
- } else {
- return 7;
- }
- }
-
- public static float getVerticalHeight(String str) {
- str = StringUtils.cleanColour(str);
- float height = 0;
- for(int i=0; i<str.length(); i++) {
- char c = str.charAt(i);
- int charHeight = getCharVertLen(c);
- height += charHeight + 1.5f;
- }
- return height;
- }
-
- public static void drawStringVertical(String str, FontRenderer fr, float x, float y, boolean shadow, int colour) {
- String format = FontRenderer.getFormatFromString(str);
- str = StringUtils.cleanColour(str);
- for(int i=0; i<str.length(); i++) {
- char c = str.charAt(i);
-
- int charHeight = getCharVertLen(c);
- int charWidth = fr.getCharWidth(c);
- fr.drawString(format+c, x+(5-charWidth)/2f, y-7+charHeight, colour, shadow);
-
- y += charHeight + 1.5f;
- }
- }
-
- public static void drawStringScaledMaxWidth(String str, FontRenderer fr, float x, float y, boolean shadow, int len, int colour) {
- int strLen = fr.getStringWidth(str);
- float factor = len/(float)strLen;
- factor = Math.min(1, factor);
-
- drawStringScaled(str, fr, x, y, shadow, colour, factor);
- }
-
- public static void drawStringCentered(String str, FontRenderer fr, float x, float y, boolean shadow, int colour) {
- int strLen = fr.getStringWidth(str);
-
- float x2 = x - strLen/2f;
- float y2 = y - fr.FONT_HEIGHT/2f;
-
- GL11.glTranslatef(x2, y2, 0);
- fr.drawString(str, 0, 0, colour, shadow);
- GL11.glTranslatef(-x2, -y2, 0);
- }
-
- public static void drawStringScaled(String str, FontRenderer fr, float x, float y, boolean shadow, int colour, float factor) {
- GlStateManager.scale(factor, factor, 1);
- fr.drawString(str, x/factor, y/factor, colour, shadow);
- GlStateManager.scale(1/factor, 1/factor, 1);
- }
-
- public static void drawStringCenteredScaledMaxWidth(String str, FontRenderer fr, float x, float y, boolean shadow, int len, int colour) {
- int strLen = fr.getStringWidth(str);
- float factor = len/(float)strLen;
- factor = Math.min(1, factor);
- int newLen = Math.min(strLen, len);
-
- float fontHeight = 8*factor;
-
- drawStringScaled(str, fr, x-newLen/2, y-fontHeight/2, shadow, colour, factor);
- }
-
- public static void renderToolTip(ItemStack stack, int mouseX, int mouseY, int screenWidth, int screenHeight, FontRenderer fontStd) {
- List<String> list = stack.getTooltip(Minecraft.getMinecraft().thePlayer,
- Minecraft.getMinecraft().gameSettings.advancedItemTooltips);
-
- for (int i = 0; i < list.size(); ++i) {
- if (i == 0) {
- list.set(i, stack.getRarity().rarityColor + list.get(i));
- } else {
- list.set(i, EnumChatFormatting.GRAY + list.get(i));
- }
- }
-
- FontRenderer font = stack.getItem().getFontRenderer(stack);
- drawHoveringText(list, mouseX, mouseY, screenWidth, screenHeight, -1, font == null ? fontStd : font);
- }
-
- public static void drawHoveringText(List<String> textLines, final int mouseX, final int mouseY, final int screenWidth, final int screenHeight, final int maxTextWidth, FontRenderer font) {
- if (!textLines.isEmpty()) {
- GlStateManager.disableRescaleNormal();
- RenderHelper.disableStandardItemLighting();
- GlStateManager.disableLighting();
- GlStateManager.disableDepth();
- int tooltipTextWidth = 0;
-
- for (String textLine : textLines) {
- int textLineWidth = font.getStringWidth(textLine);
-
- if (textLineWidth > tooltipTextWidth) {
- tooltipTextWidth = textLineWidth;
- }
- }
-
- boolean needsWrap = false;
-
- int titleLinesCount = 1;
- int tooltipX = mouseX + 12;
- if (tooltipX + tooltipTextWidth + 4 > screenWidth) {
- tooltipX = mouseX - 16 - tooltipTextWidth;
- if (tooltipX < 4) // if the tooltip doesn't fit on the screen
- {
- if (mouseX > screenWidth / 2) {
- tooltipTextWidth = mouseX - 12 - 8;
- } else {
- tooltipTextWidth = screenWidth - 16 - mouseX;
- }
- needsWrap = true;
- }
- }
-
- if (maxTextWidth > 0 && tooltipTextWidth > maxTextWidth) {
- tooltipTextWidth = maxTextWidth;
- needsWrap = true;
- }
-
- if (needsWrap) {
- int wrappedTooltipWidth = 0;
- List<String> wrappedTextLines = new ArrayList<String>();
- for (int i = 0; i < textLines.size(); i++) {
- String textLine = textLines.get(i);
- List<String> wrappedLine = font.listFormattedStringToWidth(textLine, tooltipTextWidth);
- if (i == 0) {
- titleLinesCount = wrappedLine.size();
- }
-
- for (String line : wrappedLine) {
- int lineWidth = font.getStringWidth(line);
- if (lineWidth > wrappedTooltipWidth) {
- wrappedTooltipWidth = lineWidth;
- }
- wrappedTextLines.add(line);
- }
- }
- tooltipTextWidth = wrappedTooltipWidth;
- textLines = wrappedTextLines;
-
- if (mouseX > screenWidth / 2) {
- tooltipX = mouseX - 16 - tooltipTextWidth;
- } else {
- tooltipX = mouseX + 12;
- }
- }
-
- int tooltipY = mouseY - 12;
- int tooltipHeight = 8;
-
- if (textLines.size() > 1) {
- tooltipHeight += (textLines.size() - 1) * 10;
- if (textLines.size() > titleLinesCount) {
- tooltipHeight += 2; // gap between title lines and next lines
- }
- }
-
- if (tooltipY + tooltipHeight + 6 > screenHeight) {
- tooltipY = screenHeight - tooltipHeight - 6;
- }
-
- final int zLevel = 300;
- final int backgroundColor = 0xF0100010;
- RenderUtils.drawGradientRect(zLevel, tooltipX - 3, tooltipY - 4, tooltipX + tooltipTextWidth + 3, tooltipY - 3, backgroundColor, backgroundColor);
- RenderUtils.drawGradientRect(zLevel, tooltipX - 3, tooltipY + tooltipHeight + 3, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 4, backgroundColor, backgroundColor);
- RenderUtils.drawGradientRect(zLevel, tooltipX - 3, tooltipY - 3, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3, backgroundColor, backgroundColor);
- RenderUtils.drawGradientRect(zLevel, tooltipX - 4, tooltipY - 3, tooltipX - 3, tooltipY + tooltipHeight + 3, backgroundColor, backgroundColor);
- RenderUtils.drawGradientRect(zLevel, tooltipX + tooltipTextWidth + 3, tooltipY - 3, tooltipX + tooltipTextWidth + 4, tooltipY + tooltipHeight + 3, backgroundColor, backgroundColor);
- final int borderColorStart = 0x505000FF;
- final int borderColorEnd = (borderColorStart & 0xFEFEFE) >> 1 | borderColorStart & 0xFF000000;
- RenderUtils.drawGradientRect(zLevel, tooltipX - 3, tooltipY - 3 + 1, tooltipX - 3 + 1, tooltipY + tooltipHeight + 3 - 1, borderColorStart, borderColorEnd);
- RenderUtils.drawGradientRect(zLevel, tooltipX + tooltipTextWidth + 2, tooltipY - 3 + 1, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3 - 1, borderColorStart, borderColorEnd);
- RenderUtils.drawGradientRect(zLevel, tooltipX - 3, tooltipY - 3, tooltipX + tooltipTextWidth + 3, tooltipY - 3 + 1, borderColorStart, borderColorStart);
- RenderUtils.drawGradientRect(zLevel, tooltipX - 3, tooltipY + tooltipHeight + 2, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3, borderColorEnd, borderColorEnd);
-
- for (int lineNumber = 0; lineNumber < textLines.size(); ++lineNumber) {
- String line = textLines.get(lineNumber);
- font.drawStringWithShadow(line, (float) tooltipX, (float) tooltipY, -1);
-
- if (lineNumber + 1 == titleLinesCount) {
- tooltipY += 2;
- }
-
- tooltipY += 10;
- }
-
- GlStateManager.enableLighting();
- GlStateManager.enableDepth();
- RenderHelper.enableStandardItemLighting();
- GlStateManager.enableRescaleNormal();
- }
- GlStateManager.disableLighting();
- }
-
+ public static int getCharVertLen(char c) {
+ if ("acegmnopqrsuvwxyz".indexOf(c) >= 0) {
+ return 5;
+ } else {
+ return 7;
+ }
+ }
+
+ public static float getVerticalHeight(String str) {
+ str = StringUtils.cleanColour(str);
+ float height = 0;
+ for (int i = 0; i < str.length(); i++) {
+ char c = str.charAt(i);
+ int charHeight = getCharVertLen(c);
+ height += charHeight + 1.5f;
+ }
+ return height;
+ }
+
+ public static void drawStringVertical(String str, FontRenderer fr, float x, float y, boolean shadow, int colour) {
+ String format = FontRenderer.getFormatFromString(str);
+ str = StringUtils.cleanColour(str);
+ for (int i = 0; i < str.length(); i++) {
+ char c = str.charAt(i);
+
+ int charHeight = getCharVertLen(c);
+ int charWidth = fr.getCharWidth(c);
+ fr.drawString(format + c, x + (5 - charWidth) / 2f, y - 7 + charHeight, colour, shadow);
+
+ y += charHeight + 1.5f;
+ }
+ }
+
+ public static void drawStringScaledMaxWidth(
+ String str,
+ FontRenderer fr,
+ float x,
+ float y,
+ boolean shadow,
+ int len,
+ int colour
+ ) {
+ int strLen = fr.getStringWidth(str);
+ float factor = len / (float) strLen;
+ factor = Math.min(1, factor);
+
+ drawStringScaled(str, fr, x, y, shadow, colour, factor);
+ }
+
+ public static void drawStringCentered(String str, FontRenderer fr, float x, float y, boolean shadow, int colour) {
+ int strLen = fr.getStringWidth(str);
+
+ float x2 = x - strLen / 2f;
+ float y2 = y - fr.FONT_HEIGHT / 2f;
+
+ GL11.glTranslatef(x2, y2, 0);
+ fr.drawString(str, 0, 0, colour, shadow);
+ GL11.glTranslatef(-x2, -y2, 0);
+ }
+
+ public static void drawStringScaled(
+ String str,
+ FontRenderer fr,
+ float x,
+ float y,
+ boolean shadow,
+ int colour,
+ float factor
+ ) {
+ GlStateManager.scale(factor, factor, 1);
+ fr.drawString(str, x / factor, y / factor, colour, shadow);
+ GlStateManager.scale(1 / factor, 1 / factor, 1);
+ }
+
+ public static void drawStringCenteredScaledMaxWidth(
+ String str,
+ FontRenderer fr,
+ float x,
+ float y,
+ boolean shadow,
+ int len,
+ int colour
+ ) {
+ int strLen = fr.getStringWidth(str);
+ float factor = len / (float) strLen;
+ factor = Math.min(1, factor);
+ int newLen = Math.min(strLen, len);
+
+ float fontHeight = 8 * factor;
+
+ drawStringScaled(str, fr, x - newLen / 2, y - fontHeight / 2, shadow, colour, factor);
+ }
+
+ public static void renderToolTip(
+ ItemStack stack,
+ int mouseX,
+ int mouseY,
+ int screenWidth,
+ int screenHeight,
+ FontRenderer fontStd
+ ) {
+ List<String> list = stack.getTooltip(
+ Minecraft.getMinecraft().thePlayer,
+ Minecraft.getMinecraft().gameSettings.advancedItemTooltips
+ );
+
+ for (int i = 0; i < list.size(); ++i) {
+ if (i == 0) {
+ list.set(i, stack.getRarity().rarityColor + list.get(i));
+ } else {
+ list.set(i, EnumChatFormatting.GRAY + list.get(i));
+ }
+ }
+
+ FontRenderer font = stack.getItem().getFontRenderer(stack);
+ drawHoveringText(list, mouseX, mouseY, screenWidth, screenHeight, -1, font == null ? fontStd : font);
+ }
+
+ public static void drawHoveringText(
+ List<String> textLines,
+ final int mouseX,
+ final int mouseY,
+ final int screenWidth,
+ final int screenHeight,
+ final int maxTextWidth,
+ FontRenderer font
+ ) {
+ if (!textLines.isEmpty()) {
+ GlStateManager.disableRescaleNormal();
+ RenderHelper.disableStandardItemLighting();
+ GlStateManager.disableLighting();
+ GlStateManager.disableDepth();
+ int tooltipTextWidth = 0;
+
+ for (String textLine : textLines) {
+ int textLineWidth = font.getStringWidth(textLine);
+
+ if (textLineWidth > tooltipTextWidth) {
+ tooltipTextWidth = textLineWidth;
+ }
+ }
+
+ boolean needsWrap = false;
+
+ int titleLinesCount = 1;
+ int tooltipX = mouseX + 12;
+ if (tooltipX + tooltipTextWidth + 4 > screenWidth) {
+ tooltipX = mouseX - 16 - tooltipTextWidth;
+ if (tooltipX < 4) // if the tooltip doesn't fit on the screen
+ {
+ if (mouseX > screenWidth / 2) {
+ tooltipTextWidth = mouseX - 12 - 8;
+ } else {
+ tooltipTextWidth = screenWidth - 16 - mouseX;
+ }
+ needsWrap = true;
+ }
+ }
+
+ if (maxTextWidth > 0 && tooltipTextWidth > maxTextWidth) {
+ tooltipTextWidth = maxTextWidth;
+ needsWrap = true;
+ }
+
+ if (needsWrap) {
+ int wrappedTooltipWidth = 0;
+ List<String> wrappedTextLines = new ArrayList<>();
+ for (int i = 0; i < textLines.size(); i++) {
+ String textLine = textLines.get(i);
+ List<String> wrappedLine = font.listFormattedStringToWidth(textLine, tooltipTextWidth);
+ if (i == 0) {
+ titleLinesCount = wrappedLine.size();
+ }
+
+ for (String line : wrappedLine) {
+ int lineWidth = font.getStringWidth(line);
+ if (lineWidth > wrappedTooltipWidth) {
+ wrappedTooltipWidth = lineWidth;
+ }
+ wrappedTextLines.add(line);
+ }
+ }
+ tooltipTextWidth = wrappedTooltipWidth;
+ textLines = wrappedTextLines;
+
+ if (mouseX > screenWidth / 2) {
+ tooltipX = mouseX - 16 - tooltipTextWidth;
+ } else {
+ tooltipX = mouseX + 12;
+ }
+ }
+
+ int tooltipY = mouseY - 12;
+ int tooltipHeight = 8;
+
+ if (textLines.size() > 1) {
+ tooltipHeight += (textLines.size() - 1) * 10;
+ if (textLines.size() > titleLinesCount) {
+ tooltipHeight += 2; // gap between title lines and next lines
+ }
+ }
+
+ if (tooltipY + tooltipHeight + 6 > screenHeight) {
+ tooltipY = screenHeight - tooltipHeight - 6;
+ }
+
+ final int zLevel = 300;
+ final int backgroundColor = 0xF0100010;
+ RenderUtils.drawGradientRect(
+ zLevel,
+ tooltipX - 3,
+ tooltipY - 4,
+ tooltipX + tooltipTextWidth + 3,
+ tooltipY - 3,
+ backgroundColor,
+ backgroundColor
+ );
+ RenderUtils.drawGradientRect(
+ zLevel,
+ tooltipX - 3,
+ tooltipY + tooltipHeight + 3,
+ tooltipX + tooltipTextWidth + 3,
+ tooltipY + tooltipHeight + 4,
+ backgroundColor,
+ backgroundColor
+ );
+ RenderUtils.drawGradientRect(
+ zLevel,
+ tooltipX - 3,
+ tooltipY - 3,
+ tooltipX + tooltipTextWidth + 3,
+ tooltipY + tooltipHeight + 3,
+ backgroundColor,
+ backgroundColor
+ );
+ RenderUtils.drawGradientRect(
+ zLevel,
+ tooltipX - 4,
+ tooltipY - 3,
+ tooltipX - 3,
+ tooltipY + tooltipHeight + 3,
+ backgroundColor,
+ backgroundColor
+ );
+ RenderUtils.drawGradientRect(
+ zLevel,
+ tooltipX + tooltipTextWidth + 3,
+ tooltipY - 3,
+ tooltipX + tooltipTextWidth + 4,
+ tooltipY + tooltipHeight + 3,
+ backgroundColor,
+ backgroundColor
+ );
+ final int borderColorStart = 0x505000FF;
+ final int borderColorEnd = (borderColorStart & 0xFEFEFE) >> 1 | borderColorStart & 0xFF000000;
+ RenderUtils.drawGradientRect(
+ zLevel,
+ tooltipX - 3,
+ tooltipY - 3 + 1,
+ tooltipX - 3 + 1,
+ tooltipY + tooltipHeight + 3 - 1,
+ borderColorStart,
+ borderColorEnd
+ );
+ RenderUtils.drawGradientRect(
+ zLevel,
+ tooltipX + tooltipTextWidth + 2,
+ tooltipY - 3 + 1,
+ tooltipX + tooltipTextWidth + 3,
+ tooltipY + tooltipHeight + 3 - 1,
+ borderColorStart,
+ borderColorEnd
+ );
+ RenderUtils.drawGradientRect(
+ zLevel,
+ tooltipX - 3,
+ tooltipY - 3,
+ tooltipX + tooltipTextWidth + 3,
+ tooltipY - 3 + 1,
+ borderColorStart,
+ borderColorStart
+ );
+ RenderUtils.drawGradientRect(
+ zLevel,
+ tooltipX - 3,
+ tooltipY + tooltipHeight + 2,
+ tooltipX + tooltipTextWidth + 3,
+ tooltipY + tooltipHeight + 3,
+ borderColorEnd,
+ borderColorEnd
+ );
+
+ for (int lineNumber = 0; lineNumber < textLines.size(); ++lineNumber) {
+ String line = textLines.get(lineNumber);
+ font.drawStringWithShadow(line, (float) tooltipX, (float) tooltipY, -1);
+
+ if (lineNumber + 1 == titleLinesCount) {
+ tooltipY += 2;
+ }
+
+ tooltipY += 10;
+ }
+
+ GlStateManager.enableLighting();
+ GlStateManager.enableDepth();
+ RenderHelper.enableStandardItemLighting();
+ GlStateManager.enableRescaleNormal();
+ }
+ GlStateManager.disableLighting();
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java
index 0ec52ec8..3f7476bd 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java
@@ -2,33 +2,23 @@ package io.github.moulberry.notenoughupdates.cosmetics;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
-import com.google.common.collect.Maps;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
-import io.github.moulberry.notenoughupdates.NEUManager;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
-import io.github.moulberry.notenoughupdates.util.HypixelApi;
import net.minecraft.client.Minecraft;
-import net.minecraft.client.entity.EntityPlayerSP;
-import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.shader.Framebuffer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.potion.Potion;
import net.minecraftforge.client.event.RenderPlayerEvent;
-import net.minecraftforge.client.event.RenderWorldEvent;
-import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
-import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.tuple.MutablePair;
import org.apache.commons.lang3.tuple.Pair;
-import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL30;
-import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
@@ -36,352 +26,334 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class CapeManager {
-
- public static final CapeManager INSTANCE = new CapeManager();
- public long lastCapeUpdate = 0;
- public long lastCapeSynced = 0;
-
- public Pair<NEUCape, String> localCape = null;
- private HashMap<String, Pair<NEUCape, String>> capeMap = new HashMap<>();
-
- private int permSyncTries = 5;
- private boolean allAvailable = false;
- private HashSet<String> availableCapes = new HashSet<>();
-
- public JsonObject lastJsonSync = null;
-
- public static class CapeData {
- public String capeName;
- public boolean special;
- public boolean hidden;
-
- public boolean canShow() {
- return !special && !hidden;
- }
-
- public CapeData(String capeName, boolean special, boolean hidden) {
- this.capeName = capeName;
- this.special = special;
- this.hidden = hidden;
- }
- }
-
- public CapeData[] capes = new CapeData[]{
-
- //Admins
- new CapeData("nullzee", true, false),
- new CapeData("ironmoon", true, false),
- new CapeData("gravy", true, false),
-
- //Special Other
- new CapeData("contrib", true, false),
- new CapeData("mbstaff", true, false),
-
- //Partner
- new CapeData("thebakery", true, false),
- new CapeData("furf", true, false),
- new CapeData("dsm", true, false),
- new CapeData("skyclient", true, false),
- new CapeData("subreddit_dark", true, false),
- new CapeData("subreddit_light", true, false),
- new CapeData("packshq", true, false),
- new CapeData("skytils", true, false),
- new CapeData("sbp", true, false),
- new CapeData("sharex", true, false),
- new CapeData("sharex_white", true, false),
-
- //Content Creator
- new CapeData("jakethybro", false, true),
- new CapeData("krusty", false, true),
- new CapeData("krusty_day", false, true),
- new CapeData("krusty_sunset", false, true),
- new CapeData("krusty_night", false, true),
- new CapeData("zera", false, true),
- new CapeData("soldier", false, true),
- new CapeData("alexxoffi", false, true),
- new CapeData("secondpfirsisch", false, true),
- new CapeData("stormy_lh", false, true),
-
- //Patreon
- new CapeData("patreon1", false, false),
- new CapeData("patreon2", false, false),
- new CapeData("fade", false, false),
- new CapeData("space", false, false),
- new CapeData("mcworld", false, false),
- new CapeData("negative", false, false),
- new CapeData("void", false, false),
- new CapeData("lava", false, false),
- new CapeData("tunnel", false, false),
- new CapeData("planets", false, false)
-
-
- };
-
- /*private String[] capes = new String[]{"patreon1", "patreon2", "fade", "contrib", "nullzee",
- "gravy", "space", "mcworld", "lava", "packshq", "mbstaff", "thebakery", "negative",
- "void", "ironmoon", "krusty", "furf", "soldier", "dsm", "zera", "tunnel", "alexxoffi", "parallax", "jakethybro", "planets", "skytils" };
- public Boolean[] specialCapes = new Boolean[] {true, true, false, true, true,
- true, false, false, false, true, true, true, false,
- false, true, false, true, true, true, true, false, true, true, true, true, true };*/
-
- public static CapeManager getInstance() {
- return INSTANCE;
- }
-
- public void tryUnlockCape(String unlock) {
- for(CapeData data : capes) {
- if(data.capeName.equalsIgnoreCase(unlock)) {
- data.hidden = false;
- }
- }
- }
-
- public void tick() {
- long currentTime = System.currentTimeMillis();
- if(currentTime - lastCapeUpdate > 60*1000) {
- lastCapeUpdate = currentTime;
- updateCapes();
- }
- }
-
- private void updateCapes() {
-
- NotEnoughUpdates.INSTANCE.manager.hypixelApi.getMyApiAsync("activecapes.json", (jsonObject) -> {
- if(jsonObject.get("success").getAsBoolean()) {
- lastJsonSync = jsonObject;
-
- lastCapeSynced = System.currentTimeMillis();
- capeMap.clear();
- for(JsonElement active : jsonObject.get("active").getAsJsonArray()) {
- if(active.isJsonObject()) {
- JsonObject activeObj = (JsonObject) active;
- setCape(activeObj.get("_id").getAsString(), activeObj.get("capeType").getAsString(), false);
- }
- }
- }
- }, () -> {
- System.out.println("[MBAPI] Update capes errored");
- });
-
- if(Minecraft.getMinecraft().thePlayer != null && permSyncTries > 0) {
- String uuid = Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", "");
- permSyncTries--;
- NotEnoughUpdates.INSTANCE.manager.hypixelApi.getMyApiAsync("permscapes.json", (jsonObject) -> {
- if(jsonObject.get("success").getAsBoolean()) {
- permSyncTries = 0;
-
- availableCapes.clear();
- for(JsonElement permPlayer : jsonObject.get("perms").getAsJsonArray()) {
- if(permPlayer.isJsonObject()) {
- String playerUuid = permPlayer.getAsJsonObject().get("_id").getAsString();
- if(playerUuid != null && playerUuid.equals(uuid)) {
- for(JsonElement perm : permPlayer.getAsJsonObject().get("perms").getAsJsonArray()) {
- if(perm.isJsonPrimitive()) {
- String cape = perm.getAsString();
- if(cape.equals("*")) {
- allAvailable = true;
- } else {
- availableCapes.add(cape);
- }
- }
- }
- return;
- }
- }
- }
- }
- }, () -> {
- System.out.println("[MBAPI] Update capes errored - perms");
- });
- }
- }
-
- public HashSet<String> getAvailableCapes() {
- return allAvailable ? null : availableCapes;
- }
-
- public void setCape(String playerUUID, String capename, boolean updateConfig) {
- boolean none = capename == null || capename.equals("null");
-
- updateConfig = updateConfig && playerUUID.equals(Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""));
- if(updateConfig) {
- NotEnoughUpdates.INSTANCE.config.hidden.selectedCape = String.valueOf(capename);
- }
-
- if(updateConfig) {
- if(none) {
- localCape = null;
- } else {
- localCape = new MutablePair<>(new NEUCape(capename), capename);
- }
- } else if(capeMap.containsKey(playerUUID)) {
- if(none) {
- capeMap.remove(playerUUID);
- } else {
- Pair<NEUCape, String> capePair = capeMap.get(playerUUID);
- capePair.setValue(capename);
- }
- } else if(!none) {
- capeMap.put(playerUUID, new MutablePair<>(new NEUCape(capename), capename));
- }
- }
-
- public String getCape(String player) {
- if(capeMap.containsKey(player)) {
- return capeMap.get(player).getRight();
- }
- return null;
- }
-
- private static BiMap<String, EntityPlayer> playerMap = null;
-
- public EntityPlayer getPlayerForUUID(String uuid) {
- if(playerMap == null) {
- return null;
- }
- if(playerMap.containsKey(uuid)) {
- return playerMap.get(uuid);
- }
- return null;
- }
-
- private static Framebuffer checkFramebufferSizes(Framebuffer framebuffer, int width, int height) {
- if(framebuffer == null || framebuffer.framebufferWidth != width || framebuffer.framebufferHeight != height) {
- if(framebuffer == null) {
- framebuffer = new Framebuffer(width, height, true);
- } else {
- framebuffer.createBindFramebuffer(width, height);
- }
- framebuffer.setFramebufferFilter(GL11.GL_NEAREST);
- }
- return framebuffer;
- }
-
- public boolean updateWorldFramebuffer = false;
- public Framebuffer backgroundFramebuffer = null;
-
- public void postRenderBlocks() {
- int width = Minecraft.getMinecraft().displayWidth;
- int height = Minecraft.getMinecraft().displayHeight;
- backgroundFramebuffer = checkFramebufferSizes(backgroundFramebuffer,
- width, height);
-
- if(OpenGlHelper.isFramebufferEnabled() && updateWorldFramebuffer) {
- GL30.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, Minecraft.getMinecraft().getFramebuffer().framebufferObject);
- GL30.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, backgroundFramebuffer.framebufferObject);
- GL30.glBlitFramebuffer(0, 0, width, height,
- 0, 0, width, height,
- GL11.GL_COLOR_BUFFER_BIT, GL11.GL_NEAREST);
-
- Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true);
- }
-
- updateWorldFramebuffer = false;
- }
-
- @SubscribeEvent
- public void onWorldLoad(WorldEvent.Unload event) {
- if(playerMap != null) playerMap.clear();
- }
-
- @SubscribeEvent
- public void onRenderPlayer(RenderPlayerEvent.Post e) {
- if(e.partialRenderTick == 1.0F) return; //rendering in inventory
-
- try {
- String uuid = e.entityPlayer.getUniqueID().toString().replace("-", "");
- String clientUuid = Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", "");
-
- if(Minecraft.getMinecraft().thePlayer != null && uuid.equals(clientUuid)) {
- String selCape = NotEnoughUpdates.INSTANCE.config.hidden.selectedCape;
- if(selCape != null && !selCape.isEmpty()) {
- if(localCape == null) {
- localCape = new MutablePair<>(new NEUCape(selCape), selCape);
- } else {
- localCape.setValue(selCape);
- }
- }
- }
- if(uuid.equals(clientUuid) && localCape != null && localCape.getRight() != null && !localCape.getRight().equals("null")) {
- localCape.getLeft().onRenderPlayer(e);
- } else if(!Minecraft.getMinecraft().thePlayer.isPotionActive(Potion.blindness) && capeMap.containsKey(uuid)) {
- capeMap.get(uuid).getLeft().onRenderPlayer(e);
- }
- } catch(Exception ignored) {}
- }
-
- public static void onTickSlow() {
- if(Minecraft.getMinecraft().theWorld == null) return;
-
- if(playerMap == null) {
- playerMap = HashBiMap.create(Minecraft.getMinecraft().theWorld.playerEntities.size());
- }
- playerMap.clear();
- for(EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) {
- String uuid = player.getUniqueID().toString().replace("-", "");
- try {
- playerMap.put(uuid, player);
- } catch(IllegalArgumentException ignored){}
- }
- }
-
- private static final ExecutorService capeTicker = Executors.newCachedThreadPool();
-
- @SubscribeEvent
- public void onTick(TickEvent.ClientTickEvent event) {
- if (event.phase != TickEvent.Phase.END) return;
- if(Minecraft.getMinecraft().theWorld == null) return;
-
- if(playerMap == null) {
- return;
- }
-
- String clientUuid = null;
- if(Minecraft.getMinecraft().thePlayer != null) {
- clientUuid = Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", "");
- }
-
- boolean hasLocalCape = localCape != null && localCape.getRight() != null && !localCape.getRight().equals("null");
-
- Set<String> toRemove = new HashSet<>();
- try {
- for(String playerUUID : capeMap.keySet()) {
- EntityPlayer player;
- if(playerUUID.equals(clientUuid)) {
- player = Minecraft.getMinecraft().thePlayer;
- } else {
- player = getPlayerForUUID(playerUUID);
- }
- if(player != null) {
- String capeName = capeMap.get(playerUUID).getRight();
- if(capeName != null && !capeName.equals("null")) {
- if(player == Minecraft.getMinecraft().thePlayer && hasLocalCape) {
- continue;
- }
- capeMap.get(playerUUID).getLeft().setCapeTexture(capeName);
- capeTicker.submit(() -> {
- capeMap.get(playerUUID).getLeft().onTick(event, player);
- });
- } else {
- toRemove.add(playerUUID);
- }
- }
- }
- } catch(Exception e) {}
-
- if(hasLocalCape) {
- localCape.getLeft().setCapeTexture(localCape.getValue());
- capeTicker.submit(() -> {
- localCape.getLeft().onTick(event, Minecraft.getMinecraft().thePlayer);
- });
- }
- for(String playerName : toRemove) {
- capeMap.remove(playerName);
- }
- }
-
- public CapeData[] getCapes() {
- return capes;
- }
-
+ public static final CapeManager INSTANCE = new CapeManager();
+ public long lastCapeUpdate = 0;
+ public long lastCapeSynced = 0;
+
+ public Pair<NEUCape, String> localCape = null;
+ private final HashMap<String, Pair<NEUCape, String>> capeMap = new HashMap<>();
+
+ private int permSyncTries = 5;
+ private boolean allAvailable = false;
+ private final HashSet<String> availableCapes = new HashSet<>();
+
+ public JsonObject lastJsonSync = null;
+
+ public static class CapeData {
+ public String capeName;
+ public boolean special;
+ public boolean hidden;
+
+ public boolean canShow() {
+ return !special && !hidden;
+ }
+
+ public CapeData(String capeName, boolean special, boolean hidden) {
+ this.capeName = capeName;
+ this.special = special;
+ this.hidden = hidden;
+ }
+ }
+
+ public CapeData[] capes = new CapeData[]{
+ //Patreon
+ new CapeData("patreon1", false, false),
+ new CapeData("patreon2", false, false),
+ new CapeData("fade", false, false),
+ new CapeData("space", false, false),
+ new CapeData("mcworld", false, false),
+ new CapeData("negative", false, false),
+ new CapeData("void", false, false),
+ new CapeData("lava", false, false),
+ new CapeData("tunnel", false, false),
+ new CapeData("planets", false, false),
+
+ //Admins
+ new CapeData("nullzee", true, false),
+ new CapeData("ironmoon", true, false),
+ new CapeData("gravy", true, false),
+
+ //Special Other
+ new CapeData("contrib", true, false),
+ new CapeData("mbstaff", true, false),
+
+ //Partner
+ new CapeData("thebakery", true, false),
+ new CapeData("furf", true, false),
+ new CapeData("dsm", true, false),
+ new CapeData("skyclient", true, false),
+ new CapeData("subreddit_dark", true, false),
+ new CapeData("subreddit_light", true, false),
+ new CapeData("packshq", true, false),
+ new CapeData("skytils", true, false),
+ new CapeData("sbp", true, false),
+ new CapeData("sharex", true, false),
+ new CapeData("sharex_white", true, false),
+ new CapeData("dg", true, false),
+
+ //Content Creator
+ new CapeData("jakethybro", false, true),
+ new CapeData("krusty", false, true),
+ new CapeData("krusty_day", false, true),
+ new CapeData("krusty_sunset", false, true),
+ new CapeData("krusty_night", false, true),
+ new CapeData("zera", false, true),
+ new CapeData("soldier", false, true),
+ new CapeData("alexxoffi", false, true),
+ new CapeData("secondpfirsisch", false, true),
+ new CapeData("stormy_lh", false, true),
+ };
+
+ public static CapeManager getInstance() {
+ return INSTANCE;
+ }
+
+ public void tryUnlockCape(String unlock) {
+ for (CapeData data : capes) {
+ if (data.capeName.equalsIgnoreCase(unlock)) {
+ data.hidden = false;
+ }
+ }
+ }
+
+ public void tick() {
+ long currentTime = System.currentTimeMillis();
+ if (currentTime - lastCapeUpdate > 60 * 1000) {
+ lastCapeUpdate = currentTime;
+ updateCapes();
+ }
+ }
+
+ private void updateCapes() {
+ NotEnoughUpdates.INSTANCE.manager.hypixelApi.getMyApiAsync("activecapes.json", (jsonObject) -> {
+ if (jsonObject.get("success").getAsBoolean()) {
+ lastJsonSync = jsonObject;
+
+ lastCapeSynced = System.currentTimeMillis();
+ capeMap.clear();
+ for (JsonElement active : jsonObject.get("active").getAsJsonArray()) {
+ if (active.isJsonObject()) {
+ JsonObject activeObj = (JsonObject) active;
+ setCape(activeObj.get("_id").getAsString(), activeObj.get("capeType").getAsString(), false);
+ }
+ }
+ }
+ }, () -> System.out.println("[MBAPI] Update capes errored"));
+
+ if (Minecraft.getMinecraft().thePlayer != null && permSyncTries > 0) {
+ String uuid = Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", "");
+ permSyncTries--;
+ NotEnoughUpdates.INSTANCE.manager.hypixelApi.getMyApiAsync("permscapes.json", (jsonObject) -> {
+ if (!jsonObject.get("success").getAsBoolean()) return;
+
+ permSyncTries = 0;
+ availableCapes.clear();
+ for (JsonElement permPlayer : jsonObject.get("perms").getAsJsonArray()) {
+ if (!permPlayer.isJsonObject()) continue;
+ String playerUuid = permPlayer.getAsJsonObject().get("_id").getAsString();
+ if (!(playerUuid != null && playerUuid.equals(uuid))) continue;
+ for (JsonElement perm : permPlayer.getAsJsonObject().get("perms").getAsJsonArray()) {
+ if (!perm.isJsonPrimitive()) continue;
+ String cape = perm.getAsString();
+ if (cape.equals("*")) {
+ allAvailable = true;
+ } else {
+ availableCapes.add(cape);
+ }
+
+ }
+ return;
+ }
+ }, () -> System.out.println("[MBAPI] Update capes errored - perms"));
+ }
+ }
+
+ public HashSet<String> getAvailableCapes() {
+ return allAvailable ? null : availableCapes;
+ }
+
+ public void setCape(String playerUUID, String capename, boolean updateConfig) {
+ boolean none = capename == null || capename.equals("null");
+
+ updateConfig = updateConfig && playerUUID.equals(Minecraft.getMinecraft().thePlayer
+ .getUniqueID()
+ .toString()
+ .replace("-", ""));
+ if (updateConfig) {
+ NotEnoughUpdates.INSTANCE.config.hidden.selectedCape = String.valueOf(capename);
+ }
+
+ if (updateConfig) {
+ localCape = none ? null : new MutablePair<>(new NEUCape(capename), capename);
+ } else if (capeMap.containsKey(playerUUID)) {
+ if (none) {
+ capeMap.remove(playerUUID);
+ } else {
+ Pair<NEUCape, String> capePair = capeMap.get(playerUUID);
+ capePair.setValue(capename);
+ }
+ } else if (!none) {
+ capeMap.put(playerUUID, new MutablePair<>(new NEUCape(capename), capename));
+ }
+ }
+
+ public String getCape(String player) {
+ if (capeMap.containsKey(player)) {
+ return capeMap.get(player).getRight();
+ }
+ return null;
+ }
+
+ private static BiMap<String, EntityPlayer> playerMap = null;
+
+ public EntityPlayer getPlayerForUUID(String uuid) {
+ if (playerMap == null) {
+ return null;
+ }
+ if (playerMap.containsKey(uuid)) {
+ return playerMap.get(uuid);
+ }
+ return null;
+ }
+
+ private static Framebuffer checkFramebufferSizes(Framebuffer framebuffer, int width, int height) {
+ if (framebuffer == null || framebuffer.framebufferWidth != width || framebuffer.framebufferHeight != height) {
+ if (framebuffer == null) {
+ framebuffer = new Framebuffer(width, height, true);
+ } else {
+ framebuffer.createBindFramebuffer(width, height);
+ }
+ framebuffer.setFramebufferFilter(GL11.GL_NEAREST);
+ }
+ return framebuffer;
+ }
+
+ public boolean updateWorldFramebuffer = false;
+ public Framebuffer backgroundFramebuffer = null;
+
+ public void postRenderBlocks() {
+ int width = Minecraft.getMinecraft().displayWidth;
+ int height = Minecraft.getMinecraft().displayHeight;
+ backgroundFramebuffer = checkFramebufferSizes(backgroundFramebuffer,
+ width, height
+ );
+
+ if (OpenGlHelper.isFramebufferEnabled() && updateWorldFramebuffer) {
+ GL30.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, Minecraft.getMinecraft().getFramebuffer().framebufferObject);
+ GL30.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, backgroundFramebuffer.framebufferObject);
+ GL30.glBlitFramebuffer(0, 0, width, height,
+ 0, 0, width, height,
+ GL11.GL_COLOR_BUFFER_BIT, GL11.GL_NEAREST
+ );
+
+ Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true);
+ }
+
+ updateWorldFramebuffer = false;
+ }
+
+ @SubscribeEvent
+ public void onWorldLoad(WorldEvent.Unload event) {
+ if (playerMap != null) playerMap.clear();
+ }
+
+ @SubscribeEvent
+ public void onRenderPlayer(RenderPlayerEvent.Post e) {
+ if (e.partialRenderTick == 1.0F) return; //rendering in inventory
+
+ try {
+ String uuid = e.entityPlayer.getUniqueID().toString().replace("-", "");
+ String clientUuid = Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", "");
+
+ if (Minecraft.getMinecraft().thePlayer != null && uuid.equals(clientUuid)) {
+ String selCape = NotEnoughUpdates.INSTANCE.config.hidden.selectedCape;
+ if (selCape != null && !selCape.isEmpty()) {
+ if (localCape == null) {
+ localCape = new MutablePair<>(new NEUCape(selCape), selCape);
+ } else {
+ localCape.setValue(selCape);
+ }
+ }
+ }
+ if (uuid.equals(clientUuid) && localCape != null && localCape.getRight() != null && !localCape.getRight().equals(
+ "null")) {
+ localCape.getLeft().onRenderPlayer(e);
+ } else if (!Minecraft.getMinecraft().thePlayer.isPotionActive(Potion.blindness) && capeMap.containsKey(uuid)) {
+ capeMap.get(uuid).getLeft().onRenderPlayer(e);
+ }
+ } catch (Exception ignored) {
+ }
+ }
+
+ public static void onTickSlow() {
+ if (Minecraft.getMinecraft().theWorld == null) return;
+
+ if (playerMap == null) {
+ playerMap = HashBiMap.create(Minecraft.getMinecraft().theWorld.playerEntities.size());
+ }
+ playerMap.clear();
+ for (EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) {
+ String uuid = player.getUniqueID().toString().replace("-", "");
+ try {
+ playerMap.put(uuid, player);
+ } catch (IllegalArgumentException ignored) {
+ }
+ }
+ }
+
+ private static final ExecutorService capeTicker = Executors.newCachedThreadPool();
+
+ @SubscribeEvent
+ public void onTick(TickEvent.ClientTickEvent event) {
+ if (event.phase != TickEvent.Phase.END) return;
+ if (Minecraft.getMinecraft().theWorld == null) return;
+
+ if (playerMap == null) {
+ return;
+ }
+
+ String clientUuid = null;
+ if (Minecraft.getMinecraft().thePlayer != null) {
+ clientUuid = Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", "");
+ }
+
+ boolean hasLocalCape = localCape != null && localCape.getRight() != null && !localCape.getRight().equals("null");
+
+ Set<String> toRemove = new HashSet<>();
+ try {
+ for (String playerUUID : capeMap.keySet()) {
+ EntityPlayer player;
+ if (playerUUID.equals(clientUuid)) {
+ player = Minecraft.getMinecraft().thePlayer;
+ } else {
+ player = getPlayerForUUID(playerUUID);
+ }
+ if (player != null) {
+ String capeName = capeMap.get(playerUUID).getRight();
+ if (capeName != null && !capeName.equals("null")) {
+ if (player == Minecraft.getMinecraft().thePlayer && hasLocalCape) {
+ continue;
+ }
+ capeMap.get(playerUUID).getLeft().setCapeTexture(capeName);
+ capeTicker.submit(() -> capeMap.get(playerUUID).getLeft().onTick(event, player));
+ } else {
+ toRemove.add(playerUUID);
+ }
+ }
+ }
+ } catch (Exception ignored) {
+ }
+
+ if (hasLocalCape) {
+ localCape.getLeft().setCapeTexture(localCape.getValue());
+ capeTicker.submit(() -> localCape.getLeft().onTick(event, Minecraft.getMinecraft().thePlayer));
+ }
+ for (String playerName : toRemove) {
+ capeMap.remove(playerName);
+ }
+ }
+
+ public CapeData[] getCapes() {
+ return capes;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeNode.java b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeNode.java
index 06bc6db4..c32cc98f 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeNode.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeNode.java
@@ -1,14 +1,8 @@
package io.github.moulberry.notenoughupdates.cosmetics;
-import net.minecraft.block.Block;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
-import net.minecraft.util.BlockPos;
-import net.minecraft.util.MathHelper;
-import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.vector.Vector2f;
import org.lwjgl.util.vector.Vector3f;
@@ -19,101 +13,108 @@ import java.util.HashMap;
import java.util.List;
public class CapeNode {
-
- private static final NEUCape.Direction[] cardinals = new NEUCape.Direction[]{NEUCape.Direction.UP, NEUCape.Direction.RIGHT, NEUCape.Direction.DOWN, NEUCape.Direction.LEFT};
-
- public Vector3f position;
- public Vector3f lastPosition = new Vector3f();
- public Vector3f renderPosition = new Vector3f();
- public final Vector3f[] oldRenderPosition = new Vector3f[5];
- public final Vector3f velocity = new Vector3f();
- public Vector3f normal = null;
- public Vector3f sideNormal = null;
- public boolean fixed = false;
-
- public static final int DRAW_MASK_FRONT = 0b1;
- public static final int DRAW_MASK_BACK = 0b10;
- public static final int DRAW_MASK_SIDES = 0b100;
-
- public HashMap<NEUCape.Offset, CapeNode> neighbors = new HashMap<>();
-
- public float texU = 0;
- public float texV = 0;
-
- public float horzDistMult = 2f;
- public float vertDistMult = 0.5f;
-
- public float horzSideTexU = 0;
- public float horzSideTexVTop = 0;
-
- public float vertSideTexU = 0;
- public float vertSideTexVTop = 0;
-
- public final float gravity = 0.1f;
- public final float resistance = 0.5f;
-
- public static final int FLOAT_NUM = 20;
-
- public CapeNode(float x, float y, float z) {
- this.position = new Vector3f(x, y, z);
- }
-
- private List<Vector2f> getConstaints() {
- List<Vector2f> constaints = new ArrayList<>();
- for(NEUCape.Direction cardinal : cardinals) {
- for(int i=1; i<=2; i++) {
- NEUCape.Offset offset = new NEUCape.Offset(cardinal, i);
- CapeNode other = neighbors.get(offset);
- if(other != null) {
- int iOffset = offset.getXOffset() + NEUCape.HORZ_NODES * offset.getYOffset();
- constaints.add(new Vector2f(iOffset, i*NEUCape.targetDist*(cardinal.yOff==0?horzDistMult:vertDistMult)));
- }
- }
-
- }
- return constaints;
- }
-
- public void loadIntoBuffer(FloatBuffer buffer) {
- loadVec3IntoBuffer(buffer, position);
- List<Vector2f> containts = getConstaints();
- buffer.put(containts.size());
- for(int i=0; i<8; i++) {
- if(i < containts.size()) {
- loadVec2IntoBuffer(buffer, containts.get(i));
- } else {
- loadVec2IntoBuffer(buffer, new Vector2f());
- }
- }
- }
-
- public void readFromBuffer(FloatBuffer buffer) {
- readVec3FromBuffer(buffer, position);
- buffer.position(buffer.position()+17);
- }
-
- private void readVec3FromBuffer(FloatBuffer buffer, Vector3f vec) {
- vec.x = buffer.get();
- vec.y = buffer.get();
- vec.z = buffer.get();
- }
-
- private void loadVec2IntoBuffer(FloatBuffer buffer, Vector2f vec) {
- buffer.put(vec.x);
- buffer.put(vec.y);
- }
-
- private void loadVec3IntoBuffer(FloatBuffer buffer, Vector3f vec) {
- buffer.put(vec.x);
- buffer.put(vec.y);
- buffer.put(vec.z);
- }
-
- public void update() {
- if(!fixed) {
- velocity.y -= gravity * (resistance)/(1-resistance);
-
- float actualResistance = resistance;
+ private static final NEUCape.Direction[] cardinals = new NEUCape.Direction[]{
+ NEUCape.Direction.UP,
+ NEUCape.Direction.RIGHT,
+ NEUCape.Direction.DOWN,
+ NEUCape.Direction.LEFT
+ };
+
+ public Vector3f position;
+ public Vector3f lastPosition = new Vector3f();
+ public Vector3f renderPosition = new Vector3f();
+ public final Vector3f[] oldRenderPosition = new Vector3f[5];
+ public final Vector3f velocity = new Vector3f();
+ public Vector3f normal = null;
+ public Vector3f sideNormal = null;
+ public boolean fixed = false;
+
+ public static final int DRAW_MASK_FRONT = 0b1;
+ public static final int DRAW_MASK_BACK = 0b10;
+ public static final int DRAW_MASK_SIDES = 0b100;
+
+ public HashMap<NEUCape.Offset, CapeNode> neighbors = new HashMap<>();
+
+ public float texU = 0;
+ public float texV = 0;
+
+ public float horzDistMult = 2f;
+ public float vertDistMult = 0.5f;
+
+ public float horzSideTexU = 0;
+ public float horzSideTexVTop = 0;
+
+ public float vertSideTexU = 0;
+ public float vertSideTexVTop = 0;
+
+ public final float gravity = 0.1f;
+ public final float resistance = 0.5f;
+
+ public static final int FLOAT_NUM = 20;
+
+ public CapeNode(float x, float y, float z) {
+ this.position = new Vector3f(x, y, z);
+ }
+
+ private List<Vector2f> getConstaints() {
+ List<Vector2f> constaints = new ArrayList<>();
+ for (NEUCape.Direction cardinal : cardinals) {
+ for (int i = 1; i <= 2; i++) {
+ NEUCape.Offset offset = new NEUCape.Offset(cardinal, i);
+ CapeNode other = neighbors.get(offset);
+ if (other != null) {
+ int iOffset = offset.getXOffset() + NEUCape.HORZ_NODES * offset.getYOffset();
+ constaints.add(new Vector2f(
+ iOffset,
+ i * NEUCape.targetDist * (cardinal.yOff == 0 ? horzDistMult : vertDistMult)
+ ));
+ }
+ }
+
+ }
+ return constaints;
+ }
+
+ public void loadIntoBuffer(FloatBuffer buffer) {
+ loadVec3IntoBuffer(buffer, position);
+ List<Vector2f> containts = getConstaints();
+ buffer.put(containts.size());
+ for (int i = 0; i < 8; i++) {
+ if (i < containts.size()) {
+ loadVec2IntoBuffer(buffer, containts.get(i));
+ } else {
+ loadVec2IntoBuffer(buffer, new Vector2f());
+ }
+ }
+ }
+
+ public void readFromBuffer(FloatBuffer buffer) {
+ readVec3FromBuffer(buffer, position);
+ buffer.position(buffer.position() + 17);
+ }
+
+ private void readVec3FromBuffer(FloatBuffer buffer, Vector3f vec) {
+ vec.x = buffer.get();
+ vec.y = buffer.get();
+ vec.z = buffer.get();
+ }
+
+ private void loadVec2IntoBuffer(FloatBuffer buffer, Vector2f vec) {
+ buffer.put(vec.x);
+ buffer.put(vec.y);
+ }
+
+ private void loadVec3IntoBuffer(FloatBuffer buffer, Vector3f vec) {
+ buffer.put(vec.x);
+ buffer.put(vec.y);
+ buffer.put(vec.z);
+ }
+
+ public void update() {
+ if (!fixed) {
+ velocity.y -= gravity * (resistance) / (1 - resistance);
+
+ float actualResistance = resistance;
/*BlockPos pos = new BlockPos(
MathHelper.floor_double(position.x),
MathHelper.floor_double(position.y),
@@ -123,249 +124,271 @@ public class CapeNode {
actualResistance = 0.8f;
}*/
- velocity.scale(1-actualResistance);
-
- Vector3f.add(position, velocity, position);
- }
- }
-
- public final CapeNode getNeighbor(NEUCape.Offset offset) {
- return neighbors.get(offset);
- }
-
- public final void setNeighbor(NEUCape.Offset offset, CapeNode node) {
- neighbors.put(offset, node);
- }
-
- public void applyForce(float dX, float dY, float dZ) {
- velocity.x += dX;
- velocity.y += dY;
- velocity.z += dZ;
- }
-
- public void move(float dX, float dY, float dZ) {
- position.x += dX;
- position.y += dY;
- position.z += dZ;
- lastPosition.x = position.x;
- lastPosition.y = position.y;
- lastPosition.z = position.z;
- }
-
- public void resetNormal() {
- normal = null;
- sideNormal = null;
- }
-
- public void resolveAll(float horzDistMult, boolean opt) {
- resolveBend(horzDistMult, opt);
- //resolveShear();
- resolveStruct(horzDistMult, opt);
- }
-
- public void resolve(CapeNode other, float targetDist, float strength, boolean opt) {
- double dX = position.x - other.position.x;
- double dY = position.y - other.position.y;
- double dZ = position.z - other.position.z;
-
- double distSq = dX*dX + dY*dY + dZ*dZ;
-
- double factor = (distSq - targetDist*targetDist)/(40*distSq)*strength;
-
- factor = Math.max(-0.5f, factor);
- dX *= factor;
- dY *= factor;
- dZ *= factor;
-
- if(fixed || other.fixed) {
- dX *= 2;
- dY *= 2;
- dZ *= 2;
- }
-
- if(!fixed) {
- position.x -= dX;
- position.y -= dY;
- position.z -= dZ;
- }
-
- if(!other.fixed) {
- other.position.x += dX;
- other.position.y += dY;
- other.position.z += dZ;
- }
- }
-
- public void resolveStruct(float horzDistMult, boolean opt) {
- for(NEUCape.Direction cardinal : cardinals) {
- NEUCape.Offset offset = new NEUCape.Offset(cardinal, 1);
- CapeNode other = neighbors.get(offset);
- if(other != null) {
- resolve(other, NEUCape.targetDist*(cardinal.yOff==0?horzDistMult:1), 2f*7.5f, opt);
- }
- }
- }
-
- public void resolveShear(float horzDistMult, boolean opt) {
- for(NEUCape.Direction d : new NEUCape.Direction[]{NEUCape.Direction.DOWNLEFT, NEUCape.Direction.UPLEFT, NEUCape.Direction.DOWNRIGHT, NEUCape.Direction.DOWNLEFT}) {
- NEUCape.Offset o = new NEUCape.Offset(d, 1);
- CapeNode neighbor = getNeighbor(o);
- if(neighbor != null) {
- resolve(neighbor, 1f*NEUCape.targetDist*(d.yOff==0?horzDistMult:1f), 0.5f*7.5f, opt);
- }
- }
- }
-
- public void resolveBend(float horzDistMult, boolean opt) {
- for(NEUCape.Direction cardinal : cardinals) {
- NEUCape.Offset offset = new NEUCape.Offset(cardinal, 2);
- CapeNode other = neighbors.get(offset);
- if(other != null) {
- resolve(other, 2f*NEUCape.targetDist*(cardinal.yOff==0?horzDistMult:1), 1f*7.5f, opt);
- }
- }
- }
-
- public Vector3f normal() {
- if(normal != null) return normal;
-
- normal = new Vector3f();
- for(int i=0; i<cardinals.length; i++) {
- NEUCape.Direction dir1 = cardinals[i];
- NEUCape.Direction dir2 = cardinals[(i+1)%cardinals.length];
- CapeNode node1 = getNeighbor(new NEUCape.Offset(dir1, 1));
- CapeNode node2 = getNeighbor(new NEUCape.Offset(dir2, 1));
-
- if(node1 == null || node2 == null) continue;
-
- Vector3f toCapeNode1 = Vector3f.sub(node1.renderPosition, renderPosition, null);
- Vector3f toCapeNode2 = Vector3f.sub(node2.renderPosition, renderPosition, null);
- Vector3f cross = Vector3f.cross(toCapeNode1, toCapeNode2, null);
- Vector3f.add(normal, cross.normalise(null), normal);
- }
- float l = normal.length();
- if(l != 0) {
- normal.scale(1f/l);
- }
- return normal;
- }
-
- public Vector3f sideNormal() {
- if(sideNormal != null) return sideNormal;
-
- sideNormal = new Vector3f();
- NEUCape.Direction[] cardinals = new NEUCape.Direction[]{NEUCape.Direction.UP, NEUCape.Direction.RIGHT, NEUCape.Direction.DOWN, NEUCape.Direction.LEFT};
- for(NEUCape.Direction cardinal : cardinals) {
- CapeNode nodeCardinal = getNeighbor(new NEUCape.Offset(cardinal, 1));
- if(nodeCardinal == null) {
- NEUCape.Direction dirLeft = cardinal.rotateLeft90();
- NEUCape.Direction dirRight = cardinal.rotateRight90();
- CapeNode nodeLeft = getNeighbor(new NEUCape.Offset(dirLeft, 1));
- CapeNode nodeRight = getNeighbor(new NEUCape.Offset(dirRight, 1));
-
- if(nodeRight != null) {
- Vector3f toOther = Vector3f.sub(nodeRight.renderPosition, renderPosition, null);
- Vector3f cross = Vector3f.cross(normal(), toOther, null); //Inverted
- Vector3f.add(sideNormal, cross.normalise(null), sideNormal);
- }
- if(nodeLeft != null) {
- Vector3f toOther = Vector3f.sub(nodeLeft.renderPosition, renderPosition, null);
- Vector3f cross = Vector3f.cross(toOther, normal(), null);
- Vector3f.add(sideNormal, cross.normalise(null), sideNormal);
- }
- }
- }
- float l = sideNormal.length();
- if(l != 0) {
- sideNormal.scale(0.05f/l);
- }
- return sideNormal;
- }
-
- public void renderNode() {
- renderNode(DRAW_MASK_FRONT | DRAW_MASK_BACK | DRAW_MASK_SIDES);
- }
-
- public void renderNode(int mask) {
- CapeNode nodeLeft = getNeighbor(new NEUCape.Offset(NEUCape.Direction.LEFT, 1));
- CapeNode nodeUp = getNeighbor(new NEUCape.Offset(NEUCape.Direction.UP, 1));
- CapeNode nodeDown = getNeighbor(new NEUCape.Offset(NEUCape.Direction.DOWN, 1));
- CapeNode nodeRight = getNeighbor(new NEUCape.Offset(NEUCape.Direction.RIGHT, 1));
- CapeNode nodeDownRight = getNeighbor(new NEUCape.Offset(NEUCape.Direction.DOWNRIGHT, 1));
-
- Tessellator tessellator = Tessellator.getInstance();
- WorldRenderer worldrenderer = tessellator.getWorldRenderer();
-
- if(nodeDown != null && nodeRight != null && nodeDownRight != null) {
- //Back
- if((mask & DRAW_MASK_BACK) != 0) {
- worldrenderer.begin(GL11.GL_TRIANGLE_STRIP, DefaultVertexFormats.POSITION_TEX_NORMAL);
- for(CapeNode node : new CapeNode[]{this, nodeDown, nodeRight, nodeDownRight}) {
- Vector3f nodeNorm = node.normal();
- worldrenderer.pos(node.renderPosition.x, node.renderPosition.y, node.renderPosition.z)
- .tex(1-node.texU, node.texV)
- .normal(-nodeNorm.x, -nodeNorm.y, -nodeNorm.z).endVertex();
- }
- tessellator.draw();
- }
-
- //Front (Offset by normal)
- if((mask & DRAW_MASK_FRONT) != 0) {
- worldrenderer.begin(GL11.GL_TRIANGLE_STRIP, DefaultVertexFormats.POSITION_TEX_NORMAL);
- for(CapeNode node : new CapeNode[]{nodeDownRight, nodeDown, nodeRight, this}) {
- Vector3f nodeNorm = node.normal();
- worldrenderer.pos(node.renderPosition.x+nodeNorm.x*0.05f, node.renderPosition.y+nodeNorm.y*0.05f, node.renderPosition.z+nodeNorm.z*0.05f)
- .tex(node.texU, node.texV)
- .normal(nodeNorm.x, nodeNorm.y, nodeNorm.z).endVertex();
- }
- tessellator.draw();
- }
- }
-
- if((mask & DRAW_MASK_SIDES) != 0) {
- if(nodeLeft == null || nodeRight == null) {
- //Render left/right edge
- if(nodeDown != null) {
- renderEdge(nodeDown, true);
- }
- }
- if(nodeUp == null || nodeDown == null) {
- //Render up/down edge
- if(nodeRight != null) {
- renderEdge(nodeRight, false);
- }
- }
- }
- }
-
- public void renderEdge(CapeNode other, boolean lr) {
- float thisTexU = lr ? this.horzSideTexU : this.vertSideTexU;
- float thisTexV = lr ? this.horzSideTexVTop : this.vertSideTexVTop;
- float otherTexU = lr ? other.horzSideTexU : other.vertSideTexU;
- float otherTexV = lr ? other.horzSideTexVTop : other.vertSideTexVTop;
-
- Tessellator tessellator = Tessellator.getInstance();
- WorldRenderer worldrenderer = tessellator.getWorldRenderer();
-
- Vector3f thisNorm = normal();
- Vector3f otherNorm = other.normal();
-
- Vector3f thisSideNorm = sideNormal();
- Vector3f otherSideNorm = other.sideNormal();
-
- worldrenderer.begin(GL11.GL_TRIANGLE_STRIP, DefaultVertexFormats.POSITION_TEX_NORMAL);
- worldrenderer.pos(this.renderPosition.x, this.renderPosition.y, this.renderPosition.z)
- .tex(thisTexU, thisTexV+20/1024f)
- .normal(thisSideNorm.x, thisSideNorm.y, thisSideNorm.z).endVertex();
- worldrenderer.pos(other.renderPosition.x, other.renderPosition.y, other.renderPosition.z)
- .tex(otherTexU, otherTexV+20/1024f)
- .normal(otherSideNorm.x, otherSideNorm.y, otherSideNorm.z).endVertex();
- worldrenderer.pos(this.renderPosition.x+thisNorm.x*0.05f, this.renderPosition.y+thisNorm.y*0.05f, this.renderPosition.z+thisNorm.z*0.05f)
- .tex(thisTexU, thisTexV)
- .normal(thisSideNorm.x, thisSideNorm.y, thisSideNorm.z).endVertex();
- worldrenderer.pos(other.renderPosition.x+otherNorm.x*0.05f, other.renderPosition.y+otherNorm.y*0.05f, other.renderPosition.z+otherNorm.z*0.05f)
- .tex(otherTexU, otherTexV)
- .normal(otherSideNorm.x, otherSideNorm.y, otherSideNorm.z).endVertex();
- tessellator.draw();
- }
+ velocity.scale(1 - actualResistance);
+
+ Vector3f.add(position, velocity, position);
+ }
+ }
+
+ public final CapeNode getNeighbor(NEUCape.Offset offset) {
+ return neighbors.get(offset);
+ }
+
+ public final void setNeighbor(NEUCape.Offset offset, CapeNode node) {
+ neighbors.put(offset, node);
+ }
+
+ public void applyForce(float dX, float dY, float dZ) {
+ velocity.x += dX;
+ velocity.y += dY;
+ velocity.z += dZ;
+ }
+
+ public void move(float dX, float dY, float dZ) {
+ position.x += dX;
+ position.y += dY;
+ position.z += dZ;
+ lastPosition.x = position.x;
+ lastPosition.y = position.y;
+ lastPosition.z = position.z;
+ }
+
+ public void resetNormal() {
+ normal = null;
+ sideNormal = null;
+ }
+
+ public void resolveAll(float horzDistMult, boolean opt) {
+ resolveBend(horzDistMult, opt);
+ //resolveShear();
+ resolveStruct(horzDistMult, opt);
+ }
+
+ public void resolve(CapeNode other, float targetDist, float strength, boolean opt) {
+ double dX = position.x - other.position.x;
+ double dY = position.y - other.position.y;
+ double dZ = position.z - other.position.z;
+
+ double distSq = dX * dX + dY * dY + dZ * dZ;
+
+ double factor = (distSq - targetDist * targetDist) / (40 * distSq) * strength;
+
+ factor = Math.max(-0.5f, factor);
+ dX *= factor;
+ dY *= factor;
+ dZ *= factor;
+
+ if (fixed || other.fixed) {
+ dX *= 2;
+ dY *= 2;
+ dZ *= 2;
+ }
+
+ if (!fixed) {
+ position.x -= dX;
+ position.y -= dY;
+ position.z -= dZ;
+ }
+
+ if (!other.fixed) {
+ other.position.x += dX;
+ other.position.y += dY;
+ other.position.z += dZ;
+ }
+ }
+
+ public void resolveStruct(float horzDistMult, boolean opt) {
+ for (NEUCape.Direction cardinal : cardinals) {
+ NEUCape.Offset offset = new NEUCape.Offset(cardinal, 1);
+ CapeNode other = neighbors.get(offset);
+ if (other != null) {
+ resolve(other, NEUCape.targetDist * (cardinal.yOff == 0 ? horzDistMult : 1), 2f * 7.5f, opt);
+ }
+ }
+ }
+
+ public void resolveShear(float horzDistMult, boolean opt) {
+ for (NEUCape.Direction d : new NEUCape.Direction[]{
+ NEUCape.Direction.DOWNLEFT,
+ NEUCape.Direction.UPLEFT,
+ NEUCape.Direction.DOWNRIGHT,
+ NEUCape.Direction.DOWNLEFT
+ }) {
+ NEUCape.Offset o = new NEUCape.Offset(d, 1);
+ CapeNode neighbor = getNeighbor(o);
+ if (neighbor != null) {
+ resolve(neighbor, 1f * NEUCape.targetDist * (d.yOff == 0 ? horzDistMult : 1f), 0.5f * 7.5f, opt);
+ }
+ }
+ }
+
+ public void resolveBend(float horzDistMult, boolean opt) {
+ for (NEUCape.Direction cardinal : cardinals) {
+ NEUCape.Offset offset = new NEUCape.Offset(cardinal, 2);
+ CapeNode other = neighbors.get(offset);
+ if (other != null) {
+ resolve(other, 2f * NEUCape.targetDist * (cardinal.yOff == 0 ? horzDistMult : 1), 1f * 7.5f, opt);
+ }
+ }
+ }
+
+ public Vector3f normal() {
+ if (normal != null) return normal;
+
+ normal = new Vector3f();
+ for (int i = 0; i < cardinals.length; i++) {
+ NEUCape.Direction dir1 = cardinals[i];
+ NEUCape.Direction dir2 = cardinals[(i + 1) % cardinals.length];
+ CapeNode node1 = getNeighbor(new NEUCape.Offset(dir1, 1));
+ CapeNode node2 = getNeighbor(new NEUCape.Offset(dir2, 1));
+
+ if (node1 == null || node2 == null) continue;
+
+ Vector3f toCapeNode1 = Vector3f.sub(node1.renderPosition, renderPosition, null);
+ Vector3f toCapeNode2 = Vector3f.sub(node2.renderPosition, renderPosition, null);
+ Vector3f cross = Vector3f.cross(toCapeNode1, toCapeNode2, null);
+ Vector3f.add(normal, cross.normalise(null), normal);
+ }
+ float l = normal.length();
+ if (l != 0) {
+ normal.scale(1f / l);
+ }
+ return normal;
+ }
+
+ public Vector3f sideNormal() {
+ if (sideNormal != null) return sideNormal;
+
+ sideNormal = new Vector3f();
+ NEUCape.Direction[] cardinals = new NEUCape.Direction[]{
+ NEUCape.Direction.UP,
+ NEUCape.Direction.RIGHT,
+ NEUCape.Direction.DOWN,
+ NEUCape.Direction.LEFT
+ };
+ for (NEUCape.Direction cardinal : cardinals) {
+ CapeNode nodeCardinal = getNeighbor(new NEUCape.Offset(cardinal, 1));
+ if (nodeCardinal == null) {
+ NEUCape.Direction dirLeft = cardinal.rotateLeft90();
+ NEUCape.Direction dirRight = cardinal.rotateRight90();
+ CapeNode nodeLeft = getNeighbor(new NEUCape.Offset(dirLeft, 1));
+ CapeNode nodeRight = getNeighbor(new NEUCape.Offset(dirRight, 1));
+
+ if (nodeRight != null) {
+ Vector3f toOther = Vector3f.sub(nodeRight.renderPosition, renderPosition, null);
+ Vector3f cross = Vector3f.cross(normal(), toOther, null); //Inverted
+ Vector3f.add(sideNormal, cross.normalise(null), sideNormal);
+ }
+ if (nodeLeft != null) {
+ Vector3f toOther = Vector3f.sub(nodeLeft.renderPosition, renderPosition, null);
+ Vector3f cross = Vector3f.cross(toOther, normal(), null);
+ Vector3f.add(sideNormal, cross.normalise(null), sideNormal);
+ }
+ }
+ }
+ float l = sideNormal.length();
+ if (l != 0) {
+ sideNormal.scale(0.05f / l);
+ }
+ return sideNormal;
+ }
+
+ public void renderNode() {
+ renderNode(DRAW_MASK_FRONT | DRAW_MASK_BACK | DRAW_MASK_SIDES);
+ }
+
+ public void renderNode(int mask) {
+ CapeNode nodeLeft = getNeighbor(new NEUCape.Offset(NEUCape.Direction.LEFT, 1));
+ CapeNode nodeUp = getNeighbor(new NEUCape.Offset(NEUCape.Direction.UP, 1));
+ CapeNode nodeDown = getNeighbor(new NEUCape.Offset(NEUCape.Direction.DOWN, 1));
+ CapeNode nodeRight = getNeighbor(new NEUCape.Offset(NEUCape.Direction.RIGHT, 1));
+ CapeNode nodeDownRight = getNeighbor(new NEUCape.Offset(NEUCape.Direction.DOWNRIGHT, 1));
+
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+
+ if (nodeDown != null && nodeRight != null && nodeDownRight != null) {
+ //Back
+ if ((mask & DRAW_MASK_BACK) != 0) {
+ worldrenderer.begin(GL11.GL_TRIANGLE_STRIP, DefaultVertexFormats.POSITION_TEX_NORMAL);
+ for (CapeNode node : new CapeNode[]{this, nodeDown, nodeRight, nodeDownRight}) {
+ Vector3f nodeNorm = node.normal();
+ worldrenderer.pos(node.renderPosition.x, node.renderPosition.y, node.renderPosition.z)
+ .tex(1 - node.texU, node.texV)
+ .normal(-nodeNorm.x, -nodeNorm.y, -nodeNorm.z).endVertex();
+ }
+ tessellator.draw();
+ }
+
+ //Front (Offset by normal)
+ if ((mask & DRAW_MASK_FRONT) != 0) {
+ worldrenderer.begin(GL11.GL_TRIANGLE_STRIP, DefaultVertexFormats.POSITION_TEX_NORMAL);
+ for (CapeNode node : new CapeNode[]{nodeDownRight, nodeDown, nodeRight, this}) {
+ Vector3f nodeNorm = node.normal();
+ worldrenderer.pos(
+ node.renderPosition.x + nodeNorm.x * 0.05f,
+ node.renderPosition.y + nodeNorm.y * 0.05f,
+ node.renderPosition.z + nodeNorm.z * 0.05f
+ )
+ .tex(node.texU, node.texV)
+ .normal(nodeNorm.x, nodeNorm.y, nodeNorm.z).endVertex();
+ }
+ tessellator.draw();
+ }
+ }
+
+ if ((mask & DRAW_MASK_SIDES) != 0) {
+ if (nodeLeft == null || nodeRight == null) {
+ //Render left/right edge
+ if (nodeDown != null) {
+ renderEdge(nodeDown, true);
+ }
+ }
+ if (nodeUp == null || nodeDown == null) {
+ //Render up/down edge
+ if (nodeRight != null) {
+ renderEdge(nodeRight, false);
+ }
+ }
+ }
+ }
+
+ public void renderEdge(CapeNode other, boolean lr) {
+ float thisTexU = lr ? this.horzSideTexU : this.vertSideTexU;
+ float thisTexV = lr ? this.horzSideTexVTop : this.vertSideTexVTop;
+ float otherTexU = lr ? other.horzSideTexU : other.vertSideTexU;
+ float otherTexV = lr ? other.horzSideTexVTop : other.vertSideTexVTop;
+
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+
+ Vector3f thisNorm = normal();
+ Vector3f otherNorm = other.normal();
+
+ Vector3f thisSideNorm = sideNormal();
+ Vector3f otherSideNorm = other.sideNormal();
+
+ worldrenderer.begin(GL11.GL_TRIANGLE_STRIP, DefaultVertexFormats.POSITION_TEX_NORMAL);
+ worldrenderer.pos(this.renderPosition.x, this.renderPosition.y, this.renderPosition.z)
+ .tex(thisTexU, thisTexV + 20 / 1024f)
+ .normal(thisSideNorm.x, thisSideNorm.y, thisSideNorm.z).endVertex();
+ worldrenderer.pos(other.renderPosition.x, other.renderPosition.y, other.renderPosition.z)
+ .tex(otherTexU, otherTexV + 20 / 1024f)
+ .normal(otherSideNorm.x, otherSideNorm.y, otherSideNorm.z).endVertex();
+ worldrenderer.pos(
+ this.renderPosition.x + thisNorm.x * 0.05f,
+ this.renderPosition.y + thisNorm.y * 0.05f,
+ this.renderPosition.z + thisNorm.z * 0.05f
+ )
+ .tex(thisTexU, thisTexV)
+ .normal(thisSideNorm.x, thisSideNorm.y, thisSideNorm.z).endVertex();
+ worldrenderer.pos(
+ other.renderPosition.x + otherNorm.x * 0.05f,
+ other.renderPosition.y + otherNorm.y * 0.05f,
+ other.renderPosition.z + otherNorm.z * 0.05f
+ )
+ .tex(otherTexU, otherTexV)
+ .normal(otherSideNorm.x, otherSideNorm.y, otherSideNorm.z).endVertex();
+ tessellator.draw();
+ }
} \ No newline at end of file
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/GuiCosmetics.java b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/GuiCosmetics.java
index 978f3d6a..1b33decf 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/GuiCosmetics.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/GuiCosmetics.java
@@ -1,8 +1,6 @@
package io.github.moulberry.notenoughupdates.cosmetics;
-import com.google.common.collect.Lists;
import com.google.gson.Gson;
-import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.reflect.TypeToken;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
@@ -27,562 +25,651 @@ import org.lwjgl.opengl.GL14;
import java.awt.*;
import java.io.IOException;
import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
-import java.util.*;
+import java.util.Random;
public class GuiCosmetics extends GuiScreen {
-
- public static final ResourceLocation pv_bg = new ResourceLocation("notenoughupdates:pv_bg.png");
- public static final ResourceLocation pv_dropdown = new ResourceLocation("notenoughupdates:pv_dropdown.png");
- public static final ResourceLocation cosmetics_fg = new ResourceLocation("notenoughupdates:cosmetics_fg.png");
- public static final ResourceLocation pv_elements = new ResourceLocation("notenoughupdates:pv_elements.png");
-
- private GuiElementTextField unlockTextField = new GuiElementTextField("", GuiElementTextField.SCALE_TEXT);
-
- private CosmeticsPage currentPage = CosmeticsPage.CAPES;
- private int sizeX;
- private int sizeY;
- private int guiLeft;
- private int guiTop;
-
- private String wantToEquipCape = null;
- private long lastCapeEquip = 0;
-
- private List<String> cosmeticsInfoTooltip = null;
-
-
-
- public GuiCosmetics(){
- Gson gson = new Gson();
-
- JsonElement cosmeticHelpTextElement = Utils.getElement(Constants.MISC, "cosmeticsinfo.lore");
- if(cosmeticHelpTextElement.isJsonArray()) {
- cosmeticsInfoTooltip = gson.fromJson(cosmeticHelpTextElement, new TypeToken<List<String>>(){}.getType());
- }
-
- }
-
- public enum CosmeticsPage {
- CAPES(new ItemStack(Items.chainmail_chestplate));
-
- public final ItemStack stack;
-
- CosmeticsPage(ItemStack stack) {
- this.stack = stack;
- }
- }
-
- @Override
- public void drawScreen(int mouseX, int mouseY, float partialTicks) {
- this.sizeX = 431;
- this.sizeY = 202;
- this.guiLeft = (this.width-this.sizeX)/2;
- this.guiTop = (this.height-this.sizeY)/2;
-
- super.drawScreen(mouseX, mouseY, partialTicks);
- drawDefaultBackground();
-
- blurBackground();
- renderBlurredBackground(width, height, guiLeft+2, guiTop+2, sizeX-4, sizeY-4);
-
- GlStateManager.enableDepth();
- GlStateManager.translate(0, 0, 5);
- renderTabs(true);
- GlStateManager.translate(0, 0, -3);
-
- GlStateManager.disableDepth();
- GlStateManager.translate(0, 0, -2);
- renderTabs(false);
- GlStateManager.translate(0, 0, 2);
-
- GlStateManager.disableLighting();
- GlStateManager.enableDepth();
- GlStateManager.enableBlend();
- GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
- GlStateManager.enableAlpha();
- GlStateManager.alphaFunc(516, 0.1F);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_bg);
- Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST);
-
- GlStateManager.color(1, 1, 1, 1);
- switch (currentPage) {
- case CAPES:
- drawCapesPage(mouseX, mouseY, partialTicks);
- break;
- }
- int helpX = guiLeft+sizeX-20;
- if(mouseX >= helpX && mouseX <= helpX+20 && mouseY >= guiTop-20 && mouseY <= guiTop) {
- if(cosmeticsInfoTooltip != null) {
- List<String> grayTooltip = new ArrayList<>(cosmeticsInfoTooltip.size());
- for (String line : cosmeticsInfoTooltip) {
- grayTooltip.add(EnumChatFormatting.GRAY + line);
- }
- Utils.drawHoveringText(grayTooltip, mouseX, mouseY, width, height, -1, Minecraft.getMinecraft().fontRendererObj);
-
- }
- }
-
- StringBuilder statusMsg = new StringBuilder("Last Sync: ");
- if(CapeManager.INSTANCE.lastCapeSynced == 0) {
- statusMsg.append("Not Synced");
- } else {
- statusMsg.append((System.currentTimeMillis() - CapeManager.INSTANCE.lastCapeSynced)/1000).append("s ago");
- }
- statusMsg.append(" - Next Sync: ");
- if(CapeManager.INSTANCE.lastCapeUpdate == 0) {
- statusMsg.append("ASAP");
- } else {
- statusMsg.append(60 - (System.currentTimeMillis() - CapeManager.INSTANCE.lastCapeUpdate)/1000).append("s");
- }
-
- Minecraft.getMinecraft().fontRendererObj.drawString(EnumChatFormatting.AQUA+statusMsg.toString(),
- guiLeft+sizeX-Minecraft.getMinecraft().fontRendererObj.getStringWidth(statusMsg.toString())-20, guiTop-12, 0, true);
-
- if(currentPage == CosmeticsPage.CAPES) {
- GlStateManager.color(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_dropdown);
- Utils.drawTexturedRect(guiLeft+sizeX/2f-50, guiTop+sizeY+5, 100, 20, 0, 100/200f, 0, 20/185f, GL11.GL_NEAREST);
-
- String equipMsg;
- if(wantToEquipCape != null) {
- equipMsg = EnumChatFormatting.GREEN + "Equip Cape";
- if(System.currentTimeMillis() - lastCapeEquip < 20*1000) {
- equipMsg += " - " + (20 - (System.currentTimeMillis() - lastCapeEquip)/1000) + "s";
- }
- } else {
- equipMsg = EnumChatFormatting.GREEN + "Unequip";
- if(System.currentTimeMillis() - lastCapeEquip < 20*1000) {
- equipMsg += " - " + (20 - (System.currentTimeMillis() - lastCapeEquip)/1000) + "s";
- }
- }
-
- Utils.drawStringCenteredScaledMaxWidth(equipMsg, Minecraft.getMinecraft().fontRendererObj,
- guiLeft+sizeX/2f, guiTop+sizeY+5+10, false, 90, 0);
- }
-
- if(unlockTextField.getFocus() || !unlockTextField.getText().isEmpty()) {
- unlockTextField.setPrependText("");
- } else {
- unlockTextField.setPrependText("\u00a77Creator Code");
- }
-
- unlockTextField.setSize(80, 20);
- unlockTextField.render(guiLeft+sizeX-80, guiTop+sizeY+2);
-
-
-
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(GuiTextures.help);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(helpX, guiTop-20, 20, 20, GL11.GL_LINEAR);
-
-
-
-
- }
-
- private void renderTabs(boolean renderPressed) {
- int ignoredTabs = 0;
- for(int i = 0; i< CosmeticsPage.values().length; i++) {
- CosmeticsPage page = CosmeticsPage.values()[i];
- if(page.stack == null) {
- ignoredTabs++;
- continue;
- }
- boolean pressed = page == currentPage;
- if(pressed == renderPressed) {
- renderTab(page.stack, i-ignoredTabs, pressed);
- }
- }
- }
-
- private void renderTab(ItemStack stack, int xIndex, boolean pressed) {
- GlStateManager.disableLighting();
- GlStateManager.enableBlend();
- GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
- GlStateManager.enableAlpha();
- GlStateManager.alphaFunc(516, 0.1F);
-
- int x = guiLeft+xIndex*28;
- int y = guiTop-28;
-
- float uMin = 0;
- float uMax = 28/256f;
- float vMin = 20/256f;
- float vMax = 51/256f;
- if(pressed) {
- vMin = 52/256f;
- vMax = 84/256f;
-
- if(xIndex != 0) {
- uMin = 28/256f;
- uMax = 56/256f;
- }
-
- renderBlurredBackground(width, height, x+2, y+2, 28-4, 28-4);
- } else {
- renderBlurredBackground(width, height, x+2, y+4, 28-4, 28-4);
- }
-
- GlStateManager.disableLighting();
- GlStateManager.enableBlend();
- GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
- GlStateManager.enableAlpha();
- GlStateManager.alphaFunc(516, 0.1F);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements);
- Utils.drawTexturedRect(x, y, 28, pressed?32:31, uMin, uMax, vMin, vMax, GL11.GL_NEAREST);
-
- GlStateManager.enableDepth();
- Utils.drawItemStack(stack, x+6, y+9);
- }
-
- @Override
- protected void keyTyped(char typedChar, int keyCode) throws IOException {
- if(unlockTextField.getFocus()) {
- if(keyCode == Keyboard.KEY_ESCAPE || keyCode == Keyboard.KEY_RETURN) {
- CapeManager.INSTANCE.tryUnlockCape(unlockTextField.getText().trim());
- unlockTextField.setText("");
- unlockTextField.setFocus(false);
- } else {
- unlockTextField.keyTyped(typedChar, keyCode);
- }
- } else {
- super.keyTyped(typedChar, keyCode);
- }
- }
-
- @Override
- protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
- //guiLeft+sizeX-140, guiTop+sizeY+2
-
- if(mouseX > guiLeft+sizeX-140 & mouseX < guiLeft+sizeX &&
- mouseY > guiTop+sizeY && mouseY < guiTop+sizeY+22) {
- unlockTextField.mouseClicked(mouseX, mouseY, mouseButton);
- }
-
- for (int i = 0; i < CosmeticsPage.values().length; i++) {
- CosmeticsPage page = CosmeticsPage.values()[i];
- int x = guiLeft + i * 28;
- int y = guiTop - 28;
-
- if (mouseX > x && mouseX < x + 28) {
- if (mouseY > y && mouseY < y + 32) {
- if (currentPage != page) Utils.playPressSound();
- currentPage = page;
- return;
- }
- }
- }
- if(mouseY > guiTop+177 && mouseY < guiTop+177+12) {
- if(mouseX > guiLeft+15+371*scroll && mouseX < guiLeft+15+371*scroll+32) {
- scrollClickedX = mouseX - (int)(guiLeft+15+371*scroll);
- return;
- }
- }
-
- int index = 0;
- int displayingCapes = 0;
- for(CapeManager.CapeData cape : CapeManager.INSTANCE.getCapes()) {
- boolean equipable = CapeManager.INSTANCE.getAvailableCapes() == null || CapeManager.INSTANCE.getAvailableCapes().contains(cape.capeName);
- if (cape.canShow() || equipable) {
- displayingCapes++;
- }
- }
-
- float totalNeeded = 91*displayingCapes;
- float totalAvail = sizeX-20;
- float xOffset = scroll*(totalNeeded-totalAvail);
-
- index = 0;
- int displayIndex = 0;
- for(CapeManager.CapeData cape : CapeManager.INSTANCE.getCapes()) {
- boolean equipable = CapeManager.INSTANCE.getAvailableCapes() == null || CapeManager.INSTANCE.getAvailableCapes().contains(cape.capeName);
- if(!cape.canShow() && !equipable) continue;
-
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(guiLeft + 20 + 91 * displayIndex - xOffset, guiTop + 123, 81, 20,
- 0, 81 / 256f, 216 / 256f, 236 / 256f, GL11.GL_NEAREST);
-
- if(mouseX > guiLeft + 20 + 91 * displayIndex - xOffset && mouseX < guiLeft + 20 + 91 * displayIndex - xOffset+81) {
- if(mouseY > guiTop + 123 && mouseY < guiTop + 123 + 20) {
- if(CapeManager.INSTANCE.localCape != null && CapeManager.INSTANCE.localCape.getRight().equals(cape.capeName)) {
- CapeManager.INSTANCE.setCape(Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""),
- "null", true);
- } else {
- CapeManager.INSTANCE.setCape(Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""),
- cape.capeName, true);
- }
-
- return;
- } else if(equipable && mouseY > guiTop + 149 && mouseY < guiTop + 149 + 20) {
- if(cape.capeName.equals(wantToEquipCape)) {
- wantToEquipCape = null;
- } else {
- wantToEquipCape = cape.capeName;
- }
- return;
- }
- }
-
- displayIndex++;
- }
-
- if(currentPage == CosmeticsPage.CAPES) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_dropdown);
- Utils.drawTexturedRect(guiLeft+sizeX/2f-50, guiTop+sizeY+5, 100, 20, 0, 100/200f, 0, 20/185f, GL11.GL_NEAREST);
-
- if(mouseX > guiLeft+sizeX/2f-50 && mouseX < guiLeft+sizeX/2f+50) {
- if(mouseY > guiTop+sizeY+5 && mouseY < guiTop+sizeY+25) {
- if(System.currentTimeMillis() - lastCapeEquip > 20*1000) {
- CapeManager.INSTANCE.setCape(Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""),
- wantToEquipCape, true);
-
- lastCapeEquip = System.currentTimeMillis();
-
- try {
- String userName = Minecraft.getMinecraft().thePlayer.getName();
- String accessToken = Minecraft.getMinecraft().getSession().getToken();
- Random r1 = new Random();
- Random r2 = new Random(System.identityHashCode(new Object()));
- BigInteger random1Bi = new BigInteger(128, r1);
- BigInteger random2Bi = new BigInteger(128, r2);
- BigInteger serverBi = random1Bi.xor(random2Bi);
- String serverId = serverBi.toString(16);
- Minecraft.getMinecraft().getSessionService().joinServer(Minecraft.getMinecraft().getSession().getProfile(), accessToken, serverId);
-
- if(wantToEquipCape == null) {
- NotEnoughUpdates.INSTANCE.manager.hypixelApi.getMyApiAsync("cgi-bin/changecape.py?capeType=null&serverId="+
- serverId+"&username="+userName, (jsonObject) -> { System.out.println(jsonObject); }, () -> {
- System.out.println("Change cape error");
- });
- } else {
- NotEnoughUpdates.INSTANCE.manager.hypixelApi.getMyApiAsync("cgi-bin/changecape.py?capeType="+wantToEquipCape+"&serverId="+
- serverId+"&username="+userName, (jsonObject) -> { System.out.println(jsonObject); }, () -> {
- System.out.println("Change cape error");
- });
- }
- } catch(Exception e) {
- System.out.println("Exception while generating mojang shared secret");
- e.printStackTrace();
- }
-
-
- }
- }
- }
- }
- }
-
- @Override
- protected void mouseReleased(int mouseX, int mouseY, int state) {
- super.mouseReleased(mouseX, mouseY, state);
-
- scrollClickedX = -1;
- }
-
- @Override
- protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
- super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
-
- if(scrollClickedX >= 0) {
- float scrollStartX = mouseX - scrollClickedX;
- scroll = (scrollStartX-(guiLeft+15))/371f;
- scroll = Math.max(0, Math.min(1, scroll));
- }
- }
-
- private HashMap<String, ResourceLocation> capesLocation = new HashMap<>();
- private float scroll = 0f;
- private int scrollClickedX = -1;
- private void drawCapesPage(int mouseX, int mouseY, float partialTicks) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(cosmetics_fg);
- Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements);
- Utils.drawTexturedRect(guiLeft+15+371*scroll, guiTop+177, 32, 12,
- 0, 32/256f, 192/256f, 204/256f, GL11.GL_NEAREST);
-
- GL11.glEnable(GL11.GL_SCISSOR_TEST);
- GL11.glScissor(Minecraft.getMinecraft().displayWidth*(guiLeft+3)/width, 0,
- Minecraft.getMinecraft().displayWidth*(sizeX-6)/width, Minecraft.getMinecraft().displayHeight);
-
- int index = 0;
- int displayingCapes = 0;
- for(CapeManager.CapeData capeData : CapeManager.INSTANCE.getCapes()) {
- boolean equipable = CapeManager.INSTANCE.getAvailableCapes() == null || CapeManager.INSTANCE.getAvailableCapes().contains(capeData.capeName);
- if (capeData.canShow() || equipable) {
- displayingCapes++;
- }
- }
-
- float totalNeeded = 91*displayingCapes;
- float totalAvail = sizeX-20;
- float xOffset = scroll*(totalNeeded-totalAvail);
-
- index = 0;
- int displayIndex = 0;
- for(CapeManager.CapeData capeData : CapeManager.INSTANCE.getCapes()) {
- boolean equipable = CapeManager.INSTANCE.getAvailableCapes() == null || CapeManager.INSTANCE.getAvailableCapes().contains(capeData.capeName);
- if(!capeData.canShow() && !equipable) continue;
-
- if(capeData.capeName.equals(CapeManager.INSTANCE.getCape(Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", "")))) {
- GlStateManager.color(250 / 255f, 200 / 255f, 0 / 255f, 1);
- Utils.drawGradientRect(guiLeft + 20 + 91 * displayIndex - (int) xOffset, guiTop + 10,
- guiLeft + 20 + 91 * displayIndex - (int) xOffset + 81, guiTop + 10 + 108,
- new Color(150, 100, 0, 40).getRGB(), new Color(250, 200, 0, 40).getRGB());
- } else if(capeData.capeName.equals(wantToEquipCape)) {
- GlStateManager.color(0, 200 / 255f, 250 / 255f, 1);
- Utils.drawGradientRect(guiLeft + 20 + 91 * displayIndex - (int) xOffset, guiTop + 10,
- guiLeft + 20 + 91 * displayIndex - (int) xOffset + 81, guiTop + 10 + 108,
- new Color(0, 100, 150, 40).getRGB(), new Color(0, 200, 250, 40).getRGB());
- } else if(CapeManager.INSTANCE.localCape != null && CapeManager.INSTANCE.localCape.getRight().equals(capeData.capeName)) {
- GlStateManager.color(100/255f, 250/255f, 150/255f, 1);
- Utils.drawGradientRect(guiLeft+20+91*displayIndex-(int)xOffset, guiTop+10,
- guiLeft+20+91*displayIndex-(int)xOffset+81, guiTop+10+108,
- new Color(50, 100, 75, 40).getRGB(), new Color(100, 250, 150, 40).getRGB());
- }
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements);
- Utils.drawTexturedRect(guiLeft+20+91*displayIndex-xOffset, guiTop+10, 81, 108,
- 0, 81/256f, 84/256f, 192/256f, GL11.GL_NEAREST);
- GlStateManager.color(1, 1, 1, 1);
-
- Utils.drawTexturedRect(guiLeft+20+91*displayIndex-xOffset, guiTop+123, 81, 20,
- 0, 81/256f, 216/256f, 236/256f, GL11.GL_NEAREST);
-
- boolean equipPressed = capeData.capeName.equals(wantToEquipCape);
- if(!equipable) GlStateManager.color(1, 1, 1, 0.5f);
- Utils.drawTexturedRect(guiLeft+20+91*displayIndex-xOffset, guiTop+149, 81, 20,
- equipPressed?81/256f:0, equipPressed?0:81/256f, equipPressed?236/256f:216/256f, equipPressed?216/256f:236/256f, GL11.GL_NEAREST);
-
- Utils.drawStringCenteredScaledMaxWidth("Try it out", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+20+91*displayIndex+81/2f-xOffset, guiTop+123+10, false, 75, new Color(100, 250, 150).getRGB());
- if(equipable) {
- Utils.drawStringCenteredScaledMaxWidth("Equip", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+20+91*displayIndex+81/2f-xOffset, guiTop+149+10, false, 75, new Color(100, 250, 150).getRGB());
- } else {
- Utils.drawStringCenteredScaledMaxWidth("Not Unlocked", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+20+91*displayIndex+81/2f-xOffset, guiTop+149+10, false, 75, new Color(200, 50, 50, 100).getRGB());
- }
- GlStateManager.color(1, 1, 1, 1);
-
- ResourceLocation capeTexture = capesLocation.computeIfAbsent(capeData.capeName,
- k -> new ResourceLocation("notenoughupdates", "capes/"+capeData.capeName+"_preview.png"));
- Minecraft.getMinecraft().getTextureManager().bindTexture(capeTexture);
- Utils.drawTexturedRect(guiLeft+31+91*displayIndex-xOffset, guiTop+24, 59, 84, GL11.GL_NEAREST);
-
- displayIndex++;
- }
-
- GL11.glScissor(0, 0, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight);
- GL11.glDisable(GL11.GL_SCISSOR_TEST);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements);
- }
-
- Shader blurShaderHorz = null;
- Framebuffer blurOutputHorz = null;
- Shader blurShaderVert = null;
- Framebuffer blurOutputVert = null;
-
- /**
- * Creates a projection matrix that projects from our coordinate space [0->width; 0->height] to OpenGL coordinate
- * space [-1 -> 1; 1 -> -1] (Note: flipped y-axis).
- *
- * This is so that we can render to and from the framebuffer in a way that is familiar to us, instead of needing to
- * apply scales and translations manually.
- */
- private Matrix4f createProjectionMatrix(int width, int height) {
- Matrix4f projMatrix = new Matrix4f();
- projMatrix.setIdentity();
- projMatrix.m00 = 2.0F / (float)width;
- projMatrix.m11 = 2.0F / (float)(-height);
- projMatrix.m22 = -0.0020001999F;
- projMatrix.m33 = 1.0F;
- projMatrix.m03 = -1.0F;
- projMatrix.m13 = 1.0F;
- projMatrix.m23 = -1.0001999F;
- return projMatrix;
- }
-
- /**
- * Renders whatever is currently in the Minecraft framebuffer to our two framebuffers, applying a horizontal
- * and vertical blur separately in order to significantly save computation time.
- * This is only possible if framebuffers are supported by the system, so this method will exit prematurely
- * if framebuffers are not available. (Apple machines, for example, have poor framebuffer support).
- */
- private double lastBgBlurFactor = -1;
- private void blurBackground() {
- int width = Minecraft.getMinecraft().displayWidth;
- int height = Minecraft.getMinecraft().displayHeight;
-
- if(blurOutputHorz == null) {
- blurOutputHorz = new Framebuffer(width, height, false);
- blurOutputHorz.setFramebufferFilter(GL11.GL_NEAREST);
- }
- if(blurOutputVert == null) {
- blurOutputVert = new Framebuffer(width, height, false);
- blurOutputVert.setFramebufferFilter(GL11.GL_NEAREST);
- }
- if(blurOutputHorz.framebufferWidth != width || blurOutputHorz.framebufferHeight != height) {
- blurOutputHorz.createBindFramebuffer(width, height);
- blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height));
- Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
- }
- if(blurOutputVert.framebufferWidth != width || blurOutputVert.framebufferHeight != height) {
- blurOutputVert.createBindFramebuffer(width, height);
- blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height));
- Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
- }
-
- if(blurShaderHorz == null) {
- try {
- blurShaderHorz = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur",
- Minecraft.getMinecraft().getFramebuffer(), blurOutputHorz);
- blurShaderHorz.getShaderManager().getShaderUniform("BlurDir").set(1, 0);
- blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height));
- } catch(Exception e) { }
- }
- if(blurShaderVert == null) {
- try {
- blurShaderVert = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur",
- blurOutputHorz, blurOutputVert);
- blurShaderVert.getShaderManager().getShaderUniform("BlurDir").set(0, 1);
- blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height));
- } catch(Exception e) { }
- }
- if(blurShaderHorz != null && blurShaderVert != null) {
- if(15 != lastBgBlurFactor) {
- blurShaderHorz.getShaderManager().getShaderUniform("Radius").set((float)15);
- blurShaderVert.getShaderManager().getShaderUniform("Radius").set((float)15);
- lastBgBlurFactor = 15;
- }
- GL11.glPushMatrix();
- blurShaderHorz.loadShader(0);
- blurShaderVert.loadShader(0);
- GlStateManager.enableDepth();
- GL11.glPopMatrix();
-
- Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
- }
- }
-
- /**
- * Renders a subsection of the blurred framebuffer on to the corresponding section of the screen.
- * Essentially, this method will "blur" the background inside the bounds specified by [x->x+blurWidth, y->y+blurHeight]
- */
- public void renderBlurredBackground(int width, int height, int x, int y, int blurWidth, int blurHeight) {
- float uMin = x/(float)width;
- float uMax = (x+blurWidth)/(float)width;
- float vMin = (height-y)/(float)height;
- float vMax = (height-y-blurHeight)/(float)height;
-
- blurOutputVert.bindFramebufferTexture();
- GlStateManager.color(1f, 1f, 1f, 1f);
- //Utils.setScreen(width*f, height*f, f);
- Utils.drawTexturedRect(x, y, blurWidth, blurHeight, uMin, uMax, vMin, vMax);
- //Utils.setScreen(width, height, f);
- blurOutputVert.unbindFramebufferTexture();
- }
+ public static final ResourceLocation pv_bg = new ResourceLocation("notenoughupdates:pv_bg.png");
+ public static final ResourceLocation pv_dropdown = new ResourceLocation("notenoughupdates:pv_dropdown.png");
+ public static final ResourceLocation cosmetics_fg = new ResourceLocation("notenoughupdates:cosmetics_fg.png");
+ public static final ResourceLocation pv_elements = new ResourceLocation("notenoughupdates:pv_elements.png");
+
+ private final GuiElementTextField unlockTextField = new GuiElementTextField("", GuiElementTextField.SCALE_TEXT);
+
+ private CosmeticsPage currentPage = CosmeticsPage.CAPES;
+ private int sizeX;
+ private int sizeY;
+ private int guiLeft;
+ private int guiTop;
+
+ private String wantToEquipCape = null;
+ private long lastCapeEquip = 0;
+
+ private List<String> cosmeticsInfoTooltip = null;
+
+ public GuiCosmetics() {
+ Gson gson = new Gson();
+
+ JsonElement cosmeticHelpTextElement = Utils.getElement(Constants.MISC, "cosmeticsinfo.lore");
+ if (cosmeticHelpTextElement.isJsonArray()) {
+ cosmeticsInfoTooltip = gson.fromJson(cosmeticHelpTextElement, new TypeToken<List<String>>() {}.getType());
+ }
+
+ }
+
+ public enum CosmeticsPage {
+ CAPES(new ItemStack(Items.chainmail_chestplate));
+
+ public final ItemStack stack;
+
+ CosmeticsPage(ItemStack stack) {
+ this.stack = stack;
+ }
+ }
+
+ @Override
+ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
+ this.sizeX = 431;
+ this.sizeY = 202;
+ this.guiLeft = (this.width - this.sizeX) / 2;
+ this.guiTop = (this.height - this.sizeY) / 2;
+
+ super.drawScreen(mouseX, mouseY, partialTicks);
+ drawDefaultBackground();
+
+ blurBackground();
+ renderBlurredBackground(width, height, guiLeft + 2, guiTop + 2, sizeX - 4, sizeY - 4);
+
+ GlStateManager.enableDepth();
+ GlStateManager.translate(0, 0, 5);
+ renderTabs(true);
+ GlStateManager.translate(0, 0, -3);
+
+ GlStateManager.disableDepth();
+ GlStateManager.translate(0, 0, -2);
+ renderTabs(false);
+ GlStateManager.translate(0, 0, 2);
+
+ GlStateManager.disableLighting();
+ GlStateManager.enableDepth();
+ GlStateManager.enableBlend();
+ GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ GlStateManager.enableAlpha();
+ GlStateManager.alphaFunc(516, 0.1F);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_bg);
+ Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST);
+
+ GlStateManager.color(1, 1, 1, 1);
+ switch (currentPage) {
+ case CAPES:
+ drawCapesPage(mouseX, mouseY, partialTicks);
+ break;
+ }
+ int helpX = guiLeft + sizeX - 20;
+ if (mouseX >= helpX && mouseX <= helpX + 20 && mouseY >= guiTop - 20 && mouseY <= guiTop) {
+ if (cosmeticsInfoTooltip != null) {
+ List<String> grayTooltip = new ArrayList<>(cosmeticsInfoTooltip.size());
+ for (String line : cosmeticsInfoTooltip) {
+ grayTooltip.add(EnumChatFormatting.GRAY + line);
+ }
+ Utils.drawHoveringText(
+ grayTooltip,
+ mouseX,
+ mouseY,
+ width,
+ height,
+ -1,
+ Minecraft.getMinecraft().fontRendererObj
+ );
+
+ }
+ }
+
+ StringBuilder statusMsg = new StringBuilder("Last Sync: ");
+ if (CapeManager.INSTANCE.lastCapeSynced == 0) {
+ statusMsg.append("Not Synced");
+ } else {
+ statusMsg.append((System.currentTimeMillis() - CapeManager.INSTANCE.lastCapeSynced) / 1000).append("s ago");
+ }
+ statusMsg.append(" - Next Sync: ");
+ if (CapeManager.INSTANCE.lastCapeUpdate == 0) {
+ statusMsg.append("ASAP");
+ } else {
+ statusMsg.append(60 - (System.currentTimeMillis() - CapeManager.INSTANCE.lastCapeUpdate) / 1000).append("s");
+ }
+
+ Minecraft.getMinecraft().fontRendererObj.drawString(
+ EnumChatFormatting.AQUA + statusMsg.toString(),
+ guiLeft + sizeX - Minecraft.getMinecraft().fontRendererObj.getStringWidth(statusMsg.toString()) - 20,
+ guiTop - 12,
+ 0,
+ true
+ );
+
+ if (currentPage == CosmeticsPage.CAPES) {
+ GlStateManager.color(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_dropdown);
+ Utils.drawTexturedRect(
+ guiLeft + sizeX / 2f - 50,
+ guiTop + sizeY + 5,
+ 100,
+ 20,
+ 0,
+ 100 / 200f,
+ 0,
+ 20 / 185f,
+ GL11.GL_NEAREST
+ );
+
+ String equipMsg;
+ if (wantToEquipCape != null) {
+ equipMsg = EnumChatFormatting.GREEN + "Equip Cape";
+ } else {
+ equipMsg = EnumChatFormatting.GREEN + "Unequip";
+ }
+ if (System.currentTimeMillis() - lastCapeEquip < 20 * 1000) {
+ equipMsg += " - " + (20 - (System.currentTimeMillis() - lastCapeEquip) / 1000) + "s";
+ }
+
+ Utils.drawStringCenteredScaledMaxWidth(equipMsg, Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + sizeX / 2f, guiTop + sizeY + 5 + 10, false, 90, 0
+ );
+ }
+
+ if (unlockTextField.getFocus() || !unlockTextField.getText().isEmpty()) {
+ unlockTextField.setPrependText("");
+ } else {
+ unlockTextField.setPrependText("\u00a77Creator Code");
+ }
+
+ unlockTextField.setSize(80, 20);
+ unlockTextField.render(guiLeft + sizeX - 80, guiTop + sizeY + 2);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(GuiTextures.help);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(helpX, guiTop - 20, 20, 20, GL11.GL_LINEAR);
+
+ }
+
+ private void renderTabs(boolean renderPressed) {
+ int ignoredTabs = 0;
+ for (int i = 0; i < CosmeticsPage.values().length; i++) {
+ CosmeticsPage page = CosmeticsPage.values()[i];
+ if (page.stack == null) {
+ ignoredTabs++;
+ continue;
+ }
+ boolean pressed = page == currentPage;
+ if (pressed == renderPressed) {
+ renderTab(page.stack, i - ignoredTabs, pressed);
+ }
+ }
+ }
+
+ private void renderTab(ItemStack stack, int xIndex, boolean pressed) {
+ GlStateManager.disableLighting();
+ GlStateManager.enableBlend();
+ GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ GlStateManager.enableAlpha();
+ GlStateManager.alphaFunc(516, 0.1F);
+
+ int x = guiLeft + xIndex * 28;
+ int y = guiTop - 28;
+
+ float uMin = 0;
+ float uMax = 28 / 256f;
+ float vMin = 20 / 256f;
+ float vMax = 51 / 256f;
+ if (pressed) {
+ vMin = 52 / 256f;
+ vMax = 84 / 256f;
+
+ if (xIndex != 0) {
+ uMin = 28 / 256f;
+ uMax = 56 / 256f;
+ }
+
+ renderBlurredBackground(width, height, x + 2, y + 2, 28 - 4, 28 - 4);
+ } else {
+ renderBlurredBackground(width, height, x + 2, y + 4, 28 - 4, 28 - 4);
+ }
+
+ GlStateManager.disableLighting();
+ GlStateManager.enableBlend();
+ GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ GlStateManager.enableAlpha();
+ GlStateManager.alphaFunc(516, 0.1F);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements);
+ Utils.drawTexturedRect(x, y, 28, pressed ? 32 : 31, uMin, uMax, vMin, vMax, GL11.GL_NEAREST);
+
+ GlStateManager.enableDepth();
+ Utils.drawItemStack(stack, x + 6, y + 9);
+ }
+
+ @Override
+ protected void keyTyped(char typedChar, int keyCode) throws IOException {
+ if (unlockTextField.getFocus()) {
+ if (keyCode == Keyboard.KEY_ESCAPE || keyCode == Keyboard.KEY_RETURN) {
+ CapeManager.INSTANCE.tryUnlockCape(unlockTextField.getText().trim());
+ unlockTextField.setText("");
+ unlockTextField.setFocus(false);
+ } else {
+ unlockTextField.keyTyped(typedChar, keyCode);
+ }
+ } else {
+ super.keyTyped(typedChar, keyCode);
+ }
+ }
+
+ @Override
+ protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
+ //guiLeft+sizeX-140, guiTop+sizeY+2
+
+ if (mouseX > guiLeft + sizeX - 140 & mouseX < guiLeft + sizeX &&
+ mouseY > guiTop + sizeY && mouseY < guiTop + sizeY + 22) {
+ unlockTextField.mouseClicked(mouseX, mouseY, mouseButton);
+ }
+
+ for (int i = 0; i < CosmeticsPage.values().length; i++) {
+ CosmeticsPage page = CosmeticsPage.values()[i];
+ int x = guiLeft + i * 28;
+ int y = guiTop - 28;
+
+ if (mouseX > x && mouseX < x + 28) {
+ if (mouseY > y && mouseY < y + 32) {
+ if (currentPage != page) Utils.playPressSound();
+ currentPage = page;
+ return;
+ }
+ }
+ }
+ if (mouseY > guiTop + 177 && mouseY < guiTop + 177 + 12) {
+ if (mouseX > guiLeft + 15 + 371 * scroll && mouseX < guiLeft + 15 + 371 * scroll + 32) {
+ scrollClickedX = mouseX - (int) (guiLeft + 15 + 371 * scroll);
+ return;
+ }
+ }
+
+ int index = 0;
+ int displayingCapes = 0;
+ for (CapeManager.CapeData cape : CapeManager.INSTANCE.getCapes()) {
+ boolean equipable = CapeManager.INSTANCE.getAvailableCapes() == null ||
+ CapeManager.INSTANCE.getAvailableCapes().contains(cape.capeName);
+ if (cape.canShow() || equipable) {
+ displayingCapes++;
+ }
+ }
+
+ float totalNeeded = 91 * displayingCapes;
+ float totalAvail = sizeX - 20;
+ float xOffset = scroll * (totalNeeded - totalAvail);
+
+ index = 0;
+ int displayIndex = 0;
+ for (CapeManager.CapeData cape : CapeManager.INSTANCE.getCapes()) {
+ boolean equipable = CapeManager.INSTANCE.getAvailableCapes() == null ||
+ CapeManager.INSTANCE.getAvailableCapes().contains(cape.capeName);
+ if (!cape.canShow() && !equipable) continue;
+
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(guiLeft + 20 + 91 * displayIndex - xOffset, guiTop + 123, 81, 20,
+ 0, 81 / 256f, 216 / 256f, 236 / 256f, GL11.GL_NEAREST
+ );
+
+ if (mouseX > guiLeft + 20 + 91 * displayIndex - xOffset &&
+ mouseX < guiLeft + 20 + 91 * displayIndex - xOffset + 81) {
+ if (mouseY > guiTop + 123 && mouseY < guiTop + 123 + 20) {
+ if (CapeManager.INSTANCE.localCape != null &&
+ CapeManager.INSTANCE.localCape.getRight().equals(cape.capeName)) {
+ CapeManager.INSTANCE.setCape(Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""),
+ "null", true
+ );
+ } else {
+ CapeManager.INSTANCE.setCape(Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""),
+ cape.capeName, true
+ );
+ }
+
+ return;
+ } else if (equipable && mouseY > guiTop + 149 && mouseY < guiTop + 149 + 20) {
+ if (cape.capeName.equals(wantToEquipCape)) {
+ wantToEquipCape = null;
+ } else {
+ wantToEquipCape = cape.capeName;
+ }
+ return;
+ }
+ }
+
+ displayIndex++;
+ }
+
+ if (currentPage == CosmeticsPage.CAPES) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_dropdown);
+ Utils.drawTexturedRect(
+ guiLeft + sizeX / 2f - 50,
+ guiTop + sizeY + 5,
+ 100,
+ 20,
+ 0,
+ 100 / 200f,
+ 0,
+ 20 / 185f,
+ GL11.GL_NEAREST
+ );
+
+ if (mouseX > guiLeft + sizeX / 2f - 50 && mouseX < guiLeft + sizeX / 2f + 50) {
+ if (mouseY > guiTop + sizeY + 5 && mouseY < guiTop + sizeY + 25) {
+ if (System.currentTimeMillis() - lastCapeEquip > 20 * 1000) {
+ CapeManager.INSTANCE.setCape(Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""),
+ wantToEquipCape, true
+ );
+
+ lastCapeEquip = System.currentTimeMillis();
+
+ try {
+ String userName = Minecraft.getMinecraft().thePlayer.getName();
+ String accessToken = Minecraft.getMinecraft().getSession().getToken();
+ Random r1 = new Random();
+ Random r2 = new Random(System.identityHashCode(new Object()));
+ BigInteger random1Bi = new BigInteger(128, r1);
+ BigInteger random2Bi = new BigInteger(128, r2);
+ BigInteger serverBi = random1Bi.xor(random2Bi);
+ String serverId = serverBi.toString(16);
+ Minecraft.getMinecraft().getSessionService().joinServer(Minecraft
+ .getMinecraft()
+ .getSession()
+ .getProfile(), accessToken, serverId);
+
+ if (wantToEquipCape == null) {
+ NotEnoughUpdates.INSTANCE.manager.hypixelApi.getMyApiAsync(
+ "cgi-bin/changecape.py?capeType=null&serverId=" +
+ serverId + "&username=" + userName,
+ System.out::println,
+ () -> System.out.println("Change cape error")
+ );
+ } else {
+ NotEnoughUpdates.INSTANCE.manager.hypixelApi.getMyApiAsync(
+ "cgi-bin/changecape.py?capeType=" + wantToEquipCape + "&serverId=" +
+ serverId + "&username=" + userName,
+ System.out::println,
+ () -> System.out.println("Change cape error")
+ );
+ }
+ } catch (Exception e) {
+ System.out.println("Exception while generating mojang shared secret");
+ e.printStackTrace();
+ }
+
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void mouseReleased(int mouseX, int mouseY, int state) {
+ super.mouseReleased(mouseX, mouseY, state);
+
+ scrollClickedX = -1;
+ }
+
+ @Override
+ protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
+ super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
+
+ if (scrollClickedX >= 0) {
+ float scrollStartX = mouseX - scrollClickedX;
+ scroll = (scrollStartX - (guiLeft + 15)) / 371f;
+ scroll = Math.max(0, Math.min(1, scroll));
+ }
+ }
+
+ private final HashMap<String, ResourceLocation> capesLocation = new HashMap<>();
+ private float scroll = 0f;
+ private int scrollClickedX = -1;
+
+ private void drawCapesPage(int mouseX, int mouseY, float partialTicks) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(cosmetics_fg);
+ Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements);
+ Utils.drawTexturedRect(guiLeft + 15 + 371 * scroll, guiTop + 177, 32, 12,
+ 0, 32 / 256f, 192 / 256f, 204 / 256f, GL11.GL_NEAREST
+ );
+
+ GL11.glEnable(GL11.GL_SCISSOR_TEST);
+ GL11.glScissor(Minecraft.getMinecraft().displayWidth * (guiLeft + 3) / width, 0,
+ Minecraft.getMinecraft().displayWidth * (sizeX - 6) / width, Minecraft.getMinecraft().displayHeight
+ );
+
+ int index = 0;
+ int displayingCapes = 0;
+ for (CapeManager.CapeData capeData : CapeManager.INSTANCE.getCapes()) {
+ boolean equipable = CapeManager.INSTANCE.getAvailableCapes() == null ||
+ CapeManager.INSTANCE.getAvailableCapes().contains(capeData.capeName);
+ if (capeData.canShow() || equipable) {
+ displayingCapes++;
+ }
+ }
+
+ float totalNeeded = 91 * displayingCapes;
+ float totalAvail = sizeX - 20;
+ float xOffset = scroll * (totalNeeded - totalAvail);
+
+ index = 0;
+ int displayIndex = 0;
+ for (CapeManager.CapeData capeData : CapeManager.INSTANCE.getCapes()) {
+ boolean equipable = CapeManager.INSTANCE.getAvailableCapes() == null ||
+ CapeManager.INSTANCE.getAvailableCapes().contains(capeData.capeName);
+ if (!capeData.canShow() && !equipable) continue;
+
+ if (capeData.capeName.equals(CapeManager.INSTANCE.getCape(Minecraft.getMinecraft().thePlayer
+ .getUniqueID()
+ .toString()
+ .replace("-", "")))) {
+ GlStateManager.color(250 / 255f, 200 / 255f, 0 / 255f, 1);
+ Utils.drawGradientRect(guiLeft + 20 + 91 * displayIndex - (int) xOffset, guiTop + 10,
+ guiLeft + 20 + 91 * displayIndex - (int) xOffset + 81, guiTop + 10 + 108,
+ new Color(150, 100, 0, 40).getRGB(), new Color(250, 200, 0, 40).getRGB()
+ );
+ } else if (capeData.capeName.equals(wantToEquipCape)) {
+ GlStateManager.color(0, 200 / 255f, 250 / 255f, 1);
+ Utils.drawGradientRect(guiLeft + 20 + 91 * displayIndex - (int) xOffset, guiTop + 10,
+ guiLeft + 20 + 91 * displayIndex - (int) xOffset + 81, guiTop + 10 + 108,
+ new Color(0, 100, 150, 40).getRGB(), new Color(0, 200, 250, 40).getRGB()
+ );
+ } else if (CapeManager.INSTANCE.localCape != null &&
+ CapeManager.INSTANCE.localCape.getRight().equals(capeData.capeName)) {
+ GlStateManager.color(100 / 255f, 250 / 255f, 150 / 255f, 1);
+ Utils.drawGradientRect(guiLeft + 20 + 91 * displayIndex - (int) xOffset, guiTop + 10,
+ guiLeft + 20 + 91 * displayIndex - (int) xOffset + 81, guiTop + 10 + 108,
+ new Color(50, 100, 75, 40).getRGB(), new Color(100, 250, 150, 40).getRGB()
+ );
+ }
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements);
+ Utils.drawTexturedRect(guiLeft + 20 + 91 * displayIndex - xOffset, guiTop + 10, 81, 108,
+ 0, 81 / 256f, 84 / 256f, 192 / 256f, GL11.GL_NEAREST
+ );
+ GlStateManager.color(1, 1, 1, 1);
+
+ Utils.drawTexturedRect(guiLeft + 20 + 91 * displayIndex - xOffset, guiTop + 123, 81, 20,
+ 0, 81 / 256f, 216 / 256f, 236 / 256f, GL11.GL_NEAREST
+ );
+
+ boolean equipPressed = capeData.capeName.equals(wantToEquipCape);
+ if (!equipable) GlStateManager.color(1, 1, 1, 0.5f);
+ Utils.drawTexturedRect(
+ guiLeft + 20 + 91 * displayIndex - xOffset,
+ guiTop + 149,
+ 81,
+ 20,
+ equipPressed ? 81 / 256f : 0,
+ equipPressed ? 0 : 81 / 256f,
+ equipPressed ? 236 / 256f : 216 / 256f,
+ equipPressed ? 216 / 256f : 236 / 256f,
+ GL11.GL_NEAREST
+ );
+
+ Utils.drawStringCenteredScaledMaxWidth(
+ "Try it out",
+ Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 20 + 91 * displayIndex + 81 / 2f - xOffset,
+ guiTop + 123 + 10,
+ false,
+ 75,
+ new Color(100, 250, 150).getRGB()
+ );
+ if (equipable) {
+ Utils.drawStringCenteredScaledMaxWidth(
+ "Equip",
+ Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 20 + 91 * displayIndex + 81 / 2f - xOffset,
+ guiTop + 149 + 10,
+ false,
+ 75,
+ new Color(100, 250, 150).getRGB()
+ );
+ } else {
+ Utils.drawStringCenteredScaledMaxWidth(
+ "Not Unlocked",
+ Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 20 + 91 * displayIndex + 81 / 2f - xOffset,
+ guiTop + 149 + 10,
+ false,
+ 75,
+ new Color(200, 50, 50, 100).getRGB()
+ );
+ }
+ GlStateManager.color(1, 1, 1, 1);
+
+ ResourceLocation capeTexture = capesLocation.computeIfAbsent(
+ capeData.capeName,
+ k -> new ResourceLocation("notenoughupdates", "capes/" + capeData.capeName + "_preview.png")
+ );
+ Minecraft.getMinecraft().getTextureManager().bindTexture(capeTexture);
+ Utils.drawTexturedRect(guiLeft + 31 + 91 * displayIndex - xOffset, guiTop + 24, 59, 84, GL11.GL_NEAREST);
+
+ displayIndex++;
+ }
+
+ GL11.glScissor(0, 0, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight);
+ GL11.glDisable(GL11.GL_SCISSOR_TEST);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements);
+ }
+
+ Shader blurShaderHorz = null;
+ Framebuffer blurOutputHorz = null;
+ Shader blurShaderVert = null;
+ Framebuffer blurOutputVert = null;
+
+ /**
+ * Creates a projection matrix that projects from our coordinate space [0->width; 0->height] to OpenGL coordinate
+ * space [-1 -> 1; 1 -> -1] (Note: flipped y-axis).
+ * <p>
+ * This is so that we can render to and from the framebuffer in a way that is familiar to us, instead of needing to
+ * apply scales and translations manually.
+ */
+ private Matrix4f createProjectionMatrix(int width, int height) {
+ Matrix4f projMatrix = new Matrix4f();
+ projMatrix.setIdentity();
+ projMatrix.m00 = 2.0F / (float) width;
+ projMatrix.m11 = 2.0F / (float) (-height);
+ projMatrix.m22 = -0.0020001999F;
+ projMatrix.m33 = 1.0F;
+ projMatrix.m03 = -1.0F;
+ projMatrix.m13 = 1.0F;
+ projMatrix.m23 = -1.0001999F;
+ return projMatrix;
+ }
+
+ /**
+ * Renders whatever is currently in the Minecraft framebuffer to our two framebuffers, applying a horizontal
+ * and vertical blur separately in order to significantly save computation time.
+ * This is only possible if framebuffers are supported by the system, so this method will exit prematurely
+ * if framebuffers are not available. (Apple machines, for example, have poor framebuffer support).
+ */
+ private double lastBgBlurFactor = -1;
+
+ private void blurBackground() {
+ int width = Minecraft.getMinecraft().displayWidth;
+ int height = Minecraft.getMinecraft().displayHeight;
+
+ if (blurOutputHorz == null) {
+ blurOutputHorz = new Framebuffer(width, height, false);
+ blurOutputHorz.setFramebufferFilter(GL11.GL_NEAREST);
+ }
+ if (blurOutputVert == null) {
+ blurOutputVert = new Framebuffer(width, height, false);
+ blurOutputVert.setFramebufferFilter(GL11.GL_NEAREST);
+ }
+ if (blurOutputHorz.framebufferWidth != width || blurOutputHorz.framebufferHeight != height) {
+ blurOutputHorz.createBindFramebuffer(width, height);
+ blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height));
+ Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
+ }
+ if (blurOutputVert.framebufferWidth != width || blurOutputVert.framebufferHeight != height) {
+ blurOutputVert.createBindFramebuffer(width, height);
+ blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height));
+ Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
+ }
+
+ if (blurShaderHorz == null) {
+ try {
+ blurShaderHorz = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur",
+ Minecraft.getMinecraft().getFramebuffer(), blurOutputHorz
+ );
+ blurShaderHorz.getShaderManager().getShaderUniform("BlurDir").set(1, 0);
+ blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height));
+ } catch (Exception ignored) {
+ }
+ }
+ if (blurShaderVert == null) {
+ try {
+ blurShaderVert = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur",
+ blurOutputHorz, blurOutputVert
+ );
+ blurShaderVert.getShaderManager().getShaderUniform("BlurDir").set(0, 1);
+ blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height));
+ } catch (Exception ignored) {
+ }
+ }
+ if (blurShaderHorz != null && blurShaderVert != null) {
+ if (15 != lastBgBlurFactor) {
+ blurShaderHorz.getShaderManager().getShaderUniform("Radius").set((float) 15);
+ blurShaderVert.getShaderManager().getShaderUniform("Radius").set((float) 15);
+ lastBgBlurFactor = 15;
+ }
+ GL11.glPushMatrix();
+ blurShaderHorz.loadShader(0);
+ blurShaderVert.loadShader(0);
+ GlStateManager.enableDepth();
+ GL11.glPopMatrix();
+
+ Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
+ }
+ }
+
+ /**
+ * Renders a subsection of the blurred framebuffer on to the corresponding section of the screen.
+ * Essentially, this method will "blur" the background inside the bounds specified by [x->x+blurWidth, y->y+blurHeight]
+ */
+ public void renderBlurredBackground(int width, int height, int x, int y, int blurWidth, int blurHeight) {
+ float uMin = x / (float) width;
+ float uMax = (x + blurWidth) / (float) width;
+ float vMin = (height - y) / (float) height;
+ float vMax = (height - y - blurHeight) / (float) height;
+
+ blurOutputVert.bindFramebufferTexture();
+ GlStateManager.color(1f, 1f, 1f, 1f);
+ //Utils.setScreen(width*f, height*f, f);
+ Utils.drawTexturedRect(x, y, blurWidth, blurHeight, uMin, uMax, vMin, vMax);
+ //Utils.setScreen(width, height, f);
+ blurOutputVert.unbindFramebufferTexture();
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/NEUCape.java b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/NEUCape.java
index 3b0e0928..da9d1f68 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/NEUCape.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/NEUCape.java
@@ -1,14 +1,8 @@
package io.github.moulberry.notenoughupdates.cosmetics;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
-import io.github.moulberry.notenoughupdates.core.util.lerp.LerpUtils;
-import io.github.moulberry.notenoughupdates.util.ReverseWorldRenderer;
-import io.github.moulberry.notenoughupdates.util.TexLoc;
-import io.github.moulberry.notenoughupdates.util.Utils;
-import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
@@ -18,16 +12,11 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.potion.Potion;
-import net.minecraft.util.BlockPos;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
-import net.minecraft.util.Vec3;
-import net.minecraft.world.gen.NoiseGeneratorSimplex;
import net.minecraftforge.client.event.RenderPlayerEvent;
-import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import org.lwjgl.BufferUtils;
-import org.lwjgl.Sys;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.*;
import org.lwjgl.util.vector.Vector2f;
@@ -35,1271 +24,1299 @@ import org.lwjgl.util.vector.Vector3f;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
-import java.nio.IntBuffer;
-import java.security.Key;
import java.util.*;
public class NEUCape {
-
- private int currentFrame = 0;
- private int displayFrame = 0;
- private String capeName;
- public ResourceLocation[] capeTextures = null;
-
- private long lastFrameUpdate = 0;
-
- private static int ANIM_MODE_LOOP = 0;
- private static int ANIM_MODE_PINGPONG = 1;
- private int animMode = ANIM_MODE_LOOP;
-
- private CapeNode[] nodes = null;
-
- private Random random = new Random();
-
- private long eventMillis;
- private float eventLength;
- private float eventRandom;
-
- private static double vertOffset = 1.4;
- private static double shoulderLength = 0.24;
- private static double shoulderWidth = 0.13;
-
- public static final int HORZ_NODES = 6;
- public static final int VERT_NODES = 22;
-
- public static float targetDist = 1 / 20f;
-
- private EntityPlayer currentPlayer;
- private boolean keepCurrentPlayer = false;
-
- private String shaderName = "cape";
-
- public NEUCape(String capeName) {
- setCapeTexture(capeName);
- }
-
- public void setCapeTexture(String capeName) {
- if(this.capeName != null && this.capeName.equalsIgnoreCase(capeName)) return;
-
- startTime = System.currentTimeMillis();
- boolean defaultBehaviour = true;
-
- if(NotEnoughUpdates.INSTANCE.config.hidden.disableBrokenCapes){
- if(capeName.equals("negative")){
- defaultBehaviour = false;
- this.capeName = "fade";
- this.shaderName = "fade_cape";
- }
-
- }
- if(defaultBehaviour){
- this.capeName = capeName;
-
- if (capeName.equalsIgnoreCase("fade")) {
- shaderName = "fade_cape";
- } else if (capeName.equalsIgnoreCase("space")) {
- shaderName = "space_cape";
- } else if (capeName.equalsIgnoreCase("mcworld")) {
- shaderName = "mcworld_cape";
- } else if(capeName.equalsIgnoreCase("lava") || capeName.equalsIgnoreCase("skyclient")) {
- shaderName = "lava_cape";
- } else if (capeName.equalsIgnoreCase("lightning")) {
- shaderName = "lightning_cape";
- } else if (capeName.equalsIgnoreCase("thebakery")) {
- shaderName = "biscuit_cape";
- } else if (capeName.equalsIgnoreCase("negative")) {
- shaderName = "negative";
- } else if (capeName.equalsIgnoreCase("void")) {
- shaderName = "void";
- } else if (capeName.equalsIgnoreCase("tunnel")) {
- shaderName = "tunnel";
- } else if (capeName.equalsIgnoreCase("planets")) {
- shaderName = "planets";
- } else {
- shaderName = "shiny_cape";
- }
- }
-
- ResourceLocation staticCapeTex = new ResourceLocation("notenoughupdates:capes/" + capeName + ".png");
- capeTextures = new ResourceLocation[1];
- capeTextures[0] = staticCapeTex;
- }
-
- private void bindTexture() {
- if(capeName.equalsIgnoreCase("negative")) {
- CapeManager.getInstance().updateWorldFramebuffer = true;
- if(CapeManager.getInstance().backgroundFramebuffer != null) {
- CapeManager.getInstance().backgroundFramebuffer.bindFramebufferTexture();
- }
- } else if(capeTextures != null && capeTextures.length > 0) {
- long currentTime = System.currentTimeMillis();
- if(currentTime - lastFrameUpdate > 100) {
- lastFrameUpdate = currentTime / 100 * 100;
- currentFrame++;
-
- if(animMode == ANIM_MODE_PINGPONG) {
- if(capeTextures.length == 1) {
- currentFrame = displayFrame = 0;
- } else {
- int frameCount = 2 * capeTextures.length - 2;
- currentFrame %= frameCount;
- displayFrame = currentFrame;
- if(currentFrame >= capeTextures.length) {
- displayFrame = frameCount - displayFrame;
- }
- }
- } else if(animMode == ANIM_MODE_LOOP) {
- currentFrame %= capeTextures.length;
- displayFrame = currentFrame;
- }
- }
- Minecraft.getMinecraft().getTextureManager().bindTexture(capeTextures[displayFrame]);
- }
- }
-
- private CapeNode getNode(int x, int y) {
- return nodes[x + y * HORZ_NODES];
- }
-
- public void createCapeNodes(EntityPlayer player) {
- nodes = new CapeNode[HORZ_NODES * VERT_NODES];
-
- float pX = (float) player.posX % 7789;
- float pY = (float) player.posY;
- float pZ = (float) player.posZ % 7789;
-
- float uMinTop = 48 / 1024f;
- float uMaxTop = 246 / 1024f;
- float uMinBottom = 0 / 1024f;
- float uMaxBottom = 293 / 1024f;
-
- float vMaxSide = 404 / 1024f;
- float vMaxCenter = 419 / 1024f;
-
- for(int i = 0; i < VERT_NODES; i++) {
- float uMin = uMinTop + (uMinBottom - uMinTop) * i / (float) (VERT_NODES - 1);
- float uMax = uMaxTop + (uMaxBottom - uMaxTop) * i / (float) (VERT_NODES - 1);
-
- for(int j = 0; j < HORZ_NODES; j++) {
- float vMin = 0f;
- float centerMult = 1 - Math.abs(j - (HORZ_NODES - 1) / 2f) / ((HORZ_NODES - 1) / 2f);//0-(horzCapeNodes) -> 0-1-0
- float vMax = vMaxSide + (vMaxCenter - vMaxSide) * centerMult;
-
- CapeNode node = new CapeNode(pX, pY, pZ);//pX-1, pY+2-i*targetDist, pZ+(j-(horzCapeNodes-1)/2f)*targetDist*2
- node.texU = uMin + (uMax - uMin) * j / (float) (HORZ_NODES - 1);
- node.texV = vMin + (vMax - vMin) * i / (float) (VERT_NODES - 1);
-
- node.horzDistMult = 2f + 1f * i / (float) (VERT_NODES - 1);
-
- if(j == 0 || j == HORZ_NODES - 1) {
- node.horzSideTexU = 406 / 1024f * i / (float) (VERT_NODES - 1);
- if(j == 0) {
- node.horzSideTexVTop = 1 - 20 / 1024f;
- } else {
- node.horzSideTexVTop = 1 - 40 / 1024f;
- }
- }
- if(i == 0) {
- node.vertSideTexU = 198 / 1024f * j / (float) (HORZ_NODES - 1);
- node.vertSideTexVTop = 1 - 60 / 1024f;
- } else if(i == VERT_NODES - 1) {
- node.vertSideTexU = 300 / 1024f * j / (float) (HORZ_NODES - 1);
- node.vertSideTexVTop = 1 - 80 / 1024f;
- }
- nodes[j + i * HORZ_NODES] = node;
- }
- }
- for(int y = 0; y < VERT_NODES; y++) {
- for(int x = 0; x < HORZ_NODES; x++) {
- CapeNode node = nodes[x + y * HORZ_NODES];
-
- for(Direction dir : Direction.values()) {
- for(int i = 1; i <= 2; i++) {
- Offset offset = new Offset(dir, i);
-
- int xNeighbor = x + offset.getXOffset();
- int yNeighbor = y + offset.getYOffset();
-
- if(xNeighbor >= 0 && xNeighbor < HORZ_NODES
- && yNeighbor >= 0 && yNeighbor < VERT_NODES) {
- CapeNode neighbor = nodes[xNeighbor + yNeighbor * HORZ_NODES];
- node.setNeighbor(offset, neighbor);
- }
- }
- }
- }
- }
- }
-
- public void ensureCapeNodesCreated(EntityPlayer player) {
- if(nodes == null) createCapeNodes(player);
- }
-
- public enum Direction {
- LEFT(-1, 0),
- UP(0, 1),
- RIGHT(1, 0),
- DOWN(0, -1),
- UPLEFT(-1, 1),
- UPRIGHT(1, 1),
- DOWNLEFT(-1, -1),
- DOWNRIGHT(1, -1);
-
- int xOff;
- int yOff;
-
- Direction(int xOff, int yOff) {
- this.xOff = xOff;
- this.yOff = yOff;
- }
-
- public Direction rotateRight90() {
- int wantXOff = -yOff;
- int wantYOff = xOff;
- for(Direction dir : values()) {
- if(dir.xOff == wantXOff && dir.yOff == wantYOff) {
- return dir;
- }
- }
- return this;
- }
-
- public Direction rotateLeft90() {
- int wantXOff = yOff;
- int wantYOff = -xOff;
- for(Direction dir : values()) {
- if(dir.xOff == wantXOff && dir.yOff == wantYOff) {
- return dir;
- }
- }
- return this;
- }
- }
-
- public static class Offset {
- Direction direction;
- int steps;
-
- public Offset(Direction direction, int steps) {
- this.direction = direction;
- this.steps = steps;
- }
-
- public int getXOffset() {
- return direction.xOff * steps;
- }
-
- public int getYOffset() {
- return direction.yOff * steps;
- }
-
- public boolean equals(Object obj) {
- if(obj instanceof Offset) {
- Offset other = (Offset) obj;
- return other.direction == direction && other.steps == steps;
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return 13 * direction.ordinal() + 7 * steps;
- }
- }
-
- private void loadShaderUniforms(ShaderManager shaderManager) {
- String shaderId = "capes/" + shaderName + "/" + shaderName;
- if(shaderName.equalsIgnoreCase("fade_cape") || shaderName.equalsIgnoreCase("planets")) {
- shaderManager.loadData(shaderId, "millis", (int) (System.currentTimeMillis() - startTime));
- } else if(shaderName.equalsIgnoreCase("space_cape")) {
- shaderManager.loadData(shaderId, "millis", (int) (System.currentTimeMillis() - startTime));
- shaderManager.loadData(shaderId, "eventMillis", (int) (System.currentTimeMillis() - eventMillis));
- shaderManager.loadData(shaderId, "eventRand", eventRandom);
- } else if(shaderName.equalsIgnoreCase("mcworld_cape")) {
- shaderManager.loadData(shaderId, "millis", (int) (System.currentTimeMillis() - startTime));
- } else if(shaderName.equalsIgnoreCase("lava_cape")) {
- shaderManager.loadData(shaderId, "millis", (int) (System.currentTimeMillis() - startTime));
- } else if(shaderName.equalsIgnoreCase("tunnel")) {
- shaderManager.loadData(shaderId, "millis", (int) (System.currentTimeMillis() - startTime));
- } else if(shaderName.equalsIgnoreCase("biscuit_cape") || shaderName.equalsIgnoreCase("shiny_cape")) {
- shaderManager.loadData(shaderId, "millis", (int) (System.currentTimeMillis() - startTime));
- shaderManager.loadData(shaderId, "eventMillis", (int) (System.currentTimeMillis() - eventMillis));
- } else if(shaderName.equalsIgnoreCase("negative")) {
- shaderManager.loadData(shaderId, "screensize", new Vector2f(
- Minecraft.getMinecraft().displayWidth,
- Minecraft.getMinecraft().displayHeight
- ));
- } else if(shaderName.equalsIgnoreCase("void")) {
- shaderManager.loadData(shaderId, "millis", (int) (System.currentTimeMillis() - startTime));
- shaderManager.loadData(shaderId, "screensize", new Vector2f(
- Minecraft.getMinecraft().displayWidth,
- Minecraft.getMinecraft().displayHeight
- ));
- }
- }
-
- long lastRender = 0;
-
- public void onRenderPlayer(RenderPlayerEvent.Post e) {
- EntityPlayer player = e.entityPlayer;
-
- if(currentPlayer != null && keepCurrentPlayer && currentPlayer != player) return;
-
- if(player.getActivePotionEffect(Potion.invisibility) != null) return;
- if(player.isSpectator() || player.isInvisible()) return;
-
- ensureCapeNodesCreated(player);
-
- Entity viewer = Minecraft.getMinecraft().getRenderViewEntity();
- double viewerX = (viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * e.partialRenderTick) % 7789;
- double viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * e.partialRenderTick;
- double viewerZ = (viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * e.partialRenderTick) % 7789;
-
- GlStateManager.pushMatrix();
- GlStateManager.enableBlend();
- GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA,
- GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
- bindTexture();
- GlStateManager.enableTexture2D();
- GlStateManager.enableDepth();
- GlStateManager.disableCull();
- GlStateManager.disableLighting();
- GlStateManager.color(1, 1, 1, 1);
-
- if(shaderName.equals("mcworld_cape")) {
- 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 {
- GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
- GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
- }
-
- GL11.glTranslatef(-(float) viewerX, -(float) viewerY, -(float) viewerZ);
-
- ShaderManager shaderManager = ShaderManager.getInstance();
- shaderManager.loadShader("capes/" + shaderName + "/" + shaderName);
- loadShaderUniforms(shaderManager);
-
- renderCape(player, e.partialRenderTick);
-
- GL11.glTranslatef((float) viewerX, (float) viewerY, (float) viewerZ);
-
- GL20.glUseProgram(0);
-
- GlStateManager.enableCull();
- GlStateManager.enableTexture2D();
- GlStateManager.disableBlend();
- GlStateManager.enableDepth();
- GlStateManager.enableLighting();
- GlStateManager.popMatrix();
-
- lastRender = System.currentTimeMillis();
- }
-
- public void onTick(TickEvent.ClientTickEvent event, EntityPlayer player) {
- if(player == null) return;
- if(Minecraft.getMinecraft().isGamePaused()) return;
-
- if(System.currentTimeMillis() - lastRender < 500) {
- if(currentPlayer == null || !keepCurrentPlayer) {
- keepCurrentPlayer = true;
- currentPlayer = player;
- } else if(currentPlayer != player) {
- return;
- }
-
- ensureCapeNodesCreated(player);
-
- for(int y = 0; y < VERT_NODES; y++) {
- for(int x = 0; x < HORZ_NODES; x++) {
- CapeNode node = nodes[x + y * HORZ_NODES];
- node.lastPosition.x = node.position.x;
- node.lastPosition.y = node.position.y;
- node.lastPosition.z = node.position.z;
- }
- }
- updateCape(player);
- } else {
- keepCurrentPlayer = false;
- }
- }
-
- private static double interpolateRotation(float a, float b, float amount) {
- double f;
-
- for(f = b - a; f < -180.0F; f += 360.0F) {
- ;
- }
-
- while(f >= 180.0F) {
- f -= 360.0F;
- }
-
- return a + amount * f;
- }
-
- private double getPlayerRenderAngle(EntityPlayer player, float partialRenderTick) {
- double angle = interpolateRotation(player.prevRenderYawOffset, player.renderYawOffset, partialRenderTick);
-
- if(player.isRiding() && player.ridingEntity instanceof EntityLivingBase && player.ridingEntity.shouldRiderSit()) {
-
- EntityLivingBase entitylivingbase = (EntityLivingBase) player.ridingEntity;
- double head = interpolateRotation(player.prevRotationYawHead, player.rotationYawHead, partialRenderTick);
- angle = interpolateRotation(entitylivingbase.prevRenderYawOffset, entitylivingbase.renderYawOffset, partialRenderTick);
- double wrapped = MathHelper.wrapAngleTo180_double(head - angle);
-
- if(wrapped < -85.0F) {
- wrapped = -85.0F;
- }
-
- if(wrapped >= 85.0F) {
- wrapped = 85.0F;
- }
-
- angle = head - wrapped;
-
- if(wrapped * wrapped > 2500.0F) {
- angle += wrapped * 0.2F;
- }
- }
-
- return Math.toRadians(angle);
- }
-
- private Vector3f updateFixedCapeNodes(EntityPlayer player) {
- double pX = player.posX % 7789;//player.lastTickPosX + (player.posX - player.lastTickPosX) * partialRenderTick;
- double pY = player.posY;//player.lastTickPosY + (player.posY - player.lastTickPosY) * partialRenderTick;
- double pZ = player.posZ % 7789;//player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialRenderTick;
- double angle = getPlayerRenderAngle(player, 0);
-
- double vertOffset2 = vertOffset + (player.isSneaking() ? -0.22f : 0) + (player.getCurrentArmor(2) != null ? 0.06f : 0);
- double shoulderWidth2 = shoulderWidth + (player.getCurrentArmor(2) != null ? 0.08f : 0);
-
- float xOff = (float) (Math.cos(angle) * shoulderLength);
- float zOff = (float) (Math.sin(angle) * shoulderLength);
-
- float totalDX = 0;
- float totalDY = 0;
- float totalDZ = 0;
- int totalMovements = 0;
-
- for(int i = 0; i < HORZ_NODES; i++) {
- float mult = 1 - 2f * i / (HORZ_NODES - 1); //1 -> -1
- float widthMult = 1.25f - (1.414f * i / (HORZ_NODES - 1) - 0.707f) * (1.414f * i / (HORZ_NODES - 1) - 0.707f);
- CapeNode node = nodes[i];
- float x = (float) pX + (float) (xOff * mult - widthMult * Math.cos(angle + Math.PI / 2) * shoulderWidth2);
- float y = (float) pY + (float) (vertOffset2);
- float z = (float) pZ + (float) (zOff * mult - widthMult * Math.sin(angle + Math.PI / 2) * shoulderWidth2);
- totalDX += x - node.position.x;
- totalDY += y - node.position.y;
- totalDZ += z - node.position.z;
- totalMovements++;
- node.position.x = x;
- node.position.y = y;
- node.position.z = z;
- node.fixed = true;
- }
-
- float avgDX = totalDX / totalMovements;
- float avgDY = totalDY / totalMovements;
- float avgDZ = totalDZ / totalMovements;
-
- return new Vector3f(avgDX, avgDY, avgDZ);
- }
-
- private void updateFixedCapeNodesPartial(EntityPlayer player, float partialRenderTick) {
- double pX = (player.lastTickPosX + (player.posX - player.lastTickPosX) * partialRenderTick) % 7789;
- double pY = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialRenderTick;
- double pZ = (player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialRenderTick) % 7789;
- double angle = getPlayerRenderAngle(player, partialRenderTick);
-
- double vertOffset2 = vertOffset + (player.isSneaking() ? -0.22f : 0) + (player.getCurrentArmor(2) != null ? 0.06f : 0);
- double shoulderWidth2 = shoulderWidth + (player.getCurrentArmor(2) != null ? 0.08f : 0);
-
- float xOff = (float) (Math.cos(angle) * shoulderLength);
- float zOff = (float) (Math.sin(angle) * shoulderLength);
-
- for(int i = 0; i < HORZ_NODES; i++) {
- float mult = 1 - 2f * i / (HORZ_NODES - 1); //1 -> -1
- float widthMult = 1.25f - (1.414f * i / (HORZ_NODES - 1) - 0.707f) * (1.414f * i / (HORZ_NODES - 1) - 0.707f);
- CapeNode node = nodes[i];
- node.renderPosition.x = (float) pX + (float) (xOff * mult - widthMult * Math.cos(angle + Math.PI / 2) * shoulderWidth2);
- node.renderPosition.y = (float) pY + (float) (vertOffset2);
- node.renderPosition.z = (float) pZ + (float) (zOff * mult - widthMult * Math.sin(angle + Math.PI / 2) * shoulderWidth2);
- node.fixed = true;
- }
- }
-
- private double deltaAngleAccum;
- private double oldPlayerAngle;
- private int crouchTicks = 0;
- long startTime = 0;
-
- private void updateCape(EntityPlayer player) {
- Vector3f capeTranslation = updateFixedCapeNodes(player);
-
- if(shaderName.equals("space_cape")) {
- long currentTime = System.currentTimeMillis();
- if(currentTime - startTime > eventMillis - startTime + eventLength) {
- eventMillis = currentTime;
- eventLength = random.nextFloat() * 2000 + 4000;
- eventRandom = random.nextFloat();
- }
- } else if(shaderName.equals("biscuit_cape") || shaderName.equals("shiny_cape")) {
- long currentTime = System.currentTimeMillis();
- if(currentTime - startTime > eventMillis - startTime + eventLength) {
- eventMillis = currentTime;
- eventLength = random.nextFloat() * 3000 + 3000;
- }
- }
-
- double playerAngle = getPlayerRenderAngle(player, 0);
- double deltaAngle = playerAngle - oldPlayerAngle;
- if(deltaAngle > Math.PI) {
- deltaAngle = 2 * Math.PI - deltaAngle;
- }
- if(deltaAngle < -Math.PI) {
- deltaAngle = 2 * Math.PI + deltaAngle;
- }
- deltaAngleAccum *= 0.5f;
- deltaAngleAccum += deltaAngle;
-
- float dX = (float) Math.cos(playerAngle + Math.PI / 2f);
- float dZ = (float) Math.sin(playerAngle + Math.PI / 2f);
-
- float factor = (float) (deltaAngleAccum * deltaAngleAccum);
-
- float capeTransLength = capeTranslation.length();
-
- float capeTranslationFactor = 0f;
- if(capeTransLength > 0.5f) {
- capeTranslationFactor = (capeTransLength - 0.5f) / capeTransLength;
- }
- Vector3f lookDir = new Vector3f(dX, 0, dZ);
- Vector3f lookDirNorm = lookDir.normalise(null);
- float dot = Vector3f.dot(capeTranslation, lookDirNorm);
- if(dot < 0) { //Moving backwards
- for(int y = 0; y < VERT_NODES; y++) {
- for(int x = 0; x < HORZ_NODES; x++) {
- CapeNode node = nodes[x + y * HORZ_NODES];
- if(!node.fixed) {
- node.position.x += lookDirNorm.x * dot;
- node.position.y += lookDirNorm.y * dot;
- node.position.z += lookDirNorm.z * dot;
- }
- }
- }
- //Apply small backwards force
- factor = 0.05f;
- }
-
- if(factor > 0) {
- for(int y = 0; y < VERT_NODES; y++) {
- for(int x = 0; x < HORZ_NODES; x++) {
- nodes[x + y * HORZ_NODES].applyForce(-dX * factor, 0, -dZ * factor);
- }
- }
- }
-
- if(capeTranslationFactor > 0f) {
- float capeDX = capeTranslation.x * capeTranslationFactor;
- float capeDY = capeTranslation.y * capeTranslationFactor;
- float capeDZ = capeTranslation.z * capeTranslationFactor;
-
- for(int y = 0; y < VERT_NODES; y++) {
- for(int x = 0; x < HORZ_NODES; x++) {
- CapeNode node = nodes[x + y * HORZ_NODES];
- if(!node.fixed) {
- node.position.x += capeDX;
- node.position.y += capeDY;
- node.position.z += capeDZ;
- }
- }
- }
- }
-
- //Wind
- float currTime = (System.currentTimeMillis() - startTime) / 1000f;
- float windRandom = Math.abs((float) (0.5f * Math.sin(0.22f * currTime) + Math.sin(0.44f * currTime) * Math.sin(0.47f * currTime)));
- double windDir = playerAngle + Math.PI / 4f * Math.sin(0.2f * currTime);
-
- float windDX = (float) Math.cos(windDir + Math.PI / 2f);
- float windDZ = (float) Math.sin(windDir + Math.PI / 2f);
- for(int y = 0; y < VERT_NODES; y++) {
- for(int x = 0; x < HORZ_NODES; x++) {
- nodes[x + y * HORZ_NODES].applyForce(-windDX * windRandom * 0.01f, 0, -windDZ * windRandom * 0.01f);
- }
- }
-
- if(player.isSneaking()) {
- crouchTicks++;
- float mult = 0.5f;
- if(crouchTicks < 5) {
- mult = 2f;
- }
- for(int y = 0; y < 8; y++) {
- for(int x = 0; x < HORZ_NODES; x++) {
- nodes[x + y * HORZ_NODES].applyForce(-dX * mult, 0, -dZ * mult);
- }
- }
- } else {
- crouchTicks = 0;
- }
-
- Vector3f avgPosition = avgFixedPosition();
- for(int y = 0; y < VERT_NODES; y++) {
- for(int x = 0; x < HORZ_NODES; x++) {
- CapeNode node = nodes[x + y * HORZ_NODES];
-
- Vector3f delta = Vector3f.sub(node.position, avgPosition, null);
-
- if(delta.lengthSquared() > 5 * 5) {
- Vector3f norm = delta.normalise(null);
- node.position = Vector3f.add(avgPosition, norm, null);
- }
- }
- }
-
- oldPlayerAngle = playerAngle;
-
- for(int y = 0; y < VERT_NODES; y++) {
- for(int x = 0; x < HORZ_NODES; x++) {
- nodes[x + y * HORZ_NODES].update();
- }
- }
- int updates = player == Minecraft.getMinecraft().thePlayer ? 50 : 50;
- for(int i = 0; i < updates; i++) {
- for(int y = 0; y < VERT_NODES; y++) {
- for(int x = 0; x < HORZ_NODES; x++) {
- nodes[x + y * HORZ_NODES].resolveAll(2 + 1f * y / VERT_NODES, false);
- }
- }
- }
- }
-
- private int ssbo = -1;
-
- private void generateSSBO() {
- ssbo = GL15.glGenBuffers();
- loadSBBO();
- }
-
- private void loadSBBO() {
- FloatBuffer buff = BufferUtils.createFloatBuffer(CapeNode.FLOAT_NUM * HORZ_NODES * VERT_NODES);
- for(int y = 0; y < VERT_NODES; y++) {
- for(int x = 0; x < HORZ_NODES; x++) {
- nodes[x + y * HORZ_NODES].loadIntoBuffer(buff);
- }
- }
- buff.flip();
-
- GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, ssbo);
- GL15.glBufferData(GL43.GL_SHADER_STORAGE_BUFFER, buff, GL15.GL_DYNAMIC_DRAW);
- GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, 0);
- }
-
- private void resolveAllCompute() {
- if(ssbo == -1) {
- generateSSBO();
- }
- loadSBBO();
-
- int program = ShaderManager.getInstance().getShader("node");
-
- int block_index = GL43.glGetProgramResourceIndex(program, GL43.GL_SHADER_STORAGE_BLOCK, "nodes_buffer");
- int ssbo_binding_point_index = 0;
- GL43.glShaderStorageBlockBinding(program, block_index, ssbo_binding_point_index);
- int binding_point_index = 0;
- GL30.glBindBufferBase(GL43.GL_SHADER_STORAGE_BUFFER, binding_point_index, ssbo);
-
- GL20.glUseProgram(program);
-
- for(int i = 0; i < 30; i++) {
- GL43.glDispatchCompute(VERT_NODES, 1, 1);
- GL42.glMemoryBarrier(GL43.GL_SHADER_STORAGE_BARRIER_BIT);
- }
-
- GL20.glUseProgram(0);
-
- FloatBuffer buff = BufferUtils.createFloatBuffer(CapeNode.FLOAT_NUM * HORZ_NODES * VERT_NODES);
-
- GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, ssbo);
- GL15.glGetBufferSubData(GL43.GL_SHADER_STORAGE_BUFFER, 0, buff);
- GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, 0);
-
- for(int y = 0; y < VERT_NODES; y++) {
- for(int x = 0; x < HORZ_NODES; x++) {
- nodes[x + y * HORZ_NODES].readFromBuffer(buff);
- }
- }
- }
-
- private Vector3f avgRenderPosition() {
- Vector3f accum = new Vector3f();
- int num = 0;
- for(int y = 0; y < VERT_NODES; y++) {
- for(int x = 0; x < HORZ_NODES; x++) {
- CapeNode node = nodes[x + y * HORZ_NODES];
- Vector3f.add(accum, node.renderPosition, accum);
- num++;
- }
- }
- if(num != 0) {
- accum.scale(1f / num);
- }
- return accum;
- }
-
- private Vector3f avgNormal() {
- Vector3f accum = new Vector3f();
- int num = 0;
- for(int y = 0; y < VERT_NODES; y++) {
- for(int x = 0; x < HORZ_NODES; x++) {
- CapeNode node = nodes[x + y * HORZ_NODES];
- Vector3f.add(accum, node.normal(), accum);
- num++;
- }
- }
- if(num != 0) {
- accum.scale(1f / num);
- }
- return accum;
- }
-
- private Vector3f avgFixedRenderPosition() {
- Vector3f accum = new Vector3f();
- int numFixed = 0;
- for(int y = 0; y < VERT_NODES; y++) {
- for(int x = 0; x < HORZ_NODES; x++) {
- CapeNode node = nodes[x + y * HORZ_NODES];
- if(node.fixed) {
- Vector3f.add(accum, node.renderPosition, accum);
- numFixed++;
- }
- }
- }
- if(numFixed != 0) {
- accum.scale(1f / numFixed);
- }
- return accum;
- }
-
- private Vector3f avgFixedPosition() {
- Vector3f accum = new Vector3f();
- int numFixed = 0;
- for(int y = 0; y < VERT_NODES; y++) {
- for(int x = 0; x < HORZ_NODES; x++) {
- CapeNode node = nodes[x + y * HORZ_NODES];
- if(node.fixed) {
- Vector3f.add(accum, node.position, accum);
- numFixed++;
- }
- }
- }
- if(numFixed != 0) {
- accum.scale(1f / numFixed);
- }
- return accum;
- }
-
- private void renderBackAndDoFrontStencil() {
- for(int y = 0; y < VERT_NODES; y++) {
- for(int x = 0; x < HORZ_NODES; x++) {
- nodes[x + y * HORZ_NODES].renderNode(CapeNode.DRAW_MASK_BACK | CapeNode.DRAW_MASK_SIDES);
- }
- }
-
- if(!Minecraft.getMinecraft().getFramebuffer().isStencilEnabled())
- Minecraft.getMinecraft().getFramebuffer().enableStencil();
-
- GL11.glEnable(GL11.GL_STENCIL_TEST);
- GL11.glStencilFunc(GL11.GL_ALWAYS, 1, 0xFF);
- GL11.glStencilOp(GL11.GL_ZERO, GL11.GL_ZERO, GL11.GL_REPLACE);
- GL11.glStencilMask(0xFF);
- GL11.glClear(GL11.GL_STENCIL_BUFFER_BIT);
- GlStateManager.enableDepth();
-
- GL11.glColorMask(false, false, false, false);
- for(int y = 0; y < VERT_NODES; y++) {
- for(int x = 0; x < HORZ_NODES; x++) {
- nodes[x + y * HORZ_NODES].renderNode(CapeNode.DRAW_MASK_FRONT);
- }
- }
- GL11.glColorMask(true, true, true, true);
-
- // Only pass stencil test if equal to 1
- GL11.glStencilMask(0x00);
- GL11.glStencilFunc(GL11.GL_EQUAL, 1, 0xFF);
- }
-
- private Vector3f getPoint(Vector3f point, Vector3f... vectors) {
- Vector3f res = new Vector3f(point);
- for(Vector3f vec : vectors) Vector3f.add(res, vec, res);
- return res;
- }
-
- private static void renderVBO(WorldRenderer worldRenderer) {
- if(worldRenderer != null && worldRenderer.getVertexCount() > 0) {
- VertexFormat vertexformat = worldRenderer.getVertexFormat();
- int stride = vertexformat.getNextOffset();
- ByteBuffer bytebuffer = worldRenderer.getByteBuffer();
- List<VertexFormatElement> list = vertexformat.getElements();
-
- for(int index = 0; index < list.size(); index++) {
- VertexFormatElement vertexformatelement = list.get(index);
- vertexformatelement.getUsage().preDraw(vertexformat, index, stride, bytebuffer);
- }
-
- GL11.glDrawArrays(worldRenderer.getDrawMode(), 0, worldRenderer.getVertexCount());
-
- for(int index = 0; index < list.size(); index++) {
- VertexFormatElement vertexformatelement = list.get(index);
- vertexformatelement.getUsage().postDraw(vertexformat, index, stride, bytebuffer);
- }
- }
- }
-
- private static WorldRenderer sphereVBO = null;
-
- private void renderNodes() {
- if(capeName.equalsIgnoreCase("planets")) {
- renderBackAndDoFrontStencil();
-
- Vector3f pointNorm = avgNormal();
- Vector3f capeAvgPos = avgRenderPosition();
-
- pointNorm.scale(0.5f / pointNorm.length());
- pointNorm.scale(1 - pointNorm.y / 1.3f);
- Vector3f point = Vector3f.sub(capeAvgPos, pointNorm, null);
-
- if(sphereVBO == null || Keyboard.isKeyDown(Keyboard.KEY_K)) {
- if(sphereVBO != null) sphereVBO.reset();
-
- int arcSegments = 24;
- int rotationSegments = 24;
- double arcAngleDelta = Math.PI / (arcSegments - 1);
-
- float xScale = 0.95f;
-
- double diameterUnitArcLen = 0;
-
- double arcAngle = 0;
- for(int i = 0; i < arcSegments; i++) {
- diameterUnitArcLen += Math.sin(arcAngle);
- arcAngle += arcAngleDelta;
- }
- double arcLength = 2f / diameterUnitArcLen;
-
- List<List<Vector3f>> arcs = new ArrayList<>();
- for(int angleI = 0; angleI < rotationSegments; angleI++) {
- double angle = Math.PI * 2 * angleI / rotationSegments;
-
- List<Vector3f> arc = new ArrayList<>();
-
- Vector3f arcPos = new Vector3f(0, 0, -1);
-
- arc.add(arcPos);
-
- arcAngle = 0;
- for(int segmentI = 0; segmentI < arcSegments; segmentI++) {
-
- double deltaZ = Math.sin(arcAngle) * arcLength;
- double deltaY = Math.cos(arcAngle) * Math.cos(angle) * arcLength;
- double deltaX = Math.cos(arcAngle) * Math.sin(angle) * arcLength * xScale;
-
- arcPos = new Vector3f(arcPos);
- arcPos.z += deltaZ;
- arcPos.y += deltaY;
- arcPos.x += deltaX;
- arcPos.normalise();
- arc.add(arcPos);
-
- arcAngle += arcAngleDelta;
- }
-
- arcs.add(arc);
- }
-
- sphereVBO = new WorldRenderer(8 * 4 * rotationSegments * arcSegments);
- sphereVBO.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_NORMAL);
-
- double maxXYRad = 0;
- for(int angleI = 0; angleI < rotationSegments; angleI++) {
- for(int segmentI = 0; segmentI <= arcSegments; segmentI++) {
- List<Vector3f> thisArc = arcs.get(angleI);
- Vector3f point1 = thisArc.get(segmentI);
- double rad = Math.sqrt(point1.x * point1.x + point1.y * point1.y);
- maxXYRad = Math.max(maxXYRad, rad);
- }
- }
-
- for(int angleI = 0; angleI < rotationSegments; angleI++) {
-
- int nextAngleI = angleI + 1;
- if(angleI == rotationSegments - 1) {
- nextAngleI = 0;
- }
-
- float v = 0.5f * (angleI) / (rotationSegments);
- float v2 = 0.5f * (angleI + 1) / (rotationSegments);
- //if(v2 == 0) v2 = 0.5f;
-
- List<Vector3f> thisArc = arcs.get(angleI);
- List<Vector3f> nextArc = arcs.get(nextAngleI);
-
- for(int segmentI = 1; segmentI <= arcSegments; segmentI++) {
- Vector3f point1 = thisArc.get(segmentI);
- Vector3f point2 = thisArc.get(segmentI - 1);
- Vector3f point3 = nextArc.get(segmentI - 1);
- Vector3f point4 = nextArc.get(segmentI);
-
- double u1 = 0.5f * segmentI / arcSegments;
- double u2 = 0.5f * (segmentI - 1) / arcSegments;
-
- sphereVBO.pos(point4.x, point4.y, point4.z)
- .tex(u1, v2).normal(-point4.x, -point4.y, -point4.z).endVertex();
- sphereVBO.pos(point3.x, point3.y, point3.z)
- .tex(u2, v2).normal(-point3.x, -point3.y, -point3.z).endVertex();
- sphereVBO.pos(point2.x, point2.y, point2.z)
- .tex(u2, v).normal(-point2.x, -point2.y, -point2.z).endVertex();
- sphereVBO.pos(point1.x, point1.y, point1.z)
- .tex(u1, v).normal(-point1.x, -point1.y, -point1.z).endVertex();
- }
- }
- }
-
- String shaderId = "capes/" + shaderName + "/" + shaderName;
- double mercuryAngle = Math.PI * 2 * ((System.currentTimeMillis() - startTime) / 10000f % 1);
- double mercuryX = Math.sin(mercuryAngle) * 0.3;
- double mercuryZ = Math.cos(mercuryAngle) * 0.3;
-
- double earthAngle = Math.PI * 2 * ((System.currentTimeMillis() - startTime) / 30000f % 1);
- double earthSlant = Math.PI * 0.1;
- double earthX = Math.sin(earthAngle) * Math.cos(earthSlant) * 0.6;
- double earthY = Math.sin(earthAngle) * Math.sin(earthSlant) * 0.6;
- double earthZ = Math.cos(earthAngle) * Math.cos(earthSlant) * 0.6;
-
- float sunDist = Vector3f.sub(point, capeAvgPos, null).lengthSquared();
- float mercuryDist = Vector3f.sub(new Vector3f(point.x + (float) mercuryX, point.y, point.z + (float) mercuryZ),
- capeAvgPos, null).lengthSquared();
- float earthDist = Vector3f.sub(new Vector3f(point.x + (float) earthX, point.y + (float) earthY, point.z + (float) earthZ),
- capeAvgPos, null).lengthSquared();
-
- double jupiterAngle = Math.PI * 2 * ((System.currentTimeMillis() - startTime) / 200000f % 1);
- double jupiterSlant = Math.PI * -0.08;
- double jupiterX = Math.sin(jupiterAngle) * Math.cos(jupiterSlant) * 1.5;
- double jupiterY = Math.sin(jupiterAngle) * Math.sin(jupiterSlant) * 1.5;
- double jupiterZ = Math.cos(jupiterAngle) * Math.cos(jupiterSlant) * 1.5;
- float jupiterDist = Vector3f.sub(new Vector3f(point.x + (float) jupiterX, point.y + (float) jupiterY, point.z + (float) jupiterZ),
- capeAvgPos, null).lengthSquared();
-
- double neptuneX = -Math.sin(earthAngle) * Math.cos(earthSlant);
- double neptuneY = -Math.sin(earthAngle) * Math.sin(earthSlant);
- double neptuneZ = -Math.cos(earthAngle) * Math.cos(earthSlant);
-
- float neptuneDist = Vector3f.sub(new Vector3f(point.x + (float) neptuneX, point.y + (float) neptuneY, point.z + (float) neptuneZ),
- capeAvgPos, null).lengthSquared();
-
- TreeMap<Float, Integer> orbitals = new TreeMap<>();
- orbitals.put(sunDist, 0);
- orbitals.put(earthDist, 1);
- orbitals.put(mercuryDist, 2);
-
- double delta = Minecraft.getMinecraft().getRenderViewEntity().getRotationYawHead() % 360;
- while(delta < 0) delta += 360;
-
- double jupDelta = (delta + Math.toDegrees(jupiterAngle)) % 360;
- while(jupDelta < 0) jupDelta += 360;
- if(jupDelta > 250 || jupDelta < 110) orbitals.put(jupiterDist, 3);
-
- double nepDelta = (delta + Math.toDegrees(-earthAngle)) % 360;
- while(nepDelta < 0) nepDelta += 360;
- if(nepDelta > 250 || nepDelta < 110) orbitals.put(neptuneDist, 4);
-
- GlStateManager.disableDepth();
- GlStateManager.enableCull();
-
- for(int planetId : orbitals.descendingMap().values()) {
- GlStateManager.pushMatrix();
- switch(planetId) {
- case 0: {
- GlStateManager.translate(point.x, point.y, point.z);
- GlStateManager.scale(0.2f, 0.2f, 0.2f);
- break;
- }
- case 1: {
- Vector3f sunVec = new Vector3f((float) earthX, (float) earthY, (float) earthZ);
- ShaderManager.getInstance().loadData(shaderId, "sunVec", sunVec);
- GlStateManager.translate(point.x + earthX, point.y + earthY, point.z + earthZ);
- GlStateManager.scale(0.1f, 0.1f, 0.1f);
- break;
- }
- case 2: {
- Vector3f sunVec = new Vector3f((float) mercuryX, 0, (float) mercuryZ);
- ShaderManager.getInstance().loadData(shaderId, "sunVec", sunVec);
- GlStateManager.translate(point.x + mercuryX, point.y, point.z + mercuryZ);
- GlStateManager.scale(0.05f, 0.05f, 0.05f);
- break;
- }
- case 3: {
- Vector3f sunVec = new Vector3f((float) jupiterX, (float) jupiterY, (float) jupiterZ);
- ShaderManager.getInstance().loadData(shaderId, "sunVec", sunVec);
- GlStateManager.translate(point.x + jupiterX, point.y + jupiterY, point.z + jupiterZ);
- GlStateManager.scale(0.3f, 0.3f, 0.3f);
- break;
- }
- case 4: {
- Vector3f sunVec = new Vector3f((float) neptuneX, (float) neptuneY, (float) neptuneZ);
- ShaderManager.getInstance().loadData(shaderId, "sunVec", sunVec);
- GlStateManager.translate(point.x + neptuneX, point.y + neptuneY, point.z + neptuneZ);
- GlStateManager.scale(0.15f, 0.15f, 0.15f);
- break;
- }
- }
- ShaderManager.getInstance().loadData(shaderId, "planetType", planetId);
- renderVBO(sphereVBO);
- GlStateManager.popMatrix();
- }
-
-
- GlStateManager.disableCull();
- GlStateManager.enableDepth();
-
- GL11.glDisable(GL11.GL_STENCIL_TEST);
- } else if(capeName.equalsIgnoreCase("parallax")) {
- renderBackAndDoFrontStencil();
-
- Vector3f pointNorm = avgNormal();
- pointNorm.scale(-0.2f / pointNorm.length());
- Vector3f negPointNorm = new Vector3f(pointNorm);
- negPointNorm.scale(-1);
- //pointNorm.scale(1 - pointNorm.y/1.3f);
- Vector3f point = Vector3f.add(avgRenderPosition(), pointNorm, null);
- Vector3f fixedPoint = Vector3f.add(avgFixedRenderPosition(), pointNorm, null);
-
- Vector3f up = Vector3f.sub(fixedPoint, point, null);
- float halfUp = up.length();
-
- Vector3f down = new Vector3f(up);
- down.scale(-1);
-
- Vector3f left = Vector3f.cross(up, pointNorm, null);
- left.scale(halfUp * 522f / 341f / left.length());
- Vector3f right = new Vector3f(left);
- right.scale(-1);
-
- Vector3f point1 = getPoint(point, left);
- Vector3f point2 = getPoint(point, left, down, down);
- Vector3f point3 = getPoint(point, right, down, down);
- Vector3f point4 = getPoint(point, right);
-
- Vector3f point2Edge = getPoint(point2, negPointNorm, negPointNorm);
- Vector3f point3Edge = getPoint(point3, negPointNorm, negPointNorm);
-
- GlStateManager.disableDepth();
- GlStateManager.disableCull();
-
- GlStateManager.color(1, 1, 1, 1);
-
- Tessellator tessellator = Tessellator.getInstance();
- WorldRenderer worldrenderer = tessellator.getWorldRenderer();
- worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
-
- worldrenderer.pos(point1.x, point1.y, point1.z)
- .tex(0, 943 / 1024f).endVertex();
- worldrenderer.pos(point2.x, point2.y, point2.z)
- .tex(280 / 1024f, 943 / 1024f).endVertex();
- worldrenderer.pos(point3.x, point3.y, point3.z)
- .tex(280 / 1024f, 421 / 1024f).endVertex();
- worldrenderer.pos(point4.x, point4.y, point4.z)
- .tex(0, 421 / 1024f).endVertex();
-
- tessellator.draw();
-
- worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
-
- worldrenderer.pos(point2.x, point2.y, point2.z)
- .tex(280 / 1024f, 943 / 1024f).endVertex();
- worldrenderer.pos(point2Edge.x, point2Edge.y, point2Edge.z)
- .tex(341 / 1024f, 943 / 1024f).endVertex();
- worldrenderer.pos(point3Edge.x, point3Edge.y, point3Edge.z)
- .tex(341 / 1024f, 421 / 1024f).endVertex();
- worldrenderer.pos(point3.x, point3.y, point3.z)
- .tex(280 / 1024f, 421 / 1024f).endVertex();
-
- tessellator.draw();
-
-
- GlStateManager.disableCull();
- GlStateManager.enableDepth();
-
- GL11.glDisable(GL11.GL_STENCIL_TEST);
- } else if(capeName.equalsIgnoreCase("tunnel")) {
- renderBackAndDoFrontStencil();
-
- Vector3f pointNorm = avgNormal();
-
- pointNorm.scale(0.7f / pointNorm.length());
- pointNorm.scale(1 - pointNorm.y / 1.3f);
- Vector3f point = Vector3f.sub(avgRenderPosition(), pointNorm, null);
-
- List<CapeNode> edgeNodes = new ArrayList<>();
- List<Vector2f> edgeCoords = new ArrayList<>();
-
- //Left edge
- for(int y = 0; y < VERT_NODES; y++) {
- edgeNodes.add(nodes[y * HORZ_NODES]);
- edgeCoords.add(new Vector2f(0, (float) y / (VERT_NODES - 1)));
- }
- edgeNodes.add(null);
- edgeCoords.add(null);
- //Bottom edge
- int bottomIndex = VERT_NODES - 1;
- int botSize = HORZ_NODES;
- for(int x = 0; x < botSize; x++) {
- edgeNodes.add(getNode(x, bottomIndex));
- edgeCoords.add(new Vector2f((float) x / (botSize - 1), 1));
- }
- edgeNodes.add(null);
- edgeCoords.add(null);
- //Right edge
- for(int y = VERT_NODES - 1; y >= 0; y--) {
- edgeNodes.add(getNode(HORZ_NODES - 1, y));
- edgeCoords.add(new Vector2f(1, (float) y / VERT_NODES));
- }
- edgeNodes.add(null);
- edgeCoords.add(null);
- //Top edge
- int topSize = HORZ_NODES;
- for(int x = topSize - 1; x >= 0; x--) {
- edgeNodes.add(getNode(x, 0));
- edgeCoords.add(new Vector2f((float) x / (topSize - 1), 0));
- }
-
- GlStateManager.disableDepth();
- GlStateManager.enableCull();
- CapeNode last = null;
- for(int i = 0; i < edgeNodes.size(); i++) {
- CapeNode node = edgeNodes.get(i);
- if(last != null && node != null) {
- Vector2f lastCoord = edgeCoords.get(i - 1);
- Vector2f coord = edgeCoords.get(i);
-
- Tessellator tessellator = Tessellator.getInstance();
- WorldRenderer worldrenderer = tessellator.getWorldRenderer();
- worldrenderer.begin(GL11.GL_TRIANGLES, DefaultVertexFormats.POSITION_TEX_NORMAL);
-
- Vector3f lastNodeNorm = last.normal();
- worldrenderer.pos(last.renderPosition.x + lastNodeNorm.x * 0.05f, last.renderPosition.y + lastNodeNorm.y * 0.05f, last.renderPosition.z + lastNodeNorm.z * 0.05f)
- .tex(lastCoord.x * 300f / 1024f, lastCoord.y * 420f / 1024f)
- .normal(-lastNodeNorm.x, -lastNodeNorm.y, -lastNodeNorm.z).endVertex();
-
- Vector3f nodeNorm = node.normal();
- worldrenderer.pos(node.renderPosition.x + nodeNorm.x * 0.05f, node.renderPosition.y + nodeNorm.y * 0.05f, node.renderPosition.z + nodeNorm.z * 0.05f)
- .tex(coord.x * 300f / 1024f, coord.y * 420f / 1024f)
- .normal(-nodeNorm.x, -nodeNorm.y, -nodeNorm.z).endVertex();
-
- worldrenderer.pos(point.x, point.y, point.z)
- .tex(150f / 1024f, 210f / 1024f)
- .normal(-pointNorm.x, -pointNorm.y, -pointNorm.z).endVertex();
-
- tessellator.draw();
- }
- last = node;
- }
- GlStateManager.disableCull();
- GlStateManager.enableDepth();
-
- GL11.glDisable(GL11.GL_STENCIL_TEST);
- } else {
- for(int y = 0; y < VERT_NODES; y++) {
- for(int x = 0; x < HORZ_NODES; x++) {
- nodes[x + y * HORZ_NODES].renderNode();
- }
- }
- }
- }
-
- private void renderCape(EntityPlayer player, float partialRenderTick) {
- ensureCapeNodesCreated(player);
-
- Vector3f avgPositionFixedBefore = avgFixedRenderPosition();
- updateFixedCapeNodesPartial(player, partialRenderTick);
- Vector3f avgPositionFixed = avgFixedRenderPosition();
- Vector3f delta = Vector3f.sub(avgPositionFixed, avgPositionFixedBefore, null);
-
- if(delta.lengthSquared() > 9) {
- updateFixedCapeNodes(player);
-
- for(int y = 0; y < VERT_NODES; y++) {
- for(int x = 0; x < HORZ_NODES; x++) {
- CapeNode node = nodes[x + y * HORZ_NODES];
- if(!node.fixed) {
- Vector3f.add(node.renderPosition, delta, node.renderPosition);
- node.position.set(node.renderPosition);
- node.lastPosition.set(node.renderPosition);
- } else {
- node.lastPosition.set(node.position);
- }
- }
- }
-
- renderNodes();
- return;
- }
-
- for(int y = 0; y < VERT_NODES; y++) {
- for(int x = 0; x < HORZ_NODES; x++) {
- CapeNode node = nodes[x + y * HORZ_NODES];
-
- node.resetNormal();
-
- if(node.fixed) continue;
-
- Vector3f newPosition = new Vector3f();
- newPosition.x = node.lastPosition.x + (node.position.x - node.lastPosition.x) * partialRenderTick;
- newPosition.y = node.lastPosition.y + (node.position.y - node.lastPosition.y) * partialRenderTick;
- newPosition.z = node.lastPosition.z + (node.position.z - node.lastPosition.z) * partialRenderTick;
-
- int length = node.oldRenderPosition.length;
-
- int fps = Minecraft.getDebugFPS();
- if(fps < 50) {
- length = 2;
- } else if(fps < 100) {
- length = 2 + (int) ((fps - 50) / 50f * 3);
- }
-
- if(node.oldRenderPosition[length - 1] == null) {
- Arrays.fill(node.oldRenderPosition, Vector3f.sub(newPosition, avgPositionFixed, null));
- node.renderPosition = newPosition;
- } else {
- Vector3f accum = new Vector3f();
- for(int i = 0; i < length; i++) {
- Vector3f.add(accum, node.oldRenderPosition[i], accum);
- Vector3f.add(accum, avgPositionFixed, accum);
- }
- accum.scale(1 / (float) (length));
-
- float blendFactor = 0.5f + 0.3f * y / (float) (VERT_NODES - 1); //0.5/0.5 -> 0.8/0.2 //0-1
- accum.scale(blendFactor);
- newPosition.scale(1 - blendFactor);
- Vector3f.add(accum, newPosition, accum);
- node.renderPosition = accum;
- }
-
- if(!Minecraft.getMinecraft().isGamePaused()) {
- for(int i = node.oldRenderPosition.length - 1; i >= 0; i--) {
- if(i > 0) {
- node.oldRenderPosition[i] = node.oldRenderPosition[i - 1];
- } else {
- node.oldRenderPosition[i] = Vector3f.sub(node.renderPosition, avgPositionFixed, null);
- }
- }
- }
- }
- }
- renderNodes();
- }
-
+ private int currentFrame = 0;
+ private int displayFrame = 0;
+ private String capeName;
+ public ResourceLocation[] capeTextures = null;
+
+ private long lastFrameUpdate = 0;
+
+ private static final int ANIM_MODE_LOOP = 0;
+ private static final int ANIM_MODE_PINGPONG = 1;
+ private final int animMode = ANIM_MODE_LOOP;
+
+ private CapeNode[] nodes = null;
+
+ private final Random random = new Random();
+
+ private long eventMillis;
+ private float eventLength;
+ private float eventRandom;
+
+ private static final double vertOffset = 1.4;
+ private static final double shoulderLength = 0.24;
+ private static final double shoulderWidth = 0.13;
+
+ public static final int HORZ_NODES = 6;
+ public static final int VERT_NODES = 22;
+
+ public static float targetDist = 1 / 20f;
+
+ private EntityPlayer currentPlayer;
+ private boolean keepCurrentPlayer = false;
+
+ private String shaderName = "cape";
+
+ public NEUCape(String capeName) {
+ setCapeTexture(capeName);
+ }
+
+ public void setCapeTexture(String capeName) {
+ if (this.capeName != null && this.capeName.equalsIgnoreCase(capeName)) return;
+
+ startTime = System.currentTimeMillis();
+ boolean defaultBehaviour = true;
+
+ if (NotEnoughUpdates.INSTANCE.config.hidden.disableBrokenCapes) {
+ if (capeName.equals("negative")) {
+ defaultBehaviour = false;
+ this.capeName = "fade";
+ this.shaderName = "fade_cape";
+ }
+
+ }
+ if (defaultBehaviour) {
+ this.capeName = capeName;
+
+ if (capeName.equalsIgnoreCase("fade")) {
+ shaderName = "fade_cape";
+ } else if (capeName.equalsIgnoreCase("space")) {
+ shaderName = "space_cape";
+ } else if (capeName.equalsIgnoreCase("mcworld")) {
+ shaderName = "mcworld_cape";
+ } else if (capeName.equalsIgnoreCase("lava") || capeName.equalsIgnoreCase("skyclient")) {
+ shaderName = "lava_cape";
+ } else if (capeName.equalsIgnoreCase("lightning")) {
+ shaderName = "lightning_cape";
+ } else if (capeName.equalsIgnoreCase("thebakery")) {
+ shaderName = "biscuit_cape";
+ } else if (capeName.equalsIgnoreCase("negative")) {
+ shaderName = "negative";
+ } else if (capeName.equalsIgnoreCase("void")) {
+ shaderName = "void";
+ } else if (capeName.equalsIgnoreCase("tunnel")) {
+ shaderName = "tunnel";
+ } else if (capeName.equalsIgnoreCase("planets")) {
+ shaderName = "planets";
+ } else {
+ shaderName = "shiny_cape";
+ }
+ }
+
+ ResourceLocation staticCapeTex = new ResourceLocation("notenoughupdates:capes/" + capeName + ".png");
+ capeTextures = new ResourceLocation[1];
+ capeTextures[0] = staticCapeTex;
+ }
+
+ private void bindTexture() {
+ if (capeName.equalsIgnoreCase("negative")) {
+ CapeManager.getInstance().updateWorldFramebuffer = true;
+ if (CapeManager.getInstance().backgroundFramebuffer != null) {
+ CapeManager.getInstance().backgroundFramebuffer.bindFramebufferTexture();
+ }
+ } else if (capeTextures != null && capeTextures.length > 0) {
+ long currentTime = System.currentTimeMillis();
+ if (currentTime - lastFrameUpdate > 100) {
+ lastFrameUpdate = currentTime / 100 * 100;
+ currentFrame++;
+
+ if (animMode == ANIM_MODE_PINGPONG) {
+ if (capeTextures.length == 1) {
+ currentFrame = displayFrame = 0;
+ } else {
+ int frameCount = 2 * capeTextures.length - 2;
+ currentFrame %= frameCount;
+ displayFrame = currentFrame;
+ if (currentFrame >= capeTextures.length) {
+ displayFrame = frameCount - displayFrame;
+ }
+ }
+ } else if (animMode == ANIM_MODE_LOOP) {
+ currentFrame %= capeTextures.length;
+ displayFrame = currentFrame;
+ }
+ }
+ Minecraft.getMinecraft().getTextureManager().bindTexture(capeTextures[displayFrame]);
+ }
+ }
+
+ private CapeNode getNode(int x, int y) {
+ return nodes[x + y * HORZ_NODES];
+ }
+
+ public void createCapeNodes(EntityPlayer player) {
+ nodes = new CapeNode[HORZ_NODES * VERT_NODES];
+
+ float pX = (float) player.posX % 7789;
+ float pY = (float) player.posY;
+ float pZ = (float) player.posZ % 7789;
+
+ float uMinTop = 48 / 1024f;
+ float uMaxTop = 246 / 1024f;
+ float uMinBottom = 0 / 1024f;
+ float uMaxBottom = 293 / 1024f;
+
+ float vMaxSide = 404 / 1024f;
+ float vMaxCenter = 419 / 1024f;
+
+ for (int i = 0; i < VERT_NODES; i++) {
+ float uMin = uMinTop + (uMinBottom - uMinTop) * i / (float) (VERT_NODES - 1);
+ float uMax = uMaxTop + (uMaxBottom - uMaxTop) * i / (float) (VERT_NODES - 1);
+
+ for (int j = 0; j < HORZ_NODES; j++) {
+ float vMin = 0f;
+ float centerMult = 1 - Math.abs(j - (HORZ_NODES - 1) / 2f) /
+ ((HORZ_NODES - 1) / 2f);//0-(horzCapeNodes) -> 0-1-0
+ float vMax = vMaxSide + (vMaxCenter - vMaxSide) * centerMult;
+
+ CapeNode node = new CapeNode(pX, pY, pZ);//pX-1, pY+2-i*targetDist, pZ+(j-(horzCapeNodes-1)/2f)*targetDist*2
+ node.texU = uMin + (uMax - uMin) * j / (float) (HORZ_NODES - 1);
+ node.texV = vMin + (vMax - vMin) * i / (float) (VERT_NODES - 1);
+
+ node.horzDistMult = 2f + 1f * i / (float) (VERT_NODES - 1);
+
+ if (j == 0 || j == HORZ_NODES - 1) {
+ node.horzSideTexU = 406 / 1024f * i / (float) (VERT_NODES - 1);
+ if (j == 0) {
+ node.horzSideTexVTop = 1 - 20 / 1024f;
+ } else {
+ node.horzSideTexVTop = 1 - 40 / 1024f;
+ }
+ }
+ if (i == 0) {
+ node.vertSideTexU = 198 / 1024f * j / (float) (HORZ_NODES - 1);
+ node.vertSideTexVTop = 1 - 60 / 1024f;
+ } else if (i == VERT_NODES - 1) {
+ node.vertSideTexU = 300 / 1024f * j / (float) (HORZ_NODES - 1);
+ node.vertSideTexVTop = 1 - 80 / 1024f;
+ }
+ nodes[j + i * HORZ_NODES] = node;
+ }
+ }
+ for (int y = 0; y < VERT_NODES; y++) {
+ for (int x = 0; x < HORZ_NODES; x++) {
+ CapeNode node = nodes[x + y * HORZ_NODES];
+
+ for (Direction dir : Direction.values()) {
+ for (int i = 1; i <= 2; i++) {
+ Offset offset = new Offset(dir, i);
+
+ int xNeighbor = x + offset.getXOffset();
+ int yNeighbor = y + offset.getYOffset();
+
+ if (xNeighbor >= 0 && xNeighbor < HORZ_NODES
+ && yNeighbor >= 0 && yNeighbor < VERT_NODES) {
+ CapeNode neighbor = nodes[xNeighbor + yNeighbor * HORZ_NODES];
+ node.setNeighbor(offset, neighbor);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public void ensureCapeNodesCreated(EntityPlayer player) {
+ if (nodes == null) createCapeNodes(player);
+ }
+
+ public enum Direction {
+ LEFT(-1, 0),
+ UP(0, 1),
+ RIGHT(1, 0),
+ DOWN(0, -1),
+ UPLEFT(-1, 1),
+ UPRIGHT(1, 1),
+ DOWNLEFT(-1, -1),
+ DOWNRIGHT(1, -1);
+
+ int xOff;
+ int yOff;
+
+ Direction(int xOff, int yOff) {
+ this.xOff = xOff;
+ this.yOff = yOff;
+ }
+
+ public Direction rotateRight90() {
+ int wantXOff = -yOff;
+ int wantYOff = xOff;
+ for (Direction dir : values()) {
+ if (dir.xOff == wantXOff && dir.yOff == wantYOff) {
+ return dir;
+ }
+ }
+ return this;
+ }
+
+ public Direction rotateLeft90() {
+ int wantXOff = yOff;
+ int wantYOff = -xOff;
+ for (Direction dir : values()) {
+ if (dir.xOff == wantXOff && dir.yOff == wantYOff) {
+ return dir;
+ }
+ }
+ return this;
+ }
+ }
+
+ public static class Offset {
+ Direction direction;
+ int steps;
+
+ public Offset(Direction direction, int steps) {
+ this.direction = direction;
+ this.steps = steps;
+ }
+
+ public int getXOffset() {
+ return direction.xOff * steps;
+ }
+
+ public int getYOffset() {
+ return direction.yOff * steps;
+ }
+
+ public boolean equals(Object obj) {
+ if (obj instanceof Offset) {
+ Offset other = (Offset) obj;
+ return other.direction == direction && other.steps == steps;
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return 13 * direction.ordinal() + 7 * steps;
+ }
+ }
+
+ private void loadShaderUniforms(ShaderManager shaderManager) {
+ String shaderId = "capes/" + shaderName + "/" + shaderName;
+ if (shaderName.equalsIgnoreCase("fade_cape") || shaderName.equalsIgnoreCase("planets")) {
+ shaderManager.loadData(shaderId, "millis", (int) (System.currentTimeMillis() - startTime));
+ } else if (shaderName.equalsIgnoreCase("space_cape")) {
+ shaderManager.loadData(shaderId, "millis", (int) (System.currentTimeMillis() - startTime));
+ shaderManager.loadData(shaderId, "eventMillis", (int) (System.currentTimeMillis() - eventMillis));
+ shaderManager.loadData(shaderId, "eventRand", eventRandom);
+ } else if (shaderName.equalsIgnoreCase("mcworld_cape")) {
+ shaderManager.loadData(shaderId, "millis", (int) (System.currentTimeMillis() - startTime));
+ } else if (shaderName.equalsIgnoreCase("lava_cape")) {
+ shaderManager.loadData(shaderId, "millis", (int) (System.currentTimeMillis() - startTime));
+ } else if (shaderName.equalsIgnoreCase("tunnel")) {
+ shaderManager.loadData(shaderId, "millis", (int) (System.currentTimeMillis() - startTime));
+ } else if (shaderName.equalsIgnoreCase("biscuit_cape") || shaderName.equalsIgnoreCase("shiny_cape")) {
+ shaderManager.loadData(shaderId, "millis", (int) (System.currentTimeMillis() - startTime));
+ shaderManager.loadData(shaderId, "eventMillis", (int) (System.currentTimeMillis() - eventMillis));
+ } else if (shaderName.equalsIgnoreCase("negative")) {
+ shaderManager.loadData(shaderId, "screensize", new Vector2f(
+ Minecraft.getMinecraft().displayWidth,
+ Minecraft.getMinecraft().displayHeight
+ ));
+ } else if (shaderName.equalsIgnoreCase("void")) {
+ shaderManager.loadData(shaderId, "millis", (int) (System.currentTimeMillis() - startTime));
+ shaderManager.loadData(shaderId, "screensize", new Vector2f(
+ Minecraft.getMinecraft().displayWidth,
+ Minecraft.getMinecraft().displayHeight
+ ));
+ }
+ }
+
+ long lastRender = 0;
+
+ public void onRenderPlayer(RenderPlayerEvent.Post e) {
+ EntityPlayer player = e.entityPlayer;
+
+ if (currentPlayer != null && keepCurrentPlayer && currentPlayer != player) return;
+
+ if (player.getActivePotionEffect(Potion.invisibility) != null) return;
+ if (player.isSpectator() || player.isInvisible()) return;
+
+ ensureCapeNodesCreated(player);
+
+ Entity viewer = Minecraft.getMinecraft().getRenderViewEntity();
+ double viewerX = (viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * e.partialRenderTick) % 7789;
+ double viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * e.partialRenderTick;
+ double viewerZ = (viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * e.partialRenderTick) % 7789;
+
+ GlStateManager.pushMatrix();
+ GlStateManager.enableBlend();
+ GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA,
+ GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO
+ );
+ bindTexture();
+ GlStateManager.enableTexture2D();
+ GlStateManager.enableDepth();
+ GlStateManager.disableCull();
+ GlStateManager.disableLighting();
+ GlStateManager.color(1, 1, 1, 1);
+
+ if (shaderName.equals("mcworld_cape")) {
+ 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 {
+ GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
+ GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
+ }
+
+ GL11.glTranslatef(-(float) viewerX, -(float) viewerY, -(float) viewerZ);
+
+ ShaderManager shaderManager = ShaderManager.getInstance();
+ shaderManager.loadShader("capes/" + shaderName + "/" + shaderName);
+ loadShaderUniforms(shaderManager);
+
+ renderCape(player, e.partialRenderTick);
+
+ GL11.glTranslatef((float) viewerX, (float) viewerY, (float) viewerZ);
+
+ GL20.glUseProgram(0);
+
+ GlStateManager.enableCull();
+ GlStateManager.enableTexture2D();
+ GlStateManager.disableBlend();
+ GlStateManager.enableDepth();
+ GlStateManager.enableLighting();
+ GlStateManager.popMatrix();
+
+ lastRender = System.currentTimeMillis();
+ }
+
+ public void onTick(TickEvent.ClientTickEvent event, EntityPlayer player) {
+ if (player == null) return;
+ if (Minecraft.getMinecraft().isGamePaused()) return;
+
+ if (System.currentTimeMillis() - lastRender < 500) {
+ if (currentPlayer == null || !keepCurrentPlayer) {
+ keepCurrentPlayer = true;
+ currentPlayer = player;
+ } else if (currentPlayer != player) {
+ return;
+ }
+
+ ensureCapeNodesCreated(player);
+
+ for (int y = 0; y < VERT_NODES; y++) {
+ for (int x = 0; x < HORZ_NODES; x++) {
+ CapeNode node = nodes[x + y * HORZ_NODES];
+ node.lastPosition.x = node.position.x;
+ node.lastPosition.y = node.position.y;
+ node.lastPosition.z = node.position.z;
+ }
+ }
+ updateCape(player);
+ } else {
+ keepCurrentPlayer = false;
+ }
+ }
+
+ private static double interpolateRotation(float a, float b, float amount) {
+ double f;
+
+ for (f = b - a; f < -180.0F; f += 360.0F) {
+ }
+
+ while (f >= 180.0F) {
+ f -= 360.0F;
+ }
+
+ return a + amount * f;
+ }
+
+ private double getPlayerRenderAngle(EntityPlayer player, float partialRenderTick) {
+ double angle = interpolateRotation(player.prevRenderYawOffset, player.renderYawOffset, partialRenderTick);
+
+ if (player.isRiding() && player.ridingEntity instanceof EntityLivingBase && player.ridingEntity.shouldRiderSit()) {
+
+ EntityLivingBase entitylivingbase = (EntityLivingBase) player.ridingEntity;
+ double head = interpolateRotation(player.prevRotationYawHead, player.rotationYawHead, partialRenderTick);
+ angle = interpolateRotation(
+ entitylivingbase.prevRenderYawOffset,
+ entitylivingbase.renderYawOffset,
+ partialRenderTick
+ );
+ double wrapped = MathHelper.wrapAngleTo180_double(head - angle);
+
+ if (wrapped < -85.0F) {
+ wrapped = -85.0F;
+ }
+
+ if (wrapped >= 85.0F) {
+ wrapped = 85.0F;
+ }
+
+ angle = head - wrapped;
+
+ if (wrapped * wrapped > 2500.0F) {
+ angle += wrapped * 0.2F;
+ }
+ }
+
+ return Math.toRadians(angle);
+ }
+
+ private Vector3f updateFixedCapeNodes(EntityPlayer player) {
+ double pX = player.posX % 7789;//player.lastTickPosX + (player.posX - player.lastTickPosX) * partialRenderTick;
+ double pY = player.posY;//player.lastTickPosY + (player.posY - player.lastTickPosY) * partialRenderTick;
+ double pZ = player.posZ % 7789;//player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialRenderTick;
+ double angle = getPlayerRenderAngle(player, 0);
+
+ double vertOffset2 =
+ vertOffset + (player.isSneaking() ? -0.22f : 0) + (player.getCurrentArmor(2) != null ? 0.06f : 0);
+ double shoulderWidth2 = shoulderWidth + (player.getCurrentArmor(2) != null ? 0.08f : 0);
+
+ float xOff = (float) (Math.cos(angle) * shoulderLength);
+ float zOff = (float) (Math.sin(angle) * shoulderLength);
+
+ float totalDX = 0;
+ float totalDY = 0;
+ float totalDZ = 0;
+ int totalMovements = 0;
+
+ for (int i = 0; i < HORZ_NODES; i++) {
+ float mult = 1 - 2f * i / (HORZ_NODES - 1); //1 -> -1
+ float widthMult = 1.25f - (1.414f * i / (HORZ_NODES - 1) - 0.707f) * (1.414f * i / (HORZ_NODES - 1) - 0.707f);
+ CapeNode node = nodes[i];
+ float x = (float) pX + (float) (xOff * mult - widthMult * Math.cos(angle + Math.PI / 2) * shoulderWidth2);
+ float y = (float) pY + (float) (vertOffset2);
+ float z = (float) pZ + (float) (zOff * mult - widthMult * Math.sin(angle + Math.PI / 2) * shoulderWidth2);
+ totalDX += x - node.position.x;
+ totalDY += y - node.position.y;
+ totalDZ += z - node.position.z;
+ totalMovements++;
+ node.position.x = x;
+ node.position.y = y;
+ node.position.z = z;
+ node.fixed = true;
+ }
+
+ float avgDX = totalDX / totalMovements;
+ float avgDY = totalDY / totalMovements;
+ float avgDZ = totalDZ / totalMovements;
+
+ return new Vector3f(avgDX, avgDY, avgDZ);
+ }
+
+ private void updateFixedCapeNodesPartial(EntityPlayer player, float partialRenderTick) {
+ double pX = (player.lastTickPosX + (player.posX - player.lastTickPosX) * partialRenderTick) % 7789;
+ double pY = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialRenderTick;
+ double pZ = (player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialRenderTick) % 7789;
+ double angle = getPlayerRenderAngle(player, partialRenderTick);
+
+ double vertOffset2 =
+ vertOffset + (player.isSneaking() ? -0.22f : 0) + (player.getCurrentArmor(2) != null ? 0.06f : 0);
+ double shoulderWidth2 = shoulderWidth + (player.getCurrentArmor(2) != null ? 0.08f : 0);
+
+ float xOff = (float) (Math.cos(angle) * shoulderLength);
+ float zOff = (float) (Math.sin(angle) * shoulderLength);
+
+ for (int i = 0; i < HORZ_NODES; i++) {
+ float mult = 1 - 2f * i / (HORZ_NODES - 1); //1 -> -1
+ float widthMult = 1.25f - (1.414f * i / (HORZ_NODES - 1) - 0.707f) * (1.414f * i / (HORZ_NODES - 1) - 0.707f);
+ CapeNode node = nodes[i];
+ node.renderPosition.x = (float) pX + (float) (xOff * mult - widthMult * Math.cos(angle + Math.PI / 2) *
+ shoulderWidth2);
+ node.renderPosition.y = (float) pY + (float) (vertOffset2);
+ node.renderPosition.z = (float) pZ + (float) (zOff * mult - widthMult * Math.sin(angle + Math.PI / 2) *
+ shoulderWidth2);
+ node.fixed = true;
+ }
+ }
+
+ private double deltaAngleAccum;
+ private double oldPlayerAngle;
+ private int crouchTicks = 0;
+ long startTime = 0;
+
+ private void updateCape(EntityPlayer player) {
+ Vector3f capeTranslation = updateFixedCapeNodes(player);
+
+ if (shaderName.equals("space_cape")) {
+ long currentTime = System.currentTimeMillis();
+ if (currentTime - startTime > eventMillis - startTime + eventLength) {
+ eventMillis = currentTime;
+ eventLength = random.nextFloat() * 2000 + 4000;
+ eventRandom = random.nextFloat();
+ }
+ } else if (shaderName.equals("biscuit_cape") || shaderName.equals("shiny_cape")) {
+ long currentTime = System.currentTimeMillis();
+ if (currentTime - startTime > eventMillis - startTime + eventLength) {
+ eventMillis = currentTime;
+ eventLength = random.nextFloat() * 3000 + 3000;
+ }
+ }
+
+ double playerAngle = getPlayerRenderAngle(player, 0);
+ double deltaAngle = playerAngle - oldPlayerAngle;
+ if (deltaAngle > Math.PI) {
+ deltaAngle = 2 * Math.PI - deltaAngle;
+ }
+ if (deltaAngle < -Math.PI) {
+ deltaAngle = 2 * Math.PI + deltaAngle;
+ }
+ deltaAngleAccum *= 0.5f;
+ deltaAngleAccum += deltaAngle;
+
+ float dX = (float) Math.cos(playerAngle + Math.PI / 2f);
+ float dZ = (float) Math.sin(playerAngle + Math.PI / 2f);
+
+ float factor = (float) (deltaAngleAccum * deltaAngleAccum);
+
+ float capeTransLength = capeTranslation.length();
+
+ float capeTranslationFactor = 0f;
+ if (capeTransLength > 0.5f) {
+ capeTranslationFactor = (capeTransLength - 0.5f) / capeTransLength;
+ }
+ Vector3f lookDir = new Vector3f(dX, 0, dZ);
+ Vector3f lookDirNorm = lookDir.normalise(null);
+ float dot = Vector3f.dot(capeTranslation, lookDirNorm);
+ if (dot < 0) { //Moving backwards
+ for (int y = 0; y < VERT_NODES; y++) {
+ for (int x = 0; x < HORZ_NODES; x++) {
+ CapeNode node = nodes[x + y * HORZ_NODES];
+ if (!node.fixed) {
+ node.position.x += lookDirNorm.x * dot;
+ node.position.y += lookDirNorm.y * dot;
+ node.position.z += lookDirNorm.z * dot;
+ }
+ }
+ }
+ //Apply small backwards force
+ factor = 0.05f;
+ }
+
+ if (factor > 0) {
+ for (int y = 0; y < VERT_NODES; y++) {
+ for (int x = 0; x < HORZ_NODES; x++) {
+ nodes[x + y * HORZ_NODES].applyForce(-dX * factor, 0, -dZ * factor);
+ }
+ }
+ }
+
+ if (capeTranslationFactor > 0f) {
+ float capeDX = capeTranslation.x * capeTranslationFactor;
+ float capeDY = capeTranslation.y * capeTranslationFactor;
+ float capeDZ = capeTranslation.z * capeTranslationFactor;
+
+ for (int y = 0; y < VERT_NODES; y++) {
+ for (int x = 0; x < HORZ_NODES; x++) {
+ CapeNode node = nodes[x + y * HORZ_NODES];
+ if (!node.fixed) {
+ node.position.x += capeDX;
+ node.position.y += capeDY;
+ node.position.z += capeDZ;
+ }
+ }
+ }
+ }
+
+ //Wind
+ float currTime = (System.currentTimeMillis() - startTime) / 1000f;
+ float windRandom = Math.abs((float) (0.5f * Math.sin(0.22f * currTime) + Math.sin(0.44f * currTime) * Math.sin(
+ 0.47f * currTime)));
+ double windDir = playerAngle + Math.PI / 4f * Math.sin(0.2f * currTime);
+
+ float windDX = (float) Math.cos(windDir + Math.PI / 2f);
+ float windDZ = (float) Math.sin(windDir + Math.PI / 2f);
+ for (int y = 0; y < VERT_NODES; y++) {
+ for (int x = 0; x < HORZ_NODES; x++) {
+ nodes[x + y * HORZ_NODES].applyForce(-windDX * windRandom * 0.01f, 0, -windDZ * windRandom * 0.01f);
+ }
+ }
+
+ if (player.isSneaking()) {
+ crouchTicks++;
+ float mult = 0.5f;
+ if (crouchTicks < 5) {
+ mult = 2f;
+ }
+ for (int y = 0; y < 8; y++) {
+ for (int x = 0; x < HORZ_NODES; x++) {
+ nodes[x + y * HORZ_NODES].applyForce(-dX * mult, 0, -dZ * mult);
+ }
+ }
+ } else {
+ crouchTicks = 0;
+ }
+
+ Vector3f avgPosition = avgFixedPosition();
+ for (int y = 0; y < VERT_NODES; y++) {
+ for (int x = 0; x < HORZ_NODES; x++) {
+ CapeNode node = nodes[x + y * HORZ_NODES];
+
+ Vector3f delta = Vector3f.sub(node.position, avgPosition, null);
+
+ if (delta.lengthSquared() > 5 * 5) {
+ Vector3f norm = delta.normalise(null);
+ node.position = Vector3f.add(avgPosition, norm, null);
+ }
+ }
+ }
+
+ oldPlayerAngle = playerAngle;
+
+ for (int y = 0; y < VERT_NODES; y++) {
+ for (int x = 0; x < HORZ_NODES; x++) {
+ nodes[x + y * HORZ_NODES].update();
+ }
+ }
+ int updates = 50;
+ for (int i = 0; i < updates; i++) {
+ for (int y = 0; y < VERT_NODES; y++) {
+ for (int x = 0; x < HORZ_NODES; x++) {
+ nodes[x + y * HORZ_NODES].resolveAll(2 + 1f * y / VERT_NODES, false);
+ }
+ }
+ }
+ }
+
+ private int ssbo = -1;
+
+ private void generateSSBO() {
+ ssbo = GL15.glGenBuffers();
+ loadSBBO();
+ }
+
+ private void loadSBBO() {
+ FloatBuffer buff = BufferUtils.createFloatBuffer(CapeNode.FLOAT_NUM * HORZ_NODES * VERT_NODES);
+ for (int y = 0; y < VERT_NODES; y++) {
+ for (int x = 0; x < HORZ_NODES; x++) {
+ nodes[x + y * HORZ_NODES].loadIntoBuffer(buff);
+ }
+ }
+ buff.flip();
+
+ GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, ssbo);
+ GL15.glBufferData(GL43.GL_SHADER_STORAGE_BUFFER, buff, GL15.GL_DYNAMIC_DRAW);
+ GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, 0);
+ }
+
+ private void resolveAllCompute() {
+ if (ssbo == -1) {
+ generateSSBO();
+ }
+ loadSBBO();
+
+ int program = ShaderManager.getInstance().getShader("node");
+
+ int block_index = GL43.glGetProgramResourceIndex(program, GL43.GL_SHADER_STORAGE_BLOCK, "nodes_buffer");
+ int ssbo_binding_point_index = 0;
+ GL43.glShaderStorageBlockBinding(program, block_index, ssbo_binding_point_index);
+ int binding_point_index = 0;
+ GL30.glBindBufferBase(GL43.GL_SHADER_STORAGE_BUFFER, binding_point_index, ssbo);
+
+ GL20.glUseProgram(program);
+
+ for (int i = 0; i < 30; i++) {
+ GL43.glDispatchCompute(VERT_NODES, 1, 1);
+ GL42.glMemoryBarrier(GL43.GL_SHADER_STORAGE_BARRIER_BIT);
+ }
+
+ GL20.glUseProgram(0);
+
+ FloatBuffer buff = BufferUtils.createFloatBuffer(CapeNode.FLOAT_NUM * HORZ_NODES * VERT_NODES);
+
+ GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, ssbo);
+ GL15.glGetBufferSubData(GL43.GL_SHADER_STORAGE_BUFFER, 0, buff);
+ GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, 0);
+
+ for (int y = 0; y < VERT_NODES; y++) {
+ for (int x = 0; x < HORZ_NODES; x++) {
+ nodes[x + y * HORZ_NODES].readFromBuffer(buff);
+ }
+ }
+ }
+
+ private Vector3f avgRenderPosition() {
+ Vector3f accum = new Vector3f();
+ int num = 0;
+ for (int y = 0; y < VERT_NODES; y++) {
+ for (int x = 0; x < HORZ_NODES; x++) {
+ CapeNode node = nodes[x + y * HORZ_NODES];
+ Vector3f.add(accum, node.renderPosition, accum);
+ num++;
+ }
+ }
+ if (num != 0) {
+ accum.scale(1f / num);
+ }
+ return accum;
+ }
+
+ private Vector3f avgNormal() {
+ Vector3f accum = new Vector3f();
+ int num = 0;
+ for (int y = 0; y < VERT_NODES; y++) {
+ for (int x = 0; x < HORZ_NODES; x++) {
+ CapeNode node = nodes[x + y * HORZ_NODES];
+ Vector3f.add(accum, node.normal(), accum);
+ num++;
+ }
+ }
+ if (num != 0) {
+ accum.scale(1f / num);
+ }
+ return accum;
+ }
+
+ private Vector3f avgFixedRenderPosition() {
+ Vector3f accum = new Vector3f();
+ int numFixed = 0;
+ for (int y = 0; y < VERT_NODES; y++) {
+ for (int x = 0; x < HORZ_NODES; x++) {
+ CapeNode node = nodes[x + y * HORZ_NODES];
+ if (node.fixed) {
+ Vector3f.add(accum, node.renderPosition, accum);
+ numFixed++;
+ }
+ }
+ }
+ if (numFixed != 0) {
+ accum.scale(1f / numFixed);
+ }
+ return accum;
+ }
+
+ private Vector3f avgFixedPosition() {
+ Vector3f accum = new Vector3f();
+ int numFixed = 0;
+ for (int y = 0; y < VERT_NODES; y++) {
+ for (int x = 0; x < HORZ_NODES; x++) {
+ CapeNode node = nodes[x + y * HORZ_NODES];
+ if (node.fixed) {
+ Vector3f.add(accum, node.position, accum);
+ numFixed++;
+ }
+ }
+ }
+ if (numFixed != 0) {
+ accum.scale(1f / numFixed);
+ }
+ return accum;
+ }
+
+ private void renderBackAndDoFrontStencil() {
+ for (int y = 0; y < VERT_NODES; y++) {
+ for (int x = 0; x < HORZ_NODES; x++) {
+ nodes[x + y * HORZ_NODES].renderNode(CapeNode.DRAW_MASK_BACK | CapeNode.DRAW_MASK_SIDES);
+ }
+ }
+
+ if (!Minecraft.getMinecraft().getFramebuffer().isStencilEnabled())
+ Minecraft.getMinecraft().getFramebuffer().enableStencil();
+
+ GL11.glEnable(GL11.GL_STENCIL_TEST);
+ GL11.glStencilFunc(GL11.GL_ALWAYS, 1, 0xFF);
+ GL11.glStencilOp(GL11.GL_ZERO, GL11.GL_ZERO, GL11.GL_REPLACE);
+ GL11.glStencilMask(0xFF);
+ GL11.glClear(GL11.GL_STENCIL_BUFFER_BIT);
+ GlStateManager.enableDepth();
+
+ GL11.glColorMask(false, false, false, false);
+ for (int y = 0; y < VERT_NODES; y++) {
+ for (int x = 0; x < HORZ_NODES; x++) {
+ nodes[x + y * HORZ_NODES].renderNode(CapeNode.DRAW_MASK_FRONT);
+ }
+ }
+ GL11.glColorMask(true, true, true, true);
+
+ // Only pass stencil test if equal to 1
+ GL11.glStencilMask(0x00);
+ GL11.glStencilFunc(GL11.GL_EQUAL, 1, 0xFF);
+ }
+
+ private Vector3f getPoint(Vector3f point, Vector3f... vectors) {
+ Vector3f res = new Vector3f(point);
+ for (Vector3f vec : vectors) Vector3f.add(res, vec, res);
+ return res;
+ }
+
+ private static void renderVBO(WorldRenderer worldRenderer) {
+ if (worldRenderer != null && worldRenderer.getVertexCount() > 0) {
+ VertexFormat vertexformat = worldRenderer.getVertexFormat();
+ int stride = vertexformat.getNextOffset();
+ ByteBuffer bytebuffer = worldRenderer.getByteBuffer();
+ List<VertexFormatElement> list = vertexformat.getElements();
+
+ for (int index = 0; index < list.size(); index++) {
+ VertexFormatElement vertexformatelement = list.get(index);
+ vertexformatelement.getUsage().preDraw(vertexformat, index, stride, bytebuffer);
+ }
+
+ GL11.glDrawArrays(worldRenderer.getDrawMode(), 0, worldRenderer.getVertexCount());
+
+ for (int index = 0; index < list.size(); index++) {
+ VertexFormatElement vertexformatelement = list.get(index);
+ vertexformatelement.getUsage().postDraw(vertexformat, index, stride, bytebuffer);
+ }
+ }
+ }
+
+ private static WorldRenderer sphereVBO = null;
+
+ private void renderNodes() {
+ if (capeName.equalsIgnoreCase("planets")) {
+ renderBackAndDoFrontStencil();
+
+ Vector3f pointNorm = avgNormal();
+ Vector3f capeAvgPos = avgRenderPosition();
+
+ pointNorm.scale(0.5f / pointNorm.length());
+ pointNorm.scale(1 - pointNorm.y / 1.3f);
+ Vector3f point = Vector3f.sub(capeAvgPos, pointNorm, null);
+
+ if (sphereVBO == null || Keyboard.isKeyDown(Keyboard.KEY_K)) {
+ if (sphereVBO != null) sphereVBO.reset();
+
+ int arcSegments = 24;
+ int rotationSegments = 24;
+ double arcAngleDelta = Math.PI / (arcSegments - 1);
+
+ float xScale = 0.95f;
+
+ double diameterUnitArcLen = 0;
+
+ double arcAngle = 0;
+ for (int i = 0; i < arcSegments; i++) {
+ diameterUnitArcLen += Math.sin(arcAngle);
+ arcAngle += arcAngleDelta;
+ }
+ double arcLength = 2f / diameterUnitArcLen;
+
+ List<List<Vector3f>> arcs = new ArrayList<>();
+ for (int angleI = 0; angleI < rotationSegments; angleI++) {
+ double angle = Math.PI * 2 * angleI / rotationSegments;
+
+ List<Vector3f> arc = new ArrayList<>();
+
+ Vector3f arcPos = new Vector3f(0, 0, -1);
+
+ arc.add(arcPos);
+
+ arcAngle = 0;
+ for (int segmentI = 0; segmentI < arcSegments; segmentI++) {
+
+ double deltaZ = Math.sin(arcAngle) * arcLength;
+ double deltaY = Math.cos(arcAngle) * Math.cos(angle) * arcLength;
+ double deltaX = Math.cos(arcAngle) * Math.sin(angle) * arcLength * xScale;
+
+ arcPos = new Vector3f(arcPos);
+ arcPos.z += deltaZ;
+ arcPos.y += deltaY;
+ arcPos.x += deltaX;
+ arcPos.normalise();
+ arc.add(arcPos);
+
+ arcAngle += arcAngleDelta;
+ }
+
+ arcs.add(arc);
+ }
+
+ sphereVBO = new WorldRenderer(8 * 4 * rotationSegments * arcSegments);
+ sphereVBO.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_NORMAL);
+
+ double maxXYRad = 0;
+ for (int angleI = 0; angleI < rotationSegments; angleI++) {
+ for (int segmentI = 0; segmentI <= arcSegments; segmentI++) {
+ List<Vector3f> thisArc = arcs.get(angleI);
+ Vector3f point1 = thisArc.get(segmentI);
+ double rad = Math.sqrt(point1.x * point1.x + point1.y * point1.y);
+ maxXYRad = Math.max(maxXYRad, rad);
+ }
+ }
+
+ for (int angleI = 0; angleI < rotationSegments; angleI++) {
+
+ int nextAngleI = angleI + 1;
+ if (angleI == rotationSegments - 1) {
+ nextAngleI = 0;
+ }
+
+ float v = 0.5f * (angleI) / (rotationSegments);
+ float v2 = 0.5f * (angleI + 1) / (rotationSegments);
+ //if(v2 == 0) v2 = 0.5f;
+
+ List<Vector3f> thisArc = arcs.get(angleI);
+ List<Vector3f> nextArc = arcs.get(nextAngleI);
+
+ for (int segmentI = 1; segmentI <= arcSegments; segmentI++) {
+ Vector3f point1 = thisArc.get(segmentI);
+ Vector3f point2 = thisArc.get(segmentI - 1);
+ Vector3f point3 = nextArc.get(segmentI - 1);
+ Vector3f point4 = nextArc.get(segmentI);
+
+ double u1 = 0.5f * segmentI / arcSegments;
+ double u2 = 0.5f * (segmentI - 1) / arcSegments;
+
+ sphereVBO.pos(point4.x, point4.y, point4.z)
+ .tex(u1, v2).normal(-point4.x, -point4.y, -point4.z).endVertex();
+ sphereVBO.pos(point3.x, point3.y, point3.z)
+ .tex(u2, v2).normal(-point3.x, -point3.y, -point3.z).endVertex();
+ sphereVBO.pos(point2.x, point2.y, point2.z)
+ .tex(u2, v).normal(-point2.x, -point2.y, -point2.z).endVertex();
+ sphereVBO.pos(point1.x, point1.y, point1.z)
+ .tex(u1, v).normal(-point1.x, -point1.y, -point1.z).endVertex();
+ }
+ }
+ }
+
+ String shaderId = "capes/" + shaderName + "/" + shaderName;
+ double mercuryAngle = Math.PI * 2 * ((System.currentTimeMillis() - startTime) / 10000f % 1);
+ double mercuryX = Math.sin(mercuryAngle) * 0.3;
+ double mercuryZ = Math.cos(mercuryAngle) * 0.3;
+
+ double earthAngle = Math.PI * 2 * ((System.currentTimeMillis() - startTime) / 30000f % 1);
+ double earthSlant = Math.PI * 0.1;
+ double earthX = Math.sin(earthAngle) * Math.cos(earthSlant) * 0.6;
+ double earthY = Math.sin(earthAngle) * Math.sin(earthSlant) * 0.6;
+ double earthZ = Math.cos(earthAngle) * Math.cos(earthSlant) * 0.6;
+
+ float sunDist = Vector3f.sub(point, capeAvgPos, null).lengthSquared();
+ float mercuryDist = Vector3f.sub(new Vector3f(point.x + (float) mercuryX, point.y, point.z + (float) mercuryZ),
+ capeAvgPos, null
+ ).lengthSquared();
+ float earthDist = Vector3f.sub(new Vector3f(
+ point.x + (float) earthX,
+ point.y + (float) earthY,
+ point.z + (float) earthZ
+ ),
+ capeAvgPos, null
+ ).lengthSquared();
+
+ double jupiterAngle = Math.PI * 2 * ((System.currentTimeMillis() - startTime) / 200000f % 1);
+ double jupiterSlant = Math.PI * -0.08;
+ double jupiterX = Math.sin(jupiterAngle) * Math.cos(jupiterSlant) * 1.5;
+ double jupiterY = Math.sin(jupiterAngle) * Math.sin(jupiterSlant) * 1.5;
+ double jupiterZ = Math.cos(jupiterAngle) * Math.cos(jupiterSlant) * 1.5;
+ float jupiterDist = Vector3f.sub(new Vector3f(
+ point.x + (float) jupiterX,
+ point.y + (float) jupiterY,
+ point.z + (float) jupiterZ
+ ),
+ capeAvgPos, null
+ ).lengthSquared();
+
+ double neptuneX = -Math.sin(earthAngle) * Math.cos(earthSlant);
+ double neptuneY = -Math.sin(earthAngle) * Math.sin(earthSlant);
+ double neptuneZ = -Math.cos(earthAngle) * Math.cos(earthSlant);
+
+ float neptuneDist = Vector3f.sub(new Vector3f(
+ point.x + (float) neptuneX,
+ point.y + (float) neptuneY,
+ point.z + (float) neptuneZ
+ ),
+ capeAvgPos, null
+ ).lengthSquared();
+
+ TreeMap<Float, Integer> orbitals = new TreeMap<>();
+ orbitals.put(sunDist, 0);
+ orbitals.put(earthDist, 1);
+ orbitals.put(mercuryDist, 2);
+
+ double delta = Minecraft.getMinecraft().getRenderViewEntity().getRotationYawHead() % 360;
+ while (delta < 0) delta += 360;
+
+ double jupDelta = (delta + Math.toDegrees(jupiterAngle)) % 360;
+ while (jupDelta < 0) jupDelta += 360;
+ if (jupDelta > 250 || jupDelta < 110) orbitals.put(jupiterDist, 3);
+
+ double nepDelta = (delta + Math.toDegrees(-earthAngle)) % 360;
+ while (nepDelta < 0) nepDelta += 360;
+ if (nepDelta > 250 || nepDelta < 110) orbitals.put(neptuneDist, 4);
+
+ GlStateManager.disableDepth();
+ GlStateManager.enableCull();
+
+ for (int planetId : orbitals.descendingMap().values()) {
+ GlStateManager.pushMatrix();
+ switch (planetId) {
+ case 0: {
+ GlStateManager.translate(point.x, point.y, point.z);
+ GlStateManager.scale(0.2f, 0.2f, 0.2f);
+ break;
+ }
+ case 1: {
+ Vector3f sunVec = new Vector3f((float) earthX, (float) earthY, (float) earthZ);
+ ShaderManager.getInstance().loadData(shaderId, "sunVec", sunVec);
+ GlStateManager.translate(point.x + earthX, point.y + earthY, point.z + earthZ);
+ GlStateManager.scale(0.1f, 0.1f, 0.1f);
+ break;
+ }
+ case 2: {
+ Vector3f sunVec = new Vector3f((float) mercuryX, 0, (float) mercuryZ);
+ ShaderManager.getInstance().loadData(shaderId, "sunVec", sunVec);
+ GlStateManager.translate(point.x + mercuryX, point.y, point.z + mercuryZ);
+ GlStateManager.scale(0.05f, 0.05f, 0.05f);
+ break;
+ }
+ case 3: {
+ Vector3f sunVec = new Vector3f((float) jupiterX, (float) jupiterY, (float) jupiterZ);
+ ShaderManager.getInstance().loadData(shaderId, "sunVec", sunVec);
+ GlStateManager.translate(point.x + jupiterX, point.y + jupiterY, point.z + jupiterZ);
+ GlStateManager.scale(0.3f, 0.3f, 0.3f);
+ break;
+ }
+ case 4: {
+ Vector3f sunVec = new Vector3f((float) neptuneX, (float) neptuneY, (float) neptuneZ);
+ ShaderManager.getInstance().loadData(shaderId, "sunVec", sunVec);
+ GlStateManager.translate(point.x + neptuneX, point.y + neptuneY, point.z + neptuneZ);
+ GlStateManager.scale(0.15f, 0.15f, 0.15f);
+ break;
+ }
+ }
+ ShaderManager.getInstance().loadData(shaderId, "planetType", planetId);
+ renderVBO(sphereVBO);
+ GlStateManager.popMatrix();
+ }
+
+ GlStateManager.disableCull();
+ GlStateManager.enableDepth();
+
+ GL11.glDisable(GL11.GL_STENCIL_TEST);
+ } else if (capeName.equalsIgnoreCase("parallax")) {
+ renderBackAndDoFrontStencil();
+
+ Vector3f pointNorm = avgNormal();
+ pointNorm.scale(-0.2f / pointNorm.length());
+ Vector3f negPointNorm = new Vector3f(pointNorm);
+ negPointNorm.scale(-1);
+ //pointNorm.scale(1 - pointNorm.y/1.3f);
+ Vector3f point = Vector3f.add(avgRenderPosition(), pointNorm, null);
+ Vector3f fixedPoint = Vector3f.add(avgFixedRenderPosition(), pointNorm, null);
+
+ Vector3f up = Vector3f.sub(fixedPoint, point, null);
+ float halfUp = up.length();
+
+ Vector3f down = new Vector3f(up);
+ down.scale(-1);
+
+ Vector3f left = Vector3f.cross(up, pointNorm, null);
+ left.scale(halfUp * 522f / 341f / left.length());
+ Vector3f right = new Vector3f(left);
+ right.scale(-1);
+
+ Vector3f point1 = getPoint(point, left);
+ Vector3f point2 = getPoint(point, left, down, down);
+ Vector3f point3 = getPoint(point, right, down, down);
+ Vector3f point4 = getPoint(point, right);
+
+ Vector3f point2Edge = getPoint(point2, negPointNorm, negPointNorm);
+ Vector3f point3Edge = getPoint(point3, negPointNorm, negPointNorm);
+
+ GlStateManager.disableDepth();
+ GlStateManager.disableCull();
+
+ GlStateManager.color(1, 1, 1, 1);
+
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+ worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
+
+ worldrenderer.pos(point1.x, point1.y, point1.z)
+ .tex(0, 943 / 1024f).endVertex();
+ worldrenderer.pos(point2.x, point2.y, point2.z)
+ .tex(280 / 1024f, 943 / 1024f).endVertex();
+ worldrenderer.pos(point3.x, point3.y, point3.z)
+ .tex(280 / 1024f, 421 / 1024f).endVertex();
+ worldrenderer.pos(point4.x, point4.y, point4.z)
+ .tex(0, 421 / 1024f).endVertex();
+
+ tessellator.draw();
+
+ worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
+
+ worldrenderer.pos(point2.x, point2.y, point2.z)
+ .tex(280 / 1024f, 943 / 1024f).endVertex();
+ worldrenderer.pos(point2Edge.x, point2Edge.y, point2Edge.z)
+ .tex(341 / 1024f, 943 / 1024f).endVertex();
+ worldrenderer.pos(point3Edge.x, point3Edge.y, point3Edge.z)
+ .tex(341 / 1024f, 421 / 1024f).endVertex();
+ worldrenderer.pos(point3.x, point3.y, point3.z)
+ .tex(280 / 1024f, 421 / 1024f).endVertex();
+
+ tessellator.draw();
+
+ GlStateManager.disableCull();
+ GlStateManager.enableDepth();
+
+ GL11.glDisable(GL11.GL_STENCIL_TEST);
+ } else if (capeName.equalsIgnoreCase("tunnel")) {
+ renderBackAndDoFrontStencil();
+
+ Vector3f pointNorm = avgNormal();
+
+ pointNorm.scale(0.7f / pointNorm.length());
+ pointNorm.scale(1 - pointNorm.y / 1.3f);
+ Vector3f point = Vector3f.sub(avgRenderPosition(), pointNorm, null);
+
+ List<CapeNode> edgeNodes = new ArrayList<>();
+ List<Vector2f> edgeCoords = new ArrayList<>();
+
+ //Left edge
+ for (int y = 0; y < VERT_NODES; y++) {
+ edgeNodes.add(nodes[y * HORZ_NODES]);
+ edgeCoords.add(new Vector2f(0, (float) y / (VERT_NODES - 1)));
+ }
+ edgeNodes.add(null);
+ edgeCoords.add(null);
+ //Bottom edge
+ int bottomIndex = VERT_NODES - 1;
+ int botSize = HORZ_NODES;
+ for (int x = 0; x < botSize; x++) {
+ edgeNodes.add(getNode(x, bottomIndex));
+ edgeCoords.add(new Vector2f((float) x / (botSize - 1), 1));
+ }
+ edgeNodes.add(null);
+ edgeCoords.add(null);
+ //Right edge
+ for (int y = VERT_NODES - 1; y >= 0; y--) {
+ edgeNodes.add(getNode(HORZ_NODES - 1, y));
+ edgeCoords.add(new Vector2f(1, (float) y / VERT_NODES));
+ }
+ edgeNodes.add(null);
+ edgeCoords.add(null);
+ //Top edge
+ int topSize = HORZ_NODES;
+ for (int x = topSize - 1; x >= 0; x--) {
+ edgeNodes.add(getNode(x, 0));
+ edgeCoords.add(new Vector2f((float) x / (topSize - 1), 0));
+ }
+
+ GlStateManager.disableDepth();
+ GlStateManager.enableCull();
+ CapeNode last = null;
+ for (int i = 0; i < edgeNodes.size(); i++) {
+ CapeNode node = edgeNodes.get(i);
+ if (last != null && node != null) {
+ Vector2f lastCoord = edgeCoords.get(i - 1);
+ Vector2f coord = edgeCoords.get(i);
+
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+ worldrenderer.begin(GL11.GL_TRIANGLES, DefaultVertexFormats.POSITION_TEX_NORMAL);
+
+ Vector3f lastNodeNorm = last.normal();
+ worldrenderer.pos(
+ last.renderPosition.x + lastNodeNorm.x * 0.05f,
+ last.renderPosition.y + lastNodeNorm.y * 0.05f,
+ last.renderPosition.z + lastNodeNorm.z * 0.05f
+ )
+ .tex(lastCoord.x * 300f / 1024f, lastCoord.y * 420f / 1024f)
+ .normal(-lastNodeNorm.x, -lastNodeNorm.y, -lastNodeNorm.z).endVertex();
+
+ Vector3f nodeNorm = node.normal();
+ worldrenderer.pos(
+ node.renderPosition.x + nodeNorm.x * 0.05f,
+ node.renderPosition.y + nodeNorm.y * 0.05f,
+ node.renderPosition.z + nodeNorm.z * 0.05f
+ )
+ .tex(coord.x * 300f / 1024f, coord.y * 420f / 1024f)
+ .normal(-nodeNorm.x, -nodeNorm.y, -nodeNorm.z).endVertex();
+
+ worldrenderer.pos(point.x, point.y, point.z)
+ .tex(150f / 1024f, 210f / 1024f)
+ .normal(-pointNorm.x, -pointNorm.y, -pointNorm.z).endVertex();
+
+ tessellator.draw();
+ }
+ last = node;
+ }
+ GlStateManager.disableCull();
+ GlStateManager.enableDepth();
+
+ GL11.glDisable(GL11.GL_STENCIL_TEST);
+ } else {
+ for (int y = 0; y < VERT_NODES; y++) {
+ for (int x = 0; x < HORZ_NODES; x++) {
+ nodes[x + y * HORZ_NODES].renderNode();
+ }
+ }
+ }
+ }
+
+ private void renderCape(EntityPlayer player, float partialRenderTick) {
+ ensureCapeNodesCreated(player);
+
+ Vector3f avgPositionFixedBefore = avgFixedRenderPosition();
+ updateFixedCapeNodesPartial(player, partialRenderTick);
+ Vector3f avgPositionFixed = avgFixedRenderPosition();
+ Vector3f delta = Vector3f.sub(avgPositionFixed, avgPositionFixedBefore, null);
+
+ if (delta.lengthSquared() > 9) {
+ updateFixedCapeNodes(player);
+
+ for (int y = 0; y < VERT_NODES; y++) {
+ for (int x = 0; x < HORZ_NODES; x++) {
+ CapeNode node = nodes[x + y * HORZ_NODES];
+ if (!node.fixed) {
+ Vector3f.add(node.renderPosition, delta, node.renderPosition);
+ node.position.set(node.renderPosition);
+ node.lastPosition.set(node.renderPosition);
+ } else {
+ node.lastPosition.set(node.position);
+ }
+ }
+ }
+
+ renderNodes();
+ return;
+ }
+
+ for (int y = 0; y < VERT_NODES; y++) {
+ for (int x = 0; x < HORZ_NODES; x++) {
+ CapeNode node = nodes[x + y * HORZ_NODES];
+
+ node.resetNormal();
+
+ if (node.fixed) continue;
+
+ Vector3f newPosition = new Vector3f();
+ newPosition.x = node.lastPosition.x + (node.position.x - node.lastPosition.x) * partialRenderTick;
+ newPosition.y = node.lastPosition.y + (node.position.y - node.lastPosition.y) * partialRenderTick;
+ newPosition.z = node.lastPosition.z + (node.position.z - node.lastPosition.z) * partialRenderTick;
+
+ int length = node.oldRenderPosition.length;
+
+ int fps = Minecraft.getDebugFPS();
+ if (fps < 50) {
+ length = 2;
+ } else if (fps < 100) {
+ length = 2 + (int) ((fps - 50) / 50f * 3);
+ }
+
+ if (node.oldRenderPosition[length - 1] == null) {
+ Arrays.fill(node.oldRenderPosition, Vector3f.sub(newPosition, avgPositionFixed, null));
+ node.renderPosition = newPosition;
+ } else {
+ Vector3f accum = new Vector3f();
+ for (int i = 0; i < length; i++) {
+ Vector3f.add(accum, node.oldRenderPosition[i], accum);
+ Vector3f.add(accum, avgPositionFixed, accum);
+ }
+ accum.scale(1 / (float) (length));
+
+ float blendFactor = 0.5f + 0.3f * y / (float) (VERT_NODES - 1); //0.5/0.5 -> 0.8/0.2 //0-1
+ accum.scale(blendFactor);
+ newPosition.scale(1 - blendFactor);
+ Vector3f.add(accum, newPosition, accum);
+ node.renderPosition = accum;
+ }
+
+ if (!Minecraft.getMinecraft().isGamePaused()) {
+ for (int i = node.oldRenderPosition.length - 1; i >= 0; i--) {
+ if (i > 0) {
+ node.oldRenderPosition[i] = node.oldRenderPosition[i - 1];
+ } else {
+ node.oldRenderPosition[i] = Vector3f.sub(node.renderPosition, avgPositionFixed, null);
+ }
+ }
+ }
+ }
+ }
+ renderNodes();
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/ShaderManager.java b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/ShaderManager.java
index a750f597..4e934e10 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/ShaderManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/ShaderManager.java
@@ -15,143 +15,144 @@ import java.io.InputStreamReader;
import java.util.HashMap;
public class ShaderManager {
-
- private ResourceLocation shaderLocation = new ResourceLocation("notenoughupdates:shaders");
- private HashMap<String, Shader> shaderMap = new HashMap<>();
-
- private static final ShaderManager INSTANCE = new ShaderManager();
-
- public static ShaderManager getInstance() {
- return INSTANCE;
- }
-
- public class Shader {
- public final int program;
-
- public Shader(int program) {
- this.program = program;
- }
- }
-
- public int getShader(String name) {
- if(!shaderMap.containsKey(name)) {
- reloadShader(name);
- }
- return shaderMap.get(name).program;
- }
-
- public int loadShader(String name) {
- if(!shaderMap.containsKey(name)) {
- reloadShader(name);
- }
- GL20.glUseProgram(shaderMap.get(name).program);
- return shaderMap.get(name).program;
- }
-
- public void loadData(String name, String var, Object value) {
- int location = GL20.glGetUniformLocation(shaderMap.get(name).program, var);
-
- if(value instanceof Integer) {
- GL20.glUniform1i(location, (Integer) value);
- } else if(value instanceof Float) {
- GL20.glUniform1f(location, (Float) value);
- } else if(value instanceof Vector2f) {
- Vector2f vec = (Vector2f) value;
- GL20.glUniform2f(location, vec.x, vec.y);
- } else if(value instanceof Vector3f) {
- Vector3f vec = (Vector3f) value;
- GL20.glUniform3f(location, vec.x, vec.y, vec.z);
- } else if(value instanceof Vector4f) {
- Vector4f vec = (Vector4f) value;
- GL20.glUniform4f(location, vec.x, vec.y, vec.z, vec.w);
- } else {
- throw new UnsupportedOperationException("Failed to load data into shader: Unsupported data type.");
- }
- }
-
- private void reloadShader(String name) {
- int vertex = -1;
- String sourceVert = getShaderSource(name, GL20.GL_VERTEX_SHADER);
- if(!sourceVert.isEmpty()) {
- vertex = GL20.glCreateShader(GL20.GL_VERTEX_SHADER);
- GL20.glShaderSource(vertex, sourceVert);
- GL20.glCompileShader(vertex);
-
- if (GL20.glGetShaderi(vertex, 35713) == 0) {
- System.err.println(GL20.glGetShaderInfoLog(vertex, 100));
- }
- }
-
- int fragment = -1;
- String sourceFrag = getShaderSource(name, GL20.GL_FRAGMENT_SHADER);
- if(!sourceFrag.isEmpty()) {
- fragment = GL20.glCreateShader(GL20.GL_FRAGMENT_SHADER);
- GL20.glShaderSource(fragment, sourceFrag);
- GL20.glCompileShader(fragment);
-
- if (GL20.glGetShaderi(fragment, 35713) == 0) {
- System.err.println(GL20.glGetShaderInfoLog(fragment, 100));
- }
- }
-
- int compute = -1;
- String sourceCompute = getShaderSource(name, GL43.GL_COMPUTE_SHADER);
- if(!sourceCompute.isEmpty()) {
- compute = GL20.glCreateShader(GL43.GL_COMPUTE_SHADER);
- GL20.glShaderSource(compute, sourceCompute);
- GL20.glCompileShader(compute);
-
- if (GL20.glGetShaderi(compute, 35713) == 0) {
- System.err.println(GL20.glGetShaderInfoLog(compute, 100));
- }
- }
-
- int program = GL20.glCreateProgram();
- if(vertex != -1) GL20.glAttachShader(program, vertex);
- if(fragment != -1) GL20.glAttachShader(program, fragment);
- if(compute != -1) GL20.glAttachShader(program, compute);
-
- GL20.glLinkProgram(program);
-
- if(vertex != -1) GL20.glDeleteShader(vertex);
- if(fragment != -1) GL20.glDeleteShader(fragment);
- if(compute != -1) GL20.glDeleteShader(compute);
-
- if (GL20.glGetProgrami(program, 35714) == 0) {
- System.err.println(GL20.glGetProgramInfoLog(program, 100));
- }
- GL20.glValidateProgram(program);
- if (GL20.glGetProgrami(program, 35715) == 0) {
- System.err.println(GL20.glGetProgramInfoLog(program, 100));
- }
-
- shaderMap.put(name, new Shader(program));
- }
-
- public String getShaderSource(String name, int type) {
- String ext = "";
- if(type == GL20.GL_VERTEX_SHADER) {
- ext = ".vert";
- } else if(type == GL20.GL_FRAGMENT_SHADER) {
- ext = ".frag";
- } else if(type == GL43.GL_COMPUTE_SHADER) {
- ext = ".compute";
- } else {
- return "";
- }
- ResourceLocation location = new ResourceLocation(shaderLocation.getResourceDomain(),
- shaderLocation.getResourcePath()+"/"+name+ext);
- try(InputStream is = Minecraft.getMinecraft().getResourceManager().getResource(location).getInputStream()) {
- StringBuilder source = new StringBuilder();
- BufferedReader br = new BufferedReader(new InputStreamReader(is));
-
- String line;
- while((line = br.readLine()) != null) {
- source.append(line).append("\n");
- }
- return source.toString();
- } catch(IOException e) {
- }
- return "";
- }
+ private final ResourceLocation shaderLocation = new ResourceLocation("notenoughupdates:shaders");
+ private final HashMap<String, Shader> shaderMap = new HashMap<>();
+
+ private static final ShaderManager INSTANCE = new ShaderManager();
+
+ public static ShaderManager getInstance() {
+ return INSTANCE;
+ }
+
+ public static class Shader {
+ public final int program;
+
+ public Shader(int program) {
+ this.program = program;
+ }
+ }
+
+ public int getShader(String name) {
+ if (!shaderMap.containsKey(name)) {
+ reloadShader(name);
+ }
+ return shaderMap.get(name).program;
+ }
+
+ public int loadShader(String name) {
+ if (!shaderMap.containsKey(name)) {
+ reloadShader(name);
+ }
+ GL20.glUseProgram(shaderMap.get(name).program);
+ return shaderMap.get(name).program;
+ }
+
+ public void loadData(String name, String var, Object value) {
+ int location = GL20.glGetUniformLocation(shaderMap.get(name).program, var);
+
+ if (value instanceof Integer) {
+ GL20.glUniform1i(location, (Integer) value);
+ } else if (value instanceof Float) {
+ GL20.glUniform1f(location, (Float) value);
+ } else if (value instanceof Vector2f) {
+ Vector2f vec = (Vector2f) value;
+ GL20.glUniform2f(location, vec.x, vec.y);
+ } else if (value instanceof Vector3f) {
+ Vector3f vec = (Vector3f) value;
+ GL20.glUniform3f(location, vec.x, vec.y, vec.z);
+ } else if (value instanceof Vector4f) {
+ Vector4f vec = (Vector4f) value;
+ GL20.glUniform4f(location, vec.x, vec.y, vec.z, vec.w);
+ } else {
+ throw new UnsupportedOperationException("Failed to load data into shader: Unsupported data type.");
+ }
+ }
+
+ private void reloadShader(String name) {
+ int vertex = -1;
+ String sourceVert = getShaderSource(name, GL20.GL_VERTEX_SHADER);
+ if (!sourceVert.isEmpty()) {
+ vertex = GL20.glCreateShader(GL20.GL_VERTEX_SHADER);
+ GL20.glShaderSource(vertex, sourceVert);
+ GL20.glCompileShader(vertex);
+
+ if (GL20.glGetShaderi(vertex, 35713) == 0) {
+ System.err.println(GL20.glGetShaderInfoLog(vertex, 100));
+ }
+ }
+
+ int fragment = -1;
+ String sourceFrag = getShaderSource(name, GL20.GL_FRAGMENT_SHADER);
+ if (!sourceFrag.isEmpty()) {
+ fragment = GL20.glCreateShader(GL20.GL_FRAGMENT_SHADER);
+ GL20.glShaderSource(fragment, sourceFrag);
+ GL20.glCompileShader(fragment);
+
+ if (GL20.glGetShaderi(fragment, 35713) == 0) {
+ System.err.println(GL20.glGetShaderInfoLog(fragment, 100));
+ }
+ }
+
+ int compute = -1;
+ String sourceCompute = getShaderSource(name, GL43.GL_COMPUTE_SHADER);
+ if (!sourceCompute.isEmpty()) {
+ compute = GL20.glCreateShader(GL43.GL_COMPUTE_SHADER);
+ GL20.glShaderSource(compute, sourceCompute);
+ GL20.glCompileShader(compute);
+
+ if (GL20.glGetShaderi(compute, 35713) == 0) {
+ System.err.println(GL20.glGetShaderInfoLog(compute, 100));
+ }
+ }
+
+ int program = GL20.glCreateProgram();
+ if (vertex != -1) GL20.glAttachShader(program, vertex);
+ if (fragment != -1) GL20.glAttachShader(program, fragment);
+ if (compute != -1) GL20.glAttachShader(program, compute);
+
+ GL20.glLinkProgram(program);
+
+ if (vertex != -1) GL20.glDeleteShader(vertex);
+ if (fragment != -1) GL20.glDeleteShader(fragment);
+ if (compute != -1) GL20.glDeleteShader(compute);
+
+ if (GL20.glGetProgrami(program, 35714) == 0) {
+ System.err.println(GL20.glGetProgramInfoLog(program, 100));
+ }
+ GL20.glValidateProgram(program);
+ if (GL20.glGetProgrami(program, 35715) == 0) {
+ System.err.println(GL20.glGetProgramInfoLog(program, 100));
+ }
+
+ shaderMap.put(name, new Shader(program));
+ }
+
+ public String getShaderSource(String name, int type) {
+ String ext = "";
+ if (type == GL20.GL_VERTEX_SHADER) {
+ ext = ".vert";
+ } else if (type == GL20.GL_FRAGMENT_SHADER) {
+ ext = ".frag";
+ } else if (type == GL43.GL_COMPUTE_SHADER) {
+ ext = ".compute";
+ } else {
+ return "";
+ }
+ ResourceLocation location = new ResourceLocation(
+ shaderLocation.getResourceDomain(),
+ shaderLocation.getResourcePath() + "/" + name + ext
+ );
+ try (InputStream is = Minecraft.getMinecraft().getResourceManager().getResource(location).getInputStream()) {
+ StringBuilder source = new StringBuilder();
+ BufferedReader br = new BufferedReader(new InputStreamReader(is));
+
+ String line;
+ while ((line = br.readLine()) != null) {
+ source.append(line).append("\n");
+ }
+ return source.toString();
+ } catch (IOException ignored) {
+ }
+ return "";
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonBlocks.java b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonBlocks.java
index 890155e8..0e7c59c7 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonBlocks.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonBlocks.java
@@ -7,12 +7,17 @@ import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution;
-import net.minecraft.client.renderer.*;
-import net.minecraft.client.renderer.texture.*;
+import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.client.renderer.OpenGlHelper;
+import net.minecraft.client.renderer.texture.TextureAtlasSprite;
+import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.shader.Framebuffer;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.BufferUtils;
-import org.lwjgl.opengl.*;
+import org.lwjgl.opengl.GL11;
+import org.lwjgl.opengl.GL12;
+import org.lwjgl.opengl.GL14;
+import org.lwjgl.opengl.GL30;
import java.nio.FloatBuffer;
import java.util.HashMap;
@@ -20,237 +25,273 @@ import java.util.HashSet;
import java.util.Map;
public class DungeonBlocks {
-
- private static Framebuffer framebufferBlocksTo = null;
- private static Framebuffer framebufferBlocksFrom = null;
-
- private static HashMap<String, Framebuffer> framebuffersDynamicTo = new HashMap<>();
- public static HashMap<String, Framebuffer> framebuffersDynamicFrom = new HashMap<>();
- private static HashSet<String> dynamicUpdated = new HashSet<>();
-
- private static FloatBuffer projectionMatrixOld = BufferUtils.createFloatBuffer(16);
- private static FloatBuffer modelviewMatrixOld = BufferUtils.createFloatBuffer(16);
-
- public static boolean textureExists() {
- return framebufferBlocksFrom != null && isOverriding();
- }
-
- public static void bindTextureIfExists() {
- if(textureExists()) {
- framebufferBlocksFrom.bindFramebufferTexture();
- }
- }
-
- public static boolean isOverriding() {
- return OpenGlHelper.isFramebufferEnabled() && NotEnoughUpdates.INSTANCE.config.dungeons.enableDungBlockOverlay &&
- (NotEnoughUpdates.INSTANCE.config.dungeons.dungeonBlocksEverywhere ||
- (SBInfo.getInstance().getLocation() != null && SBInfo.getInstance().getLocation().equals("dungeon")));
- }
-
- public static boolean bindModifiedTexture(ResourceLocation location, int colour) {
- if(!isOverriding()) {
- return false;
- }
-
- if(Utils.disableCustomDungColours) {
- return false;
- }
-
- if(((colour >> 24) & 0xFF) < 10) {
- return false;
- }
-
- String id = location.getResourceDomain()+":"+location.getResourcePath();
- if(dynamicUpdated.contains(id) && framebuffersDynamicFrom.containsKey(id)) {
- framebuffersDynamicFrom.get(id).bindFramebufferTexture();
- return true;
- }
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(location);
- int w = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_WIDTH);
- int h = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_HEIGHT);
-
- Framebuffer to = checkFramebufferSizes(framebuffersDynamicTo.get(id), w, h);
- dynamicUpdated.add(id);
-
- try {
- GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, projectionMatrixOld);
- GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, modelviewMatrixOld);
-
- GL11.glPushMatrix();
-
- GlStateManager.matrixMode(GL11.GL_PROJECTION);
- GlStateManager.loadIdentity();
- GlStateManager.ortho(0.0D, w, h, 0.0D, 1000.0D, 3000.0D);
- GlStateManager.matrixMode(GL11.GL_MODELVIEW);
- GlStateManager.loadIdentity();
- GlStateManager.translate(0.0F, 0.0F, -2000.0F);
-
- to.bindFramebuffer(true);
- GlStateManager.clearColor(0, 1, 0, 1);
- GlStateManager.clear(GL11.GL_COLOR_BUFFER_BIT);
-
- GlStateManager.disableBlend();
- GlStateManager.disableLighting();
- GlStateManager.disableFog();
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(location);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRectNoBlend(0, 0, w, h, 0, 1, 1, 0, GL11.GL_LINEAR);
-
- GlStateManager.enableBlend();
- GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
- Utils.drawRectNoBlend(0, 0, w, h, colour);
-
- GL11.glPopMatrix();
-
- to.bindFramebufferTexture();
- if (Minecraft.getMinecraft().gameSettings.mipmapLevels >= 0) {
- GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LEVEL, Minecraft.getMinecraft().gameSettings.mipmapLevels);
- GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MIN_LOD, 0.0F);
- GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LOD, (float)Minecraft.getMinecraft().gameSettings.mipmapLevels);
- GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, 0.0F);
- GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);
- }
-
- GlStateManager.matrixMode(GL11.GL_PROJECTION);
- GL11.glLoadMatrix(projectionMatrixOld);
- GlStateManager.matrixMode(GL11.GL_MODELVIEW);
- GL11.glLoadMatrix(modelviewMatrixOld);
-
- Framebuffer from = checkFramebufferSizes(framebuffersDynamicFrom.get(id), w, h);
- framebuffersDynamicFrom.put(id, to);
- framebuffersDynamicTo.put(id, from);
-
- to.bindFramebufferTexture();
-
- Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true);
- GlStateManager.disableBlend();
- GlStateManager.enableLighting();
- return true;
- } catch(Exception e) {
- e.printStackTrace();
- }
- Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true);
- GlStateManager.disableBlend();
- GlStateManager.enableLighting();
- return false;
- }
-
- private static HashMap<ResourceLocation, String> dynamicPreloadMap = new HashMap<>();
-
- static {
- dynamicPreloadMap.put(new ResourceLocation("textures/entity/bat.png"),
- NotEnoughUpdates.INSTANCE.config.dungeons.dungBatColour);
- dynamicPreloadMap.put(new ResourceLocation("textures/entity/chest/normal.png"),
- NotEnoughUpdates.INSTANCE.config.dungeons.dungChestColour);
- dynamicPreloadMap.put(new ResourceLocation("textures/entity/chest/normal_double.png"),
- NotEnoughUpdates.INSTANCE.config.dungeons.dungChestColour);
- dynamicPreloadMap.put(new ResourceLocation("textures/entity/chest/trapped.png"),
- NotEnoughUpdates.INSTANCE.config.dungeons.dungTrappedChestColour);
- dynamicPreloadMap.put(new ResourceLocation("textures/entity/chest/trapped_double.png"),
- NotEnoughUpdates.INSTANCE.config.dungeons.dungTrappedChestColour);
- }
-
- public static void tick() {
- if(!isOverriding() || Minecraft.getMinecraft().theWorld == null) {
- return;
- }
-
- dynamicUpdated.clear();
-
- for(Map.Entry<ResourceLocation, String> entry : dynamicPreloadMap.entrySet()) {
- bindModifiedTexture(entry.getKey(), SpecialColour.specialToChromaRGB(entry.getValue()));
- }
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
- int w = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_WIDTH);
- int h = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_HEIGHT);
-
- Framebuffer to = checkFramebufferSizes(framebufferBlocksTo, w, h);
-
- try {
- GL11.glPushMatrix();
-
- GlStateManager.matrixMode(5889);
- GlStateManager.loadIdentity();
- GlStateManager.ortho(0.0D, w, h, 0.0D, 1000.0D, 3000.0D);
- GlStateManager.matrixMode(5888);
- GlStateManager.loadIdentity();
- GlStateManager.translate(0.0F, 0.0F, -2000.0F);
-
- to.bindFramebuffer(true);
- GlStateManager.clear(GL11.GL_COLOR_BUFFER_BIT);
-
- GlStateManager.disableBlend();
- GlStateManager.disableLighting();
- GlStateManager.disableFog();
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRectNoBlend(0, 0, w, h, 0, 1, 1, 0, GL11.GL_LINEAR);
-
- HashMap<TextureAtlasSprite, Integer> spriteMap = new HashMap<>();
- spriteMap.put(Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/stonebrick_cracked"),
- SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.dungeons.dungCrackedColour));
- spriteMap.put(Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/dispenser_front_horizontal"),
- SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.dungeons.dungDispenserColour));
- spriteMap.put(Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/lever"),
- SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.dungeons.dungLeverColour));
- spriteMap.put(Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/trip_wire"),
- SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.dungeons.dungTripWireColour));
-
- for(Map.Entry<TextureAtlasSprite, Integer> entry : spriteMap.entrySet()) {
- if(((entry.getValue() >> 24) & 0xFF) < 10) continue;
-
- TextureAtlasSprite tas = entry.getKey();
- Gui.drawRect((int)(w*tas.getMinU()), h-(int)(h*tas.getMaxV())-1,
- (int)(w*tas.getMaxU())+1, h-(int)(h*tas.getMinV()), entry.getValue());
- }
-
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- GlStateManager.matrixMode(5889);
- GlStateManager.loadIdentity();
- GlStateManager.ortho(0.0D, scaledResolution.getScaledWidth_double(), scaledResolution.getScaledHeight_double(),
- 0.0D, 1000.0D, 3000.0D);
- GlStateManager.matrixMode(5888);
- GlStateManager.loadIdentity();
- GlStateManager.translate(0.0F, 0.0F, -2000.0F);
-
- GL11.glPopMatrix();
-
- to.bindFramebufferTexture();
- if (Minecraft.getMinecraft().gameSettings.mipmapLevels >= 0) {
- GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LEVEL, Minecraft.getMinecraft().gameSettings.mipmapLevels);
- GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MIN_LOD, 0.0F);
- GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LOD, (float)Minecraft.getMinecraft().gameSettings.mipmapLevels);
- GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, 0.0F);
- GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);
- }
-
- Framebuffer from = checkFramebufferSizes(framebufferBlocksFrom, w, h);
- framebufferBlocksFrom = to;
- framebufferBlocksTo = from;
- } catch(Exception e) {
- e.printStackTrace();
- }
- Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true);
- GlStateManager.enableBlend();
- }
-
- private static Framebuffer checkFramebufferSizes(Framebuffer framebuffer, int width, int height) {
- if(framebuffer == null || framebuffer.framebufferWidth != width || framebuffer.framebufferHeight != height) {
- if(framebuffer == null) {
- framebuffer = new Framebuffer(width, height, false);
- framebuffer.framebufferColor[0] = 1f;
- framebuffer.framebufferColor[1] = 0f;
- framebuffer.framebufferColor[2] = 0f;
- framebuffer.framebufferColor[3] = 0;
- } else {
- framebuffer.createBindFramebuffer(width, height);
- }
- framebuffer.setFramebufferFilter(GL11.GL_NEAREST);
- }
- return framebuffer;
- }
+ private static Framebuffer framebufferBlocksTo = null;
+ private static Framebuffer framebufferBlocksFrom = null;
+
+ private static final HashMap<String, Framebuffer> framebuffersDynamicTo = new HashMap<>();
+ public static HashMap<String, Framebuffer> framebuffersDynamicFrom = new HashMap<>();
+ private static final HashSet<String> dynamicUpdated = new HashSet<>();
+
+ private static final FloatBuffer projectionMatrixOld = BufferUtils.createFloatBuffer(16);
+ private static final FloatBuffer modelviewMatrixOld = BufferUtils.createFloatBuffer(16);
+
+ public static boolean textureExists() {
+ return framebufferBlocksFrom != null && isOverriding();
+ }
+
+ public static void bindTextureIfExists() {
+ if (textureExists()) {
+ framebufferBlocksFrom.bindFramebufferTexture();
+ }
+ }
+
+ public static boolean isOverriding() {
+ return OpenGlHelper.isFramebufferEnabled() && NotEnoughUpdates.INSTANCE.config.dungeons.enableDungBlockOverlay &&
+ (NotEnoughUpdates.INSTANCE.config.dungeons.dungeonBlocksEverywhere ||
+ (SBInfo.getInstance().getLocation() != null && SBInfo.getInstance().getLocation().equals("dungeon")));
+ }
+
+ public static boolean bindModifiedTexture(ResourceLocation location, int colour) {
+ if (!isOverriding()) {
+ return false;
+ }
+
+ if (Utils.disableCustomDungColours) {
+ return false;
+ }
+
+ if (((colour >> 24) & 0xFF) < 10) {
+ return false;
+ }
+
+ String id = location.getResourceDomain() + ":" + location.getResourcePath();
+ if (dynamicUpdated.contains(id) && framebuffersDynamicFrom.containsKey(id)) {
+ framebuffersDynamicFrom.get(id).bindFramebufferTexture();
+ return true;
+ }
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(location);
+ int w = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_WIDTH);
+ int h = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_HEIGHT);
+
+ Framebuffer to = checkFramebufferSizes(framebuffersDynamicTo.get(id), w, h);
+ dynamicUpdated.add(id);
+
+ try {
+ GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, projectionMatrixOld);
+ GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, modelviewMatrixOld);
+
+ GL11.glPushMatrix();
+
+ GlStateManager.matrixMode(GL11.GL_PROJECTION);
+ GlStateManager.loadIdentity();
+ GlStateManager.ortho(0.0D, w, h, 0.0D, 1000.0D, 3000.0D);
+ GlStateManager.matrixMode(GL11.GL_MODELVIEW);
+ GlStateManager.loadIdentity();
+ GlStateManager.translate(0.0F, 0.0F, -2000.0F);
+
+ to.bindFramebuffer(true);
+ GlStateManager.clearColor(0, 1, 0, 1);
+ GlStateManager.clear(GL11.GL_COLOR_BUFFER_BIT);
+
+ GlStateManager.disableBlend();
+ GlStateManager.disableLighting();
+ GlStateManager.disableFog();
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(location);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRectNoBlend(0, 0, w, h, 0, 1, 1, 0, GL11.GL_LINEAR);
+
+ GlStateManager.enableBlend();
+ GL14.glBlendFuncSeparate(
+ GL11.GL_SRC_ALPHA,
+ GL11.GL_ONE_MINUS_SRC_ALPHA,
+ GL11.GL_ONE,
+ GL11.GL_ONE_MINUS_SRC_ALPHA
+ );
+ Utils.drawRectNoBlend(0, 0, w, h, colour);
+
+ GL11.glPopMatrix();
+
+ to.bindFramebufferTexture();
+ if (Minecraft.getMinecraft().gameSettings.mipmapLevels >= 0) {
+ GL11.glTexParameteri(
+ GL11.GL_TEXTURE_2D,
+ GL12.GL_TEXTURE_MAX_LEVEL,
+ Minecraft.getMinecraft().gameSettings.mipmapLevels
+ );
+ GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MIN_LOD, 0.0F);
+ GL11.glTexParameterf(
+ GL11.GL_TEXTURE_2D,
+ GL12.GL_TEXTURE_MAX_LOD,
+ (float) Minecraft.getMinecraft().gameSettings.mipmapLevels
+ );
+ GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, 0.0F);
+ GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);
+ }
+
+ GlStateManager.matrixMode(GL11.GL_PROJECTION);
+ GL11.glLoadMatrix(projectionMatrixOld);
+ GlStateManager.matrixMode(GL11.GL_MODELVIEW);
+ GL11.glLoadMatrix(modelviewMatrixOld);
+
+ Framebuffer from = checkFramebufferSizes(framebuffersDynamicFrom.get(id), w, h);
+ framebuffersDynamicFrom.put(id, to);
+ framebuffersDynamicTo.put(id, from);
+
+ to.bindFramebufferTexture();
+
+ Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true);
+ GlStateManager.disableBlend();
+ GlStateManager.enableLighting();
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true);
+ GlStateManager.disableBlend();
+ GlStateManager.enableLighting();
+ return false;
+ }
+
+ private static final HashMap<ResourceLocation, String> dynamicPreloadMap = new HashMap<ResourceLocation, String>() {{
+ put(new ResourceLocation("textures/entity/bat.png"), NotEnoughUpdates.INSTANCE.config.dungeons.dungBatColour);
+ put(
+ new ResourceLocation("textures/entity/chest/normal.png"),
+ NotEnoughUpdates.INSTANCE.config.dungeons.dungChestColour
+ );
+ put(
+ new ResourceLocation("textures/entity/chest/normal_double.png"),
+ NotEnoughUpdates.INSTANCE.config.dungeons.dungChestColour
+ );
+ put(
+ new ResourceLocation("textures/entity/chest/trapped.png"),
+ NotEnoughUpdates.INSTANCE.config.dungeons.dungTrappedChestColour
+ );
+ put(
+ new ResourceLocation("textures/entity/chest/trapped_double.png"),
+ NotEnoughUpdates.INSTANCE.config.dungeons.dungTrappedChestColour
+ );
+ }};
+
+ public static void tick() {
+ if (!isOverriding() || Minecraft.getMinecraft().theWorld == null) {
+ return;
+ }
+
+ dynamicUpdated.clear();
+
+ for (Map.Entry<ResourceLocation, String> entry : dynamicPreloadMap.entrySet()) {
+ bindModifiedTexture(entry.getKey(), SpecialColour.specialToChromaRGB(entry.getValue()));
+ }
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
+ int w = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_WIDTH);
+ int h = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_HEIGHT);
+
+ Framebuffer to = checkFramebufferSizes(framebufferBlocksTo, w, h);
+
+ try {
+ GL11.glPushMatrix();
+
+ GlStateManager.matrixMode(5889);
+ GlStateManager.loadIdentity();
+ GlStateManager.ortho(0.0D, w, h, 0.0D, 1000.0D, 3000.0D);
+ GlStateManager.matrixMode(5888);
+ GlStateManager.loadIdentity();
+ GlStateManager.translate(0.0F, 0.0F, -2000.0F);
+
+ to.bindFramebuffer(true);
+ GlStateManager.clear(GL11.GL_COLOR_BUFFER_BIT);
+
+ GlStateManager.disableBlend();
+ GlStateManager.disableLighting();
+ GlStateManager.disableFog();
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRectNoBlend(0, 0, w, h, 0, 1, 1, 0, GL11.GL_LINEAR);
+
+ HashMap<TextureAtlasSprite, Integer> spriteMap = new HashMap<TextureAtlasSprite, Integer>() {{
+ put(
+ Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/stonebrick_cracked"),
+ SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.dungeons.dungCrackedColour)
+ );
+ put(
+ Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/dispenser_front_horizontal"),
+ SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.dungeons.dungDispenserColour)
+ );
+ put(
+ Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/lever"),
+ SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.dungeons.dungLeverColour)
+ );
+ put(
+ Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/trip_wire"),
+ SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.dungeons.dungTripWireColour)
+ );
+ }};
+
+ for (Map.Entry<TextureAtlasSprite, Integer> entry : spriteMap.entrySet()) {
+ if (((entry.getValue() >> 24) & 0xFF) < 10) continue;
+
+ TextureAtlasSprite tas = entry.getKey();
+ Gui.drawRect((int) (w * tas.getMinU()), h - (int) (h * tas.getMaxV()) - 1,
+ (int) (w * tas.getMaxU()) + 1, h - (int) (h * tas.getMinV()), entry.getValue()
+ );
+ }
+
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ GlStateManager.matrixMode(5889);
+ GlStateManager.loadIdentity();
+ GlStateManager.ortho(0.0D, scaledResolution.getScaledWidth_double(), scaledResolution.getScaledHeight_double(),
+ 0.0D, 1000.0D, 3000.0D
+ );
+ GlStateManager.matrixMode(5888);
+ GlStateManager.loadIdentity();
+ GlStateManager.translate(0.0F, 0.0F, -2000.0F);
+
+ GL11.glPopMatrix();
+
+ to.bindFramebufferTexture();
+ if (Minecraft.getMinecraft().gameSettings.mipmapLevels >= 0) {
+ GL11.glTexParameteri(
+ GL11.GL_TEXTURE_2D,
+ GL12.GL_TEXTURE_MAX_LEVEL,
+ Minecraft.getMinecraft().gameSettings.mipmapLevels
+ );
+ GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MIN_LOD, 0.0F);
+ GL11.glTexParameterf(
+ GL11.GL_TEXTURE_2D,
+ GL12.GL_TEXTURE_MAX_LOD,
+ (float) Minecraft.getMinecraft().gameSettings.mipmapLevels
+ );
+ GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, 0.0F);
+ GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);
+ }
+
+ Framebuffer from = checkFramebufferSizes(framebufferBlocksFrom, w, h);
+ framebufferBlocksFrom = to;
+ framebufferBlocksTo = from;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true);
+ GlStateManager.enableBlend();
+ }
+
+ private static Framebuffer checkFramebufferSizes(Framebuffer framebuffer, int width, int height) {
+ if (framebuffer == null || framebuffer.framebufferWidth != width || framebuffer.framebufferHeight != height) {
+ if (framebuffer == null) {
+ framebuffer = new Framebuffer(width, height, false);
+ framebuffer.framebufferColor[0] = 1f;
+ framebuffer.framebufferColor[1] = 0f;
+ framebuffer.framebufferColor[2] = 0f;
+ framebuffer.framebufferColor[3] = 0;
+ } else {
+ framebuffer.createBindFramebuffer(width, height);
+ }
+ framebuffer.setFramebufferFilter(GL11.GL_NEAREST);
+ }
+ return framebuffer;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java
index 658f72df..592f5b19 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java
@@ -2,10 +2,10 @@ package io.github.moulberry.notenoughupdates.dungeons;
import com.google.common.collect.Iterables;
import com.google.gson.JsonObject;
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.core.BackgroundBlur;
import io.github.moulberry.notenoughupdates.core.config.Position;
import io.github.moulberry.notenoughupdates.util.NEUResourceManager;
-import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.util.SpecialColour;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.block.material.MapColor;
@@ -13,7 +13,10 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution;
-import net.minecraft.client.renderer.*;
+import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.client.renderer.OpenGlHelper;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.texture.TextureUtil;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.resources.DefaultPlayerSkin;
@@ -29,11 +32,12 @@ import net.minecraft.scoreboard.Score;
import net.minecraft.scoreboard.ScoreObjective;
import net.minecraft.scoreboard.ScorePlayerTeam;
import net.minecraft.scoreboard.Scoreboard;
-import net.minecraft.util.*;
+import net.minecraft.util.Matrix4f;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.Vec4b;
import net.minecraft.world.storage.MapData;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.event.world.WorldEvent;
-import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL14;
@@ -42,357 +46,393 @@ import java.awt.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
-import java.util.*;
import java.util.List;
+import java.util.*;
public class DungeonMap {
-
- private static final ResourceLocation GREEN_CHECK = new ResourceLocation("notenoughupdates:dungeon_map/green_check.png");
- private static final ResourceLocation WHITE_CHECK = new ResourceLocation("notenoughupdates:dungeon_map/white_check.png");
- private static final ResourceLocation QUESTION = new ResourceLocation("notenoughupdates:dungeon_map/question.png");
- private static final ResourceLocation CROSS = new ResourceLocation("notenoughupdates:dungeon_map/cross.png");
-
- private static final ResourceLocation ROOM_RED = new ResourceLocation("notenoughupdates:dungeon_map/rooms_default/red_room.png");
- private static final ResourceLocation ROOM_BROWN = new ResourceLocation("notenoughupdates:dungeon_map/rooms_default/brown_room.png");
- private static final ResourceLocation ROOM_GRAY = new ResourceLocation("notenoughupdates:dungeon_map/rooms_default/gray_room.png");
- private static final ResourceLocation ROOM_GREEN = new ResourceLocation("notenoughupdates:dungeon_map/rooms_default/green_room.png");
- private static final ResourceLocation ROOM_PINK = new ResourceLocation("notenoughupdates:dungeon_map/rooms_default/pink_room.png");
- private static final ResourceLocation ROOM_PURPLE = new ResourceLocation("notenoughupdates:dungeon_map/rooms_default/purple_room.png");
- private static final ResourceLocation ROOM_YELLOW = new ResourceLocation("notenoughupdates:dungeon_map/rooms_default/yellow_room.png");
- private static final ResourceLocation ROOM_ORANGE = new ResourceLocation("notenoughupdates:dungeon_map/rooms_default/orange_room.png");
-
- private static final ResourceLocation CORRIDOR_RED = new ResourceLocation("notenoughupdates:dungeon_map/corridors_default/red_corridor.png");
- private static final ResourceLocation CORRIDOR_BROWN = new ResourceLocation("notenoughupdates:dungeon_map/corridors_default/brown_corridor.png");
- private static final ResourceLocation CORRIDOR_GRAY = new ResourceLocation("notenoughupdates:dungeon_map/corridors_default/gray_corridor.png");
- private static final ResourceLocation CORRIDOR_GREEN = new ResourceLocation("notenoughupdates:dungeon_map/corridors_default/green_corridor.png");
- private static final ResourceLocation CORRIDOR_PINK = new ResourceLocation("notenoughupdates:dungeon_map/corridors_default/pink_corridor.png");
- private static final ResourceLocation CORRIDOR_PURPLE = new ResourceLocation("notenoughupdates:dungeon_map/corridors_default/purple_corridor.png");
- private static final ResourceLocation CORRIDOR_YELLOW = new ResourceLocation("notenoughupdates:dungeon_map/corridors_default/yellow_corridor.png");
- private static final ResourceLocation CORRIDOR_ORANGE = new ResourceLocation("notenoughupdates:dungeon_map/corridors_default/orange_corridor.png");
-
- private static final ResourceLocation DIVIDER_BROWN = new ResourceLocation("notenoughupdates:dungeon_map/dividers_default/brown_divider.png");
-
- private static final ResourceLocation CORNER_BROWN = new ResourceLocation("notenoughupdates:dungeon_map/corners_default/brown_corner.png");
-
- private final HashMap<RoomOffset, Room> roomMap = new HashMap<>();
- private Color[][] colourMap = new Color[128][128];
- private int startRoomX = -1;
- private int startRoomY = -1;
- private int connectorSize = 5;
- private int roomSize = 0;
-
- //private final List<MapDecoration> decorations = new ArrayList<>();
- //private final List<MapDecoration> lastDecorations = new ArrayList<>();
- private long lastDecorationsMillis = -1;
- private long lastLastDecorationsMillis = -1;
-
- private Map<String, MapPosition> playerEntityMapPositions = new HashMap<>();
- private Map<String, MapPosition> playerMarkerMapPositions = new HashMap<>();
- private Set<MapPosition> rawPlayerMarkerMapPositions = new HashSet<>();
- private Map<String, MapPosition> playerMarkerMapPositionsLast = new HashMap<>();
- private HashMap<String, Integer> playerIdMap = new HashMap<>();
-
- private Map<String, ResourceLocation> playerSkinMap = new HashMap<>();
-
- private class RoomOffset {
- int x;
- int y;
-
- public RoomOffset(int x, int y) {
- this.x = x;
- this.y = y;
- }
-
- public RoomOffset left() {
- return new RoomOffset(x-1, y);
- }
-
- public RoomOffset right() {
- return new RoomOffset(x+1, y);
- }
-
- public RoomOffset up() {
- return new RoomOffset(x, y-1);
- }
-
- public RoomOffset down() {
- return new RoomOffset(x, y+1);
- }
-
- public RoomOffset[] getNeighbors() {
- return new RoomOffset[]{left(), right(), up(), down()};
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- RoomOffset that = (RoomOffset) o;
- return x == that.x && y == that.y;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(x, y);
- }
- }
-
- private enum RoomConnectionType {
- NONE, WALL, CORRIDOR, ROOM_DIVIDER
- }
-
- private class RoomConnection {
- RoomConnectionType type;
- Color colour;
-
- public RoomConnection(RoomConnectionType type, Color colour) {
- this.type = type;
- this.colour = colour;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- RoomConnection that = (RoomConnection) o;
- return type == that.type &&
- Objects.equals(colour, that.colour);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(type, colour);
- }
- }
-
- private class Room {
- Color colour = new Color(0, 0, 0, 0);
- int tickColour = 0;
- boolean fillCorner = false;
-
- RoomConnection left = new RoomConnection(RoomConnectionType.NONE, new Color(0, true));
- RoomConnection up = new RoomConnection(RoomConnectionType.NONE, new Color(0, true));
- RoomConnection right = new RoomConnection(RoomConnectionType.NONE, new Color(0, true));
- RoomConnection down = new RoomConnection(RoomConnectionType.NONE, new Color(0, true));
-
- public void renderNoRotate(int roomSize, int connectorSize, int rotation) {
- if(tickColour != 0) {
- Color tick = new Color(tickColour, true);
- ResourceLocation indicatorTex = null;
- if(tick.getRed() == 255 && tick.getGreen() == 255 && tick.getBlue() == 255) {
- indicatorTex = WHITE_CHECK;
- } else if(tick.getRed() == 0 && tick.getGreen() == 124 && tick.getBlue() == 0) {
- indicatorTex = GREEN_CHECK;
- } else if(tick.getRed() == 13 && tick.getGreen() == 13 && tick.getBlue() == 13) {
- indicatorTex = QUESTION;
- } else if(tick.getRed() == 255 && tick.getGreen() == 0 && tick.getBlue() == 0) {
- indicatorTex = CROSS;
- }
- if(indicatorTex != null) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(indicatorTex);
- float x = 0;
- float y = 0;
-
- if(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmCenterCheck) {
- if(fillCorner) {
- x += -(roomSize+connectorSize)/2f*Math.cos(Math.toRadians(rotation-45))*1.414f;
- y += (roomSize+connectorSize)/2f*Math.sin(Math.toRadians(rotation-45))*1.414;
- }
- if(down.type == RoomConnectionType.ROOM_DIVIDER && right.type != RoomConnectionType.ROOM_DIVIDER) {
- x += -(roomSize+connectorSize)/2f*Math.sin(Math.toRadians(rotation));
- y += -(roomSize+connectorSize)/2f*Math.cos(Math.toRadians(rotation));
- } else if(down.type != RoomConnectionType.ROOM_DIVIDER && right.type == RoomConnectionType.ROOM_DIVIDER) {
- x += -(roomSize+connectorSize)/2f*Math.cos(Math.toRadians(rotation));
- y += (roomSize+connectorSize)/2f*Math.sin(Math.toRadians(rotation));
- }
- }
- GlStateManager.translate(x, y, 0);
- if(!NotEnoughUpdates.INSTANCE.config.dungeonMap.dmOrientCheck) {
- GlStateManager.rotate(-rotation+180, 0, 0, 1);
- }
-
- GlStateManager.pushMatrix();
- GlStateManager.scale(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmIconScale,
- NotEnoughUpdates.INSTANCE.config.dungeonMap.dmIconScale, 1);
- Utils.drawTexturedRect(-5, -5, 10, 10, GL11.GL_NEAREST);
- GlStateManager.popMatrix();
-
- if(!NotEnoughUpdates.INSTANCE.config.dungeonMap.dmOrientCheck) {
- GlStateManager.rotate(rotation-180, 0, 0, 1);
- }
- GlStateManager.translate(-x, -y, 0);
- }
- }
- }
-
- public void render(int roomSize, int connectorSize) {
- ResourceLocation roomTex = null;
- if(colour.getRed() == 114 && colour.getGreen() == 67 && colour.getBlue() == 27) {
- roomTex = ROOM_BROWN;
- } else if(colour.getRed() == 65 && colour.getGreen() == 65 && colour.getBlue() == 65) {
- roomTex = ROOM_GRAY;
- } else if(colour.getRed() == 0 && colour.getGreen() == 124 && colour.getBlue() == 0) {
- roomTex = ROOM_GREEN;
- } else if(colour.getRed() == 242 && colour.getGreen() == 127 && colour.getBlue() == 165) {
- roomTex = ROOM_PINK;
- } else if(colour.getRed() == 178 && colour.getGreen() == 76 && colour.getBlue() == 216) {
- roomTex = ROOM_PURPLE;
- } else if(colour.getRed() == 255 && colour.getGreen() == 0 && colour.getBlue() == 0) {
- roomTex = ROOM_RED;
- } else if(colour.getRed() == 229 && colour.getGreen() == 229 && colour.getBlue() == 51) {
- roomTex = ROOM_YELLOW;
- } else if(colour.getRed() == 216 && colour.getGreen() == 127 && colour.getBlue() == 51) {
- roomTex = ROOM_ORANGE;
- }
-
- if(roomTex != null) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(roomTex);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(0, 0, roomSize, roomSize, GL11.GL_LINEAR);
- } else {
- Gui.drawRect(0, 0, roomSize, roomSize, colour.getRGB());
- }
-
- if(fillCorner) {
- GlStateManager.color(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(CORNER_BROWN);
- Utils.drawTexturedRect(roomSize, roomSize, connectorSize, connectorSize, GL11.GL_NEAREST);
- }
-
- for(int k=0; k<2; k++) {
- RoomConnection connection = down;
- if(k == 1) connection = right;
-
- if(connection.type == RoomConnectionType.NONE || connection.type == RoomConnectionType.WALL) continue;
-
- ResourceLocation corridorTex = null;
- if(connection.colour.getRed() == 114 && connection.colour.getGreen() == 67 && connection.colour.getBlue() == 27) {
- corridorTex = connection.type == RoomConnectionType.CORRIDOR ? CORRIDOR_BROWN : DIVIDER_BROWN;
- } else if(connection.colour.getRed() == 65 && connection.colour.getGreen() == 65 && connection.colour.getBlue() == 65) {
- corridorTex = CORRIDOR_GRAY;
- } else if(connection.colour.getRed() == 0 && connection.colour.getGreen() == 124 && connection.colour.getBlue() == 0) {
- corridorTex = CORRIDOR_GREEN;
- } else if(connection.colour.getRed() == 242 && connection.colour.getGreen() == 127 && connection.colour.getBlue() == 165) {
- corridorTex = CORRIDOR_PINK;
- } else if(connection.colour.getRed() == 178 && connection.colour.getGreen() == 76 && connection.colour.getBlue() == 216) {
- corridorTex = CORRIDOR_PURPLE;
- } else if(connection.colour.getRed() == 255 && connection.colour.getGreen() == 0 && connection.colour.getBlue() == 0) {
- corridorTex = CORRIDOR_RED;
- } else if(connection.colour.getRed() == 229 && connection.colour.getGreen() == 229 && connection.colour.getBlue() == 51) {
- corridorTex = CORRIDOR_YELLOW;
- } else if(connection.colour.getRed() == 216 && connection.colour.getGreen() == 127 && connection.colour.getBlue() == 51) {
- corridorTex = CORRIDOR_ORANGE;
- }
-
- if(corridorTex == null) {
- int xOffset = 0;
- int yOffset = 0;
- int width = 0;
- int height = 0;
-
- if(connection == right) {
- xOffset = roomSize;
- width = connectorSize;
- height = roomSize;
-
- if(connection.type == RoomConnectionType.CORRIDOR) {
- height = 8;
- yOffset += 4;
- }
- } else if(connection == down) {
- yOffset = roomSize;
- width = roomSize;
- height = connectorSize;
-
- if(connection.type == RoomConnectionType.CORRIDOR) {
- width = 8;
- xOffset += 4;
- }
- }
-
- Gui.drawRect(xOffset, yOffset, xOffset+width, yOffset+height, connection.colour.getRGB());
- } else {
- GlStateManager.color(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(corridorTex);
- GlStateManager.pushMatrix();
- if(connection==right) {
- GlStateManager.translate(roomSize/2f, roomSize/2f, 0);
- GlStateManager.rotate(-90, 0, 0, 1);
- GlStateManager.translate(-roomSize/2f, -roomSize/2f, 0);
- }
- Utils.drawTexturedRect(0, roomSize, roomSize, connectorSize, GL11.GL_NEAREST);
- GlStateManager.popMatrix();
- }
- }
- }
- }
-
- private static final ResourceLocation mapIcons = new ResourceLocation("textures/map/map_icons.png");
-
- public static Framebuffer mapFramebuffer1 = null;
- public static Framebuffer mapFramebuffer2 = null;
- public static Matrix4f projectionMatrix = null;
- public static Shader mapShader = null;
-
- private static Framebuffer checkFramebufferSizes(Framebuffer framebuffer, int width, int height) {
- if(framebuffer == null || framebuffer.framebufferWidth != width || framebuffer.framebufferHeight != height) {
- if(framebuffer == null) {
- framebuffer = new Framebuffer(width, height, true);
- } else {
- framebuffer.createBindFramebuffer(width, height);
- }
- framebuffer.setFramebufferFilter(GL11.GL_NEAREST);
- }
- return framebuffer;
- }
-
- private static void upload(Shader shader, int width, int height, int scale, float radiusSq) {
- if(shader == null) return;
- shader.getShaderManager().getShaderUniformOrDefault("ProjMat").set(projectionMatrix);
- shader.getShaderManager().getShaderUniformOrDefault("InSize").set(width*scale, height*scale);
- shader.getShaderManager().getShaderUniformOrDefault("OutSize").set(width, height);
- shader.getShaderManager().getShaderUniformOrDefault("ScreenSize").set((float)width, (float)height);
- shader.getShaderManager().getShaderUniformOrDefault("radiusSq").set(radiusSq);
- }
-
- public int getRenderRoomSize() {
- double roomSizeOption = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmRoomSize;
- if(roomSizeOption <= 0) return 12;
- return 12 + (int)Math.round(roomSizeOption*4);
- }
-
- public int getRenderConnSize() {
- int roomSizeOption = (int)Math.round(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmRoomSize);
- if(roomSizeOption <= 0) return 3;
- return 3 + roomSizeOption;
- }
-
- private HashMap<Integer, Float> borderRadiusCache = new HashMap<>();
- public float getBorderRadius() {
- int borderSizeOption = Math.round(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderSize);
- String sizeId = borderSizeOption == 0 ? "small" : borderSizeOption == 2 ? "large" : "medium";
-
- int style = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderStyle;
- if(borderRadiusCache.containsKey(style)) {
- return borderRadiusCache.get(style);
- }
-
- try(BufferedReader reader = new BufferedReader(new InputStreamReader(Minecraft.getMinecraft().getResourceManager().getResource(
- new ResourceLocation("notenoughupdates:dungeon_map/borders/"+sizeId+"/"+style+".json")).getInputStream(), StandardCharsets.UTF_8))) {
- JsonObject json = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(reader, JsonObject.class);
- float radiusSq = json.get("radiusSq").getAsFloat();
-
- borderRadiusCache.put(style, radiusSq);
- return radiusSq;
- } catch(Exception ignored) { }
-
- borderRadiusCache.put(style, 1f);
- return 1f;
- }
-
- public void render(int centerX, int centerY) {
- boolean useFb = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmCompat <= 1 && OpenGlHelper.isFramebufferEnabled();
- boolean useShd = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmCompat <= 0 && OpenGlHelper.areShadersSupported();
+ private static final ResourceLocation GREEN_CHECK = new ResourceLocation(
+ "notenoughupdates:dungeon_map/green_check.png");
+ private static final ResourceLocation WHITE_CHECK = new ResourceLocation(
+ "notenoughupdates:dungeon_map/white_check.png");
+ private static final ResourceLocation QUESTION = new ResourceLocation("notenoughupdates:dungeon_map/question.png");
+ private static final ResourceLocation CROSS = new ResourceLocation("notenoughupdates:dungeon_map/cross.png");
+
+ private static final ResourceLocation ROOM_RED = new ResourceLocation(
+ "notenoughupdates:dungeon_map/rooms_default/red_room.png");
+ private static final ResourceLocation ROOM_BROWN = new ResourceLocation(
+ "notenoughupdates:dungeon_map/rooms_default/brown_room.png");
+ private static final ResourceLocation ROOM_GRAY = new ResourceLocation(
+ "notenoughupdates:dungeon_map/rooms_default/gray_room.png");
+ private static final ResourceLocation ROOM_GREEN = new ResourceLocation(
+ "notenoughupdates:dungeon_map/rooms_default/green_room.png");
+ private static final ResourceLocation ROOM_PINK = new ResourceLocation(
+ "notenoughupdates:dungeon_map/rooms_default/pink_room.png");
+ private static final ResourceLocation ROOM_PURPLE = new ResourceLocation(
+ "notenoughupdates:dungeon_map/rooms_default/purple_room.png");
+ private static final ResourceLocation ROOM_YELLOW = new ResourceLocation(
+ "notenoughupdates:dungeon_map/rooms_default/yellow_room.png");
+ private static final ResourceLocation ROOM_ORANGE = new ResourceLocation(
+ "notenoughupdates:dungeon_map/rooms_default/orange_room.png");
+
+ private static final ResourceLocation CORRIDOR_RED = new ResourceLocation(
+ "notenoughupdates:dungeon_map/corridors_default/red_corridor.png");
+ private static final ResourceLocation CORRIDOR_BROWN = new ResourceLocation(
+ "notenoughupdates:dungeon_map/corridors_default/brown_corridor.png");
+ private static final ResourceLocation CORRIDOR_GRAY = new ResourceLocation(
+ "notenoughupdates:dungeon_map/corridors_default/gray_corridor.png");
+ private static final ResourceLocation CORRIDOR_GREEN = new ResourceLocation(
+ "notenoughupdates:dungeon_map/corridors_default/green_corridor.png");
+ private static final ResourceLocation CORRIDOR_PINK = new ResourceLocation(
+ "notenoughupdates:dungeon_map/corridors_default/pink_corridor.png");
+ private static final ResourceLocation CORRIDOR_PURPLE = new ResourceLocation(
+ "notenoughupdates:dungeon_map/corridors_default/purple_corridor.png");
+ private static final ResourceLocation CORRIDOR_YELLOW = new ResourceLocation(
+ "notenoughupdates:dungeon_map/corridors_default/yellow_corridor.png");
+ private static final ResourceLocation CORRIDOR_ORANGE = new ResourceLocation(
+ "notenoughupdates:dungeon_map/corridors_default/orange_corridor.png");
+
+ private static final ResourceLocation DIVIDER_BROWN = new ResourceLocation(
+ "notenoughupdates:dungeon_map/dividers_default/brown_divider.png");
+
+ private static final ResourceLocation CORNER_BROWN = new ResourceLocation(
+ "notenoughupdates:dungeon_map/corners_default/brown_corner.png");
+
+ private final HashMap<RoomOffset, Room> roomMap = new HashMap<>();
+ private Color[][] colourMap = new Color[128][128];
+ private int startRoomX = -1;
+ private int startRoomY = -1;
+ private int connectorSize = 5;
+ private int roomSize = 0;
+
+ //private final List<MapDecoration> decorations = new ArrayList<>();
+ //private final List<MapDecoration> lastDecorations = new ArrayList<>();
+ private long lastDecorationsMillis = -1;
+ private long lastLastDecorationsMillis = -1;
+
+ private final Map<String, MapPosition> playerEntityMapPositions = new HashMap<>();
+ private final Map<String, MapPosition> playerMarkerMapPositions = new HashMap<>();
+ private final Set<MapPosition> rawPlayerMarkerMapPositions = new HashSet<>();
+ private final Map<String, MapPosition> playerMarkerMapPositionsLast = new HashMap<>();
+ private final HashMap<String, Integer> playerIdMap = new HashMap<>();
+
+ private final Map<String, ResourceLocation> playerSkinMap = new HashMap<>();
+
+ private static class RoomOffset {
+ int x;
+ int y;
+
+ public RoomOffset(int x, int y) {
+ this.x = x;
+ this.y = y;
+ }
+
+ public RoomOffset left() {
+ return new RoomOffset(x - 1, y);
+ }
+
+ public RoomOffset right() {
+ return new RoomOffset(x + 1, y);
+ }
+
+ public RoomOffset up() {
+ return new RoomOffset(x, y - 1);
+ }
+
+ public RoomOffset down() {
+ return new RoomOffset(x, y + 1);
+ }
+
+ public RoomOffset[] getNeighbors() {
+ return new RoomOffset[]{left(), right(), up(), down()};
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ RoomOffset that = (RoomOffset) o;
+ return x == that.x && y == that.y;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(x, y);
+ }
+ }
+
+ private enum RoomConnectionType {
+ NONE, WALL, CORRIDOR, ROOM_DIVIDER
+ }
+
+ private static class RoomConnection {
+ RoomConnectionType type;
+ Color colour;
+
+ public RoomConnection(RoomConnectionType type, Color colour) {
+ this.type = type;
+ this.colour = colour;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ RoomConnection that = (RoomConnection) o;
+ return type == that.type &&
+ Objects.equals(colour, that.colour);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(type, colour);
+ }
+ }
+
+ private class Room {
+ Color colour = new Color(0, 0, 0, 0);
+ int tickColour = 0;
+ boolean fillCorner = false;
+
+ RoomConnection left = new RoomConnection(RoomConnectionType.NONE, new Color(0, true));
+ RoomConnection up = new RoomConnection(RoomConnectionType.NONE, new Color(0, true));
+ RoomConnection right = new RoomConnection(RoomConnectionType.NONE, new Color(0, true));
+ RoomConnection down = new RoomConnection(RoomConnectionType.NONE, new Color(0, true));
+
+ public void renderNoRotate(int roomSize, int connectorSize, int rotation) {
+ if (tickColour != 0) {
+ Color tick = new Color(tickColour, true);
+ ResourceLocation indicatorTex = null;
+ if (tick.getRed() == 255 && tick.getGreen() == 255 && tick.getBlue() == 255) {
+ indicatorTex = WHITE_CHECK;
+ } else if (tick.getRed() == 0 && tick.getGreen() == 124 && tick.getBlue() == 0) {
+ indicatorTex = GREEN_CHECK;
+ } else if (tick.getRed() == 13 && tick.getGreen() == 13 && tick.getBlue() == 13) {
+ indicatorTex = QUESTION;
+ } else if (tick.getRed() == 255 && tick.getGreen() == 0 && tick.getBlue() == 0) {
+ indicatorTex = CROSS;
+ }
+ if (indicatorTex != null) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(indicatorTex);
+ float x = 0;
+ float y = 0;
+
+ if (NotEnoughUpdates.INSTANCE.config.dungeonMap.dmCenterCheck) {
+ if (fillCorner) {
+ x += -(roomSize + connectorSize) / 2f * Math.cos(Math.toRadians(rotation - 45)) * 1.414f;
+ y += (roomSize + connectorSize) / 2f * Math.sin(Math.toRadians(rotation - 45)) * 1.414;
+ }
+ if (down.type == RoomConnectionType.ROOM_DIVIDER && right.type != RoomConnectionType.ROOM_DIVIDER) {
+ x += -(roomSize + connectorSize) / 2f * Math.sin(Math.toRadians(rotation));
+ y += -(roomSize + connectorSize) / 2f * Math.cos(Math.toRadians(rotation));
+ } else if (down.type != RoomConnectionType.ROOM_DIVIDER && right.type == RoomConnectionType.ROOM_DIVIDER) {
+ x += -(roomSize + connectorSize) / 2f * Math.cos(Math.toRadians(rotation));
+ y += (roomSize + connectorSize) / 2f * Math.sin(Math.toRadians(rotation));
+ }
+ }
+ GlStateManager.translate(x, y, 0);
+ if (!NotEnoughUpdates.INSTANCE.config.dungeonMap.dmOrientCheck) {
+ GlStateManager.rotate(-rotation + 180, 0, 0, 1);
+ }
+
+ GlStateManager.pushMatrix();
+ GlStateManager.scale(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmIconScale,
+ NotEnoughUpdates.INSTANCE.config.dungeonMap.dmIconScale, 1
+ );
+ Utils.drawTexturedRect(-5, -5, 10, 10, GL11.GL_NEAREST);
+ GlStateManager.popMatrix();
+
+ if (!NotEnoughUpdates.INSTANCE.config.dungeonMap.dmOrientCheck) {
+ GlStateManager.rotate(rotation - 180, 0, 0, 1);
+ }
+ GlStateManager.translate(-x, -y, 0);
+ }
+ }
+ }
+
+ public void render(int roomSize, int connectorSize) {
+ ResourceLocation roomTex = null;
+ if (colour.getRed() == 114 && colour.getGreen() == 67 && colour.getBlue() == 27) {
+ roomTex = ROOM_BROWN;
+ } else if (colour.getRed() == 65 && colour.getGreen() == 65 && colour.getBlue() == 65) {
+ roomTex = ROOM_GRAY;
+ } else if (colour.getRed() == 0 && colour.getGreen() == 124 && colour.getBlue() == 0) {
+ roomTex = ROOM_GREEN;
+ } else if (colour.getRed() == 242 && colour.getGreen() == 127 && colour.getBlue() == 165) {
+ roomTex = ROOM_PINK;
+ } else if (colour.getRed() == 178 && colour.getGreen() == 76 && colour.getBlue() == 216) {
+ roomTex = ROOM_PURPLE;
+ } else if (colour.getRed() == 255 && colour.getGreen() == 0 && colour.getBlue() == 0) {
+ roomTex = ROOM_RED;
+ } else if (colour.getRed() == 229 && colour.getGreen() == 229 && colour.getBlue() == 51) {
+ roomTex = ROOM_YELLOW;
+ } else if (colour.getRed() == 216 && colour.getGreen() == 127 && colour.getBlue() == 51) {
+ roomTex = ROOM_ORANGE;
+ }
+
+ if (roomTex != null) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(roomTex);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(0, 0, roomSize, roomSize, GL11.GL_LINEAR);
+ } else {
+ Gui.drawRect(0, 0, roomSize, roomSize, colour.getRGB());
+ }
+
+ if (fillCorner) {
+ GlStateManager.color(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(CORNER_BROWN);
+ Utils.drawTexturedRect(roomSize, roomSize, connectorSize, connectorSize, GL11.GL_NEAREST);
+ }
+
+ for (int k = 0; k < 2; k++) {
+ RoomConnection connection = down;
+ if (k == 1) connection = right;
+
+ if (connection.type == RoomConnectionType.NONE || connection.type == RoomConnectionType.WALL) continue;
+
+ ResourceLocation corridorTex = null;
+ if (connection.colour.getRed() == 114 && connection.colour.getGreen() == 67 &&
+ connection.colour.getBlue() == 27) {
+ corridorTex = connection.type == RoomConnectionType.CORRIDOR ? CORRIDOR_BROWN : DIVIDER_BROWN;
+ } else if (connection.colour.getRed() == 65 && connection.colour.getGreen() == 65 &&
+ connection.colour.getBlue() == 65) {
+ corridorTex = CORRIDOR_GRAY;
+ } else if (connection.colour.getRed() == 0 && connection.colour.getGreen() == 124 &&
+ connection.colour.getBlue() == 0) {
+ corridorTex = CORRIDOR_GREEN;
+ } else if (connection.colour.getRed() == 242 && connection.colour.getGreen() == 127 &&
+ connection.colour.getBlue() == 165) {
+ corridorTex = CORRIDOR_PINK;
+ } else if (connection.colour.getRed() == 178 && connection.colour.getGreen() == 76 &&
+ connection.colour.getBlue() == 216) {
+ corridorTex = CORRIDOR_PURPLE;
+ } else if (connection.colour.getRed() == 255 && connection.colour.getGreen() == 0 &&
+ connection.colour.getBlue() == 0) {
+ corridorTex = CORRIDOR_RED;
+ } else if (connection.colour.getRed() == 229 && connection.colour.getGreen() == 229 &&
+ connection.colour.getBlue() == 51) {
+ corridorTex = CORRIDOR_YELLOW;
+ } else if (connection.colour.getRed() == 216 && connection.colour.getGreen() == 127 &&
+ connection.colour.getBlue() == 51) {
+ corridorTex = CORRIDOR_ORANGE;
+ }
+
+ if (corridorTex == null) {
+ int xOffset = 0;
+ int yOffset = 0;
+ int width = 0;
+ int height = 0;
+
+ if (connection == right) {
+ xOffset = roomSize;
+ width = connectorSize;
+ height = roomSize;
+
+ if (connection.type == RoomConnectionType.CORRIDOR) {
+ height = 8;
+ yOffset += 4;
+ }
+ } else if (connection == down) {
+ yOffset = roomSize;
+ width = roomSize;
+ height = connectorSize;
+
+ if (connection.type == RoomConnectionType.CORRIDOR) {
+ width = 8;
+ xOffset += 4;
+ }
+ }
+
+ Gui.drawRect(xOffset, yOffset, xOffset + width, yOffset + height, connection.colour.getRGB());
+ } else {
+ GlStateManager.color(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(corridorTex);
+ GlStateManager.pushMatrix();
+ if (connection == right) {
+ GlStateManager.translate(roomSize / 2f, roomSize / 2f, 0);
+ GlStateManager.rotate(-90, 0, 0, 1);
+ GlStateManager.translate(-roomSize / 2f, -roomSize / 2f, 0);
+ }
+ Utils.drawTexturedRect(0, roomSize, roomSize, connectorSize, GL11.GL_NEAREST);
+ GlStateManager.popMatrix();
+ }
+ }
+ }
+ }
+
+ private static final ResourceLocation mapIcons = new ResourceLocation("textures/map/map_icons.png");
+
+ public static Framebuffer mapFramebuffer1 = null;
+ public static Framebuffer mapFramebuffer2 = null;
+ public static Matrix4f projectionMatrix = null;
+ public static Shader mapShader = null;
+
+ private static Framebuffer checkFramebufferSizes(Framebuffer framebuffer, int width, int height) {
+ if (framebuffer == null || framebuffer.framebufferWidth != width || framebuffer.framebufferHeight != height) {
+ if (framebuffer == null) {
+ framebuffer = new Framebuffer(width, height, true);
+ } else {
+ framebuffer.createBindFramebuffer(width, height);
+ }
+ framebuffer.setFramebufferFilter(GL11.GL_NEAREST);
+ }
+ return framebuffer;
+ }
+
+ private static void upload(Shader shader, int width, int height, int scale, float radiusSq) {
+ if (shader == null) return;
+ shader.getShaderManager().getShaderUniformOrDefault("ProjMat").set(projectionMatrix);
+ shader.getShaderManager().getShaderUniformOrDefault("InSize").set(width * scale, height * scale);
+ shader.getShaderManager().getShaderUniformOrDefault("OutSize").set(width, height);
+ shader.getShaderManager().getShaderUniformOrDefault("ScreenSize").set((float) width, (float) height);
+ shader.getShaderManager().getShaderUniformOrDefault("radiusSq").set(radiusSq);
+ }
+
+ public int getRenderRoomSize() {
+ double roomSizeOption = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmRoomSize;
+ if (roomSizeOption <= 0) return 12;
+ return 12 + (int) Math.round(roomSizeOption * 4);
+ }
+
+ public int getRenderConnSize() {
+ int roomSizeOption = Math.round(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmRoomSize);
+ if (roomSizeOption <= 0) return 3;
+ return 3 + roomSizeOption;
+ }
+
+ private final HashMap<Integer, Float> borderRadiusCache = new HashMap<>();
+
+ public float getBorderRadius() {
+ int borderSizeOption = Math.round(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderSize);
+ String sizeId = borderSizeOption == 0 ? "small" : borderSizeOption == 2 ? "large" : "medium";
+
+ int style = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderStyle;
+ if (borderRadiusCache.containsKey(style)) {
+ return borderRadiusCache.get(style);
+ }
+
+ try (
+ BufferedReader reader = new BufferedReader(new InputStreamReader(Minecraft
+ .getMinecraft()
+ .getResourceManager()
+ .getResource(
+ new ResourceLocation("notenoughupdates:dungeon_map/borders/" + sizeId + "/" + style + ".json"))
+ .getInputStream(), StandardCharsets.UTF_8))
+ ) {
+ JsonObject json = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(reader, JsonObject.class);
+ float radiusSq = json.get("radiusSq").getAsFloat();
+
+ borderRadiusCache.put(style, radiusSq);
+ return radiusSq;
+ } catch (Exception ignored) {
+ }
+
+ borderRadiusCache.put(style, 1f);
+ return 1f;
+ }
+
+ public void render(int centerX, int centerY) {
+ boolean useFb = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmCompat <= 1 && OpenGlHelper.isFramebufferEnabled();
+ boolean useShd = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmCompat <= 0 && OpenGlHelper.areShadersSupported();
/*if((useFb && !OpenGlHelper.isFramebufferEnabled()) || (useShd && !OpenGlHelper.areShadersSupported())) {
Utils.drawStringCentered(EnumChatFormatting.RED+"NEU Dungeon Map requires framebuffers & shaders",
@@ -404,203 +444,221 @@ public class DungeonMap {
return;
}*/
- ScaledResolution scaledResolution = Utils.pushGuiScale(2);
-
- int minRoomX = 999;
- int minRoomY = 999;
- int maxRoomX = -999;
- int maxRoomY = -999;
- for(RoomOffset offset : roomMap.keySet()) {
- minRoomX = Math.min(offset.x, minRoomX);
- minRoomY = Math.min(offset.y, minRoomY);
- maxRoomX = Math.max(offset.x, maxRoomX);
- maxRoomY = Math.max(offset.y, maxRoomY);
- }
-
- int borderSizeOption = Math.round(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderSize);
-
- int renderRoomSize = getRenderRoomSize();
- int renderConnSize = getRenderConnSize();
-
- MapPosition playerPos = null;
- if(playerEntityMapPositions.containsKey(Minecraft.getMinecraft().thePlayer.getName())) {
- playerPos = playerEntityMapPositions.get(Minecraft.getMinecraft().thePlayer.getName());
- } else if(playerMarkerMapPositions.containsKey(Minecraft.getMinecraft().thePlayer.getName())) {
- playerPos = playerMarkerMapPositions.get(Minecraft.getMinecraft().thePlayer.getName());
- }
-
- int rotation = 180;
- if(playerPos != null && NotEnoughUpdates.INSTANCE.config.dungeonMap.dmRotatePlayer) {
- rotation = (int)playerPos.rotation;
- }
-
- int mapSizeX;
- int mapSizeY;
- if(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderStyle <= 1) {
- mapSizeX = 80 + Math.round(40*NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderSize);
- } else {
- mapSizeX = borderSizeOption == 0 ? 90 : borderSizeOption == 1 ? 120 : borderSizeOption == 2 ? 160 : 240;
- }
- mapSizeY = mapSizeX;
- int roomsSizeX = (maxRoomX-minRoomX)*(renderRoomSize+renderConnSize)+renderRoomSize;
- int roomsSizeY = (maxRoomY-minRoomY)*(renderRoomSize+renderConnSize)+renderRoomSize;
- int mapCenterX = mapSizeX/2;
- int mapCenterY = mapSizeY/2;
- int scaleFactor = 8;
-
- projectionMatrix = Utils.createProjectionMatrix(mapSizeX*scaleFactor, mapSizeY*scaleFactor);
- mapFramebuffer1 = checkFramebufferSizes(mapFramebuffer1, mapSizeX*scaleFactor, mapSizeY*scaleFactor);
- mapFramebuffer2 = checkFramebufferSizes(mapFramebuffer2, mapSizeX*scaleFactor, mapSizeY*scaleFactor);
- mapFramebuffer1.framebufferColor[1] = 0;
- mapFramebuffer1.framebufferColor[2] = 0;
-
- try {
- if(mapShader == null) {
- mapShader = new Shader(new NEUResourceManager(Minecraft.getMinecraft().getResourceManager()),
- "dungeonmap", mapFramebuffer1, mapFramebuffer2);
- }
- } catch(Exception e) {
- e.printStackTrace();
- Utils.pushGuiScale(-1);
- return;
- }
-
- int backgroundColour = SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBackgroundColour);
-
- mapFramebuffer1.framebufferColor[0] = ((backgroundColour >> 16) & 0xFF)/255f;
- mapFramebuffer1.framebufferColor[1] = ((backgroundColour >> 8) & 0xFF)/255f;
- mapFramebuffer1.framebufferColor[2] = (backgroundColour & 0xFF)/255f;
- mapFramebuffer2.framebufferColor[0] = ((backgroundColour >> 16) & 0xFF)/255f;
- mapFramebuffer2.framebufferColor[1] = ((backgroundColour >> 8) & 0xFF)/255f;
- mapFramebuffer2.framebufferColor[2] = (backgroundColour & 0xFF)/255f;
-
- try {
- if(useFb) {
- mapFramebuffer1.framebufferClear();
- mapFramebuffer2.framebufferClear();
- }
-
- GlStateManager.pushMatrix(); {
- if(useFb) {
- GlStateManager.matrixMode(5889);
- GlStateManager.loadIdentity();
- GlStateManager.ortho(0.0D, mapSizeX*scaleFactor, mapSizeY*scaleFactor, 0.0D, 1000.0D, 3000.0D);
- GlStateManager.matrixMode(5888);
- GlStateManager.loadIdentity();
- GlStateManager.translate(0.0F, 0.0F, -2000.0F);
-
- GlStateManager.scale(scaleFactor, scaleFactor, 1);
- mapFramebuffer1.bindFramebuffer(true);
-
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
- GlStateManager.disableBlend();
- } else {
- GL11.glEnable(GL11.GL_SCISSOR_TEST);
- GL11.glScissor((centerX-mapSizeX/2)*2, Minecraft.getMinecraft().displayHeight-(centerY+mapSizeY/2)*2, mapSizeX*2, mapSizeY*2);
-
- GlStateManager.translate(centerX-mapSizeX/2, centerY-mapSizeY/2, 100);
- }
-
- if(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBackgroundBlur > 0.1) {
- GlStateManager.translate(-centerX+mapSizeX/2, -centerY+mapSizeY/2, 0);
- BackgroundBlur.renderBlurredBackground(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBackgroundBlur,
- scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(),
- centerX-mapSizeX/2, centerY-mapSizeY/2, mapSizeX, mapSizeY);
- BackgroundBlur.markDirty();
- GlStateManager.translate(centerX-mapSizeX/2, centerY-mapSizeY/2, 0);
- }
-
- GlStateManager.translate(mapCenterX, mapCenterY, 10);
-
- if(!useFb || NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBackgroundBlur > 0.1) {
- GlStateManager.enableBlend();
- GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
- }
- Utils.drawRectNoBlend(-mapCenterX, -mapCenterY, mapCenterX, mapCenterY, backgroundColour);
-
- GlStateManager.rotate(-rotation+180, 0, 0, 1);
-
- if(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmCenterPlayer && playerPos != null) {
- float x = playerPos.getRenderX();
- float y = playerPos.getRenderY();
- x -= minRoomX*(renderRoomSize+renderConnSize);
- y -= minRoomY*(renderRoomSize+renderConnSize);
-
- GlStateManager.translate(-x, -y, 0);
- } else {
- GlStateManager.translate(-roomsSizeX/2, -roomsSizeY/2, 0);
- }
-
- for(Map.Entry<RoomOffset, Room> entry : roomMap.entrySet()) {
- RoomOffset roomOffset = entry.getKey();
- Room room = entry.getValue();
-
- int x = (roomOffset.x-minRoomX)*(renderRoomSize+renderConnSize);
- int y = (roomOffset.y-minRoomY)*(renderRoomSize+renderConnSize);
-
- GlStateManager.pushMatrix();
- GlStateManager.translate(x, y, 0);
-
- room.render(renderRoomSize, renderConnSize);
-
- GlStateManager.translate(-x, -y, 0);
- GlStateManager.popMatrix();
- }
-
- GlStateManager.translate(-mapCenterX+roomsSizeX/2f, -mapCenterY+roomsSizeY/2f, 0);
-
- GlStateManager.translate(mapCenterX, mapCenterY, 0);
- GlStateManager.rotate(rotation-180, 0, 0, 1);
- GlStateManager.translate(-mapCenterX, -mapCenterY, 0);
-
- GlStateManager.translate(mapCenterX, mapCenterY, 0);
-
- for(Map.Entry<RoomOffset, Room> entry : roomMap.entrySet()) {
- RoomOffset roomOffset = entry.getKey();
- Room room = entry.getValue();
-
- float x = (roomOffset.x-minRoomX)*(renderRoomSize+renderConnSize)-roomsSizeX/2f+renderRoomSize/2f;
- float y = (roomOffset.y-minRoomY)*(renderRoomSize+renderConnSize)-roomsSizeY/2f+renderRoomSize/2f;
- float x2 = (float)(-x*Math.cos(Math.toRadians(-rotation)) + y*Math.sin(Math.toRadians(-rotation)));
- float y2 = (float)(-x*Math.sin(Math.toRadians(-rotation)) - y*Math.cos(Math.toRadians(-rotation)));
-
- GlStateManager.pushMatrix();
- GlStateManager.translate(x2, y2, 0);
-
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
- room.renderNoRotate(renderRoomSize, renderConnSize, rotation);
-
- GlStateManager.translate(-x2, -y2, 0);
- GlStateManager.popMatrix();
- }
-
-
- GlStateManager.translate(-mapCenterX, -mapCenterY, 0);
-
- GlStateManager.translate(mapCenterX, mapCenterY, 0);
- GlStateManager.rotate(-rotation+180, 0, 0, 1);
- GlStateManager.translate(-mapCenterX, -mapCenterY, 0);
-
- GlStateManager.translate(mapCenterX-roomsSizeX/2f, mapCenterY-roomsSizeY/2f, 0);
-
- Tessellator tessellator = Tessellator.getInstance();
- WorldRenderer worldrenderer = tessellator.getWorldRenderer();
- int k = 0;
-
- for(Map.Entry<String, MapPosition> entry : playerMarkerMapPositions.entrySet()) {
- String name = entry.getKey();
- MapPosition pos = entry.getValue();
- float x = pos.getRenderX();
- float y = pos.getRenderY();
- float angle = pos.rotation;
-
- boolean doInterp = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmPlayerInterp;
- if(!isFloorOne && playerEntityMapPositions.containsKey(name)) {
- MapPosition entityPos = playerEntityMapPositions.get(name);
- angle = entityPos.rotation;
+ ScaledResolution scaledResolution = Utils.pushGuiScale(2);
+
+ int minRoomX = 999;
+ int minRoomY = 999;
+ int maxRoomX = -999;
+ int maxRoomY = -999;
+ for (RoomOffset offset : roomMap.keySet()) {
+ minRoomX = Math.min(offset.x, minRoomX);
+ minRoomY = Math.min(offset.y, minRoomY);
+ maxRoomX = Math.max(offset.x, maxRoomX);
+ maxRoomY = Math.max(offset.y, maxRoomY);
+ }
+
+ int borderSizeOption = Math.round(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderSize);
+
+ int renderRoomSize = getRenderRoomSize();
+ int renderConnSize = getRenderConnSize();
+
+ MapPosition playerPos = null;
+ if (playerEntityMapPositions.containsKey(Minecraft.getMinecraft().thePlayer.getName())) {
+ playerPos = playerEntityMapPositions.get(Minecraft.getMinecraft().thePlayer.getName());
+ } else if (playerMarkerMapPositions.containsKey(Minecraft.getMinecraft().thePlayer.getName())) {
+ playerPos = playerMarkerMapPositions.get(Minecraft.getMinecraft().thePlayer.getName());
+ }
+
+ int rotation = 180;
+ if (playerPos != null && NotEnoughUpdates.INSTANCE.config.dungeonMap.dmRotatePlayer) {
+ rotation = (int) playerPos.rotation;
+ }
+
+ int mapSizeX;
+ int mapSizeY;
+ if (NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderStyle <= 1) {
+ mapSizeX = 80 + Math.round(40 * NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderSize);
+ } else {
+ mapSizeX = borderSizeOption == 0 ? 90 : borderSizeOption == 1 ? 120 : borderSizeOption == 2 ? 160 : 240;
+ }
+ mapSizeY = mapSizeX;
+ int roomsSizeX = (maxRoomX - minRoomX) * (renderRoomSize + renderConnSize) + renderRoomSize;
+ int roomsSizeY = (maxRoomY - minRoomY) * (renderRoomSize + renderConnSize) + renderRoomSize;
+ int mapCenterX = mapSizeX / 2;
+ int mapCenterY = mapSizeY / 2;
+ int scaleFactor = 8;
+
+ projectionMatrix = Utils.createProjectionMatrix(mapSizeX * scaleFactor, mapSizeY * scaleFactor);
+ mapFramebuffer1 = checkFramebufferSizes(mapFramebuffer1, mapSizeX * scaleFactor, mapSizeY * scaleFactor);
+ mapFramebuffer2 = checkFramebufferSizes(mapFramebuffer2, mapSizeX * scaleFactor, mapSizeY * scaleFactor);
+ mapFramebuffer1.framebufferColor[1] = 0;
+ mapFramebuffer1.framebufferColor[2] = 0;
+
+ try {
+ if (mapShader == null) {
+ mapShader = new Shader(new NEUResourceManager(Minecraft.getMinecraft().getResourceManager()),
+ "dungeonmap", mapFramebuffer1, mapFramebuffer2
+ );
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ Utils.pushGuiScale(-1);
+ return;
+ }
+
+ int backgroundColour =
+ SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBackgroundColour);
+
+ mapFramebuffer1.framebufferColor[0] = ((backgroundColour >> 16) & 0xFF) / 255f;
+ mapFramebuffer1.framebufferColor[1] = ((backgroundColour >> 8) & 0xFF) / 255f;
+ mapFramebuffer1.framebufferColor[2] = (backgroundColour & 0xFF) / 255f;
+ mapFramebuffer2.framebufferColor[0] = ((backgroundColour >> 16) & 0xFF) / 255f;
+ mapFramebuffer2.framebufferColor[1] = ((backgroundColour >> 8) & 0xFF) / 255f;
+ mapFramebuffer2.framebufferColor[2] = (backgroundColour & 0xFF) / 255f;
+
+ try {
+ if (useFb) {
+ mapFramebuffer1.framebufferClear();
+ mapFramebuffer2.framebufferClear();
+ }
+
+ GlStateManager.pushMatrix();
+ {
+ if (useFb) {
+ GlStateManager.matrixMode(5889);
+ GlStateManager.loadIdentity();
+ GlStateManager.ortho(0.0D, mapSizeX * scaleFactor, mapSizeY * scaleFactor, 0.0D, 1000.0D, 3000.0D);
+ GlStateManager.matrixMode(5888);
+ GlStateManager.loadIdentity();
+ GlStateManager.translate(0.0F, 0.0F, -2000.0F);
+
+ GlStateManager.scale(scaleFactor, scaleFactor, 1);
+ mapFramebuffer1.bindFramebuffer(true);
+
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ GlStateManager.disableBlend();
+ } else {
+ GL11.glEnable(GL11.GL_SCISSOR_TEST);
+ GL11.glScissor(
+ (centerX - mapSizeX / 2) * 2,
+ Minecraft.getMinecraft().displayHeight - (centerY + mapSizeY / 2) * 2,
+ mapSizeX * 2,
+ mapSizeY * 2
+ );
+
+ GlStateManager.translate(centerX - mapSizeX / 2, centerY - mapSizeY / 2, 100);
+ }
+
+ if (NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBackgroundBlur > 0.1 &&
+ NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBackgroundBlur < 100 &&
+ NotEnoughUpdates.INSTANCE.config.dungeonMap.dmEnable) {
+ GlStateManager.translate(-centerX + mapSizeX / 2, -centerY + mapSizeY / 2, 0);
+ BackgroundBlur.renderBlurredBackground(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBackgroundBlur,
+ scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(),
+ centerX - mapSizeX / 2, centerY - mapSizeY / 2, mapSizeX, mapSizeY
+ );
+ BackgroundBlur.markDirty();
+ GlStateManager.translate(centerX - mapSizeX / 2, centerY - mapSizeY / 2, 0);
+ }
+
+ GlStateManager.translate(mapCenterX, mapCenterY, 10);
+
+ if (!useFb || NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBackgroundBlur > 0.1 &&
+ NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBackgroundBlur < 100) {
+ GlStateManager.enableBlend();
+ GL14.glBlendFuncSeparate(
+ GL11.GL_SRC_ALPHA,
+ GL11.GL_ONE_MINUS_SRC_ALPHA,
+ GL11.GL_ONE,
+ GL11.GL_ONE_MINUS_SRC_ALPHA
+ );
+ }
+ Utils.drawRectNoBlend(-mapCenterX, -mapCenterY, mapCenterX, mapCenterY, backgroundColour);
+
+ GlStateManager.rotate(-rotation + 180, 0, 0, 1);
+
+ if (NotEnoughUpdates.INSTANCE.config.dungeonMap.dmCenterPlayer && playerPos != null) {
+ float x = playerPos.getRenderX();
+ float y = playerPos.getRenderY();
+ x -= minRoomX * (renderRoomSize + renderConnSize);
+ y -= minRoomY * (renderRoomSize + renderConnSize);
+
+ GlStateManager.translate(-x, -y, 0);
+ } else {
+ GlStateManager.translate(-roomsSizeX / 2, -roomsSizeY / 2, 0);
+ }
+
+ for (Map.Entry<RoomOffset, Room> entry : roomMap.entrySet()) {
+ RoomOffset roomOffset = entry.getKey();
+ Room room = entry.getValue();
+
+ int x = (roomOffset.x - minRoomX) * (renderRoomSize + renderConnSize);
+ int y = (roomOffset.y - minRoomY) * (renderRoomSize + renderConnSize);
+
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(x, y, 0);
+
+ room.render(renderRoomSize, renderConnSize);
+
+ GlStateManager.translate(-x, -y, 0);
+ GlStateManager.popMatrix();
+ }
+
+ GlStateManager.translate(-mapCenterX + roomsSizeX / 2f, -mapCenterY + roomsSizeY / 2f, 0);
+
+ GlStateManager.translate(mapCenterX, mapCenterY, 0);
+ GlStateManager.rotate(rotation - 180, 0, 0, 1);
+ GlStateManager.translate(-mapCenterX, -mapCenterY, 0);
+
+ GlStateManager.translate(mapCenterX, mapCenterY, 0);
+
+ for (Map.Entry<RoomOffset, Room> entry : roomMap.entrySet()) {
+ RoomOffset roomOffset = entry.getKey();
+ Room room = entry.getValue();
+
+ float x =
+ (roomOffset.x - minRoomX) * (renderRoomSize + renderConnSize) - roomsSizeX / 2f + renderRoomSize / 2f;
+ float y =
+ (roomOffset.y - minRoomY) * (renderRoomSize + renderConnSize) - roomsSizeY / 2f + renderRoomSize / 2f;
+ float x2 = (float) (-x * Math.cos(Math.toRadians(-rotation)) + y * Math.sin(Math.toRadians(-rotation)));
+ float y2 = (float) (-x * Math.sin(Math.toRadians(-rotation)) - y * Math.cos(Math.toRadians(-rotation)));
+
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(x2, y2, 0);
+
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ room.renderNoRotate(renderRoomSize, renderConnSize, rotation);
+
+ GlStateManager.translate(-x2, -y2, 0);
+ GlStateManager.popMatrix();
+ }
+
+ GlStateManager.translate(-mapCenterX, -mapCenterY, 0);
+
+ GlStateManager.translate(mapCenterX, mapCenterY, 0);
+ GlStateManager.rotate(-rotation + 180, 0, 0, 1);
+ GlStateManager.translate(-mapCenterX, -mapCenterY, 0);
+
+ GlStateManager.translate(mapCenterX - roomsSizeX / 2f, mapCenterY - roomsSizeY / 2f, 0);
+
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+ int k = 0;
+
+ for (Map.Entry<String, MapPosition> entry : playerMarkerMapPositions.entrySet()) {
+ String name = entry.getKey();
+ MapPosition pos = entry.getValue();
+ float x = pos.getRenderX();
+ float y = pos.getRenderY();
+ float angle = pos.rotation;
+
+ boolean doInterp = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmPlayerInterp;
+ if (!isFloorOne && playerEntityMapPositions.containsKey(name)) {
+ MapPosition entityPos = playerEntityMapPositions.get(name);
+ angle = entityPos.rotation;
- float deltaX = entityPos.getRenderX() - pos.getRenderX();
- float deltaY = entityPos.getRenderY() - pos.getRenderY();
+ float deltaX = entityPos.getRenderX() - pos.getRenderX();
+ float deltaY = entityPos.getRenderY() - pos.getRenderY();
/*if(deltaX > (renderRoomSize + renderConnSize)/2) {
deltaX -= (renderRoomSize + renderConnSize);
@@ -613,843 +671,901 @@ public class DungeonMap {
deltaY += (renderRoomSize + renderConnSize);
}*/
- x += deltaX;
- y += deltaY;
-
- doInterp = false;
- }
-
- float minU = 3/4f;
- float minV = 0;
-
- if(name.equals(Minecraft.getMinecraft().thePlayer.getName())) {
- minU = 1/4f;
- }
-
- float maxU = minU + 1/4f;
- float maxV = minV + 1/4f;
-
- if(doInterp && playerMarkerMapPositionsLast.containsKey(name)) {
- MapPosition last = playerMarkerMapPositionsLast.get(name);
- float xLast = last.getRenderX();
- float yLast = last.getRenderY();
-
- float distSq = (x-xLast) * (x-xLast) + (y-yLast) * (y-yLast);
- if (distSq < renderRoomSize*renderRoomSize/4f) {
- float angleLast = last.rotation;
- if (angle > 180 && angleLast < 180) angleLast += 360;
- if (angleLast > 180 && angle < 180) angle += 360;
-
- float interpFactor = Math.round((System.currentTimeMillis() - lastDecorationsMillis) * 100f) / 100f / (lastDecorationsMillis - lastLastDecorationsMillis);
- interpFactor = Math.max(0, Math.min(1, interpFactor));
-
- x = xLast + (x - xLast) * interpFactor;
- y = yLast + (y - yLast) * interpFactor;
- angle = angleLast + (angle - angleLast) * interpFactor;
- angle %= 360;
- }
- }
-
- boolean blackBorder = false;
- boolean headLayer = false;
- int pixelWidth = 8;
- int pixelHeight = 8;
- if(renderRoomSize >= 24) {
- pixelWidth = pixelHeight = 12;
- }
- GlStateManager.color(1, 1, 1, 1);
- if((!NotEnoughUpdates.INSTANCE.config.dungeons.showOwnHeadAsMarker ||
- playerMarkerMapPositions.size() <= 1 || minU != 1/4f) &&
- NotEnoughUpdates.INSTANCE.config.dungeonMap.dmPlayerHeads >= 1 &&
- playerSkinMap.containsKey(entry.getKey())) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(playerSkinMap.get(entry.getKey()));
-
- minU = 8/64f;
- minV = 8/64f;
- maxU = 16/64f;
- maxV = 16/64f;
-
- headLayer = true;
- if(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmPlayerHeads >= 2) {
- blackBorder = true;
- }
- } else {
- Minecraft.getMinecraft().getTextureManager().bindTexture(mapIcons);
- }
-
- x -= minRoomX*(renderRoomSize+renderConnSize);
- y -= minRoomY*(renderRoomSize+renderConnSize);
-
- GlStateManager.pushMatrix();
-
- GlStateManager.disableDepth();
- GlStateManager.enableBlend();
- GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
-
- GlStateManager.translate(x, y, -0.02F);
- GlStateManager.scale(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmIconScale,
- NotEnoughUpdates.INSTANCE.config.dungeonMap.dmIconScale, 1);
- GlStateManager.rotate(angle, 0.0F, 0.0F, 1.0F);
- GlStateManager.translate(-0.5F, 0.5F, 0.0F);
-
- if(blackBorder) {
- Gui.drawRect(-pixelWidth/2-1,-pixelHeight/2-1, pixelWidth/2+1, pixelHeight/2+1, 0xff111111);
- GlStateManager.color(1, 1, 1, 1);
- }
-
- worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
- worldrenderer.pos(-pixelWidth/2f, pixelHeight/2f, 30+((float)k * -0.005F)).tex(minU, minV).endVertex();
- worldrenderer.pos(pixelWidth/2f, pixelHeight/2f, 30+((float)k * -0.005F)).tex(maxU, minV).endVertex();
- worldrenderer.pos(pixelWidth/2f, -pixelHeight/2f, 30+((float)k * -0.005F)).tex(maxU, maxV).endVertex();
- worldrenderer.pos(-pixelWidth/2f, -pixelHeight/2f, 30+((float)k * -0.005F)).tex(minU, maxV).endVertex();
- tessellator.draw();
-
- if(headLayer) {
- worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
- worldrenderer.pos(-pixelWidth/2f, pixelHeight/2f, 30+((float)k * -0.005F)+0.001f).tex(minU+0.5f, minV).endVertex();
- worldrenderer.pos(pixelWidth/2f, pixelHeight/2f, 30+((float)k * -0.005F)+0.001f).tex(maxU+0.5f, minV).endVertex();
- worldrenderer.pos(pixelWidth/2f, -pixelHeight/2f, 30+((float)k * -0.005F)+0.001f).tex(maxU+0.5f, maxV).endVertex();
- worldrenderer.pos(-pixelWidth/2f, -pixelHeight/2f, 30+((float)k * -0.005F)+0.001f).tex(minU+0.5f, maxV).endVertex();
- tessellator.draw();
- }
- GlStateManager.popMatrix();
- k--;
- }
-
- if(useFb) {
- GlStateManager.enableBlend();
- GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
- } else {
- GL11.glDisable(GL11.GL_SCISSOR_TEST);
- }
- } GlStateManager.popMatrix();
-
- if(useFb) {
- Framebuffer renderFromBuffer = mapFramebuffer1;
- if(useShd) {
- GlStateManager.pushMatrix(); {
- try {
- upload(mapShader, mapSizeX, mapSizeY, scaleFactor, getBorderRadius());
- mapShader.setProjectionMatrix(projectionMatrix);
- mapShader.loadShader(0);
- renderFromBuffer = mapFramebuffer2;
- } catch(Exception e) {
- }
- } GlStateManager.popMatrix();
- }
-
- Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true);
-
- Utils.pushGuiScale(2);
-
- GlStateManager.translate(centerX, centerY, 100);
-
- renderFromBuffer.bindFramebufferTexture();
- Utils.drawTexturedRect(-mapSizeX/2, -mapSizeY/2, mapSizeX, mapSizeY,
- 0, 1, 1, 0, GL11.GL_NEAREST);
- GlStateManager.bindTexture(0);
-
- GlStateManager.translate(-centerX, -centerY, -100);
-
- Utils.pushGuiScale(-1);
- }
-
- GlStateManager.translate(centerX, centerY, 100);
-
- if(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmChromaBorder) {
- int colour = SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderColour);
-
- Gui.drawRect(-mapCenterX-2, -mapCenterY-2, -mapCenterX, -mapCenterY,
- colour); //topleft
- Gui.drawRect(-mapCenterX-2, mapCenterY+2, -mapCenterX, mapCenterY,
- SpecialColour.rotateHue(colour, -180)); //bottomleft
- Gui.drawRect(mapCenterX, -mapCenterY-2, mapCenterX+2, mapCenterY,
- SpecialColour.rotateHue(colour, -180)); //topright
- Gui.drawRect(mapCenterX, mapCenterY, mapCenterX+2, mapCenterY+2,
- colour); //bottomright
-
- for(int i=0; i<20; i++) {
- int start1 = SpecialColour.rotateHue(colour, -9*i);
- int start2 = SpecialColour.rotateHue(colour, -9*i-9);
- int end1 = SpecialColour.rotateHue(colour, -180-9*i);
- int end2 = SpecialColour.rotateHue(colour, -180-9*i-9);
-
- Utils.drawGradientRect(-mapCenterX-2, -mapCenterY+(int)(mapSizeY*(i/20f)), -mapCenterX,
- -mapCenterY+(int)(mapSizeY*((i+1)/20f)), start1, start2); //left
- Utils.drawGradientRect(mapCenterX, -mapCenterY+(int)(mapSizeX*(i/20f)), mapCenterX+2,
- -mapCenterY+(int)(mapSizeX*((i+1)/20f)),
- end1, end2); //right
- Utils.drawGradientRectHorz(-mapCenterX+(int)(mapSizeX*(i/20f)), -mapCenterY-2,
- -mapCenterX+(int)(mapSizeX*((i+1)/20f)), -mapCenterY, start1, start2); //top
- Utils.drawGradientRectHorz(-mapCenterX+(int)(mapSizeX*(i/20f)),
- mapCenterY, -mapCenterX+(int)(mapSizeX*((i+1)/20f)), mapCenterY+2,
- end1, end2); //bottom
- }
-
- } else {
- Gui.drawRect(-mapCenterX-2, -mapCenterY, -mapCenterX, mapCenterY,
- SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderColour)); //left
- Gui.drawRect(mapCenterX, -mapCenterY, mapCenterX+2, mapCenterY,
- SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderColour)); //right
- Gui.drawRect(-mapCenterX-2, -mapCenterY-2, mapCenterX+2, -mapCenterY,
- SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderColour)); //top
- Gui.drawRect(-mapCenterX-2, mapCenterY, mapCenterX+2, mapCenterY+2,
- SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderColour)); //bottom
- }
-
- String sizeId = borderSizeOption == 0 ? "small" : borderSizeOption == 2 ? "large" : "medium";
-
- ResourceLocation rl = new ResourceLocation("notenoughupdates:dungeon_map/borders/"+sizeId+"/"+
- NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderStyle+".png");
- if(Minecraft.getMinecraft().getTextureManager().getTexture(rl) != TextureUtil.missingTexture) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(rl);
- GlStateManager.color(1, 1, 1, 1);
-
- int size = borderSizeOption == 0 ? 165 : borderSizeOption == 1 ? 220 : borderSizeOption == 2 ? 300 : 440;
- Utils.drawTexturedRect(-size/2, -size/2, size, size, GL11.GL_NEAREST);
- }
-
- GlStateManager.translate(-centerX, -centerY, -100);
- } catch(Exception e) {
- e.printStackTrace();
- Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true);
- Minecraft.getMinecraft().entityRenderer.setupOverlayRendering();
- }
-
- Utils.pushGuiScale(-1);
-
- GlStateManager.enableBlend();
- GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
- GlStateManager.enableDepth();
- GlStateManager.disableLighting();
- }
-
-
- public void updateRoomConnections(RoomOffset roomOffset) {
- if(roomMap.containsKey(roomOffset)) {
- Room room = roomMap.get(roomOffset);
-
- int otherPixelFilled = 0;
- int otherPixelColour = 0;
- for(int xOff=0; xOff<roomSize; xOff++) {
- for(int yOff=0; yOff<roomSize; yOff++) {
- int x = startRoomX + roomOffset.x*(roomSize+connectorSize) + xOff;
- int y = startRoomY + roomOffset.y*(roomSize+connectorSize) + yOff;
-
- if(x > 0 && y > 0 && x < colourMap.length && y < colourMap[x].length) {
- Color c = colourMap[x][y];
- if(!c.equals(room.colour)) {
- if(otherPixelColour == c.getRGB()) {
- otherPixelFilled++;
- } else {
- otherPixelFilled--;
- if(otherPixelFilled <= 0) {
- otherPixelFilled = 1;
- otherPixelColour = c.getRGB();
- }
- }
- }
- }
- }
- }
-
- room.tickColour = 0;
- if((float)otherPixelFilled/roomSize/connectorSize > 0.05) {
- room.tickColour = otherPixelColour;
- }
-
- for(int k=0; k<4; k++) {
- Color colour = null;
- int totalFilled = 0;
-
- for(int i=0; i<roomSize; i++) {
- for(int j=1; j<=connectorSize; j++) {
- int x = startRoomX + roomOffset.x*(roomSize+connectorSize);
- int y = startRoomY + roomOffset.y*(roomSize+connectorSize);
-
- if(k == 0) {
- x += i;
- y -= j;
- } else if(k == 1) {
- x += roomSize+j-1;
- y += i;
- } else if(k == 2) {
- x += i;
- y += roomSize+j-1;
- } else {
- x -= j;
- y += i;
- }
-
- if(x > 0 && y > 0 && x < colourMap.length && y < colourMap[x].length) {
- Color pixel = colourMap[x][y];
- if(pixel.getAlpha() > 40) {
- if(colour == null) {
- colour = pixel;
- totalFilled = 1;
- } else {
- if(colour.equals(pixel)) {
- totalFilled++;
- } else {
- totalFilled--;
- if(totalFilled <= 0) {
- colour = pixel;
- totalFilled = 1;
- }
- }
- }
- }
- }
- }
- }
- float proportionFilled = (float)totalFilled/roomSize/connectorSize;
-
- RoomConnectionType type = RoomConnectionType.WALL;
- if(proportionFilled > 0.8) {
- type = RoomConnectionType.ROOM_DIVIDER;
- } else if(proportionFilled > 0.1) {
- type = RoomConnectionType.CORRIDOR;
- }
- if(k == 0) {
- room.up = new RoomConnection(type, colour);
- } else if(k == 1) {
- room.right = new RoomConnection(type, colour);
- } else if(k == 2) {
- room.down = new RoomConnection(type, colour);
- } else {
- room.left = new RoomConnection(type, colour);
- }
- }
-
- int x = startRoomX + roomOffset.x*(roomSize+connectorSize) + roomSize + connectorSize/2;
- int y = startRoomY + roomOffset.y*(roomSize+connectorSize) + roomSize + connectorSize/2;
-
- room.fillCorner = false;
- if(x > 0 && y > 0 && x < colourMap.length && y < colourMap[x].length) {
- Color pixel = colourMap[x][y];
- if(pixel.equals(room.colour)) {
- room.fillCorner = true;
- }
- }
- }
- }
-
- public void loadNeighbors(RoomOffset room) {
- if(!roomMap.containsKey(room)) {
- roomMap.put(room, new Room());
- }
- for(RoomOffset neighbor : room.getNeighbors()) {
- if(!roomMap.containsKey(neighbor)) {
- int x = startRoomX + neighbor.x*(roomSize+connectorSize);
- int y = startRoomY + neighbor.y*(roomSize+connectorSize);
-
- if(x >= 0 && y >= 0 && x+roomSize < colourMap.length && y+roomSize < colourMap[x].length) {
- if(colourMap[x][y].getAlpha() > 100) {
- roomMap.put(neighbor, new Room());
- loadNeighbors(neighbor);
- }
- }
- }
- }
- }
-
- public void updateRoomColours() {
- for(Map.Entry<RoomOffset, Room> entry : roomMap.entrySet()) {
- int x = startRoomX + entry.getKey().x*(roomSize+connectorSize);
- int y = startRoomY + entry.getKey().y*(roomSize+connectorSize);
-
- try {
- entry.getValue().colour = colourMap[x][y];
- } catch(Exception e) {}
- }
- }
-
- private class MapPosition {
- public float roomOffsetX;
- public float connOffsetX;
-
- public float roomOffsetY;
- public float connOffsetY;
-
- public float rotation;
-
- public MapPosition(float roomOffsetX, float connOffsetX, float roomOffsetY, float connOffsetY) {
- this.roomOffsetX = roomOffsetX;
- this.connOffsetX = connOffsetX;
- this.roomOffsetY = roomOffsetY;
- this.connOffsetY = connOffsetY;
- }
-
- public float getRenderX() {
- return roomOffsetX*getRenderRoomSize() + connOffsetX*getRenderConnSize();
- }
-
- public float getRenderY() {
- return roomOffsetY*getRenderRoomSize() + connOffsetY*getRenderConnSize();
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- MapPosition that = (MapPosition) o;
- return Float.compare(that.roomOffsetX, roomOffsetX) == 0 &&
- Float.compare(that.connOffsetX, connOffsetX) == 0 &&
- Float.compare(that.roomOffsetY, roomOffsetY) == 0 &&
- Float.compare(that.connOffsetY, connOffsetY) == 0 &&
- Float.compare(that.rotation, rotation) == 0;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(roomOffsetX, connOffsetX, roomOffsetY, connOffsetY, rotation);
- }
- }
-
- private boolean isFloorOne = false;
- private boolean failMap = false;
- private long lastClearCache = 0;
- public void renderMap(int centerX, int centerY, Color[][] colourMap, Map<String, Vec4b> mapDecorations,
- int roomSizeBlocks, Set<String> actualPlayers, boolean usePlayerPositions, float partialTicks) {
- if(!NotEnoughUpdates.INSTANCE.config.dungeonMap.dmEnable) return;
- if(colourMap == null) return;
- if(colourMap.length != 128) return;
- if(colourMap[0].length != 128) return;
- this.colourMap = colourMap;
-
- boolean searchForPlayers = false;
- if(System.currentTimeMillis() - lastClearCache > 1000) {
- roomMap.clear();
- searchForPlayers = true;
- startRoomX = -1;
- startRoomY = -1;
- connectorSize = -1;
- roomSize = -1;
- borderRadiusCache.clear();
- failMap = false;
-
- lastClearCache = System.currentTimeMillis();
-
- isFloorOne = false;
- Scoreboard scoreboard = Minecraft.getMinecraft().thePlayer.getWorldScoreboard();
-
- ScoreObjective sidebarObjective = scoreboard.getObjectiveInDisplaySlot(1);
-
- List<Score> scores = new ArrayList<>(scoreboard.getSortedScores(sidebarObjective));
-
- for(int i=scores.size()-1; i>=0; i--) {
- Score score = scores.get(i);
- ScorePlayerTeam scoreplayerteam1 = scoreboard.getPlayersTeam(score.getPlayerName());
- String line = ScorePlayerTeam.formatPlayerName(scoreplayerteam1, score.getPlayerName());
- line = Utils.cleanColour(line);
-
- if(line.contains("(F1)") || line.contains("(E)") || line.contains("(M1)")) {
- isFloorOne = true;
- break;
- }
- }
- }
-
- if(failMap) {
- return;
- }
-
- int alphaPixels = 0;
- for(int x=0; x<128; x++) {
- for(int y=0; y<128; y++) {
- Color c = colourMap[x][y];
- if(c == null) {
- return;
- } else if(c.getAlpha() < 50) {
- alphaPixels++;
- }
- }
- }
- if(alphaPixels < 128*128/10) {
- failMap = true;
- return;
- }
-
- if(startRoomX < 0 || startRoomY < 0 || roomSize <= 0) {
- for(int x=0; x<colourMap.length; x++) {
- for(int y=0; y<colourMap[x].length; y++) {
- Color c = colourMap[x][y];
- if(c.getAlpha() > 80) {
- if(startRoomX < 0 && startRoomY < 0 && c.getRed() == 0 && c.getGreen() == 124 && c.getBlue() == 0) {
- roomSize = 0;
- out:
- for(int xd=0; xd<=20; xd++) {
- for(int yd=0; yd<=20; yd++) {
- if(x+xd >= colourMap.length || y+yd >= colourMap[x+xd].length) continue;
- Color c2 = colourMap[x+xd][y+yd];
-
- if(c2.getGreen() != 124 || c2.getAlpha() <= 80) {
- if(xd < 10 && yd < 10) {
- break out;
- }
- } else {
- roomSize = Math.max(roomSize, Math.min(xd+1, yd+1));
- }
- if(xd == 20 && yd == 20) {
- if(roomSize == 0) roomSize = 20;
- startRoomX = x;
- startRoomY = y;
- }
- }
- }
- }
- }
- }
- }
- }
-
- if(startRoomX < 0 || startRoomY < 0) {
- failMap = true;
- return;
- }
-
- if(connectorSize <= 0) {
- for(int i=0; i<roomSize; i++) {
- for(int k=0; k<4; k++) {
- for(int j=1; j<8; j++) {
- int x;
- int y;
-
- if(k == 0) {
- x = startRoomX+i;
- y = startRoomY-j;
- } else if(k == 1) {
- x = startRoomX+roomSize+j-1;
- y = startRoomY+i;
- } else if(k == 2) {
- x = startRoomX+i;
- y = startRoomY+roomSize+j-1;
- } else {
- x = startRoomX-j;
- y = startRoomY+i;
- }
-
- if(x > 0 && y > 0 && x < colourMap.length && y < colourMap[x].length) {
- if(colourMap[x][y].getAlpha() > 80) {
- if(j == 1) {
- break;
- }
- connectorSize = Math.min(connectorSize, j-1);
- }
- }
- }
- }
- }
-
- if(connectorSize <= 0) {
- connectorSize = 4;
- }
- }
-
- actualPlayers.add(Minecraft.getMinecraft().thePlayer.getName());
- if(searchForPlayers) {
- for(EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) {
- if(player instanceof AbstractClientPlayer && actualPlayers.contains(player.getName())) {
- AbstractClientPlayer aplayer = (AbstractClientPlayer) player;
- ResourceLocation skin = aplayer.getLocationSkin();
- if(skin != DefaultPlayerSkin.getDefaultSkin(aplayer.getUniqueID())) {
- playerSkinMap.put(player.getName(), skin);
- playerIdMap.put(player.getName(), player.getEntityId());
- }
- }
- }
- }
-
- playerEntityMapPositions.clear();
- if(usePlayerPositions) {
- for(String playerName : actualPlayers) {
- if(playerIdMap.containsKey(playerName)) {
- Entity entity = Minecraft.getMinecraft().theWorld.getEntityByID(playerIdMap.get(playerName));
- if(entity instanceof EntityPlayer) {
- EntityPlayer player = (EntityPlayer) entity;
-
- float roomX = (float)player.posX / (roomSizeBlocks+1);
- float roomY = (float)player.posZ / (roomSizeBlocks+1);
-
- float playerRoomOffsetX = (float) Math.floor(roomX);
- float playerConnOffsetX = (float) Math.floor(roomX);
- float playerRoomOffsetY = (float) Math.floor(roomY);
- float playerConnOffsetY = (float) Math.floor(roomY);
-
- float roomXInBlocks = (float)player.posX % (roomSizeBlocks+1);
- if(roomXInBlocks < 2) { //0,1
- playerConnOffsetX -= 2/5f-roomXInBlocks/5f;
- } else if(roomXInBlocks > roomSizeBlocks-2) { //31,30,29
- playerRoomOffsetX++;
- playerConnOffsetX += (roomXInBlocks - (roomSizeBlocks-2))/5f;
- } else {
- playerRoomOffsetX += (roomXInBlocks-2) / (roomSizeBlocks-4);
- }
-
- float roomYInBlocks = (float)player.posZ % (roomSizeBlocks+1);
- if(roomYInBlocks < 2) { //0,1
- playerConnOffsetY -= 2/5f-roomYInBlocks/5f;
- } else if(roomYInBlocks > roomSizeBlocks-2) { //31,30,29
- playerRoomOffsetY++;
- playerConnOffsetY += (roomYInBlocks - (roomSizeBlocks-2))/5f;
- } else {
- playerRoomOffsetY += (roomYInBlocks-2) / (roomSizeBlocks-4);
- }
-
- playerRoomOffsetX -= startRoomX/(roomSize+connectorSize);
- playerRoomOffsetY -= startRoomY/(roomSize+connectorSize);
- playerConnOffsetX -= startRoomX/(roomSize+connectorSize);
- playerConnOffsetY -= startRoomY/(roomSize+connectorSize);
-
- MapPosition pos = new MapPosition(playerRoomOffsetX, playerConnOffsetX, playerRoomOffsetY, playerConnOffsetY);
- pos.rotation = (player.prevRotationYawHead + (player.rotationYawHead-player.prevRotationYawHead)*partialTicks) % 360;
- if(pos.rotation < 0) pos.rotation += 360;
- playerEntityMapPositions.put(player.getName(), pos);
- }
- }
- }
- }
-
- loadNeighbors(new RoomOffset(0, 0));
- updateRoomColours();
- for(RoomOffset offset : roomMap.keySet()) {
- updateRoomConnections(offset);
- }
-
- if(roomMap.isEmpty()) {
- failMap = true;
- return;
- }
-
- if(mapDecorations != null && mapDecorations.size() > 0) {
- List<MapPosition> positions = new ArrayList<>();
- int decorations = 0;
- for (Vec4b vec4b : mapDecorations.values()) {
- byte id = vec4b.func_176110_a();
- if(id != 1 && id != 3) continue;
-
- float x = (float) vec4b.func_176112_b() / 2.0F + 64.0F;
- float y = (float) vec4b.func_176113_c() / 2.0F + 64.0F;
-
- if(x < 0 || y < 0 || x > 128 || y > 128) {
- continue;
- }
-
- float deltaX = x - startRoomX;
- float deltaY = y - startRoomY;
-
- float roomsOffsetX = (int) Math.floor(deltaX / (roomSize + connectorSize));
- float connOffsetX = (int) Math.floor(deltaX / (roomSize + connectorSize));
- float xRemainder = deltaX % (roomSize + connectorSize);
- if (Math.abs(xRemainder) > roomSize) {
- roomsOffsetX += Math.copySign(1, xRemainder);
- connOffsetX += Math.copySign(1, xRemainder) * (Math.abs(xRemainder) - roomSize) / connectorSize;
- } else {
- roomsOffsetX += xRemainder / roomSize;
- }
- if (deltaX < 0 && xRemainder != 0) {
- roomsOffsetX++;
- connOffsetX++;
- }
- float roomsOffsetY = (int) Math.floor(deltaY / (roomSize + connectorSize));
- float connOffsetY = (int) Math.floor(deltaY / (roomSize + connectorSize));
- float yRemainder = deltaY % (roomSize + connectorSize);
- if (Math.abs(yRemainder) > roomSize) {
- roomsOffsetY += Math.copySign(1, yRemainder);
- connOffsetY += Math.copySign(1, yRemainder) * (Math.abs(yRemainder) - roomSize) / connectorSize;
- } else {
- roomsOffsetY += yRemainder / roomSize;
- }
- if (deltaY < 0 && yRemainder != 0) {
- roomsOffsetY++;
- connOffsetY++;
- }
-
- float angle = (float) (vec4b.func_176111_d() * 360) / 16.0F;
-
- MapPosition pos = new MapPosition(roomsOffsetX, connOffsetX, roomsOffsetY, connOffsetY);
- pos.rotation = angle % 360;
- if(pos.rotation < 0) pos.rotation += 360;
-
- if(decorations++ <= 6) {
- positions.add(pos);
- }
- rawPlayerMarkerMapPositions.add(pos);
- }
-
- boolean different = playerMarkerMapPositions.size() != positions.size();
-
- if (!different) {
- for (MapPosition pos : playerMarkerMapPositions.values()) {
- if (!positions.contains(pos)) {
- different = true;
- break;
- }
- }
- }
-
- if(different && positions.size() > 0) {
- lastLastDecorationsMillis = lastDecorationsMillis;
- lastDecorationsMillis = System.currentTimeMillis();
-
- playerMarkerMapPositionsLast.clear();
- for (Map.Entry<String, MapPosition> entry : playerMarkerMapPositions.entrySet()) {
- playerMarkerMapPositionsLast.put(entry.getKey(), entry.getValue());
- }
- playerMarkerMapPositions.clear();
-
- Set<String> foundPlayers = new HashSet<>();
- for (Map.Entry<String, MapPosition> entry : playerEntityMapPositions.entrySet()) {
- playerMarkerMapPositions.put(entry.getKey(), entry.getValue());
- playerMarkerMapPositionsLast.put(entry.getKey(), entry.getValue());
- foundPlayers.add(entry.getKey());
- }
-
- HashMap<String, HashMap<Integer, Float>> distanceMap = new HashMap<>();
- for (Map.Entry<String, MapPosition> entry : playerMarkerMapPositionsLast.entrySet()) {
- HashMap<Integer, Float> deltaDists = new HashMap<>();
- for (int i = 0; i < positions.size(); i++) {
- float dx = entry.getValue().getRenderX() - positions.get(i).getRenderX();
- float dy = entry.getValue().getRenderY() - positions.get(i).getRenderY();
- deltaDists.put(i, dx * dx + dy * dy);
- }
- distanceMap.put(entry.getKey(), deltaDists);
- }
-
- List<String> playerList = new ArrayList<>(playerMarkerMapPositionsLast.keySet());
- List<List<String>> playerPermutations = permutations(playerList);
-
- List<Integer> finalUsedIndexes = new ArrayList<>();
- if (playerPermutations.size() > 0) {
- HashMap<String, Integer> smallestPermutation = null;
- float smallestTotalDistance = 0;
-
- for (List<String> permutation : playerPermutations) {
- HashMap<String, Integer> usedIndexes = new HashMap<>();
-
- float totalDistance = 0;
- for (String player : permutation) {
- int smallestIndex = -1;
- float smallestDist = 0;
- for (Map.Entry<Integer, Float> entry : distanceMap.get(player).entrySet()) {
- if (!usedIndexes.containsValue(entry.getKey())) {
- if (smallestIndex == -1 || entry.getValue() < smallestDist) {
- smallestIndex = entry.getKey();
- smallestDist = entry.getValue();
- }
- }
- }
- if (smallestIndex != -1) {
- usedIndexes.put(player, smallestIndex);
- totalDistance += smallestDist;
- }
- }
-
- if (smallestPermutation == null || totalDistance < smallestTotalDistance) {
- smallestPermutation = usedIndexes;
- smallestTotalDistance = totalDistance;
- }
- }
-
- //System.out.println("--- PERM START ---");
- for (Map.Entry<String, Integer> entry : smallestPermutation.entrySet()) {
- //System.out.println(entry.getKey() + ":" + entry.getValue() + " : Total dist: " + smallestTotalDistance);
- finalUsedIndexes.add(entry.getValue());
- playerMarkerMapPositions.put(entry.getKey(), positions.get(entry.getValue()));
- }
- }
-
- List<Integer> nonUsedIndexes = new ArrayList<>();
- for(int i=0; i<positions.size(); i++) {
- if(!finalUsedIndexes.contains(i)) {
- nonUsedIndexes.add(i);
- }
- }
-
- for(String missingPlayer : actualPlayers) {
- if(!playerList.contains(missingPlayer)) {
- if(nonUsedIndexes.isEmpty()) break;
- playerMarkerMapPositions.put(missingPlayer, positions.get(nonUsedIndexes.get(0)));
- nonUsedIndexes.remove(0);
- }
- }
- }
- } else if(mapDecorations == null) {
- playerMarkerMapPositions.clear();
- playerMarkerMapPositionsLast.clear();
-
- for (Map.Entry<String, MapPosition> entry : playerEntityMapPositions.entrySet()) {
- playerMarkerMapPositions.put(entry.getKey(), entry.getValue());
- }
- }
-
- if(!roomMap.isEmpty() && startRoomX >= 0 && startRoomY >= 0) {
- render(centerX, centerY);
- }
-
- this.colourMap = colourMap;
- }
-
- @SubscribeEvent
- public void onWorldChange(WorldEvent.Load event) {
- colourMap = null;
- }
-
- @SubscribeEvent
- public void onRenderOverlay(RenderGameOverlayEvent.Post event) {
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
- if(event.type == RenderGameOverlayEvent.ElementType.ALL) {
- if(!NotEnoughUpdates.INSTANCE.config.dungeonMap.dmEnable) return;
-
- if(Minecraft.getMinecraft().gameSettings.showDebugInfo ||
- (Minecraft.getMinecraft().gameSettings.keyBindPlayerList.isKeyDown() &&
- (!Minecraft.getMinecraft().isIntegratedServerRunning() ||
- Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap().size() > 1))) {
- return;
- }
-
- ItemStack stack = Minecraft.getMinecraft().thePlayer.inventory.mainInventory[8];
- boolean holdingBow = stack != null && stack.getItem() == Items.arrow && colourMap != null;
- if(holdingBow || (stack != null && stack.getItem() instanceof ItemMap)) {
- Map<String, Vec4b> decorations = null;
-
- Color[][] colourMap = new Color[128][128];
- if(holdingBow) {
- for(int x=0; x<128; x++) {
- for(int y=0; y<128; y++) {
- if(this.colourMap[x][y] != null) {
- colourMap[x][y] = this.colourMap[x][y];
- } else {
- colourMap[x][y] = new Color(0, true);
- }
- }
- }
- } else {
- ItemMap map = (ItemMap) stack.getItem();
- MapData mapData = map.getMapData(stack, Minecraft.getMinecraft().theWorld);
-
- if(mapData == null) return;
-
- decorations = mapData.mapDecorations;
-
- for (int i = 0; i < 16384; ++i) {
- int x = i % 128;
- int y = i / 128;
-
- int j = mapData.colors[i] & 255;
-
- Color c;
- if (j / 4 == 0) {
- c = new Color((i + i / 128 & 1) * 8 + 16 << 24, true);
- } else {
- c = new Color(MapColor.mapColorArray[j / 4].getMapColor(j & 3), true);
- }
-
- colourMap[x][y] = c;
- }
- }
-
- int roomSizeBlocks = 31;
+ x += deltaX;
+ y += deltaY;
+
+ doInterp = false;
+ }
+
+ float minU = 3 / 4f;
+ float minV = 0;
+
+ if (name.equals(Minecraft.getMinecraft().thePlayer.getName())) {
+ minU = 1 / 4f;
+ }
+
+ float maxU = minU + 1 / 4f;
+ float maxV = minV + 1 / 4f;
+
+ if (doInterp && playerMarkerMapPositionsLast.containsKey(name)) {
+ MapPosition last = playerMarkerMapPositionsLast.get(name);
+ float xLast = last.getRenderX();
+ float yLast = last.getRenderY();
+
+ float distSq = (x - xLast) * (x - xLast) + (y - yLast) * (y - yLast);
+ if (distSq < renderRoomSize * renderRoomSize / 4f) {
+ float angleLast = last.rotation;
+ if (angle > 180 && angleLast < 180) angleLast += 360;
+ if (angleLast > 180 && angle < 180) angle += 360;
+
+ float interpFactor = Math.round((System.currentTimeMillis() - lastDecorationsMillis) * 100f) / 100f /
+ (lastDecorationsMillis - lastLastDecorationsMillis);
+ interpFactor = Math.max(0, Math.min(1, interpFactor));
+
+ x = xLast + (x - xLast) * interpFactor;
+ y = yLast + (y - yLast) * interpFactor;
+ angle = angleLast + (angle - angleLast) * interpFactor;
+ angle %= 360;
+ }
+ }
+
+ boolean blackBorder = false;
+ boolean headLayer = false;
+ int pixelWidth = 8;
+ int pixelHeight = 8;
+ if (renderRoomSize >= 24) {
+ pixelWidth = pixelHeight = 12;
+ }
+ GlStateManager.color(1, 1, 1, 1);
+ if ((!NotEnoughUpdates.INSTANCE.config.dungeons.showOwnHeadAsMarker ||
+ playerMarkerMapPositions.size() <= 1 || minU != 1 / 4f) &&
+ NotEnoughUpdates.INSTANCE.config.dungeonMap.dmPlayerHeads >= 1 &&
+ playerSkinMap.containsKey(entry.getKey())) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(playerSkinMap.get(entry.getKey()));
+
+ minU = 8 / 64f;
+ minV = 8 / 64f;
+ maxU = 16 / 64f;
+ maxV = 16 / 64f;
+
+ headLayer = true;
+ if (NotEnoughUpdates.INSTANCE.config.dungeonMap.dmPlayerHeads >= 2) {
+ blackBorder = true;
+ }
+ } else {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(mapIcons);
+ }
+
+ x -= minRoomX * (renderRoomSize + renderConnSize);
+ y -= minRoomY * (renderRoomSize + renderConnSize);
+
+ GlStateManager.pushMatrix();
+
+ GlStateManager.disableDepth();
+ GlStateManager.enableBlend();
+ GL14.glBlendFuncSeparate(
+ GL11.GL_SRC_ALPHA,
+ GL11.GL_ONE_MINUS_SRC_ALPHA,
+ GL11.GL_ONE,
+ GL11.GL_ONE_MINUS_SRC_ALPHA
+ );
+
+ GlStateManager.translate(x, y, -0.02F);
+ GlStateManager.scale(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmIconScale,
+ NotEnoughUpdates.INSTANCE.config.dungeonMap.dmIconScale, 1
+ );
+ GlStateManager.rotate(angle, 0.0F, 0.0F, 1.0F);
+ GlStateManager.translate(-0.5F, 0.5F, 0.0F);
+
+ if (blackBorder) {
+ Gui.drawRect(
+ -pixelWidth / 2 - 1,
+ -pixelHeight / 2 - 1,
+ pixelWidth / 2 + 1,
+ pixelHeight / 2 + 1,
+ 0xff111111
+ );
+ GlStateManager.color(1, 1, 1, 1);
+ }
+
+ worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
+ worldrenderer.pos(-pixelWidth / 2f, pixelHeight / 2f, 30 + ((float) k * -0.005F)).tex(minU, minV).endVertex();
+ worldrenderer.pos(pixelWidth / 2f, pixelHeight / 2f, 30 + ((float) k * -0.005F)).tex(maxU, minV).endVertex();
+ worldrenderer.pos(pixelWidth / 2f, -pixelHeight / 2f, 30 + ((float) k * -0.005F)).tex(maxU, maxV).endVertex();
+ worldrenderer
+ .pos(-pixelWidth / 2f, -pixelHeight / 2f, 30 + ((float) k * -0.005F))
+ .tex(minU, maxV)
+ .endVertex();
+ tessellator.draw();
+
+ if (headLayer) {
+ worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
+ worldrenderer.pos(-pixelWidth / 2f, pixelHeight / 2f, 30 + ((float) k * -0.005F) + 0.001f).tex(
+ minU + 0.5f,
+ minV
+ ).endVertex();
+ worldrenderer.pos(pixelWidth / 2f, pixelHeight / 2f, 30 + ((float) k * -0.005F) + 0.001f).tex(
+ maxU + 0.5f,
+ minV
+ ).endVertex();
+ worldrenderer.pos(pixelWidth / 2f, -pixelHeight / 2f, 30 + ((float) k * -0.005F) + 0.001f).tex(
+ maxU + 0.5f,
+ maxV
+ ).endVertex();
+ worldrenderer.pos(-pixelWidth / 2f, -pixelHeight / 2f, 30 + ((float) k * -0.005F) + 0.001f).tex(
+ minU + 0.5f,
+ maxV
+ ).endVertex();
+ tessellator.draw();
+ }
+ GlStateManager.popMatrix();
+ k--;
+ }
+
+ if (useFb) {
+ GlStateManager.enableBlend();
+ GL14.glBlendFuncSeparate(
+ GL11.GL_SRC_ALPHA,
+ GL11.GL_ONE_MINUS_SRC_ALPHA,
+ GL11.GL_ONE,
+ GL11.GL_ONE_MINUS_SRC_ALPHA
+ );
+ } else {
+ GL11.glDisable(GL11.GL_SCISSOR_TEST);
+ }
+ }
+ GlStateManager.popMatrix();
+
+ if (useFb) {
+ Framebuffer renderFromBuffer = mapFramebuffer1;
+ if (useShd) {
+ GlStateManager.pushMatrix();
+ {
+ try {
+ upload(mapShader, mapSizeX, mapSizeY, scaleFactor, getBorderRadius());
+ mapShader.setProjectionMatrix(projectionMatrix);
+ mapShader.loadShader(0);
+ renderFromBuffer = mapFramebuffer2;
+ } catch (Exception ignored) {
+ }
+ }
+ GlStateManager.popMatrix();
+ }
+
+ Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true);
+
+ Utils.pushGuiScale(2);
+
+ GlStateManager.translate(centerX, centerY, 100);
+
+ renderFromBuffer.bindFramebufferTexture();
+ Utils.drawTexturedRect(-mapSizeX / 2, -mapSizeY / 2, mapSizeX, mapSizeY,
+ 0, 1, 1, 0, GL11.GL_NEAREST
+ );
+ GlStateManager.bindTexture(0);
+
+ GlStateManager.translate(-centerX, -centerY, -100);
+
+ Utils.pushGuiScale(-1);
+ }
+
+ GlStateManager.translate(centerX, centerY, 100);
+
+ if (NotEnoughUpdates.INSTANCE.config.dungeonMap.dmChromaBorder) {
+ int colour = SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderColour);
+
+ Gui.drawRect(-mapCenterX - 2, -mapCenterY - 2, -mapCenterX, -mapCenterY,
+ colour
+ ); //topleft
+ Gui.drawRect(-mapCenterX - 2, mapCenterY + 2, -mapCenterX, mapCenterY,
+ SpecialColour.rotateHue(colour, -180)
+ ); //bottomleft
+ Gui.drawRect(mapCenterX, -mapCenterY - 2, mapCenterX + 2, mapCenterY,
+ SpecialColour.rotateHue(colour, -180)
+ ); //topright
+ Gui.drawRect(mapCenterX, mapCenterY, mapCenterX + 2, mapCenterY + 2,
+ colour
+ ); //bottomright
+
+ for (int i = 0; i < 20; i++) {
+ int start1 = SpecialColour.rotateHue(colour, -9 * i);
+ int start2 = SpecialColour.rotateHue(colour, -9 * i - 9);
+ int end1 = SpecialColour.rotateHue(colour, -180 - 9 * i);
+ int end2 = SpecialColour.rotateHue(colour, -180 - 9 * i - 9);
+
+ Utils.drawGradientRect(-mapCenterX - 2, -mapCenterY + (int) (mapSizeY * (i / 20f)), -mapCenterX,
+ -mapCenterY + (int) (mapSizeY * ((i + 1) / 20f)), start1, start2
+ ); //left
+ Utils.drawGradientRect(mapCenterX, -mapCenterY + (int) (mapSizeX * (i / 20f)), mapCenterX + 2,
+ -mapCenterY + (int) (mapSizeX * ((i + 1) / 20f)),
+ end1, end2
+ ); //right
+ Utils.drawGradientRectHorz(-mapCenterX + (int) (mapSizeX * (i / 20f)), -mapCenterY - 2,
+ -mapCenterX + (int) (mapSizeX * ((i + 1) / 20f)), -mapCenterY, start1, start2
+ ); //top
+ Utils.drawGradientRectHorz(-mapCenterX + (int) (mapSizeX * (i / 20f)),
+ mapCenterY, -mapCenterX + (int) (mapSizeX * ((i + 1) / 20f)), mapCenterY + 2,
+ end1, end2
+ ); //bottom
+ }
+
+ } else {
+ Gui.drawRect(-mapCenterX - 2, -mapCenterY, -mapCenterX, mapCenterY,
+ SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderColour)
+ ); //left
+ Gui.drawRect(mapCenterX, -mapCenterY, mapCenterX + 2, mapCenterY,
+ SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderColour)
+ ); //right
+ Gui.drawRect(-mapCenterX - 2, -mapCenterY - 2, mapCenterX + 2, -mapCenterY,
+ SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderColour)
+ ); //top
+ Gui.drawRect(-mapCenterX - 2, mapCenterY, mapCenterX + 2, mapCenterY + 2,
+ SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderColour)
+ ); //bottom
+ }
+
+ String sizeId = borderSizeOption == 0 ? "small" : borderSizeOption == 2 ? "large" : "medium";
+
+ ResourceLocation rl = new ResourceLocation("notenoughupdates:dungeon_map/borders/" + sizeId + "/" +
+ NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderStyle + ".png");
+ if (Minecraft.getMinecraft().getTextureManager().getTexture(rl) != TextureUtil.missingTexture) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(rl);
+ GlStateManager.color(1, 1, 1, 1);
+
+ int size = borderSizeOption == 0 ? 165 : borderSizeOption == 1 ? 220 : borderSizeOption == 2 ? 300 : 440;
+ Utils.drawTexturedRect(-size / 2, -size / 2, size, size, GL11.GL_NEAREST);
+ }
+
+ GlStateManager.translate(-centerX, -centerY, -100);
+ } catch (Exception e) {
+ e.printStackTrace();
+ Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true);
+ Minecraft.getMinecraft().entityRenderer.setupOverlayRendering();
+ }
+
+ Utils.pushGuiScale(-1);
+
+ GlStateManager.enableBlend();
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+ GlStateManager.enableDepth();
+ GlStateManager.disableLighting();
+ }
+
+ public void updateRoomConnections(RoomOffset roomOffset) {
+ if (roomMap.containsKey(roomOffset)) {
+ Room room = roomMap.get(roomOffset);
+
+ int otherPixelFilled = 0;
+ int otherPixelColour = 0;
+ for (int xOff = 0; xOff < roomSize; xOff++) {
+ for (int yOff = 0; yOff < roomSize; yOff++) {
+ int x = startRoomX + roomOffset.x * (roomSize + connectorSize) + xOff;
+ int y = startRoomY + roomOffset.y * (roomSize + connectorSize) + yOff;
+
+ if (x > 0 && y > 0 && x < colourMap.length && y < colourMap[x].length) {
+ Color c = colourMap[x][y];
+ if (!c.equals(room.colour)) {
+ if (otherPixelColour == c.getRGB()) {
+ otherPixelFilled++;
+ } else {
+ otherPixelFilled--;
+ if (otherPixelFilled <= 0) {
+ otherPixelFilled = 1;
+ otherPixelColour = c.getRGB();
+ }
+ }
+ }
+ }
+ }
+ }
+
+ room.tickColour = 0;
+ if ((float) otherPixelFilled / roomSize / connectorSize > 0.05) {
+ room.tickColour = otherPixelColour;
+ }
+
+ for (int k = 0; k < 4; k++) {
+ Color colour = null;
+ int totalFilled = 0;
+
+ for (int i = 0; i < roomSize; i++) {
+ for (int j = 1; j <= connectorSize; j++) {
+ int x = startRoomX + roomOffset.x * (roomSize + connectorSize);
+ int y = startRoomY + roomOffset.y * (roomSize + connectorSize);
+
+ if (k == 0) {
+ x += i;
+ y -= j;
+ } else if (k == 1) {
+ x += roomSize + j - 1;
+ y += i;
+ } else if (k == 2) {
+ x += i;
+ y += roomSize + j - 1;
+ } else {
+ x -= j;
+ y += i;
+ }
+
+ if (x > 0 && y > 0 && x < colourMap.length && y < colourMap[x].length) {
+ Color pixel = colourMap[x][y];
+ if (pixel.getAlpha() > 40) {
+ if (colour == null) {
+ colour = pixel;
+ totalFilled = 1;
+ } else {
+ if (colour.equals(pixel)) {
+ totalFilled++;
+ } else {
+ totalFilled--;
+ if (totalFilled <= 0) {
+ colour = pixel;
+ totalFilled = 1;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ float proportionFilled = (float) totalFilled / roomSize / connectorSize;
+
+ RoomConnectionType type = RoomConnectionType.WALL;
+ if (proportionFilled > 0.8) {
+ type = RoomConnectionType.ROOM_DIVIDER;
+ } else if (proportionFilled > 0.1) {
+ type = RoomConnectionType.CORRIDOR;
+ }
+ if (k == 0) {
+ room.up = new RoomConnection(type, colour);
+ } else if (k == 1) {
+ room.right = new RoomConnection(type, colour);
+ } else if (k == 2) {
+ room.down = new RoomConnection(type, colour);
+ } else {
+ room.left = new RoomConnection(type, colour);
+ }
+ }
+
+ int x = startRoomX + roomOffset.x * (roomSize + connectorSize) + roomSize + connectorSize / 2;
+ int y = startRoomY + roomOffset.y * (roomSize + connectorSize) + roomSize + connectorSize / 2;
+
+ room.fillCorner = false;
+ if (x > 0 && y > 0 && x < colourMap.length && y < colourMap[x].length) {
+ Color pixel = colourMap[x][y];
+ if (pixel.equals(room.colour)) {
+ room.fillCorner = true;
+ }
+ }
+ }
+ }
+
+ public void loadNeighbors(RoomOffset room) {
+ if (!roomMap.containsKey(room)) {
+ roomMap.put(room, new Room());
+ }
+ for (RoomOffset neighbor : room.getNeighbors()) {
+ if (!roomMap.containsKey(neighbor)) {
+ int x = startRoomX + neighbor.x * (roomSize + connectorSize);
+ int y = startRoomY + neighbor.y * (roomSize + connectorSize);
+
+ if (x >= 0 && y >= 0 && x + roomSize < colourMap.length && y + roomSize < colourMap[x].length) {
+ if (colourMap[x][y].getAlpha() > 100) {
+ roomMap.put(neighbor, new Room());
+ loadNeighbors(neighbor);
+ }
+ }
+ }
+ }
+ }
+
+ public void updateRoomColours() {
+ for (Map.Entry<RoomOffset, Room> entry : roomMap.entrySet()) {
+ int x = startRoomX + entry.getKey().x * (roomSize + connectorSize);
+ int y = startRoomY + entry.getKey().y * (roomSize + connectorSize);
+
+ try {
+ entry.getValue().colour = colourMap[x][y];
+ } catch (Exception ignored) {
+ }
+ }
+ }
+
+ private class MapPosition {
+ public float roomOffsetX;
+ public float connOffsetX;
+
+ public float roomOffsetY;
+ public float connOffsetY;
+
+ public float rotation;
+
+ public MapPosition(float roomOffsetX, float connOffsetX, float roomOffsetY, float connOffsetY) {
+ this.roomOffsetX = roomOffsetX;
+ this.connOffsetX = connOffsetX;
+ this.roomOffsetY = roomOffsetY;
+ this.connOffsetY = connOffsetY;
+ }
+
+ public float getRenderX() {
+ return roomOffsetX * getRenderRoomSize() + connOffsetX * getRenderConnSize();
+ }
+
+ public float getRenderY() {
+ return roomOffsetY * getRenderRoomSize() + connOffsetY * getRenderConnSize();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ MapPosition that = (MapPosition) o;
+ return Float.compare(that.roomOffsetX, roomOffsetX) == 0 &&
+ Float.compare(that.connOffsetX, connOffsetX) == 0 &&
+ Float.compare(that.roomOffsetY, roomOffsetY) == 0 &&
+ Float.compare(that.connOffsetY, connOffsetY) == 0 &&
+ Float.compare(that.rotation, rotation) == 0;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(roomOffsetX, connOffsetX, roomOffsetY, connOffsetY, rotation);
+ }
+ }
+
+ private boolean isFloorOne = false;
+ private boolean failMap = false;
+ private long lastClearCache = 0;
+
+ public void renderMap(
+ int centerX, int centerY, Color[][] colourMap, Map<String, Vec4b> mapDecorations,
+ int roomSizeBlocks, Set<String> actualPlayers, boolean usePlayerPositions, float partialTicks
+ ) {
+ if (!NotEnoughUpdates.INSTANCE.config.dungeonMap.dmEnable) return;
+ if (colourMap == null) return;
+ if (colourMap.length != 128) return;
+ if (colourMap[0].length != 128) return;
+ this.colourMap = colourMap;
+
+ boolean searchForPlayers = false;
+ if (System.currentTimeMillis() - lastClearCache > 1000) {
+ roomMap.clear();
+ searchForPlayers = true;
+ startRoomX = -1;
+ startRoomY = -1;
+ connectorSize = -1;
+ roomSize = -1;
+ borderRadiusCache.clear();
+ failMap = false;
+
+ lastClearCache = System.currentTimeMillis();
+
+ isFloorOne = false;
+ Scoreboard scoreboard = Minecraft.getMinecraft().thePlayer.getWorldScoreboard();
+
+ ScoreObjective sidebarObjective = scoreboard.getObjectiveInDisplaySlot(1);
+
+ List<Score> scores = new ArrayList<>(scoreboard.getSortedScores(sidebarObjective));
+
+ for (int i = scores.size() - 1; i >= 0; i--) {
+ Score score = scores.get(i);
+ ScorePlayerTeam scoreplayerteam1 = scoreboard.getPlayersTeam(score.getPlayerName());
+ String line = ScorePlayerTeam.formatPlayerName(scoreplayerteam1, score.getPlayerName());
+ line = Utils.cleanColour(line);
+
+ if (line.contains("(F1)") || line.contains("(E0)") || line.contains("(M1)")) {
+ isFloorOne = true;
+ break;
+ }
+ }
+ }
+
+ if (failMap) {
+ return;
+ }
+
+ int alphaPixels = 0;
+ for (int x = 0; x < 128; x++) {
+ for (int y = 0; y < 128; y++) {
+ Color c = colourMap[x][y];
+ if (c == null) {
+ return;
+ } else if (c.getAlpha() < 50) {
+ alphaPixels++;
+ }
+ }
+ }
+ if (alphaPixels < 128 * 128 / 10) {
+ failMap = true;
+ return;
+ }
+
+ if (startRoomX < 0 || startRoomY < 0 || roomSize <= 0) {
+ for (int x = 0; x < colourMap.length; x++) {
+ for (int y = 0; y < colourMap[x].length; y++) {
+ Color c = colourMap[x][y];
+ if (c.getAlpha() > 80) {
+ if (startRoomX < 0 && startRoomY < 0 && c.getRed() == 0 && c.getGreen() == 124 && c.getBlue() == 0) {
+ roomSize = 0;
+ out:
+ for (int xd = 0; xd <= 20; xd++) {
+ for (int yd = 0; yd <= 20; yd++) {
+ if (x + xd >= colourMap.length || y + yd >= colourMap[x + xd].length) continue;
+ Color c2 = colourMap[x + xd][y + yd];
+
+ if (c2.getGreen() != 124 || c2.getAlpha() <= 80) {
+ if (xd < 10 && yd < 10) {
+ break out;
+ }
+ } else {
+ roomSize = Math.max(roomSize, Math.min(xd + 1, yd + 1));
+ }
+ if (xd == 20 && yd == 20) {
+ if (roomSize == 0) roomSize = 20;
+ startRoomX = x;
+ startRoomY = y;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (startRoomX < 0 || startRoomY < 0) {
+ failMap = true;
+ return;
+ }
+
+ if (connectorSize <= 0) {
+ for (int i = 0; i < roomSize; i++) {
+ for (int k = 0; k < 4; k++) {
+ for (int j = 1; j < 8; j++) {
+ int x;
+ int y;
+
+ if (k == 0) {
+ x = startRoomX + i;
+ y = startRoomY - j;
+ } else if (k == 1) {
+ x = startRoomX + roomSize + j - 1;
+ y = startRoomY + i;
+ } else if (k == 2) {
+ x = startRoomX + i;
+ y = startRoomY + roomSize + j - 1;
+ } else {
+ x = startRoomX - j;
+ y = startRoomY + i;
+ }
+
+ if (x > 0 && y > 0 && x < colourMap.length && y < colourMap[x].length) {
+ if (colourMap[x][y].getAlpha() > 80) {
+ if (j == 1) {
+ break;
+ }
+ connectorSize = Math.min(connectorSize, j - 1);
+ }
+ }
+ }
+ }
+ }
+
+ if (connectorSize <= 0) {
+ connectorSize = 4;
+ }
+ }
+
+ actualPlayers.add(Minecraft.getMinecraft().thePlayer.getName());
+ if (searchForPlayers) {
+ for (EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) {
+ if (player instanceof AbstractClientPlayer && actualPlayers.contains(player.getName())) {
+ AbstractClientPlayer aplayer = (AbstractClientPlayer) player;
+ ResourceLocation skin = aplayer.getLocationSkin();
+ if (skin != DefaultPlayerSkin.getDefaultSkin(aplayer.getUniqueID())) {
+ playerSkinMap.put(player.getName(), skin);
+ playerIdMap.put(player.getName(), player.getEntityId());
+ }
+ }
+ }
+ }
+
+ playerEntityMapPositions.clear();
+ if (usePlayerPositions) {
+ for (String playerName : actualPlayers) {
+ if (playerIdMap.containsKey(playerName)) {
+ Entity entity = Minecraft.getMinecraft().theWorld.getEntityByID(playerIdMap.get(playerName));
+ if (entity instanceof EntityPlayer) {
+ EntityPlayer player = (EntityPlayer) entity;
+
+ float roomX = (float) player.posX / (roomSizeBlocks + 1);
+ float roomY = (float) player.posZ / (roomSizeBlocks + 1);
+
+ float playerRoomOffsetX = (float) Math.floor(roomX);
+ float playerConnOffsetX = (float) Math.floor(roomX);
+ float playerRoomOffsetY = (float) Math.floor(roomY);
+ float playerConnOffsetY = (float) Math.floor(roomY);
+
+ float roomXInBlocks = (float) player.posX % (roomSizeBlocks + 1);
+ if (roomXInBlocks < 2) { //0,1
+ playerConnOffsetX -= 2 / 5f - roomXInBlocks / 5f;
+ } else if (roomXInBlocks > roomSizeBlocks - 2) { //31,30,29
+ playerRoomOffsetX++;
+ playerConnOffsetX += (roomXInBlocks - (roomSizeBlocks - 2)) / 5f;
+ } else {
+ playerRoomOffsetX += (roomXInBlocks - 2) / (roomSizeBlocks - 4);
+ }
+
+ float roomYInBlocks = (float) player.posZ % (roomSizeBlocks + 1);
+ if (roomYInBlocks < 2) { //0,1
+ playerConnOffsetY -= 2 / 5f - roomYInBlocks / 5f;
+ } else if (roomYInBlocks > roomSizeBlocks - 2) { //31,30,29
+ playerRoomOffsetY++;
+ playerConnOffsetY += (roomYInBlocks - (roomSizeBlocks - 2)) / 5f;
+ } else {
+ playerRoomOffsetY += (roomYInBlocks - 2) / (roomSizeBlocks - 4);
+ }
+
+ playerRoomOffsetX -= startRoomX / (roomSize + connectorSize);
+ playerRoomOffsetY -= startRoomY / (roomSize + connectorSize);
+ playerConnOffsetX -= startRoomX / (roomSize + connectorSize);
+ playerConnOffsetY -= startRoomY / (roomSize + connectorSize);
+
+ MapPosition pos = new MapPosition(
+ playerRoomOffsetX,
+ playerConnOffsetX,
+ playerRoomOffsetY,
+ playerConnOffsetY
+ );
+ pos.rotation =
+ (player.prevRotationYawHead + (player.rotationYawHead - player.prevRotationYawHead) * partialTicks) % 360;
+ if (pos.rotation < 0) pos.rotation += 360;
+ playerEntityMapPositions.put(player.getName(), pos);
+ }
+ }
+ }
+ }
+
+ loadNeighbors(new RoomOffset(0, 0));
+ updateRoomColours();
+ for (RoomOffset offset : roomMap.keySet()) {
+ updateRoomConnections(offset);
+ }
+
+ if (roomMap.isEmpty()) {
+ failMap = true;
+ return;
+ }
+
+ if (mapDecorations != null && mapDecorations.size() > 0) {
+ List<MapPosition> positions = new ArrayList<>();
+ int decorations = 0;
+ for (Vec4b vec4b : mapDecorations.values()) {
+ byte id = vec4b.func_176110_a();
+ if (id != 1 && id != 3) continue;
+
+ float x = (float) vec4b.func_176112_b() / 2.0F + 64.0F;
+ float y = (float) vec4b.func_176113_c() / 2.0F + 64.0F;
+
+ if (x < 0 || y < 0 || x > 128 || y > 128) {
+ continue;
+ }
+
+ float deltaX = x - startRoomX;
+ float deltaY = y - startRoomY;
+
+ float roomsOffsetX = (int) Math.floor(deltaX / (roomSize + connectorSize));
+ float connOffsetX = (int) Math.floor(deltaX / (roomSize + connectorSize));
+ float xRemainder = deltaX % (roomSize + connectorSize);
+ if (Math.abs(xRemainder) > roomSize) {
+ roomsOffsetX += Math.copySign(1, xRemainder);
+ connOffsetX += Math.copySign(1, xRemainder) * (Math.abs(xRemainder) - roomSize) / connectorSize;
+ } else {
+ roomsOffsetX += xRemainder / roomSize;
+ }
+ if (deltaX < 0 && xRemainder != 0) {
+ roomsOffsetX++;
+ connOffsetX++;
+ }
+ float roomsOffsetY = (int) Math.floor(deltaY / (roomSize + connectorSize));
+ float connOffsetY = (int) Math.floor(deltaY / (roomSize + connectorSize));
+ float yRemainder = deltaY % (roomSize + connectorSize);
+ if (Math.abs(yRemainder) > roomSize) {
+ roomsOffsetY += Math.copySign(1, yRemainder);
+ connOffsetY += Math.copySign(1, yRemainder) * (Math.abs(yRemainder) - roomSize) / connectorSize;
+ } else {
+ roomsOffsetY += yRemainder / roomSize;
+ }
+ if (deltaY < 0 && yRemainder != 0) {
+ roomsOffsetY++;
+ connOffsetY++;
+ }
+
+ float angle = (float) (vec4b.func_176111_d() * 360) / 16.0F;
+
+ MapPosition pos = new MapPosition(roomsOffsetX, connOffsetX, roomsOffsetY, connOffsetY);
+ pos.rotation = angle % 360;
+ if (pos.rotation < 0) pos.rotation += 360;
+
+ if (decorations++ <= 6) {
+ positions.add(pos);
+ }
+ rawPlayerMarkerMapPositions.add(pos);
+ }
+
+ boolean different = playerMarkerMapPositions.size() != positions.size();
+
+ if (!different) {
+ for (MapPosition pos : playerMarkerMapPositions.values()) {
+ if (!positions.contains(pos)) {
+ different = true;
+ break;
+ }
+ }
+ }
+
+ if (different && positions.size() > 0) {
+ lastLastDecorationsMillis = lastDecorationsMillis;
+ lastDecorationsMillis = System.currentTimeMillis();
+
+ playerMarkerMapPositionsLast.clear();
+ for (Map.Entry<String, MapPosition> entry : playerMarkerMapPositions.entrySet()) {
+ playerMarkerMapPositionsLast.put(entry.getKey(), entry.getValue());
+ }
+ playerMarkerMapPositions.clear();
+
+ Set<String> foundPlayers = new HashSet<>();
+ for (Map.Entry<String, MapPosition> entry : playerEntityMapPositions.entrySet()) {
+ playerMarkerMapPositions.put(entry.getKey(), entry.getValue());
+ playerMarkerMapPositionsLast.put(entry.getKey(), entry.getValue());
+ foundPlayers.add(entry.getKey());
+ }
+
+ HashMap<String, HashMap<Integer, Float>> distanceMap = new HashMap<>();
+ for (Map.Entry<String, MapPosition> entry : playerMarkerMapPositionsLast.entrySet()) {
+ HashMap<Integer, Float> deltaDists = new HashMap<>();
+ for (int i = 0; i < positions.size(); i++) {
+ float dx = entry.getValue().getRenderX() - positions.get(i).getRenderX();
+ float dy = entry.getValue().getRenderY() - positions.get(i).getRenderY();
+ deltaDists.put(i, dx * dx + dy * dy);
+ }
+ distanceMap.put(entry.getKey(), deltaDists);
+ }
+
+ List<String> playerList = new ArrayList<>(playerMarkerMapPositionsLast.keySet());
+ List<List<String>> playerPermutations = permutations(playerList);
+
+ List<Integer> finalUsedIndexes = new ArrayList<>();
+ if (playerPermutations.size() > 0) {
+ HashMap<String, Integer> smallestPermutation = null;
+ float smallestTotalDistance = 0;
+
+ for (List<String> permutation : playerPermutations) {
+ HashMap<String, Integer> usedIndexes = new HashMap<>();
+
+ float totalDistance = 0;
+ for (String player : permutation) {
+ int smallestIndex = -1;
+ float smallestDist = 0;
+ for (Map.Entry<Integer, Float> entry : distanceMap.get(player).entrySet()) {
+ if (!usedIndexes.containsValue(entry.getKey())) {
+ if (smallestIndex == -1 || entry.getValue() < smallestDist) {
+ smallestIndex = entry.getKey();
+ smallestDist = entry.getValue();
+ }
+ }
+ }
+ if (smallestIndex != -1) {
+ usedIndexes.put(player, smallestIndex);
+ totalDistance += smallestDist;
+ }
+ }
+
+ if (smallestPermutation == null || totalDistance < smallestTotalDistance) {
+ smallestPermutation = usedIndexes;
+ smallestTotalDistance = totalDistance;
+ }
+ }
+
+ //System.out.println("--- PERM START ---");
+ for (Map.Entry<String, Integer> entry : smallestPermutation.entrySet()) {
+ //System.out.println(entry.getKey() + ":" + entry.getValue() + " : Total dist: " + smallestTotalDistance);
+ finalUsedIndexes.add(entry.getValue());
+ playerMarkerMapPositions.put(entry.getKey(), positions.get(entry.getValue()));
+ }
+ }
+
+ List<Integer> nonUsedIndexes = new ArrayList<>();
+ for (int i = 0; i < positions.size(); i++) {
+ if (!finalUsedIndexes.contains(i)) {
+ nonUsedIndexes.add(i);
+ }
+ }
+
+ for (String missingPlayer : actualPlayers) {
+ if (!playerList.contains(missingPlayer)) {
+ if (nonUsedIndexes.isEmpty()) break;
+ playerMarkerMapPositions.put(missingPlayer, positions.get(nonUsedIndexes.get(0)));
+ nonUsedIndexes.remove(0);
+ }
+ }
+ }
+ } else if (mapDecorations == null) {
+ playerMarkerMapPositions.clear();
+ playerMarkerMapPositionsLast.clear();
+
+ for (Map.Entry<String, MapPosition> entry : playerEntityMapPositions.entrySet()) {
+ playerMarkerMapPositions.put(entry.getKey(), entry.getValue());
+ }
+ }
+
+ if (!roomMap.isEmpty() && startRoomX >= 0 && startRoomY >= 0) {
+ render(centerX, centerY);
+ }
+
+ this.colourMap = colourMap;
+ }
+
+ @SubscribeEvent
+ public void onWorldChange(WorldEvent.Load event) {
+ colourMap = null;
+ }
+
+ @SubscribeEvent
+ public void onRenderOverlay(RenderGameOverlayEvent.Post event) {
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
+ if (event.type == RenderGameOverlayEvent.ElementType.ALL) {
+ if (!NotEnoughUpdates.INSTANCE.config.dungeonMap.dmEnable) return;
+
+ if (Minecraft.getMinecraft().gameSettings.showDebugInfo ||
+ (Minecraft.getMinecraft().gameSettings.keyBindPlayerList.isKeyDown() &&
+ (!Minecraft.getMinecraft().isIntegratedServerRunning() ||
+ Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap().size() > 1))) {
+ return;
+ }
+
+ ItemStack stack = Minecraft.getMinecraft().thePlayer.inventory.mainInventory[8];
+ boolean holdingBow = stack != null && stack.getItem() == Items.arrow && colourMap != null;
+ if (holdingBow || (stack != null && stack.getItem() instanceof ItemMap)) {
+ Map<String, Vec4b> decorations = null;
+
+ Color[][] colourMap = new Color[128][128];
+ if (holdingBow) {
+ for (int x = 0; x < 128; x++) {
+ for (int y = 0; y < 128; y++) {
+ if (this.colourMap[x][y] != null) {
+ colourMap[x][y] = this.colourMap[x][y];
+ } else {
+ colourMap[x][y] = new Color(0, true);
+ }
+ }
+ }
+ } else {
+ ItemMap map = (ItemMap) stack.getItem();
+ MapData mapData = map.getMapData(stack, Minecraft.getMinecraft().theWorld);
+
+ if (mapData == null) return;
+
+ decorations = mapData.mapDecorations;
+
+ for (int i = 0; i < 16384; ++i) {
+ int x = i % 128;
+ int y = i / 128;
+
+ int j = mapData.colors[i] & 255;
+
+ Color c;
+ if (j / 4 == 0) {
+ c = new Color((i + i / 128 & 1) * 8 + 16 << 24, true);
+ } else {
+ c = new Color(MapColor.mapColorArray[j / 4].getMapColor(j & 3), true);
+ }
+
+ colourMap[x][y] = c;
+ }
+ }
+
+ int roomSizeBlocks = 31;
/*List<Integer> dists = new ArrayList<>();
int currentBlockCount = 0;
for(int i=0; i<300; i++) {
@@ -1485,7 +1601,7 @@ public class DungeonMap {
}
if(mostCommonDist > 31) roomSizeBlocks = mostCommonDist;*/
- Set<String> actualPlayers = new HashSet<>();
+ Set<String> actualPlayers = new HashSet<>();
/*for(EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) {
if(player.getUniqueID().toString().charAt(14) == '4') {
actualPlayers.add(player.getName());
@@ -1493,88 +1609,96 @@ public class DungeonMap {
}
}*/
- int players = 0;
- for(ScorePlayerTeam team : Minecraft.getMinecraft().thePlayer.getWorldScoreboard().getTeams()) {
- if(team.getTeamName().startsWith("a") && team.getMembershipCollection().size() == 1) {
- String playerName = Iterables.get(team.getMembershipCollection(), 0);
- boolean foundPlayer = false;
- for(EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) {
- if(player.getName().equals(playerName) && (player == Minecraft.getMinecraft().thePlayer || !player.isPlayerSleeping())) {
- actualPlayers.add(playerName);
- foundPlayer = true;
- break;
- }
- }
- if(!foundPlayer) actualPlayers.add(playerName);
- if(++players >= 6) break;
- }
- }
-
- Position pos = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmPosition;
-
- int size = 80 + Math.round(40*NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderSize);
- ScaledResolution scaledResolution = Utils.pushGuiScale(2);
- renderMap(pos.getAbsX(scaledResolution, size/2)+size/2, pos.getAbsY(scaledResolution, size/2)+size/2,
- colourMap, decorations, roomSizeBlocks, actualPlayers, true, event.partialTicks);
- Utils.pushGuiScale(-1);
- } else if(stack != null && Item.getIdFromItem(stack.getItem()) == 399){
- //This should clear the map if you're in the dungeon boss room
- //so when you're holding a bow it doesnt show the map anymore
- this.colourMap = null;
- }
- }
- }
-
- public List<List<String>> permutations(List<String> values) {
- List<List<String>> permutations = new ArrayList<>();
-
- if(values.size() == 1) {
- permutations.add(values);
- return permutations;
- }
-
- for(String first : values) {
- List<String> newList = new ArrayList<>();
- for(String val : values) {
- if(!val.equals(first)) {
- newList.add(val);
- }
- }
-
- for(List<String> list2 : permutations(newList)) {
- List<String> perm = new ArrayList<>();
- perm.add(first);
- perm.addAll(list2);
- permutations.add(perm);
- }
- }
-
- return permutations;
- }
-
- Shader blurShaderHorz = null;
- Framebuffer blurOutputHorz = null;
- Shader blurShaderVert = null;
- Framebuffer blurOutputVert = null;
-
- /**
- * Creates a projection matrix that projects from our coordinate space [0->width; 0->height] to OpenGL coordinate
- * space [-1 -> 1; 1 -> -1] (Note: flipped y-axis).
- *
- * This is so that we can render to and from the framebuffer in a way that is familiar to us, instead of needing to
- * apply scales and translations manually.
- */
- private Matrix4f createProjectionMatrix(int width, int height) {
- Matrix4f projMatrix = new Matrix4f();
- projMatrix.setIdentity();
- projMatrix.m00 = 2.0F / (float)width;
- projMatrix.m11 = 2.0F / (float)(-height);
- projMatrix.m22 = -0.0020001999F;
- projMatrix.m33 = 1.0F;
- projMatrix.m03 = -1.0F;
- projMatrix.m13 = 1.0F;
- projMatrix.m23 = -1.0001999F;
- return projMatrix;
- }
-
+ int players = 0;
+ for (ScorePlayerTeam team : Minecraft.getMinecraft().thePlayer.getWorldScoreboard().getTeams()) {
+ if (team.getTeamName().startsWith("a") && team.getMembershipCollection().size() == 1) {
+ String playerName = Iterables.get(team.getMembershipCollection(), 0);
+ boolean foundPlayer = false;
+ for (EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) {
+ if (player.getName().equals(playerName) &&
+ (player == Minecraft.getMinecraft().thePlayer || !player.isPlayerSleeping())) {
+ actualPlayers.add(playerName);
+ foundPlayer = true;
+ break;
+ }
+ }
+ if (!foundPlayer) actualPlayers.add(playerName);
+ if (++players >= 6) break;
+ }
+ }
+
+ Position pos = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmPosition;
+
+ int size = 80 + Math.round(40 * NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderSize);
+ ScaledResolution scaledResolution = Utils.pushGuiScale(2);
+ renderMap(
+ pos.getAbsX(scaledResolution, size / 2) + size / 2,
+ pos.getAbsY(scaledResolution, size / 2) + size / 2,
+ colourMap,
+ decorations,
+ roomSizeBlocks,
+ actualPlayers,
+ true,
+ event.partialTicks
+ );
+ Utils.pushGuiScale(-1);
+ } else if (stack != null && Item.getIdFromItem(stack.getItem()) == 399) {
+ //This should clear the map if you're in the dungeon boss room
+ //so when you're holding a bow it doesnt show the map anymore
+ this.colourMap = null;
+ }
+ }
+ }
+
+ public List<List<String>> permutations(List<String> values) {
+ List<List<String>> permutations = new ArrayList<>();
+
+ if (values.size() == 1) {
+ permutations.add(values);
+ return permutations;
+ }
+
+ for (String first : values) {
+ List<String> newList = new ArrayList<>();
+ for (String val : values) {
+ if (!val.equals(first)) {
+ newList.add(val);
+ }
+ }
+
+ for (List<String> list2 : permutations(newList)) {
+ List<String> perm = new ArrayList<>();
+ perm.add(first);
+ perm.addAll(list2);
+ permutations.add(perm);
+ }
+ }
+
+ return permutations;
+ }
+
+ Shader blurShaderHorz = null;
+ Framebuffer blurOutputHorz = null;
+ Shader blurShaderVert = null;
+ Framebuffer blurOutputVert = null;
+
+ /**
+ * Creates a projection matrix that projects from our coordinate space [0->width; 0->height] to OpenGL coordinate
+ * space [-1 -> 1; 1 -> -1] (Note: flipped y-axis).
+ * <p>
+ * This is so that we can render to and from the framebuffer in a way that is familiar to us, instead of needing to
+ * apply scales and translations manually.
+ */
+ private Matrix4f createProjectionMatrix(int width, int height) {
+ Matrix4f projMatrix = new Matrix4f();
+ projMatrix.setIdentity();
+ projMatrix.m00 = 2.0F / (float) width;
+ projMatrix.m11 = 2.0F / (float) (-height);
+ projMatrix.m22 = -0.0020001999F;
+ projMatrix.m33 = 1.0F;
+ projMatrix.m03 = -1.0F;
+ projMatrix.m13 = 1.0F;
+ projMatrix.m23 = -1.0001999F;
+ return projMatrix;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonWin.java b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonWin.java
index 95ca32c9..976dfcf8 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonWin.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonWin.java
@@ -14,9 +14,7 @@ import net.minecraftforge.client.event.ClientChatReceivedEvent;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL14;
-import java.awt.*;
import java.util.*;
-import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@@ -24,390 +22,443 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class DungeonWin {
-
- private static class Confetti {
- private float x;
- private float y;
- private float xLast;
- private float yLast;
- private int life = 0;
- private float xVel;
- private float yVel;
- private int id;
-
- public Confetti(float x, float y, float xVel, float yVel) {
- this.x = x;
- this.xLast = x;
- this.y = y;
- this.yLast = y;
- this.xVel = xVel;
- this.yVel = yVel;
- this.id = rand.nextInt(16);
- this.life = 20+rand.nextInt(10);
- }
- }
- public static ResourceLocation CONFETTI = new ResourceLocation("notenoughupdates:dungeon_win/confetti.png");
- public static ResourceLocation SPLUS = new ResourceLocation("notenoughupdates:dungeon_win/splus.png");
- public static ResourceLocation S = new ResourceLocation("notenoughupdates:dungeon_win/s.png");
- public static ResourceLocation A = new ResourceLocation("notenoughupdates:dungeon_win/a.png");
- public static ResourceLocation B = new ResourceLocation("notenoughupdates:dungeon_win/b.png");
- public static ResourceLocation C = new ResourceLocation("notenoughupdates:dungeon_win/c.png");
- public static ResourceLocation D = new ResourceLocation("notenoughupdates:dungeon_win/d.png");
- public static ResourceLocation TEAM_SCORE = SPLUS;
-
- private static final int SCALE_FACTOR = 3;
- private static final int WIDTH = 32*SCALE_FACTOR;
- private static final int HEIGHT = 16*SCALE_FACTOR;
-
- private static boolean hideChat = false;
- private static long lastDungeonFinish = 0;
- private static final Pattern TEAM_SCORE_REGEX = Pattern.compile("Team Score: [0-9]+ \\((S\\+|S|A|B|C|D)\\)");
-
- private static final ScheduledExecutorService SES = Executors.newScheduledThreadPool(1);
-
- public static Random rand = new Random();
- public static List<Confetti> confetti = new ArrayList<>();
- public static List<String> text = new ArrayList<>();
- public static long startTime = 0;
-
- static {
- for(int i=0; i<10; i++) {
- text.add("{PLACEHOLDER DUNGEON STAT #"+i+"}");
- }
- }
-
- public static void displayWin() {
- if(NotEnoughUpdates.INSTANCE.config.dungeons.dungeonWinMillis < 100 || !NotEnoughUpdates.INSTANCE.config.dungeons.enableDungeonWin) return;
- startTime = System.currentTimeMillis();
- confetti.clear();
- }
-
- public static void tick() {
- if(NotEnoughUpdates.INSTANCE.config.dungeons.dungeonWinMillis < 100 || !NotEnoughUpdates.INSTANCE.config.dungeons.enableDungeonWin) return;
- if(System.currentTimeMillis() - startTime > 5000) return;
- int deltaTime = (int)(System.currentTimeMillis() - startTime);
-
- if(deltaTime < 1000) {
- ScaledResolution sr = Utils.pushGuiScale(2);
- int cap = 0;
- switch(TEAM_SCORE.getResourcePath()) {
- case "dungeon_win/splus.png":
- cap = 200; break;
- case "dungeon_win/s.png":
- cap = 100; break;
- case "dungeon_win/a.png":
- cap = 50; break;
- }
- int maxConfetti = Math.min(cap, deltaTime/5);
- while(confetti.size() < maxConfetti) {
- int y;
- if(deltaTime < 500) {
- y = sr.getScaledHeight()/2-(int)(Math.sin(deltaTime/1000f*Math.PI)*sr.getScaledHeight()/9);
- } else {
- y = sr.getScaledHeight()/6+(int)(Math.sin(deltaTime/1000f*Math.PI)*sr.getScaledHeight()*4/18);
- }
- int xOffset = -WIDTH/2+rand.nextInt(WIDTH);
- int x = sr.getScaledWidth()/2+xOffset;
-
- int xVel = xOffset/2;
- int yVel = -25-rand.nextInt(10)+Math.abs(xVel)/2;
-
- confetti.add(new Confetti(x, y, xVel, yVel));
- }
- } else {
- Set<Confetti> toRemove = new HashSet<>();
- for(Confetti c : confetti) {
- if(c.life <= 0) {
- toRemove.add(c);
- }
- }
- try {
- confetti.removeAll(toRemove);
- } catch(ConcurrentModificationException ignored) {}
- }
-
- Utils.pushGuiScale(-1);
- for(Confetti c : confetti) {
- c.yVel += 1;
- c.xVel /= 1.1f;
- c.yVel /= 1.1f;
- c.xLast = c.x;
- c.yLast = c.y;
- c.x += c.xVel;
- c.y += c.yVel;
- c.life--;
- }
- }
-
-
- public static void onChatMessage(ClientChatReceivedEvent e) {
- if(e.type == 2) return;
-
- if(NotEnoughUpdates.INSTANCE.config.dungeons.dungeonWinMillis < 100 || !NotEnoughUpdates.INSTANCE.config.dungeons.enableDungeonWin) return;
-
- long currentTime = System.currentTimeMillis();
- String unformatted = Utils.cleanColour(e.message.getUnformattedText());
-
- //Added two more Resets, cant do Reset+Reset+Reset cause idk?
- //hypixel please dont randomly add more
-
- if(e.message.getFormattedText().startsWith(EnumChatFormatting.RESET+""+EnumChatFormatting.RESET+""+EnumChatFormatting.RESET+" ")){
- if(currentTime - lastDungeonFinish > 30000) {
- Matcher matcher = TEAM_SCORE_REGEX.matcher(unformatted);
- if(matcher.find()) {
- lastDungeonFinish = currentTime;
- String score = matcher.group(1);
- switch (score.toUpperCase()) {
- case "S+":
- TEAM_SCORE = SPLUS; break;
- case "S":
- TEAM_SCORE = S; break;
- case "A":
- TEAM_SCORE = A; break;
- case "B":
- TEAM_SCORE = B; break;
- case "C":
- TEAM_SCORE = C; break;
- default:
- TEAM_SCORE = D; break;
- }
-
- SES.schedule(()-> {
- NotEnoughUpdates.INSTANCE.sendChatMessage("/showextrastats");
- }, 100L, TimeUnit.MILLISECONDS);
- }
- }
- }
- if(currentTime - lastDungeonFinish > 100 && currentTime - lastDungeonFinish < 10000) {
- if(hideChat) {
- if(text.size() > 50) text.clear();
-
- e.setCanceled(true);
- if(unformatted.contains("\u25AC")) {
- hideChat = false;
- displayWin();
- } else {
- if(unformatted.trim().length() > 0) {
- text.add(e.message.getFormattedText().substring(6).trim());
- }
- }
- } else {
- if(unformatted.contains("\u25AC")) {
- hideChat = true;
- text.clear();
- e.setCanceled(true);
- }
- }
-
- }
- }
-
- public static void render(float partialTicks) {
- if(NotEnoughUpdates.INSTANCE.config.dungeons.dungeonWinMillis < 100 || !NotEnoughUpdates.INSTANCE.config.dungeons.enableDungeonWin) return;
- int maxTime = Math.min(30000, NotEnoughUpdates.INSTANCE.config.dungeons.dungeonWinMillis);
- if(System.currentTimeMillis() - startTime > maxTime) return;
- int deltaTime = (int)(System.currentTimeMillis() - startTime);
-
- float alpha = Math.max(0, Math.min(1, 1-(deltaTime-maxTime+150)/150f));
-
- ScaledResolution sr = Utils.pushGuiScale(2);
-
- if(deltaTime > 600) {
- float bottom;
- if(deltaTime < 1000) {
- bottom = sr.getScaledHeight()/6f+(float)Math.sin(deltaTime/1000f*Math.PI)*sr.getScaledHeight()*4/18+HEIGHT/2;
- } else {
- bottom = sr.getScaledHeight()/6f+HEIGHT/2;
- }
- for(int i=0; i<text.size(); i++) {
- String line = text.get(i);
- float textCenterY = sr.getScaledHeight()/6f+HEIGHT/2+7+i*10;
- if(textCenterY > bottom) {
- int textAlpha = (int)(alpha * (deltaTime > 1000 ? 255 : Math.min(255, (textCenterY-bottom)/30f*255)));
- GlStateManager.enableBlend();
-
- if(textAlpha > 150) {
- for(int xOff=-2; xOff<=2; xOff++) {
- for(int yOff=-2; yOff<=2; yOff++) {
- if(Math.abs(xOff) != Math.abs(yOff)) {
- Utils.drawStringCentered(Utils.cleanColourNotModifiers(line), Minecraft.getMinecraft().fontRendererObj,
- sr.getScaledWidth()/2+xOff/2f, textCenterY+yOff/2f, false,
- ((textAlpha/Math.max(Math.abs(xOff), Math.abs(yOff))) << 24));
- }
- }
- }
- }
-
- Utils.drawStringCentered(line, Minecraft.getMinecraft().fontRendererObj,
- sr.getScaledWidth()/2, textCenterY, false, (textAlpha << 24) | 0x00FFFFFF);
- }
- }
- }
-
- for(Confetti c : confetti) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(CONFETTI);
- GlStateManager.color(1, 1, 1, 1);
- if(c.life >= 15) {
- GlStateManager.color(1, 1, 1, Math.min(1, c.life/4f));
- Utils.drawTexturedRect(c.xLast+(c.x-c.xLast)*partialTicks-4, c.yLast+(c.y-c.yLast)*partialTicks-4,
- 8, 8, (c.id%4)/4f, (c.id%4+1)/4f, (c.id/4)/4f, (c.id/4+1)/4f, GL11.GL_NEAREST);
- }
- }
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(TEAM_SCORE);
- GlStateManager.color(1, 1, 1, alpha);
-
- GlStateManager.pushMatrix();
- if(deltaTime < 1600) {
- GlStateManager.translate(sr.getScaledWidth()/2, 0, 0);
- if(deltaTime < 500) {
- GlStateManager.translate(0, sr.getScaledHeight()/2f-Math.sin(deltaTime/1000f*Math.PI)*sr.getScaledHeight()/9, 0);
- } else if(deltaTime < 1000) {
- GlStateManager.translate(0, sr.getScaledHeight()/6f+Math.sin(deltaTime/1000f*Math.PI)*sr.getScaledHeight()*4/18, 0);
- } else {
- GlStateManager.translate(0, sr.getScaledHeight()/6f, 0);
- }
- if(deltaTime < 200) {
- float scale = deltaTime/200f;
- GlStateManager.scale(scale, scale, 1);
- } else if(deltaTime < 1000) {
- float scale = 1+(float)Math.sin((deltaTime-200)/800f*Math.PI)*0.8f;
- GlStateManager.scale(scale, scale, 1);
- } else if(deltaTime < 1100) {
- float scale = 1+(float)Math.sin((deltaTime-1000)/100f*Math.PI)*0.15f;
- GlStateManager.scale(scale, scale, 1);
- }
-
- if(deltaTime < 600) {
- GlStateManager.rotate(180+deltaTime/600f*180, 0, 1, 0);
- GlStateManager.rotate(180-deltaTime/600f*180, 1, 0, 0);
- GlStateManager.rotate(-180-deltaTime/600f*165, 0, 0, 1);
- } else if(deltaTime < 1000) {
- GlStateManager.rotate(15-(deltaTime-600)/400f*11, 0, 0, 1);
- } else {
- float logFac = 1-(float)Math.log((deltaTime-1000)/600f*1.7f+1);
- logFac = logFac*logFac;
-
- GlStateManager.rotate(4f*logFac, 0, 0, 1);
- float x = (deltaTime-1000)/300f;
- GlStateManager.rotate((float)(40*(1-Math.log(x*0.85f+1))*Math.sin(10*x*x)), 0, 1, 0);
- }
- } else {
- GlStateManager.translate(sr.getScaledWidth()/2, sr.getScaledHeight()/6f, 0);
- }
-
- GlStateManager.disableCull();
-
- Utils.drawTexturedRect(-WIDTH/2, -HEIGHT/2, WIDTH, HEIGHT, GL11.GL_NEAREST);
- GlStateManager.translate(0, 0, -SCALE_FACTOR*2);
- Utils.drawTexturedRect(-WIDTH/2, -HEIGHT/2, WIDTH, HEIGHT, GL11.GL_NEAREST);
- GlStateManager.translate(0, 0, SCALE_FACTOR*2);
-
- if(deltaTime < 1600) {
- float epsilon = 0.01f;
- for(int xIndex=0; xIndex<32; xIndex++) {
- for(int yIndex=0; yIndex<16; yIndex++) {
- float uMin = xIndex/32f;
- float uMax = (xIndex+1)/32f;
- float vMin = yIndex/16f;
- float vMax = (yIndex+1)/16f;
-
- int x = -WIDTH/2+xIndex*SCALE_FACTOR;
- int y = -HEIGHT/2+yIndex*SCALE_FACTOR;
-
- GlStateManager.enableTexture2D();
- GlStateManager.enableBlend();
- GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
-
- GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
- GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
-
- Tessellator tessellator = Tessellator.getInstance();
- WorldRenderer worldrenderer = tessellator.getWorldRenderer();
- //Left
- worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
- worldrenderer
- .pos(x+epsilon, y+SCALE_FACTOR, 0.0D+epsilon)
- .tex(uMin, vMax).endVertex();
- worldrenderer
- .pos(x+epsilon, y, 0.0D+epsilon)
- .tex(uMax, vMax).endVertex();
- worldrenderer
- .pos(x+epsilon, y, -SCALE_FACTOR*2-epsilon)
- .tex(uMax, vMin).endVertex();
- worldrenderer
- .pos(x+epsilon, y+SCALE_FACTOR, -SCALE_FACTOR*2-epsilon)
- .tex(uMin, vMin).endVertex();
- tessellator.draw();
- //Right
- worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
- worldrenderer
- .pos(x+SCALE_FACTOR-epsilon, y+SCALE_FACTOR, 0.0D+epsilon)
- .tex(uMin, vMax).endVertex();
- worldrenderer
- .pos(x+SCALE_FACTOR-epsilon, y, 0.0D+epsilon)
- .tex(uMax, vMax).endVertex();
- worldrenderer
- .pos(x+SCALE_FACTOR-epsilon, y, -SCALE_FACTOR*2-epsilon)
- .tex(uMax, vMin).endVertex();
- worldrenderer
- .pos(x+SCALE_FACTOR-epsilon, y+SCALE_FACTOR, -SCALE_FACTOR*2-epsilon)
- .tex(uMin, vMin).endVertex();
- tessellator.draw();
- //Top
- worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
- worldrenderer
- .pos(x+SCALE_FACTOR, y+epsilon, 0.0D+epsilon)
- .tex(uMin, vMax).endVertex();
- worldrenderer
- .pos(x, y+epsilon, 0.0D+epsilon)
- .tex(uMax, vMax).endVertex();
- worldrenderer
- .pos(x, y+epsilon, -SCALE_FACTOR*2-epsilon)
- .tex(uMax, vMin).endVertex();
- worldrenderer
- .pos(x+SCALE_FACTOR, y+epsilon, -SCALE_FACTOR*2-epsilon)
- .tex(uMin, vMin).endVertex();
- tessellator.draw();
- //Top
- worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
- worldrenderer
- .pos(x+SCALE_FACTOR, y+SCALE_FACTOR-epsilon, 0.0D+epsilon)
- .tex(uMin, vMax).endVertex();
- worldrenderer
- .pos(x, y+SCALE_FACTOR-epsilon, 0.0D+epsilon)
- .tex(uMax, vMax).endVertex();
- worldrenderer
- .pos(x, y+SCALE_FACTOR-epsilon, -SCALE_FACTOR*2-epsilon)
- .tex(uMax, vMin).endVertex();
- worldrenderer
- .pos(x+SCALE_FACTOR, y+SCALE_FACTOR-epsilon, -SCALE_FACTOR*2-epsilon)
- .tex(uMin, vMin).endVertex();
- tessellator.draw();
-
- GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
- GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
-
- GlStateManager.disableBlend();
- }
- }
- }
-
- GlStateManager.popMatrix();
-
- for(Confetti c : confetti) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(CONFETTI);
- GlStateManager.color(1, 1, 1, 1);
- if(c.life > 0 && c.life < 15) {
- GlStateManager.color(1, 1, 1, Math.min(1, c.life/4f));
- Utils.drawTexturedRect(c.xLast+(c.x-c.xLast)*partialTicks-4, c.yLast+(c.y-c.yLast)*partialTicks-4,
- 8, 8, (c.id%4)/4f, (c.id%4+1)/4f, (c.id/4)/4f, (c.id/4+1)/4f, GL11.GL_NEAREST);
- }
- }
-
- Utils.pushGuiScale(-1);
-
- GlStateManager.enableBlend();
- }
-
+ private static class Confetti {
+ private float x;
+ private float y;
+ private float xLast;
+ private float yLast;
+ private int life = 0;
+ private float xVel;
+ private float yVel;
+ private final int id;
+
+ public Confetti(float x, float y, float xVel, float yVel) {
+ this.x = x;
+ this.xLast = x;
+ this.y = y;
+ this.yLast = y;
+ this.xVel = xVel;
+ this.yVel = yVel;
+ this.id = rand.nextInt(16);
+ this.life = 20 + rand.nextInt(10);
+ }
+ }
+
+ public static ResourceLocation CONFETTI = new ResourceLocation("notenoughupdates:dungeon_win/confetti.png");
+ public static ResourceLocation SPLUS = new ResourceLocation("notenoughupdates:dungeon_win/splus.png");
+ public static ResourceLocation S = new ResourceLocation("notenoughupdates:dungeon_win/s.png");
+ public static ResourceLocation A = new ResourceLocation("notenoughupdates:dungeon_win/a.png");
+ public static ResourceLocation B = new ResourceLocation("notenoughupdates:dungeon_win/b.png");
+ public static ResourceLocation C = new ResourceLocation("notenoughupdates:dungeon_win/c.png");
+ public static ResourceLocation D = new ResourceLocation("notenoughupdates:dungeon_win/d.png");
+ public static ResourceLocation TEAM_SCORE = SPLUS;
+
+ private static final int SCALE_FACTOR = 3;
+ private static final int WIDTH = 32 * SCALE_FACTOR;
+ private static final int HEIGHT = 16 * SCALE_FACTOR;
+
+ private static boolean hideChat = false;
+ private static long lastDungeonFinish = 0;
+ private static final Pattern TEAM_SCORE_REGEX = Pattern.compile("Team Score: [0-9]+ \\((S\\+|S|A|B|C|D)\\)");
+
+ private static final ScheduledExecutorService SES = Executors.newScheduledThreadPool(1);
+
+ public static Random rand = new Random();
+ public static List<Confetti> confetti = new ArrayList<>();
+ public static List<String> text = new ArrayList<>();
+ public static long startTime = 0;
+
+ static {
+ for (int i = 0; i < 10; i++) {
+ text.add("{PLACEHOLDER DUNGEON STAT #" + i + "}");
+ }
+ }
+
+ public static void displayWin() {
+ if (NotEnoughUpdates.INSTANCE.config.dungeons.dungeonWinMillis < 100 ||
+ !NotEnoughUpdates.INSTANCE.config.dungeons.enableDungeonWin)
+ return;
+ startTime = System.currentTimeMillis();
+ confetti.clear();
+ }
+
+ public static void tick() {
+ if (NotEnoughUpdates.INSTANCE.config.dungeons.dungeonWinMillis < 100 ||
+ !NotEnoughUpdates.INSTANCE.config.dungeons.enableDungeonWin)
+ return;
+ if (System.currentTimeMillis() - startTime > 5000) return;
+ int deltaTime = (int) (System.currentTimeMillis() - startTime);
+
+ if (deltaTime < 1000) {
+ ScaledResolution sr = Utils.pushGuiScale(2);
+ int cap = 0;
+ switch (TEAM_SCORE.getResourcePath()) {
+ case "dungeon_win/splus.png":
+ cap = 200;
+ break;
+ case "dungeon_win/s.png":
+ cap = 100;
+ break;
+ case "dungeon_win/a.png":
+ cap = 50;
+ break;
+ }
+ int maxConfetti = Math.min(cap, deltaTime / 5);
+ while (confetti.size() < maxConfetti) {
+ int y;
+ if (deltaTime < 500) {
+ y = sr.getScaledHeight() / 2 - (int) (Math.sin(deltaTime / 1000f * Math.PI) * sr.getScaledHeight() / 9);
+ } else {
+ y = sr.getScaledHeight() / 6 + (int) (Math.sin(deltaTime / 1000f * Math.PI) * sr.getScaledHeight() * 4 / 18);
+ }
+ int xOffset = -WIDTH / 2 + rand.nextInt(WIDTH);
+ int x = sr.getScaledWidth() / 2 + xOffset;
+
+ int xVel = xOffset / 2;
+ int yVel = -25 - rand.nextInt(10) + Math.abs(xVel) / 2;
+
+ confetti.add(new Confetti(x, y, xVel, yVel));
+ }
+ } else {
+ Set<Confetti> toRemove = new HashSet<>();
+ for (Confetti c : confetti) {
+ if (c.life <= 0) {
+ toRemove.add(c);
+ }
+ }
+ try {
+ confetti.removeAll(toRemove);
+ } catch (ConcurrentModificationException ignored) {
+ }
+ }
+
+ Utils.pushGuiScale(-1);
+ for (Confetti c : confetti) {
+ c.yVel += 1;
+ c.xVel /= 1.1f;
+ c.yVel /= 1.1f;
+ c.xLast = c.x;
+ c.yLast = c.y;
+ c.x += c.xVel;
+ c.y += c.yVel;
+ c.life--;
+ }
+ }
+
+ public static void onChatMessage(ClientChatReceivedEvent e) {
+ if (e.type == 2) return;
+
+ if (NotEnoughUpdates.INSTANCE.config.dungeons.dungeonWinMillis < 100 ||
+ !NotEnoughUpdates.INSTANCE.config.dungeons.enableDungeonWin)
+ return;
+
+ long currentTime = System.currentTimeMillis();
+ String unformatted = Utils.cleanColour(e.message.getUnformattedText());
+
+ //Added two more Resets, can't do Reset+Reset+Reset cause idk?
+ //hypixel please don't randomly add more
+
+ if (e.message.getFormattedText().startsWith(
+ EnumChatFormatting.RESET + "" + EnumChatFormatting.RESET + "" + EnumChatFormatting.RESET + " ")) {
+ if (currentTime - lastDungeonFinish > 30000) {
+ Matcher matcher = TEAM_SCORE_REGEX.matcher(unformatted);
+ if (matcher.find()) {
+ lastDungeonFinish = currentTime;
+ String score = matcher.group(1);
+ switch (score.toUpperCase()) {
+ case "S+":
+ TEAM_SCORE = SPLUS;
+ break;
+ case "S":
+ TEAM_SCORE = S;
+ break;
+ case "A":
+ TEAM_SCORE = A;
+ break;
+ case "B":
+ TEAM_SCORE = B;
+ break;
+ case "C":
+ TEAM_SCORE = C;
+ break;
+ default:
+ TEAM_SCORE = D;
+ break;
+ }
+
+ SES.schedule(() -> NotEnoughUpdates.INSTANCE.sendChatMessage("/showextrastats"), 100L, TimeUnit.MILLISECONDS);
+ }
+ }
+ }
+ if (currentTime - lastDungeonFinish > 100 && currentTime - lastDungeonFinish < 10000) {
+ if (hideChat) {
+ if (text.size() > 50) text.clear();
+
+ e.setCanceled(true);
+ if (unformatted.contains("\u25AC")) {
+ hideChat = false;
+ displayWin();
+ } else {
+ if (unformatted.trim().length() > 0) {
+ text.add(e.message.getFormattedText().substring(6).trim());
+ }
+ }
+ } else {
+ if (unformatted.contains("\u25AC")) {
+ hideChat = true;
+ text.clear();
+ e.setCanceled(true);
+ }
+ }
+
+ }
+ }
+
+ public static void render(float partialTicks) {
+ if (NotEnoughUpdates.INSTANCE.config.dungeons.dungeonWinMillis < 100 ||
+ !NotEnoughUpdates.INSTANCE.config.dungeons.enableDungeonWin)
+ return;
+ int maxTime = Math.min(30000, NotEnoughUpdates.INSTANCE.config.dungeons.dungeonWinMillis);
+ if (System.currentTimeMillis() - startTime > maxTime) return;
+ int deltaTime = (int) (System.currentTimeMillis() - startTime);
+
+ float alpha = Math.max(0, Math.min(1, 1 - (deltaTime - maxTime + 150) / 150f));
+
+ ScaledResolution sr = Utils.pushGuiScale(2);
+
+ if (deltaTime > 600) {
+ float bottom;
+ if (deltaTime < 1000) {
+ bottom = sr.getScaledHeight() / 6f + (float) Math.sin(deltaTime / 1000f * Math.PI) * sr.getScaledHeight() * 4 /
+ 18 + HEIGHT / 2;
+ } else {
+ bottom = sr.getScaledHeight() / 6f + HEIGHT / 2;
+ }
+ for (int i = 0; i < text.size(); i++) {
+ String line = text.get(i);
+ float textCenterY = sr.getScaledHeight() / 6f + HEIGHT / 2 + 7 + i * 10;
+ if (textCenterY > bottom) {
+ int textAlpha = (int) (alpha * (deltaTime > 1000 ? 255 : Math.min(255, (textCenterY - bottom) / 30f * 255)));
+ GlStateManager.enableBlend();
+
+ if (textAlpha > 150) {
+ for (int xOff = -2; xOff <= 2; xOff++) {
+ for (int yOff = -2; yOff <= 2; yOff++) {
+ if (Math.abs(xOff) != Math.abs(yOff)) {
+ Utils.drawStringCentered(
+ Utils.cleanColourNotModifiers(line),
+ Minecraft.getMinecraft().fontRendererObj,
+ sr.getScaledWidth() / 2 + xOff / 2f,
+ textCenterY + yOff / 2f,
+ false,
+ ((textAlpha / Math.max(Math.abs(xOff), Math.abs(yOff))) << 24)
+ );
+ }
+ }
+ }
+ }
+
+ Utils.drawStringCentered(line, Minecraft.getMinecraft().fontRendererObj,
+ sr.getScaledWidth() / 2, textCenterY, false, (textAlpha << 24) | 0x00FFFFFF
+ );
+ }
+ }
+ }
+
+ for (Confetti c : confetti) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(CONFETTI);
+ GlStateManager.color(1, 1, 1, 1);
+ if (c.life >= 15) {
+ GlStateManager.color(1, 1, 1, Math.min(1, c.life / 4f));
+ Utils.drawTexturedRect(
+ c.xLast + (c.x - c.xLast) * partialTicks - 4,
+ c.yLast + (c.y - c.yLast) * partialTicks - 4,
+ 8,
+ 8,
+ (c.id % 4) / 4f,
+ (c.id % 4 + 1) / 4f,
+ (c.id / 4) / 4f,
+ (c.id / 4 + 1) / 4f,
+ GL11.GL_NEAREST
+ );
+ }
+ }
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(TEAM_SCORE);
+ GlStateManager.color(1, 1, 1, alpha);
+
+ GlStateManager.pushMatrix();
+ if (deltaTime < 1600) {
+ GlStateManager.translate(sr.getScaledWidth() / 2, 0, 0);
+ if (deltaTime < 500) {
+ GlStateManager.translate(
+ 0,
+ sr.getScaledHeight() / 2f - Math.sin(deltaTime / 1000f * Math.PI) * sr.getScaledHeight() / 9,
+ 0
+ );
+ } else if (deltaTime < 1000) {
+ GlStateManager.translate(
+ 0,
+ sr.getScaledHeight() / 6f + Math.sin(deltaTime / 1000f * Math.PI) * sr.getScaledHeight() * 4 / 18,
+ 0
+ );
+ } else {
+ GlStateManager.translate(0, sr.getScaledHeight() / 6f, 0);
+ }
+ if (deltaTime < 200) {
+ float scale = deltaTime / 200f;
+ GlStateManager.scale(scale, scale, 1);
+ } else if (deltaTime < 1000) {
+ float scale = 1 + (float) Math.sin((deltaTime - 200) / 800f * Math.PI) * 0.8f;
+ GlStateManager.scale(scale, scale, 1);
+ } else if (deltaTime < 1100) {
+ float scale = 1 + (float) Math.sin((deltaTime - 1000) / 100f * Math.PI) * 0.15f;
+ GlStateManager.scale(scale, scale, 1);
+ }
+
+ if (deltaTime < 600) {
+ GlStateManager.rotate(180 + deltaTime / 600f * 180, 0, 1, 0);
+ GlStateManager.rotate(180 - deltaTime / 600f * 180, 1, 0, 0);
+ GlStateManager.rotate(-180 - deltaTime / 600f * 165, 0, 0, 1);
+ } else if (deltaTime < 1000) {
+ GlStateManager.rotate(15 - (deltaTime - 600) / 400f * 11, 0, 0, 1);
+ } else {
+ float logFac = 1 - (float) Math.log((deltaTime - 1000) / 600f * 1.7f + 1);
+ logFac = logFac * logFac;
+
+ GlStateManager.rotate(4f * logFac, 0, 0, 1);
+ float x = (deltaTime - 1000) / 300f;
+ GlStateManager.rotate((float) (40 * (1 - Math.log(x * 0.85f + 1)) * Math.sin(10 * x * x)), 0, 1, 0);
+ }
+ } else {
+ GlStateManager.translate(sr.getScaledWidth() / 2, sr.getScaledHeight() / 6f, 0);
+ }
+
+ GlStateManager.disableCull();
+
+ Utils.drawTexturedRect(-WIDTH / 2, -HEIGHT / 2, WIDTH, HEIGHT, GL11.GL_NEAREST);
+ GlStateManager.translate(0, 0, -SCALE_FACTOR * 2);
+ Utils.drawTexturedRect(-WIDTH / 2, -HEIGHT / 2, WIDTH, HEIGHT, GL11.GL_NEAREST);
+ GlStateManager.translate(0, 0, SCALE_FACTOR * 2);
+
+ if (deltaTime < 1600) {
+ float epsilon = 0.01f;
+ for (int xIndex = 0; xIndex < 32; xIndex++) {
+ for (int yIndex = 0; yIndex < 16; yIndex++) {
+ float uMin = xIndex / 32f;
+ float uMax = (xIndex + 1) / 32f;
+ float vMin = yIndex / 16f;
+ float vMax = (yIndex + 1) / 16f;
+
+ int x = -WIDTH / 2 + xIndex * SCALE_FACTOR;
+ int y = -HEIGHT / 2 + yIndex * SCALE_FACTOR;
+
+ GlStateManager.enableTexture2D();
+ GlStateManager.enableBlend();
+ GL14.glBlendFuncSeparate(
+ GL11.GL_SRC_ALPHA,
+ GL11.GL_ONE_MINUS_SRC_ALPHA,
+ GL11.GL_ONE,
+ GL11.GL_ONE_MINUS_SRC_ALPHA
+ );
+
+ GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
+ GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
+
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+ //Left
+ worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
+ worldrenderer
+ .pos(x + epsilon, y + SCALE_FACTOR, 0.0D + epsilon)
+ .tex(uMin, vMax).endVertex();
+ worldrenderer
+ .pos(x + epsilon, y, 0.0D + epsilon)
+ .tex(uMax, vMax).endVertex();
+ worldrenderer
+ .pos(x + epsilon, y, -SCALE_FACTOR * 2 - epsilon)
+ .tex(uMax, vMin).endVertex();
+ worldrenderer
+ .pos(x + epsilon, y + SCALE_FACTOR, -SCALE_FACTOR * 2 - epsilon)
+ .tex(uMin, vMin).endVertex();
+ tessellator.draw();
+ //Right
+ worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
+ worldrenderer
+ .pos(x + SCALE_FACTOR - epsilon, y + SCALE_FACTOR, 0.0D + epsilon)
+ .tex(uMin, vMax).endVertex();
+ worldrenderer
+ .pos(x + SCALE_FACTOR - epsilon, y, 0.0D + epsilon)
+ .tex(uMax, vMax).endVertex();
+ worldrenderer
+ .pos(x + SCALE_FACTOR - epsilon, y, -SCALE_FACTOR * 2 - epsilon)
+ .tex(uMax, vMin).endVertex();
+ worldrenderer
+ .pos(x + SCALE_FACTOR - epsilon, y + SCALE_FACTOR, -SCALE_FACTOR * 2 - epsilon)
+ .tex(uMin, vMin).endVertex();
+ tessellator.draw();
+ //Top
+ worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
+ worldrenderer
+ .pos(x + SCALE_FACTOR, y + epsilon, 0.0D + epsilon)
+ .tex(uMin, vMax).endVertex();
+ worldrenderer
+ .pos(x, y + epsilon, 0.0D + epsilon)
+ .tex(uMax, vMax).endVertex();
+ worldrenderer
+ .pos(x, y + epsilon, -SCALE_FACTOR * 2 - epsilon)
+ .tex(uMax, vMin).endVertex();
+ worldrenderer
+ .pos(x + SCALE_FACTOR, y + epsilon, -SCALE_FACTOR * 2 - epsilon)
+ .tex(uMin, vMin).endVertex();
+ tessellator.draw();
+ //Top
+ worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
+ worldrenderer
+ .pos(x + SCALE_FACTOR, y + SCALE_FACTOR - epsilon, 0.0D + epsilon)
+ .tex(uMin, vMax).endVertex();
+ worldrenderer
+ .pos(x, y + SCALE_FACTOR - epsilon, 0.0D + epsilon)
+ .tex(uMax, vMax).endVertex();
+ worldrenderer
+ .pos(x, y + SCALE_FACTOR - epsilon, -SCALE_FACTOR * 2 - epsilon)
+ .tex(uMax, vMin).endVertex();
+ worldrenderer
+ .pos(x + SCALE_FACTOR, y + SCALE_FACTOR - epsilon, -SCALE_FACTOR * 2 - epsilon)
+ .tex(uMin, vMin).endVertex();
+ tessellator.draw();
+
+ GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
+ GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
+
+ GlStateManager.disableBlend();
+ }
+ }
+ }
+
+ GlStateManager.popMatrix();
+
+ for (Confetti c : confetti) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(CONFETTI);
+ GlStateManager.color(1, 1, 1, 1);
+ if (c.life > 0 && c.life < 15) {
+ GlStateManager.color(1, 1, 1, Math.min(1, c.life / 4f));
+ Utils.drawTexturedRect(
+ c.xLast + (c.x - c.xLast) * partialTicks - 4,
+ c.yLast + (c.y - c.yLast) * partialTicks - 4,
+ 8,
+ 8,
+ (c.id % 4) / 4f,
+ (c.id % 4 + 1) / 4f,
+ (c.id / 4) / 4f,
+ (c.id / 4 + 1) / 4f,
+ GL11.GL_NEAREST
+ );
+ }
+ }
+
+ Utils.pushGuiScale(-1);
+
+ GlStateManager.enableBlend();
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java
index 1a420c67..41fa3663 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java
@@ -1,13 +1,12 @@
package io.github.moulberry.notenoughupdates.dungeons;
-import io.github.moulberry.notenoughupdates.core.config.gui.GuiPositionEditor;
-import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils;
-import io.github.moulberry.notenoughupdates.core.util.render.TextRenderUtils;
-import io.github.moulberry.notenoughupdates.options.NEUConfig;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.core.GuiElementColour;
import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorSlider;
import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption;
+import io.github.moulberry.notenoughupdates.core.config.gui.GuiPositionEditor;
+import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils;
+import io.github.moulberry.notenoughupdates.core.util.render.TextRenderUtils;
import io.github.moulberry.notenoughupdates.itemeditor.GuiElementTextField;
import io.github.moulberry.notenoughupdates.options.seperateSections.DungeonMapConfig;
import io.github.moulberry.notenoughupdates.util.SpecialColour;
@@ -30,686 +29,819 @@ import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.io.IOException;
import java.lang.reflect.Field;
-import java.util.*;
import java.util.List;
+import java.util.*;
+
import static io.github.moulberry.notenoughupdates.util.GuiTextures.*;
public class GuiDungeonMapEditor extends GuiScreen {
-
- public static final ResourceLocation BACKGROUND = new ResourceLocation("notenoughupdates:dungeon_map/editor/background.png");
- public static final ResourceLocation BUTTON = new ResourceLocation("notenoughupdates:dungeon_map/editor/button.png");
- private static final DungeonMap demoMap = new DungeonMap();
-
- private int sizeX;
- private int sizeY;
- private int guiLeft;
- private int guiTop;
-
- private List<Button> buttons = new ArrayList<>();
-
- private GuiElementTextField blurField = new GuiElementTextField("", GuiElementTextField.NUM_ONLY | GuiElementTextField.NO_SPACE);
- private GuiElementColour activeColourEditor = null;
-
- private Field clickedSlider;
-
- class Button {
- private int id;
- private int x;
- private int y;
- private String text;
- private Color colour = new Color(-1, true);
- private Field option;
- private String displayName;
- private String desc;
-
- public Button(int id, int x, int y, String text) {
- this(id, x, y, text, null);
- }
-
- public Button(int id, int x, int y, String text, Field option) {
- this.id = id;
- this.x = x;
- this.y = y;
- this.text = text;
- this.option = option;
-
- if(option != null) {
- ConfigOption optionAnnotation = option.getAnnotation(ConfigOption.class);
- displayName = optionAnnotation.name();
- desc = optionAnnotation.desc();
- }
- }
-
- public List<String> getTooltip() {
- if(option == null) {
- return null;
- }
-
- List<String> tooltip = new ArrayList<>();
- tooltip.add(EnumChatFormatting.YELLOW+displayName);
- for(String line : desc.split("\n")) {
- tooltip.add(EnumChatFormatting.AQUA+line);
- }
- return tooltip;
- }
-
- public void render() {
- if(text == null) return;
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(BUTTON);
- if(isButtonPressed(id)) {
- GlStateManager.color(colour.getRed()*0.85f/255f, colour.getGreen()*0.85f/255f,
- colour.getBlue()*0.85f/255f, 1);
- Utils.drawTexturedRect(guiLeft+x, guiTop+y, 48, 16, 1, 0, 1, 0, GL11.GL_NEAREST);
- } else {
- GlStateManager.color(colour.getRed()/255f, colour.getGreen()/255f, colour.getBlue()/255f, 1);
- Utils.drawTexturedRect(guiLeft+x, guiTop+y, 48, 16, GL11.GL_NEAREST);
- }
-
- if(text.length() > 0) {
- Utils.drawStringCenteredScaledMaxWidth(text, Minecraft.getMinecraft().fontRendererObj , guiLeft+x+24, guiTop+y+8, false, 39, 0xFF000000);
- }
- }
-
- }
-
- public GuiDungeonMapEditor() {
- DungeonMapConfig options = NotEnoughUpdates.INSTANCE.config.dungeonMap;
- //Map Border Size
- //buttons.add(new Button(0, 6, 37, "Small", options.dmBorderSize));
- //buttons.add(new Button(1, 52, 37, "Medium", options.dmBorderSize));
- //buttons.add(new Button(2, 98, 37, "Large", options.dmBorderSize));
-
- //Map Rooms Size
- //buttons.add(new Button(3, 6, 67+19, "Small", options.dmRoomSize));
- //buttons.add(new Button(4, 52, 67+19, "Medium", options.dmRoomSize));
- //buttons.add(new Button(5, 98, 67+19, "Large", options.dmRoomSize));
-
- //Map Border Styles
- buttons.add(new Button(6, 6, 97+30, "None"));
- buttons.add(new Button(7, 52, 97+30, "Custom"));
- buttons.add(new Button(8, 98, 97+30, "Stone"));
- buttons.add(new Button(9, 6, 116+30, "Wood"));
- buttons.add(new Button(10, 52, 116+30, "Rustic(S)"));
- buttons.add(new Button(11, 98, 116+30, "Rustic(C)"));
- buttons.add(new Button(12, 6, 135+30, "Fade"));
- buttons.add(new Button(13, 52, 135+30, "Ribbons"));
- buttons.add(new Button(14, 98, 135+30, "Paper"));
- buttons.add(new Button(15, 6, 154+30, "Crimson"));
- buttons.add(new Button(16, 52, 154+30, "Ornate"));
- buttons.add(new Button(17, 98, 154+30, "Dragon"));
-
- try {
- //Dungeon Map
- buttons.add(new Button(18, 20+139, 36, "Yes/No", DungeonMapConfig.class.getDeclaredField("dmEnable")));
- //Center
- buttons.add(new Button(19, 84+139, 36, "Player/Map", DungeonMapConfig.class.getDeclaredField("dmCenterPlayer")));
- //Rotate
- buttons.add(new Button(20, 20+139, 65, "Player/No Rotate", DungeonMapConfig.class.getDeclaredField("dmRotatePlayer")));
- //Icon Style
- buttons.add(new Button(21, 84+139, 65, "Default/Heads", DungeonMapConfig.class.getDeclaredField("dmPlayerHeads")));
- //Check Orient
- buttons.add(new Button(22, 20+139, 94, "Normal/Reorient", DungeonMapConfig.class.getDeclaredField("dmOrientCheck")));
- //Check Center
- buttons.add(new Button(23, 84+139, 94, "Yes/No", DungeonMapConfig.class.getDeclaredField("dmCenterCheck")));
- //Interpolation
- buttons.add(new Button(24, 20+139, 123, "Yes/No", DungeonMapConfig.class.getDeclaredField("dmPlayerInterp")));
- //Compatibility
- buttons.add(new Button(25, 84+139, 123, "Normal/No SHD/No FB/SHD", DungeonMapConfig.class.getDeclaredField("dmCompat")));
-
- //Background
- buttons.add(new Button(26, 20+139, 152, "", DungeonMapConfig.class.getDeclaredField("dmBackgroundColour")));
- //Border
- buttons.add(new Button(27, 84+139, 152, "", DungeonMapConfig.class.getDeclaredField("dmBorderColour")));
-
- //Chroma Mode
- buttons.add(new Button(28, 84+139, 181, "Normal/Scroll", DungeonMapConfig.class.getDeclaredField("dmChromaBorder")));
- } catch(Exception e) {
- e.printStackTrace();
- }
-
- //buttons.add(new Button(29, 52, 86+19, "XLarge", options.dmRoomSize));
- //buttons.add(new Button(30, 52, 56, "XLarge", options.dmBorderSize));
-
- {
- double val = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBackgroundBlur;
- String strVal;
- if(val % 1 == 0) {
- strVal = Integer.toString((int)val);
- } else {
- strVal = Double.toString(val);
- strVal = strVal.replaceAll("(\\.\\d\\d\\d)(?:\\d)+", "$1");
- strVal = strVal.replaceAll("0+$", "");
- }
- blurField.setText(strVal);
- }
- }
-
- @Override
- public void drawScreen(int mouseX, int mouseY, float partialTicks) {
- ScaledResolution scaledResolution = Utils.pushGuiScale(2);
- this.width = scaledResolution.getScaledWidth();
- this.height = scaledResolution.getScaledHeight();
-
- mouseX = Mouse.getEventX() * this.width / this.mc.displayWidth;
- mouseY = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
-
- List<String> tooltipToDisplay = null;
- for(Button button : buttons) {
- if(mouseX >= guiLeft+button.x && mouseX <= guiLeft+button.x+48 &&
- mouseY >= guiTop+button.y-13 && mouseY <= guiTop+button.y+16) {
- if(button.id >= 6 && button.id <= 17) {
- String mapDesc = null;
- String mapCredit = null;
- int id = button.id;
- switch(id) {
- case 6:
- mapDesc = "No Border"; break;
- case 7:
- mapDesc = "Used by custom Resource Packs"; break;
- case 8:
- mapDesc = "Simple gray border"; mapCredit = "TomEngMaster"; break;
- case 9:
- mapDesc = "Viney wood border"; mapCredit = "iDevil4Hell"; break;
- case 10:
- mapDesc = "Steampunk-inspired square border"; mapCredit = "ThatGravyBoat"; break;
- case 11:
- mapDesc = "Steampunk-inspired circular border"; mapCredit = "ThatGravyBoat"; break;
- case 12:
- mapDesc = "Light fade border"; mapCredit = "Qwiken"; break;
- case 13:
- mapDesc = "Simple gray border with red ribbons"; mapCredit = "Sai"; break;
- case 14:
- mapDesc = "Paper border"; mapCredit = "KingJames02st"; break;
- case 15:
- mapDesc = "Nether-inspired border"; mapCredit = "DTRW191"; break;
- case 16:
- mapDesc = "Golden ornate border"; mapCredit = "iDevil4Hell"; break;
- case 17:
- mapDesc = "Stone dragon border"; mapCredit = "ImperiaL"; break;
- }
-
- ArrayList<String> tooltip = new ArrayList<>();
- tooltip.add(EnumChatFormatting.YELLOW+"Border Style");
- tooltip.add(EnumChatFormatting.AQUA+"Customize the look of the dungeon border");
- tooltip.add("");
- if(mapDesc != null) tooltip.add(EnumChatFormatting.YELLOW+"Set to: "+EnumChatFormatting.AQUA+mapDesc);
- if(mapCredit != null) tooltip.add(EnumChatFormatting.YELLOW+"Artist: "+EnumChatFormatting.GOLD+mapCredit);
- tooltipToDisplay = tooltip;
- } else {
- tooltipToDisplay = button.getTooltip();
- }
- break;
- }
- }
-
- this.sizeX = 431;
- this.sizeY = 237;
- this.guiLeft = (this.width - this.sizeX) / 2;
- this.guiTop = (this.height-this.sizeY)/2;
-
- super.drawScreen(mouseX, mouseY, partialTicks);
- drawDefaultBackground();
-
- blurBackground();
- renderBlurredBackground(width, height, guiLeft+2, guiTop+2, sizeX-4, sizeY-4);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(BACKGROUND);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST);
-
- Minecraft.getMinecraft().fontRendererObj.drawString("NEU Dungeon Map Editor", guiLeft+8, guiTop+6, 0xFFB4B4B4);
-
- Utils.drawStringCenteredScaledMaxWidth("Border Size", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+76, guiTop+30, false, 137, 0xFFB4B4B4);
- Utils.drawStringCenteredScaledMaxWidth("Rooms Size", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+76, guiTop+60, false, 137, 0xFFB4B4B4);
- Utils.drawStringCenteredScaledMaxWidth("Icon Scale", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+76, guiTop+90, false, 137, 0xFFB4B4B4);
- Utils.drawStringCenteredScaledMaxWidth("Border Style", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+76, guiTop+120, false, 137, 0xFFB4B4B4);
-
- Utils.drawStringCenteredScaledMaxWidth("Dungeon Map", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+44+139, guiTop+30, false, 60, 0xFFB4B4B4);
- Utils.drawStringCenteredScaledMaxWidth("Center", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+108+139, guiTop+30, false, 60, 0xFFB4B4B4);
-
- Utils.drawStringCenteredScaledMaxWidth("Rotate", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+44+139, guiTop+59, false, 60, 0xFFB4B4B4);
- Utils.drawStringCenteredScaledMaxWidth("Icon Style", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+108+139, guiTop+59, false, 60, 0xFFB4B4B4);
-
- Utils.drawStringCenteredScaledMaxWidth("Check Orient", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+44+139, guiTop+88, false, 60, 0xFFB4B4B4);
- Utils.drawStringCenteredScaledMaxWidth("Check Center", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+108+139, guiTop+88, false, 60, 0xFFB4B4B4);
-
- Utils.drawStringCenteredScaledMaxWidth("Interpolation", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+44+139, guiTop+117, false, 60, 0xFFB4B4B4);
- Utils.drawStringCenteredScaledMaxWidth("Compatibility", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+108+139, guiTop+117, false, 60, 0xFFB4B4B4);
-
- Utils.drawStringCenteredScaledMaxWidth("Background", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+44+139, guiTop+146, false, 60, 0xFFB4B4B4);
- Utils.drawStringCenteredScaledMaxWidth("Border", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+108+139, guiTop+146, false, 60, 0xFFB4B4B4);
-
- Utils.drawStringCenteredScaledMaxWidth("BG Blur", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+44+139, guiTop+175, false, 60, 0xFFB4B4B4);
- Utils.drawStringCenteredScaledMaxWidth("Chroma Type", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+108+139, guiTop+175, false, 60, 0xFFB4B4B4);
-
- Utils.drawStringCenteredScaledMaxWidth("Edit Map Position", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+76, guiTop+209, false, 200, 0xFFB4B4B4);
-
- try {
- drawSlider(DungeonMapConfig.class.getDeclaredField("dmBorderSize"), guiLeft+76, guiTop+45);
- drawSlider(DungeonMapConfig.class.getDeclaredField("dmRoomSize"), guiLeft+76, guiTop+75);
- drawSlider(DungeonMapConfig.class.getDeclaredField("dmIconScale"), guiLeft+76, guiTop+105);
- } catch(Exception e) {
- e.printStackTrace();
- }
-
- DungeonMapConfig options = NotEnoughUpdates.INSTANCE.config.dungeonMap;
- buttons.get(18-6).text = options.dmEnable ? "Enabled" : "Disabled";
- buttons.get(19-6).text = options.dmCenterPlayer ? "Player" : "Map";
- buttons.get(20-6).text = options.dmRotatePlayer ? "Player" : "Vertical";
- buttons.get(21-6).text = options.dmPlayerHeads <= 0 ? "Default" : options.dmPlayerHeads == 1 ? "Heads" : "Heads w/ Border";
- buttons.get(22-6).text = options.dmOrientCheck ? "Orient" : "Off";
- buttons.get(23-6).text = options.dmCenterCheck ? "Center" : "Off";
- buttons.get(24-6).text = options.dmPlayerInterp ? "Interp" : "No Interp";
- buttons.get(25-6).text = options.dmCompat <= 0 ? "Normal" : options.dmCompat >= 2 ? "No FB/SHD" : "No SHD";
-
- buttons.get(26-6).colour = new Color(SpecialColour.specialToChromaRGB(options.dmBackgroundColour));
- buttons.get(27-6).colour = new Color(SpecialColour.specialToChromaRGB(options.dmBorderColour));
-
- buttons.get(28-6).text = options.dmChromaBorder ? "Scroll" : "Normal";
-
- blurField.setSize(48, 16);
- blurField.render(guiLeft+20+139, guiTop+181);
-
- GlStateManager.color(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(button_tex);
- RenderUtils.drawTexturedRect(guiLeft+52, guiTop+215, 48, 16);
- TextRenderUtils.drawStringCenteredScaledMaxWidth("Edit", fontRendererObj, guiLeft+76, guiTop+223,
- false, 48, 0xFF303030);
-
- Map<String, Vec4b> decorations = new HashMap<>();
- Vec4b vec4b = new Vec4b((byte)3, (byte)(((50)-64)*2), (byte)(((40)-64)*2), (byte)((60)*16/360));
- decorations.put(Minecraft.getMinecraft().thePlayer.getName(), vec4b);
-
- HashSet<String> players = new HashSet<>();
- players.add(Minecraft.getMinecraft().thePlayer.getName());
- GlStateManager.color(1, 1, 1, 1);
-
- demoMap.renderMap(guiLeft+357, guiTop+125, NotEnoughUpdates.INSTANCE.colourMap, decorations, 0,
- players, false, partialTicks);
-
- for(Button button : buttons) {
- button.render();
- }
-
- //List<String> textLines, final int mouseX, final int mouseY, final int screenWidth, final int screenHeight, final int maxTextWidth, FontRenderer font
- if(tooltipToDisplay != null) {
- Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, 200, Minecraft.getMinecraft().fontRendererObj);
- }
-
- Utils.pushGuiScale(-1);
-
- if(activeColourEditor != null) {
- activeColourEditor.render();
- }
- }
-
- public void drawSlider(Field option, int centerX, int centerY) {
- float value;
- float minValue;
- float maxValue;
- try {
- value = ((Number)option.get(NotEnoughUpdates.INSTANCE.config.dungeonMap)).floatValue();
-
- ConfigEditorSlider sliderAnnotation = option.getAnnotation(ConfigEditorSlider.class);
- minValue = sliderAnnotation.minValue();
- maxValue = sliderAnnotation.maxValue();
- } catch(Exception e) {
- e.printStackTrace();
- return;
- }
-
- float sliderAmount = Math.max(0, Math.min(1, (value-minValue)/(maxValue-minValue)));
- int sliderAmountI = (int)(96*sliderAmount);
-
- GlStateManager.color(1f, 1f, 1f, 1f);
- Minecraft.getMinecraft().getTextureManager().bindTexture(slider_on_large);
- Utils.drawTexturedRect(centerX-48, centerY-8, sliderAmountI, 16,
- 0, sliderAmount, 0, 1, GL11.GL_NEAREST);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(slider_off_large);
- Utils.drawTexturedRect(centerX-48+sliderAmountI, centerY-8, 96-sliderAmountI, 16,
- sliderAmount, 1, 0, 1, GL11.GL_NEAREST);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(slider_button);
- Utils.drawTexturedRect(centerX-48+sliderAmountI-4, centerY-8, 8, 16,
- 0, 1, 0, 1, GL11.GL_NEAREST);
- }
-
- @Override
- protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
- super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
-
- if(clickedSlider != null) {
- float minValue;
- float maxValue;
- try {
- ConfigEditorSlider sliderAnnotation = clickedSlider.getAnnotation(ConfigEditorSlider.class);
- minValue = sliderAnnotation.minValue();
- maxValue = sliderAnnotation.maxValue();
- } catch(Exception e) {
- e.printStackTrace();
- return;
- }
-
- float sliderAmount = (mouseX - (guiLeft+76-48))/96f;
- double val = minValue+(maxValue-minValue)*sliderAmount;
- if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
- val = Math.round(val);
- }
- float value = (float)Math.max(minValue, Math.min(maxValue, val));
- try {
- if(clickedSlider.getType() == int.class) {
- clickedSlider.set(NotEnoughUpdates.INSTANCE.config.dungeonMap, Math.round(value));
- } else {
- clickedSlider.set(NotEnoughUpdates.INSTANCE.config.dungeonMap, value);
- }
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
-
- }
-
- @Override
- protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
- for(Button button : buttons) {
- if(mouseX >= guiLeft+button.x && mouseX <= guiLeft+button.x+48 &&
- mouseY >= guiTop+button.y && mouseY <= guiTop+button.y+16) {
- buttonClicked(mouseX, mouseY, button.id);
-
- blurField.otherComponentClick();
- return;
- }
- }
-
- clickedSlider = null;
- if(mouseX >= guiLeft+76-48 && mouseX <= guiLeft+76+48) {
- try {
- if(mouseY > guiTop+45-8 && mouseY < guiTop+45+8) {
- clickedSlider = DungeonMapConfig.class.getDeclaredField("dmBorderSize");
- return;
- } else if(mouseY > guiTop+75-8 && mouseY < guiTop+75+8) {
- clickedSlider = DungeonMapConfig.class.getDeclaredField("dmRoomSize");
- return;
- } else if(mouseY > guiTop+105-8 && mouseY < guiTop+105+8) {
- clickedSlider = DungeonMapConfig.class.getDeclaredField("dmIconScale");
- return;
- }
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
-
- if(mouseY > guiTop+181 && mouseY < guiTop+181+16) {
- if(mouseX > guiLeft+20+139 && mouseX < guiLeft+20+139+48) {
- blurField.mouseClicked(mouseX, mouseY, mouseButton);
- return;
- }
- } else if(mouseY > guiTop+215 && mouseY < guiTop+215+16) {
- if(mouseX > guiLeft+52 && mouseX < guiLeft+100) {
- int size = 80 + Math.round(40*NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderSize);
-
- Map<String, Vec4b> decorations = new HashMap<>();
- Vec4b vec4b = new Vec4b((byte)3, (byte)(((50)-64)*2), (byte)(((40)-64)*2), (byte)((60)*16/360));
- decorations.put(Minecraft.getMinecraft().thePlayer.getName(), vec4b);
-
- HashSet<String> players = new HashSet<>();
- players.add(Minecraft.getMinecraft().thePlayer.getName());
- GlStateManager.color(1, 1, 1, 1);
-
- Minecraft.getMinecraft().displayGuiScreen(new GuiPositionEditor(
- NotEnoughUpdates.INSTANCE.config.dungeonMap.dmPosition,
- size, size, () -> {
- ScaledResolution scaledResolution = Utils.pushGuiScale(2);
- demoMap.renderMap(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmPosition.getAbsX(scaledResolution, size)+size/2,
- NotEnoughUpdates.INSTANCE.config.dungeonMap.dmPosition.getAbsY(scaledResolution, size)+size/2,
- NotEnoughUpdates.INSTANCE.colourMap, decorations, 0,
- players, false, 0);
- Utils.pushGuiScale(-1);
- }, () -> {
- }, () -> NotEnoughUpdates.INSTANCE.openGui = new GuiDungeonMapEditor()
- ).withScale(2));
- return;
- }
- }
-
- blurField.otherComponentClick();
- }
-
- @Override
- public void handleMouseInput() throws IOException {
- super.handleMouseInput();
-
- if(activeColourEditor != null) {
- ScaledResolution realRes = new ScaledResolution(Minecraft.getMinecraft());
- int mouseX = Mouse.getEventX() * realRes.getScaledWidth() / this.mc.displayWidth;
- int mouseY = realRes.getScaledHeight() - Mouse.getEventY() * realRes.getScaledHeight() / this.mc.displayHeight - 1;
- activeColourEditor.mouseInput(mouseX, mouseY);
- }
- }
-
- @Override
- public void handleKeyboardInput() throws IOException {
- super.handleKeyboardInput();
-
- if(activeColourEditor != null) {
- activeColourEditor.keyboardInput();
- }
- }
-
- @Override
- protected void keyTyped(char typedChar, int keyCode) throws IOException {
- super.keyTyped(typedChar, keyCode);
-
- if(blurField.getFocus()) {
- blurField.keyTyped(typedChar, keyCode);
-
- try {
- blurField.setCustomBorderColour(-1);
- NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBackgroundBlur = Float.parseFloat(blurField.getText());
- } catch(Exception e) {
- blurField.setCustomBorderColour(Color.RED.getRGB());
- }
- }
- }
-
- private void buttonClicked(int mouseX, int mouseY, int id) {
- DungeonMapConfig options = NotEnoughUpdates.INSTANCE.config.dungeonMap;
- switch (id) {
- case 0:
- options.dmBorderSize = 0; break;
- case 1:
- options.dmBorderSize = 1; break;
- case 2:
- options.dmBorderSize = 2; break;
- case 30:
- options.dmBorderSize = 3; break;
- case 3:
- options.dmRoomSize = 0; break;
- case 4:
- options.dmRoomSize = 1; break;
- case 5:
- options.dmRoomSize = 2; break;
- case 29:
- options.dmRoomSize = 3; break;
- case 18:
- options.dmEnable = !options.dmEnable; break;
- case 19:
- options.dmCenterPlayer = !options.dmCenterPlayer; break;
- case 20:
- options.dmRotatePlayer = !options.dmRotatePlayer; break;
- case 21:
- options.dmPlayerHeads++;
- if(options.dmPlayerHeads > 2) options.dmPlayerHeads = 0; break;
- case 22:
- options.dmOrientCheck = !options.dmOrientCheck; break;
- case 23:
- options.dmCenterCheck = !options.dmCenterCheck; break;
- case 24:
- options.dmPlayerInterp = !options.dmPlayerInterp; break;
- case 25:
- options.dmCompat++;
- if(options.dmCompat > 2) options.dmCompat = 0;
- break;
- case 26: {
- ScaledResolution realRes = new ScaledResolution(Minecraft.getMinecraft());
- mouseX = Mouse.getEventX() * realRes.getScaledWidth() / this.mc.displayWidth;
- mouseY = realRes.getScaledHeight() - Mouse.getEventY() * realRes.getScaledHeight() / this.mc.displayHeight - 1;
- activeColourEditor = new GuiElementColour(mouseX, mouseY, options.dmBackgroundColour,
- (col) -> options.dmBackgroundColour = col, () -> activeColourEditor = null);
- }
- break;
- case 27: {
- ScaledResolution realRes = new ScaledResolution(Minecraft.getMinecraft());
- mouseX = Mouse.getEventX() * realRes.getScaledWidth() / this.mc.displayWidth;
- mouseY = realRes.getScaledHeight() - Mouse.getEventY() * realRes.getScaledHeight() / this.mc.displayHeight - 1;
- activeColourEditor = new GuiElementColour(mouseX, mouseY, options.dmBorderColour,
- (col) -> options.dmBorderColour = col, () -> activeColourEditor = null);
- }
- break;
- case 28:
- options.dmChromaBorder = !options.dmChromaBorder; break;
- default:
- if(id >= 6 && id <= 17) {
- options.dmBorderStyle = id-6; break;
- }
- };
- }
-
- private boolean isButtonPressed(int id) {
- DungeonMapConfig options = NotEnoughUpdates.INSTANCE.config.dungeonMap;
-
- if(id >= 0 && id <= 2) {
- return options.dmBorderSize == id;
- } else if(id >= 3 && id <= 5) {
- return options.dmRoomSize == id-3;
- } else if(id >= 6 && id <= 17) {
- return options.dmBorderStyle == id-6;
- } else if(id == 29) {
- return options.dmRoomSize == 3;
- } else if(id == 30) {
- return options.dmBorderSize == 3;
- }
- return false;
- }
-
- Shader blurShaderHorz = null;
- Framebuffer blurOutputHorz = null;
- Shader blurShaderVert = null;
- Framebuffer blurOutputVert = null;
-
- /**
- * Creates a projection matrix that projects from our coordinate space [0->width; 0->height] to OpenGL coordinate
- * space [-1 -> 1; 1 -> -1] (Note: flipped y-axis).
- *
- * This is so that we can render to and from the framebuffer in a way that is familiar to us, instead of needing to
- * apply scales and translations manually.
- */
- private Matrix4f createProjectionMatrix(int width, int height) {
- Matrix4f projMatrix = new Matrix4f();
- projMatrix.setIdentity();
- projMatrix.m00 = 2.0F / (float)width;
- projMatrix.m11 = 2.0F / (float)(-height);
- projMatrix.m22 = -0.0020001999F;
- projMatrix.m33 = 1.0F;
- projMatrix.m03 = -1.0F;
- projMatrix.m13 = 1.0F;
- projMatrix.m23 = -1.0001999F;
- return projMatrix;
- }
-
- private double lastBgBlurFactor = -1;
- private void blurBackground() {
- if(!OpenGlHelper.isFramebufferEnabled()) return;
-
- int width = Minecraft.getMinecraft().displayWidth;
- int height = Minecraft.getMinecraft().displayHeight;
-
- if(blurOutputHorz == null) {
- blurOutputHorz = new Framebuffer(width, height, false);
- blurOutputHorz.setFramebufferFilter(GL11.GL_NEAREST);
- }
- if(blurOutputVert == null) {
- blurOutputVert = new Framebuffer(width, height, false);
- blurOutputVert.setFramebufferFilter(GL11.GL_NEAREST);
- }
- if(blurOutputHorz.framebufferWidth != width || blurOutputHorz.framebufferHeight != height) {
- blurOutputHorz.createBindFramebuffer(width, height);
- blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height));
- Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
- }
- if(blurOutputVert.framebufferWidth != width || blurOutputVert.framebufferHeight != height) {
- blurOutputVert.createBindFramebuffer(width, height);
- blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height));
- Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
- }
-
- if(blurShaderHorz == null) {
- try {
- blurShaderHorz = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur",
- Minecraft.getMinecraft().getFramebuffer(), blurOutputHorz);
- blurShaderHorz.getShaderManager().getShaderUniform("BlurDir").set(1, 0);
- blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height));
- } catch(Exception e) { }
- }
- if(blurShaderVert == null) {
- try {
- blurShaderVert = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur",
- blurOutputHorz, blurOutputVert);
- blurShaderVert.getShaderManager().getShaderUniform("BlurDir").set(0, 1);
- blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height));
- } catch(Exception e) { }
- }
- if(blurShaderHorz != null && blurShaderVert != null) {
- if(15 != lastBgBlurFactor) {
- blurShaderHorz.getShaderManager().getShaderUniform("Radius").set((float)15);
- blurShaderVert.getShaderManager().getShaderUniform("Radius").set((float)15);
- lastBgBlurFactor = 15;
- }
- GL11.glPushMatrix();
- blurShaderHorz.loadShader(0);
- blurShaderVert.loadShader(0);
- GlStateManager.enableDepth();
- GL11.glPopMatrix();
-
- Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
- }
- }
-
- /**
- * Renders a subsection of the blurred framebuffer on to the corresponding section of the screen.
- * Essentially, this method will "blur" the background inside the bounds specified by [x->x+blurWidth, y->y+blurHeight]
- */
- public void renderBlurredBackground(int width, int height, int x, int y, int blurWidth, int blurHeight) {
- if(!OpenGlHelper.isFramebufferEnabled()) return;
-
- float uMin = x/(float)width;
- float uMax = (x+blurWidth)/(float)width;
- float vMin = (height-y)/(float)height;
- float vMax = (height-y-blurHeight)/(float)height;
-
- blurOutputVert.bindFramebufferTexture();
- GlStateManager.color(1f, 1f, 1f, 1f);
- Utils.drawTexturedRect(x, y, blurWidth, blurHeight, uMin, uMax, vMin, vMax);
- blurOutputVert.unbindFramebufferTexture();
- }
-
+ public static final ResourceLocation BACKGROUND = new ResourceLocation(
+ "notenoughupdates:dungeon_map/editor/background.png");
+ public static final ResourceLocation BUTTON = new ResourceLocation("notenoughupdates:dungeon_map/editor/button.png");
+ private static final DungeonMap demoMap = new DungeonMap();
+
+ private int sizeX;
+ private int sizeY;
+ private int guiLeft;
+ private int guiTop;
+
+ private final List<Button> buttons = new ArrayList<>();
+
+ private final GuiElementTextField blurField = new GuiElementTextField(
+ "",
+ GuiElementTextField.NUM_ONLY | GuiElementTextField.NO_SPACE
+ );
+ private GuiElementColour activeColourEditor = null;
+
+ private Field clickedSlider;
+
+ class Button {
+ private final int id;
+ private final int x;
+ private final int y;
+ private String text;
+ private Color colour = new Color(-1, true);
+ private final Field option;
+ private String displayName;
+ private String desc;
+
+ public Button(int id, int x, int y, String text) {
+ this(id, x, y, text, null);
+ }
+
+ public Button(int id, int x, int y, String text, Field option) {
+ this.id = id;
+ this.x = x;
+ this.y = y;
+ this.text = text;
+ this.option = option;
+
+ if (option != null) {
+ ConfigOption optionAnnotation = option.getAnnotation(ConfigOption.class);
+ displayName = optionAnnotation.name();
+ desc = optionAnnotation.desc();
+ }
+ }
+
+ public List<String> getTooltip() {
+ if (option == null) {
+ return null;
+ }
+
+ List<String> tooltip = new ArrayList<>();
+ tooltip.add(EnumChatFormatting.YELLOW + displayName);
+ for (String line : desc.split("\n")) {
+ tooltip.add(EnumChatFormatting.AQUA + line);
+ }
+ return tooltip;
+ }
+
+ public void render() {
+ if (text == null) return;
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(BUTTON);
+ if (isButtonPressed(id)) {
+ GlStateManager.color(colour.getRed() * 0.85f / 255f, colour.getGreen() * 0.85f / 255f,
+ colour.getBlue() * 0.85f / 255f, 1
+ );
+ Utils.drawTexturedRect(guiLeft + x, guiTop + y, 48, 16, 1, 0, 1, 0, GL11.GL_NEAREST);
+ } else {
+ GlStateManager.color(colour.getRed() / 255f, colour.getGreen() / 255f, colour.getBlue() / 255f, 1);
+ Utils.drawTexturedRect(guiLeft + x, guiTop + y, 48, 16, GL11.GL_NEAREST);
+ }
+
+ if (text.length() > 0) {
+ Utils.drawStringCenteredScaledMaxWidth(
+ text,
+ Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + x + 24,
+ guiTop + y + 8,
+ false,
+ 39,
+ 0xFF000000
+ );
+ }
+ }
+
+ }
+
+ public GuiDungeonMapEditor() {
+ DungeonMapConfig options = NotEnoughUpdates.INSTANCE.config.dungeonMap;
+ //Map Border Size
+ //buttons.add(new Button(0, 6, 37, "Small", options.dmBorderSize));
+ //buttons.add(new Button(1, 52, 37, "Medium", options.dmBorderSize));
+ //buttons.add(new Button(2, 98, 37, "Large", options.dmBorderSize));
+
+ //Map Rooms Size
+ //buttons.add(new Button(3, 6, 67+19, "Small", options.dmRoomSize));
+ //buttons.add(new Button(4, 52, 67+19, "Medium", options.dmRoomSize));
+ //buttons.add(new Button(5, 98, 67+19, "Large", options.dmRoomSize));
+
+ //Map Border Styles
+ buttons.add(new Button(6, 6, 97 + 30, "None"));
+ buttons.add(new Button(7, 52, 97 + 30, "Custom"));
+ buttons.add(new Button(8, 98, 97 + 30, "Stone"));
+ buttons.add(new Button(9, 6, 116 + 30, "Wood"));
+ buttons.add(new Button(10, 52, 116 + 30, "Rustic(S)"));
+ buttons.add(new Button(11, 98, 116 + 30, "Rustic(C)"));
+ buttons.add(new Button(12, 6, 135 + 30, "Fade"));
+ buttons.add(new Button(13, 52, 135 + 30, "Ribbons"));
+ buttons.add(new Button(14, 98, 135 + 30, "Paper"));
+ buttons.add(new Button(15, 6, 154 + 30, "Crimson"));
+ buttons.add(new Button(16, 52, 154 + 30, "Ornate"));
+ buttons.add(new Button(17, 98, 154 + 30, "Dragon"));
+
+ try {
+ //Dungeon Map
+ buttons.add(new Button(18, 20 + 139, 36, "Yes/No", DungeonMapConfig.class.getDeclaredField("dmEnable")));
+ //Center
+ buttons.add(new Button(
+ 19,
+ 84 + 139,
+ 36,
+ "Player/Map",
+ DungeonMapConfig.class.getDeclaredField("dmCenterPlayer")
+ ));
+ //Rotate
+ buttons.add(new Button(
+ 20,
+ 20 + 139,
+ 65,
+ "Player/No Rotate",
+ DungeonMapConfig.class.getDeclaredField("dmRotatePlayer")
+ ));
+ //Icon Style
+ buttons.add(new Button(
+ 21,
+ 84 + 139,
+ 65,
+ "Default/Heads",
+ DungeonMapConfig.class.getDeclaredField("dmPlayerHeads")
+ ));
+ //Check Orient
+ buttons.add(new Button(
+ 22,
+ 20 + 139,
+ 94,
+ "Normal/Reorient",
+ DungeonMapConfig.class.getDeclaredField("dmOrientCheck")
+ ));
+ //Check Center
+ buttons.add(new Button(23, 84 + 139, 94, "Yes/No", DungeonMapConfig.class.getDeclaredField("dmCenterCheck")));
+ //Interpolation
+ buttons.add(new Button(24, 20 + 139, 123, "Yes/No", DungeonMapConfig.class.getDeclaredField("dmPlayerInterp")));
+ //Compatibility
+ buttons.add(new Button(
+ 25,
+ 84 + 139,
+ 123,
+ "Normal/No SHD/No FB/SHD",
+ DungeonMapConfig.class.getDeclaredField("dmCompat")
+ ));
+
+ //Background
+ buttons.add(new Button(26, 20 + 139, 152, "", DungeonMapConfig.class.getDeclaredField("dmBackgroundColour")));
+ //Border
+ buttons.add(new Button(27, 84 + 139, 152, "", DungeonMapConfig.class.getDeclaredField("dmBorderColour")));
+
+ //Chroma Mode
+ buttons.add(new Button(
+ 28,
+ 84 + 139,
+ 181,
+ "Normal/Scroll",
+ DungeonMapConfig.class.getDeclaredField("dmChromaBorder")
+ ));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ //buttons.add(new Button(29, 52, 86+19, "XLarge", options.dmRoomSize));
+ //buttons.add(new Button(30, 52, 56, "XLarge", options.dmBorderSize));
+
+ {
+ double val = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBackgroundBlur;
+ String strVal;
+ if (val % 1 == 0) {
+ strVal = Integer.toString((int) val);
+ } else {
+ strVal = Double.toString(val);
+ strVal = strVal.replaceAll("(\\.\\d\\d\\d)(?:\\d)+", "$1");
+ strVal = strVal.replaceAll("0+$", "");
+ }
+ blurField.setText(strVal);
+ }
+ }
+
+ @Override
+ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
+ ScaledResolution scaledResolution = Utils.pushGuiScale(2);
+ this.width = scaledResolution.getScaledWidth();
+ this.height = scaledResolution.getScaledHeight();
+
+ mouseX = Mouse.getEventX() * this.width / this.mc.displayWidth;
+ mouseY = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
+
+ List<String> tooltipToDisplay = null;
+ for (Button button : buttons) {
+ if (mouseX >= guiLeft + button.x && mouseX <= guiLeft + button.x + 48 &&
+ mouseY >= guiTop + button.y - 13 && mouseY <= guiTop + button.y + 16) {
+ if (button.id >= 6 && button.id <= 17) {
+ String mapDesc = null;
+ String mapCredit = null;
+ int id = button.id;
+ switch (id) {
+ case 6:
+ mapDesc = "No Border";
+ break;
+ case 7:
+ mapDesc = "Used by custom Resource Packs";
+ break;
+ case 8:
+ mapDesc = "Simple gray border";
+ mapCredit = "TomEngMaster";
+ break;
+ case 9:
+ mapDesc = "Viney wood border";
+ mapCredit = "iDevil4Hell";
+ break;
+ case 10:
+ mapDesc = "Steampunk-inspired square border";
+ mapCredit = "ThatGravyBoat";
+ break;
+ case 11:
+ mapDesc = "Steampunk-inspired circular border";
+ mapCredit = "ThatGravyBoat";
+ break;
+ case 12:
+ mapDesc = "Light fade border";
+ mapCredit = "Qwiken";
+ break;
+ case 13:
+ mapDesc = "Simple gray border with red ribbons";
+ mapCredit = "Sai";
+ break;
+ case 14:
+ mapDesc = "Paper border";
+ mapCredit = "KingJames02st";
+ break;
+ case 15:
+ mapDesc = "Nether-inspired border";
+ mapCredit = "DTRW191";
+ break;
+ case 16:
+ mapDesc = "Golden ornate border";
+ mapCredit = "iDevil4Hell";
+ break;
+ case 17:
+ mapDesc = "Stone dragon border";
+ mapCredit = "ImperiaL";
+ break;
+ }
+
+ ArrayList<String> tooltip = new ArrayList<>();
+ tooltip.add(EnumChatFormatting.YELLOW + "Border Style");
+ tooltip.add(EnumChatFormatting.AQUA + "Customize the look of the dungeon border");
+ tooltip.add("");
+ if (mapDesc != null)
+ tooltip.add(EnumChatFormatting.YELLOW + "Set to: " + EnumChatFormatting.AQUA + mapDesc);
+ if (mapCredit != null)
+ tooltip.add(EnumChatFormatting.YELLOW + "Artist: " + EnumChatFormatting.GOLD + mapCredit);
+ tooltipToDisplay = tooltip;
+ } else {
+ tooltipToDisplay = button.getTooltip();
+ }
+ break;
+ }
+ }
+
+ this.sizeX = 431;
+ this.sizeY = 237;
+ this.guiLeft = (this.width - this.sizeX) / 2;
+ this.guiTop = (this.height - this.sizeY) / 2;
+
+ super.drawScreen(mouseX, mouseY, partialTicks);
+ drawDefaultBackground();
+
+ blurBackground();
+ renderBlurredBackground(width, height, guiLeft + 2, guiTop + 2, sizeX - 4, sizeY - 4);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(BACKGROUND);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST);
+
+ Minecraft.getMinecraft().fontRendererObj.drawString("NEU Dungeon Map Editor", guiLeft + 8, guiTop + 6, 0xFFB4B4B4);
+
+ Utils.drawStringCenteredScaledMaxWidth("Border Size", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 76, guiTop + 30, false, 137, 0xFFB4B4B4
+ );
+ Utils.drawStringCenteredScaledMaxWidth("Rooms Size", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 76, guiTop + 60, false, 137, 0xFFB4B4B4
+ );
+ Utils.drawStringCenteredScaledMaxWidth("Icon Scale", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 76, guiTop + 90, false, 137, 0xFFB4B4B4
+ );
+ Utils.drawStringCenteredScaledMaxWidth("Border Style", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 76, guiTop + 120, false, 137, 0xFFB4B4B4
+ );
+
+ Utils.drawStringCenteredScaledMaxWidth("Dungeon Map", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 44 + 139, guiTop + 30, false, 60, 0xFFB4B4B4
+ );
+ Utils.drawStringCenteredScaledMaxWidth("Center", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 108 + 139, guiTop + 30, false, 60, 0xFFB4B4B4
+ );
+
+ Utils.drawStringCenteredScaledMaxWidth("Rotate", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 44 + 139, guiTop + 59, false, 60, 0xFFB4B4B4
+ );
+ Utils.drawStringCenteredScaledMaxWidth("Icon Style", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 108 + 139, guiTop + 59, false, 60, 0xFFB4B4B4
+ );
+
+ Utils.drawStringCenteredScaledMaxWidth("Check Orient", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 44 + 139, guiTop + 88, false, 60, 0xFFB4B4B4
+ );
+ Utils.drawStringCenteredScaledMaxWidth("Check Center", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 108 + 139, guiTop + 88, false, 60, 0xFFB4B4B4
+ );
+
+ Utils.drawStringCenteredScaledMaxWidth("Interpolation", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 44 + 139, guiTop + 117, false, 60, 0xFFB4B4B4
+ );
+ Utils.drawStringCenteredScaledMaxWidth("Compatibility", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 108 + 139, guiTop + 117, false, 60, 0xFFB4B4B4
+ );
+
+ Utils.drawStringCenteredScaledMaxWidth("Background", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 44 + 139, guiTop + 146, false, 60, 0xFFB4B4B4
+ );
+ Utils.drawStringCenteredScaledMaxWidth("Border", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 108 + 139, guiTop + 146, false, 60, 0xFFB4B4B4
+ );
+
+ Utils.drawStringCenteredScaledMaxWidth("BG Blur", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 44 + 139, guiTop + 175, false, 60, 0xFFB4B4B4
+ );
+ Utils.drawStringCenteredScaledMaxWidth("Chroma Type", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 108 + 139, guiTop + 175, false, 60, 0xFFB4B4B4
+ );
+
+ Utils.drawStringCenteredScaledMaxWidth("Edit Map Position", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 76, guiTop + 209, false, 200, 0xFFB4B4B4
+ );
+
+ try {
+ drawSlider(DungeonMapConfig.class.getDeclaredField("dmBorderSize"), guiLeft + 76, guiTop + 45);
+ drawSlider(DungeonMapConfig.class.getDeclaredField("dmRoomSize"), guiLeft + 76, guiTop + 75);
+ drawSlider(DungeonMapConfig.class.getDeclaredField("dmIconScale"), guiLeft + 76, guiTop + 105);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ DungeonMapConfig options = NotEnoughUpdates.INSTANCE.config.dungeonMap;
+ buttons.get(18 - 6).text = options.dmEnable ? "Enabled" : "Disabled";
+ buttons.get(19 - 6).text = options.dmCenterPlayer ? "Player" : "Map";
+ buttons.get(20 - 6).text = options.dmRotatePlayer ? "Player" : "Vertical";
+ buttons.get(21 - 6).text =
+ options.dmPlayerHeads <= 0 ? "Default" : options.dmPlayerHeads == 1 ? "Heads" : "Heads w/ Border";
+ buttons.get(22 - 6).text = options.dmOrientCheck ? "Orient" : "Off";
+ buttons.get(23 - 6).text = options.dmCenterCheck ? "Center" : "Off";
+ buttons.get(24 - 6).text = options.dmPlayerInterp ? "Interp" : "No Interp";
+ buttons.get(25 - 6).text = options.dmCompat <= 0 ? "Normal" : options.dmCompat >= 2 ? "No FB/SHD" : "No SHD";
+
+ buttons.get(26 - 6).colour = new Color(SpecialColour.specialToChromaRGB(options.dmBackgroundColour));
+ buttons.get(27 - 6).colour = new Color(SpecialColour.specialToChromaRGB(options.dmBorderColour));
+
+ buttons.get(28 - 6).text = options.dmChromaBorder ? "Scroll" : "Normal";
+
+ blurField.setSize(48, 16);
+ blurField.render(guiLeft + 20 + 139, guiTop + 181);
+
+ GlStateManager.color(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(button_tex);
+ RenderUtils.drawTexturedRect(guiLeft + 52, guiTop + 215, 48, 16);
+ TextRenderUtils.drawStringCenteredScaledMaxWidth("Edit", fontRendererObj, guiLeft + 76, guiTop + 223,
+ false, 48, 0xFF303030
+ );
+
+ Map<String, Vec4b> decorations = new HashMap<>();
+ Vec4b vec4b = new Vec4b((byte) 3, (byte) (((50) - 64) * 2), (byte) (((40) - 64) * 2), (byte) ((60) * 16 / 360));
+ decorations.put(Minecraft.getMinecraft().thePlayer.getName(), vec4b);
+
+ HashSet<String> players = new HashSet<>();
+ players.add(Minecraft.getMinecraft().thePlayer.getName());
+ GlStateManager.color(1, 1, 1, 1);
+
+ demoMap.renderMap(guiLeft + 357, guiTop + 125, NotEnoughUpdates.INSTANCE.colourMap, decorations, 0,
+ players, false, partialTicks
+ );
+
+ for (Button button : buttons) {
+ button.render();
+ }
+
+ //List<String> textLines, final int mouseX, final int mouseY, final int screenWidth, final int screenHeight, final int maxTextWidth, FontRenderer font
+ if (tooltipToDisplay != null) {
+ Utils.drawHoveringText(
+ tooltipToDisplay,
+ mouseX,
+ mouseY,
+ width,
+ height,
+ 200,
+ Minecraft.getMinecraft().fontRendererObj
+ );
+ }
+
+ Utils.pushGuiScale(-1);
+
+ if (activeColourEditor != null) {
+ activeColourEditor.render();
+ }
+ }
+
+ public void drawSlider(Field option, int centerX, int centerY) {
+ float value;
+ float minValue;
+ float maxValue;
+ try {
+ value = ((Number) option.get(NotEnoughUpdates.INSTANCE.config.dungeonMap)).floatValue();
+
+ ConfigEditorSlider sliderAnnotation = option.getAnnotation(ConfigEditorSlider.class);
+ minValue = sliderAnnotation.minValue();
+ maxValue = sliderAnnotation.maxValue();
+ } catch (Exception e) {
+ e.printStackTrace();
+ return;
+ }
+
+ float sliderAmount = Math.max(0, Math.min(1, (value - minValue) / (maxValue - minValue)));
+ int sliderAmountI = (int) (96 * sliderAmount);
+
+ GlStateManager.color(1f, 1f, 1f, 1f);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(slider_on_large);
+ Utils.drawTexturedRect(centerX - 48, centerY - 8, sliderAmountI, 16,
+ 0, sliderAmount, 0, 1, GL11.GL_NEAREST
+ );
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(slider_off_large);
+ Utils.drawTexturedRect(centerX - 48 + sliderAmountI, centerY - 8, 96 - sliderAmountI, 16,
+ sliderAmount, 1, 0, 1, GL11.GL_NEAREST
+ );
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(slider_button);
+ Utils.drawTexturedRect(centerX - 48 + sliderAmountI - 4, centerY - 8, 8, 16,
+ 0, 1, 0, 1, GL11.GL_NEAREST
+ );
+ }
+
+ @Override
+ protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
+ super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
+
+ if (clickedSlider != null) {
+ float minValue;
+ float maxValue;
+ try {
+ ConfigEditorSlider sliderAnnotation = clickedSlider.getAnnotation(ConfigEditorSlider.class);
+ minValue = sliderAnnotation.minValue();
+ maxValue = sliderAnnotation.maxValue();
+ } catch (Exception e) {
+ e.printStackTrace();
+ return;
+ }
+
+ float sliderAmount = (mouseX - (guiLeft + 76 - 48)) / 96f;
+ double val = minValue + (maxValue - minValue) * sliderAmount;
+ if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
+ val = Math.round(val);
+ }
+ float value = (float) Math.max(minValue, Math.min(maxValue, val));
+ try {
+ if (clickedSlider.getType() == int.class) {
+ clickedSlider.set(NotEnoughUpdates.INSTANCE.config.dungeonMap, Math.round(value));
+ } else {
+ clickedSlider.set(NotEnoughUpdates.INSTANCE.config.dungeonMap, value);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ }
+
+ @Override
+ protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
+ for (Button button : buttons) {
+ if (mouseX >= guiLeft + button.x && mouseX <= guiLeft + button.x + 48 &&
+ mouseY >= guiTop + button.y && mouseY <= guiTop + button.y + 16) {
+ buttonClicked(mouseX, mouseY, button.id);
+
+ blurField.otherComponentClick();
+ return;
+ }
+ }
+
+ clickedSlider = null;
+ if (mouseX >= guiLeft + 76 - 48 && mouseX <= guiLeft + 76 + 48) {
+ try {
+ if (mouseY > guiTop + 45 - 8 && mouseY < guiTop + 45 + 8) {
+ clickedSlider = DungeonMapConfig.class.getDeclaredField("dmBorderSize");
+ return;
+ } else if (mouseY > guiTop + 75 - 8 && mouseY < guiTop + 75 + 8) {
+ clickedSlider = DungeonMapConfig.class.getDeclaredField("dmRoomSize");
+ return;
+ } else if (mouseY > guiTop + 105 - 8 && mouseY < guiTop + 105 + 8) {
+ clickedSlider = DungeonMapConfig.class.getDeclaredField("dmIconScale");
+ return;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ if (mouseY > guiTop + 181 && mouseY < guiTop + 181 + 16) {
+ if (mouseX > guiLeft + 20 + 139 && mouseX < guiLeft + 20 + 139 + 48) {
+ blurField.mouseClicked(mouseX, mouseY, mouseButton);
+ return;
+ }
+ } else if (mouseY > guiTop + 215 && mouseY < guiTop + 215 + 16) {
+ if (mouseX > guiLeft + 52 && mouseX < guiLeft + 100) {
+ int size = 80 + Math.round(40 * NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderSize);
+
+ Map<String, Vec4b> decorations = new HashMap<>();
+ Vec4b vec4b = new Vec4b((byte) 3, (byte) (((50) - 64) * 2), (byte) (((40) - 64) * 2), (byte) ((60) * 16 / 360));
+ decorations.put(Minecraft.getMinecraft().thePlayer.getName(), vec4b);
+
+ HashSet<String> players = new HashSet<>();
+ players.add(Minecraft.getMinecraft().thePlayer.getName());
+ GlStateManager.color(1, 1, 1, 1);
+
+ Minecraft.getMinecraft().displayGuiScreen(new GuiPositionEditor(
+ NotEnoughUpdates.INSTANCE.config.dungeonMap.dmPosition,
+ size, size, () -> {
+ ScaledResolution scaledResolution = Utils.pushGuiScale(2);
+ demoMap.renderMap(
+ NotEnoughUpdates.INSTANCE.config.dungeonMap.dmPosition.getAbsX(scaledResolution, size) + size / 2,
+ NotEnoughUpdates.INSTANCE.config.dungeonMap.dmPosition.getAbsY(scaledResolution, size) + size / 2,
+ NotEnoughUpdates.INSTANCE.colourMap,
+ decorations,
+ 0,
+ players,
+ false,
+ 0
+ );
+ Utils.pushGuiScale(-1);
+ }, () -> {}, () -> NotEnoughUpdates.INSTANCE.openGui = new GuiDungeonMapEditor()
+ ).withScale(2));
+ return;
+ }
+ }
+
+ blurField.otherComponentClick();
+ }
+
+ @Override
+ public void handleMouseInput() throws IOException {
+ super.handleMouseInput();
+
+ if (activeColourEditor != null) {
+ ScaledResolution realRes = new ScaledResolution(Minecraft.getMinecraft());
+ int mouseX = Mouse.getEventX() * realRes.getScaledWidth() / this.mc.displayWidth;
+ int mouseY =
+ realRes.getScaledHeight() - Mouse.getEventY() * realRes.getScaledHeight() / this.mc.displayHeight - 1;
+ activeColourEditor.mouseInput(mouseX, mouseY);
+ }
+ }
+
+ @Override
+ public void handleKeyboardInput() throws IOException {
+ super.handleKeyboardInput();
+
+ if (activeColourEditor != null) {
+ activeColourEditor.keyboardInput();
+ }
+ }
+
+ @Override
+ protected void keyTyped(char typedChar, int keyCode) throws IOException {
+ super.keyTyped(typedChar, keyCode);
+
+ if (blurField.getFocus()) {
+ blurField.keyTyped(typedChar, keyCode);
+
+ try {
+ blurField.setCustomBorderColour(-1);
+ NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBackgroundBlur = Float.parseFloat(blurField.getText());
+ } catch (Exception e) {
+ blurField.setCustomBorderColour(Color.RED.getRGB());
+ }
+ }
+ }
+
+ private void buttonClicked(int mouseX, int mouseY, int id) {
+ DungeonMapConfig options = NotEnoughUpdates.INSTANCE.config.dungeonMap;
+ switch (id) {
+ case 0:
+ options.dmBorderSize = 0;
+ break;
+ case 1:
+ options.dmBorderSize = 1;
+ break;
+ case 2:
+ options.dmBorderSize = 2;
+ break;
+ case 30:
+ options.dmBorderSize = 3;
+ break;
+ case 3:
+ options.dmRoomSize = 0;
+ break;
+ case 4:
+ options.dmRoomSize = 1;
+ break;
+ case 5:
+ options.dmRoomSize = 2;
+ break;
+ case 29:
+ options.dmRoomSize = 3;
+ break;
+ case 18:
+ options.dmEnable = !options.dmEnable;
+ break;
+ case 19:
+ options.dmCenterPlayer = !options.dmCenterPlayer;
+ break;
+ case 20:
+ options.dmRotatePlayer = !options.dmRotatePlayer;
+ break;
+ case 21:
+ options.dmPlayerHeads++;
+ if (options.dmPlayerHeads > 2) options.dmPlayerHeads = 0;
+ break;
+ case 22:
+ options.dmOrientCheck = !options.dmOrientCheck;
+ break;
+ case 23:
+ options.dmCenterCheck = !options.dmCenterCheck;
+ break;
+ case 24:
+ options.dmPlayerInterp = !options.dmPlayerInterp;
+ break;
+ case 25:
+ options.dmCompat++;
+ if (options.dmCompat > 2) options.dmCompat = 0;
+ break;
+ case 26: {
+ ScaledResolution realRes = new ScaledResolution(Minecraft.getMinecraft());
+ mouseX = Mouse.getEventX() * realRes.getScaledWidth() / this.mc.displayWidth;
+ mouseY = realRes.getScaledHeight() - Mouse.getEventY() * realRes.getScaledHeight() / this.mc.displayHeight - 1;
+ activeColourEditor = new GuiElementColour(mouseX, mouseY, options.dmBackgroundColour,
+ (col) -> options.dmBackgroundColour = col, () -> activeColourEditor = null
+ );
+ }
+ break;
+ case 27: {
+ ScaledResolution realRes = new ScaledResolution(Minecraft.getMinecraft());
+ mouseX = Mouse.getEventX() * realRes.getScaledWidth() / this.mc.displayWidth;
+ mouseY = realRes.getScaledHeight() - Mouse.getEventY() * realRes.getScaledHeight() / this.mc.displayHeight - 1;
+ activeColourEditor = new GuiElementColour(mouseX, mouseY, options.dmBorderColour,
+ (col) -> options.dmBorderColour = col, () -> activeColourEditor = null
+ );
+ }
+ break;
+ case 28:
+ options.dmChromaBorder = !options.dmChromaBorder;
+ break;
+ default:
+ if (id >= 6 && id <= 17) {
+ options.dmBorderStyle = id - 6;
+ break;
+ }
+ }
+ }
+
+ private boolean isButtonPressed(int id) {
+ DungeonMapConfig options = NotEnoughUpdates.INSTANCE.config.dungeonMap;
+
+ if (id >= 0 && id <= 2) {
+ return options.dmBorderSize == id;
+ } else if (id >= 3 && id <= 5) {
+ return options.dmRoomSize == id - 3;
+ } else if (id >= 6 && id <= 17) {
+ return options.dmBorderStyle == id - 6;
+ } else if (id == 29) {
+ return options.dmRoomSize == 3;
+ } else if (id == 30) {
+ return options.dmBorderSize == 3;
+ }
+ return false;
+ }
+
+ Shader blurShaderHorz = null;
+ Framebuffer blurOutputHorz = null;
+ Shader blurShaderVert = null;
+ Framebuffer blurOutputVert = null;
+
+ /**
+ * Creates a projection matrix that projects from our coordinate space [0->width; 0->height] to OpenGL coordinate
+ * space [-1 -> 1; 1 -> -1] (Note: flipped y-axis).
+ * <p>
+ * This is so that we can render to and from the framebuffer in a way that is familiar to us, instead of needing to
+ * apply scales and translations manually.
+ */
+ private Matrix4f createProjectionMatrix(int width, int height) {
+ Matrix4f projMatrix = new Matrix4f();
+ projMatrix.setIdentity();
+ projMatrix.m00 = 2.0F / (float) width;
+ projMatrix.m11 = 2.0F / (float) (-height);
+ projMatrix.m22 = -0.0020001999F;
+ projMatrix.m33 = 1.0F;
+ projMatrix.m03 = -1.0F;
+ projMatrix.m13 = 1.0F;
+ projMatrix.m23 = -1.0001999F;
+ return projMatrix;
+ }
+
+ private double lastBgBlurFactor = -1;
+
+ private void blurBackground() {
+ if (!OpenGlHelper.isFramebufferEnabled()) return;
+
+ int width = Minecraft.getMinecraft().displayWidth;
+ int height = Minecraft.getMinecraft().displayHeight;
+
+ if (blurOutputHorz == null) {
+ blurOutputHorz = new Framebuffer(width, height, false);
+ blurOutputHorz.setFramebufferFilter(GL11.GL_NEAREST);
+ }
+ if (blurOutputVert == null) {
+ blurOutputVert = new Framebuffer(width, height, false);
+ blurOutputVert.setFramebufferFilter(GL11.GL_NEAREST);
+ }
+ if (blurOutputHorz.framebufferWidth != width || blurOutputHorz.framebufferHeight != height) {
+ blurOutputHorz.createBindFramebuffer(width, height);
+ blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height));
+ Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
+ }
+ if (blurOutputVert.framebufferWidth != width || blurOutputVert.framebufferHeight != height) {
+ blurOutputVert.createBindFramebuffer(width, height);
+ blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height));
+ Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
+ }
+
+ if (blurShaderHorz == null) {
+ try {
+ blurShaderHorz = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur",
+ Minecraft.getMinecraft().getFramebuffer(), blurOutputHorz
+ );
+ blurShaderHorz.getShaderManager().getShaderUniform("BlurDir").set(1, 0);
+ blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height));
+ } catch (Exception ignored) {
+ }
+ }
+ if (blurShaderVert == null) {
+ try {
+ blurShaderVert = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur",
+ blurOutputHorz, blurOutputVert
+ );
+ blurShaderVert.getShaderManager().getShaderUniform("BlurDir").set(0, 1);
+ blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height));
+ } catch (Exception ignored) {
+ }
+ }
+ if (blurShaderHorz != null && blurShaderVert != null) {
+ if (15 != lastBgBlurFactor) {
+ blurShaderHorz.getShaderManager().getShaderUniform("Radius").set((float) 15);
+ blurShaderVert.getShaderManager().getShaderUniform("Radius").set((float) 15);
+ lastBgBlurFactor = 15;
+ }
+ GL11.glPushMatrix();
+ blurShaderHorz.loadShader(0);
+ blurShaderVert.loadShader(0);
+ GlStateManager.enableDepth();
+ GL11.glPopMatrix();
+
+ Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
+ }
+ }
+
+ /**
+ * Renders a subsection of the blurred framebuffer on to the corresponding section of the screen.
+ * Essentially, this method will "blur" the background inside the bounds specified by [x->x+blurWidth, y->y+blurHeight]
+ */
+ public void renderBlurredBackground(int width, int height, int x, int y, int blurWidth, int blurHeight) {
+ if (!OpenGlHelper.isFramebufferEnabled()) return;
+
+ float uMin = x / (float) width;
+ float uMax = (x + blurWidth) / (float) width;
+ float vMin = (height - y) / (float) height;
+ float vMax = (height - y - blurHeight) / (float) height;
+
+ blurOutputVert.bindFramebufferTexture();
+ GlStateManager.color(1f, 1f, 1f, 1f);
+ Utils.drawTexturedRect(x, y, blurWidth, blurHeight, uMin, uMax, vMin, vMax);
+ blurOutputVert.unbindFramebufferTexture();
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/events/NEUEvent.java b/src/main/java/io/github/moulberry/notenoughupdates/events/NEUEvent.java
new file mode 100644
index 00000000..a2c82070
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/events/NEUEvent.java
@@ -0,0 +1,11 @@
+package io.github.moulberry.notenoughupdates.events;
+
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.fml.common.eventhandler.Event;
+
+public class NEUEvent extends Event {
+ public boolean post() {
+ MinecraftForge.EVENT_BUS.post(this);
+ return isCancelable() && isCanceled();
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/events/OnBlockBreakSoundEffect.java b/src/main/java/io/github/moulberry/notenoughupdates/events/OnBlockBreakSoundEffect.java
new file mode 100644
index 00000000..aeffa7da
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/events/OnBlockBreakSoundEffect.java
@@ -0,0 +1,40 @@
+package io.github.moulberry.notenoughupdates.events;
+
+import net.minecraft.block.state.BlockState;
+import net.minecraft.block.state.IBlockState;
+import net.minecraft.client.audio.ISound;
+import net.minecraft.util.BlockPos;
+
+public class OnBlockBreakSoundEffect extends NEUEvent {
+
+ private ISound sound;
+ private final BlockPos position;
+ private final IBlockState block;
+
+ public OnBlockBreakSoundEffect(ISound sound, BlockPos position, IBlockState block) {
+ this.sound = sound;
+ this.position = position;
+ this.block = block;
+ }
+
+ @Override
+ public boolean isCancelable() {
+ return true;
+ }
+
+ public BlockPos getPosition() {
+ return position;
+ }
+
+ public IBlockState getBlock() {
+ return block;
+ }
+
+ public ISound getSound() {
+ return sound;
+ }
+
+ public void setSound(ISound sound) {
+ this.sound = sound;
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/GuiGamemodes.java b/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/GuiGamemodes.java
index b57c92a3..77305904 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/GuiGamemodes.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/GuiGamemodes.java
@@ -4,6 +4,11 @@ import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.util.ChatComponentText;
+import net.minecraft.util.EnumChatFormatting;
+import org.lwjgl.input.Keyboard;
+import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.io.IOException;
@@ -11,299 +16,308 @@ import java.util.ArrayList;
import java.util.List;
import static io.github.moulberry.notenoughupdates.util.GuiTextures.*;
-import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.util.ChatComponentText;
-import net.minecraft.util.EnumChatFormatting;
-import org.lwjgl.input.Keyboard;
-import org.lwjgl.opengl.GL11;
public class GuiGamemodes extends GuiScreen {
-
- private String currentProfile;
- private SBGamemodes.Gamemode currentGamemode = null;
- private boolean upgradeOverride;
-
- private int guiLeft = 100;
- private int guiTop = 100;
- private int xSize = 200;
- private int ySize = 232;
-
- public GuiGamemodes(boolean upgradeOverride) {
- this.currentProfile = NotEnoughUpdates.INSTANCE.manager.getCurrentProfile();
- this.upgradeOverride = upgradeOverride;
- }
-
- private boolean canChange(int from, int to) {
- if(from >= to) {
- return true;
- } else {
- return !currentGamemode.locked || upgradeOverride;
- }
- }
-
- @Override
- public void updateScreen() {
- if(this.currentProfile == null) {
- Minecraft.getMinecraft().displayGuiScreen(null);
- Minecraft.getMinecraft().thePlayer.addChatMessage(
- new ChatComponentText(EnumChatFormatting.RED+"Couldn't detect current profile. Maybe try later?"));
- }
-
- if(currentGamemode == null) {
- currentGamemode = SBGamemodes.getGamemode();
- if(currentGamemode == null) {
- Minecraft.getMinecraft().displayGuiScreen(null);
- Minecraft.getMinecraft().thePlayer.addChatMessage(
- new ChatComponentText(EnumChatFormatting.RED+"Couldn't automatically detect current profile." +
- "If you have only 1 profile, try using /api new so that NEU can detect your profile."));
- }
- }
-
- String currentProfile = NotEnoughUpdates.INSTANCE.manager.getCurrentProfile();
- if(!this.currentProfile.equals(currentProfile)) {
- Minecraft.getMinecraft().displayGuiScreen(null);
- Minecraft.getMinecraft().thePlayer.addChatMessage(
- new ChatComponentText(EnumChatFormatting.RED+"Profile change detected. Closing gamemodes menu."));
- }
- }
-
- @Override
- public void handleKeyboardInput() throws IOException {
- if(Keyboard.getEventKeyState() && Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
- SBGamemodes.saveToFile();
- }
-
- super.handleKeyboardInput();
- }
-
- public void drawStringShadow(String str, float x, float y, int len) {
- for(int xOff=-2; xOff<=2; xOff++) {
- for(int yOff=-2; yOff<=2; yOff++) {
- if(Math.abs(xOff) != Math.abs(yOff)) {
- Utils.drawStringScaledMaxWidth(Utils.cleanColourNotModifiers(str),
- Minecraft.getMinecraft().fontRendererObj,
- x+xOff/2f, y+yOff/2f, false, len,
- new Color(20, 20, 20, 100/Math.max(Math.abs(xOff), Math.abs(yOff))).getRGB());
- }
- }
- }
-
- Utils.drawStringScaledMaxWidth(str,
- Minecraft.getMinecraft().fontRendererObj,
- x, y, false, len,
- new Color(64, 64, 64, 255).getRGB());
- }
-
- @Override
- protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
- if(mouseButton == 0) {
- SBGamemodes.HardcoreMode setHC = SBGamemodes.HardcoreMode.NORMAL;
- SBGamemodes.IronmanMode setIM = SBGamemodes.IronmanMode.NORMAL;
- int setMod = 0;
-
- if(mouseX > guiLeft+xSize-27 && mouseX < guiLeft+xSize-9) {
- if(mouseY > guiTop+30 && mouseY < guiTop+30+16) {
- setHC = SBGamemodes.HardcoreMode.SOFTCORE;
- } else if(mouseY > guiTop+50 && mouseY < guiTop+50+16) {
- setHC = SBGamemodes.HardcoreMode.HARDCORE;
- } else if(mouseY > guiTop+80 && mouseY < guiTop+80+16) {
- setIM = SBGamemodes.IronmanMode.IRONMAN;
- } else if(mouseY > guiTop+100 && mouseY < guiTop+100+16) {
- setIM = SBGamemodes.IronmanMode.IRONMANPLUS;
- } else if(mouseY > guiTop+120 && mouseY < guiTop+120+16) {
- setIM = SBGamemodes.IronmanMode.ULTIMATE_IRONMAN;
- } else if(mouseY > guiTop+140 && mouseY < guiTop+140+16) {
- setIM = SBGamemodes.IronmanMode.ULTIMATE_IRONMANPLUS;
- } else if(mouseY > guiTop+170 && mouseY < guiTop+170+16) {
- setMod = SBGamemodes.MODIFIER_DEVILISH;
- } else if(mouseY > guiTop+190 && mouseY < guiTop+190+16) {
- setMod = SBGamemodes.MODIFIER_NOBANK;
- } else if(mouseY > guiTop+210 && mouseY < guiTop+210+16) {
- setMod = SBGamemodes.MODIFIER_SMALLISLAND;
- }
- }
-
- if(setHC != SBGamemodes.HardcoreMode.NORMAL) {
- if(currentGamemode.hardcoreMode == setHC) {
- currentGamemode.hardcoreMode = SBGamemodes.HardcoreMode.NORMAL;
- } else {
- if(canChange(currentGamemode.hardcoreMode.ordinal(), setHC.ordinal())) {
- currentGamemode.hardcoreMode = setHC;
- }
- }
- } else if(setIM != SBGamemodes.IronmanMode.NORMAL) {
- if(currentGamemode.ironmanMode == setIM) {
- currentGamemode.ironmanMode = SBGamemodes.IronmanMode.NORMAL;
- } else {
- if(canChange(currentGamemode.ironmanMode.ordinal(), setIM.ordinal())) {
- currentGamemode.ironmanMode = setIM;
- }
- }
- } else if(setMod != 0) {
- if(canChange(currentGamemode.gamemodeModifiers, currentGamemode.gamemodeModifiers^setMod)) {
- currentGamemode.gamemodeModifiers ^= setMod;
- }
- }
- }
- }
-
- @Override
- public void drawScreen(int mouseX, int mouseY, float partialTicks) {
- super.drawDefaultBackground();
-
- guiLeft = (width-xSize)/2;
- guiTop = (height-ySize)/2;
-
- GlStateManager.color(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(gamemodes);
- Utils.drawTexturedRect(guiLeft, guiTop, xSize, ySize, GL11.GL_NEAREST);
-
- if(currentGamemode == null) return;
-
- Utils.drawStringCentered("NEU Skyblock Gamemodes", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+xSize/2f, guiTop+14, false, new Color(64, 64, 64).getRGB());
-
- drawStringShadow(SBGamemodes.HardcoreMode.SOFTCORE.display, guiLeft+10, guiTop+30, xSize-47);
- drawStringShadow(SBGamemodes.HardcoreMode.HARDCORE.display, guiLeft+10, guiTop+50, xSize-47);
-
- drawStringShadow(SBGamemodes.IronmanMode.IRONMAN.display,guiLeft+10, guiTop+80, xSize-47);
- drawStringShadow(SBGamemodes.IronmanMode.IRONMANPLUS.display,guiLeft+10, guiTop+100, xSize-47);
- drawStringShadow(SBGamemodes.IronmanMode.ULTIMATE_IRONMAN.display,guiLeft+10, guiTop+120, xSize-47);
- drawStringShadow(SBGamemodes.IronmanMode.ULTIMATE_IRONMANPLUS.display,guiLeft+10, guiTop+140, xSize-47);
-
- drawStringShadow(SBGamemodes.MODIFIER_DEVILISH_DISPLAY,guiLeft+10, guiTop+170, xSize-47);
- drawStringShadow(SBGamemodes.MODIFIER_NOBANK_DISPLAY,guiLeft+10, guiTop+190, xSize-47);
- drawStringShadow(SBGamemodes.MODIFIER_SMALLISLAND_DISPLAY,guiLeft+10, guiTop+210, xSize-47);
-
- String tooltipToDisplay = null;
-
- GlStateManager.color(1, 1, 1, 1);
- if(canChange(currentGamemode.hardcoreMode.ordinal(), SBGamemodes.HardcoreMode.SOFTCORE.ordinal())) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(
- currentGamemode.hardcoreMode == SBGamemodes.HardcoreMode.SOFTCORE ? radial_circle_on : radial_circle_off);
- Utils.drawTexturedRect(guiLeft+xSize-26, guiTop+30-4, 16, 16, GL11.GL_NEAREST);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(help);
- Utils.drawTexturedRect(guiLeft+xSize-47, guiTop+30-4, 16, 16, GL11.GL_NEAREST);
- if(mouseX > guiLeft+xSize-47 && mouseX < guiLeft+xSize-31) {
- if(mouseY > guiTop+30-4 && mouseY < guiTop+30+12) {
- tooltipToDisplay = SBGamemodes.HardcoreMode.SOFTCORE.desc;
- }
- }
- }
- if(canChange(currentGamemode.hardcoreMode.ordinal(), SBGamemodes.HardcoreMode.HARDCORE.ordinal())) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(
- currentGamemode.hardcoreMode == SBGamemodes.HardcoreMode.HARDCORE ? radial_circle_on : radial_circle_off);
- Utils.drawTexturedRect(guiLeft+xSize-26, guiTop+50-4, 16, 16, GL11.GL_NEAREST);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(help);
- Utils.drawTexturedRect(guiLeft+xSize-47, guiTop+50-4, 16, 16, GL11.GL_NEAREST);
- if(mouseX > guiLeft+xSize-47 && mouseX < guiLeft+xSize-31) {
- if(mouseY > guiTop+50-4 && mouseY < guiTop+50+12) {
- tooltipToDisplay = SBGamemodes.HardcoreMode.HARDCORE.desc;
- }
- }
- }
-
- if(canChange(currentGamemode.ironmanMode.ordinal(), SBGamemodes.IronmanMode.IRONMAN.ordinal())) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(
- currentGamemode.ironmanMode == SBGamemodes.IronmanMode.IRONMAN ? radial_circle_on : radial_circle_off);
- Utils.drawTexturedRect(guiLeft+xSize-26, guiTop+80-4, 16, 16, GL11.GL_NEAREST);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(help);
- Utils.drawTexturedRect(guiLeft+xSize-47, guiTop+80-4, 16, 16, GL11.GL_NEAREST);
- if(mouseX > guiLeft+xSize-47 && mouseX < guiLeft+xSize-31) {
- if(mouseY > guiTop+80-4 && mouseY < guiTop+80+12) {
- tooltipToDisplay = SBGamemodes.IronmanMode.IRONMAN.desc;
- }
- }
- }
- if(canChange(currentGamemode.ironmanMode.ordinal(), SBGamemodes.IronmanMode.IRONMANPLUS.ordinal())) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(
- currentGamemode.ironmanMode == SBGamemodes.IronmanMode.IRONMANPLUS ? radial_circle_on : radial_circle_off);
- Utils.drawTexturedRect(guiLeft+xSize-26, guiTop+100-4, 16, 16, GL11.GL_NEAREST);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(help);
- Utils.drawTexturedRect(guiLeft+xSize-47, guiTop+100-4, 16, 16, GL11.GL_NEAREST);
- if(mouseX > guiLeft+xSize-47 && mouseX < guiLeft+xSize-31) {
- if(mouseY > guiTop+100-4 && mouseY < guiTop+100+12) {
- tooltipToDisplay = SBGamemodes.IronmanMode.IRONMANPLUS.desc;
- }
- }
- }
- if(canChange(currentGamemode.ironmanMode.ordinal(), SBGamemodes.IronmanMode.ULTIMATE_IRONMAN.ordinal())) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(
- currentGamemode.ironmanMode == SBGamemodes.IronmanMode.ULTIMATE_IRONMAN ? radial_circle_on : radial_circle_off);
- Utils.drawTexturedRect(guiLeft+xSize-26, guiTop+120-4, 16, 16, GL11.GL_NEAREST);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(help);
- Utils.drawTexturedRect(guiLeft+xSize-47, guiTop+120-4, 16, 16, GL11.GL_NEAREST);
- if(mouseX > guiLeft+xSize-47 && mouseX < guiLeft+xSize-31) {
- if(mouseY > guiTop+120-4 && mouseY < guiTop+120+12) {
- tooltipToDisplay = SBGamemodes.IronmanMode.ULTIMATE_IRONMAN.desc;
- }
- }
- }
- if(canChange(currentGamemode.ironmanMode.ordinal(), SBGamemodes.IronmanMode.ULTIMATE_IRONMANPLUS.ordinal())) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(
- currentGamemode.ironmanMode == SBGamemodes.IronmanMode.ULTIMATE_IRONMANPLUS ? radial_circle_on : radial_circle_off);
- Utils.drawTexturedRect(guiLeft+xSize-26, guiTop+140-4, 16, 16, GL11.GL_NEAREST);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(help);
- Utils.drawTexturedRect(guiLeft+xSize-47, guiTop+140-4, 16, 16, GL11.GL_NEAREST);
- if(mouseX > guiLeft+xSize-47 && mouseX < guiLeft+xSize-31) {
- if(mouseY > guiTop+140-4 && mouseY < guiTop+140+12) {
- tooltipToDisplay = SBGamemodes.IronmanMode.ULTIMATE_IRONMANPLUS.desc;
- }
- }
- }
-
- if(canChange(currentGamemode.gamemodeModifiers, currentGamemode.gamemodeModifiers^SBGamemodes.MODIFIER_DEVILISH)) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(
- (currentGamemode.gamemodeModifiers & SBGamemodes.MODIFIER_DEVILISH) != 0 ? radial_square_on : radial_square_off);
- Utils.drawTexturedRect(guiLeft+xSize-26, guiTop+170-4, 16, 16, GL11.GL_NEAREST);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(help);
- Utils.drawTexturedRect(guiLeft+xSize-47, guiTop+170-4, 16, 16, GL11.GL_NEAREST);
- if(mouseX > guiLeft+xSize-47 && mouseX < guiLeft+xSize-31) {
- if(mouseY > guiTop+170-4 && mouseY < guiTop+170+12) {
- tooltipToDisplay = SBGamemodes.MODIFIER_DEVILISH_DESC;
- }
- }
- }
- if(canChange(currentGamemode.gamemodeModifiers, currentGamemode.gamemodeModifiers^SBGamemodes.MODIFIER_NOBANK)) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(
- (currentGamemode.gamemodeModifiers & SBGamemodes.MODIFIER_NOBANK) != 0 ? radial_square_on : radial_square_off);
- Utils.drawTexturedRect(guiLeft+xSize-26, guiTop+190-4, 16, 16, GL11.GL_NEAREST);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(help);
- Utils.drawTexturedRect(guiLeft+xSize-47, guiTop+190-4, 16, 16, GL11.GL_NEAREST);
- if(mouseX > guiLeft+xSize-47 && mouseX < guiLeft+xSize-31) {
- if(mouseY > guiTop+190-4 && mouseY < guiTop+190+12) {
- tooltipToDisplay = SBGamemodes.MODIFIER_NOBANK_DESC;
- }
- }
- }
- if(canChange(currentGamemode.gamemodeModifiers, currentGamemode.gamemodeModifiers^SBGamemodes.MODIFIER_SMALLISLAND)) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(
- (currentGamemode.gamemodeModifiers & SBGamemodes.MODIFIER_SMALLISLAND) != 0 ? radial_square_on : radial_square_off);
- Utils.drawTexturedRect(guiLeft+xSize-26, guiTop+210-4, 16, 16, GL11.GL_NEAREST);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(help);
- Utils.drawTexturedRect(guiLeft+xSize-47, guiTop+210-4, 16, 16, GL11.GL_NEAREST);
- if(mouseX > guiLeft+xSize-47 && mouseX < guiLeft+xSize-31) {
- if(mouseY > guiTop+210-4 && mouseY < guiTop+210+12) {
- tooltipToDisplay = SBGamemodes.MODIFIER_SMALLISLAND_DESC;
- }
- }
- }
-
- if(tooltipToDisplay != null) {
- List<String> lines = new ArrayList<>();
- for(String line : tooltipToDisplay.split("\n")) {
- lines.add(EnumChatFormatting.GRAY+line);
- }
- Utils.drawHoveringText(lines, mouseX, mouseY, width, height, -1, Minecraft.getMinecraft().fontRendererObj);
- }
- }
+ private final String currentProfile;
+ private SBGamemodes.Gamemode currentGamemode = null;
+ private final boolean upgradeOverride;
+
+ private int guiLeft = 100;
+ private int guiTop = 100;
+ private final int xSize = 200;
+ private final int ySize = 232;
+
+ public GuiGamemodes(boolean upgradeOverride) {
+ this.currentProfile = NotEnoughUpdates.INSTANCE.manager.getCurrentProfile();
+ this.upgradeOverride = upgradeOverride;
+ }
+
+ private boolean canChange(int from, int to) {
+ if (from >= to) {
+ return true;
+ } else {
+ return !currentGamemode.locked || upgradeOverride;
+ }
+ }
+
+ @Override
+ public void updateScreen() {
+ if (this.currentProfile == null) {
+ Minecraft.getMinecraft().displayGuiScreen(null);
+ Minecraft.getMinecraft().thePlayer.addChatMessage(
+ new ChatComponentText(EnumChatFormatting.RED + "Couldn't detect current profile. Maybe try later?"));
+ }
+
+ if (currentGamemode == null) {
+ currentGamemode = SBGamemodes.getGamemode();
+ if (currentGamemode == null) {
+ Minecraft.getMinecraft().displayGuiScreen(null);
+ Minecraft.getMinecraft().thePlayer.addChatMessage(
+ new ChatComponentText(EnumChatFormatting.RED + "Couldn't automatically detect current profile." +
+ "If you have only 1 profile, try using /api new so that NEU can detect your profile."));
+ }
+ }
+
+ String currentProfile = NotEnoughUpdates.INSTANCE.manager.getCurrentProfile();
+ if (!this.currentProfile.equals(currentProfile)) {
+ Minecraft.getMinecraft().displayGuiScreen(null);
+ Minecraft.getMinecraft().thePlayer.addChatMessage(
+ new ChatComponentText(EnumChatFormatting.RED + "Profile change detected. Closing gamemodes menu."));
+ }
+ }
+
+ @Override
+ public void handleKeyboardInput() throws IOException {
+ if (Keyboard.getEventKeyState() && Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
+ SBGamemodes.saveToFile();
+ }
+
+ super.handleKeyboardInput();
+ }
+
+ public void drawStringShadow(String str, float x, float y, int len) {
+ for (int xOff = -2; xOff <= 2; xOff++) {
+ for (int yOff = -2; yOff <= 2; yOff++) {
+ if (Math.abs(xOff) != Math.abs(yOff)) {
+ Utils.drawStringScaledMaxWidth(Utils.cleanColourNotModifiers(str),
+ Minecraft.getMinecraft().fontRendererObj,
+ x + xOff / 2f, y + yOff / 2f, false, len,
+ new Color(20, 20, 20, 100 / Math.max(Math.abs(xOff), Math.abs(yOff))).getRGB()
+ );
+ }
+ }
+ }
+
+ Utils.drawStringScaledMaxWidth(str,
+ Minecraft.getMinecraft().fontRendererObj,
+ x, y, false, len,
+ new Color(64, 64, 64, 255).getRGB()
+ );
+ }
+
+ @Override
+ protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
+ if (mouseButton == 0) {
+ SBGamemodes.HardcoreMode setHC = SBGamemodes.HardcoreMode.NORMAL;
+ SBGamemodes.IronmanMode setIM = SBGamemodes.IronmanMode.NORMAL;
+ int setMod = 0;
+
+ if (mouseX > guiLeft + xSize - 27 && mouseX < guiLeft + xSize - 9) {
+ if (mouseY > guiTop + 30 && mouseY < guiTop + 30 + 16) {
+ setHC = SBGamemodes.HardcoreMode.SOFTCORE;
+ } else if (mouseY > guiTop + 50 && mouseY < guiTop + 50 + 16) {
+ setHC = SBGamemodes.HardcoreMode.HARDCORE;
+ } else if (mouseY > guiTop + 80 && mouseY < guiTop + 80 + 16) {
+ setIM = SBGamemodes.IronmanMode.IRONMAN;
+ } else if (mouseY > guiTop + 100 && mouseY < guiTop + 100 + 16) {
+ setIM = SBGamemodes.IronmanMode.IRONMANPLUS;
+ } else if (mouseY > guiTop + 120 && mouseY < guiTop + 120 + 16) {
+ setIM = SBGamemodes.IronmanMode.ULTIMATE_IRONMAN;
+ } else if (mouseY > guiTop + 140 && mouseY < guiTop + 140 + 16) {
+ setIM = SBGamemodes.IronmanMode.ULTIMATE_IRONMANPLUS;
+ } else if (mouseY > guiTop + 170 && mouseY < guiTop + 170 + 16) {
+ setMod = SBGamemodes.MODIFIER_DEVILISH;
+ } else if (mouseY > guiTop + 190 && mouseY < guiTop + 190 + 16) {
+ setMod = SBGamemodes.MODIFIER_NOBANK;
+ } else if (mouseY > guiTop + 210 && mouseY < guiTop + 210 + 16) {
+ setMod = SBGamemodes.MODIFIER_SMALLISLAND;
+ }
+ }
+
+ if (setHC != SBGamemodes.HardcoreMode.NORMAL) {
+ if (currentGamemode.hardcoreMode == setHC) {
+ currentGamemode.hardcoreMode = SBGamemodes.HardcoreMode.NORMAL;
+ } else {
+ if (canChange(currentGamemode.hardcoreMode.ordinal(), setHC.ordinal())) {
+ currentGamemode.hardcoreMode = setHC;
+ }
+ }
+ } else if (setIM != SBGamemodes.IronmanMode.NORMAL) {
+ if (currentGamemode.ironmanMode == setIM) {
+ currentGamemode.ironmanMode = SBGamemodes.IronmanMode.NORMAL;
+ } else {
+ if (canChange(currentGamemode.ironmanMode.ordinal(), setIM.ordinal())) {
+ currentGamemode.ironmanMode = setIM;
+ }
+ }
+ } else if (setMod != 0) {
+ if (canChange(currentGamemode.gamemodeModifiers, currentGamemode.gamemodeModifiers ^ setMod)) {
+ currentGamemode.gamemodeModifiers ^= setMod;
+ }
+ }
+ }
+ }
+
+ @Override
+ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
+ super.drawDefaultBackground();
+
+ guiLeft = (width - xSize) / 2;
+ guiTop = (height - ySize) / 2;
+
+ GlStateManager.color(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(gamemodes);
+ Utils.drawTexturedRect(guiLeft, guiTop, xSize, ySize, GL11.GL_NEAREST);
+
+ if (currentGamemode == null) return;
+
+ Utils.drawStringCentered("NEU Skyblock Gamemodes", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + xSize / 2f, guiTop + 14, false, new Color(64, 64, 64).getRGB()
+ );
+
+ drawStringShadow(SBGamemodes.HardcoreMode.SOFTCORE.display, guiLeft + 10, guiTop + 30, xSize - 47);
+ drawStringShadow(SBGamemodes.HardcoreMode.HARDCORE.display, guiLeft + 10, guiTop + 50, xSize - 47);
+
+ drawStringShadow(SBGamemodes.IronmanMode.IRONMAN.display, guiLeft + 10, guiTop + 80, xSize - 47);
+ drawStringShadow(SBGamemodes.IronmanMode.IRONMANPLUS.display, guiLeft + 10, guiTop + 100, xSize - 47);
+ drawStringShadow(SBGamemodes.IronmanMode.ULTIMATE_IRONMAN.display, guiLeft + 10, guiTop + 120, xSize - 47);
+ drawStringShadow(SBGamemodes.IronmanMode.ULTIMATE_IRONMANPLUS.display, guiLeft + 10, guiTop + 140, xSize - 47);
+
+ drawStringShadow(SBGamemodes.MODIFIER_DEVILISH_DISPLAY, guiLeft + 10, guiTop + 170, xSize - 47);
+ drawStringShadow(SBGamemodes.MODIFIER_NOBANK_DISPLAY, guiLeft + 10, guiTop + 190, xSize - 47);
+ drawStringShadow(SBGamemodes.MODIFIER_SMALLISLAND_DISPLAY, guiLeft + 10, guiTop + 210, xSize - 47);
+
+ String tooltipToDisplay = null;
+
+ GlStateManager.color(1, 1, 1, 1);
+ if (canChange(currentGamemode.hardcoreMode.ordinal(), SBGamemodes.HardcoreMode.SOFTCORE.ordinal())) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(
+ currentGamemode.hardcoreMode == SBGamemodes.HardcoreMode.SOFTCORE ? radial_circle_on : radial_circle_off);
+ Utils.drawTexturedRect(guiLeft + xSize - 26, guiTop + 30 - 4, 16, 16, GL11.GL_NEAREST);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(help);
+ Utils.drawTexturedRect(guiLeft + xSize - 47, guiTop + 30 - 4, 16, 16, GL11.GL_NEAREST);
+ if (mouseX > guiLeft + xSize - 47 && mouseX < guiLeft + xSize - 31) {
+ if (mouseY > guiTop + 30 - 4 && mouseY < guiTop + 30 + 12) {
+ tooltipToDisplay = SBGamemodes.HardcoreMode.SOFTCORE.desc;
+ }
+ }
+ }
+ if (canChange(currentGamemode.hardcoreMode.ordinal(), SBGamemodes.HardcoreMode.HARDCORE.ordinal())) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(
+ currentGamemode.hardcoreMode == SBGamemodes.HardcoreMode.HARDCORE ? radial_circle_on : radial_circle_off);
+ Utils.drawTexturedRect(guiLeft + xSize - 26, guiTop + 50 - 4, 16, 16, GL11.GL_NEAREST);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(help);
+ Utils.drawTexturedRect(guiLeft + xSize - 47, guiTop + 50 - 4, 16, 16, GL11.GL_NEAREST);
+ if (mouseX > guiLeft + xSize - 47 && mouseX < guiLeft + xSize - 31) {
+ if (mouseY > guiTop + 50 - 4 && mouseY < guiTop + 50 + 12) {
+ tooltipToDisplay = SBGamemodes.HardcoreMode.HARDCORE.desc;
+ }
+ }
+ }
+
+ if (canChange(currentGamemode.ironmanMode.ordinal(), SBGamemodes.IronmanMode.IRONMAN.ordinal())) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(
+ currentGamemode.ironmanMode == SBGamemodes.IronmanMode.IRONMAN ? radial_circle_on : radial_circle_off);
+ Utils.drawTexturedRect(guiLeft + xSize - 26, guiTop + 80 - 4, 16, 16, GL11.GL_NEAREST);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(help);
+ Utils.drawTexturedRect(guiLeft + xSize - 47, guiTop + 80 - 4, 16, 16, GL11.GL_NEAREST);
+ if (mouseX > guiLeft + xSize - 47 && mouseX < guiLeft + xSize - 31) {
+ if (mouseY > guiTop + 80 - 4 && mouseY < guiTop + 80 + 12) {
+ tooltipToDisplay = SBGamemodes.IronmanMode.IRONMAN.desc;
+ }
+ }
+ }
+ if (canChange(currentGamemode.ironmanMode.ordinal(), SBGamemodes.IronmanMode.IRONMANPLUS.ordinal())) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(
+ currentGamemode.ironmanMode == SBGamemodes.IronmanMode.IRONMANPLUS ? radial_circle_on : radial_circle_off);
+ Utils.drawTexturedRect(guiLeft + xSize - 26, guiTop + 100 - 4, 16, 16, GL11.GL_NEAREST);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(help);
+ Utils.drawTexturedRect(guiLeft + xSize - 47, guiTop + 100 - 4, 16, 16, GL11.GL_NEAREST);
+ if (mouseX > guiLeft + xSize - 47 && mouseX < guiLeft + xSize - 31) {
+ if (mouseY > guiTop + 100 - 4 && mouseY < guiTop + 100 + 12) {
+ tooltipToDisplay = SBGamemodes.IronmanMode.IRONMANPLUS.desc;
+ }
+ }
+ }
+ if (canChange(currentGamemode.ironmanMode.ordinal(), SBGamemodes.IronmanMode.ULTIMATE_IRONMAN.ordinal())) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(
+ currentGamemode.ironmanMode == SBGamemodes.IronmanMode.ULTIMATE_IRONMAN ? radial_circle_on : radial_circle_off);
+ Utils.drawTexturedRect(guiLeft + xSize - 26, guiTop + 120 - 4, 16, 16, GL11.GL_NEAREST);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(help);
+ Utils.drawTexturedRect(guiLeft + xSize - 47, guiTop + 120 - 4, 16, 16, GL11.GL_NEAREST);
+ if (mouseX > guiLeft + xSize - 47 && mouseX < guiLeft + xSize - 31) {
+ if (mouseY > guiTop + 120 - 4 && mouseY < guiTop + 120 + 12) {
+ tooltipToDisplay = SBGamemodes.IronmanMode.ULTIMATE_IRONMAN.desc;
+ }
+ }
+ }
+ if (canChange(currentGamemode.ironmanMode.ordinal(), SBGamemodes.IronmanMode.ULTIMATE_IRONMANPLUS.ordinal())) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(
+ currentGamemode.ironmanMode == SBGamemodes.IronmanMode.ULTIMATE_IRONMANPLUS
+ ? radial_circle_on
+ : radial_circle_off);
+ Utils.drawTexturedRect(guiLeft + xSize - 26, guiTop + 140 - 4, 16, 16, GL11.GL_NEAREST);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(help);
+ Utils.drawTexturedRect(guiLeft + xSize - 47, guiTop + 140 - 4, 16, 16, GL11.GL_NEAREST);
+ if (mouseX > guiLeft + xSize - 47 && mouseX < guiLeft + xSize - 31) {
+ if (mouseY > guiTop + 140 - 4 && mouseY < guiTop + 140 + 12) {
+ tooltipToDisplay = SBGamemodes.IronmanMode.ULTIMATE_IRONMANPLUS.desc;
+ }
+ }
+ }
+
+ if (canChange(
+ currentGamemode.gamemodeModifiers,
+ currentGamemode.gamemodeModifiers ^ SBGamemodes.MODIFIER_DEVILISH
+ )) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(
+ (currentGamemode.gamemodeModifiers & SBGamemodes.MODIFIER_DEVILISH) != 0
+ ? radial_square_on
+ : radial_square_off);
+ Utils.drawTexturedRect(guiLeft + xSize - 26, guiTop + 170 - 4, 16, 16, GL11.GL_NEAREST);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(help);
+ Utils.drawTexturedRect(guiLeft + xSize - 47, guiTop + 170 - 4, 16, 16, GL11.GL_NEAREST);
+ if (mouseX > guiLeft + xSize - 47 && mouseX < guiLeft + xSize - 31) {
+ if (mouseY > guiTop + 170 - 4 && mouseY < guiTop + 170 + 12) {
+ tooltipToDisplay = SBGamemodes.MODIFIER_DEVILISH_DESC;
+ }
+ }
+ }
+ if (canChange(currentGamemode.gamemodeModifiers, currentGamemode.gamemodeModifiers ^ SBGamemodes.MODIFIER_NOBANK)) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(
+ (currentGamemode.gamemodeModifiers & SBGamemodes.MODIFIER_NOBANK) != 0 ? radial_square_on : radial_square_off);
+ Utils.drawTexturedRect(guiLeft + xSize - 26, guiTop + 190 - 4, 16, 16, GL11.GL_NEAREST);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(help);
+ Utils.drawTexturedRect(guiLeft + xSize - 47, guiTop + 190 - 4, 16, 16, GL11.GL_NEAREST);
+ if (mouseX > guiLeft + xSize - 47 && mouseX < guiLeft + xSize - 31) {
+ if (mouseY > guiTop + 190 - 4 && mouseY < guiTop + 190 + 12) {
+ tooltipToDisplay = SBGamemodes.MODIFIER_NOBANK_DESC;
+ }
+ }
+ }
+ if (canChange(
+ currentGamemode.gamemodeModifiers,
+ currentGamemode.gamemodeModifiers ^ SBGamemodes.MODIFIER_SMALLISLAND
+ )) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(
+ (currentGamemode.gamemodeModifiers & SBGamemodes.MODIFIER_SMALLISLAND) != 0
+ ? radial_square_on
+ : radial_square_off);
+ Utils.drawTexturedRect(guiLeft + xSize - 26, guiTop + 210 - 4, 16, 16, GL11.GL_NEAREST);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(help);
+ Utils.drawTexturedRect(guiLeft + xSize - 47, guiTop + 210 - 4, 16, 16, GL11.GL_NEAREST);
+ if (mouseX > guiLeft + xSize - 47 && mouseX < guiLeft + xSize - 31) {
+ if (mouseY > guiTop + 210 - 4 && mouseY < guiTop + 210 + 12) {
+ tooltipToDisplay = SBGamemodes.MODIFIER_SMALLISLAND_DESC;
+ }
+ }
+ }
+
+ if (tooltipToDisplay != null) {
+ List<String> lines = new ArrayList<>();
+ for (String line : tooltipToDisplay.split("\n")) {
+ lines.add(EnumChatFormatting.GRAY + line);
+ }
+ Utils.drawHoveringText(lines, mouseX, mouseY, width, height, -1, Minecraft.getMinecraft().fontRendererObj);
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java b/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java
index 18324154..ddd4a4ba 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java
@@ -25,291 +25,315 @@ import java.util.Base64;
import java.util.HashMap;
public class SBGamemodes {
-
- private static final Gson gson = new Gson();
-
- public static final int MODIFIER_DEVILISH = 0b1;
- public static final int MODIFIER_NOBANK = 0b10;
- public static final int MODIFIER_SMALLISLAND = 0b100;
-
- public static final String MODIFIER_DEVILISH_DISPLAY = EnumChatFormatting.DARK_PURPLE+"Devilish";
- public static final String MODIFIER_NOBANK_DISPLAY = EnumChatFormatting.RED+"No"+EnumChatFormatting.GOLD+"Bank";
- public static final String MODIFIER_SMALLISLAND_DISPLAY = EnumChatFormatting.GREEN+"SmallIsland";
-
- public static final String MODIFIER_DEVILISH_DESC = EnumChatFormatting.DARK_PURPLE+"Devilish\n" +
- "You are NOT allowed to use fairy souls.";
- public static final String MODIFIER_NOBANK_DESC = EnumChatFormatting.RED+"No"+EnumChatFormatting.GOLD+"Bank\n" +
- "You are NOT allowed to use the bank.";
- public static final String MODIFIER_SMALLISLAND_DESC = EnumChatFormatting.GREEN+"SmallIsland\n" +
- "Your private island is 1/4 the normal size.";
-
- private static HashMap<String, Gamemode> currentGamemode = new HashMap<>();
- private static long lastDeathExemption = 0;
-
- public static class Gamemode {
- public HardcoreMode hardcoreMode = HardcoreMode.NORMAL;
- public IronmanMode ironmanMode = IronmanMode.NORMAL;
- public int gamemodeModifiers = 0;
-
- public boolean locked = true;
- }
-
- public enum HardcoreMode {
- NORMAL("Normal", "Normal"),
- SOFTCORE(EnumChatFormatting.RED+"Soft"+EnumChatFormatting.DARK_RED+"core\n" +
- "You only have 1 life.\nDying will remove your hardcore status.\nDeaths to the void or \'unknown\' are exempted.",
- "You died.", "You fell into the void"),
- HARDCORE(EnumChatFormatting.DARK_RED+"Hardcore\n" +
- "You only have 1 life.\nDying will remove your hardcore status.");
-
- public final String display;
- public final String desc;
- private String[] exemptions;
-
- HardcoreMode(String display, String... exemptions) {
- this.display = display.split("\n")[0];
- this.desc = display;
- this.exemptions = exemptions;
- }
-
- public boolean isExemption(String line) {
- for(String exemption : exemptions) {
- if(line.contains(exemption)) return true;
- }
- return false;
- }
- }
-
- public enum IronmanMode {
- NORMAL("Normal"),
- IRONMAN(EnumChatFormatting.WHITE+"Ironman\n" +
- "You are NOT allowed to trade or use the auction house.",
- "You ", "Auction House", "Auctions Browser", "Auction View"),
- IRONMANPLUS(EnumChatFormatting.WHITE+"Ironman"+EnumChatFormatting.GOLD+"+\n" +
- "You are NOT allowed to trade, use the auction house or bazaar.",
- "You ", "Auction House", "Auctions Browser", "Auction View", "Bazaar"),
- ULTIMATE_IRONMAN(EnumChatFormatting.DARK_AQUA+"Ultimate "+EnumChatFormatting.WHITE+"Ironman\n" +
- "You are NOT allowed to trade or use the auction house.\n" +
- "You are restricted to 1 inventory. (No containers, no echest, no wardrobe).",
- "You ", "Auction House", "Auctions Browser", "Auction View", "Chest",
- "Wardrobe", "Weapon Rack", "Shelves"),
- ULTIMATE_IRONMANPLUS(EnumChatFormatting.DARK_AQUA+"Ultimate "+EnumChatFormatting.WHITE+"Ironman"+EnumChatFormatting.GOLD+"+\n" +
- "You are NOT allowed to trade, use the auction house or bazaar.\n" +
- "You are restricted to 1 inventory. (No containers, no echest, no wardrobe).",
- "You ", "Auction House", "Auctions Browser", "Auction View", "Bazaar",
- "Chest", "Wardrobe", "Weapon Rack", "Shelves");
-
- public final String display;
- public final String desc;
- private final String[] bannedInventories;
-
- IronmanMode(String display, String... bannedInventories) {
- this.display = display.split("\n")[0];
- this.desc = display;
- this.bannedInventories = bannedInventories;
- }
-
- public boolean isBanned(String inventoryName) {
- for(String banned : bannedInventories) {
- if(inventoryName.contains(banned + " ") || inventoryName.endsWith(banned)) return true;
- }
- return false;
- }
- }
-
- public static Gamemode getGamemode() {
- String currentProfile = SBInfo.getInstance().currentProfile;
-
- if(currentProfile == null || currentProfile.isEmpty()) return null;
-
- return currentGamemode.computeIfAbsent(currentProfile, k -> new Gamemode());
- }
-
- public static void loadFromFile() {
- File configDir = NotEnoughUpdates.INSTANCE.manager.configLocation;
- File gamemodeFile = new File(configDir,
- "gamemodes/gamemodes-"+Minecraft.getMinecraft().thePlayer.getUniqueID().toString()+".json");
- gamemodeFile.getParentFile().mkdirs();
-
- if(!gamemodeFile.exists()) {
- return;
- }
-
- try(BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(gamemodeFile), StandardCharsets.UTF_8))) {
- String line = reader.readLine();
- String decoded = decrypt(line);
- currentGamemode = gson.fromJson(decoded, GamemodeWrapper.class).currentGamemode;
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
-
- public static class GamemodeWrapper {
- private HashMap<String, Gamemode> currentGamemode;
-
- public GamemodeWrapper(HashMap<String, Gamemode> currentGamemode) {
- this.currentGamemode = currentGamemode;
- }
- }
-
- public static void saveToFile() {
- File configDir = NotEnoughUpdates.INSTANCE.manager.configLocation;
- File gamemodeFile = new File(configDir,
- "gamemodes/gamemodes-"+Minecraft.getMinecraft().thePlayer.getUniqueID().toString()+".json");
- gamemodeFile.getParentFile().mkdirs();
-
- try {
- gamemodeFile.createNewFile();
-
- try(BufferedWriter writer = new BufferedWriter(
- new OutputStreamWriter(new FileOutputStream(gamemodeFile), StandardCharsets.UTF_8))) {
- JsonObject obj = new JsonObject();
- writer.write(encrypt(gson.toJson(new GamemodeWrapper(currentGamemode), GamemodeWrapper.class)));
- }
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
-
- public static Key getKeyFromPlayerUUID() {
- byte[] bytes = ByteBuffer.allocate(2 * Long.SIZE / Byte.SIZE)
- .putLong(Minecraft.getMinecraft().thePlayer.getUniqueID().getLeastSignificantBits())
- .putLong(Minecraft.getMinecraft().thePlayer.getUniqueID().getMostSignificantBits())
- .array();
- SecretKeySpec key = new SecretKeySpec(bytes, "AES");
-
- return key;
- }
-
-
- public static String encrypt(String value) {
- try {
- Cipher cipher = Cipher.getInstance("AES");
- cipher.init(Cipher.ENCRYPT_MODE, getKeyFromPlayerUUID());
- String encrypt = Base64.getEncoder().encodeToString(cipher.doFinal(value.getBytes()));
- return encrypt;
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
-
- public static String decrypt(String encrypted) {
- try {
- Cipher cipher = Cipher.getInstance("AES");
- cipher.init(Cipher.DECRYPT_MODE, getKeyFromPlayerUUID());
- byte[] b64Decoded = Base64.getDecoder().decode(encrypted);
- byte[] bytes = cipher.doFinal(b64Decoded);
-
- return new String(bytes);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
-
- public static void setGamemode(Gamemode gamemode) {
- String currentProfile = NotEnoughUpdates.INSTANCE.manager.getCurrentProfile();
-
- if(currentProfile == null || currentProfile.isEmpty()) return;
-
- currentGamemode.put(currentProfile, gamemode);
- }
-
- @SubscribeEvent
- public void onPlayerInteract(PlayerInteractEvent event) {
- if(getGamemode() == null || !NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
-
- if(!"Your Island".equals(SBInfo.getInstance().location)) return;
-
- if((getGamemode().gamemodeModifiers & MODIFIER_SMALLISLAND) != 0) {
- if(event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
- if(Math.abs(event.pos.getX()) > 40 || Math.abs(event.pos.getZ()) > 40) {
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
- EnumChatFormatting.YELLOW+"[NPC] Builder"+
- EnumChatFormatting.WHITE+": Sorry, "+Minecraft.getMinecraft().thePlayer.getName()+
- ", due to budget cuts your skyblock island is now only 80 blocks wide."));
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
- EnumChatFormatting.AQUA+"(Use "+EnumChatFormatting.YELLOW+"/neugamemodes"+
- EnumChatFormatting.AQUA+" if you would like to build further out)"));
-
- event.setCanceled(true);
- }
- }
- }
- }
-
- @SubscribeEvent
- public void onTick(TickEvent.ClientTickEvent event) {
- if (event.phase != TickEvent.Phase.START) return;
-
- if(getGamemode() == null || !NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
-
- boolean inDungeons = SBInfo.getInstance().getLocation() != null && SBInfo.getInstance().getLocation().equals("dungeon");
-
- if((EnumChatFormatting.YELLOW+"Break a log").equals(SBInfo.getInstance().objective)) {
- getGamemode().locked = false;
- } else {
- getGamemode().locked = true;
- }
-
- IronmanMode ironmanMode = getGamemode().ironmanMode;
- GuiScreen gui = Minecraft.getMinecraft().currentScreen;
- if(gui instanceof GuiChest) {
- GuiChest eventGui = (GuiChest) gui;
- ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
- String containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText();
-
- if(containerName.equals("Bank") && (getGamemode().gamemodeModifiers & MODIFIER_NOBANK) != 0) {
- Minecraft.getMinecraft().thePlayer.closeScreen();
-
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
- EnumChatFormatting.YELLOW+"[NPC] Banker"+
- EnumChatFormatting.WHITE+": Hi, "+Minecraft.getMinecraft().thePlayer.getName()+
- ", you would like to create an account and make a deposit?"));
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW+"[NPC] Banker"+
- EnumChatFormatting.WHITE+": Alright, I've invested your money into ..."));
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED+"["+
- EnumChatFormatting.WHITE+"YouTube"+EnumChatFormatting.RED+"] Nullzee"+
- EnumChatFormatting.WHITE+": Hows it going everyone, welcome to my ultimate bazaar flipping guide ..."));
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW+"[NPC] Banker"+
- EnumChatFormatting.WHITE+": Hmm, it seems as though the economy has crashed. All your money is gone. Poof. Vanished."));
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW+"[IDIOT] You"+
- EnumChatFormatting.WHITE+": ... never again ..."));
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
- EnumChatFormatting.AQUA+"(Use "+EnumChatFormatting.YELLOW+"/neugamemodes"+
- EnumChatFormatting.AQUA+" if you would like to use the bank)"));
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
- } else if(containerName.equals("Fairy") && (getGamemode().gamemodeModifiers & MODIFIER_DEVILISH) != 0) {
- Minecraft.getMinecraft().thePlayer.closeScreen();
-
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
- EnumChatFormatting.YELLOW+"[NPC] "+EnumChatFormatting.LIGHT_PURPLE+"Tia the Fairy"+
- EnumChatFormatting.WHITE+": Oh no, "+Minecraft.getMinecraft().thePlayer.getName()+
- ", you have sold your soul to the devil... please go away!"));
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
- EnumChatFormatting.AQUA+"(Use "+EnumChatFormatting.YELLOW+"/neugamemodes"+
- EnumChatFormatting.AQUA+" if you would like to use fairy souls)"));
- } else if(!inDungeons && ironmanMode.isBanned(containerName)) {
- Minecraft.getMinecraft().thePlayer.closeScreen();
-
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
- EnumChatFormatting.AQUA+"You cannot access this inventory/menu because of your"));
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
- " "+ironmanMode.display + EnumChatFormatting.AQUA+" status!"));
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
- EnumChatFormatting.AQUA+"(Use "+EnumChatFormatting.YELLOW+"/neugamemodes"+
- EnumChatFormatting.AQUA+" if you would like to downgrade the status)"));
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
- }
- }
- }
-
- @SubscribeEvent
- public void onChatMessage(ClientChatReceivedEvent event) {
- if(event.type != 0) return;
+ private static final Gson gson = new Gson();
+
+ public static final int MODIFIER_DEVILISH = 0b1;
+ public static final int MODIFIER_NOBANK = 0b10;
+ public static final int MODIFIER_SMALLISLAND = 0b100;
+
+ public static final String MODIFIER_DEVILISH_DISPLAY = EnumChatFormatting.DARK_PURPLE + "Devilish";
+ public static final String MODIFIER_NOBANK_DISPLAY = EnumChatFormatting.RED + "No" + EnumChatFormatting.GOLD + "Bank";
+ public static final String MODIFIER_SMALLISLAND_DISPLAY = EnumChatFormatting.GREEN + "SmallIsland";
+
+ public static final String MODIFIER_DEVILISH_DESC = EnumChatFormatting.DARK_PURPLE + "Devilish\n" +
+ "You are NOT allowed to use fairy souls.";
+ public static final String MODIFIER_NOBANK_DESC = EnumChatFormatting.RED + "No" + EnumChatFormatting.GOLD + "Bank\n" +
+ "You are NOT allowed to use the bank.";
+ public static final String MODIFIER_SMALLISLAND_DESC = EnumChatFormatting.GREEN + "SmallIsland\n" +
+ "Your private island is 1/4 the normal size.";
+
+ private static HashMap<String, Gamemode> currentGamemode = new HashMap<>();
+ private static long lastDeathExemption = 0;
+
+ public static class Gamemode {
+ public HardcoreMode hardcoreMode = HardcoreMode.NORMAL;
+ public IronmanMode ironmanMode = IronmanMode.NORMAL;
+ public int gamemodeModifiers = 0;
+
+ public boolean locked = true;
+ }
+
+ public enum HardcoreMode {
+ NORMAL("Normal", "Normal"),
+ SOFTCORE(EnumChatFormatting.RED + "Soft" + EnumChatFormatting.DARK_RED + "core\n" +
+ "You only have 1 life.\nDying will remove your hardcore status.\nDeaths to the void or 'unknown' are exempted.",
+ "You died.", "You fell into the void"
+ ),
+ HARDCORE(EnumChatFormatting.DARK_RED + "Hardcore\n" +
+ "You only have 1 life.\nDying will remove your hardcore status.");
+
+ public final String display;
+ public final String desc;
+ private final String[] exemptions;
+
+ HardcoreMode(String display, String... exemptions) {
+ this.display = display.split("\n")[0];
+ this.desc = display;
+ this.exemptions = exemptions;
+ }
+
+ public boolean isExemption(String line) {
+ for (String exemption : exemptions) {
+ if (line.contains(exemption)) return true;
+ }
+ return false;
+ }
+ }
+
+ public enum IronmanMode {
+ NORMAL("Normal"),
+ IRONMAN(EnumChatFormatting.WHITE + "Ironman\n" +
+ "You are NOT allowed to trade or use the auction house.",
+ "You ", "Auction House", "Auctions Browser", "Auction View"
+ ),
+ IRONMANPLUS(EnumChatFormatting.WHITE + "Ironman" + EnumChatFormatting.GOLD + "+\n" +
+ "You are NOT allowed to trade, use the auction house or bazaar.",
+ "You ", "Auction House", "Auctions Browser", "Auction View", "Bazaar"
+ ),
+ ULTIMATE_IRONMAN(EnumChatFormatting.DARK_AQUA + "Ultimate " + EnumChatFormatting.WHITE + "Ironman\n" +
+ "You are NOT allowed to trade or use the auction house.\n" +
+ "You are restricted to 1 inventory. (No containers, no echest, no wardrobe).",
+ "You ", "Auction House", "Auctions Browser", "Auction View", "Chest",
+ "Wardrobe", "Weapon Rack", "Shelves"
+ ),
+ ULTIMATE_IRONMANPLUS(
+ EnumChatFormatting.DARK_AQUA + "Ultimate " + EnumChatFormatting.WHITE + "Ironman" + EnumChatFormatting.GOLD +
+ "+\n" +
+ "You are NOT allowed to trade, use the auction house or bazaar.\n" +
+ "You are restricted to 1 inventory. (No containers, no echest, no wardrobe).",
+ "You ",
+ "Auction House",
+ "Auctions Browser",
+ "Auction View",
+ "Bazaar",
+ "Chest",
+ "Wardrobe",
+ "Weapon Rack",
+ "Shelves"
+ );
+
+ public final String display;
+ public final String desc;
+ private final String[] bannedInventories;
+
+ IronmanMode(String display, String... bannedInventories) {
+ this.display = display.split("\n")[0];
+ this.desc = display;
+ this.bannedInventories = bannedInventories;
+ }
+
+ public boolean isBanned(String inventoryName) {
+ for (String banned : bannedInventories) {
+ if (inventoryName.contains(banned + " ") || inventoryName.endsWith(banned)) return true;
+ }
+ return false;
+ }
+ }
+
+ public static Gamemode getGamemode() {
+ String currentProfile = SBInfo.getInstance().currentProfile;
+
+ if (currentProfile == null || currentProfile.isEmpty()) return null;
+
+ return currentGamemode.computeIfAbsent(currentProfile, k -> new Gamemode());
+ }
+
+ public static void loadFromFile() {
+ File configDir = NotEnoughUpdates.INSTANCE.manager.configLocation;
+ File gamemodeFile = new File(
+ configDir,
+ "gamemodes/gamemodes-" + Minecraft.getMinecraft().thePlayer.getUniqueID().toString() + ".json"
+ );
+ gamemodeFile.getParentFile().mkdirs();
+
+ if (!gamemodeFile.exists()) {
+ return;
+ }
+
+ try (
+ BufferedReader reader = new BufferedReader(new InputStreamReader(
+ new FileInputStream(gamemodeFile),
+ StandardCharsets.UTF_8
+ ))
+ ) {
+ String line = reader.readLine();
+ String decoded = decrypt(line);
+ currentGamemode = gson.fromJson(decoded, GamemodeWrapper.class).currentGamemode;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static class GamemodeWrapper {
+ private final HashMap<String, Gamemode> currentGamemode;
+
+ public GamemodeWrapper(HashMap<String, Gamemode> currentGamemode) {
+ this.currentGamemode = currentGamemode;
+ }
+ }
+
+ public static void saveToFile() {
+ File configDir = NotEnoughUpdates.INSTANCE.manager.configLocation;
+ File gamemodeFile = new File(
+ configDir,
+ "gamemodes/gamemodes-" + Minecraft.getMinecraft().thePlayer.getUniqueID().toString() + ".json"
+ );
+ gamemodeFile.getParentFile().mkdirs();
+
+ try {
+ gamemodeFile.createNewFile();
+
+ try (
+ BufferedWriter writer = new BufferedWriter(
+ new OutputStreamWriter(new FileOutputStream(gamemodeFile), StandardCharsets.UTF_8))
+ ) {
+ JsonObject obj = new JsonObject();
+ writer.write(encrypt(gson.toJson(new GamemodeWrapper(currentGamemode), GamemodeWrapper.class)));
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static Key getKeyFromPlayerUUID() {
+ byte[] bytes = ByteBuffer.allocate(2 * Long.SIZE / Byte.SIZE)
+ .putLong(Minecraft.getMinecraft().thePlayer.getUniqueID().getLeastSignificantBits())
+ .putLong(Minecraft.getMinecraft().thePlayer.getUniqueID().getMostSignificantBits())
+ .array();
+ SecretKeySpec key = new SecretKeySpec(bytes, "AES");
+
+ return key;
+ }
+
+ public static String encrypt(String value) {
+ try {
+ Cipher cipher = Cipher.getInstance("AES");
+ cipher.init(Cipher.ENCRYPT_MODE, getKeyFromPlayerUUID());
+ String encrypt = Base64.getEncoder().encodeToString(cipher.doFinal(value.getBytes()));
+ return encrypt;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ public static String decrypt(String encrypted) {
+ try {
+ Cipher cipher = Cipher.getInstance("AES");
+ cipher.init(Cipher.DECRYPT_MODE, getKeyFromPlayerUUID());
+ byte[] b64Decoded = Base64.getDecoder().decode(encrypted);
+ byte[] bytes = cipher.doFinal(b64Decoded);
+
+ return new String(bytes);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ public static void setGamemode(Gamemode gamemode) {
+ String currentProfile = NotEnoughUpdates.INSTANCE.manager.getCurrentProfile();
+
+ if (currentProfile == null || currentProfile.isEmpty()) return;
+
+ currentGamemode.put(currentProfile, gamemode);
+ }
+
+ @SubscribeEvent
+ public void onPlayerInteract(PlayerInteractEvent event) {
+ if (getGamemode() == null || !NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
+
+ if (!"Your Island".equals(SBInfo.getInstance().location)) return;
+
+ if ((getGamemode().gamemodeModifiers & MODIFIER_SMALLISLAND) != 0) {
+ if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
+ if (Math.abs(event.pos.getX()) > 40 || Math.abs(event.pos.getZ()) > 40) {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
+ EnumChatFormatting.YELLOW + "[NPC] Builder" +
+ EnumChatFormatting.WHITE + ": Sorry, " + Minecraft.getMinecraft().thePlayer.getName() +
+ ", due to budget cuts your skyblock island is now only 80 blocks wide."));
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
+ EnumChatFormatting.AQUA + "(Use " + EnumChatFormatting.YELLOW + "/neugamemodes" +
+ EnumChatFormatting.AQUA + " if you would like to build further out)"));
+
+ event.setCanceled(true);
+ }
+ }
+ }
+ }
+
+ @SubscribeEvent
+ public void onTick(TickEvent.ClientTickEvent event) {
+ if (event.phase != TickEvent.Phase.START) return;
+
+ if (getGamemode() == null || !NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
+
+ boolean inDungeons = SBInfo.getInstance().getLocation() != null && SBInfo.getInstance().getLocation().equals(
+ "dungeon");
+
+ getGamemode().locked = !(EnumChatFormatting.YELLOW + "Break a log").equals(SBInfo.getInstance().objective);
+
+ IronmanMode ironmanMode = getGamemode().ironmanMode;
+ GuiScreen gui = Minecraft.getMinecraft().currentScreen;
+ if (gui instanceof GuiChest) {
+ GuiChest eventGui = (GuiChest) gui;
+ ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
+ String containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText();
+
+ if (containerName.equals("Bank") && (getGamemode().gamemodeModifiers & MODIFIER_NOBANK) != 0) {
+ Minecraft.getMinecraft().thePlayer.closeScreen();
+
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
+ EnumChatFormatting.YELLOW + "[NPC] Banker" +
+ EnumChatFormatting.WHITE + ": Hi, " + Minecraft.getMinecraft().thePlayer.getName() +
+ ", you would like to create an account and make a deposit?"));
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
+ EnumChatFormatting.YELLOW + "[NPC] Banker" +
+ EnumChatFormatting.WHITE + ": Alright, I've invested your money into ..."));
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "[" +
+ EnumChatFormatting.WHITE + "YouTube" + EnumChatFormatting.RED + "] Nullzee" +
+ EnumChatFormatting.WHITE + ": Hows it going everyone, welcome to my ultimate bazaar flipping guide ..."));
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
+ EnumChatFormatting.YELLOW + "[NPC] Banker" +
+ EnumChatFormatting.WHITE +
+ ": Hmm, it seems as though the economy has crashed. All your money is gone. Poof. Vanished."));
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
+ EnumChatFormatting.YELLOW + "[IDIOT] You" +
+ EnumChatFormatting.WHITE + ": ... never again ..."));
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
+ EnumChatFormatting.AQUA + "(Use " + EnumChatFormatting.YELLOW + "/neugamemodes" +
+ EnumChatFormatting.AQUA + " if you would like to use the bank)"));
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
+ } else if (containerName.equals("Fairy") && (getGamemode().gamemodeModifiers & MODIFIER_DEVILISH) != 0) {
+ Minecraft.getMinecraft().thePlayer.closeScreen();
+
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
+ EnumChatFormatting.YELLOW + "[NPC] " + EnumChatFormatting.LIGHT_PURPLE + "Tia the Fairy" +
+ EnumChatFormatting.WHITE + ": Oh no, " + Minecraft.getMinecraft().thePlayer.getName() +
+ ", you have sold your soul to the devil... please go away!"));
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
+ EnumChatFormatting.AQUA + "(Use " + EnumChatFormatting.YELLOW + "/neugamemodes" +
+ EnumChatFormatting.AQUA + " if you would like to use fairy souls)"));
+ } else if (!inDungeons && ironmanMode.isBanned(containerName)) {
+ Minecraft.getMinecraft().thePlayer.closeScreen();
+
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
+ EnumChatFormatting.AQUA + "You cannot access this inventory/menu because of your"));
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
+ " " + ironmanMode.display + EnumChatFormatting.AQUA + " status!"));
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
+ EnumChatFormatting.AQUA + "(Use " + EnumChatFormatting.YELLOW + "/neugamemodes" +
+ EnumChatFormatting.AQUA + " if you would like to downgrade the status)"));
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
+ }
+ }
+ }
+
+ @SubscribeEvent
+ public void onChatMessage(ClientChatReceivedEvent event) {
+ if (event.type != 0) return;
/*if(Keyboard.isKeyDown(Keyboard.KEY_K)) {
boolean has = false;
@@ -322,29 +346,29 @@ public class SBGamemodes {
}
if(has) System.out.println("-----END");
}*/
- if(getGamemode() == null || !NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
-
- String message = event.message.getFormattedText();
- if(message.contains("\u2620")) { //Death symbol ( ☠ )
- HardcoreMode hardcoreMode = getGamemode().hardcoreMode;
- if(hardcoreMode != HardcoreMode.NORMAL) {
- if(hardcoreMode.isExemption(message)) {
- lastDeathExemption = System.currentTimeMillis();
- }
- }
- }
-
- if(System.currentTimeMillis() - lastDeathExemption > 1000 &&
- message.contains("!") && message.startsWith(EnumChatFormatting.RESET.toString()+EnumChatFormatting.RED+"You died")) {
- if(getGamemode().hardcoreMode != HardcoreMode.NORMAL) {
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
- EnumChatFormatting.RED.toString()+EnumChatFormatting.OBFUSCATED+"AAA"+
- EnumChatFormatting.RED+" You have lost your "+
- getGamemode().hardcoreMode.display+EnumChatFormatting.RED+" status! "+
- EnumChatFormatting.RED+EnumChatFormatting.OBFUSCATED+"AAA"));
- getGamemode().hardcoreMode = HardcoreMode.NORMAL;
- }
- }
- }
-
+ if (getGamemode() == null || !NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
+
+ String message = event.message.getFormattedText();
+ if (message.contains("\u2620")) { //Death symbol ( ☠ )
+ HardcoreMode hardcoreMode = getGamemode().hardcoreMode;
+ if (hardcoreMode != HardcoreMode.NORMAL) {
+ if (hardcoreMode.isExemption(message)) {
+ lastDeathExemption = System.currentTimeMillis();
+ }
+ }
+ }
+
+ if (System.currentTimeMillis() - lastDeathExemption > 1000 &&
+ message.contains("!") && message.startsWith(
+ EnumChatFormatting.RESET.toString() + EnumChatFormatting.RED + "You died")) {
+ if (getGamemode().hardcoreMode != HardcoreMode.NORMAL) {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
+ EnumChatFormatting.RED.toString() + EnumChatFormatting.OBFUSCATED + "AAA" +
+ EnumChatFormatting.RED + " You have lost your " +
+ getGamemode().hardcoreMode.display + EnumChatFormatting.RED + " status! " +
+ EnumChatFormatting.RED + EnumChatFormatting.OBFUSCATED + "AAA"));
+ getGamemode().hardcoreMode = HardcoreMode.NORMAL;
+ }
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/CollectionLogInfoPane.java b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/CollectionLogInfoPane.java
index fadb148d..bbdbabd2 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/CollectionLogInfoPane.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/CollectionLogInfoPane.java
@@ -5,7 +5,6 @@ import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.NEUManager;
import io.github.moulberry.notenoughupdates.NEUOverlay;
import io.github.moulberry.notenoughupdates.util.NEUResourceManager;
-import io.github.moulberry.notenoughupdates.util.SpecialColour;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
@@ -18,8 +17,8 @@ import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import java.awt.*;
-import java.util.*;
import java.util.List;
+import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
@@ -27,244 +26,264 @@ import java.util.concurrent.atomic.AtomicReference;
import static io.github.moulberry.notenoughupdates.util.GuiTextures.item_mask;
public class CollectionLogInfoPane extends ScrollableInfoPane {
-
- private String mobRegex = ".*?((_MONSTER)|(_ANIMAL)|(_MINIBOSS)|(_BOSS)|(_SC))$";
- private String petRegex = ".*?;[0-4]$";
-
- TreeSet<String> items = new TreeSet<>(getItemComparator());
-
- private int buttonHover = -1;
-
- private int previousAcquiredCount = 0;
- private int previousScroll = 0;
- private int previousX = 0;
- private int previousFilter = 0;
-
- private long lastUpdate = 0;
-
- private static final int FILTER_ALL = 0;
- private static final int FILTER_WEAPON = 1;
- private static final int FILTER_ARMOR = 2;
- private static final int FILTER_ACCESSORY = 3;
- private static final int FILTER_PET = 4;
- private static final int FILTER_DUNGEON = 5;
- private static final int FILTER_SLAYER_ZOMBIE = 6;
- private static final int FILTER_SLAYER_WOLF = 7;
- private static final int FILTER_SLAYER_SPIDER = 8;
- private int filterMode = FILTER_ALL;
- private String[] filterPrettyNames = new String[]{"ALL","WEAPON","ARMOR",
- "ACCESSORY","PET","DUNGEON","ZOMBIE SLAYER","WOLF SLAYER","SPIDER SLAYER"};
-
- private Framebuffer itemFramebuffer = null;
- private Framebuffer itemBGFramebuffer = null;
- private Framebuffer itemFramebufferGrayscale = null;
- private Shader grayscaleShader = null;
-
- private int updateCounter = 0;
-
- public CollectionLogInfoPane(NEUOverlay overlay, NEUManager manager) {
- super(overlay, manager);
- refreshItems();
- }
-
- private boolean loreContains(JsonArray lore, String str) {
- for(int i=0; i<lore.size(); i++) {
- String line = lore.get(i).getAsString();
- if(line.contains(str)) return true;
- }
- return false;
- }
-
- private void refreshItems() {
- items.clear();
- for(String internalname : manager.getItemInformation().keySet()) {
- if(!manager.auctionManager.isVanillaItem(internalname) && !internalname.matches(mobRegex)) {
- JsonObject item = manager.getItemInformation().get(internalname);
- JsonArray lore = manager.getItemInformation().get(internalname).get("lore").getAsJsonArray();
- switch(filterMode) {
- case FILTER_WEAPON:
- if(overlay.checkItemType(lore, "SWORD", "BOW", "WAND") < 0) continue;
- break;
- case FILTER_ARMOR:
- if(overlay.checkItemType(lore, "HELMET", "CHESTPLATE", "LEGGINGS", "BOOTS") < 0) continue;
- break;
- case FILTER_ACCESSORY:
- if(overlay.checkItemType(lore, "ACCESSORY") < 0) continue;
- break;
- case FILTER_PET:
- if(!internalname.matches(petRegex) || !item.get("displayname").getAsString().contains("[")) continue;
- break;
- case FILTER_DUNGEON:
- if(Utils.checkItemType(lore, true, "DUNGEON") < 0) continue;
- break;
- case FILTER_SLAYER_ZOMBIE:
- if(!item.has("slayer_req") || !item.get("slayer_req").getAsString().startsWith("ZOMBIE")) continue;
- break;
- case FILTER_SLAYER_WOLF:
- if(!item.has("slayer_req") || !item.get("slayer_req").getAsString().startsWith("WOLF")) continue;
- break;
- case FILTER_SLAYER_SPIDER:
- if(!item.has("slayer_req") || !item.get("slayer_req").getAsString().startsWith("SPIDER")) continue;
- break;
- }
- items.add(internalname);
- }
- }
- }
-
- private Map<String, ArrayList<String>> getAcquiredItems() {
- return null;//manager.config.collectionLog.value;
- }
-
- private Comparator<String> getItemComparator() {
- return (o1, o2) -> {
- float cost1 = manager.auctionManager.getLowestBin(o1);
- float cost2 = manager.auctionManager.getLowestBin(o2);
-
- if(cost1 == -1) cost1 = manager.auctionManager.getCraftCost(o1).craftCost;
- if(cost2 == -1) cost2 = manager.auctionManager.getCraftCost(o2).craftCost;
-
- if(cost1 < cost2) return 1;
- if(cost1 > cost2) return -1;
-
- return o1.compareTo(o2);
- };
- }
-
- public void mouseInput(int width, int height, int mouseX, int mouseY, boolean mouseDown) {
- super.mouseInput(width, height, mouseX, mouseY, mouseDown);
- if(mouseDown) {
- if(buttonHover == 0) {
- if(Mouse.getEventButton() == 0) {
- filterMode++;
- if(filterMode >= filterPrettyNames.length) {
- filterMode = 0;
- }
- } else if(Mouse.getEventButton() == 1) {
- filterMode--;
- if(filterMode < 0) {
- filterMode = filterPrettyNames.length-1;
- }
- }
- }
- refreshItems();
- }
- }
-
- public void render(int width, int height, Color bg, Color fg, ScaledResolution scaledresolution, int mouseX, int mouseY) {
- int paneWidth = (int)(width/3*overlay.getWidthMult());
- int rightSide = (int)(width*overlay.getInfoPaneOffsetFactor());
- int leftSide = rightSide - paneWidth;
- int padding = overlay.getBoxPadding();
-
- renderDefaultBackground(width, height, bg);
-
- renderControls(height, padding, leftSide+padding, rightSide-padding, 20, fg);
- renderCollectionLog(fg, width, height, leftSide+padding, rightSide-padding, padding+25, height-padding);
- }
-
- private float getCompletedness() {
- int total = items.size();
- int own = 0;
- for(String item : items) {
- if(getAcquiredItems() != null &&
- getAcquiredItems().containsKey(manager.getCurrentProfile()) &&
- getAcquiredItems().get(manager.getCurrentProfile()).contains(item)) {
- own++;
- }
-
- }
- return own/(float)total;
- }
-
- private EnumChatFormatting[] rainbow = new EnumChatFormatting[]{
- EnumChatFormatting.RED,
- EnumChatFormatting.GOLD,
- EnumChatFormatting.YELLOW,
- EnumChatFormatting.GREEN,
- EnumChatFormatting.AQUA,
- EnumChatFormatting.LIGHT_PURPLE,
- EnumChatFormatting.DARK_PURPLE
- };
-
- private String getCompletednessString() {
- float completedness = getCompletedness();
- String text = (int)(completedness*100)+"% Complete";
- if(completedness >= 1) {
- StringBuilder rainbowText = new StringBuilder();
- for(int i=0; i<text.length(); i++) {
- char c = text.charAt(i);
- int index = (int)(i-System.currentTimeMillis()/100)%rainbow.length;
- if(index < 0) index += rainbow.length;
- rainbowText.append(rainbow[index]).append(c);
- }
- text = rainbowText.toString();
- }
- return text;
- }
-
- private void renderControls(int height, int top, int left, int right, int ySize, Color fg) {
- ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
-
- int mouseX = Mouse.getX() / scaledresolution.getScaleFactor();
- int mouseY = height - Mouse.getY() / scaledresolution.getScaleFactor();
-
- buttonHover = -1;
-
- int totalAvailable = right-left;
- int controlPadding = 3;
- String[] controls = new String[]{
- "Filter: "+filterPrettyNames[filterMode],
- getCompletednessString()};
- int numControls = controls.length;
- int available = totalAvailable-(numControls-1)*controlPadding;
- int controlSize = available/numControls;
- int extraPadding = (available%controlSize)/2;
-
- for(int i=0; i<numControls; i++) {
- int width = controlSize+controlPadding;
- int x = left+extraPadding+i*width;
-
- if(mouseX > x && mouseX < x+controlSize) {
- if(mouseY > top && mouseY < top+ySize) {
- buttonHover = i;
- }
- }
-
- drawRect(x, top, x+controlSize, top+ySize,
- new Color(177,177,177).getRGB());
- drawRect(x+1, top+1, x+controlSize, top+ySize,
- new Color(50,50,50).getRGB());
- drawRect(x+1, top+1, x+controlSize-1, top+ySize-1, fg.getRGB());
- Utils.drawStringCenteredScaledMaxWidth(controls[i], Minecraft.getMinecraft().fontRendererObj,
- x+width/2f, top+ySize/2f, true, controlSize-4, Color.WHITE.getRGB());
- }
- }
-
- public int getCurrentAcquiredCount() {
- if(getAcquiredItems() == null) return 0;
- if(!getAcquiredItems().containsKey(manager.getCurrentProfile())) return 0;
- return getAcquiredItems().get(manager.getCurrentProfile()).size();
- }
-
- private void renderCollectionLog(Color fg, int width, int height, int left, int right, int top, int bottom) {
- ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
-
- int mouseX = Mouse.getX() / scaledresolution.getScaleFactor();
- int mouseY = height - Mouse.getY() / scaledresolution.getScaleFactor();
-
- if(itemFramebuffer != null && grayscaleShader != null &&
- (itemFramebuffer.framebufferWidth != width || itemFramebuffer.framebufferHeight != height)) {
- grayscaleShader.setProjectionMatrix(Utils.createProjectionMatrix(
- width*scaledresolution.getScaleFactor(), height*scaledresolution.getScaleFactor()));
- }
-
- itemFramebuffer = checkFramebufferSizes(itemFramebuffer, width, height,
- scaledresolution.getScaleFactor());
- itemBGFramebuffer = checkFramebufferSizes(itemBGFramebuffer, width, height,
- scaledresolution.getScaleFactor());
- itemFramebufferGrayscale = checkFramebufferSizes(itemFramebufferGrayscale, width, height,
- scaledresolution.getScaleFactor());
+ private final String mobRegex = ".*?((_MONSTER)|(_ANIMAL)|(_MINIBOSS)|(_BOSS)|(_SC))$";
+ private final String petRegex = ".*?;[0-4]$";
+
+ TreeSet<String> items = new TreeSet<>(getItemComparator());
+
+ private int buttonHover = -1;
+
+ private int previousAcquiredCount = 0;
+ private int previousScroll = 0;
+ private int previousX = 0;
+ private int previousFilter = 0;
+
+ private final long lastUpdate = 0;
+
+ private static final int FILTER_ALL = 0;
+ private static final int FILTER_WEAPON = 1;
+ private static final int FILTER_ARMOR = 2;
+ private static final int FILTER_ACCESSORY = 3;
+ private static final int FILTER_PET = 4;
+ private static final int FILTER_DUNGEON = 5;
+ private static final int FILTER_SLAYER_ZOMBIE = 6;
+ private static final int FILTER_SLAYER_WOLF = 7;
+ private static final int FILTER_SLAYER_SPIDER = 8;
+ private int filterMode = FILTER_ALL;
+ private final String[] filterPrettyNames = new String[]{
+ "ALL", "WEAPON", "ARMOR",
+ "ACCESSORY", "PET", "DUNGEON", "ZOMBIE SLAYER", "WOLF SLAYER", "SPIDER SLAYER"
+ };
+
+ private Framebuffer itemFramebuffer = null;
+ private Framebuffer itemBGFramebuffer = null;
+ private Framebuffer itemFramebufferGrayscale = null;
+ private Shader grayscaleShader = null;
+
+ private final int updateCounter = 0;
+
+ public CollectionLogInfoPane(NEUOverlay overlay, NEUManager manager) {
+ super(overlay, manager);
+ refreshItems();
+ }
+
+ private boolean loreContains(JsonArray lore, String str) {
+ for (int i = 0; i < lore.size(); i++) {
+ String line = lore.get(i).getAsString();
+ if (line.contains(str)) return true;
+ }
+ return false;
+ }
+
+ private void refreshItems() {
+ items.clear();
+ for (String internalname : manager.getItemInformation().keySet()) {
+ if (!manager.auctionManager.isVanillaItem(internalname) && !internalname.matches(mobRegex)) {
+ JsonObject item = manager.getItemInformation().get(internalname);
+ JsonArray lore = manager.getItemInformation().get(internalname).get("lore").getAsJsonArray();
+ switch (filterMode) {
+ case FILTER_WEAPON:
+ if (overlay.checkItemType(lore, "SWORD", "BOW", "WAND") < 0) continue;
+ break;
+ case FILTER_ARMOR:
+ if (overlay.checkItemType(lore, "HELMET", "CHESTPLATE", "LEGGINGS", "BOOTS") < 0) continue;
+ break;
+ case FILTER_ACCESSORY:
+ if (overlay.checkItemType(lore, "ACCESSORY") < 0) continue;
+ break;
+ case FILTER_PET:
+ if (!internalname.matches(petRegex) || !item.get("displayname").getAsString().contains("["))
+ continue;
+ break;
+ case FILTER_DUNGEON:
+ if (Utils.checkItemType(lore, true, "DUNGEON") < 0) continue;
+ break;
+ case FILTER_SLAYER_ZOMBIE:
+ if (!item.has("slayer_req") || !item.get("slayer_req").getAsString().startsWith("ZOMBIE"))
+ continue;
+ break;
+ case FILTER_SLAYER_WOLF:
+ if (!item.has("slayer_req") || !item.get("slayer_req").getAsString().startsWith("WOLF"))
+ continue;
+ break;
+ case FILTER_SLAYER_SPIDER:
+ if (!item.has("slayer_req") || !item.get("slayer_req").getAsString().startsWith("SPIDER"))
+ continue;
+ break;
+ }
+ items.add(internalname);
+ }
+ }
+ }
+
+ private Map<String, ArrayList<String>> getAcquiredItems() {
+ return null;//manager.config.collectionLog.value;
+ }
+
+ private Comparator<String> getItemComparator() {
+ return (o1, o2) -> {
+ float cost1 = manager.auctionManager.getLowestBin(o1);
+ float cost2 = manager.auctionManager.getLowestBin(o2);
+
+ if (cost1 == -1) cost1 = manager.auctionManager.getCraftCost(o1).craftCost;
+ if (cost2 == -1) cost2 = manager.auctionManager.getCraftCost(o2).craftCost;
+
+ if (cost1 < cost2) return 1;
+ if (cost1 > cost2) return -1;
+
+ return o1.compareTo(o2);
+ };
+ }
+
+ public void mouseInput(int width, int height, int mouseX, int mouseY, boolean mouseDown) {
+ super.mouseInput(width, height, mouseX, mouseY, mouseDown);
+ if (mouseDown) {
+ if (buttonHover == 0) {
+ if (Mouse.getEventButton() == 0) {
+ filterMode++;
+ if (filterMode >= filterPrettyNames.length) {
+ filterMode = 0;
+ }
+ } else if (Mouse.getEventButton() == 1) {
+ filterMode--;
+ if (filterMode < 0) {
+ filterMode = filterPrettyNames.length - 1;
+ }
+ }
+ }
+ refreshItems();
+ }
+ }
+
+ public void render(
+ int width,
+ int height,
+ Color bg,
+ Color fg,
+ ScaledResolution scaledresolution,
+ int mouseX,
+ int mouseY
+ ) {
+ int paneWidth = (int) (width / 3 * overlay.getWidthMult());
+ int rightSide = (int) (width * overlay.getInfoPaneOffsetFactor());
+ int leftSide = rightSide - paneWidth;
+ int padding = overlay.getBoxPadding();
+
+ renderDefaultBackground(width, height, bg);
+
+ renderControls(height, padding, leftSide + padding, rightSide - padding, 20, fg);
+ renderCollectionLog(fg, width, height, leftSide + padding, rightSide - padding, padding + 25, height - padding);
+ }
+
+ private float getCompletedness() {
+ int total = items.size();
+ int own = 0;
+ for (String item : items) {
+ if (getAcquiredItems() != null &&
+ getAcquiredItems().containsKey(manager.getCurrentProfile()) &&
+ getAcquiredItems().get(manager.getCurrentProfile()).contains(item)) {
+ own++;
+ }
+
+ }
+ return own / (float) total;
+ }
+
+ private final EnumChatFormatting[] rainbow = new EnumChatFormatting[]{
+ EnumChatFormatting.RED,
+ EnumChatFormatting.GOLD,
+ EnumChatFormatting.YELLOW,
+ EnumChatFormatting.GREEN,
+ EnumChatFormatting.AQUA,
+ EnumChatFormatting.LIGHT_PURPLE,
+ EnumChatFormatting.DARK_PURPLE
+ };
+
+ private String getCompletednessString() {
+ float completedness = getCompletedness();
+ String text = (int) (completedness * 100) + "% Complete";
+ if (completedness >= 1) {
+ StringBuilder rainbowText = new StringBuilder();
+ for (int i = 0; i < text.length(); i++) {
+ char c = text.charAt(i);
+ int index = (int) (i - System.currentTimeMillis() / 100) % rainbow.length;
+ if (index < 0) index += rainbow.length;
+ rainbowText.append(rainbow[index]).append(c);
+ }
+ text = rainbowText.toString();
+ }
+ return text;
+ }
+
+ private void renderControls(int height, int top, int left, int right, int ySize, Color fg) {
+ ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
+
+ int mouseX = Mouse.getX() / scaledresolution.getScaleFactor();
+ int mouseY = height - Mouse.getY() / scaledresolution.getScaleFactor();
+
+ buttonHover = -1;
+
+ int totalAvailable = right - left;
+ int controlPadding = 3;
+ String[] controls = new String[]{
+ "Filter: " + filterPrettyNames[filterMode],
+ getCompletednessString()
+ };
+ int numControls = controls.length;
+ int available = totalAvailable - (numControls - 1) * controlPadding;
+ int controlSize = available / numControls;
+ int extraPadding = (available % controlSize) / 2;
+
+ for (int i = 0; i < numControls; i++) {
+ int width = controlSize + controlPadding;
+ int x = left + extraPadding + i * width;
+
+ if (mouseX > x && mouseX < x + controlSize) {
+ if (mouseY > top && mouseY < top + ySize) {
+ buttonHover = i;
+ }
+ }
+
+ drawRect(x, top, x + controlSize, top + ySize,
+ new Color(177, 177, 177).getRGB()
+ );
+ drawRect(x + 1, top + 1, x + controlSize, top + ySize,
+ new Color(50, 50, 50).getRGB()
+ );
+ drawRect(x + 1, top + 1, x + controlSize - 1, top + ySize - 1, fg.getRGB());
+ Utils.drawStringCenteredScaledMaxWidth(controls[i], Minecraft.getMinecraft().fontRendererObj,
+ x + width / 2f, top + ySize / 2f, true, controlSize - 4, Color.WHITE.getRGB()
+ );
+ }
+ }
+
+ public int getCurrentAcquiredCount() {
+ if (getAcquiredItems() == null) return 0;
+ if (!getAcquiredItems().containsKey(manager.getCurrentProfile())) return 0;
+ return getAcquiredItems().get(manager.getCurrentProfile()).size();
+ }
+
+ private void renderCollectionLog(Color fg, int width, int height, int left, int right, int top, int bottom) {
+ ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
+
+ int mouseX = Mouse.getX() / scaledresolution.getScaleFactor();
+ int mouseY = height - Mouse.getY() / scaledresolution.getScaleFactor();
+
+ if (itemFramebuffer != null && grayscaleShader != null &&
+ (itemFramebuffer.framebufferWidth != width || itemFramebuffer.framebufferHeight != height)) {
+ grayscaleShader.setProjectionMatrix(Utils.createProjectionMatrix(
+ width * scaledresolution.getScaleFactor(), height * scaledresolution.getScaleFactor()));
+ }
+
+ itemFramebuffer = checkFramebufferSizes(itemFramebuffer, width, height,
+ scaledresolution.getScaleFactor()
+ );
+ itemBGFramebuffer = checkFramebufferSizes(itemBGFramebuffer, width, height,
+ scaledresolution.getScaleFactor()
+ );
+ itemFramebufferGrayscale = checkFramebufferSizes(itemFramebufferGrayscale, width, height,
+ scaledresolution.getScaleFactor()
+ );
/*if(!manager.config.cacheRenderedItempane.value || previousAcquiredCount != getCurrentAcquiredCount() ||
previousScroll != scrollHeight.getValue() || previousX != left || previousFilter != filterMode ||
@@ -273,145 +292,147 @@ public class CollectionLogInfoPane extends ScrollableInfoPane {
renderItemsToImage(itemFramebuffer, fg, left+5, right, top+1, bottom);
renderItemBGToImage(itemBGFramebuffer, fg, left+5, right, top+1, bottom);
}*/
- previousAcquiredCount = getCurrentAcquiredCount();
- previousScroll = scrollHeight.getValue();
- previousX = left;
- previousFilter = filterMode;
-
- Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true);
- renderFromImage(itemBGFramebuffer, width, height, left, right, top, bottom);
- renderFromImage(itemFramebuffer, width, height, left, right, top, bottom);
-
- if(grayscaleShader == null) {
- try {
- grayscaleShader = new Shader(new NEUResourceManager(Minecraft.getMinecraft().getResourceManager()),
- "grayscale",
- itemFramebuffer, itemFramebufferGrayscale);
- grayscaleShader.setProjectionMatrix(Utils.createProjectionMatrix(
- width*scaledresolution.getScaleFactor(), height*scaledresolution.getScaleFactor()));
- } catch(Exception e) {
- return;
- }
- }
-
- GL11.glPushMatrix();
- grayscaleShader.loadShader(0);
- GlStateManager.enableDepth();
- GL11.glPopMatrix();
-
- Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true);
-
- itemFramebufferGrayscale.bindFramebufferTexture();
-
- AtomicReference<ItemStack> tooltipToDisplay = new AtomicReference<>(null);
-
- AtomicBoolean isTop = new AtomicBoolean(false);
- AtomicInteger lowestY = new AtomicInteger(-1);
-
- String[] items = getItemList();
- GlStateManager.color(1f, 1f, 1f, 1f);
- iterateItemSlots(new ItemSlotConsumer() {
- @Override
- public void consume(int x, int y, int id) {
- if(id < items.length) {
- String internalname = items[id];
- if(id == 0) isTop.set(true);
-
- int leftI = x-1;
- int rightI = x+17;
- int topI = y-1;
- int bottomI = y+17;
-
- lowestY.set(Math.max(bottomI, lowestY.get()));
-
- if(mouseX > leftI && mouseX < rightI) {
- if(mouseY > topI && mouseY < bottomI) {
- tooltipToDisplay.set(manager.jsonToStack(manager.getItemInformation().get(internalname), true));
- }
- }
-
- if(getAcquiredItems() != null &&
- getAcquiredItems().containsKey(manager.getCurrentProfile()) &&
- getAcquiredItems().get(manager.getCurrentProfile()).contains(internalname)) {
- return;
- }
-
-
- topI = Math.max(topI, top);
- bottomI = Math.min(bottomI, bottom);
-
- Utils.drawTexturedRect(leftI, topI, rightI-leftI, bottomI-topI,
- leftI/(float)width, rightI/(float)width,
- (height-topI)/(float)height, (height-bottomI)/(float)height);
- }
- }
- }, left+5, right, top+1, bottom);
-
- if(!isTop.get()) {
- if(lowestY.get() == -1) {
- scrollHeight.setValue(0);
- } else {
- int dist = bottom - lowestY.get() - 10;
- if(dist > 0) {
- scrollHeight.setValue(scrollHeight.getValue() - dist);
- }
- }
- }
-
- itemFramebufferGrayscale.unbindFramebufferTexture();
-
- ItemStack displayStack = tooltipToDisplay.get();
- if(displayStack != null) {
- List<String> text = displayStack.getTooltip(Minecraft.getMinecraft().thePlayer, true);
- Utils.drawHoveringText(text, mouseX, mouseY, width, height, -1, Minecraft.getMinecraft().fontRendererObj);
- }
- }
-
- private String[] getItemList() {
- String[] items_arr = new String[items.size()];
- int i=0;
- for(String internalname : items) {
- items_arr[i++] = internalname;
- }
- return items_arr;
- }
-
- private int limCol(int col) {
- return Math.min(255, Math.max(0, col));
- }
-
- private void renderItems(int left, int right, int top, int bottom) {
- String[] items = getItemList();
- iterateItemSlots(new ItemSlotConsumer() {
- public void consume(int x, int y, int id) {
- if(id < items.length) {
- String internalname = items[id];
-
- ItemStack stack = manager.jsonToStack(manager.getItemInformation().get(internalname));
- Utils.drawItemStack(stack, x, y);
- }
- }
- }, left, right, top, bottom);
- }
-
- private void renderItemBackgrounds(Color fg, int left, int right, int top, int bottom) {
- Color fgCustomOpacity = null;//new Color(SpecialColour.specialToChromaRGB(manager.config.itemBackgroundColour.value), true);
- Color fgGold = null;//new Color(SpecialColour.specialToChromaRGB(manager.config.itemFavouriteColour.value), true);
-
- String[] items = getItemList();
- iterateItemSlots(new ItemSlotConsumer() {
- public void consume(int x, int y, int id) {
- if(id < items.length) {
- String internalname = items[id];
-
- Color color = fgCustomOpacity;
- if(getAcquiredItems() != null &&
- getAcquiredItems().containsKey(manager.getCurrentProfile()) &&
- getAcquiredItems().get(manager.getCurrentProfile()).contains(internalname)) {
- color = fgGold;
- }
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(item_mask);
+ previousAcquiredCount = getCurrentAcquiredCount();
+ previousScroll = scrollHeight.getValue();
+ previousX = left;
+ previousFilter = filterMode;
+
+ Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true);
+ renderFromImage(itemBGFramebuffer, width, height, left, right, top, bottom);
+ renderFromImage(itemFramebuffer, width, height, left, right, top, bottom);
+
+ if (grayscaleShader == null) {
+ try {
+ grayscaleShader = new Shader(new NEUResourceManager(Minecraft.getMinecraft().getResourceManager()),
+ "grayscale",
+ itemFramebuffer, itemFramebufferGrayscale
+ );
+ grayscaleShader.setProjectionMatrix(Utils.createProjectionMatrix(
+ width * scaledresolution.getScaleFactor(), height * scaledresolution.getScaleFactor()));
+ } catch (Exception e) {
+ return;
+ }
+ }
+
+ GL11.glPushMatrix();
+ grayscaleShader.loadShader(0);
+ GlStateManager.enableDepth();
+ GL11.glPopMatrix();
+
+ Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true);
+
+ itemFramebufferGrayscale.bindFramebufferTexture();
+
+ AtomicReference<ItemStack> tooltipToDisplay = new AtomicReference<>(null);
+
+ AtomicBoolean isTop = new AtomicBoolean(false);
+ AtomicInteger lowestY = new AtomicInteger(-1);
+
+ String[] items = getItemList();
+ GlStateManager.color(1f, 1f, 1f, 1f);
+ iterateItemSlots(new ItemSlotConsumer() {
+ @Override
+ public void consume(int x, int y, int id) {
+ if (id < items.length) {
+ String internalname = items[id];
+ if (id == 0) isTop.set(true);
+
+ int leftI = x - 1;
+ int rightI = x + 17;
+ int topI = y - 1;
+ int bottomI = y + 17;
+
+ lowestY.set(Math.max(bottomI, lowestY.get()));
+
+ if (mouseX > leftI && mouseX < rightI) {
+ if (mouseY > topI && mouseY < bottomI) {
+ tooltipToDisplay.set(manager.jsonToStack(manager.getItemInformation().get(internalname), true));
+ }
+ }
+
+ if (getAcquiredItems() != null &&
+ getAcquiredItems().containsKey(manager.getCurrentProfile()) &&
+ getAcquiredItems().get(manager.getCurrentProfile()).contains(internalname)) {
+ return;
+ }
+
+ topI = Math.max(topI, top);
+ bottomI = Math.min(bottomI, bottom);
+
+ Utils.drawTexturedRect(leftI, topI, rightI - leftI, bottomI - topI,
+ leftI / (float) width, rightI / (float) width,
+ (height - topI) / (float) height, (height - bottomI) / (float) height
+ );
+ }
+ }
+ }, left + 5, right, top + 1, bottom);
+
+ if (!isTop.get()) {
+ if (lowestY.get() == -1) {
+ scrollHeight.setValue(0);
+ } else {
+ int dist = bottom - lowestY.get() - 10;
+ if (dist > 0) {
+ scrollHeight.setValue(scrollHeight.getValue() - dist);
+ }
+ }
+ }
+
+ itemFramebufferGrayscale.unbindFramebufferTexture();
+
+ ItemStack displayStack = tooltipToDisplay.get();
+ if (displayStack != null) {
+ List<String> text = displayStack.getTooltip(Minecraft.getMinecraft().thePlayer, true);
+ Utils.drawHoveringText(text, mouseX, mouseY, width, height, -1, Minecraft.getMinecraft().fontRendererObj);
+ }
+ }
+
+ private String[] getItemList() {
+ String[] items_arr = new String[items.size()];
+ int i = 0;
+ for (String internalname : items) {
+ items_arr[i++] = internalname;
+ }
+ return items_arr;
+ }
+
+ private int limCol(int col) {
+ return Math.min(255, Math.max(0, col));
+ }
+
+ private void renderItems(int left, int right, int top, int bottom) {
+ String[] items = getItemList();
+ iterateItemSlots(new ItemSlotConsumer() {
+ public void consume(int x, int y, int id) {
+ if (id < items.length) {
+ String internalname = items[id];
+
+ ItemStack stack = manager.jsonToStack(manager.getItemInformation().get(internalname));
+ Utils.drawItemStack(stack, x, y);
+ }
+ }
+ }, left, right, top, bottom);
+ }
+
+ private void renderItemBackgrounds(Color fg, int left, int right, int top, int bottom) {
+ Color fgCustomOpacity =
+ null;//new Color(SpecialColour.specialToChromaRGB(manager.config.itemBackgroundColour.value), true);
+ Color fgGold = null;//new Color(SpecialColour.specialToChromaRGB(manager.config.itemFavouriteColour.value), true);
+
+ String[] items = getItemList();
+ iterateItemSlots(new ItemSlotConsumer() {
+ public void consume(int x, int y, int id) {
+ if (id < items.length) {
+ String internalname = items[id];
+
+ Color color = fgCustomOpacity;
+ if (getAcquiredItems() != null &&
+ getAcquiredItems().containsKey(manager.getCurrentProfile()) &&
+ getAcquiredItems().get(manager.getCurrentProfile()).contains(internalname)) {
+ color = fgGold;
+ }
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(item_mask);
/*if(manager.config.itemStyle.value) {
GlStateManager.color(color.getRed() / 255f, color.getGreen() / 255f,
color.getBlue() / 255f, color.getAlpha() / 255f);
@@ -419,86 +440,95 @@ public class CollectionLogInfoPane extends ScrollableInfoPane {
} else {
drawRect(x-1, y-1, x+overlay.ITEM_SIZE+1, y+overlay.ITEM_SIZE+1, color.getRGB());
}*/
- GlStateManager.bindTexture(0);
- }
- }
- }, left, right, top, bottom);
- }
-
- /**
- * Checks whether the screen size has changed, if so it reconstructs the itemPane framebuffer and marks that the
- * itemPane should be redrawn.
- */
- private Framebuffer checkFramebufferSizes(Framebuffer framebuffer, int width, int height, int scaleFactor) {
- int sw = width*scaleFactor;
- int sh = height*scaleFactor;
-
- if(framebuffer == null || framebuffer.framebufferWidth != sw || framebuffer.framebufferHeight != sh) {
- if(framebuffer == null) {
- framebuffer = new Framebuffer(sw, sh, true);
- } else {
- framebuffer.createBindFramebuffer(sw, sh);
- }
- framebuffer.setFramebufferFilter(GL11.GL_NEAREST);
- }
- return framebuffer;
- }
-
- private void renderItemsToImage(Framebuffer framebuffer, Color fg, int left, int right, int top, int bottom) {
- GL11.glPushMatrix();
- framebuffer.framebufferClear();
- framebuffer.bindFramebuffer(false);
-
- renderItems(left, right, top, bottom);
-
- framebuffer.unbindFramebuffer();
- Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true);
- GL11.glPopMatrix();
- }
-
- private void renderItemBGToImage(Framebuffer framebuffer, Color fg, int left, int right, int top, int bottom) {
- GL11.glPushMatrix();
- framebuffer.framebufferClear();
- framebuffer.bindFramebuffer(false);
-
- renderItemBackgrounds(fg, left, right, top, bottom);
-
- framebuffer.unbindFramebuffer();
- Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true);
- GL11.glPopMatrix();
- }
-
- private void renderFromImage(Framebuffer framebuffer, int width, int height, int left, int right, int top, int bottom) {
- framebuffer.bindFramebufferTexture();
- GlStateManager.color(1f, 1f, 1f, 1f);
- Utils.drawTexturedRect(left, top, right-left, bottom-top,
- left/(float)width, right/(float)width,
- (height-top)/(float)height, (height-bottom)/(float)height);
- framebuffer.unbindFramebufferTexture();
- }
-
- private abstract class ItemSlotConsumer {
- public abstract void consume(int x, int y, int id);
- }
-
- public void iterateItemSlots(ItemSlotConsumer itemSlotConsumer, int left, int right, int top, int bottom) {
- int scrolledTop = top-scrollHeight.getValue();
-
- int id = 0;
- int extraSize = overlay.ITEM_SIZE+overlay.ITEM_PADDING;
- for(int y=scrolledTop; y<bottom; y+=extraSize) {
- for(int x=left; x<right-extraSize; x+=extraSize) {
- if(y > top-extraSize) {
- itemSlotConsumer.consume(x, y, id);
- }
- if(++id >= items.size()) {
- return;
- }
- }
- }
- }
-
- public boolean keyboardInput() {
- return false;
- }
+ GlStateManager.bindTexture(0);
+ }
+ }
+ }, left, right, top, bottom);
+ }
+
+ /**
+ * Checks whether the screen size has changed, if so it reconstructs the itemPane framebuffer and marks that the
+ * itemPane should be redrawn.
+ */
+ private Framebuffer checkFramebufferSizes(Framebuffer framebuffer, int width, int height, int scaleFactor) {
+ int sw = width * scaleFactor;
+ int sh = height * scaleFactor;
+
+ if (framebuffer == null || framebuffer.framebufferWidth != sw || framebuffer.framebufferHeight != sh) {
+ if (framebuffer == null) {
+ framebuffer = new Framebuffer(sw, sh, true);
+ } else {
+ framebuffer.createBindFramebuffer(sw, sh);
+ }
+ framebuffer.setFramebufferFilter(GL11.GL_NEAREST);
+ }
+ return framebuffer;
+ }
+
+ private void renderItemsToImage(Framebuffer framebuffer, Color fg, int left, int right, int top, int bottom) {
+ GL11.glPushMatrix();
+ framebuffer.framebufferClear();
+ framebuffer.bindFramebuffer(false);
+
+ renderItems(left, right, top, bottom);
+
+ framebuffer.unbindFramebuffer();
+ Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true);
+ GL11.glPopMatrix();
+ }
+
+ private void renderItemBGToImage(Framebuffer framebuffer, Color fg, int left, int right, int top, int bottom) {
+ GL11.glPushMatrix();
+ framebuffer.framebufferClear();
+ framebuffer.bindFramebuffer(false);
+
+ renderItemBackgrounds(fg, left, right, top, bottom);
+
+ framebuffer.unbindFramebuffer();
+ Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true);
+ GL11.glPopMatrix();
+ }
+
+ private void renderFromImage(
+ Framebuffer framebuffer,
+ int width,
+ int height,
+ int left,
+ int right,
+ int top,
+ int bottom
+ ) {
+ framebuffer.bindFramebufferTexture();
+ GlStateManager.color(1f, 1f, 1f, 1f);
+ Utils.drawTexturedRect(left, top, right - left, bottom - top,
+ left / (float) width, right / (float) width,
+ (height - top) / (float) height, (height - bottom) / (float) height
+ );
+ framebuffer.unbindFramebufferTexture();
+ }
+
+ private abstract static class ItemSlotConsumer {
+ public abstract void consume(int x, int y, int id);
+ }
+
+ public void iterateItemSlots(ItemSlotConsumer itemSlotConsumer, int left, int right, int top, int bottom) {
+ int scrolledTop = top - scrollHeight.getValue();
+
+ int id = 0;
+ int extraSize = NEUOverlay.ITEM_SIZE + NEUOverlay.ITEM_PADDING;
+ for (int y = scrolledTop; y < bottom; y += extraSize) {
+ for (int x = left; x < right - extraSize; x += extraSize) {
+ if (y > top - extraSize) {
+ itemSlotConsumer.consume(x, y, id);
+ }
+ if (++id >= items.size()) {
+ return;
+ }
+ }
+ }
+ }
+
+ public boolean keyboardInput() {
+ return false;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/DevInfoPane.java b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/DevInfoPane.java
index 8c856c95..945dd71c 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/DevInfoPane.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/DevInfoPane.java
@@ -1,6 +1,5 @@
package io.github.moulberry.notenoughupdates.infopanes;
-import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.NEUManager;
import io.github.moulberry.notenoughupdates.NEUOverlay;
@@ -23,24 +22,24 @@ import net.minecraftforge.oredict.ShapelessOreRecipe;
import org.lwjgl.input.Keyboard;
import java.io.IOException;
-import java.util.*;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.atomic.AtomicBoolean;
+/**
+ * Provides some dev functions used to help with adding new items/detecting missing items.
+ */
public class DevInfoPane extends TextInfoPane {
+ public DevInfoPane(NEUOverlay overlay, NEUManager manager) {
+ super(overlay, manager, "Missing Items", "");
+ text = getText();
+ }
- /**
- * Provides some dev functions used to help with adding new items/detecting missing items.
- */
-
- public DevInfoPane(NEUOverlay overlay, NEUManager manager) {
- super(overlay, manager, "Missing Items", "");
- text = getText();
- }
-
- private String getText() {
- String text = "";
+ private String getText() {
+ String text = "";
/*for(Map.Entry<String, JsonObject> item : manager.getItemInformation().entrySet()) {
if(!item.getValue().has("infoType") || item.getValue().get("infoType").getAsString().isEmpty()) {
@@ -58,14 +57,14 @@ public class DevInfoPane extends TextInfoPane {
text += item.getKey() + "\n";
}
}*/
- //if(true) return text;
+ //if(true) return text;
- for(String internalname : manager.auctionManager.getItemAuctionInfoKeySet()) {
- if (internalname.matches("^.*-[0-9]{1,3}$")) continue;
- if(!manager.getItemInformation().containsKey(internalname)) {
- text += internalname + "\n";
- }
- }
+ for (String internalname : manager.auctionManager.getItemAuctionInfoKeySet()) {
+ if (internalname.matches("^.*-[0-9]{1,3}$")) continue;
+ if (!manager.getItemInformation().containsKey(internalname)) {
+ text += internalname + "\n";
+ }
+ }
/*for(Map.Entry<String, JsonElement> entry : manager.getAuctionPricesJson().get("prices").getAsJsonObject().entrySet()) {
if(!manager.getItemInformation().keySet().contains(entry.getKey())) {
@@ -79,868 +78,876 @@ public class DevInfoPane extends TextInfoPane {
text += entry.getKey() + "\n";
}
}*/
- return text;
- }
-
- //#region add vanilla items
-
- AtomicBoolean running = new AtomicBoolean(false);
- ScheduledExecutorService ses = Executors.newScheduledThreadPool(1);
-
- String[] bukkitList = new String[] {
- "ACACIA_DOOR_ITEM",
- "ACACIA_FENCE",
- "ACACIA_FENCE_GATE",
- "ACACIA_STAIRS",
- "ACTIVATOR_RAIL",
- "ANVIL",
- "APPLE",
- "ARMOR_STAND",
- "ARROW",
- "BAKED_POTATO",
- "BANNER",
- "BARRIER",
- "BEACON",
- "BED",
- "BEDROCK",
- "BIRCH_DOOR_ITEM",
- "BIRCH_FENCE",
- "BIRCH_FENCE_GATE",
- "BIRCH_WOOD_STAIRS@birch_stairs",
- "BLAZE_POWDER",
- "BLAZE_ROD",
- "BOAT",
- "BONE",
- "BOOK",
- "BOOK_AND_QUILL@writable_book",
- "BOOKSHELF",
- "BOW",
- "BOWL",
- "BREAD",
- "BREWING_STAND_ITEM",
- "BRICK@brick_block",
- "BRICK_STAIRS",
- "BROWN_MUSHROOM",
- "BUCKET",
- "CACTUS",
- "CAKE",
- "CARPET",
- "CARROT_ITEM",
- "CARROT_STICK@carrot_on_a_stick",
- "CAULDRON_ITEM",
- "CHAINMAIL_BOOTS",
- "CHAINMAIL_CHESTPLATE",
- "CHAINMAIL_HELMET",
- "CHAINMAIL_LEGGINGS",
- "CHEST",
- "CLAY",
- "CLAY_BALL",
- "CLAY_BRICK@brick",
- "COAL",
- "COAL_BLOCK",
- "COAL_ORE",
- "COBBLE_WALL@cobblestone_wall",
- "COBBLESTONE",
- "COBBLESTONE_STAIRS@stone_stairs",
- "COMMAND@command_block",
- "COMMAND_MINECART@command_block_minecart",
- "COMPASS",
- "COOKED_BEEF",
- "COOKED_CHICKEN",
- "COOKED_FISH",
- "COOKED_MUTTON",
- "COOKED_RABBIT",
- "COOKIE",
- "DARK_OAK_DOOR_ITEM",
- "DARK_OAK_FENCE",
- "DARK_OAK_FENCE_GATE",
- "DARK_OAK_STAIRS",
- "DAYLIGHT_DETECTOR",
- "DEAD_BUSH@deadbush",
- "DETECTOR_RAIL",
- "DIAMOND",
- "DIAMOND_AXE",
- "DIAMOND_BARDING@diamond_horse_armor",
- "DIAMOND_BLOCK",
- "DIAMOND_BOOTS",
- "DIAMOND_CHESTPLATE",
- "DIAMOND_HELMET",
- "DIAMOND_HOE",
- "DIAMOND_LEGGINGS",
- "DIAMOND_ORE",
- "DIAMOND_PICKAXE",
- "DIAMOND_SPADE@diamond_shovel",
- "DIAMOND_SWORD",
- "DIODE@repeater",
- "DIRT",
- "DISPENSER",
- "DOUBLE_PLANT",
- "DRAGON_EGG",
- "DROPPER",
- "EGG",
- "EMERALD",
- "EMERALD_BLOCK",
- "EMERALD_ORE",
- "EMPTY_MAP@map",
- "ENCHANTED_BOOK",
- "ENCHANTMENT_TABLE@enchanting_table",
- "ENDER_CHEST",
- "ENDER_PEARL",
- "ENDER_PORTAL_FRAME@end_portal_frame",
- "ENDER_STONE@end_stone",
- "EXP_BOTTLE@experience_bottle",
- "EXPLOSIVE_MINECART@tnt_minecart",
- "EYE_OF_ENDER@ender_eye",
- "FEATHER",
- "FENCE",
- "FENCE_GATE",
- "FERMENTED_SPIDER_EYE",
- "FIREBALL@fire_charge",
- "FIREWORK@fireworks",
- "FIREWORK_CHARGE",
- "FISHING_ROD",
- "FLINT",
- "FLINT_AND_STEEL",
- "FLOWER_POT_ITEM",
- "FURNACE",
- "GHAST_TEAR",
- "GLASS",
- "GLASS_BOTTLE",
- "GLOWSTONE",
- "GLOWSTONE_DUST",
- "GOLD_AXE@golden_axe",
- "GOLD_BARDING@golden_horse_armor",
- "GOLD_BLOCK",
- "GOLD_BOOTS@golden_boots",
- "GOLD_CHESTPLATE@golden_chestplate",
- "GOLD_HELMET@golden_helmet",
- "GOLD_HOE@golden_hoe",
- "GOLD_INGOT",
- "GOLD_LEGGINGS@golden_leggings",
- "GOLD_NUGGET",
- "GOLD_ORE",
- "GOLD_PICKAXE@golden_pickaxe",
- "GOLD_PLATE@light_weighted_pressure_plate",
- "GOLD_RECORD@record_13",
- "GOLD_SPADE@golden_shovel",
- "GOLD_SWORD@golden_sword",
- "GOLDEN_APPLE",
- "GOLDEN_CARROT",
- "GRASS",
- "GRAVEL",
- "GREEN_RECORD@record_cat",
- "GRILLED_PORK@cooked_porkchop",
- "HARD_CLAY@hardened_clay",
- "HAY_BLOCK",
- "HOPPER",
- "HOPPER_MINECART",
- "ICE",
- "INK_SACK@dye",
- "IRON_AXE",
- "IRON_BARDING@iron_horse_armor",
- "IRON_BLOCK",
- "IRON_BOOTS",
- "IRON_CHESTPLATE",
- "IRON_DOOR",
- "IRON_FENCE@iron_bars",
- "IRON_HELMET",
- "IRON_HOE",
- "IRON_INGOT",
- "IRON_LEGGINGS",
- "IRON_ORE",
- "IRON_PICKAXE",
- "IRON_PLATE@heavy_weighted_pressure_plate",
- "IRON_SPADE@iron_shovel",
- "IRON_SWORD",
- "IRON_TRAPDOOR",
- "ITEM_FRAME",
- "JACK_O_LANTERN@lit_pumpkin",
- "JUKEBOX",
- "JUNGLE_DOOR_ITEM",
- "JUNGLE_FENCE",
- "JUNGLE_FENCE_GATE",
- "JUNGLE_WOOD_STAIRS@jungle_stairs",
- "LADDER",
- "LAPIS_BLOCK",
- "LAPIS_ORE",
- "LAVA_BUCKET",
- "LEASH@lead",
- "LEATHER",
- "LEATHER_BOOTS",
- "LEATHER_CHESTPLATE",
- "LEATHER_HELMET",
- "LEATHER_LEGGINGS",
- "LEAVES",
- "LEAVES_2@leaves2",
- "LEVER",
- "LOG",
- "LOG_2@log2",
- "LONG_GRASS@tallgrass",
- "MAGMA_CREAM",
- "MAP",
- "MELON",
- "MELON_BLOCK",
- "MELON_SEEDS",
- "MILK_BUCKET",
- "MINECART",
- "MOB_SPAWNER",
- "MONSTER_EGG",
- "MONSTER_EGGS@spawn_egg",
- "MOSSY_COBBLESTONE",
- "MUSHROOM_SOUP@mushroom_stew",
- "MUTTON",
- "MYCEL@mycelium",
- "NAME_TAG",
- "NETHER_BRICK",
- "NETHER_BRICK_ITEM",
- "NETHER_BRICK_STAIRS",
- "NETHER_FENCE@nether_brick_fence",
- "NETHER_STAR",
- "NETHER_WARTS@nether_wart",
- "NETHERRACK",
- "NOTE_BLOCK@noteblock",
- "OBSIDIAN",
- "PACKED_ICE",
- "PAINTING",
- "PAPER",
- "PISTON_BASE@piston",
- "PISTON_STICKY_BASE@sticky_piston",
- "POISONOUS_POTATO",
- "PORK@porkchop",
- "POTATO_ITEM",
- "POTION",
- "POWERED_MINECART@furnace_minecart",
- "POWERED_RAIL@golden_rail",
- "PRISMARINE",
- "PRISMARINE_CRYSTALS",
- "PRISMARINE_SHARD",
- "PUMPKIN",
- "PUMPKIN_PIE",
- "PUMPKIN_SEEDS",
- "QUARTZ",
- "QUARTZ_BLOCK",
- "QUARTZ_ORE",
- "QUARTZ_STAIRS",
- "RABBIT",
- "RABBIT_FOOT",
- "RABBIT_HIDE",
- "RABBIT_STEW",
- "RAILS@rail",
- "RAW_BEEF@beef",
- "RAW_CHICKEN@chicken",
- "RAW_FISH@fish",
- "RECORD_10@record_ward",
- "RECORD_11",
- "RECORD_12@record_wait",
- "RECORD_3@record_blocks",
- "RECORD_4@record_chirp",
- "RECORD_5@record_far",
- "RECORD_6@record_mall",
- "RECORD_7@record_mellohi",
- "RECORD_8@record_stal",
- "RECORD_9@record_strad",
- "RED_MUSHROOM",
- "RED_ROSE@red_flower",
- "RED_SANDSTONE",
- "RED_SANDSTONE_STAIRS",
- "REDSTONE",
- "REDSTONE_BLOCK",
- "REDSTONE_COMPARATOR@comparator",
- "REDSTONE_LAMP_OFF@redstone_lamp",
- "REDSTONE_ORE",
- "REDSTONE_TORCH_ON@redstone_torch",
- "ROTTEN_FLESH",
- "SADDLE",
- "SAND",
- "SANDSTONE",
- "SANDSTONE_STAIRS",
- "SAPLING",
- "SEA_LANTERN",
- "SEEDS@wheat_seeds",
- "SHEARS",
- "SIGN",
- "SKULL_ITEM",
- "SLIME_BALL",
- "SLIME_BLOCK@slime",
- "SMOOTH_BRICK@stonebrick",
- "SMOOTH_STAIRS@stone_brick_stairs",
- "SNOW@snow_layer",
- "SNOW_BALL@snowball",
- "SNOW_BLOCK@snow",
- "SOUL_SAND",
- "SPECKLED_MELON",
- "SPIDER_EYE",
- "SPONGE",
- "SPRUCE_DOOR_ITEM",
- "SPRUCE_FENCE",
- "SPRUCE_FENCE_GATE",
- "SPRUCE_WOOD_STAIRS@spruce_stairs",
- "STAINED_CLAY@stained_hardened_clay",
- "STAINED_GLASS",
- "STAINED_GLASS_PANE",
- "STEP@stone_slab",
- "STICK",
- "STONE",
- "STONE_AXE",
- "STONE_BUTTON",
- "STONE_HOE",
- "STONE_PICKAXE",
- "STONE_PLATE@stone_pressure_plate",
- "STONE_SLAB2",
- "STONE_SPADE@stone_shovel",
- "STONE_SWORD",
- "STORAGE_MINECART@chest_minecart",
- "STRING",
- "SUGAR",
- "SUGAR_CANE@reeds",
- "SULPHUR@gunpowder",
- "THIN_GLASS@glass_pane",
- "TNT",
- "TORCH",
- "TRAP_DOOR@trapdoor",
- "TRAPPED_CHEST",
- "TRIPWIRE_HOOK",
- "VINE",
- "WATCH@clock",
- "WATER_BUCKET",
- "WATER_LILY@waterlily",
- "WEB",
- "WHEAT",
- "WOOD@planks",
- "WOOD_AXE@wooden_axe",
- "WOOD_BUTTON@wooden_button",
- "WOOD_DOOR@wooden_door",
- "WOOD_HOE@wooden_hoe",
- "WOOD_PICKAXE@wooden_pickaxe",
- "WOOD_PLATE@wooden_pressure_plate",
- "WOOD_SPADE@wooden_shovel",
- "WOOD_STAIRS@oak_stairs",
- "WOOD_STEP@wooden_slab",
- "WOOD_SWORD@wooden_sword",
- "WOOL",
- "WORKBENCH@crafting_table",
- "WRITTEN_BOOK",
- "YELLOW_FLOWER"
- };
-
- private void addStack(ItemStack stackToAdd, int depth) {
- if(depth > 16) return;
-
- String regName2 = stackToAdd.getItem().getRegistryName().replace("minecraft:", "");
- String internalname = null;
- for(String bukkit2 : bukkitList) {
- if(bukkit2.equalsIgnoreCase(regName2) ||
- (bukkit2.contains("@") && bukkit2.split("@")[1].equalsIgnoreCase(regName2))) {
- internalname = bukkit2.split("@")[0];
- break;
- }
- }
- if(internalname == null) return;
-
- if(stackToAdd.getItemDamage() != 0 && stackToAdd.getItemDamage() < 32000) {
- internalname += "-" + stackToAdd.getItemDamage();
- }
-
- if(manager.getItemInformation().containsKey(internalname)) return;
-
- JsonObject recipeJson = null;
- for(IRecipe recipe : CraftingManager.getInstance().getRecipeList()) {
- ItemStack out = recipe.getRecipeOutput();
- if(out != null && out.getItem() == stackToAdd.getItem() &&
- (stackToAdd.getItemDamage() >= 32000 || out.getItemDamage() == stackToAdd.getItemDamage())) {
- recipeJson = new JsonObject();
-
- if (recipe instanceof ShapedRecipes) {
- ShapedRecipes shaped = (ShapedRecipes) recipe;
-
- String[] x = {"1","2","3"};
- String[] y = {"A","B","C"};
- for(int i=0; i<9; i++) {
- int xi = i%3;
- int yi = i/3;
-
- String stacki = "";
-
- int recipeIndex = i-(3-shaped.recipeWidth)*yi;
- if(xi < shaped.recipeWidth && recipeIndex < shaped.recipeItems.length) {
- ItemStack stack = shaped.recipeItems[recipeIndex];
- if(stack != null) {
- if(stack.getItem() != stackToAdd.getItem() ||
- (stackToAdd.getItemDamage() < 32000 && stack.getItemDamage() != stackToAdd.getItemDamage())) {
- addStack(stack, depth+1);
- }
-
- Item stackItem = stack.getItem();
- String regName = stackItem.getRegistryName().replace("minecraft:", "");
- for(String bukkit2 : bukkitList) {
- if(bukkit2.equalsIgnoreCase(regName) ||
- (bukkit2.contains("@") && bukkit2.split("@")[1].equalsIgnoreCase(regName))) {
- stacki = bukkit2.split("@")[0];
- break;
- }
- }
- if(!stacki.isEmpty()) {
- if(stack.getItemDamage() != 0 && stack.getItemDamage() < 32000) {
- stacki += "-" + stack.getItemDamage();
- }
- stacki += ":"+stack.stackSize;
- }
- }
- }
-
- recipeJson.addProperty(y[yi]+x[xi], stacki);
- }
- break;
- } else if(recipe instanceof ShapedOreRecipe) {
- ShapedOreRecipe shaped = (ShapedOreRecipe) recipe;
- int width = (int)Utils.getField(ShapedOreRecipe.class, recipe, "width");
- String[] x = {"1","2","3"};
- String[] y = {"A","B","C"};
- for(int i=0; i<9; i++) {
- int xi = i%3;
- int yi = i/3;
-
- String stacki = "";
-
- int recipeIndex = i - (3 - width) * yi;
- if (xi < width && recipeIndex < shaped.getRecipeSize()) {
- ItemStack stack = null;
- if(recipeIndex < shaped.getRecipeSize()) {
- Object o = shaped.getInput()[recipeIndex];
- if(o instanceof ItemStack) {
- stack = (ItemStack) o;
- } else if(o instanceof List<?>) {
- for(Object o2 : (List<?>)o) {
- if(o2 instanceof ItemStack) {
- stack = (ItemStack) o2;
- break;
- }
- }
- }
- }
- if(stack != null) {
- if(stack.getItem() != stackToAdd.getItem() ||
- (stackToAdd.getItemDamage() < 32000 && stack.getItemDamage() != stackToAdd.getItemDamage())) {
- addStack(stack, depth+1);
- }
- Item stackItem = stack.getItem();
- String regName = stackItem.getRegistryName().replace("minecraft:", "");
- for(String bukkit2 : bukkitList) {
- if(bukkit2.equalsIgnoreCase(regName) || bukkit2.equalsIgnoreCase(regName+"_ITEM") ||
- (bukkit2.contains("@") && bukkit2.split("@")[1].equalsIgnoreCase(regName))) {
- stacki = bukkit2.split("@")[0];
- break;
- }
- }
- if(!stacki.isEmpty()) {
- if(stack.getItemDamage() != 0 && stack.getItemDamage() < 32000) {
- stacki += "-" + stack.getItemDamage();
- }
- //stacki += ":"+stack.stackSize;
- stacki += ":1";
- }
- }
- }
-
- recipeJson.addProperty(y[yi]+x[xi], stacki);
- }
- } else if (recipe instanceof ShapelessRecipes) {
- ShapelessRecipes shapeless = (ShapelessRecipes) recipe;
- String[] x = {"1","2","3"};
- String[] y = {"A","B","C"};
- for(int i=0; i<9; i++) {
- int xi = i%3;
- int yi = i/3;
-
- String stacki = "";
-
- ItemStack stack = null;
- if(i < shapeless.recipeItems.size()) {
- stack = shapeless.recipeItems.get(i);
- }
- if(stack != null) {
- if(stack.getItem() != stackToAdd.getItem() ||
- (stackToAdd.getItemDamage() < 32000 && stack.getItemDamage() != stackToAdd.getItemDamage())) {
- addStack(stack, depth + 1);
- }
- Item stackItem = stack.getItem();
- String regName = stackItem.getRegistryName().replace("minecraft:", "");
- for(String bukkit2 : bukkitList) {
- if(bukkit2.equalsIgnoreCase(regName) || bukkit2.equalsIgnoreCase(regName+"_ITEM") ||
- (bukkit2.contains("@") && bukkit2.split("@")[1].equalsIgnoreCase(regName))) {
- stacki = bukkit2.split("@")[0];
- break;
- }
- }
- if(!stacki.isEmpty()) {
- if(stack.getItemDamage() != 0 && stack.getItemDamage() < 32000) {
- stacki += "-" + stack.getItemDamage();
- }
- //stacki += ":"+stack.stackSize;
- stacki += ":1";
- }
- }
-
- recipeJson.addProperty(y[yi]+x[xi], stacki);
- }
- break;
- } else if (recipe instanceof ShapelessOreRecipe) {
- ShapelessOreRecipe shapeless = (ShapelessOreRecipe) recipe;
- String[] x = {"1","2","3"};
- String[] y = {"A","B","C"};
- for(int i=0; i<9; i++) {
- int xi = i%3;
- int yi = i/3;
-
- String stacki = "";
-
- ItemStack stack = null;
- if(i < shapeless.getRecipeSize()) {
- Object o = shapeless.getInput().get(i);
- if(o instanceof ItemStack) {
- stack = (ItemStack) o;
- } else if(o instanceof List<?>) {
- for(Object o2 : (List<?>)o) {
- if(o2 instanceof ItemStack) {
- stack = (ItemStack) o2;
- break;
- }
- }
- }
- }
- if(stack != null) {
- if(stack.getItem() != stackToAdd.getItem() ||
- (stackToAdd.getItemDamage() < 32000 && stack.getItemDamage() != stackToAdd.getItemDamage())) {
- addStack(stack, depth+1);
- }
- Item stackItem = stack.getItem();
- String regName = stackItem.getRegistryName().replace("minecraft:", "");
- for(String bukkit2 : bukkitList) {
- if(bukkit2.equalsIgnoreCase(regName) || bukkit2.equalsIgnoreCase(regName+"_ITEM") ||
- (bukkit2.contains("@") && bukkit2.split("@")[1].equalsIgnoreCase(regName))) {
- stacki = bukkit2.split("@")[0];
- break;
- }
- }
- if(!stacki.isEmpty()) {
- if(stack.getItemDamage() != 0 && stack.getItemDamage() < 32000) {
- stacki += "-" + stack.getItemDamage();
- }
- //stacki += ":"+stack.stackSize;
- stacki += ":1";
- }
- }
-
- recipeJson.addProperty(y[yi]+x[xi], stacki);
- }
- break;
- }
- }
-
- }
- ItemStack res = Utils.createItemStack(stackToAdd.getItem(),
- EnumChatFormatting.WHITE+stackToAdd.getItem().getItemStackDisplayName(stackToAdd),
- EnumChatFormatting.WHITE.toString()+EnumChatFormatting.BOLD+"COMMON");
- if(stackToAdd.getItemDamage() != 0 && stackToAdd.getItemDamage() < 32000) {
- res.setItemDamage(stackToAdd.getItemDamage());
- }
- res.getTagCompound().setInteger("HideFlags", 254);
- NBTTagCompound ea = new NBTTagCompound();
- ea.setString("id", internalname);
- res.getTagCompound().setTag("ExtraAttributes", ea);
-
-
- JsonObject json = manager.getJsonForItem(res);
- if(stackToAdd.getItemDamage() != 0 && stackToAdd.getItemDamage() < 32000) {
- json.addProperty("parent", internalname.split("-")[0]);
- }
-
- json.addProperty("internalname", internalname);
- json.addProperty("modver", NotEnoughUpdates.VERSION);
- json.addProperty("vanilla", true);
-
- if(recipeJson != null) {
- json.add("recipe", recipeJson);
- json.addProperty("clickcommand", "viewrecipe");
- } else {
- json.addProperty("clickcommand", "");
- }
-
- json.addProperty("modver", NotEnoughUpdates.VERSION);
-
- try {
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Added: " + internalname));
- manager.writeJsonDefaultDir(json, internalname+".json");
- manager.loadItem(internalname);
- } catch(IOException e) {}
- }
-
- @Override
- public boolean keyboardInput() {
- if(running.get() || true) return false;
- if(Keyboard.isKeyDown(Keyboard.KEY_J)) {
- running.set(!running.get());
-
- for(String bukkit : bukkitList) {
- String internalname = bukkit.split("@")[0];
- if(true || !manager.getItemInformation().containsKey(internalname)) {
- //System.out.println("adding vanilla: " + internalname);
- String vanilla = internalname.toLowerCase().replace("_item", "");
- if(bukkit.contains("@")) {
- vanilla = bukkit.split("@")[1];
- }
- Item item = Item.itemRegistry.getObject(new ResourceLocation(vanilla));
- if(item == null) {
- item = Item.getItemFromBlock(Block.blockRegistry.getObject(new ResourceLocation(vanilla)));
- }
- if(item != null) {
- HashMap<Integer, JsonObject> recipeJsonForDamage = new HashMap<>();
- for(IRecipe recipe : CraftingManager.getInstance().getRecipeList()) {
- ItemStack out = recipe.getRecipeOutput();
- if(out != null && out.getItem() == item) {
- System.out.println("Found recipe for : " + internalname + ":" + recipe);
- JsonObject obj = new JsonObject();
-
- if (recipe instanceof ShapedRecipes) {
- ShapedRecipes shaped = (ShapedRecipes) recipe;
- String[] x = {"1", "2", "3"};
- String[] y = {"A", "B", "C"};
- for (int i = 0; i < 9; i++) {
- int xi = i % 3;
- int yi = i / 3;
-
- String stacki = "";
-
- int recipeIndex = i - (3 - shaped.recipeWidth) * yi;
- if (xi < shaped.recipeWidth && recipeIndex < shaped.recipeItems.length) {
- ItemStack stack = shaped.recipeItems[recipeIndex];
- if (stack != null) {
- addStack(stack, 0);
- Item stackItem = stack.getItem();
- String regName = stackItem.getRegistryName().replace("minecraft:", "");
- for (String bukkit2 : bukkitList) {
- if (bukkit2.equalsIgnoreCase(regName) || bukkit2.equalsIgnoreCase(regName + "_ITEM") ||
- (bukkit2.contains("@") && bukkit2.split("@")[1].equalsIgnoreCase(regName))) {
- stacki = bukkit2.split("@")[0];
- break;
- }
- }
- if (!stacki.isEmpty()) {
- if (stack.getItemDamage() != 0 && stack.getItemDamage() < 32000) {
- stacki += "-" + stack.getItemDamage();
- }
- //stacki += ":"+stack.stackSize;
- stacki += ":1";
- }
- }
- }
-
- obj.addProperty(y[yi] + x[xi], stacki);
- }
- recipeJsonForDamage.put(out.getItemDamage() > 32000 ? 0 : out.getItemDamage(), obj);
- } else if(recipe instanceof ShapedOreRecipe) {
- ShapedOreRecipe shaped = (ShapedOreRecipe) recipe;
- int width = (int)Utils.getField(ShapedOreRecipe.class, recipe, "width");
- String[] x = {"1","2","3"};
- String[] y = {"A","B","C"};
- for(int i=0; i<9; i++) {
- int xi = i%3;
- int yi = i/3;
-
- String stacki = "";
-
- int recipeIndex = i - (3 - width) * yi;
- if (xi < width && recipeIndex < shaped.getRecipeSize()) {
- ItemStack stack = null;
- if(recipeIndex < shaped.getRecipeSize()) {
- Object o = shaped.getInput()[recipeIndex];
- if(o instanceof ItemStack) {
- stack = (ItemStack) o;
- } else if(o instanceof List<?>) {
- for(Object o2 : (List<?>)o) {
- if(o2 instanceof ItemStack) {
- stack = (ItemStack) o2;
- break;
- }
- }
- }
- }
- if(stack != null) {
- addStack(stack, 0);
- Item stackItem = stack.getItem();
- String regName = stackItem.getRegistryName().replace("minecraft:", "");
- for(String bukkit2 : bukkitList) {
- if(bukkit2.equalsIgnoreCase(regName) || bukkit2.equalsIgnoreCase(regName+"_ITEM") ||
- (bukkit2.contains("@") && bukkit2.split("@")[1].equalsIgnoreCase(regName))) {
- stacki = bukkit2.split("@")[0];
- break;
- }
- }
- if(!stacki.isEmpty()) {
- if(stack.getItemDamage() != 0 && stack.getItemDamage() < 32000) {
- stacki += "-" + stack.getItemDamage();
- }
- //stacki += ":"+stack.stackSize;
- stacki += ":1";
- }
- }
- }
-
- obj.addProperty(y[yi]+x[xi], stacki);
- }
- recipeJsonForDamage.put(out.getItemDamage()>32000?0:out.getItemDamage(), obj);
- } else if (recipe instanceof ShapelessRecipes) {
- ShapelessRecipes shapeless = (ShapelessRecipes) recipe;
- String[] x = {"1","2","3"};
- String[] y = {"A","B","C"};
- for(int i=0; i<9; i++) {
- int xi = i%3;
- int yi = i/3;
-
- String stacki = "";
-
- ItemStack stack = null;
- if(i < shapeless.recipeItems.size()) {
- stack = shapeless.recipeItems.get(i);
- }
- if(stack != null) {
- addStack(stack, 0);
- Item stackItem = stack.getItem();
- String regName = stackItem.getRegistryName().replace("minecraft:", "");
- for(String bukkit2 : bukkitList) {
- if(bukkit2.equalsIgnoreCase(regName) || bukkit2.equalsIgnoreCase(regName+"_ITEM") ||
- (bukkit2.contains("@") && bukkit2.split("@")[1].equalsIgnoreCase(regName))) {
- stacki = bukkit2.split("@")[0];
- break;
- }
- }
- if(!stacki.isEmpty()) {
- if(stack.getItemDamage() != 0 && stack.getItemDamage() < 32000) {
- stacki += "-" + stack.getItemDamage();
- }
- //stacki += ":"+stack.stackSize;
- stacki += ":1";
- }
- }
-
- obj.addProperty(y[yi]+x[xi], stacki);
- }
- recipeJsonForDamage.put(out.getItemDamage() > 32000 ? 0 : out.getItemDamage(), obj);
- break;
- } else if (recipe instanceof ShapelessOreRecipe) {
- ShapelessOreRecipe shapeless = (ShapelessOreRecipe) recipe;
- String[] x = {"1","2","3"};
- String[] y = {"A","B","C"};
- for(int i=0; i<9; i++) {
- int xi = i%3;
- int yi = i/3;
-
- String stacki = "";
-
- ItemStack stack = null;
- if(i < shapeless.getRecipeSize()) {
- Object o = shapeless.getInput().get(i);
- if(o instanceof ItemStack) {
- stack = (ItemStack) o;
- } else if(o instanceof List<?>) {
- for(Object o2 : (List<?>)o) {
- if(o2 instanceof ItemStack) {
- stack = (ItemStack) o2;
- break;
- }
- }
- }
- }
- if(stack != null) {
- addStack(stack, 0);
- Item stackItem = stack.getItem();
- String regName = stackItem.getRegistryName().replace("minecraft:", "");
- for(String bukkit2 : bukkitList) {
- if(bukkit2.equalsIgnoreCase(regName) || bukkit2.equalsIgnoreCase(regName+"_ITEM") ||
- (bukkit2.contains("@") && bukkit2.split("@")[1].equalsIgnoreCase(regName))) {
- stacki = bukkit2.split("@")[0];
- break;
- }
- }
- if(!stacki.isEmpty()) {
- if(stack.getItemDamage() != 0 && stack.getItemDamage() < 32000) {
- stacki += "-" + stack.getItemDamage();
- }
- //stacki += ":"+stack.stackSize;
- stacki += ":1";
- }
- }
-
- obj.addProperty(y[yi]+x[xi], stacki);
- }
- recipeJsonForDamage.put(out.getItemDamage() > 32000 ? 0 : out.getItemDamage(), obj);
- break;
- }
- }
- }
-
- if(recipeJsonForDamage.isEmpty()) {
- ItemStack res = Utils.createItemStack(item,
- EnumChatFormatting.WHITE+item.getItemStackDisplayName(new ItemStack(item)),
- EnumChatFormatting.WHITE.toString()+EnumChatFormatting.BOLD+"COMMON");
- res.getTagCompound().setInteger("HideFlags", 254);
- NBTTagCompound ea = new NBTTagCompound();
- ea.setString("id", internalname);
- res.getTagCompound().setTag("ExtraAttributes", ea);
-
- JsonObject json = manager.getJsonForItem(res);
- json.addProperty("internalname", internalname);
-
- json.addProperty("modver", NotEnoughUpdates.VERSION);
- json.addProperty("vanilla", true);
-
- json.addProperty("clickcommand", "");
- try {
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Added: " + internalname));
- manager.writeJsonDefaultDir(json, internalname+".json");
- manager.loadItem(internalname);
- } catch(IOException e) {}
- } else {
- System.out.println("writing with recipe:" + internalname);
- for(Map.Entry<Integer, JsonObject> entry : recipeJsonForDamage.entrySet()) {
- ItemStack res = Utils.createItemStack(item,
- EnumChatFormatting.WHITE+item.getItemStackDisplayName(new ItemStack(item, 1, entry.getKey())),
- EnumChatFormatting.WHITE.toString()+EnumChatFormatting.BOLD+"COMMON");
- res.setItemDamage(entry.getKey());
- res.getTagCompound().setInteger("HideFlags", 254);
- NBTTagCompound ea = new NBTTagCompound();
- ea.setString("id", internalname);
- res.getTagCompound().setTag("ExtraAttributes", ea);
-
- JsonObject json = manager.getJsonForItem(res);
-
- if(entry.getKey() != 0 && entry.getKey() < 32000) {
- json.addProperty("internalname", internalname+"-"+entry.getKey());
- json.addProperty("parent", internalname);
- } else {
- json.addProperty("internalname", internalname);
- }
-
- json.addProperty("modver", NotEnoughUpdates.VERSION);
- json.addProperty("vanilla", true);
- json.addProperty("clickcommand", "viewrecipe");
- json.add("recipe", entry.getValue());
- try {
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Added: " + internalname));
- if(entry.getKey() != 0 && entry.getKey() < 32000) {
- manager.writeJsonDefaultDir(json, internalname+"-"+entry.getKey()+".json");
- } else {
- manager.writeJsonDefaultDir(json, internalname+".json");
- }
- manager.loadItem(internalname);
- } catch(IOException e) {}
- }
- }
- }
- }
- }
-
- //for(Map.Entry<String, JsonObject> item : manager.getItemInformation().entrySet()) {
+ return text;
+ }
+
+ //#region add vanilla items
+
+ AtomicBoolean running = new AtomicBoolean(false);
+ ScheduledExecutorService ses = Executors.newScheduledThreadPool(1);
+
+ String[] bukkitList = new String[]{
+ "ACACIA_DOOR_ITEM",
+ "ACACIA_FENCE",
+ "ACACIA_FENCE_GATE",
+ "ACACIA_STAIRS",
+ "ACTIVATOR_RAIL",
+ "ANVIL",
+ "APPLE",
+ "ARMOR_STAND",
+ "ARROW",
+ "BAKED_POTATO",
+ "BANNER",
+ "BARRIER",
+ "BEACON",
+ "BED",
+ "BEDROCK",
+ "BIRCH_DOOR_ITEM",
+ "BIRCH_FENCE",
+ "BIRCH_FENCE_GATE",
+ "BIRCH_WOOD_STAIRS@birch_stairs",
+ "BLAZE_POWDER",
+ "BLAZE_ROD",
+ "BOAT",
+ "BONE",
+ "BOOK",
+ "BOOK_AND_QUILL@writable_book",
+ "BOOKSHELF",
+ "BOW",
+ "BOWL",
+ "BREAD",
+ "BREWING_STAND_ITEM",
+ "BRICK@brick_block",
+ "BRICK_STAIRS",
+ "BROWN_MUSHROOM",
+ "BUCKET",
+ "CACTUS",
+ "CAKE",
+ "CARPET",
+ "CARROT_ITEM",
+ "CARROT_STICK@carrot_on_a_stick",
+ "CAULDRON_ITEM",
+ "CHAINMAIL_BOOTS",
+ "CHAINMAIL_CHESTPLATE",
+ "CHAINMAIL_HELMET",
+ "CHAINMAIL_LEGGINGS",
+ "CHEST",
+ "CLAY",
+ "CLAY_BALL",
+ "CLAY_BRICK@brick",
+ "COAL",
+ "COAL_BLOCK",
+ "COAL_ORE",
+ "COBBLE_WALL@cobblestone_wall",
+ "COBBLESTONE",
+ "COBBLESTONE_STAIRS@stone_stairs",
+ "COMMAND@command_block",
+ "COMMAND_MINECART@command_block_minecart",
+ "COMPASS",
+ "COOKED_BEEF",
+ "COOKED_CHICKEN",
+ "COOKED_FISH",
+ "COOKED_MUTTON",
+ "COOKED_RABBIT",
+ "COOKIE",
+ "DARK_OAK_DOOR_ITEM",
+ "DARK_OAK_FENCE",
+ "DARK_OAK_FENCE_GATE",
+ "DARK_OAK_STAIRS",
+ "DAYLIGHT_DETECTOR",
+ "DEAD_BUSH@deadbush",
+ "DETECTOR_RAIL",
+ "DIAMOND",
+ "DIAMOND_AXE",
+ "DIAMOND_BARDING@diamond_horse_armor",
+ "DIAMOND_BLOCK",
+ "DIAMOND_BOOTS",
+ "DIAMOND_CHESTPLATE",
+ "DIAMOND_HELMET",
+ "DIAMOND_HOE",
+ "DIAMOND_LEGGINGS",
+ "DIAMOND_ORE",
+ "DIAMOND_PICKAXE",
+ "DIAMOND_SPADE@diamond_shovel",
+ "DIAMOND_SWORD",
+ "DIODE@repeater",
+ "DIRT",
+ "DISPENSER",
+ "DOUBLE_PLANT",
+ "DRAGON_EGG",
+ "DROPPER",
+ "EGG",
+ "EMERALD",
+ "EMERALD_BLOCK",
+ "EMERALD_ORE",
+ "EMPTY_MAP@map",
+ "ENCHANTED_BOOK",
+ "ENCHANTMENT_TABLE@enchanting_table",
+ "ENDER_CHEST",
+ "ENDER_PEARL",
+ "ENDER_PORTAL_FRAME@end_portal_frame",
+ "ENDER_STONE@end_stone",
+ "EXP_BOTTLE@experience_bottle",
+ "EXPLOSIVE_MINECART@tnt_minecart",
+ "EYE_OF_ENDER@ender_eye",
+ "FEATHER",
+ "FENCE",
+ "FENCE_GATE",
+ "FERMENTED_SPIDER_EYE",
+ "FIREBALL@fire_charge",
+ "FIREWORK@fireworks",
+ "FIREWORK_CHARGE",
+ "FISHING_ROD",
+ "FLINT",
+ "FLINT_AND_STEEL",
+ "FLOWER_POT_ITEM",
+ "FURNACE",
+ "GHAST_TEAR",
+ "GLASS",
+ "GLASS_BOTTLE",
+ "GLOWSTONE",
+ "GLOWSTONE_DUST",
+ "GOLD_AXE@golden_axe",
+ "GOLD_BARDING@golden_horse_armor",
+ "GOLD_BLOCK",
+ "GOLD_BOOTS@golden_boots",
+ "GOLD_CHESTPLATE@golden_chestplate",
+ "GOLD_HELMET@golden_helmet",
+ "GOLD_HOE@golden_hoe",
+ "GOLD_INGOT",
+ "GOLD_LEGGINGS@golden_leggings",
+ "GOLD_NUGGET",
+ "GOLD_ORE",
+ "GOLD_PICKAXE@golden_pickaxe",
+ "GOLD_PLATE@light_weighted_pressure_plate",
+ "GOLD_RECORD@record_13",
+ "GOLD_SPADE@golden_shovel",
+ "GOLD_SWORD@golden_sword",
+ "GOLDEN_APPLE",
+ "GOLDEN_CARROT",
+ "GRASS",
+ "GRAVEL",
+ "GREEN_RECORD@record_cat",
+ "GRILLED_PORK@cooked_porkchop",
+ "HARD_CLAY@hardened_clay",
+ "HAY_BLOCK",
+ "HOPPER",
+ "HOPPER_MINECART",
+ "ICE",
+ "INK_SACK@dye",
+ "IRON_AXE",
+ "IRON_BARDING@iron_horse_armor",
+ "IRON_BLOCK",
+ "IRON_BOOTS",
+ "IRON_CHESTPLATE",
+ "IRON_DOOR",
+ "IRON_FENCE@iron_bars",
+ "IRON_HELMET",
+ "IRON_HOE",
+ "IRON_INGOT",
+ "IRON_LEGGINGS",
+ "IRON_ORE",
+ "IRON_PICKAXE",
+ "IRON_PLATE@heavy_weighted_pressure_plate",
+ "IRON_SPADE@iron_shovel",
+ "IRON_SWORD",
+ "IRON_TRAPDOOR",
+ "ITEM_FRAME",
+ "JACK_O_LANTERN@lit_pumpkin",
+ "JUKEBOX",
+ "JUNGLE_DOOR_ITEM",
+ "JUNGLE_FENCE",
+ "JUNGLE_FENCE_GATE",
+ "JUNGLE_WOOD_STAIRS@jungle_stairs",
+ "LADDER",
+ "LAPIS_BLOCK",
+ "LAPIS_ORE",
+ "LAVA_BUCKET",
+ "LEASH@lead",
+ "LEATHER",
+ "LEATHER_BOOTS",
+ "LEATHER_CHESTPLATE",
+ "LEATHER_HELMET",
+ "LEATHER_LEGGINGS",
+ "LEAVES",
+ "LEAVES_2@leaves2",
+ "LEVER",
+ "LOG",
+ "LOG_2@log2",
+ "LONG_GRASS@tallgrass",
+ "MAGMA_CREAM",
+ "MAP",
+ "MELON",
+ "MELON_BLOCK",
+ "MELON_SEEDS",
+ "MILK_BUCKET",
+ "MINECART",
+ "MOB_SPAWNER",
+ "MONSTER_EGG",
+ "MONSTER_EGGS@spawn_egg",
+ "MOSSY_COBBLESTONE",
+ "MUSHROOM_SOUP@mushroom_stew",
+ "MUTTON",
+ "MYCEL@mycelium",
+ "NAME_TAG",
+ "NETHER_BRICK",
+ "NETHER_BRICK_ITEM",
+ "NETHER_BRICK_STAIRS",
+ "NETHER_FENCE@nether_brick_fence",
+ "NETHER_STAR",
+ "NETHER_WARTS@nether_wart",
+ "NETHERRACK",
+ "NOTE_BLOCK@noteblock",
+ "OBSIDIAN",
+ "PACKED_ICE",
+ "PAINTING",
+ "PAPER",
+ "PISTON_BASE@piston",
+ "PISTON_STICKY_BASE@sticky_piston",
+ "POISONOUS_POTATO",
+ "PORK@porkchop",
+ "POTATO_ITEM",
+ "POTION",
+ "POWERED_MINECART@furnace_minecart",
+ "POWERED_RAIL@golden_rail",
+ "PRISMARINE",
+ "PRISMARINE_CRYSTALS",
+ "PRISMARINE_SHARD",
+ "PUMPKIN",
+ "PUMPKIN_PIE",
+ "PUMPKIN_SEEDS",
+ "QUARTZ",
+ "QUARTZ_BLOCK",
+ "QUARTZ_ORE",
+ "QUARTZ_STAIRS",
+ "RABBIT",
+ "RABBIT_FOOT",
+ "RABBIT_HIDE",
+ "RABBIT_STEW",
+ "RAILS@rail",
+ "RAW_BEEF@beef",
+ "RAW_CHICKEN@chicken",
+ "RAW_FISH@fish",
+ "RECORD_10@record_ward",
+ "RECORD_11",
+ "RECORD_12@record_wait",
+ "RECORD_3@record_blocks",
+ "RECORD_4@record_chirp",
+ "RECORD_5@record_far",
+ "RECORD_6@record_mall",
+ "RECORD_7@record_mellohi",
+ "RECORD_8@record_stal",
+ "RECORD_9@record_strad",
+ "RED_MUSHROOM",
+ "RED_ROSE@red_flower",
+ "RED_SANDSTONE",
+ "RED_SANDSTONE_STAIRS",
+ "REDSTONE",
+ "REDSTONE_BLOCK",
+ "REDSTONE_COMPARATOR@comparator",
+ "REDSTONE_LAMP_OFF@redstone_lamp",
+ "REDSTONE_ORE",
+ "REDSTONE_TORCH_ON@redstone_torch",
+ "ROTTEN_FLESH",
+ "SADDLE",
+ "SAND",
+ "SANDSTONE",
+ "SANDSTONE_STAIRS",
+ "SAPLING",
+ "SEA_LANTERN",
+ "SEEDS@wheat_seeds",
+ "SHEARS",
+ "SIGN",
+ "SKULL_ITEM",
+ "SLIME_BALL",
+ "SLIME_BLOCK@slime",
+ "SMOOTH_BRICK@stonebrick",
+ "SMOOTH_STAIRS@stone_brick_stairs",
+ "SNOW@snow_layer",
+ "SNOW_BALL@snowball",
+ "SNOW_BLOCK@snow",
+ "SOUL_SAND",
+ "SPECKLED_MELON",
+ "SPIDER_EYE",
+ "SPONGE",
+ "SPRUCE_DOOR_ITEM",
+ "SPRUCE_FENCE",
+ "SPRUCE_FENCE_GATE",
+ "SPRUCE_WOOD_STAIRS@spruce_stairs",
+ "STAINED_CLAY@stained_hardened_clay",
+ "STAINED_GLASS",
+ "STAINED_GLASS_PANE",
+ "STEP@stone_slab",
+ "STICK",
+ "STONE",
+ "STONE_AXE",
+ "STONE_BUTTON",
+ "STONE_HOE",
+ "STONE_PICKAXE",
+ "STONE_PLATE@stone_pressure_plate",
+ "STONE_SLAB2",
+ "STONE_SPADE@stone_shovel",
+ "STONE_SWORD",
+ "STORAGE_MINECART@chest_minecart",
+ "STRING",
+ "SUGAR",
+ "SUGAR_CANE@reeds",
+ "SULPHUR@gunpowder",
+ "THIN_GLASS@glass_pane",
+ "TNT",
+ "TORCH",
+ "TRAP_DOOR@trapdoor",
+ "TRAPPED_CHEST",
+ "TRIPWIRE_HOOK",
+ "VINE",
+ "WATCH@clock",
+ "WATER_BUCKET",
+ "WATER_LILY@waterlily",
+ "WEB",
+ "WHEAT",
+ "WOOD@planks",
+ "WOOD_AXE@wooden_axe",
+ "WOOD_BUTTON@wooden_button",
+ "WOOD_DOOR@wooden_door",
+ "WOOD_HOE@wooden_hoe",
+ "WOOD_PICKAXE@wooden_pickaxe",
+ "WOOD_PLATE@wooden_pressure_plate",
+ "WOOD_SPADE@wooden_shovel",
+ "WOOD_STAIRS@oak_stairs",
+ "WOOD_STEP@wooden_slab",
+ "WOOD_SWORD@wooden_sword",
+ "WOOL",
+ "WORKBENCH@crafting_table",
+ "WRITTEN_BOOK",
+ "YELLOW_FLOWER"
+ };
+
+ private void addStack(ItemStack stackToAdd, int depth) {
+ if (depth > 16) return;
+
+ String regName2 = stackToAdd.getItem().getRegistryName().replace("minecraft:", "");
+ String internalname = null;
+ for (String bukkit2 : bukkitList) {
+ if (bukkit2.equalsIgnoreCase(regName2) ||
+ (bukkit2.contains("@") && bukkit2.split("@")[1].equalsIgnoreCase(regName2))) {
+ internalname = bukkit2.split("@")[0];
+ break;
+ }
+ }
+ if (internalname == null) return;
+
+ if (stackToAdd.getItemDamage() != 0 && stackToAdd.getItemDamage() < 32000) {
+ internalname += "-" + stackToAdd.getItemDamage();
+ }
+
+ if (manager.getItemInformation().containsKey(internalname)) return;
+
+ JsonObject recipeJson = null;
+ for (IRecipe recipe : CraftingManager.getInstance().getRecipeList()) {
+ ItemStack out = recipe.getRecipeOutput();
+ if (out != null && out.getItem() == stackToAdd.getItem() &&
+ (stackToAdd.getItemDamage() >= 32000 || out.getItemDamage() == stackToAdd.getItemDamage())) {
+ recipeJson = new JsonObject();
+
+ if (recipe instanceof ShapedRecipes) {
+ ShapedRecipes shaped = (ShapedRecipes) recipe;
+
+ String[] x = {"1", "2", "3"};
+ String[] y = {"A", "B", "C"};
+ for (int i = 0; i < 9; i++) {
+ int xi = i % 3;
+ int yi = i / 3;
+
+ String stacki = "";
+
+ int recipeIndex = i - (3 - shaped.recipeWidth) * yi;
+ if (xi < shaped.recipeWidth && recipeIndex < shaped.recipeItems.length) {
+ ItemStack stack = shaped.recipeItems[recipeIndex];
+ if (stack != null) {
+ if (stack.getItem() != stackToAdd.getItem() ||
+ (stackToAdd.getItemDamage() < 32000 && stack.getItemDamage() != stackToAdd.getItemDamage())) {
+ addStack(stack, depth + 1);
+ }
+
+ Item stackItem = stack.getItem();
+ String regName = stackItem.getRegistryName().replace("minecraft:", "");
+ for (String bukkit2 : bukkitList) {
+ if (bukkit2.equalsIgnoreCase(regName) ||
+ (bukkit2.contains("@") && bukkit2.split("@")[1].equalsIgnoreCase(regName))) {
+ stacki = bukkit2.split("@")[0];
+ break;
+ }
+ }
+ if (!stacki.isEmpty()) {
+ if (stack.getItemDamage() != 0 && stack.getItemDamage() < 32000) {
+ stacki += "-" + stack.getItemDamage();
+ }
+ stacki += ":" + stack.stackSize;
+ }
+ }
+ }
+
+ recipeJson.addProperty(y[yi] + x[xi], stacki);
+ }
+ break;
+ } else if (recipe instanceof ShapedOreRecipe) {
+ ShapedOreRecipe shaped = (ShapedOreRecipe) recipe;
+ int width = (int) Utils.getField(ShapedOreRecipe.class, recipe, "width");
+ String[] x = {"1", "2", "3"};
+ String[] y = {"A", "B", "C"};
+ for (int i = 0; i < 9; i++) {
+ int xi = i % 3;
+ int yi = i / 3;
+
+ String stacki = "";
+
+ int recipeIndex = i - (3 - width) * yi;
+ if (xi < width && recipeIndex < shaped.getRecipeSize()) {
+ ItemStack stack = null;
+ if (recipeIndex < shaped.getRecipeSize()) {
+ Object o = shaped.getInput()[recipeIndex];
+ if (o instanceof ItemStack) {
+ stack = (ItemStack) o;
+ } else if (o instanceof List<?>) {
+ for (Object o2 : (List<?>) o) {
+ if (o2 instanceof ItemStack) {
+ stack = (ItemStack) o2;
+ break;
+ }
+ }
+ }
+ }
+ if (stack != null) {
+ if (stack.getItem() != stackToAdd.getItem() ||
+ (stackToAdd.getItemDamage() < 32000 && stack.getItemDamage() != stackToAdd.getItemDamage())) {
+ addStack(stack, depth + 1);
+ }
+ Item stackItem = stack.getItem();
+ String regName = stackItem.getRegistryName().replace("minecraft:", "");
+ for (String bukkit2 : bukkitList) {
+ if (bukkit2.equalsIgnoreCase(regName) || bukkit2.equalsIgnoreCase(regName + "_ITEM") ||
+ (bukkit2.contains("@") && bukkit2.split("@")[1].equalsIgnoreCase(regName))) {
+ stacki = bukkit2.split("@")[0];
+ break;
+ }
+ }
+ if (!stacki.isEmpty()) {
+ if (stack.getItemDamage() != 0 && stack.getItemDamage() < 32000) {
+ stacki += "-" + stack.getItemDamage();
+ }
+ //stacki += ":"+stack.stackSize;
+ stacki += ":1";
+ }
+ }
+ }
+
+ recipeJson.addProperty(y[yi] + x[xi], stacki);
+ }
+ } else if (recipe instanceof ShapelessRecipes) {
+ ShapelessRecipes shapeless = (ShapelessRecipes) recipe;
+ String[] x = {"1", "2", "3"};
+ String[] y = {"A", "B", "C"};
+ for (int i = 0; i < 9; i++) {
+ int xi = i % 3;
+ int yi = i / 3;
+
+ String stacki = "";
+
+ ItemStack stack = null;
+ if (i < shapeless.recipeItems.size()) {
+ stack = shapeless.recipeItems.get(i);
+ }
+ if (stack != null) {
+ if (stack.getItem() != stackToAdd.getItem() ||
+ (stackToAdd.getItemDamage() < 32000 && stack.getItemDamage() != stackToAdd.getItemDamage())) {
+ addStack(stack, depth + 1);
+ }
+ Item stackItem = stack.getItem();
+ String regName = stackItem.getRegistryName().replace("minecraft:", "");
+ for (String bukkit2 : bukkitList) {
+ if (bukkit2.equalsIgnoreCase(regName) || bukkit2.equalsIgnoreCase(regName + "_ITEM") ||
+ (bukkit2.contains("@") && bukkit2.split("@")[1].equalsIgnoreCase(regName))) {
+ stacki = bukkit2.split("@")[0];
+ break;
+ }
+ }
+ if (!stacki.isEmpty()) {
+ if (stack.getItemDamage() != 0 && stack.getItemDamage() < 32000) {
+ stacki += "-" + stack.getItemDamage();
+ }
+ //stacki += ":"+stack.stackSize;
+ stacki += ":1";
+ }
+ }
+
+ recipeJson.addProperty(y[yi] + x[xi], stacki);
+ }
+ break;
+ } else if (recipe instanceof ShapelessOreRecipe) {
+ ShapelessOreRecipe shapeless = (ShapelessOreRecipe) recipe;
+ String[] x = {"1", "2", "3"};
+ String[] y = {"A", "B", "C"};
+ for (int i = 0; i < 9; i++) {
+ int xi = i % 3;
+ int yi = i / 3;
+
+ String stacki = "";
+
+ ItemStack stack = null;
+ if (i < shapeless.getRecipeSize()) {
+ Object o = shapeless.getInput().get(i);
+ if (o instanceof ItemStack) {
+ stack = (ItemStack) o;
+ } else if (o instanceof List<?>) {
+ for (Object o2 : (List<?>) o) {
+ if (o2 instanceof ItemStack) {
+ stack = (ItemStack) o2;
+ break;
+ }
+ }
+ }
+ }
+ if (stack != null) {
+ if (stack.getItem() != stackToAdd.getItem() ||
+ (stackToAdd.getItemDamage() < 32000 && stack.getItemDamage() != stackToAdd.getItemDamage())) {
+ addStack(stack, depth + 1);
+ }
+ Item stackItem = stack.getItem();
+ String regName = stackItem.getRegistryName().replace("minecraft:", "");
+ for (String bukkit2 : bukkitList) {
+ if (bukkit2.equalsIgnoreCase(regName) || bukkit2.equalsIgnoreCase(regName + "_ITEM") ||
+ (bukkit2.contains("@") && bukkit2.split("@")[1].equalsIgnoreCase(regName))) {
+ stacki = bukkit2.split("@")[0];
+ break;
+ }
+ }
+ if (!stacki.isEmpty()) {
+ if (stack.getItemDamage() != 0 && stack.getItemDamage() < 32000) {
+ stacki += "-" + stack.getItemDamage();
+ }
+ //stacki += ":"+stack.stackSize;
+ stacki += ":1";
+ }
+ }
+
+ recipeJson.addProperty(y[yi] + x[xi], stacki);
+ }
+ break;
+ }
+ }
+
+ }
+ ItemStack res = Utils.createItemStack(
+ stackToAdd.getItem(),
+ EnumChatFormatting.WHITE + stackToAdd.getItem().getItemStackDisplayName(stackToAdd),
+ EnumChatFormatting.WHITE.toString() + EnumChatFormatting.BOLD + "COMMON"
+ );
+ if (stackToAdd.getItemDamage() != 0 && stackToAdd.getItemDamage() < 32000) {
+ res.setItemDamage(stackToAdd.getItemDamage());
+ }
+ res.getTagCompound().setInteger("HideFlags", 254);
+ NBTTagCompound ea = new NBTTagCompound();
+ ea.setString("id", internalname);
+ res.getTagCompound().setTag("ExtraAttributes", ea);
+
+ JsonObject json = manager.getJsonForItem(res);
+ if (stackToAdd.getItemDamage() != 0 && stackToAdd.getItemDamage() < 32000) {
+ json.addProperty("parent", internalname.split("-")[0]);
+ }
+
+ json.addProperty("internalname", internalname);
+ json.addProperty("modver", NotEnoughUpdates.VERSION);
+ json.addProperty("vanilla", true);
+
+ if (recipeJson != null) {
+ json.add("recipe", recipeJson);
+ json.addProperty("clickcommand", "viewrecipe");
+ } else {
+ json.addProperty("clickcommand", "");
+ }
+
+ json.addProperty("modver", NotEnoughUpdates.VERSION);
+
+ try {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Added: " + internalname));
+ manager.writeJsonDefaultDir(json, internalname + ".json");
+ manager.loadItem(internalname);
+ } catch (IOException ignored) {
+ }
+ }
+
+ @Override
+ public boolean keyboardInput() {
+ if (running.get() || true) return false;
+ if (Keyboard.isKeyDown(Keyboard.KEY_J)) {
+ running.set(!running.get());
+
+ for (String bukkit : bukkitList) {
+ String internalname = bukkit.split("@")[0];
+ if (true || !manager.getItemInformation().containsKey(internalname)) {
+ //System.out.println("adding vanilla: " + internalname);
+ String vanilla = internalname.toLowerCase().replace("_item", "");
+ if (bukkit.contains("@")) {
+ vanilla = bukkit.split("@")[1];
+ }
+ Item item = Item.itemRegistry.getObject(new ResourceLocation(vanilla));
+ if (item == null) {
+ item = Item.getItemFromBlock(Block.blockRegistry.getObject(new ResourceLocation(vanilla)));
+ }
+ if (item != null) {
+ HashMap<Integer, JsonObject> recipeJsonForDamage = new HashMap<>();
+ for (IRecipe recipe : CraftingManager.getInstance().getRecipeList()) {
+ ItemStack out = recipe.getRecipeOutput();
+ if (out != null && out.getItem() == item) {
+ System.out.println("Found recipe for : " + internalname + ":" + recipe);
+ JsonObject obj = new JsonObject();
+
+ if (recipe instanceof ShapedRecipes) {
+ ShapedRecipes shaped = (ShapedRecipes) recipe;
+ String[] x = {"1", "2", "3"};
+ String[] y = {"A", "B", "C"};
+ for (int i = 0; i < 9; i++) {
+ int xi = i % 3;
+ int yi = i / 3;
+
+ String stacki = "";
+
+ int recipeIndex = i - (3 - shaped.recipeWidth) * yi;
+ if (xi < shaped.recipeWidth && recipeIndex < shaped.recipeItems.length) {
+ ItemStack stack = shaped.recipeItems[recipeIndex];
+ if (stack != null) {
+ addStack(stack, 0);
+ Item stackItem = stack.getItem();
+ String regName = stackItem.getRegistryName().replace("minecraft:", "");
+ for (String bukkit2 : bukkitList) {
+ if (bukkit2.equalsIgnoreCase(regName) || bukkit2.equalsIgnoreCase(regName + "_ITEM") ||
+ (bukkit2.contains("@") && bukkit2.split("@")[1].equalsIgnoreCase(regName))) {
+ stacki = bukkit2.split("@")[0];
+ break;
+ }
+ }
+ if (!stacki.isEmpty()) {
+ if (stack.getItemDamage() != 0 && stack.getItemDamage() < 32000) {
+ stacki += "-" + stack.getItemDamage();
+ }
+ //stacki += ":"+stack.stackSize;
+ stacki += ":1";
+ }
+ }
+ }
+
+ obj.addProperty(y[yi] + x[xi], stacki);
+ }
+ recipeJsonForDamage.put(out.getItemDamage() > 32000 ? 0 : out.getItemDamage(), obj);
+ } else if (recipe instanceof ShapedOreRecipe) {
+ ShapedOreRecipe shaped = (ShapedOreRecipe) recipe;
+ int width = (int) Utils.getField(ShapedOreRecipe.class, recipe, "width");
+ String[] x = {"1", "2", "3"};
+ String[] y = {"A", "B", "C"};
+ for (int i = 0; i < 9; i++) {
+ int xi = i % 3;
+ int yi = i / 3;
+
+ String stacki = "";
+
+ int recipeIndex = i - (3 - width) * yi;
+ if (xi < width && recipeIndex < shaped.getRecipeSize()) {
+ ItemStack stack = null;
+ if (recipeIndex < shaped.getRecipeSize()) {
+ Object o = shaped.getInput()[recipeIndex];
+ if (o instanceof ItemStack) {
+ stack = (ItemStack) o;
+ } else if (o instanceof List<?>) {
+ for (Object o2 : (List<?>) o) {
+ if (o2 instanceof ItemStack) {
+ stack = (ItemStack) o2;
+ break;
+ }
+ }
+ }
+ }
+ if (stack != null) {
+ addStack(stack, 0);
+ Item stackItem = stack.getItem();
+ String regName = stackItem.getRegistryName().replace("minecraft:", "");
+ for (String bukkit2 : bukkitList) {
+ if (bukkit2.equalsIgnoreCase(regName) || bukkit2.equalsIgnoreCase(regName + "_ITEM") ||
+ (bukkit2.contains("@") && bukkit2.split("@")[1].equalsIgnoreCase(regName))) {
+ stacki = bukkit2.split("@")[0];
+ break;
+ }
+ }
+ if (!stacki.isEmpty()) {
+ if (stack.getItemDamage() != 0 && stack.getItemDamage() < 32000) {
+ stacki += "-" + stack.getItemDamage();
+ }
+ //stacki += ":"+stack.stackSize;
+ stacki += ":1";
+ }
+ }
+ }
+
+ obj.addProperty(y[yi] + x[xi], stacki);
+ }
+ recipeJsonForDamage.put(out.getItemDamage() > 32000 ? 0 : out.getItemDamage(), obj);
+ } else if (recipe instanceof ShapelessRecipes) {
+ ShapelessRecipes shapeless = (ShapelessRecipes) recipe;
+ String[] x = {"1", "2", "3"};
+ String[] y = {"A", "B", "C"};
+ for (int i = 0; i < 9; i++) {
+ int xi = i % 3;
+ int yi = i / 3;
+
+ String stacki = "";
+
+ ItemStack stack = null;
+ if (i < shapeless.recipeItems.size()) {
+ stack = shapeless.recipeItems.get(i);
+ }
+ if (stack != null) {
+ addStack(stack, 0);
+ Item stackItem = stack.getItem();
+ String regName = stackItem.getRegistryName().replace("minecraft:", "");
+ for (String bukkit2 : bukkitList) {
+ if (bukkit2.equalsIgnoreCase(regName) || bukkit2.equalsIgnoreCase(regName + "_ITEM") ||
+ (bukkit2.contains("@") && bukkit2.split("@")[1].equalsIgnoreCase(regName))) {
+ stacki = bukkit2.split("@")[0];
+ break;
+ }
+ }
+ if (!stacki.isEmpty()) {
+ if (stack.getItemDamage() != 0 && stack.getItemDamage() < 32000) {
+ stacki += "-" + stack.getItemDamage();
+ }
+ //stacki += ":"+stack.stackSize;
+ stacki += ":1";
+ }
+ }
+
+ obj.addProperty(y[yi] + x[xi], stacki);
+ }
+ recipeJsonForDamage.put(out.getItemDamage() > 32000 ? 0 : out.getItemDamage(), obj);
+ break;
+ } else if (recipe instanceof ShapelessOreRecipe) {
+ ShapelessOreRecipe shapeless = (ShapelessOreRecipe) recipe;
+ String[] x = {"1", "2", "3"};
+ String[] y = {"A", "B", "C"};
+ for (int i = 0; i < 9; i++) {
+ int xi = i % 3;
+ int yi = i / 3;
+
+ String stacki = "";
+
+ ItemStack stack = null;
+ if (i < shapeless.getRecipeSize()) {
+ Object o = shapeless.getInput().get(i);
+ if (o instanceof ItemStack) {
+ stack = (ItemStack) o;
+ } else if (o instanceof List<?>) {
+ for (Object o2 : (List<?>) o) {
+ if (o2 instanceof ItemStack) {
+ stack = (ItemStack) o2;
+ break;
+ }
+ }
+ }
+ }
+ if (stack != null) {
+ addStack(stack, 0);
+ Item stackItem = stack.getItem();
+ String regName = stackItem.getRegistryName().replace("minecraft:", "");
+ for (String bukkit2 : bukkitList) {
+ if (bukkit2.equalsIgnoreCase(regName) || bukkit2.equalsIgnoreCase(regName + "_ITEM") ||
+ (bukkit2.contains("@") && bukkit2.split("@")[1].equalsIgnoreCase(regName))) {
+ stacki = bukkit2.split("@")[0];
+ break;
+ }
+ }
+ if (!stacki.isEmpty()) {
+ if (stack.getItemDamage() != 0 && stack.getItemDamage() < 32000) {
+ stacki += "-" + stack.getItemDamage();
+ }
+ //stacki += ":"+stack.stackSize;
+ stacki += ":1";
+ }
+ }
+
+ obj.addProperty(y[yi] + x[xi], stacki);
+ }
+ recipeJsonForDamage.put(out.getItemDamage() > 32000 ? 0 : out.getItemDamage(), obj);
+ break;
+ }
+ }
+ }
+
+ if (recipeJsonForDamage.isEmpty()) {
+ ItemStack res = Utils.createItemStack(
+ item,
+ EnumChatFormatting.WHITE + item.getItemStackDisplayName(new ItemStack(item)),
+ EnumChatFormatting.WHITE.toString() + EnumChatFormatting.BOLD + "COMMON"
+ );
+ res.getTagCompound().setInteger("HideFlags", 254);
+ NBTTagCompound ea = new NBTTagCompound();
+ ea.setString("id", internalname);
+ res.getTagCompound().setTag("ExtraAttributes", ea);
+
+ JsonObject json = manager.getJsonForItem(res);
+ json.addProperty("internalname", internalname);
+
+ json.addProperty("modver", NotEnoughUpdates.VERSION);
+ json.addProperty("vanilla", true);
+
+ json.addProperty("clickcommand", "");
+ try {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Added: " + internalname));
+ manager.writeJsonDefaultDir(json, internalname + ".json");
+ manager.loadItem(internalname);
+ } catch (IOException ignored) {
+ }
+ } else {
+ System.out.println("writing with recipe:" + internalname);
+ for (Map.Entry<Integer, JsonObject> entry : recipeJsonForDamage.entrySet()) {
+ ItemStack res = Utils.createItemStack(
+ item,
+ EnumChatFormatting.WHITE + item.getItemStackDisplayName(new ItemStack(item, 1, entry.getKey())),
+ EnumChatFormatting.WHITE.toString() + EnumChatFormatting.BOLD + "COMMON"
+ );
+ res.setItemDamage(entry.getKey());
+ res.getTagCompound().setInteger("HideFlags", 254);
+ NBTTagCompound ea = new NBTTagCompound();
+ ea.setString("id", internalname);
+ res.getTagCompound().setTag("ExtraAttributes", ea);
+
+ JsonObject json = manager.getJsonForItem(res);
+
+ if (entry.getKey() != 0 && entry.getKey() < 32000) {
+ json.addProperty("internalname", internalname + "-" + entry.getKey());
+ json.addProperty("parent", internalname);
+ } else {
+ json.addProperty("internalname", internalname);
+ }
+
+ json.addProperty("modver", NotEnoughUpdates.VERSION);
+ json.addProperty("vanilla", true);
+ json.addProperty("clickcommand", "viewrecipe");
+ json.add("recipe", entry.getValue());
+ try {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Added: " + internalname));
+ if (entry.getKey() != 0 && entry.getKey() < 32000) {
+ manager.writeJsonDefaultDir(json, internalname + "-" + entry.getKey() + ".json");
+ } else {
+ manager.writeJsonDefaultDir(json, internalname + ".json");
+ }
+ manager.loadItem(internalname);
+ } catch (IOException ignored) {
+ }
+ }
+ }
+ }
+ }
+ }
+
+ //for(Map.Entry<String, JsonObject> item : manager.getItemInformation().entrySet()) {
/*if(!item.getValue().has("infoType") || item.getValue().get("infoType").getAsString().isEmpty()) {
if(item.getValue().has("info") && item.getValue().get("info").getAsJsonArray().size()>0) {
item.getValue().addProperty("infoType", "WIKI_URL");
@@ -1009,7 +1016,7 @@ public class DevInfoPane extends TextInfoPane {
} catch(IOException e){}
manager.loadItem(item.getKey());
}*/
- }
+ }
/*if(running.get()) {
List<String> add = new ArrayList<>();
@@ -1033,7 +1040,7 @@ public class DevInfoPane extends TextInfoPane {
}
}, 1000L, TimeUnit.MILLISECONDS);
}*/
- //}
+ //}
/*if(Keyboard.isKeyDown(Keyboard.KEY_J) && !running) {
running = true;
List<String> add = new ArrayList<>();
@@ -1060,7 +1067,7 @@ public class DevInfoPane extends TextInfoPane {
}
}, 1000L, TimeUnit.MILLISECONDS);
}*/
- return false;
- }
- //#endregion
+ return false;
+ }
+ //#endregion
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/FlipperInfoPane.java b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/FlipperInfoPane.java
index b6db53f3..441bf735 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/FlipperInfoPane.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/FlipperInfoPane.java
@@ -2,109 +2,121 @@ package io.github.moulberry.notenoughupdates.infopanes;
import io.github.moulberry.notenoughupdates.NEUManager;
import io.github.moulberry.notenoughupdates.NEUOverlay;
-import io.github.moulberry.notenoughupdates.util.Utils;
import io.github.moulberry.notenoughupdates.itemeditor.GuiElementTextField;
+import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.GlStateManager;
-import static io.github.moulberry.notenoughupdates.util.GuiTextures.*;
-import static io.github.moulberry.notenoughupdates.itemeditor.GuiElementTextField.*;
-
import java.awt.*;
-public class FlipperInfoPane extends InfoPane {
+import static io.github.moulberry.notenoughupdates.itemeditor.GuiElementTextField.NO_SPACE;
+import static io.github.moulberry.notenoughupdates.itemeditor.GuiElementTextField.NUM_ONLY;
+import static io.github.moulberry.notenoughupdates.util.GuiTextures.off;
+import static io.github.moulberry.notenoughupdates.util.GuiTextures.on;
- /**
- * Not currently used in BETA-1.6
- */
-
- protected String title;
- protected String text;
-
- GuiElementTextField minPrice = new GuiElementTextField("0", NUM_ONLY | NO_SPACE);
- GuiElementTextField maxPrice = new GuiElementTextField("100000000", NUM_ONLY | NO_SPACE);
- GuiElementTextField priceDiff = new GuiElementTextField("1000000", NUM_ONLY | NO_SPACE);
-
- public FlipperInfoPane(NEUOverlay overlay, NEUManager manager, String title, String text) {
- super(overlay, manager);
- this.title = title;
- this.text = text;
-
- minPrice.setSize(60, 16);
- maxPrice.setSize(60, 16);
- priceDiff.setSize(60, 16);
- }
-
- public void render(int width, int height, Color bg, Color fg, ScaledResolution scaledresolution, int mouseX, int mouseY) {
- FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
-
- int paneWidth = (int)(width/3*overlay.getWidthMult());
- int rightSide = (int)(width*overlay.getInfoPaneOffsetFactor());
- int leftSide = rightSide - paneWidth;
-
- int titleLen = fr.getStringWidth(title);
- fr.drawString(title, (leftSide+rightSide-titleLen)/2, overlay.getBoxPadding() + 5,
- Color.WHITE.getRGB());
-
- int y = 0;
- y += renderParagraph(width, height, y, "Bazaar Flips", bg);
- //draw controls
- y += 20;
- y += renderParagraph(width, height, y, "-- Strong Dragon Fragments", bg);
- y += renderParagraph(width, height, y, "-- Strong Dragon Fragments", bg);
- y += renderParagraph(width, height, y, "-- Strong Dragon Fragments", bg);
- y += renderParagraph(width, height, y, "-- Strong Dragon Fragments", bg);
-
- y += renderParagraph(width, height, y, "AH Flips", bg);
- //min price, max price, price diff, blacklist stackables
- //GuiElementButton stackables = new GuiElementButton("1000000", NUM_ONLY | NO_SPACE);
-
- y += 10;
- int x = 10;
- fr.drawString("Min Price: ", x, y, Color.WHITE.getRGB());
- minPrice.render(x, y+10); x += 70;
- fr.drawString("Max Price: ", x, y, Color.WHITE.getRGB());
- maxPrice.render(x, y+10); x += 70;
- fr.drawString("Price Diff: ", x, y, Color.WHITE.getRGB());
- priceDiff.render(x, y+10); x += 70;
- fr.drawString("Incl. Stackables: ", x, y, Color.WHITE.getRGB());
- drawButton(x, y, false);
-
- drawRect(leftSide+overlay.getBoxPadding()-5, overlay.getBoxPadding()-5,
- rightSide-overlay.getBoxPadding()+5, height-overlay.getBoxPadding()+5, bg.getRGB());
- }
-
- private void drawButton(int x, int y, boolean enabled) {
- GlStateManager.color(1f, 1f, 1f, 1f);
- Minecraft.getMinecraft().getTextureManager().bindTexture((enabled) ? on : off);
- Utils.drawTexturedRect(x, y, 48, 16);
- }
-
- public void mouseInput(int width, int height, int mouseX, int mouseY, boolean mouseDown) {
-
- }
-
- public boolean keyboardInput() {
- return false;
- }
-
- private int renderParagraph(int width, int height, int startY, String text, Color bg) {
- FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
-
- int paneWidth = (int)(width/3*overlay.getWidthMult());
- int rightSide = (int)(width*overlay.getInfoPaneOffsetFactor());
- int leftSide = rightSide - paneWidth;
-
- int yOff = 0;
- for(String line : text.split("\n")) {
- yOff += Utils.renderStringTrimWidth(line, fr, false,leftSide+overlay.getBoxPadding() + 5,
- startY+overlay.getBoxPadding() + 10 + yOff,
- width*1/3-overlay.getBoxPadding()*2-10, Color.WHITE.getRGB(), -1);
- yOff += 16;
- }
-
- return yOff;
- }
+/**
+ * Not currently used
+ */
+public class FlipperInfoPane extends InfoPane {
+ protected String title;
+ protected String text;
+
+ GuiElementTextField minPrice = new GuiElementTextField("0", NUM_ONLY | NO_SPACE);
+ GuiElementTextField maxPrice = new GuiElementTextField("100000000", NUM_ONLY | NO_SPACE);
+ GuiElementTextField priceDiff = new GuiElementTextField("1000000", NUM_ONLY | NO_SPACE);
+
+ public FlipperInfoPane(NEUOverlay overlay, NEUManager manager, String title, String text) {
+ super(overlay, manager);
+ this.title = title;
+ this.text = text;
+
+ minPrice.setSize(60, 16);
+ maxPrice.setSize(60, 16);
+ priceDiff.setSize(60, 16);
+ }
+
+ public void render(
+ int width,
+ int height,
+ Color bg,
+ Color fg,
+ ScaledResolution scaledresolution,
+ int mouseX,
+ int mouseY
+ ) {
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+
+ int paneWidth = (int) (width / 3 * overlay.getWidthMult());
+ int rightSide = (int) (width * overlay.getInfoPaneOffsetFactor());
+ int leftSide = rightSide - paneWidth;
+
+ int titleLen = fr.getStringWidth(title);
+ fr.drawString(title, (leftSide + rightSide - titleLen) / 2, overlay.getBoxPadding() + 5,
+ Color.WHITE.getRGB()
+ );
+
+ int y = 0;
+ y += renderParagraph(width, height, y, "Bazaar Flips", bg);
+ //draw controls
+ y += 20;
+ y += renderParagraph(width, height, y, "-- Strong Dragon Fragments", bg);
+ y += renderParagraph(width, height, y, "-- Strong Dragon Fragments", bg);
+ y += renderParagraph(width, height, y, "-- Strong Dragon Fragments", bg);
+ y += renderParagraph(width, height, y, "-- Strong Dragon Fragments", bg);
+
+ y += renderParagraph(width, height, y, "AH Flips", bg);
+ //min price, max price, price diff, blacklist stackables
+ //GuiElementButton stackables = new GuiElementButton("1000000", NUM_ONLY | NO_SPACE);
+
+ y += 10;
+ int x = 10;
+ fr.drawString("Min Price: ", x, y, Color.WHITE.getRGB());
+ minPrice.render(x, y + 10);
+ x += 70;
+ fr.drawString("Max Price: ", x, y, Color.WHITE.getRGB());
+ maxPrice.render(x, y + 10);
+ x += 70;
+ fr.drawString("Price Diff: ", x, y, Color.WHITE.getRGB());
+ priceDiff.render(x, y + 10);
+ x += 70;
+ fr.drawString("Incl. Stackables: ", x, y, Color.WHITE.getRGB());
+ drawButton(x, y, false);
+
+ drawRect(leftSide + overlay.getBoxPadding() - 5, overlay.getBoxPadding() - 5,
+ rightSide - overlay.getBoxPadding() + 5, height - overlay.getBoxPadding() + 5, bg.getRGB()
+ );
+ }
+
+ private void drawButton(int x, int y, boolean enabled) {
+ GlStateManager.color(1f, 1f, 1f, 1f);
+ Minecraft.getMinecraft().getTextureManager().bindTexture((enabled) ? on : off);
+ Utils.drawTexturedRect(x, y, 48, 16);
+ }
+
+ public void mouseInput(int width, int height, int mouseX, int mouseY, boolean mouseDown) {}
+
+ public boolean keyboardInput() {
+ return false;
+ }
+
+ private int renderParagraph(int width, int height, int startY, String text, Color bg) {
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+
+ int paneWidth = (int) (width / 3 * overlay.getWidthMult());
+ int rightSide = (int) (width * overlay.getInfoPaneOffsetFactor());
+ int leftSide = rightSide - paneWidth;
+
+ int yOff = 0;
+ for (String line : text.split("\n")) {
+ yOff += Utils.renderStringTrimWidth(line, fr, false, leftSide + overlay.getBoxPadding() + 5,
+ startY + overlay.getBoxPadding() + 10 + yOff,
+ width * 1 / 3 - overlay.getBoxPadding() * 2 - 10, Color.WHITE.getRGB(), -1
+ );
+ yOff += 16;
+ }
+
+ return yOff;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/HTMLInfoPane.java b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/HTMLInfoPane.java
index df7069d4..baf88457 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/HTMLInfoPane.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/HTMLInfoPane.java
@@ -8,9 +8,9 @@ import info.bliki.wiki.model.WikiModel;
import info.bliki.wiki.tags.HTMLBlockTag;
import info.bliki.wiki.tags.HTMLTag;
import info.bliki.wiki.tags.IgnoreTag;
-import io.github.moulberry.notenoughupdates.util.AllowEmptyHTMLTag;
import io.github.moulberry.notenoughupdates.NEUManager;
import io.github.moulberry.notenoughupdates.NEUOverlay;
+import io.github.moulberry.notenoughupdates.util.AllowEmptyHTMLTag;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
@@ -30,239 +30,269 @@ import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.CharsetEncoder;
import java.nio.charset.StandardCharsets;
+import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
public class HTMLInfoPane extends TextInfoPane {
-
- private static WikiModel wikiModel;
-
- private final int ZOOM_FACTOR = 2;
- private final int IMAGE_WIDTH = 400;
- private final int EXT_WIDTH = 100;
-
- private ResourceLocation imageTexture = null;
- private BufferedImage imageTemp = null;
- private int imageHeight = 0;
- private int imageWidth = 0;
-
- private static boolean hasAttemptedDownload = false;
-
- /**
- * Creates a wiki model and sets the configuration to work with hypixel-skyblock wikia.
- */
- static {
- Configuration conf = new Configuration();
- conf.addTokenTag("img", new HTMLTag("img"));
- conf.addTokenTag("code", new HTMLTag("code"));
- conf.addTokenTag("span", new AllowEmptyHTMLTag("span"));
- conf.addTokenTag("table", new HTMLBlockTag("table", Configuration.SPECIAL_BLOCK_TAGS+"span|"));
- conf.addTokenTag("infobox", new IgnoreTag("infobox"));
- conf.addTokenTag("tabber", new IgnoreTag("tabber"));
- conf.addTokenTag("kbd", new HTMLTag("kbd"));
- wikiModel = new WikiModel(conf,"https://hypixel-skyblock.fandom.com/wiki/Special:Filepath/${image}",
- "https://hypixel-skyblock.fandom.com/wiki/${title}") {
- {
- TagNode.addAllowedAttribute("style");
- TagNode.addAllowedAttribute("src");
- }
-
- protected String createImageName(ImageFormat imageFormat) {
- String imageName = imageFormat.getFilename();
- if (imageName.endsWith(".svg")) {
- imageName += ".png";
- }
- imageName = Encoder.encodeUrl(imageName);
- if (replaceColon()) {
- imageName = imageName.replace(':', '/');
- }
- return imageName;
- }
-
- public void parseInternalImageLink(String imageNamespace, String rawImageLink) {
- rawImageLink = rawImageLink.replaceFirst("\\|x([0-9]+)px", "\\|$1x$1px");
- if(!rawImageLink.split("\\|")[0].toLowerCase().endsWith(".jpg")) {
- super.parseInternalImageLink(imageNamespace, rawImageLink);
- }
- }
- };
- }
-
- /**
- * Takes a wiki url, uses NEUManager#getWebFile to download the web file and passed that in to #createFromWiki
- */
- public static HTMLInfoPane createFromWikiUrl(NEUOverlay overlay, NEUManager manager, String name,
- String wikiUrl) {
- File f = manager.getWebFile(wikiUrl);
- if(f == null) {
- return new HTMLInfoPane(overlay, manager, "error", "error","Failed to load wiki url: "+ wikiUrl);
- };
-
- StringBuilder sb = new StringBuilder();
- try(BufferedReader br = new BufferedReader(new InputStreamReader(
- new FileInputStream(f), StandardCharsets.UTF_8))) {
- String l;
- while((l = br.readLine()) != null){
- sb.append(l).append("\n");
- }
- } catch(IOException e) {
- return new HTMLInfoPane(overlay, manager, "error", "error","Failed to load wiki url: "+ wikiUrl);
- }
- return createFromWiki(overlay, manager, name, f.getName(), sb.toString());
- }
-
- /**
- * Takes raw wikia code and uses Bliki to generate HTML. Lot's of shennanigans to get it to render appropriately.
- * Honestly, I could have just downloaded the raw HTML of the wiki page and displayed that but I wanted
- * a more permanent solution that can be abstracted to work with arbitrary wiki codes (eg. moulberry.github.io/
- * files/neu_help.html).
- */
- public static HTMLInfoPane createFromWiki(NEUOverlay overlay, NEUManager manager, String name, String filename,
- String wiki) {
- String[] split = wiki.split("</infobox>");
- wiki = split[split.length - 1]; //Remove everything before infobox
- wiki = wiki.split("<span class=\"navbox-vde\">")[0]; //Remove navbox
- wiki = wiki.split("<table class=\"navbox mw-collapsible\"")[0];
- wiki = "__NOTOC__\n" + wiki; //Remove TOC
- try (PrintWriter out = new PrintWriter(new File(manager.configLocation, "debug/parsed.txt"))) {
- out.println(wiki);
- } catch (IOException e) {
- }
- String html;
- try {
- html = wikiModel.render(wiki);
- } catch(IOException e) {
- return new HTMLInfoPane(overlay, manager, "error", "error", "Could not render wiki.");
- }
- try (PrintWriter out = new PrintWriter(new File(manager.configLocation, "debug/html.txt"))) {
- out.println(html);
- } catch (IOException e) {
- }
- return new HTMLInfoPane(overlay, manager, name, filename, html);
- }
-
- private String spaceEscape(String str) {
- return str.replace(" ", "\\ ");
- }
-
- private static final ExecutorService wkDownloadES = Executors.newSingleThreadExecutor();
- private static final ExecutorService rendererES = Executors.newCachedThreadPool();
-
- /**
- * Uses the wkhtmltoimage command-line tool to generate an image from the HTML code. This
- * generation is done asynchronously as sometimes it can take up to 10 seconds for more
- * complex webpages.
- */
- public HTMLInfoPane(NEUOverlay overlay, NEUManager manager, String name, String filename, String html) {
- super(overlay, manager, name, "");
- this.title = name;
-
- String osId;
- if(SystemUtils.IS_OS_WINDOWS) {
- osId = "win";
- } else if(SystemUtils.IS_OS_MAC) {
- osId = "mac";
- } else if(SystemUtils.IS_OS_LINUX) {
- osId = "linux";
- } else {
- text = EnumChatFormatting.RED+"Unsupported operating system.";
- return;
- }
-
- File cssFile = new File(manager.configLocation, "wikia.css");
- File wkHtmlToImage = new File(manager.configLocation, "wkhtmltox-"+osId+"/bin/wkhtmltoimage");
-
- //Use old binary folder
- if(new File(manager.configLocation, "wkhtmltox/bin/wkhtmltoimage").exists() && SystemUtils.IS_OS_WINDOWS) {
- wkHtmlToImage = new File(manager.configLocation, "wkhtmltox/bin/wkhtmltoimage");
- }
-
- Runtime runtime = Runtime.getRuntime();
- String[] chmodCommand = new String[]{ "chmod", "-R", "777", new File(manager.configLocation, "wkhtmltox-"+osId).getAbsolutePath() };
- try {
- Process p = runtime.exec(chmodCommand);
- p.waitFor();
- } catch(IOException | InterruptedException e) {}
-
- if(!wkHtmlToImage.exists()) {
- if(hasAttemptedDownload) {
- text = EnumChatFormatting.RED+"Downloading web renderer failed? Or still downloading? Not sure what to do";
- return;
- } else {
- hasAttemptedDownload = true;
- Utils.recursiveDelete(new File(manager.configLocation, "wkhtmltox-"+osId));
- wkDownloadES.submit(() -> {
- try {
- File itemsZip = new File(manager.configLocation, "wkhtmltox-"+osId+".zip");
- if(!itemsZip.exists()) {
- URL url = new URL("https://moulberry.codes/wkhtmltox/wkhtmltox-"+osId+".zip");
- URLConnection urlConnection = url.openConnection();
- urlConnection.setConnectTimeout(15000);
- urlConnection.setReadTimeout(60000);
-
- FileUtils.copyInputStreamToFile(urlConnection.getInputStream(), itemsZip);
- }
-
- try(InputStream is = new FileInputStream(itemsZip)) {
- manager.unzip(is, manager.configLocation);
- }
-
- itemsZip.delete();
- itemsZip.deleteOnExit();
- } catch (IOException e) {
- e.printStackTrace();
- }
- });
-
- text = EnumChatFormatting.YELLOW+"Downloading web renderer... try again soon";
- return;
- }
- }
-
- File input = new File(manager.configLocation, "tmp/input.html");
- String outputFileName = filename.replaceAll("(?i)\\u00A7.", "")
- .replaceAll("[^a-zA-Z0-9_\\-]", "_");
- File output = new File(manager.configLocation, "tmp/"+
- outputFileName+".png");
- File outputExt = new File(manager.configLocation, "tmp/"+
- outputFileName+"_ext.png");
-
- input.deleteOnExit();
- output.deleteOnExit();
-
- File tmp = new File(manager.configLocation, "tmp");
- if(!tmp.exists()) {
- tmp.mkdir();
- }
-
- if(output.exists()) {
- try {
- imageTemp = ImageIO.read(output);
- text = EnumChatFormatting.RED+"Creating dynamic texture.";
- } catch(IOException e) {
- e.printStackTrace();
- text = EnumChatFormatting.RED+"Failed to read image.";
- return;
- }
- } else {
- html = "<div id=\"mw-content-text\" lang=\"en\" dir=\"ltr\" class=\"mw-content-ltr mw-content-text\">"+html+"</div>";
- html = "<div id=\"WikiaArticle\" class=\"WikiaArticle\">"+html+"</div>";
- html = "<link rel=\"stylesheet\" href=\"file:///"+cssFile.getAbsolutePath().replaceAll("^/", "")+"\">\n"+html;
-
- try(PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(
- new FileOutputStream(input), StandardCharsets.UTF_8)), false)) {
-
- out.println(encodeNonAscii(html));
- } catch(IOException e) {}
-
- try {
- text = EnumChatFormatting.GRAY+"Rendering webpage (" + name + EnumChatFormatting.RESET+
- EnumChatFormatting.GRAY+"), please wait...";
-
- String[] wkCommand = new String[]{ wkHtmlToImage.getAbsolutePath(), "--width", ""+IMAGE_WIDTH*ZOOM_FACTOR,
- "--transparent", "--allow", manager.configLocation.getAbsolutePath(), "--zoom", ""+ZOOM_FACTOR, input.getAbsolutePath(), output.getAbsolutePath()};
- Process p = runtime.exec(wkCommand);
+ private static final WikiModel wikiModel;
+
+ private final int ZOOM_FACTOR = 2;
+ private final int IMAGE_WIDTH = 400;
+ private final int EXT_WIDTH = 100;
+
+ private ResourceLocation imageTexture = null;
+ private BufferedImage imageTemp = null;
+ private int imageHeight = 0;
+ private int imageWidth = 0;
+
+ private static boolean hasAttemptedDownload = false;
+
+ /*
+ * Creates a wiki model and sets the configuration to work with hypixel-skyblock wikia.
+ */
+ static {
+ Configuration conf = new Configuration();
+ conf.addTokenTag("img", new HTMLTag("img"));
+ conf.addTokenTag("code", new HTMLTag("code"));
+ conf.addTokenTag("span", new AllowEmptyHTMLTag("span"));
+ conf.addTokenTag("table", new HTMLBlockTag("table", Configuration.SPECIAL_BLOCK_TAGS + "span|"));
+ conf.addTokenTag("infobox", new IgnoreTag("infobox"));
+ conf.addTokenTag("tabber", new IgnoreTag("tabber"));
+ conf.addTokenTag("kbd", new HTMLTag("kbd"));
+ wikiModel = new WikiModel(conf, "https://hypixel-skyblock.fandom.com/wiki/Special:Filepath/${image}",
+ "https://hypixel-skyblock.fandom.com/wiki/${title}"
+ ) {
+ {
+ TagNode.addAllowedAttribute("style");
+ TagNode.addAllowedAttribute("src");
+ }
+
+ protected String createImageName(ImageFormat imageFormat) {
+ String imageName = imageFormat.getFilename();
+ if (imageName.endsWith(".svg")) {
+ imageName += ".png";
+ }
+ imageName = Encoder.encodeUrl(imageName);
+ if (replaceColon()) {
+ imageName = imageName.replace(':', '/');
+ }
+ return imageName;
+ }
+
+ public void parseInternalImageLink(String imageNamespace, String rawImageLink) {
+ rawImageLink = rawImageLink.replaceFirst("\\|x([0-9]+)px", "\\|$1x$1px");
+ if (!rawImageLink.split("\\|")[0].toLowerCase().endsWith(".jpg")) {
+ super.parseInternalImageLink(imageNamespace, rawImageLink);
+ }
+ }
+ };
+ }
+
+ /**
+ * Takes a wiki url, uses NEUManager#getWebFile to download the web file and passed that in to #createFromWiki
+ */
+ public static CompletableFuture<HTMLInfoPane> createFromWikiUrl(
+ NEUOverlay overlay,
+ NEUManager manager,
+ String name,
+ String wikiUrl
+ ) {
+ return manager.getWebFile(wikiUrl).thenApply(f -> {
+ if (f == null) {
+ return new HTMLInfoPane(overlay, manager, "error", "error", "Failed to load wiki url: " + wikiUrl);
+ }
+
+ StringBuilder sb = new StringBuilder();
+ try (
+ BufferedReader br = new BufferedReader(new InputStreamReader(
+ new FileInputStream(f), StandardCharsets.UTF_8))
+ ) {
+ String l;
+ while ((l = br.readLine()) != null) {
+ sb.append(l).append("\n");
+ }
+ } catch (IOException e) {
+ return new HTMLInfoPane(overlay, manager, "error", "error", "Failed to load wiki url: " + wikiUrl);
+ }
+ return createFromWikiText(overlay, manager, name, f.getName(), sb.toString());
+ });
+ }
+
+ /**
+ * Takes raw wikia code and uses Bliki to generate HTML. Lot's of shennanigans to get it to render appropriately.
+ * Honestly, I could have just downloaded the raw HTML of the wiki page and displayed that but I wanted
+ * a more permanent solution that can be abstracted to work with arbitrary wiki codes (eg. moulberry.github.io/
+ * files/neu_help.html).
+ */
+ public static HTMLInfoPane createFromWikiText(
+ NEUOverlay overlay, NEUManager manager, String name, String filename,
+ String wiki
+ ) {
+ String[] split = wiki.split("</infobox>");
+ wiki = split[split.length - 1]; //Remove everything before infobox
+ wiki = wiki.split("<span class=\"navbox-vde\">")[0]; //Remove navbox
+ wiki = wiki.split("<table class=\"navbox mw-collapsible\"")[0];
+ wiki = "__NOTOC__\n" + wiki; //Remove TOC
+ try (PrintWriter out = new PrintWriter(new File(manager.configLocation, "debug/parsed.txt"))) {
+ out.println(wiki);
+ } catch (IOException ignored) {
+ }
+ String html;
+ try {
+ html = wikiModel.render(wiki);
+ } catch (IOException e) {
+ return new HTMLInfoPane(overlay, manager, "error", "error", "Could not render wiki.");
+ }
+ try (PrintWriter out = new PrintWriter(new File(manager.configLocation, "debug/html.txt"))) {
+ out.println(html);
+ } catch (IOException ignored) {
+ }
+ return new HTMLInfoPane(overlay, manager, name, filename, html);
+ }
+
+ private String spaceEscape(String str) {
+ return str.replace(" ", "\\ ");
+ }
+
+ private static final ExecutorService wkDownloadES = Executors.newSingleThreadExecutor();
+ private static final ExecutorService rendererES = Executors.newCachedThreadPool();
+
+ /**
+ * Uses the wkhtmltoimage command-line tool to generate an image from the HTML code. This
+ * generation is done asynchronously as sometimes it can take up to 10 seconds for more
+ * complex webpages.
+ */
+ public HTMLInfoPane(NEUOverlay overlay, NEUManager manager, String name, String filename, String html) {
+ super(overlay, manager, name, "");
+ this.title = name;
+
+ String osId;
+ if (SystemUtils.IS_OS_WINDOWS) {
+ osId = "win";
+ } else if (SystemUtils.IS_OS_MAC) {
+ osId = "mac";
+ } else if (SystemUtils.IS_OS_LINUX) {
+ osId = "linux";
+ } else {
+ text = EnumChatFormatting.RED + "Unsupported operating system.";
+ return;
+ }
+
+ File cssFile = new File(manager.configLocation, "wikia.css");
+ File wkHtmlToImage = new File(manager.configLocation, "wkhtmltox-" + osId + "/bin/wkhtmltoimage");
+
+ //Use old binary folder
+ if (new File(manager.configLocation, "wkhtmltox/bin/wkhtmltoimage").exists() && SystemUtils.IS_OS_WINDOWS) {
+ wkHtmlToImage = new File(manager.configLocation, "wkhtmltox/bin/wkhtmltoimage");
+ }
+
+ Runtime runtime = Runtime.getRuntime();
+ String[] chmodCommand = new String[]{
+ "chmod", "-R", "777", new File(
+ manager.configLocation,
+ "wkhtmltox-" + osId
+ ).getAbsolutePath()
+ };
+ try {
+ Process p = runtime.exec(chmodCommand);
+ p.waitFor();
+ } catch (IOException | InterruptedException ignored) {
+ }
+
+ if (!wkHtmlToImage.exists()) {
+ if (hasAttemptedDownload) {
+ text = EnumChatFormatting.RED + "Downloading web renderer failed? Or still downloading? Not sure what to do";
+ } else {
+ hasAttemptedDownload = true;
+ Utils.recursiveDelete(new File(manager.configLocation, "wkhtmltox-" + osId));
+ wkDownloadES.submit(() -> {
+ try {
+ File itemsZip = new File(manager.configLocation, "wkhtmltox-" + osId + ".zip");
+ if (!itemsZip.exists()) {
+ URL url = new URL("https://moulberry.codes/wkhtmltox/wkhtmltox-" + osId + ".zip");
+ URLConnection urlConnection = url.openConnection();
+ urlConnection.setConnectTimeout(15000);
+ urlConnection.setReadTimeout(60000);
+
+ FileUtils.copyInputStreamToFile(urlConnection.getInputStream(), itemsZip);
+ }
+
+ try (InputStream is = new FileInputStream(itemsZip)) {
+ NEUManager.unzip(is, manager.configLocation);
+ }
+
+ itemsZip.delete();
+ itemsZip.deleteOnExit();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ });
+
+ text = EnumChatFormatting.YELLOW + "Downloading web renderer... try again soon";
+ }
+ return;
+ }
+
+ File input = new File(manager.configLocation, "tmp/input.html");
+ String outputFileName = filename.replaceAll("(?i)\\u00A7.", "")
+ .replaceAll("[^a-zA-Z0-9_\\-]", "_");
+ File output = new File(manager.configLocation, "tmp/" +
+ outputFileName + ".png");
+ File outputExt = new File(manager.configLocation, "tmp/" +
+ outputFileName + "_ext.png");
+
+ input.deleteOnExit();
+ output.deleteOnExit();
+
+ File tmp = new File(manager.configLocation, "tmp");
+ if (!tmp.exists()) {
+ tmp.mkdir();
+ }
+
+ if (output.exists()) {
+ try {
+ imageTemp = ImageIO.read(output);
+ text = EnumChatFormatting.RED + "Creating dynamic texture.";
+ } catch (IOException e) {
+ e.printStackTrace();
+ text = EnumChatFormatting.RED + "Failed to read image.";
+ return;
+ }
+ } else {
+ html = "<div id=\"mw-content-text\" lang=\"en\" dir=\"ltr\" class=\"mw-content-ltr mw-content-text\">" + html +
+ "</div>";
+ html = "<div id=\"WikiaArticle\" class=\"WikiaArticle\">" + html + "</div>";
+ html = "<link rel=\"stylesheet\" href=\"file:///" + cssFile.getAbsolutePath().replaceAll("^/", "") + "\">\n" +
+ html;
+
+ try (
+ PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(
+ new FileOutputStream(input), StandardCharsets.UTF_8)), false)
+ ) {
+
+ out.println(encodeNonAscii(html));
+ } catch (IOException ignored) {
+ }
+
+ try {
+ text = EnumChatFormatting.GRAY + "Rendering webpage (" + name + EnumChatFormatting.RESET +
+ EnumChatFormatting.GRAY + "), please wait...";
+
+ String[] wkCommand = new String[]{
+ wkHtmlToImage.getAbsolutePath(),
+ "--width",
+ "" + IMAGE_WIDTH * ZOOM_FACTOR,
+ "--transparent",
+ "--allow",
+ manager.configLocation.getAbsolutePath(),
+ "--zoom",
+ "" + ZOOM_FACTOR,
+ input.getAbsolutePath(),
+ output.getAbsolutePath()
+ };
+ Process p = runtime.exec(wkCommand);
/*Process p = runtime.exec(spaceEscape(wkHtmlToImage.getAbsolutePath()) + " --width "+
IMAGE_WIDTH*ZOOM_FACTOR+" --transparent --zoom "+ZOOM_FACTOR + " " + spaceEscape(input.getAbsolutePath()) +
" " + spaceEscape(output.getAbsolutePath()));*/
@@ -272,14 +302,14 @@ public class HTMLInfoPane extends TextInfoPane {
/*Process p2 = runtime.exec("\""+wkHtmlToImage.getAbsolutePath() + "\" --width "+
(IMAGE_WIDTH+EXT_WIDTH)*ZOOM_FACTOR+" --transparent --zoom "+ZOOM_FACTOR+" \"" + input.getAbsolutePath() +
"\" \"" + outputExt.getAbsolutePath() + "\"");*/
- rendererES.submit(() -> {
- try {
- if(p.waitFor(15, TimeUnit.SECONDS)) {
- //if(p2.waitFor(5, TimeUnit.SECONDS)) {
- if(overlay.getActiveInfoPane() != this) return;
-
- try {
- imageTemp = ImageIO.read(output);
+ rendererES.submit(() -> {
+ try {
+ if (p.waitFor(15, TimeUnit.SECONDS)) {
+ //if(p2.waitFor(5, TimeUnit.SECONDS)) {
+ if (overlay.getActiveInfoPane() != this) return;
+
+ try {
+ imageTemp = ImageIO.read(output);
/*BufferedImage imageReg = ImageIO.read(output);
BufferedImage imageExt = ImageIO.read(outputExt);
ArrayList<Integer[]> pixels = new ArrayList<>();
@@ -307,106 +337,121 @@ public class HTMLInfoPane extends TextInfoPane {
imageTemp.setRGB(x, y, col);
}
}*/
- text = EnumChatFormatting.RED+"Creating dynamic texture.";
- } catch(IOException e) {
- e.printStackTrace();
- text = EnumChatFormatting.RED+"Failed to read image.";
- return;
- }
- } else {
- if(overlay.getActiveInfoPane() != this) return;
-
- text = EnumChatFormatting.RED+"Webpage render timed out (>15sec). Maybe it's too large?";
- }
- } catch(Exception e) {
- e.printStackTrace();
- }
- });
- } catch(IOException e) {
- e.printStackTrace();
- text = EnumChatFormatting.RED+"Failed to exec webpage renderer.";
- }
- }
- }
-
- /**
- * Renders a background, title and the image created in the ctor (if it has been generated).
- */
- @Override
- public void render(int width, int height, Color bg, Color fg, ScaledResolution scaledresolution, int mouseX, int mouseY) {
- if(imageTemp != null && imageTexture == null) {
- DynamicTexture tex = new DynamicTexture(imageTemp);
- imageTexture = Minecraft.getMinecraft().getTextureManager().getDynamicTextureLocation(
- "notenoughupdates/informationPaneImage", tex);
- imageHeight = imageTemp.getHeight();
- imageWidth = imageTemp.getWidth();
- }
- if(imageTexture == null) {
- super.render(width, height, bg, fg, scaledresolution, mouseX, mouseY);
- return;
- }
-
- FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
-
- int paneWidth = (int)(width/3*overlay.getWidthMult());
- int rightSide = (int)(width*overlay.getInfoPaneOffsetFactor());
- int leftSide = rightSide - paneWidth;
-
- int titleLen = fr.getStringWidth(title);
- fr.drawString(title, (leftSide+rightSide-titleLen)/2, overlay.getBoxPadding() + 5, Color.WHITE.getRGB());
-
- drawRect(leftSide+overlay.getBoxPadding()-5, overlay.getBoxPadding()-5, rightSide-overlay.getBoxPadding()+5,
- height-overlay.getBoxPadding()+5, bg.getRGB());
-
- int imageW = paneWidth - overlay.getBoxPadding()*2;
- float scaleF = IMAGE_WIDTH*ZOOM_FACTOR/(float)imageW;
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(imageTexture);
- GlStateManager.color(1f, 1f, 1f, 1f);
- if(height-overlay.getBoxPadding()*3 < imageHeight/scaleF) {
- if(scrollHeight.getValue() > imageHeight/scaleF-height+overlay.getBoxPadding()*3) {
- scrollHeight.setValue((int)(imageHeight/scaleF-height+overlay.getBoxPadding()*3));
- }
- int yScroll = scrollHeight.getValue();
-
- float vMin = yScroll/(imageHeight/scaleF);
- float vMax = (yScroll+height-overlay.getBoxPadding()*3)/(imageHeight/scaleF);
- Utils.drawTexturedRect(leftSide+overlay.getBoxPadding(), overlay.getBoxPadding()*2, imageW,
- height-overlay.getBoxPadding()*3,
- 0, 1, vMin, vMax);
- } else {
- scrollHeight.setValue(0);
-
- Utils.drawTexturedRect(leftSide+overlay.getBoxPadding(), overlay.getBoxPadding()*2, imageW,
- (int)(imageHeight/scaleF));
- }
- GlStateManager.bindTexture(0);
- }
-
- @Override
- public boolean keyboardInput() {
- return false;
- }
-
- @Override
- public void mouseInput(int width, int height, int mouseX, int mouseY, boolean mouseDown) {
- super.mouseInput(width, height, mouseX, mouseY, mouseDown);
- }
-
- //From https://stackoverflow.com/questions/1760766/how-to-convert-non-supported-character-to-html-entity-in-java
- public String encodeNonAscii(String c) {
- StringBuilder buf = new StringBuilder(c.length());
- CharsetEncoder enc = StandardCharsets.US_ASCII.newEncoder();
- for (int idx = 0; idx < c.length(); ++idx) {
- char ch = c.charAt(idx);
- if (enc.canEncode(ch))
- buf.append(ch);
- else {
- buf.append("&#");
- buf.append((int) ch);
- buf.append(';');
- }
- }
- return buf.toString();
- }
+ text = EnumChatFormatting.RED + "Creating dynamic texture.";
+ } catch (IOException e) {
+ e.printStackTrace();
+ text = EnumChatFormatting.RED + "Failed to read image.";
+ return;
+ }
+ } else {
+ if (overlay.getActiveInfoPane() != this) return;
+
+ text = EnumChatFormatting.RED + "Webpage render timed out (>15sec). Maybe it's too large?";
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ });
+ } catch (IOException e) {
+ e.printStackTrace();
+ text = EnumChatFormatting.RED + "Failed to exec webpage renderer.";
+ }
+ }
+ }
+
+ /**
+ * Renders a background, title and the image created in the ctor (if it has been generated).
+ */
+ @Override
+ public void render(
+ int width,
+ int height,
+ Color bg,
+ Color fg,
+ ScaledResolution scaledresolution,
+ int mouseX,
+ int mouseY
+ ) {
+ if (imageTemp != null && imageTexture == null) {
+ DynamicTexture tex = new DynamicTexture(imageTemp);
+ imageTexture = Minecraft.getMinecraft().getTextureManager().getDynamicTextureLocation(
+ "notenoughupdates/informationPaneImage", tex);
+ imageHeight = imageTemp.getHeight();
+ imageWidth = imageTemp.getWidth();
+ }
+ if (imageTexture == null) {
+ super.render(width, height, bg, fg, scaledresolution, mouseX, mouseY);
+ return;
+ }
+
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+
+ int paneWidth = (int) (width / 3 * overlay.getWidthMult());
+ int rightSide = (int) (width * overlay.getInfoPaneOffsetFactor());
+ int leftSide = rightSide - paneWidth;
+
+ int titleLen = fr.getStringWidth(title);
+ fr.drawString(title, (leftSide + rightSide - titleLen) / 2, overlay.getBoxPadding() + 5, Color.WHITE.getRGB());
+
+ drawRect(
+ leftSide + overlay.getBoxPadding() - 5,
+ overlay.getBoxPadding() - 5,
+ rightSide - overlay.getBoxPadding() + 5,
+ height - overlay.getBoxPadding() + 5,
+ bg.getRGB()
+ );
+
+ int imageW = paneWidth - overlay.getBoxPadding() * 2;
+ float scaleF = IMAGE_WIDTH * ZOOM_FACTOR / (float) imageW;
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(imageTexture);
+ GlStateManager.color(1f, 1f, 1f, 1f);
+ if (height - overlay.getBoxPadding() * 3 < imageHeight / scaleF) {
+ if (scrollHeight.getValue() > imageHeight / scaleF - height + overlay.getBoxPadding() * 3) {
+ scrollHeight.setValue((int) (imageHeight / scaleF - height + overlay.getBoxPadding() * 3));
+ }
+ int yScroll = scrollHeight.getValue();
+
+ float vMin = yScroll / (imageHeight / scaleF);
+ float vMax = (yScroll + height - overlay.getBoxPadding() * 3) / (imageHeight / scaleF);
+ Utils.drawTexturedRect(leftSide + overlay.getBoxPadding(), overlay.getBoxPadding() * 2, imageW,
+ height - overlay.getBoxPadding() * 3,
+ 0, 1, vMin, vMax
+ );
+ } else {
+ scrollHeight.setValue(0);
+
+ Utils.drawTexturedRect(leftSide + overlay.getBoxPadding(), overlay.getBoxPadding() * 2, imageW,
+ (int) (imageHeight / scaleF)
+ );
+ }
+ GlStateManager.bindTexture(0);
+ }
+
+ @Override
+ public boolean keyboardInput() {
+ return false;
+ }
+
+ @Override
+ public void mouseInput(int width, int height, int mouseX, int mouseY, boolean mouseDown) {
+ super.mouseInput(width, height, mouseX, mouseY, mouseDown);
+ }
+
+ //From https://stackoverflow.com/questions/1760766/how-to-convert-non-supported-character-to-html-entity-in-java
+ public String encodeNonAscii(String c) {
+ StringBuilder buf = new StringBuilder(c.length());
+ CharsetEncoder enc = StandardCharsets.US_ASCII.newEncoder();
+ for (int idx = 0; idx < c.length(); ++idx) {
+ char ch = c.charAt(idx);
+ if (enc.canEncode(ch))
+ buf.append(ch);
+ else {
+ buf.append("&#");
+ buf.append((int) ch);
+ buf.append(';');
+ }
+ }
+ return buf.toString();
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/InfoPane.java b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/InfoPane.java
index 45502cf2..70d7d65b 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/InfoPane.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/InfoPane.java
@@ -8,43 +8,66 @@ import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution;
import java.awt.*;
+import java.util.concurrent.CompletableFuture;
-public abstract class InfoPane extends Gui {
+public abstract class InfoPane extends Gui {
+ final NEUOverlay overlay;
+ final NEUManager manager;
- final NEUOverlay overlay;
- final NEUManager manager;
+ public InfoPane(NEUOverlay overlay, NEUManager manager) {
+ this.overlay = overlay;
+ this.manager = manager;
+ }
- public InfoPane(NEUOverlay overlay, NEUManager manager) {
- this.overlay = overlay;
- this.manager = manager;
- }
+ public void reset() {}
- public void reset() {}
+ public void tick() {}
- public void tick() {}
+ public abstract void render(
+ int width, int height, Color bg, Color fg, ScaledResolution scaledresolution, int mouseX,
+ int mouseY
+ );
- public abstract void render(int width, int height, Color bg, Color fg, ScaledResolution scaledresolution, int mouseX,
- int mouseY);
+ public abstract void mouseInput(int width, int height, int mouseX, int mouseY, boolean mouseDown);
- public abstract void mouseInput(int width, int height, int mouseX, int mouseY, boolean mouseDown);
- public void mouseInputOutside(){};
+ public void mouseInputOutside() {}
- public abstract boolean keyboardInput();
+ public abstract boolean keyboardInput();
- public void renderDefaultBackground(int width, int height, Color bg) {
- int paneWidth = (int)(width/3*overlay.getWidthMult());
- int rightSide = (int)(width*overlay.getInfoPaneOffsetFactor());
- int leftSide = rightSide - paneWidth;
+ public void renderDefaultBackground(int width, int height, Color bg) {
+ int paneWidth = (int) (width / 3 * overlay.getWidthMult());
+ int rightSide = (int) (width * overlay.getInfoPaneOffsetFactor());
+ int leftSide = rightSide - paneWidth;
- int boxLeft = leftSide + overlay.getBoxPadding() - 5;
- int boxRight = rightSide - overlay.getBoxPadding() + 5;
+ int boxLeft = leftSide + overlay.getBoxPadding() - 5;
+ int boxRight = rightSide - overlay.getBoxPadding() + 5;
- BackgroundBlur.renderBlurredBackground(NotEnoughUpdates.INSTANCE.config.itemlist.bgBlurFactor,
- width, height,
- boxLeft, overlay.getBoxPadding()-5,
- boxRight-boxLeft, height-overlay.getBoxPadding()*2+10, true);
- drawRect(boxLeft, overlay.getBoxPadding() - 5, boxRight,
- height - overlay.getBoxPadding() + 5, bg.getRGB());
- }
+ BackgroundBlur.renderBlurredBackground(NotEnoughUpdates.INSTANCE.config.itemlist.bgBlurFactor,
+ width, height,
+ boxLeft, overlay.getBoxPadding() - 5,
+ boxRight - boxLeft, height - overlay.getBoxPadding() * 2 + 10, true
+ );
+ drawRect(boxLeft, overlay.getBoxPadding() - 5, boxRight,
+ height - overlay.getBoxPadding() + 5, bg.getRGB()
+ );
+ }
+ public static CompletableFuture<? extends InfoPane> create(
+ NEUOverlay overlay, NEUManager manager, String infoType,
+ String name, String internalName, String infoText
+ ) {
+ switch (infoType.intern()) {
+ case "WIKI_URL":
+ return HTMLInfoPane.createFromWikiUrl(overlay, manager, name, infoText);
+ case "WIKI":
+ return CompletableFuture.completedFuture(
+ HTMLInfoPane.createFromWikiText(overlay, manager, name, internalName, infoText));
+ case "HTML":
+ return CompletableFuture.completedFuture(
+ new HTMLInfoPane(overlay, manager, name, internalName, infoText));
+ default:
+ return CompletableFuture.completedFuture(
+ new TextInfoPane(overlay, manager, name, infoText));
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/ScrollableInfoPane.java b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/ScrollableInfoPane.java
index 12d42551..75b66770 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/ScrollableInfoPane.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/ScrollableInfoPane.java
@@ -6,29 +6,28 @@ import io.github.moulberry.notenoughupdates.core.util.lerp.LerpingInteger;
import org.lwjgl.input.Mouse;
public abstract class ScrollableInfoPane extends InfoPane {
+ private static final int SCROLL_AMOUNT = 50;
+ protected LerpingInteger scrollHeight = new LerpingInteger(0);
- private static final int SCROLL_AMOUNT = 50;
- protected LerpingInteger scrollHeight = new LerpingInteger(0);
+ public ScrollableInfoPane(NEUOverlay overlay, NEUManager manager) {
+ super(overlay, manager);
+ }
- public ScrollableInfoPane(NEUOverlay overlay, NEUManager manager) {
- super(overlay, manager);
- }
+ public void tick() {
+ scrollHeight.tick();
+ if (scrollHeight.getValue() < 0) scrollHeight.setValue(0);
+ }
- public void tick() {
- scrollHeight.tick();
- if(scrollHeight.getValue() < 0) scrollHeight.setValue(0);
- }
+ @Override
+ public void mouseInput(int width, int height, int mouseX, int mouseY, boolean mouseDown) {
+ int dWheel = Mouse.getEventDWheel();
- @Override
- public void mouseInput(int width, int height, int mouseX, int mouseY, boolean mouseDown) {
- int dWheel = Mouse.getEventDWheel();
-
- if(dWheel < 0) {
- scrollHeight.setTarget(scrollHeight.getTarget()+SCROLL_AMOUNT);
- scrollHeight.resetTimer();
- } else if(dWheel > 0) {
- scrollHeight.setTarget(scrollHeight.getTarget()-SCROLL_AMOUNT);
- scrollHeight.resetTimer();
- }
- }
+ if (dWheel < 0) {
+ scrollHeight.setTarget(scrollHeight.getTarget() + SCROLL_AMOUNT);
+ scrollHeight.resetTimer();
+ } else if (dWheel > 0) {
+ scrollHeight.setTarget(scrollHeight.getTarget() - SCROLL_AMOUNT);
+ scrollHeight.resetTimer();
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/TextInfoPane.java b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/TextInfoPane.java
index 72a9e42b..77d47a3d 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/TextInfoPane.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/TextInfoPane.java
@@ -10,52 +10,62 @@ import net.minecraft.client.gui.ScaledResolution;
import java.awt.*;
public class TextInfoPane extends ScrollableInfoPane {
+ protected String title;
+ protected String text;
- protected String title;
- protected String text;
-
- public TextInfoPane(NEUOverlay overlay, NEUManager manager, String title, String text) {
- super(overlay, manager);
- this.title = title;
- this.text = text;
- }
-
- public void render(int width, int height, Color bg, Color fg, ScaledResolution scaledresolution, int mouseX, int mouseY) {
- FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
-
- int paneWidth = (int)(width/3*overlay.getWidthMult());
- int rightSide = (int)(width*overlay.getInfoPaneOffsetFactor());
- int leftSide = rightSide - paneWidth;
-
- int titleLen = fr.getStringWidth(title);
- int yScroll = -scrollHeight.getValue();
- fr.drawString(title, (leftSide+rightSide-titleLen)/2, yScroll+overlay.getBoxPadding() + 5,
- Color.WHITE.getRGB());
-
- int yOff = 20;
- for(String line : text.split("\n")) {
- yOff += Utils.renderStringTrimWidth(line, fr, false,leftSide+overlay.getBoxPadding() + 5,
- yScroll+overlay.getBoxPadding() + 10 + yOff,
- width*1/3-overlay.getBoxPadding()*2-10, Color.WHITE.getRGB(), -1);
- yOff += 16;
- }
-
- int top = overlay.getBoxPadding() - 5;
- int totalBoxHeight = yOff+14;
- int bottom = Math.max(top+totalBoxHeight, height-overlay.getBoxPadding()+5);
-
- if(scrollHeight.getValue() > top+totalBoxHeight-(height-overlay.getBoxPadding()+5)) {
- scrollHeight.setValue(top+totalBoxHeight-(height-overlay.getBoxPadding()+5));
- }
- drawRect(leftSide+overlay.getBoxPadding()-5, yScroll+overlay.getBoxPadding()-5,
- rightSide-overlay.getBoxPadding()+5, yScroll+bottom, bg.getRGB());
- }
-
- public boolean keyboardInput() {
- return false;
- }
-
- public void mouseInput(int width, int height, int mouseX, int mouseY, boolean mouseDown) {
- super.mouseInput(width, height, mouseX, mouseY, mouseDown);
- }
+ public TextInfoPane(NEUOverlay overlay, NEUManager manager, String title, String text) {
+ super(overlay, manager);
+ this.title = title;
+ this.text = text;
+ }
+
+ public void render(
+ int width,
+ int height,
+ Color bg,
+ Color fg,
+ ScaledResolution scaledresolution,
+ int mouseX,
+ int mouseY
+ ) {
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+
+ int paneWidth = (int) (width / 3 * overlay.getWidthMult());
+ int rightSide = (int) (width * overlay.getInfoPaneOffsetFactor());
+ int leftSide = rightSide - paneWidth;
+
+ int titleLen = fr.getStringWidth(title);
+ int yScroll = -scrollHeight.getValue();
+ fr.drawString(title, (leftSide + rightSide - titleLen) / 2, yScroll + overlay.getBoxPadding() + 5,
+ Color.WHITE.getRGB()
+ );
+
+ int yOff = 20;
+ for (String line : text.split("\n")) {
+ yOff += Utils.renderStringTrimWidth(line, fr, false, leftSide + overlay.getBoxPadding() + 5,
+ yScroll + overlay.getBoxPadding() + 10 + yOff,
+ width * 1 / 3 - overlay.getBoxPadding() * 2 - 10, Color.WHITE.getRGB(), -1
+ );
+ yOff += 16;
+ }
+
+ int top = overlay.getBoxPadding() - 5;
+ int totalBoxHeight = yOff + 14;
+ int bottom = Math.max(top + totalBoxHeight, height - overlay.getBoxPadding() + 5);
+
+ if (scrollHeight.getValue() > top + totalBoxHeight - (height - overlay.getBoxPadding() + 5)) {
+ scrollHeight.setValue(top + totalBoxHeight - (height - overlay.getBoxPadding() + 5));
+ }
+ drawRect(leftSide + overlay.getBoxPadding() - 5, yScroll + overlay.getBoxPadding() - 5,
+ rightSide - overlay.getBoxPadding() + 5, yScroll + bottom, bg.getRGB()
+ );
+ }
+
+ public boolean keyboardInput() {
+ return false;
+ }
+
+ public void mouseInput(int width, int height, int mouseX, int mouseY, boolean mouseDown) {
+ super.mouseInput(width, height, mouseX, mouseY, mouseDown);
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElement.java b/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElement.java
index 06a8810d..38ad2824 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElement.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElement.java
@@ -3,13 +3,17 @@ package io.github.moulberry.notenoughupdates.itemeditor;
import net.minecraft.client.gui.Gui;
public abstract class GuiElement extends Gui {
+ public abstract void render(int x, int y);
- public abstract void render(int x, int y);
- public abstract int getWidth();
- public abstract int getHeight();
- public void mouseClicked(int mouseX, int mouseY, int mouseButton) {}
- public void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {}
- public void otherComponentClick() {}
- public void keyTyped(char typedChar, int keyCode) {}
+ public abstract int getWidth();
+ public abstract int getHeight();
+
+ public void mouseClicked(int mouseX, int mouseY, int mouseButton) {}
+
+ public void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {}
+
+ public void otherComponentClick() {}
+
+ public void keyTyped(char typedChar, int keyCode) {}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementButton.java b/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementButton.java
index 0ed03c36..35b31490 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementButton.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementButton.java
@@ -3,33 +3,32 @@ package io.github.moulberry.notenoughupdates.itemeditor;
import java.awt.*;
public class GuiElementButton extends GuiElementText {
-
- private Runnable callback;
-
- public GuiElementButton(String text, int colour, Runnable callback) {
- super(text, colour);
- this.callback = callback;
- }
-
- @Override
- public int getHeight() {
- return super.getHeight() + 5;
- }
-
- @Override
- public int getWidth() {
- return super.getWidth() + 10;
- }
-
- @Override
- public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
- callback.run();
- }
-
- @Override
- public void render(int x, int y) {
- drawRect(x, y, x+getWidth(), y+super.getHeight(), Color.WHITE.getRGB());
- drawRect(x+1, y+1, x+getWidth()-1, y+super.getHeight()-1, Color.BLACK.getRGB());
- super.render(x+5, y-1);
- }
+ private final Runnable callback;
+
+ public GuiElementButton(String text, int colour, Runnable callback) {
+ super(text, colour);
+ this.callback = callback;
+ }
+
+ @Override
+ public int getHeight() {
+ return super.getHeight() + 5;
+ }
+
+ @Override
+ public int getWidth() {
+ return super.getWidth() + 10;
+ }
+
+ @Override
+ public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
+ callback.run();
+ }
+
+ @Override
+ public void render(int x, int y) {
+ drawRect(x, y, x + getWidth(), y + super.getHeight(), Color.WHITE.getRGB());
+ drawRect(x + 1, y + 1, x + getWidth() - 1, y + super.getHeight() - 1, Color.BLACK.getRGB());
+ super.render(x + 5, y - 1);
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementText.java b/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementText.java
index 28bc9b71..1e7a8c08 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementText.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementText.java
@@ -4,39 +4,37 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
public class GuiElementText extends GuiElement {
-
- protected String text;
- private int colour;
-
- public GuiElementText(String text, int colour) {
- this.text = text;
- this.colour = colour;
- }
-
- @Override
- public int getHeight() {
- return 18;
- }
-
- @Override
- public int getWidth() {
- FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
- return fr.getStringWidth(text);
- }
-
- public String getText() {
- return text;
- }
-
- public void setText(String text) {
- this.text = text;
- }
-
- @Override
- public void render(int x, int y) {
- FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
-
- fr.drawString(text, x, y+6, colour);
- }
-
+ protected String text;
+ private final int colour;
+
+ public GuiElementText(String text, int colour) {
+ this.text = text;
+ this.colour = colour;
+ }
+
+ @Override
+ public int getHeight() {
+ return 18;
+ }
+
+ @Override
+ public int getWidth() {
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+ return fr.getStringWidth(text);
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ @Override
+ public void render(int x, int y) {
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+
+ fr.drawString(text, x, y + 6, colour);
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementTextField.java b/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementTextField.java
index b460af36..fd78f3aa 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementTextField.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementTextField.java
@@ -13,500 +13,524 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class GuiElementTextField extends GuiElement {
+ public static final int SCALE_TEXT = 0b100000;
+ public static final int NUM_ONLY = 0b10000;
+ public static final int NO_SPACE = 0b01000;
+ public static final int FORCE_CAPS = 0b00100;
+ public static final int COLOUR = 0b00010;
+ public static final int MULTILINE = 0b00001;
+
+ private int searchBarYSize = 20;
+ private int searchBarXSize = 350;
+ private static final int searchBarPadding = 2;
+
+ private int options = 0;
+
+ private boolean focus = false;
- public static final int SCALE_TEXT = 0b100000;
- public static final int NUM_ONLY = 0b10000;
- public static final int NO_SPACE = 0b01000;
- public static final int FORCE_CAPS = 0b00100;
- public static final int COLOUR = 0b00010;
- public static final int MULTILINE = 0b00001;
-
- private int searchBarYSize = 20;
- private int searchBarXSize = 350;
- private static final int searchBarPadding = 2;
+ private int x;
+ private int y;
- private int options = 0;
-
- private boolean focus = false;
-
- private int x;
- private int y;
-
- private String prependText = "";
-
- private GuiTextField textField = new GuiTextField(0, Minecraft.getMinecraft().fontRendererObj,
- 0 , 0, 0, 0);
-
- private int customBorderColour = -1;
-
- public GuiElementTextField(String initialText, int options) {
- textField.setFocused(true);
- textField.setCanLoseFocus(false);
- textField.setMaxStringLength(9999);
- textField.setText(initialText);
- this.options = options;
- }
-
- public void setMaxStringLength(int len) {
- textField.setMaxStringLength(len);
- }
-
- public void setCustomBorderColour(int colour) {
- this.customBorderColour = colour;
- }
-
- public String getText() {
- return textField.getText();
- }
-
- public void setPrependText(String text) {
- this.prependText = text;
- }
-
- public void setText(String text) {
- if(textField.getText() == null || !textField.getText().equals(text)) {
- textField.setText(text);
- }
- }
-
- public void setSize(int searchBarXSize, int searchBarYSize) {
- this.searchBarXSize = searchBarXSize;
- this.searchBarYSize = searchBarYSize;
- }
-
- @Override
- public String toString() {
- return textField.getText();
- }
-
- public boolean getFocus() {
- return focus;
- }
-
- @Override
- public int getHeight() {
- ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
- int paddingUnscaled = searchBarPadding/scaledresolution.getScaleFactor();
-
- int numLines = StringUtils.countMatches(textField.getText(), "\n")+1;
- int extraSize = (searchBarYSize-8)/2+8;
- int bottomTextBox = searchBarYSize + extraSize*(numLines-1);
-
- return bottomTextBox + paddingUnscaled*2;
- }
-
- @Override
- public int getWidth() {
- ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
- int paddingUnscaled = searchBarPadding/scaledresolution.getScaleFactor();
-
- return searchBarXSize + paddingUnscaled*2;
- }
-
- private float getScaleFactor(String str) {
- return Math.min(1, (searchBarXSize-2)/(float)Minecraft.getMinecraft().fontRendererObj.getStringWidth(str));
- }
-
- private boolean isScaling() {
- return (options & SCALE_TEXT) != 0;
- }
-
- private float getStringWidth(String str) {
- if(isScaling()) {
- return Minecraft.getMinecraft().fontRendererObj.getStringWidth(str)*getScaleFactor(str);
- } else {
- return Minecraft.getMinecraft().fontRendererObj.getStringWidth(str);
- }
- }
-
- public int getCursorPos(int mouseX, int mouseY) {
- int xComp = mouseX - x;
- int yComp = mouseY - y;
-
- int extraSize = (searchBarYSize-8)/2+8;
-
- String renderText = prependText + textField.getText();
-
- int lineNum = Math.round(((yComp - (searchBarYSize-8)/2))/extraSize);
-
- Pattern patternControlCode = Pattern.compile("(?i)\\u00A7([^\\u00B6])(?!\\u00B6)");
- String text = renderText;
- String textNoColour = renderText;
- if((options & COLOUR) != 0) {
- while(true) {
- Matcher matcher = patternControlCode.matcher(text);
- if(!matcher.find() || matcher.groupCount() < 1) break;
- String code = matcher.group(1);
- text = matcher.replaceFirst("\u00A7"+code+"\u00B6"+code);
- }
- }
- while(true) {
- Matcher matcher = patternControlCode.matcher(textNoColour);
- if(!matcher.find() || matcher.groupCount() < 1) break;
- String code = matcher.group(1);
- textNoColour = matcher.replaceFirst("\u00B6"+code);
- }
-
- int currentLine = 0;
- int cursorIndex = 0;
- for(; cursorIndex<textNoColour.length(); cursorIndex++) {
- if(currentLine == lineNum) break;
- if(textNoColour.charAt(cursorIndex) == '\n') {
- currentLine++;
- }
- }
-
-
- String textNC = textNoColour.substring(0, cursorIndex);
- int colorCodes = StringUtils.countMatches(textNC, "\u00B6");
- String line = text.substring(cursorIndex+(((options & COLOUR) != 0)?colorCodes*2:0)).split("\n")[0];
- int padding = Math.min(5, searchBarXSize-strLenNoColor(line))/2;
- String trimmed = Minecraft.getMinecraft().fontRendererObj.trimStringToWidth(line, xComp-padding);
- int linePos = strLenNoColor(trimmed);
- if(linePos != strLenNoColor(line)) {
- char after = line.charAt(linePos);
- int trimmedWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(trimmed);
- int charWidth = Minecraft.getMinecraft().fontRendererObj.getCharWidth(after);
- if(trimmedWidth + charWidth/2 < xComp-padding) {
- linePos++;
- }
- }
- cursorIndex += linePos;
-
- int pre = Utils.cleanColour(prependText).length();
- if(cursorIndex < pre) {
- cursorIndex = 0;
- } else {
- cursorIndex -= pre;
- }
-
- return cursorIndex;
- }
-
- @Override
- public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
- if(mouseButton == 1) {
- textField.setText("");
- } else {
- textField.setCursorPosition(getCursorPos(mouseX, mouseY));
- }
- focus = true;
- }
-
- public void otherComponentClick() {
- focus = false;
- textField.setSelectionPos(textField.getCursorPosition());
- }
-
- public int strLenNoColor(String str) {
- return str.replaceAll("(?i)\\u00A7.", "").length();
- }
-
- public void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
- if(focus) {
- textField.setSelectionPos(getCursorPos(mouseX, mouseY));
- }
- }
-
- @Override
- public void keyTyped(char typedChar, int keyCode) {
- if(focus) {
- if((options & MULTILINE) != 0) { //Carriage return
- Pattern patternControlCode = Pattern.compile("(?i)\\u00A7([^\\u00B6\n])(?!\\u00B6)");
-
- String text = textField.getText();
- String textNoColour = textField.getText();
- while(true) {
- Matcher matcher = patternControlCode.matcher(text);
- if(!matcher.find() || matcher.groupCount() < 1) break;
- String code = matcher.group(1);
- text = matcher.replaceFirst("\u00A7"+code+"\u00B6"+code);
- }
- while(true) {
- Matcher matcher = patternControlCode.matcher(textNoColour);
- if(!matcher.find() || matcher.groupCount() < 1) break;
- String code = matcher.group(1);
- textNoColour = matcher.replaceFirst("\u00B6"+code);
- }
-
- if(keyCode == 28) {
- String before = textField.getText().substring(0, textField.getCursorPosition());
- String after = textField.getText().substring(textField.getCursorPosition());
- int pos = textField.getCursorPosition();
- textField.setText(before + "\n" + after);
- textField.setCursorPosition(pos+1);
- return;
- } else if(keyCode == 200) { //Up
- String textNCBeforeCursor = textNoColour.substring(0, textField.getSelectionEnd());
- int colorCodes = StringUtils.countMatches(textNCBeforeCursor, "\u00B6");
- String textBeforeCursor = text.substring(0, textField.getSelectionEnd()+colorCodes*2);
-
- int numLinesBeforeCursor = StringUtils.countMatches(textBeforeCursor, "\n");
-
- String[] split = textBeforeCursor.split("\n");
- int textBeforeCursorWidth;
- String lineBefore;
- String thisLineBeforeCursor;
- if(split.length == numLinesBeforeCursor && split.length > 0) {
- textBeforeCursorWidth = 0;
- lineBefore = split[split.length-1];
- thisLineBeforeCursor = "";
- } else if(split.length > 1) {
- thisLineBeforeCursor = split[split.length-1];
- lineBefore = split[split.length-2];
- textBeforeCursorWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(thisLineBeforeCursor);
- } else {
- return;
- }
- String trimmed = Minecraft.getMinecraft().fontRendererObj
- .trimStringToWidth(lineBefore, textBeforeCursorWidth);
- int linePos = strLenNoColor(trimmed);
- if(linePos != strLenNoColor(lineBefore)) {
- char after = lineBefore.charAt(linePos);
- int trimmedWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(trimmed);
- int charWidth = Minecraft.getMinecraft().fontRendererObj.getCharWidth(after);
- if(trimmedWidth + charWidth/2 < textBeforeCursorWidth) {
- linePos++;
- }
- }
- int newPos = textField.getSelectionEnd()-strLenNoColor(thisLineBeforeCursor)
- -strLenNoColor(lineBefore)-1+linePos;
-
- if(GuiScreen.isShiftKeyDown()) {
- textField.setSelectionPos(newPos);
- } else {
- textField.setCursorPosition(newPos);
- }
- } else if(keyCode == 208) { //Down
- String textNCBeforeCursor = textNoColour.substring(0, textField.getSelectionEnd());
- int colorCodes = StringUtils.countMatches(textNCBeforeCursor, "\u00B6");
- String textBeforeCursor = text.substring(0, textField.getSelectionEnd()+colorCodes*2);
-
- int numLinesBeforeCursor = StringUtils.countMatches(textBeforeCursor, "\n");
-
- String[] split = textBeforeCursor.split("\n");
- String thisLineBeforeCursor;
- int textBeforeCursorWidth;
- if(split.length == numLinesBeforeCursor) {
- thisLineBeforeCursor = "";
- textBeforeCursorWidth = 0;
- } else if(split.length > 0) {
- thisLineBeforeCursor = split[split.length-1];
- textBeforeCursorWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(thisLineBeforeCursor);
- } else {
- return;
- }
-
- String[] split2 = textNoColour.split("\n");
- if(split2.length > numLinesBeforeCursor+1) {
- String lineAfter = split2[numLinesBeforeCursor+1];
- String trimmed = Minecraft.getMinecraft().fontRendererObj
- .trimStringToWidth(lineAfter, textBeforeCursorWidth);
- int linePos = strLenNoColor(trimmed);
- if(linePos != strLenNoColor(lineAfter)) {
- char after = lineAfter.charAt(linePos);
- int trimmedWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(trimmed);
- int charWidth = Minecraft.getMinecraft().fontRendererObj.getCharWidth(after);
- if(trimmedWidth + charWidth/2 < textBeforeCursorWidth) {
- linePos++;
- }
- }
- int newPos = textField.getSelectionEnd()-strLenNoColor(thisLineBeforeCursor)
- +strLenNoColor(split2[numLinesBeforeCursor])+1+linePos;
-
- if(GuiScreen.isShiftKeyDown()) {
- textField.setSelectionPos(newPos);
- } else {
- textField.setCursorPosition(newPos);
- }
- }
- }
- }
-
- String old = textField.getText();
- if((options & FORCE_CAPS) != 0) typedChar = Character.toUpperCase(typedChar);
- if((options & NO_SPACE) != 0 && typedChar == ' ') return;
-
- textField.setFocused(true);
- textField.textboxKeyTyped(typedChar, keyCode);
-
- if((options & COLOUR) != 0) {
- if(typedChar == '&') {
- int pos = textField.getCursorPosition()-2;
- if(pos >= 0 && pos < textField.getText().length()) {
- if(textField.getText().charAt(pos) == '&') {
- String before = textField.getText().substring(0, pos);
- String after = "";
- if(pos+2 < textField.getText().length()) {
- after = textField.getText().substring(pos+2);
- }
- textField.setText(before + "\u00A7" + after);
- textField.setCursorPosition(pos+1);
- }
- }
- }
- }
-
- if((options & NUM_ONLY) != 0 && textField.getText().matches("[^0-9.]")) textField.setText(old);
- }
- }
-
- public void render(int x, int y) {
- this.x = x;
- this.y = y;
- drawTextbox(x, y, searchBarXSize, searchBarYSize, searchBarPadding, textField, focus);
- }
-
- private void drawTextbox(int x, int y, int searchBarXSize, int searchBarYSize, int searchBarPadding,
- GuiTextField textField, boolean focus) {
- ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
- String renderText = prependText + textField.getText();
-
- GlStateManager.disableLighting();
-
- /**
- * Search bar
- */
- int paddingUnscaled = searchBarPadding/scaledresolution.getScaleFactor();
- if(paddingUnscaled < 1) paddingUnscaled = 1;
-
- int numLines = StringUtils.countMatches(renderText, "\n")+1;
- int extraSize = (searchBarYSize-8)/2+8;
- int bottomTextBox = y + searchBarYSize + extraSize*(numLines-1);
-
- int borderColour = focus ? Color.GREEN.getRGB() : Color.WHITE.getRGB();
- if(customBorderColour != -1) {
- borderColour = customBorderColour;
- }
- //bar background
- drawRect(x - paddingUnscaled,
- y - paddingUnscaled,
- x + searchBarXSize + paddingUnscaled,
- bottomTextBox + paddingUnscaled, borderColour);
- drawRect(x,
- y,
- x + searchBarXSize,
- bottomTextBox, Color.BLACK.getRGB());
-
- //bar text
- Pattern patternControlCode = Pattern.compile("(?i)\\u00A7([^\\u00B6\n])(?!\\u00B6)");
-
- String text = renderText;
- String textNoColor = renderText;
- if((options & COLOUR) != 0) {
- while(true) {
- Matcher matcher = patternControlCode.matcher(text);
- if(!matcher.find() || matcher.groupCount() < 1) break;
- String code = matcher.group(1);
- text = matcher.replaceFirst("\u00A7"+code+"\u00B6"+code);
- }
- }
- while(true) {
- Matcher matcher = patternControlCode.matcher(textNoColor);
- if(!matcher.find() || matcher.groupCount() < 1) break;
- String code = matcher.group(1);
- textNoColor = matcher.replaceFirst("\u00B6"+code);
- }
-
- int xStartOffset = 5;
- float scale = 1;
- String[] texts = text.split("\n");
- for(int yOffI = 0; yOffI < texts.length; yOffI++) {
- int yOff = yOffI*extraSize;
-
- if(isScaling() && Minecraft.getMinecraft().fontRendererObj.getStringWidth(texts[yOffI])>searchBarXSize-10) {
- scale = (searchBarXSize-2)/(float)Minecraft.getMinecraft().fontRendererObj.getStringWidth(texts[yOffI]);
- if(scale > 1) scale=1;
- float newLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(texts[yOffI])*scale;
- xStartOffset = (int)((searchBarXSize-newLen)/2f);
-
- Utils.drawStringCenteredScaledMaxWidth(texts[yOffI], Minecraft.getMinecraft().fontRendererObj, x+searchBarXSize/2f,
- y+searchBarYSize/2f+yOff, false,
- searchBarXSize-2, Color.WHITE.getRGB());
- } else {
- Minecraft.getMinecraft().fontRendererObj.drawString(Utils.trimToWidth(texts[yOffI], searchBarXSize-10), x + 5,
- y+(searchBarYSize-8)/2+yOff, Color.WHITE.getRGB());
- }
- }
-
- if(focus && System.currentTimeMillis()%1000>500) {
- String textNCBeforeCursor = textNoColor.substring(0, textField.getCursorPosition()+prependText.length());
- int colorCodes = StringUtils.countMatches(textNCBeforeCursor, "\u00B6");
- String textBeforeCursor = text.substring(0, textField.getCursorPosition()+prependText.length()+(((options & COLOUR) != 0) ? colorCodes*2 : 0));
-
- int numLinesBeforeCursor = StringUtils.countMatches(textBeforeCursor, "\n");
- int yOff = numLinesBeforeCursor*extraSize;
-
- String[] split = textBeforeCursor.split("\n");
- int textBeforeCursorWidth;
- if(split.length <= numLinesBeforeCursor || split.length == 0) {
- textBeforeCursorWidth = 0;
- } else {
- textBeforeCursorWidth = (int)(Minecraft.getMinecraft().fontRendererObj.getStringWidth(split[split.length-1])*scale);
- }
- drawRect(x + xStartOffset + textBeforeCursorWidth,
- y+(searchBarYSize-8)/2-1 + yOff,
- x + xStartOffset + textBeforeCursorWidth+1,
- y+(searchBarYSize-8)/2+9 + yOff, Color.WHITE.getRGB());
- }
-
- String selectedText = textField.getSelectedText();
- if(!selectedText.isEmpty()) {
- int leftIndex = Math.min(textField.getCursorPosition()+prependText.length(), textField.getSelectionEnd()+prependText.length());
- int rightIndex = Math.max(textField.getCursorPosition()+prependText.length(), textField.getSelectionEnd()+prependText.length());
-
- float texX = 0;
- int texY = 0;
- boolean sectionSignPrev = false;
- boolean bold = false;
- for(int i=0; i<textNoColor.length(); i++) {
- char c = textNoColor.charAt(i);
- if(sectionSignPrev) {
- if(c != 'k' && c != 'K'
- && c != 'm' && c != 'M'
- && c != 'n' && c != 'N'
- && c != 'o' && c != 'O') {
- bold = c == 'l' || c == 'L';
- }
- }
- sectionSignPrev = false;
- if(c == '\u00B6') sectionSignPrev = true;
-
- if(c == '\n') {
- if(i >= leftIndex && i < rightIndex) {
- drawRect(x + xStartOffset + (int)texX,
- y+(searchBarYSize-8)/2-1 + texY,
- x + xStartOffset + (int)texX + 3,
- y+(searchBarYSize-8)/2+9 + texY, Color.LIGHT_GRAY.getRGB());
- }
-
- texX = 0;
- texY += extraSize;
- continue;
- }
-
- //String c2 = bold ? EnumChatFormatting.BOLD.toString() : "" + c;
-
- int len = Minecraft.getMinecraft().fontRendererObj.getStringWidth(String.valueOf(c));
- if(bold) len++;
- if(i >= leftIndex && i < rightIndex) {
- drawRect(x + xStartOffset + (int)texX,
- y+(searchBarYSize-8)/2-1 + texY,
- x + xStartOffset + (int)(texX + len*scale),
- y+(searchBarYSize-8)/2+9 + texY, Color.LIGHT_GRAY.getRGB());
-
- Utils.drawStringScaled(String.valueOf(c), Minecraft.getMinecraft().fontRendererObj,
- x + xStartOffset + texX,
- y+searchBarYSize/2f-scale*8/2f + texY, false, Color.BLACK.getRGB(), scale);
- if(bold) {
- Utils.drawStringScaled(String.valueOf(c), Minecraft.getMinecraft().fontRendererObj,
- x + xStartOffset + texX + 1,
- y+searchBarYSize/2f-scale*8/2f + texY, false, Color.BLACK.getRGB(), scale);
- }
- }
-
- texX += len*scale;
- }
- }
- }
+ private String prependText = "";
+
+ private final GuiTextField textField = new GuiTextField(0, Minecraft.getMinecraft().fontRendererObj,
+ 0, 0, 0, 0
+ );
+
+ private int customBorderColour = -1;
+
+ public GuiElementTextField(String initialText, int options) {
+ textField.setFocused(true);
+ textField.setCanLoseFocus(false);
+ textField.setMaxStringLength(9999);
+ textField.setText(initialText);
+ this.options = options;
+ }
+
+ public void setMaxStringLength(int len) {
+ textField.setMaxStringLength(len);
+ }
+
+ public void setCustomBorderColour(int colour) {
+ this.customBorderColour = colour;
+ }
+
+ public String getText() {
+ return textField.getText();
+ }
+
+ public void setPrependText(String text) {
+ this.prependText = text;
+ }
+
+ public void setText(String text) {
+ if (textField.getText() == null || !textField.getText().equals(text)) {
+ textField.setText(text);
+ }
+ }
+
+ public void setSize(int searchBarXSize, int searchBarYSize) {
+ this.searchBarXSize = searchBarXSize;
+ this.searchBarYSize = searchBarYSize;
+ }
+
+ @Override
+ public String toString() {
+ return textField.getText();
+ }
+
+ public boolean getFocus() {
+ return focus;
+ }
+
+ @Override
+ public int getHeight() {
+ ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
+ int paddingUnscaled = searchBarPadding / scaledresolution.getScaleFactor();
+
+ int numLines = StringUtils.countMatches(textField.getText(), "\n") + 1;
+ int extraSize = (searchBarYSize - 8) / 2 + 8;
+ int bottomTextBox = searchBarYSize + extraSize * (numLines - 1);
+
+ return bottomTextBox + paddingUnscaled * 2;
+ }
+
+ @Override
+ public int getWidth() {
+ ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
+ int paddingUnscaled = searchBarPadding / scaledresolution.getScaleFactor();
+
+ return searchBarXSize + paddingUnscaled * 2;
+ }
+
+ private float getScaleFactor(String str) {
+ return Math.min(1, (searchBarXSize - 2) / (float) Minecraft.getMinecraft().fontRendererObj.getStringWidth(str));
+ }
+
+ private boolean isScaling() {
+ return (options & SCALE_TEXT) != 0;
+ }
+
+ private float getStringWidth(String str) {
+ if (isScaling()) {
+ return Minecraft.getMinecraft().fontRendererObj.getStringWidth(str) * getScaleFactor(str);
+ } else {
+ return Minecraft.getMinecraft().fontRendererObj.getStringWidth(str);
+ }
+ }
+
+ public int getCursorPos(int mouseX, int mouseY) {
+ int xComp = mouseX - x;
+ int yComp = mouseY - y;
+
+ int extraSize = (searchBarYSize - 8) / 2 + 8;
+
+ String renderText = prependText + textField.getText();
+
+ int lineNum = Math.round(((yComp - (searchBarYSize - 8) / 2)) / extraSize);
+
+ Pattern patternControlCode = Pattern.compile("(?i)\\u00A7([^\\u00B6])(?!\\u00B6)");
+ String text = renderText;
+ String textNoColour = renderText;
+ if ((options & COLOUR) != 0) {
+ while (true) {
+ Matcher matcher = patternControlCode.matcher(text);
+ if (!matcher.find() || matcher.groupCount() < 1) break;
+ String code = matcher.group(1);
+ text = matcher.replaceFirst("\u00A7" + code + "\u00B6" + code);
+ }
+ }
+ while (true) {
+ Matcher matcher = patternControlCode.matcher(textNoColour);
+ if (!matcher.find() || matcher.groupCount() < 1) break;
+ String code = matcher.group(1);
+ textNoColour = matcher.replaceFirst("\u00B6" + code);
+ }
+
+ int currentLine = 0;
+ int cursorIndex = 0;
+ for (; cursorIndex < textNoColour.length(); cursorIndex++) {
+ if (currentLine == lineNum) break;
+ if (textNoColour.charAt(cursorIndex) == '\n') {
+ currentLine++;
+ }
+ }
+
+ String textNC = textNoColour.substring(0, cursorIndex);
+ int colorCodes = StringUtils.countMatches(textNC, "\u00B6");
+ String line = text.substring(cursorIndex + (((options & COLOUR) != 0) ? colorCodes * 2 : 0)).split("\n")[0];
+ int padding = Math.min(5, searchBarXSize - strLenNoColor(line)) / 2;
+ String trimmed = Minecraft.getMinecraft().fontRendererObj.trimStringToWidth(line, xComp - padding);
+ int linePos = strLenNoColor(trimmed);
+ if (linePos != strLenNoColor(line)) {
+ char after = line.charAt(linePos);
+ int trimmedWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(trimmed);
+ int charWidth = Minecraft.getMinecraft().fontRendererObj.getCharWidth(after);
+ if (trimmedWidth + charWidth / 2 < xComp - padding) {
+ linePos++;
+ }
+ }
+ cursorIndex += linePos;
+
+ int pre = Utils.cleanColour(prependText).length();
+ if (cursorIndex < pre) {
+ cursorIndex = 0;
+ } else {
+ cursorIndex -= pre;
+ }
+
+ return cursorIndex;
+ }
+
+ @Override
+ public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
+ if (mouseButton == 1) {
+ textField.setText("");
+ } else {
+ textField.setCursorPosition(getCursorPos(mouseX, mouseY));
+ }
+ focus = true;
+ }
+
+ public void otherComponentClick() {
+ focus = false;
+ textField.setSelectionPos(textField.getCursorPosition());
+ }
+
+ public int strLenNoColor(String str) {
+ return str.replaceAll("(?i)\\u00A7.", "").length();
+ }
+
+ public void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
+ if (focus) {
+ textField.setSelectionPos(getCursorPos(mouseX, mouseY));
+ }
+ }
+
+ @Override
+ public void keyTyped(char typedChar, int keyCode) {
+ if (focus) {
+ if ((options & MULTILINE) != 0) { //Carriage return
+ Pattern patternControlCode = Pattern.compile("(?i)\\u00A7([^\\u00B6\n])(?!\\u00B6)");
+
+ String text = textField.getText();
+ String textNoColour = textField.getText();
+ while (true) {
+ Matcher matcher = patternControlCode.matcher(text);
+ if (!matcher.find() || matcher.groupCount() < 1) break;
+ String code = matcher.group(1);
+ text = matcher.replaceFirst("\u00A7" + code + "\u00B6" + code);
+ }
+ while (true) {
+ Matcher matcher = patternControlCode.matcher(textNoColour);
+ if (!matcher.find() || matcher.groupCount() < 1) break;
+ String code = matcher.group(1);
+ textNoColour = matcher.replaceFirst("\u00B6" + code);
+ }
+
+ if (keyCode == 28) {
+ String before = textField.getText().substring(0, textField.getCursorPosition());
+ String after = textField.getText().substring(textField.getCursorPosition());
+ int pos = textField.getCursorPosition();
+ textField.setText(before + "\n" + after);
+ textField.setCursorPosition(pos + 1);
+ return;
+ } else if (keyCode == 200) { //Up
+ String textNCBeforeCursor = textNoColour.substring(0, textField.getSelectionEnd());
+ int colorCodes = StringUtils.countMatches(textNCBeforeCursor, "\u00B6");
+ String textBeforeCursor = text.substring(0, textField.getSelectionEnd() + colorCodes * 2);
+
+ int numLinesBeforeCursor = StringUtils.countMatches(textBeforeCursor, "\n");
+
+ String[] split = textBeforeCursor.split("\n");
+ int textBeforeCursorWidth;
+ String lineBefore;
+ String thisLineBeforeCursor;
+ if (split.length == numLinesBeforeCursor && split.length > 0) {
+ textBeforeCursorWidth = 0;
+ lineBefore = split[split.length - 1];
+ thisLineBeforeCursor = "";
+ } else if (split.length > 1) {
+ thisLineBeforeCursor = split[split.length - 1];
+ lineBefore = split[split.length - 2];
+ textBeforeCursorWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(thisLineBeforeCursor);
+ } else {
+ return;
+ }
+ String trimmed = Minecraft.getMinecraft().fontRendererObj
+ .trimStringToWidth(lineBefore, textBeforeCursorWidth);
+ int linePos = strLenNoColor(trimmed);
+ if (linePos != strLenNoColor(lineBefore)) {
+ char after = lineBefore.charAt(linePos);
+ int trimmedWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(trimmed);
+ int charWidth = Minecraft.getMinecraft().fontRendererObj.getCharWidth(after);
+ if (trimmedWidth + charWidth / 2 < textBeforeCursorWidth) {
+ linePos++;
+ }
+ }
+ int newPos = textField.getSelectionEnd() - strLenNoColor(thisLineBeforeCursor)
+ - strLenNoColor(lineBefore) - 1 + linePos;
+
+ if (GuiScreen.isShiftKeyDown()) {
+ textField.setSelectionPos(newPos);
+ } else {
+ textField.setCursorPosition(newPos);
+ }
+ } else if (keyCode == 208) { //Down
+ String textNCBeforeCursor = textNoColour.substring(0, textField.getSelectionEnd());
+ int colorCodes = StringUtils.countMatches(textNCBeforeCursor, "\u00B6");
+ String textBeforeCursor = text.substring(0, textField.getSelectionEnd() + colorCodes * 2);
+
+ int numLinesBeforeCursor = StringUtils.countMatches(textBeforeCursor, "\n");
+
+ String[] split = textBeforeCursor.split("\n");
+ String thisLineBeforeCursor;
+ int textBeforeCursorWidth;
+ if (split.length == numLinesBeforeCursor) {
+ thisLineBeforeCursor = "";
+ textBeforeCursorWidth = 0;
+ } else if (split.length > 0) {
+ thisLineBeforeCursor = split[split.length - 1];
+ textBeforeCursorWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(thisLineBeforeCursor);
+ } else {
+ return;
+ }
+
+ String[] split2 = textNoColour.split("\n");
+ if (split2.length > numLinesBeforeCursor + 1) {
+ String lineAfter = split2[numLinesBeforeCursor + 1];
+ String trimmed = Minecraft.getMinecraft().fontRendererObj
+ .trimStringToWidth(lineAfter, textBeforeCursorWidth);
+ int linePos = strLenNoColor(trimmed);
+ if (linePos != strLenNoColor(lineAfter)) {
+ char after = lineAfter.charAt(linePos);
+ int trimmedWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(trimmed);
+ int charWidth = Minecraft.getMinecraft().fontRendererObj.getCharWidth(after);
+ if (trimmedWidth + charWidth / 2 < textBeforeCursorWidth) {
+ linePos++;
+ }
+ }
+ int newPos = textField.getSelectionEnd() - strLenNoColor(thisLineBeforeCursor)
+ + strLenNoColor(split2[numLinesBeforeCursor]) + 1 + linePos;
+
+ if (GuiScreen.isShiftKeyDown()) {
+ textField.setSelectionPos(newPos);
+ } else {
+ textField.setCursorPosition(newPos);
+ }
+ }
+ }
+ }
+
+ String old = textField.getText();
+ if ((options & FORCE_CAPS) != 0) typedChar = Character.toUpperCase(typedChar);
+ if ((options & NO_SPACE) != 0 && typedChar == ' ') return;
+
+ textField.setFocused(true);
+ textField.textboxKeyTyped(typedChar, keyCode);
+
+ if ((options & COLOUR) != 0) {
+ if (typedChar == '&') {
+ int pos = textField.getCursorPosition() - 2;
+ if (pos >= 0 && pos < textField.getText().length()) {
+ if (textField.getText().charAt(pos) == '&') {
+ String before = textField.getText().substring(0, pos);
+ String after = "";
+ if (pos + 2 < textField.getText().length()) {
+ after = textField.getText().substring(pos + 2);
+ }
+ textField.setText(before + "\u00A7" + after);
+ textField.setCursorPosition(pos + 1);
+ }
+ }
+ }
+ }
+
+ if ((options & NUM_ONLY) != 0 && textField.getText().matches("[^0-9.]")) textField.setText(old);
+ }
+ }
+
+ public void render(int x, int y) {
+ this.x = x;
+ this.y = y;
+ drawTextbox(x, y, searchBarXSize, searchBarYSize, searchBarPadding, textField, focus);
+ }
+
+ private void drawTextbox(
+ int x, int y, int searchBarXSize, int searchBarYSize, int searchBarPadding,
+ GuiTextField textField, boolean focus
+ ) {
+ ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
+ String renderText = prependText + textField.getText();
+
+ GlStateManager.disableLighting();
+
+ /*
+ * Search bar
+ */
+ int paddingUnscaled = searchBarPadding / scaledresolution.getScaleFactor();
+ if (paddingUnscaled < 1) paddingUnscaled = 1;
+
+ int numLines = StringUtils.countMatches(renderText, "\n") + 1;
+ int extraSize = (searchBarYSize - 8) / 2 + 8;
+ int bottomTextBox = y + searchBarYSize + extraSize * (numLines - 1);
+
+ int borderColour = focus ? Color.GREEN.getRGB() : Color.WHITE.getRGB();
+ if (customBorderColour != -1) {
+ borderColour = customBorderColour;
+ }
+ //bar background
+ drawRect(x - paddingUnscaled,
+ y - paddingUnscaled,
+ x + searchBarXSize + paddingUnscaled,
+ bottomTextBox + paddingUnscaled, borderColour
+ );
+ drawRect(x,
+ y,
+ x + searchBarXSize,
+ bottomTextBox, Color.BLACK.getRGB()
+ );
+
+ //bar text
+ Pattern patternControlCode = Pattern.compile("(?i)\\u00A7([^\\u00B6\n])(?!\\u00B6)");
+
+ String text = renderText;
+ String textNoColor = renderText;
+ if ((options & COLOUR) != 0) {
+ while (true) {
+ Matcher matcher = patternControlCode.matcher(text);
+ if (!matcher.find() || matcher.groupCount() < 1) break;
+ String code = matcher.group(1);
+ text = matcher.replaceFirst("\u00A7" + code + "\u00B6" + code);
+ }
+ }
+ while (true) {
+ Matcher matcher = patternControlCode.matcher(textNoColor);
+ if (!matcher.find() || matcher.groupCount() < 1) break;
+ String code = matcher.group(1);
+ textNoColor = matcher.replaceFirst("\u00B6" + code);
+ }
+
+ int xStartOffset = 5;
+ float scale = 1;
+ String[] texts = text.split("\n");
+ for (int yOffI = 0; yOffI < texts.length; yOffI++) {
+ int yOff = yOffI * extraSize;
+
+ if (isScaling() && Minecraft.getMinecraft().fontRendererObj.getStringWidth(texts[yOffI]) > searchBarXSize - 10) {
+ scale = (searchBarXSize - 2) / (float) Minecraft.getMinecraft().fontRendererObj.getStringWidth(texts[yOffI]);
+ if (scale > 1) scale = 1;
+ float newLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(texts[yOffI]) * scale;
+ xStartOffset = (int) ((searchBarXSize - newLen) / 2f);
+
+ Utils.drawStringCenteredScaledMaxWidth(
+ texts[yOffI],
+ Minecraft.getMinecraft().fontRendererObj,
+ x + searchBarXSize / 2f,
+ y + searchBarYSize / 2f + yOff,
+ false,
+ searchBarXSize - 2,
+ Color.WHITE.getRGB()
+ );
+ } else {
+ Minecraft.getMinecraft().fontRendererObj.drawString(Utils.trimToWidth(texts[yOffI], searchBarXSize - 10), x + 5,
+ y + (searchBarYSize - 8) / 2 + yOff, Color.WHITE.getRGB()
+ );
+ }
+ }
+
+ if (focus && System.currentTimeMillis() % 1000 > 500) {
+ String textNCBeforeCursor = textNoColor.substring(0, textField.getCursorPosition() + prependText.length());
+ int colorCodes = StringUtils.countMatches(textNCBeforeCursor, "\u00B6");
+ String textBeforeCursor = text.substring(
+ 0,
+ textField.getCursorPosition() + prependText.length() + (((options & COLOUR) != 0) ? colorCodes * 2 : 0)
+ );
+
+ int numLinesBeforeCursor = StringUtils.countMatches(textBeforeCursor, "\n");
+ int yOff = numLinesBeforeCursor * extraSize;
+
+ String[] split = textBeforeCursor.split("\n");
+ int textBeforeCursorWidth;
+ if (split.length <= numLinesBeforeCursor || split.length == 0) {
+ textBeforeCursorWidth = 0;
+ } else {
+ textBeforeCursorWidth = (int) (Minecraft.getMinecraft().fontRendererObj.getStringWidth(split[split.length -
+ 1]) * scale);
+ }
+ drawRect(x + xStartOffset + textBeforeCursorWidth,
+ y + (searchBarYSize - 8) / 2 - 1 + yOff,
+ x + xStartOffset + textBeforeCursorWidth + 1,
+ y + (searchBarYSize - 8) / 2 + 9 + yOff, Color.WHITE.getRGB()
+ );
+ }
+
+ String selectedText = textField.getSelectedText();
+ if (!selectedText.isEmpty()) {
+ int leftIndex = Math.min(
+ textField.getCursorPosition() + prependText.length(),
+ textField.getSelectionEnd() + prependText.length()
+ );
+ int rightIndex = Math.max(
+ textField.getCursorPosition() + prependText.length(),
+ textField.getSelectionEnd() + prependText.length()
+ );
+
+ float texX = 0;
+ int texY = 0;
+ boolean sectionSignPrev = false;
+ boolean bold = false;
+ for (int i = 0; i < textNoColor.length(); i++) {
+ char c = textNoColor.charAt(i);
+ if (sectionSignPrev) {
+ if (c != 'k' && c != 'K'
+ && c != 'm' && c != 'M'
+ && c != 'n' && c != 'N'
+ && c != 'o' && c != 'O') {
+ bold = c == 'l' || c == 'L';
+ }
+ }
+ sectionSignPrev = c == '\u00B6';
+
+ if (c == '\n') {
+ if (i >= leftIndex && i < rightIndex) {
+ drawRect(x + xStartOffset + (int) texX,
+ y + (searchBarYSize - 8) / 2 - 1 + texY,
+ x + xStartOffset + (int) texX + 3,
+ y + (searchBarYSize - 8) / 2 + 9 + texY, Color.LIGHT_GRAY.getRGB()
+ );
+ }
+
+ texX = 0;
+ texY += extraSize;
+ continue;
+ }
+
+ //String c2 = bold ? EnumChatFormatting.BOLD.toString() : "" + c;
+
+ int len = Minecraft.getMinecraft().fontRendererObj.getStringWidth(String.valueOf(c));
+ if (bold) len++;
+ if (i >= leftIndex && i < rightIndex) {
+ drawRect(x + xStartOffset + (int) texX,
+ y + (searchBarYSize - 8) / 2 - 1 + texY,
+ x + xStartOffset + (int) (texX + len * scale),
+ y + (searchBarYSize - 8) / 2 + 9 + texY, Color.LIGHT_GRAY.getRGB()
+ );
+
+ Utils.drawStringScaled(String.valueOf(c), Minecraft.getMinecraft().fontRendererObj,
+ x + xStartOffset + texX,
+ y + searchBarYSize / 2f - scale * 8 / 2f + texY, false, Color.BLACK.getRGB(), scale
+ );
+ if (bold) {
+ Utils.drawStringScaled(String.valueOf(c), Minecraft.getMinecraft().fontRendererObj,
+ x + xStartOffset + texX + 1,
+ y + searchBarYSize / 2f - scale * 8 / 2f + texY, false, Color.BLACK.getRGB(), scale
+ );
+ }
+ }
+
+ texX += len * scale;
+ }
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/NEUItemEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/NEUItemEditor.java
index 4614a6d3..0392c32f 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/NEUItemEditor.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/NEUItemEditor.java
@@ -6,7 +6,9 @@ import io.github.moulberry.notenoughupdates.NEUManager;
import io.github.moulberry.notenoughupdates.core.util.lerp.LerpingInteger;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.*;
+import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderItem;
@@ -20,379 +22,391 @@ import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.io.IOException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import java.util.function.Supplier;
+
import static io.github.moulberry.notenoughupdates.itemeditor.GuiElementTextField.*;
public class NEUItemEditor extends GuiScreen {
-
- private NEUManager manager;
-
- private List<GuiElement> options = new ArrayList<>();
- private List<GuiElement> rightOptions = new ArrayList<>();
-
- private JsonObject item;
-
- private static final int PADDING = 10;
- private static final int SCROLL_AMOUNT = 20;
-
- private LerpingInteger scrollHeight = new LerpingInteger(0);
-
- private Supplier<String> internalname;
- private Supplier<String> itemid;
- private Supplier<String> displayname;
- private Supplier<String> lore;
- private Supplier<String> crafttext;
- private Supplier<String> infoType;
- private Supplier<String> info;
- private Supplier<String> clickcommand;
- private Supplier<String> damage;
- private NBTTagCompound nbttag;
-
- public NEUItemEditor(NEUManager manager, String internalname, JsonObject item) {
- this.manager = manager;
- this.item = item;
-
- if(item.has("nbttag")) {
- try {
- nbttag = JsonToNBT.getTagFromJson(item.get("nbttag").getAsString());
- } catch(NBTException e) {}
- }
-
- internalname = internalname == null ? "" : internalname;
- options.add(new GuiElementText("Internal Name: ", Color.WHITE.getRGB()));
- this.internalname = addTextFieldWithSupplier(internalname, NO_SPACE | FORCE_CAPS);
-
- options.add(new GuiElementText("Item ID: ", Color.WHITE.getRGB()));
- String itemid = item.has("itemid") ? item.get("itemid").getAsString() : "";
- this.itemid = addTextFieldWithSupplier(itemid, NO_SPACE);
-
- options.add(new GuiElementText("Display name: ", Color.WHITE.getRGB()));
- String displayname = item.has("displayname") ? item.get("displayname").getAsString() : "";
- this.displayname = addTextFieldWithSupplier(displayname, COLOUR);
-
- options.add(new GuiElementText("Lore: ", Color.WHITE.getRGB()));
- JsonArray lore = item.has("lore") ? item.get("lore").getAsJsonArray() : new JsonArray();
- String[] loreA = new String[lore.size()];
- for(int i=0; i<lore.size(); i++) loreA[i] = lore.get(i).getAsString();
- this.lore = addTextFieldWithSupplier(String.join("\n", loreA), COLOUR | MULTILINE);
-
- options.add(new GuiElementText("Craft text: ", Color.WHITE.getRGB()));
- String crafttext = item.has("crafttext") ? item.get("crafttext").getAsString() : "";
- this.crafttext = addTextFieldWithSupplier(crafttext, COLOUR);
-
- options.add(new GuiElementText("Info type: ", Color.WHITE.getRGB()));
- String infoType = item.has("infoType") ? item.get("infoType").getAsString() : "";
- this.infoType = addTextFieldWithSupplier(infoType, NO_SPACE | FORCE_CAPS);
-
- options.add(new GuiElementText("Additional information: ", Color.WHITE.getRGB()));
- JsonArray info = item.has("info") ? item.get("info").getAsJsonArray() : new JsonArray();
- String[] infoA = new String[info.size()];
- for(int i=0; i<info.size(); i++) infoA[i] = info.get(i).getAsString();
- this.info = addTextFieldWithSupplier(String.join("\n", infoA), COLOUR | MULTILINE);
-
- options.add(new GuiElementText("Click-command (viewrecipe or viewpotion): ", Color.WHITE.getRGB()));
- String clickcommand = item.has("clickcommand") ? item.get("clickcommand").getAsString() : "";
- this.clickcommand = addTextFieldWithSupplier(clickcommand, NO_SPACE);
-
- options.add(new GuiElementText("Damage: ", Color.WHITE.getRGB()));
- String damage = item.has("damage") ? item.get("damage").getAsString() : "";
- this.damage = addTextFieldWithSupplier(damage, NO_SPACE | NUM_ONLY);
-
- rightOptions.add(new GuiElementButton("Close (discards changes)", Color.LIGHT_GRAY.getRGB(), () -> {
- Minecraft.getMinecraft().displayGuiScreen(null);
- }));
- GuiElementButton button = new Object() { //Used to make the compiler shut the fuck up
- GuiElementButton b = new GuiElementButton("Save to local disk", Color.GREEN.getRGB(), new Runnable() {
- public void run() {
- if(save()) {
- b.setText("Save to local disk (SUCCESS)");
- } else {
- b.setText("Save to local disk (FAILED)");
- }
- }
- });
- }.b;
- rightOptions.add(button);
-
- rightOptions.add(new GuiElementText("", Color.WHITE.getRGB()));
-
- rightOptions.add(new GuiElementButton("Remove enchants", Color.RED.getRGB(), () -> {
- nbttag.removeTag("ench");
- nbttag.getCompoundTag("ExtraAttributes").removeTag("enchantments");
- }));
- rightOptions.add(new GuiElementButton("Add enchant glint", Color.ORANGE.getRGB(), () -> {
- nbttag.setTag("ench", new NBTTagList());
- }));
-
- resetScrollToTop();
- }
-
- public boolean save() {
- int damageI = 0;
- try {
- damageI = Integer.valueOf(damage.get());
- } catch(NumberFormatException e) {}
- resyncNbttag();
- String[] infoA = info.get().trim().split("\n");
- if(infoA.length == 0 || infoA[0].isEmpty()) {
- infoA = new String[0];
- }
- return manager.writeItemJson(item, internalname.get(), itemid.get(), displayname.get(), lore.get().split("\n"),
- crafttext.get(), infoType.get(), infoA, clickcommand.get(), damageI, nbttag);
- }
-
- public void onGuiClosed() {
- Keyboard.enableRepeatEvents(false);
- }
-
- public Supplier<String> addTextFieldWithSupplier(String initialText, int options) {
- GuiElementTextField textField = new GuiElementTextField(initialText, options);
- this.options.add(textField);
- return () -> textField.toString();
- }
-
- public void resyncNbttag() {
- if(nbttag == null) nbttag = new NBTTagCompound();
-
- //Item lore
- NBTTagList list = new NBTTagList();
- for(String lore : this.lore.get().split("\n")) {
- list.appendTag(new NBTTagString(lore));
- }
-
- NBTTagCompound display = nbttag.getCompoundTag("display");
- display.setTag("Lore", list);
-
- //Name
- display.setString("Name", displayname.get());
- nbttag.setTag("display", display);
-
- //Internal ID
- NBTTagCompound ea = nbttag.getCompoundTag("ExtraAttributes");
- ea.setString("id", internalname.get());
- nbttag.setTag("ExtraAttributes", ea);
- }
-
- public void resetScrollToTop() {
- int totalHeight = PADDING;
- for(GuiElement gui : options) {
- totalHeight += gui.getHeight();
- }
-
- ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
- int height = scaledresolution.getScaledHeight();
-
- scrollHeight.setValue(totalHeight-height+PADDING);
- }
-
- public int calculateYScroll() {
- ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
- int height = scaledresolution.getScaledHeight();
-
- int totalHeight = PADDING;
- for(GuiElement gui : options) {
- totalHeight += gui.getHeight();
- }
-
- if(scrollHeight.getValue() < 0) scrollHeight.setValue(0);
-
- int yScroll = 0;
- if(totalHeight > height-PADDING) {
- yScroll = totalHeight-height+PADDING-scrollHeight.getValue();
- } else {
- scrollHeight.setValue(0);
- }
- if(yScroll < 0) {
- yScroll = 0;
- scrollHeight.setValue(totalHeight-height+PADDING);
- }
-
- return yScroll;
- }
-
- @Override
- public void drawScreen(int mouseX, int mouseY, float partialTicks) {
- scrollHeight.tick();
-
- ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
- int width = scaledresolution.getScaledWidth();
- int height = scaledresolution.getScaledHeight();
-
- GlStateManager.disableLighting();
-
- Color backgroundColour = new Color(10, 10, 10, 240);
- drawRect(0, 0, width, height, backgroundColour.getRGB());
-
- int yScroll = calculateYScroll();
- if(yScroll > 0){
- //Render scroll bar
- }
-
- int currentY = PADDING-yScroll;
- for(GuiElement gui : options) {
- gui.render(PADDING, currentY);
- currentY += gui.getHeight();
- }
-
- currentY = PADDING;
- for(GuiElement gui : rightOptions) {
- gui.render(width-PADDING-gui.getWidth(), currentY);
- currentY += gui.getHeight();
- }
-
- int itemX = 424;
- int itemY = 32;
- int itemSize = 128;
- Color itemBorder = new Color(100, 50, 150, 255);
- Color itemBackground = new Color(120, 120, 120, 255);
- drawRect(itemX-10, itemY-10, itemX+itemSize+10, itemY+itemSize+10, Color.DARK_GRAY.getRGB());
- drawRect(itemX-9, itemY-9, itemX+itemSize+9, itemY+itemSize+9, itemBorder.getRGB());
- drawRect(itemX-6, itemY-6, itemX+itemSize+6, itemY+itemSize+6, Color.DARK_GRAY.getRGB());
- drawRect(itemX-5, itemY-5, itemX+itemSize+5, itemY+itemSize+5, itemBackground.getRGB());
- ItemStack stack = new ItemStack(Item.itemRegistry.getObject(new ResourceLocation(itemid.get())));
-
- if(stack.getItem() != null) {
- try {
- stack.setItemDamage(Integer.valueOf(damage.get()));
- } catch(NumberFormatException e) {}
-
- resyncNbttag();
- stack.setTagCompound(nbttag);
-
- int scaleFactor = itemSize/16;
- GL11.glPushMatrix();
- GlStateManager.scale(scaleFactor, scaleFactor, 1);
- drawItemStack(stack, itemX/scaleFactor, itemY/scaleFactor, null);
- GL11.glPopMatrix();
- }
-
- //Tooltip
- List<String> text = new ArrayList<>();
- text.add(displayname.get());
- text.addAll(Arrays.asList(lore.get().split("\n")));
-
- Utils.drawHoveringText(text, itemX-20, itemY+itemSize+28, width, height, -1,
- Minecraft.getMinecraft().fontRendererObj);
-
- GlStateManager.disableLighting();
- }
-
- @Override
- protected void keyTyped(char typedChar, int keyCode) {
- for(GuiElement gui : options) {
- gui.keyTyped(typedChar, keyCode);
- }
- }
-
- @Override
- protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
- ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
- int width = scaledresolution.getScaledWidth();
-
- int yScroll = calculateYScroll();
- int currentY = PADDING-yScroll;
- for(GuiElement gui : options) {
- if(mouseY > currentY && mouseY < currentY+gui.getHeight()
- && mouseX < gui.getWidth()) {
- gui.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
- return;
- }
- currentY += gui.getHeight();
- }
-
- currentY = PADDING;
- for(GuiElement gui : rightOptions) {
- if(mouseY > currentY && mouseY < currentY+gui.getHeight()
- && mouseX > width-PADDING-gui.getWidth()) {
- gui.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
- return;
- }
- currentY += gui.getHeight();
- }
- }
-
- @Override
- public void handleMouseInput() throws IOException {
- ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
-
- int maxWidth = 0;
- for(GuiElement gui : options) {
- if(gui.getWidth() > maxWidth) maxWidth = gui.getWidth();
- }
-
- if(Mouse.getX() < maxWidth*scaledresolution.getScaleFactor()) {
- int dWheel = Mouse.getEventDWheel();
-
- if(dWheel < 0) {
- scrollHeight.setTarget(scrollHeight.getTarget()-SCROLL_AMOUNT);
- scrollHeight.resetTimer();
- } else if(dWheel > 0) {
- scrollHeight.setTarget(scrollHeight.getTarget()+SCROLL_AMOUNT);
- scrollHeight.resetTimer();
- }
- }
-
- super.handleMouseInput();
- }
-
- @Override
- protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
- ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
- int width = scaledresolution.getScaledWidth();
-
- int yScroll = calculateYScroll();
- int currentY = PADDING-yScroll;
- for(GuiElement gui : options) {
- if(mouseY > currentY && mouseY < currentY+gui.getHeight()
- && mouseX < gui.getWidth()) {
- gui.mouseClicked(mouseX, mouseY, mouseButton);
- for(GuiElement gui2 : options) {
- if(gui2 != gui) {
- gui2.otherComponentClick();
- }
- }
- for(GuiElement gui2 : rightOptions) {
- if(gui2 != gui) {
- gui2.otherComponentClick();
- }
- }
- return;
- }
- currentY += gui.getHeight();
- }
-
- currentY = PADDING;
- for(GuiElement gui : rightOptions) {
- if(mouseY > currentY && mouseY < currentY+gui.getHeight()
- && mouseX > width-PADDING-gui.getWidth()) {
- gui.mouseClicked(mouseX, mouseY, mouseButton);
- for(GuiElement gui2 : options) {
- if(gui2 != gui) {
- gui2.otherComponentClick();
- }
- }
- for(GuiElement gui2 : rightOptions) {
- if(gui2 != gui) {
- gui2.otherComponentClick();
- }
- }
- return;
- }
- currentY += gui.getHeight();
- }
- }
-
- private void drawItemStack(ItemStack stack, int x, int y, String altText) {
- RenderItem itemRender = Minecraft.getMinecraft().getRenderItem();
- FontRenderer font = Minecraft.getMinecraft().fontRendererObj;
-
- RenderHelper.enableGUIStandardItemLighting();
- itemRender.renderItemAndEffectIntoGUI(stack, x, y);
- RenderHelper.disableStandardItemLighting();
-
- itemRender.renderItemOverlayIntoGUI(font, stack, x, y, altText);
- }
+ private final NEUManager manager;
+
+ private final List<GuiElement> options = new ArrayList<>();
+ private final List<GuiElement> rightOptions = new ArrayList<>();
+
+ private final JsonObject item;
+
+ private static final int PADDING = 10;
+ private static final int SCROLL_AMOUNT = 20;
+
+ private final LerpingInteger scrollHeight = new LerpingInteger(0);
+
+ private final Supplier<String> internalname;
+ private final Supplier<String> itemid;
+ private final Supplier<String> displayname;
+ private final Supplier<String> lore;
+ private final Supplier<String> crafttext;
+ private final Supplier<String> infoType;
+ private final Supplier<String> info;
+ private final Supplier<String> clickcommand;
+ private final Supplier<String> damage;
+ private NBTTagCompound nbttag;
+
+ public NEUItemEditor(NEUManager manager, String internalname, JsonObject item) {
+ this.manager = manager;
+ this.item = item;
+
+ if (item.has("nbttag")) {
+ try {
+ nbttag = JsonToNBT.getTagFromJson(item.get("nbttag").getAsString());
+ } catch (NBTException ignored) {
+ }
+ }
+
+ internalname = internalname == null ? "" : internalname;
+ options.add(new GuiElementText("Internal Name: ", Color.WHITE.getRGB()));
+ this.internalname = addTextFieldWithSupplier(internalname, NO_SPACE | FORCE_CAPS);
+
+ options.add(new GuiElementText("Item ID: ", Color.WHITE.getRGB()));
+ String itemid = item.has("itemid") ? item.get("itemid").getAsString() : "";
+ this.itemid = addTextFieldWithSupplier(itemid, NO_SPACE);
+
+ options.add(new GuiElementText("Display name: ", Color.WHITE.getRGB()));
+ String displayname = item.has("displayname") ? item.get("displayname").getAsString() : "";
+ this.displayname = addTextFieldWithSupplier(displayname, COLOUR);
+
+ options.add(new GuiElementText("Lore: ", Color.WHITE.getRGB()));
+ JsonArray lore = item.has("lore") ? item.get("lore").getAsJsonArray() : new JsonArray();
+ String[] loreA = new String[lore.size()];
+ for (int i = 0; i < lore.size(); i++) loreA[i] = lore.get(i).getAsString();
+ this.lore = addTextFieldWithSupplier(String.join("\n", loreA), COLOUR | MULTILINE);
+
+ options.add(new GuiElementText("Craft text: ", Color.WHITE.getRGB()));
+ String crafttext = item.has("crafttext") ? item.get("crafttext").getAsString() : "";
+ this.crafttext = addTextFieldWithSupplier(crafttext, COLOUR);
+
+ options.add(new GuiElementText("Info type: ", Color.WHITE.getRGB()));
+ String infoType = item.has("infoType") ? item.get("infoType").getAsString() : "";
+ this.infoType = addTextFieldWithSupplier(infoType, NO_SPACE | FORCE_CAPS);
+
+ options.add(new GuiElementText("Additional information: ", Color.WHITE.getRGB()));
+ JsonArray info = item.has("info") ? item.get("info").getAsJsonArray() : new JsonArray();
+ String[] infoA = new String[info.size()];
+ for (int i = 0; i < info.size(); i++) infoA[i] = info.get(i).getAsString();
+ this.info = addTextFieldWithSupplier(String.join("\n", infoA), COLOUR | MULTILINE);
+
+ options.add(new GuiElementText("Click-command (viewrecipe or viewpotion): ", Color.WHITE.getRGB()));
+ String clickcommand = item.has("clickcommand") ? item.get("clickcommand").getAsString() : "";
+ this.clickcommand = addTextFieldWithSupplier(clickcommand, NO_SPACE);
+
+ options.add(new GuiElementText("Damage: ", Color.WHITE.getRGB()));
+ String damage = item.has("damage") ? item.get("damage").getAsString() : "";
+ this.damage = addTextFieldWithSupplier(damage, NO_SPACE | NUM_ONLY);
+
+ rightOptions.add(new GuiElementButton("Close (discards changes)", Color.LIGHT_GRAY.getRGB(), () ->
+ Minecraft.getMinecraft().displayGuiScreen(null)));
+ GuiElementButton button = new Object() { //Used to make the compiler shut the fuck up
+ final GuiElementButton b = new GuiElementButton("Save to local disk", Color.GREEN.getRGB(), new Runnable() {
+ public void run() {
+ if (save()) {
+ b.setText("Save to local disk (SUCCESS)");
+ } else {
+ b.setText("Save to local disk (FAILED)");
+ }
+ }
+ });
+ }.b;
+ rightOptions.add(button);
+
+ rightOptions.add(new GuiElementText("", Color.WHITE.getRGB()));
+
+ rightOptions.add(new GuiElementButton("Remove enchants", Color.RED.getRGB(), () -> {
+ nbttag.removeTag("ench");
+ nbttag.getCompoundTag("ExtraAttributes").removeTag("enchantments");
+ }));
+ rightOptions.add(new GuiElementButton(
+ "Add enchant glint",
+ Color.ORANGE.getRGB(),
+ () -> nbttag.setTag("ench", new NBTTagList())
+ ));
+
+ rightOptions.add(new GuiElementButton("Remove timestamp/uuid", Color.RED.getRGB(), () -> {
+ nbttag.getCompoundTag("ExtraAttributes").removeTag("uuid");
+ nbttag.getCompoundTag("ExtraAttributes").removeTag("timestamp");
+ }));
+
+ resetScrollToTop();
+ }
+
+ public boolean save() {
+ int damageI = 0;
+ try {
+ damageI = Integer.parseInt(damage.get());
+ } catch (NumberFormatException ignored) {
+ }
+ resyncNbttag();
+ String[] infoA = info.get().trim().split("\n");
+ if (infoA.length == 0 || infoA[0].isEmpty()) {
+ infoA = new String[0];
+ }
+ return manager.writeItemJson(item, internalname.get(), itemid.get(), displayname.get(), lore.get().split("\n"),
+ crafttext.get(), infoType.get(), infoA, clickcommand.get(), damageI, nbttag
+ );
+ }
+
+ public void onGuiClosed() {
+ Keyboard.enableRepeatEvents(false);
+ }
+
+ public Supplier<String> addTextFieldWithSupplier(String initialText, int options) {
+ GuiElementTextField textField = new GuiElementTextField(initialText, options);
+ this.options.add(textField);
+ return textField::toString;
+ }
+
+ public void resyncNbttag() {
+ if (nbttag == null) nbttag = new NBTTagCompound();
+
+ //Item lore
+ NBTTagList list = new NBTTagList();
+ for (String lore : this.lore.get().split("\n")) {
+ list.appendTag(new NBTTagString(lore));
+ }
+
+ NBTTagCompound display = nbttag.getCompoundTag("display");
+ display.setTag("Lore", list);
+
+ //Name
+ display.setString("Name", displayname.get());
+ nbttag.setTag("display", display);
+
+ //Internal ID
+ NBTTagCompound ea = nbttag.getCompoundTag("ExtraAttributes");
+ ea.setString("id", internalname.get());
+ nbttag.setTag("ExtraAttributes", ea);
+ }
+
+ public void resetScrollToTop() {
+ int totalHeight = PADDING;
+ for (GuiElement gui : options) {
+ totalHeight += gui.getHeight();
+ }
+
+ ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
+ int height = scaledresolution.getScaledHeight();
+
+ scrollHeight.setValue(totalHeight - height + PADDING);
+ }
+
+ public int calculateYScroll() {
+ ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
+ int height = scaledresolution.getScaledHeight();
+
+ int totalHeight = PADDING;
+ for (GuiElement gui : options) {
+ totalHeight += gui.getHeight();
+ }
+
+ if (scrollHeight.getValue() < 0) scrollHeight.setValue(0);
+
+ int yScroll = 0;
+ if (totalHeight > height - PADDING) {
+ yScroll = totalHeight - height + PADDING - scrollHeight.getValue();
+ } else {
+ scrollHeight.setValue(0);
+ }
+ if (yScroll < 0) {
+ yScroll = 0;
+ scrollHeight.setValue(totalHeight - height + PADDING);
+ }
+
+ return yScroll;
+ }
+
+ @Override
+ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
+ scrollHeight.tick();
+
+ ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
+ int width = scaledresolution.getScaledWidth();
+ int height = scaledresolution.getScaledHeight();
+
+ GlStateManager.disableLighting();
+
+ Color backgroundColour = new Color(10, 10, 10, 240);
+ drawRect(0, 0, width, height, backgroundColour.getRGB());
+
+ int yScroll = calculateYScroll();
+ if (yScroll > 0) {
+ //Render scroll bar
+ }
+
+ int currentY = PADDING - yScroll;
+ for (GuiElement gui : options) {
+ gui.render(PADDING, currentY);
+ currentY += gui.getHeight();
+ }
+
+ currentY = PADDING;
+ for (GuiElement gui : rightOptions) {
+ gui.render(width - PADDING - gui.getWidth(), currentY);
+ currentY += gui.getHeight();
+ }
+
+ int itemX = 424;
+ int itemY = 32;
+ int itemSize = 128;
+ Color itemBorder = new Color(100, 50, 150, 255);
+ Color itemBackground = new Color(120, 120, 120, 255);
+ drawRect(itemX - 10, itemY - 10, itemX + itemSize + 10, itemY + itemSize + 10, Color.DARK_GRAY.getRGB());
+ drawRect(itemX - 9, itemY - 9, itemX + itemSize + 9, itemY + itemSize + 9, itemBorder.getRGB());
+ drawRect(itemX - 6, itemY - 6, itemX + itemSize + 6, itemY + itemSize + 6, Color.DARK_GRAY.getRGB());
+ drawRect(itemX - 5, itemY - 5, itemX + itemSize + 5, itemY + itemSize + 5, itemBackground.getRGB());
+ ItemStack stack = new ItemStack(Item.itemRegistry.getObject(new ResourceLocation(itemid.get())));
+
+ if (stack.getItem() != null) {
+ try {
+ stack.setItemDamage(Integer.parseInt(damage.get()));
+ } catch (NumberFormatException ignored) {
+ }
+
+ resyncNbttag();
+ stack.setTagCompound(nbttag);
+
+ int scaleFactor = itemSize / 16;
+ GL11.glPushMatrix();
+ GlStateManager.scale(scaleFactor, scaleFactor, 1);
+ drawItemStack(stack, itemX / scaleFactor, itemY / scaleFactor, null);
+ GL11.glPopMatrix();
+ }
+
+ //Tooltip
+ List<String> text = new ArrayList<>();
+ text.add(displayname.get());
+ text.addAll(Arrays.asList(lore.get().split("\n")));
+
+ Utils.drawHoveringText(text, itemX - 20, itemY + itemSize + 28, width, height, -1,
+ Minecraft.getMinecraft().fontRendererObj
+ );
+
+ GlStateManager.disableLighting();
+ }
+
+ @Override
+ protected void keyTyped(char typedChar, int keyCode) {
+ for (GuiElement gui : options) {
+ gui.keyTyped(typedChar, keyCode);
+ }
+ }
+
+ @Override
+ protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
+ ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
+ int width = scaledresolution.getScaledWidth();
+
+ int yScroll = calculateYScroll();
+ int currentY = PADDING - yScroll;
+ for (GuiElement gui : options) {
+ if (mouseY > currentY && mouseY < currentY + gui.getHeight()
+ && mouseX < gui.getWidth()) {
+ gui.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
+ return;
+ }
+ currentY += gui.getHeight();
+ }
+
+ currentY = PADDING;
+ for (GuiElement gui : rightOptions) {
+ if (mouseY > currentY && mouseY < currentY + gui.getHeight()
+ && mouseX > width - PADDING - gui.getWidth()) {
+ gui.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
+ return;
+ }
+ currentY += gui.getHeight();
+ }
+ }
+
+ @Override
+ public void handleMouseInput() throws IOException {
+ ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
+
+ int maxWidth = 0;
+ for (GuiElement gui : options) {
+ if (gui.getWidth() > maxWidth) maxWidth = gui.getWidth();
+ }
+
+ if (Mouse.getX() < maxWidth * scaledresolution.getScaleFactor()) {
+ int dWheel = Mouse.getEventDWheel();
+
+ if (dWheel < 0) {
+ scrollHeight.setTarget(scrollHeight.getTarget() - SCROLL_AMOUNT);
+ scrollHeight.resetTimer();
+ } else if (dWheel > 0) {
+ scrollHeight.setTarget(scrollHeight.getTarget() + SCROLL_AMOUNT);
+ scrollHeight.resetTimer();
+ }
+ }
+
+ super.handleMouseInput();
+ }
+
+ @Override
+ protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
+ ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
+ int width = scaledresolution.getScaledWidth();
+
+ int yScroll = calculateYScroll();
+ int currentY = PADDING - yScroll;
+ for (GuiElement gui : options) {
+ if (mouseY > currentY && mouseY < currentY + gui.getHeight()
+ && mouseX < gui.getWidth()) {
+ gui.mouseClicked(mouseX, mouseY, mouseButton);
+ for (GuiElement gui2 : options) {
+ if (gui2 != gui) {
+ gui2.otherComponentClick();
+ }
+ }
+ for (GuiElement gui2 : rightOptions) {
+ if (gui2 != gui) {
+ gui2.otherComponentClick();
+ }
+ }
+ return;
+ }
+ currentY += gui.getHeight();
+ }
+
+ currentY = PADDING;
+ for (GuiElement gui : rightOptions) {
+ if (mouseY > currentY && mouseY < currentY + gui.getHeight()
+ && mouseX > width - PADDING - gui.getWidth()) {
+ gui.mouseClicked(mouseX, mouseY, mouseButton);
+ for (GuiElement gui2 : options) {
+ if (gui2 != gui) {
+ gui2.otherComponentClick();
+ }
+ }
+ for (GuiElement gui2 : rightOptions) {
+ if (gui2 != gui) {
+ gui2.otherComponentClick();
+ }
+ }
+ return;
+ }
+ currentY += gui.getHeight();
+ }
+ }
+
+ private void drawItemStack(ItemStack stack, int x, int y, String altText) {
+ RenderItem itemRender = Minecraft.getMinecraft().getRenderItem();
+ FontRenderer font = Minecraft.getMinecraft().fontRendererObj;
+
+ RenderHelper.enableGUIStandardItemLighting();
+ itemRender.renderItemAndEffectIntoGUI(stack, x, y);
+ RenderHelper.disableStandardItemLighting();
+
+ itemRender.renderItemOverlayIntoGUI(font, stack, x, y, altText);
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBAnchorPoint.java b/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBAnchorPoint.java
index da1b9ddc..eaf41ba6 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBAnchorPoint.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBAnchorPoint.java
@@ -5,50 +5,51 @@ import org.lwjgl.util.vector.Vector2f;
import java.io.Serializable;
public class MBAnchorPoint implements Serializable {
-
- public enum AnchorPoint {
- TOPLEFT(0, 0), TOPMID(0.5f, 0), TOPRIGHT(1, 0),
- MIDRIGHT(1, 0.5f), BOTRIGHT(1, 1), BOTMID(0.5f, 1),
- BOTLEFT(0, 1), MIDLEFT(0, 0.5f), MIDMID(0.5f, 0.5f);
-
- public final float x;
- public final float y;
-
- AnchorPoint(float x, float y) {
- this.x = x;
- this.y = y;
- }
- }
-
- public AnchorPoint anchorPoint;
- public Vector2f offset;
- public boolean inventoryRelative;
-
- public MBAnchorPoint(AnchorPoint anchorPoint, Vector2f offset) {
- this(anchorPoint, offset, false);
- }
-
- public MBAnchorPoint(AnchorPoint anchorPoint, Vector2f offset, boolean inventoryRelative) {
- this.anchorPoint = anchorPoint;
- this.offset = offset;
- this.inventoryRelative = inventoryRelative;
- }
-
- public static MBAnchorPoint createFromString(String str) {
- if(str == null || str.split(":").length != 4) {
- return null;
- }
-
- try {
- String[] split = str.split(":");
- AnchorPoint point = AnchorPoint.valueOf(split[0].toUpperCase());
- Vector2f pos = new Vector2f(Float.parseFloat(split[1]), Float.parseFloat(split[2]));
- return new MBAnchorPoint(point, pos, Boolean.parseBoolean(split[3]));
- } catch(Exception e) { return null; }
- }
-
- @Override
- public String toString() {
- return anchorPoint.toString() + ":" + offset.x + ":" + offset.y + ":" + inventoryRelative;
- }
+ public enum AnchorPoint {
+ TOPLEFT(0, 0), TOPMID(0.5f, 0), TOPRIGHT(1, 0),
+ MIDRIGHT(1, 0.5f), BOTRIGHT(1, 1), BOTMID(0.5f, 1),
+ BOTLEFT(0, 1), MIDLEFT(0, 0.5f), MIDMID(0.5f, 0.5f);
+
+ public final float x;
+ public final float y;
+
+ AnchorPoint(float x, float y) {
+ this.x = x;
+ this.y = y;
+ }
+ }
+
+ public AnchorPoint anchorPoint;
+ public Vector2f offset;
+ public boolean inventoryRelative;
+
+ public MBAnchorPoint(AnchorPoint anchorPoint, Vector2f offset) {
+ this(anchorPoint, offset, false);
+ }
+
+ public MBAnchorPoint(AnchorPoint anchorPoint, Vector2f offset, boolean inventoryRelative) {
+ this.anchorPoint = anchorPoint;
+ this.offset = offset;
+ this.inventoryRelative = inventoryRelative;
+ }
+
+ public static MBAnchorPoint createFromString(String str) {
+ if (str == null || str.split(":").length != 4) {
+ return null;
+ }
+
+ try {
+ String[] split = str.split(":");
+ AnchorPoint point = AnchorPoint.valueOf(split[0].toUpperCase());
+ Vector2f pos = new Vector2f(Float.parseFloat(split[1]), Float.parseFloat(split[2]));
+ return new MBAnchorPoint(point, pos, Boolean.parseBoolean(split[3]));
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return anchorPoint.toString() + ":" + offset.x + ":" + offset.y + ":" + inventoryRelative;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBDeserializer.java b/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBDeserializer.java
index 8f7d1bc0..b9e858ef 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBDeserializer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBDeserializer.java
@@ -5,16 +5,14 @@ import com.google.gson.JsonObject;
import java.io.IOException;
public class MBDeserializer {
+ public static MBGuiElement deserialize(JsonObject json) {
+ return null;
+ }
- public static MBGuiElement deserialize(JsonObject json) {
- return null;
- }
-
- public static void serializeAndSave(MBGuiElement element, String filename) throws IOException {
+ public static void serializeAndSave(MBGuiElement element, String filename) throws IOException {
/*JsonObject json = element.serialize();
File file = new File(NotEnoughUpdates.INSTANCE.manager.configLocation, filename+".json");
NotEnoughUpdates.INSTANCE.manager.writeJson(json, file);*/
- }
-
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiElement.java b/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiElement.java
index 1ff51238..ad836097 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiElement.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiElement.java
@@ -1,14 +1,17 @@
package io.github.moulberry.notenoughupdates.mbgui;
public abstract class MBGuiElement {
+ public abstract int getWidth();
- public abstract int getWidth();
- public abstract int getHeight();
- public abstract void recalculate();
- public abstract void mouseClick(float x, float y, int mouseX, int mouseY);
- public abstract void mouseClickOutside();
- public abstract void render(float x, float y);
+ public abstract int getHeight();
- //public abstract JsonObject serialize();
+ public abstract void recalculate();
+ public abstract void mouseClick(float x, float y, int mouseX, int mouseY);
+
+ public abstract void mouseClickOutside();
+
+ public abstract void render(float x, float y);
+
+ //public abstract JsonObject serialize();
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroup.java b/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroup.java
index 86ff7278..4540b146 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroup.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroup.java
@@ -8,61 +8,56 @@ import java.util.HashMap;
import java.util.Map;
public abstract class MBGuiGroup extends MBGuiElement {
-
- public int width;
- public int height;
- protected HashMap<MBGuiElement, Vector2f> childrenPosition = new HashMap<>();
-
- public MBGuiGroup() {
- }
-
- public abstract Collection<MBGuiElement> getChildren();
-
- public Map<MBGuiElement, Vector2f> getChildrenPosition() {
- return Collections.unmodifiableMap(childrenPosition);
- }
-
- @Override
- public int getWidth() {
- return width;
- }
-
- @Override
- public int getHeight() {
- return height;
- }
-
-
- @Override
- public void mouseClick(float x, float y, int mouseX, int mouseY) {
- Map<MBGuiElement, Vector2f> childrenPos = getChildrenPosition();
-
- for(MBGuiElement child : getChildren()) {
- Vector2f childPos = childrenPos.get(child);
- if(mouseX > x+childPos.x && mouseX < x+childPos.x+child.getWidth()) {
- if(mouseY > y+childPos.y && mouseY < y+childPos.y+child.getHeight()) {
- child.mouseClick(x+childPos.x, y+childPos.y, mouseX, mouseY);
- }
- }
- }
- }
-
- @Override
- public void mouseClickOutside() {
- for(MBGuiElement child : getChildren()) {
- child.mouseClickOutside();
- }
- }
-
- @Override
- public void render(float x, float y) {
- Map<MBGuiElement, Vector2f> childrenPos = getChildrenPosition();
-
- for(MBGuiElement child : getChildren()) {
- Vector2f childPos = childrenPos.get(child);
- child.render(x+childPos.x, y+childPos.y);
- }
- }
-
-
+ public int width;
+ public int height;
+ protected HashMap<MBGuiElement, Vector2f> childrenPosition = new HashMap<>();
+
+ public MBGuiGroup() {}
+
+ public abstract Collection<MBGuiElement> getChildren();
+
+ public Map<MBGuiElement, Vector2f> getChildrenPosition() {
+ return Collections.unmodifiableMap(childrenPosition);
+ }
+
+ @Override
+ public int getWidth() {
+ return width;
+ }
+
+ @Override
+ public int getHeight() {
+ return height;
+ }
+
+ @Override
+ public void mouseClick(float x, float y, int mouseX, int mouseY) {
+ Map<MBGuiElement, Vector2f> childrenPos = getChildrenPosition();
+
+ for (MBGuiElement child : getChildren()) {
+ Vector2f childPos = childrenPos.get(child);
+ if (mouseX > x + childPos.x && mouseX < x + childPos.x + child.getWidth()) {
+ if (mouseY > y + childPos.y && mouseY < y + childPos.y + child.getHeight()) {
+ child.mouseClick(x + childPos.x, y + childPos.y, mouseX, mouseY);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void mouseClickOutside() {
+ for (MBGuiElement child : getChildren()) {
+ child.mouseClickOutside();
+ }
+ }
+
+ @Override
+ public void render(float x, float y) {
+ Map<MBGuiElement, Vector2f> childrenPos = getChildrenPosition();
+
+ for (MBGuiElement child : getChildren()) {
+ Vector2f childPos = childrenPos.get(child);
+ child.render(x + childPos.x, y + childPos.y);
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupAligned.java b/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupAligned.java
index 77a28fd5..eef4b5e5 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupAligned.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupAligned.java
@@ -6,62 +6,59 @@ import java.util.Collection;
import java.util.List;
public abstract class MBGuiGroupAligned extends MBGuiGroup {
+ //Serialized
+ private final List<MBGuiElement> children;
+ private final boolean vertical;
- //Serialized
- private List<MBGuiElement> children;
- private boolean vertical;
+ public MBGuiGroupAligned(List<MBGuiElement> children, boolean vertical) {
+ this.children = children;
+ this.vertical = vertical;
+ recalculate();
+ }
- public MBGuiGroupAligned(List<MBGuiElement> children, boolean vertical) {
- this.children = children;
- this.vertical = vertical;
- recalculate();
- }
+ public abstract int getPadding();
- public abstract int getPadding();
+ public Collection<MBGuiElement> getChildren() {
+ return children;
+ }
- public Collection<MBGuiElement> getChildren() {
- return children;
- }
+ public void recalculate() {
+ for (MBGuiElement child : children) {
+ child.recalculate();
+ }
- public void recalculate() {
- for(MBGuiElement child : children) {
- child.recalculate();
- }
+ if (vertical) {
+ height = 0;
+ for (int i = 0; i < children.size(); i++) {
+ MBGuiElement child = children.get(i);
+ childrenPosition.put(child, new Vector2f(0, height));
+ height += child.getHeight();
+ if (i != children.size() - 1) height += getPadding();
+ }
- if(vertical) {
- height = 0;
- for(int i=0; i<children.size(); i++) {
- MBGuiElement child = children.get(i);
- childrenPosition.put(child, new Vector2f(0, height));
- height += child.getHeight();
- if(i != children.size()-1) height += getPadding();
- }
-
- width = 0;
- for(MBGuiElement child : children) {
- int childWidth = child.getWidth();
- if(childWidth > width) {
- width = childWidth;
- }
- }
- } else {
- width = 0;
- for(int i=0; i<children.size(); i++) {
- MBGuiElement child = children.get(i);
- childrenPosition.put(child, new Vector2f(width, 0));
- width += child.getWidth();
- if(i != children.size()-1) width += getPadding();
- }
-
- height = 0;
- for(MBGuiElement child : children) {
- int childHeight = child.getHeight();
- if(childHeight > height) {
- height = childHeight;
- }
- }
- }
-
- }
+ width = 0;
+ for (MBGuiElement child : children) {
+ int childWidth = child.getWidth();
+ if (childWidth > width) {
+ width = childWidth;
+ }
+ }
+ } else {
+ width = 0;
+ for (int i = 0; i < children.size(); i++) {
+ MBGuiElement child = children.get(i);
+ childrenPosition.put(child, new Vector2f(width, 0));
+ width += child.getWidth();
+ if (i != children.size() - 1) width += getPadding();
+ }
+ height = 0;
+ for (MBGuiElement child : children) {
+ int childHeight = child.getHeight();
+ if (childHeight > height) {
+ height = childHeight;
+ }
+ }
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupFloating.java b/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupFloating.java
index 8a972f78..24697cc6 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupFloating.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupFloating.java
@@ -1,8 +1,8 @@
package io.github.moulberry.notenoughupdates.mbgui;
-import io.github.moulberry.notenoughupdates.miscgui.GuiItemRecipe;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.auction.CustomAHGui;
+import io.github.moulberry.notenoughupdates.miscgui.GuiItemRecipe;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
@@ -13,125 +13,125 @@ import org.lwjgl.util.vector.Vector2f;
import java.util.*;
public class MBGuiGroupFloating extends MBGuiGroup {
-
- private GuiScreen lastScreen = null;
- private HashMap<MBGuiElement, Vector2f> childrenPositionOffset = new HashMap<>();
-
- //Serialized
- private LinkedHashMap<MBGuiElement, MBAnchorPoint> children;
-
- public MBGuiGroupFloating(int width, int height, LinkedHashMap<MBGuiElement, MBAnchorPoint> children) {
- this.width = width;
- this.height = height;
- this.children = children;
- recalculate();
- }
-
- public Map<MBGuiElement, MBAnchorPoint> getChildrenMap() {
- return Collections.unmodifiableMap(children);
- }
-
- @Override
- public Map<MBGuiElement, Vector2f> getChildrenPosition() {
- GuiScreen currentScreen = Minecraft.getMinecraft().currentScreen;
-
- if(currentScreen instanceof GuiContainer || currentScreen instanceof GuiItemRecipe
- || currentScreen instanceof CustomAHGui || NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.isRenderOverAuctionView()) {
-
- if(lastScreen != currentScreen) {
- lastScreen = currentScreen;
-
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- int screenWidth = scaledResolution.getScaledWidth();
- int screenHeight = scaledResolution.getScaledHeight();
-
- int xSize = -1;
- int ySize = -1;
- int guiLeft = -1;
- int guiTop = -1;
-
- if(currentScreen instanceof GuiContainer) {
- GuiContainer currentContainer = (GuiContainer) currentScreen;
-
- try {
- xSize = (int) Utils.getField(GuiContainer.class, currentContainer, "xSize", "field_146999_f");
- ySize = (int) Utils.getField(GuiContainer.class, currentContainer, "ySize", "field_147000_g");
- guiLeft = (int) Utils.getField(GuiContainer.class, currentContainer, "guiLeft", "field_147003_i");
- guiTop = (int) Utils.getField(GuiContainer.class, currentContainer, "guiTop", "field_147009_r");
- } catch(Exception ignored) {
- }
- } else if(currentScreen instanceof GuiItemRecipe) {
- xSize = ((GuiItemRecipe)currentScreen).xSize;
- ySize = ((GuiItemRecipe)currentScreen).ySize;
- guiLeft = ((GuiItemRecipe)currentScreen).guiLeft;
- guiTop = ((GuiItemRecipe)currentScreen).guiTop;
- } else if(currentScreen instanceof CustomAHGui ||
- NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.isRenderOverAuctionView()) {
- xSize = NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.getXSize();
- ySize = NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.getYSize();
- guiLeft = NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.guiLeft;
- guiTop = NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.guiTop;
- }
-
- if(xSize <= 0 && ySize <= 0 && guiLeft <= 0 && guiTop <= 0) {
- lastScreen = null;
- return Collections.unmodifiableMap(childrenPosition);
- }
-
- for(Map.Entry<MBGuiElement, MBAnchorPoint> entry : children.entrySet()) {
- MBGuiElement child = entry.getKey();
- MBAnchorPoint anchorPoint = entry.getValue();
-
- Vector2f childPos;
- if(childrenPosition.containsKey(child)) {
- childPos = new Vector2f(childrenPosition.get(child));
- } else {
- childPos = new Vector2f();
- }
-
- if(anchorPoint.inventoryRelative) {
- int defGuiLeft = (screenWidth - xSize) / 2;
- int defGuiTop = (screenHeight - ySize) / 2;
-
- childPos.x += guiLeft-defGuiLeft + (0.5f-anchorPoint.anchorPoint.x)*xSize;
- childPos.y += guiTop-defGuiTop + (0.5f-anchorPoint.anchorPoint.y)*ySize;
- }
-
- childrenPositionOffset.put(child, childPos);
- }
- }
- return Collections.unmodifiableMap(childrenPositionOffset);
- } else {
- return Collections.unmodifiableMap(childrenPosition);
- }
- }
-
- @Override
- public void recalculate() {
- lastScreen = null;
-
- for(MBGuiElement child : children.keySet()) {
- child.recalculate();
- }
-
- for(Map.Entry<MBGuiElement, MBAnchorPoint> entry : children.entrySet()) {
- MBGuiElement child = entry.getKey();
- MBAnchorPoint anchorPoint = entry.getValue();
- float x = anchorPoint.anchorPoint.x * width - anchorPoint.anchorPoint.x * child.getWidth() + anchorPoint.offset.x;
- float y = anchorPoint.anchorPoint.y * height - anchorPoint.anchorPoint.y * child.getHeight() + anchorPoint.offset.y;
-
- if(anchorPoint.inventoryRelative) {
- x = width*0.5f + anchorPoint.offset.x;
- y = height*0.5f + anchorPoint.offset.y;
- }
-
- childrenPosition.put(child, new Vector2f(x, y));
- }
- }
-
- @Override
- public Collection<MBGuiElement> getChildren() {
- return children.keySet();
- }
-
+ private GuiScreen lastScreen = null;
+ private final HashMap<MBGuiElement, Vector2f> childrenPositionOffset = new HashMap<>();
+
+ //Serialized
+ private final LinkedHashMap<MBGuiElement, MBAnchorPoint> children;
+
+ public MBGuiGroupFloating(int width, int height, LinkedHashMap<MBGuiElement, MBAnchorPoint> children) {
+ this.width = width;
+ this.height = height;
+ this.children = children;
+ recalculate();
+ }
+
+ public Map<MBGuiElement, MBAnchorPoint> getChildrenMap() {
+ return Collections.unmodifiableMap(children);
+ }
+
+ @Override
+ public Map<MBGuiElement, Vector2f> getChildrenPosition() {
+ GuiScreen currentScreen = Minecraft.getMinecraft().currentScreen;
+
+ if (currentScreen instanceof GuiContainer || currentScreen instanceof GuiItemRecipe
+ || currentScreen instanceof CustomAHGui ||
+ NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.isRenderOverAuctionView()) {
+
+ if (lastScreen != currentScreen) {
+ lastScreen = currentScreen;
+
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ int screenWidth = scaledResolution.getScaledWidth();
+ int screenHeight = scaledResolution.getScaledHeight();
+
+ int xSize = -1;
+ int ySize = -1;
+ int guiLeft = -1;
+ int guiTop = -1;
+
+ if (currentScreen instanceof GuiContainer) {
+ GuiContainer currentContainer = (GuiContainer) currentScreen;
+
+ try {
+ xSize = (int) Utils.getField(GuiContainer.class, currentContainer, "xSize", "field_146999_f");
+ ySize = (int) Utils.getField(GuiContainer.class, currentContainer, "ySize", "field_147000_g");
+ guiLeft = (int) Utils.getField(GuiContainer.class, currentContainer, "guiLeft", "field_147003_i");
+ guiTop = (int) Utils.getField(GuiContainer.class, currentContainer, "guiTop", "field_147009_r");
+ } catch (Exception ignored) {
+ }
+ } else if (currentScreen instanceof GuiItemRecipe) {
+ xSize = ((GuiItemRecipe) currentScreen).xSize;
+ ySize = ((GuiItemRecipe) currentScreen).ySize;
+ guiLeft = ((GuiItemRecipe) currentScreen).guiLeft;
+ guiTop = ((GuiItemRecipe) currentScreen).guiTop;
+ } else if (currentScreen instanceof CustomAHGui ||
+ NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.isRenderOverAuctionView()) {
+ xSize = NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.getXSize();
+ ySize = NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.getYSize();
+ guiLeft = NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.guiLeft;
+ guiTop = NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.guiTop;
+ }
+
+ if (xSize <= 0 && ySize <= 0 && guiLeft <= 0 && guiTop <= 0) {
+ lastScreen = null;
+ return Collections.unmodifiableMap(childrenPosition);
+ }
+
+ for (Map.Entry<MBGuiElement, MBAnchorPoint> entry : children.entrySet()) {
+ MBGuiElement child = entry.getKey();
+ MBAnchorPoint anchorPoint = entry.getValue();
+
+ Vector2f childPos;
+ if (childrenPosition.containsKey(child)) {
+ childPos = new Vector2f(childrenPosition.get(child));
+ } else {
+ childPos = new Vector2f();
+ }
+
+ if (anchorPoint.inventoryRelative) {
+ int defGuiLeft = (screenWidth - xSize) / 2;
+ int defGuiTop = (screenHeight - ySize) / 2;
+
+ childPos.x += guiLeft - defGuiLeft + (0.5f - anchorPoint.anchorPoint.x) * xSize;
+ childPos.y += guiTop - defGuiTop + (0.5f - anchorPoint.anchorPoint.y) * ySize;
+ }
+
+ childrenPositionOffset.put(child, childPos);
+ }
+ }
+ return Collections.unmodifiableMap(childrenPositionOffset);
+ } else {
+ return Collections.unmodifiableMap(childrenPosition);
+ }
+ }
+
+ @Override
+ public void recalculate() {
+ lastScreen = null;
+
+ for (MBGuiElement child : children.keySet()) {
+ child.recalculate();
+ }
+
+ for (Map.Entry<MBGuiElement, MBAnchorPoint> entry : children.entrySet()) {
+ MBGuiElement child = entry.getKey();
+ MBAnchorPoint anchorPoint = entry.getValue();
+ float x = anchorPoint.anchorPoint.x * width - anchorPoint.anchorPoint.x * child.getWidth() + anchorPoint.offset.x;
+ float y =
+ anchorPoint.anchorPoint.y * height - anchorPoint.anchorPoint.y * child.getHeight() + anchorPoint.offset.y;
+
+ if (anchorPoint.inventoryRelative) {
+ x = width * 0.5f + anchorPoint.offset.x;
+ y = height * 0.5f + anchorPoint.offset.y;
+ }
+
+ childrenPosition.put(child, new Vector2f(x, y));
+ }
+ }
+
+ @Override
+ public Collection<MBGuiElement> getChildren() {
+ return children.keySet();
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionBINWarning.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionBINWarning.java
index fc2eaf61..c76a22b4 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionBINWarning.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionBINWarning.java
@@ -24,220 +24,270 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class AuctionBINWarning extends GuiElement {
-
- private static final AuctionBINWarning INSTANCE = new AuctionBINWarning();
- public static AuctionBINWarning getInstance() {
- return INSTANCE;
- }
-
- private static final Pattern ITEM_PRICE_REGEX = Pattern.compile("\u00a7fItem price: \u00a76([0-9,]+) coins");
-
- private boolean showWarning = false;
- private List<String> sellingTooltip;
- private String sellingName;
- private int sellingPrice;
- private int lowestPrice;
-
- private boolean shouldPerformCheck() {
- if(!NotEnoughUpdates.INSTANCE.config.ahTweaks.enableBINWarning ||
- !NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
- sellingTooltip = null;
- showWarning = false;
- return false;
- }
-
- if(Minecraft.getMinecraft().currentScreen instanceof GuiChest &&
- SBInfo.getInstance().lastOpenContainerName.startsWith("Create BIN Auction")) {
- return true;
- } else {
- sellingTooltip = null;
- showWarning = false;
- return false;
- }
- }
-
- public boolean shouldShow() {
- return shouldPerformCheck() && showWarning;
- }
-
- public boolean onMouseClick(Slot slotIn, int slotId, int clickedButton, int clickType) {
- if(!shouldPerformCheck()) return false;
-
- if(slotId == 29) {
- GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
-
- sellingPrice = -1;
-
- ItemStack priceStack = chest.inventorySlots.getSlot(31).getStack();
- if(priceStack != null) {
- String displayName = priceStack.getDisplayName();
- Matcher priceMatcher = ITEM_PRICE_REGEX.matcher(displayName);
-
- if(priceMatcher.matches()) {
- try {
- sellingPrice = Integer.parseInt(priceMatcher.group(1).replace(",", ""));
- } catch(NumberFormatException ignored) {
- }
- }
- }
-
- ItemStack sellStack = chest.inventorySlots.getSlot(13).getStack();
- String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(sellStack);
-
- if(internalname == null) {
- return false;
- }
-
- JsonObject itemInfo = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(internalname);
- if(itemInfo == null || !itemInfo.has("displayname")) {
- sellingName = internalname;
- } else {
- sellingName = itemInfo.get("displayname").getAsString();
- }
-
- sellingTooltip = sellStack.getTooltip(Minecraft.getMinecraft().thePlayer,
- Minecraft.getMinecraft().gameSettings.advancedItemTooltips);
-
- lowestPrice = NotEnoughUpdates.INSTANCE.manager.auctionManager.getLowestBin(internalname);
- if(lowestPrice <= 0) {
- lowestPrice = (int)NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAvgBin(internalname);
- }
-
- //TODO: Add option for warning if lowest price does not exist
-
- float factor = 1 - NotEnoughUpdates.INSTANCE.config.ahTweaks.warningThreshold/100;
- if(factor < 0) factor = 0;
- if(factor > 1) factor = 1;
-
- if(sellingPrice > 0 && lowestPrice > 0 && sellingPrice < lowestPrice*factor) {
- showWarning = true;
- return true;
- } else {
- return false;
- }
- }
- return false;
- }
-
- public void overrideIsMouseOverSlot(Slot slot, int mouseX, int mouseY, CallbackInfoReturnable<Boolean> cir) {
- if(shouldShow()) {
- cir.setReturnValue(false);
- }
- }
-
- @Override
- public void render() {
- final ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- final int width = scaledResolution.getScaledWidth();
- final int height = scaledResolution.getScaledHeight();
-
- GlStateManager.disableLighting();
-
- GlStateManager.pushMatrix();
- GlStateManager.translate(0, 0, 500);
-
- Gui.drawRect(0, 0, width, height, 0x80000000);
-
- RenderUtils.drawFloatingRectDark(width/2-90, height/2-45, 180, 90);
-
- int neuLength = Minecraft.getMinecraft().fontRendererObj.getStringWidth("\u00a7lNEU");
- Minecraft.getMinecraft().fontRendererObj.drawString("\u00a7lNEU", width/2+90-neuLength-3, height/2-45+4, 0xff000000);
-
- TextRenderUtils.drawStringCenteredScaledMaxWidth("Are you SURE?", Minecraft.getMinecraft().fontRendererObj,
- width/2, height/2-45+10, false, 170, 0xffff4040);
-
- String lowestPriceStr;
- if(lowestPrice > 999) {
- lowestPriceStr = Utils.shortNumberFormat(lowestPrice, 0);
- } else {
- lowestPriceStr = ""+lowestPrice;
- }
-
- String sellingPriceStr;
- if(sellingPrice > 999) {
- sellingPriceStr = Utils.shortNumberFormat(sellingPrice, 0);
- } else {
- sellingPriceStr = ""+sellingPrice;
- }
-
- String sellLine = "\u00a77[ \u00a7r"+sellingName+"\u00a77 ]";
-
- TextRenderUtils.drawStringCenteredScaledMaxWidth(sellLine, Minecraft.getMinecraft().fontRendererObj,
- width/2, height/2-45+25, false, 170, 0xffffffff);
- TextRenderUtils.drawStringCenteredScaledMaxWidth("has a lowest BIN of \u00a76"+lowestPriceStr+"\u00a7r coins", Minecraft.getMinecraft().fontRendererObj,
- width/2, height/2-45+34, false, 170, 0xffa0a0a0);
-
- int buyPercentage = 100 - sellingPrice*100/lowestPrice;
- if(buyPercentage <= 0) buyPercentage = 1;
-
- TextRenderUtils.drawStringCenteredScaledMaxWidth("Continue selling it for", Minecraft.getMinecraft().fontRendererObj,
- width/2, height/2-45+50, false, 170, 0xffa0a0a0);
- TextRenderUtils.drawStringCenteredScaledMaxWidth("\u00a76"+sellingPriceStr+"\u00a7r coins? (\u00a7c-"+buyPercentage+"%\u00a7r)",
- Minecraft.getMinecraft().fontRendererObj,
- width/2, height/2-45+59, false, 170, 0xffa0a0a0);
-
- RenderUtils.drawFloatingRectDark(width/2-43, height/2+23, 40, 16, false);
- RenderUtils.drawFloatingRectDark(width/2+3, height/2+23, 40, 16, false);
-
- TextRenderUtils.drawStringCenteredScaledMaxWidth(EnumChatFormatting.GREEN+"[Y]es", Minecraft.getMinecraft().fontRendererObj,
- width/2-23, height/2+31, true, 36, 0xff00ff00);
- TextRenderUtils.drawStringCenteredScaledMaxWidth(EnumChatFormatting.RED+"[n]o", Minecraft.getMinecraft().fontRendererObj,
- width/2+23, height/2+31, true, 36, 0xffff0000);
-
- if(sellingTooltip != null) {
- int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
- int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
-
- int sellLineLength = Minecraft.getMinecraft().fontRendererObj.getStringWidth(sellLine);
-
- if(mouseX >= width/2-sellLineLength/2 && mouseX <= width/2+sellLineLength/2 &&
- mouseY >= height/2-45+20 && mouseY <= height/2-45+30) {
- Utils.drawHoveringText(sellingTooltip, mouseX, mouseY, width, height, -1, Minecraft.getMinecraft().fontRendererObj);
- }
- }
-
- GlStateManager.popMatrix();
- }
-
- @Override
- public boolean mouseInput(int mouseX, int mouseY) {
- final ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- final int width = scaledResolution.getScaledWidth();
- final int height = scaledResolution.getScaledHeight();
-
- if(Mouse.getEventButtonState()) {
- if(mouseY >= height/2+23 && mouseY <= height/2+23+16) {
- if(mouseX >= width/2-43 && mouseX <= width/2-3) {
- GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
- Minecraft.getMinecraft().playerController.windowClick(chest.inventorySlots.windowId,
- 29, 0, 0, Minecraft.getMinecraft().thePlayer);
- showWarning = false;
- } else {
- showWarning = false;
- }
- }
-
- if(mouseX < width/2-90 || mouseX > width/2+90 ||
- mouseY < height/2-45 || mouseY > height/2+45) {
- showWarning = false;
- }
- }
-
- return false;
- }
-
- @Override
- public boolean keyboardInput() {
- if(!Keyboard.getEventKeyState()) {
- if(Keyboard.getEventKey() == Keyboard.KEY_Y || Keyboard.getEventKey() == Keyboard.KEY_RETURN) {
- GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
- Minecraft.getMinecraft().playerController.windowClick(chest.inventorySlots.windowId,
- 29, 0, 0, Minecraft.getMinecraft().thePlayer);
- }
- showWarning = false;
- }
-
- return false;
- }
-
+ private static final AuctionBINWarning INSTANCE = new AuctionBINWarning();
+
+ public static AuctionBINWarning getInstance() {
+ return INSTANCE;
+ }
+
+ private static final Pattern ITEM_PRICE_REGEX = Pattern.compile("\u00a7fItem price: \u00a76([0-9,]+) coins");
+
+ private boolean showWarning = false;
+ private List<String> sellingTooltip;
+ private String sellingName;
+ private int sellingPrice;
+ private int lowestPrice;
+
+ private boolean shouldPerformCheck() {
+ if (!NotEnoughUpdates.INSTANCE.config.ahTweaks.enableBINWarning ||
+ !NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
+ sellingTooltip = null;
+ showWarning = false;
+ return false;
+ }
+
+ if (Minecraft.getMinecraft().currentScreen instanceof GuiChest &&
+ SBInfo.getInstance().lastOpenContainerName.startsWith("Create BIN Auction")) {
+ return true;
+ } else {
+ sellingTooltip = null;
+ showWarning = false;
+ return false;
+ }
+ }
+
+ public boolean shouldShow() {
+ return shouldPerformCheck() && showWarning;
+ }
+
+ public boolean onMouseClick(Slot slotIn, int slotId, int clickedButton, int clickType) {
+ if (!shouldPerformCheck()) return false;
+
+ if (slotId == 29) {
+ GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
+
+ sellingPrice = -1;
+
+ ItemStack priceStack = chest.inventorySlots.getSlot(31).getStack();
+ if (priceStack != null) {
+ String displayName = priceStack.getDisplayName();
+ Matcher priceMatcher = ITEM_PRICE_REGEX.matcher(displayName);
+
+ if (priceMatcher.matches()) {
+ try {
+ sellingPrice = Integer.parseInt(priceMatcher.group(1).replace(",", ""));
+ } catch (NumberFormatException ignored) {
+ }
+ }
+ }
+
+ ItemStack sellStack = chest.inventorySlots.getSlot(13).getStack();
+ String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(sellStack);
+
+ if (internalname == null) {
+ return false;
+ }
+
+ JsonObject itemInfo = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(internalname);
+ if (itemInfo == null || !itemInfo.has("displayname")) {
+ sellingName = internalname;
+ } else {
+ sellingName = itemInfo.get("displayname").getAsString();
+ }
+
+ sellingTooltip = sellStack.getTooltip(
+ Minecraft.getMinecraft().thePlayer,
+ Minecraft.getMinecraft().gameSettings.advancedItemTooltips
+ );
+
+ lowestPrice = NotEnoughUpdates.INSTANCE.manager.auctionManager.getLowestBin(internalname);
+ if (lowestPrice <= 0) {
+ lowestPrice = (int) NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAvgBin(internalname);
+ }
+
+ //TODO: Add option for warning if lowest price does not exist
+
+ float factor = 1 - NotEnoughUpdates.INSTANCE.config.ahTweaks.warningThreshold / 100;
+ if (factor < 0) factor = 0;
+ if (factor > 1) factor = 1;
+
+ if (sellingPrice > 0 && lowestPrice > 0 && sellingPrice < lowestPrice * factor) {
+ showWarning = true;
+ return true;
+ } else {
+ return false;
+ }
+ }
+ return false;
+ }
+
+ public void overrideIsMouseOverSlot(Slot slot, int mouseX, int mouseY, CallbackInfoReturnable<Boolean> cir) {
+ if (shouldShow()) {
+ cir.setReturnValue(false);
+ }
+ }
+
+ @Override
+ public void render() {
+ final ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ final int width = scaledResolution.getScaledWidth();
+ final int height = scaledResolution.getScaledHeight();
+
+ GlStateManager.disableLighting();
+
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(0, 0, 500);
+
+ Gui.drawRect(0, 0, width, height, 0x80000000);
+
+ RenderUtils.drawFloatingRectDark(width / 2 - 90, height / 2 - 45, 180, 90);
+
+ int neuLength = Minecraft.getMinecraft().fontRendererObj.getStringWidth("\u00a7lNEU");
+ Minecraft.getMinecraft().fontRendererObj.drawString(
+ "\u00a7lNEU",
+ width / 2 + 90 - neuLength - 3,
+ height / 2 - 45 + 4,
+ 0xff000000
+ );
+
+ TextRenderUtils.drawStringCenteredScaledMaxWidth("Are you SURE?", Minecraft.getMinecraft().fontRendererObj,
+ width / 2, height / 2 - 45 + 10, false, 170, 0xffff4040
+ );
+
+ String lowestPriceStr;
+ if (lowestPrice > 999) {
+ lowestPriceStr = Utils.shortNumberFormat(lowestPrice, 0);
+ } else {
+ lowestPriceStr = "" + lowestPrice;
+ }
+
+ String sellingPriceStr;
+ if (sellingPrice > 999) {
+ sellingPriceStr = Utils.shortNumberFormat(sellingPrice, 0);
+ } else {
+ sellingPriceStr = "" + sellingPrice;
+ }
+
+ String sellLine = "\u00a77[ \u00a7r" + sellingName + "\u00a77 ]";
+
+ TextRenderUtils.drawStringCenteredScaledMaxWidth(sellLine, Minecraft.getMinecraft().fontRendererObj,
+ width / 2, height / 2 - 45 + 25, false, 170, 0xffffffff
+ );
+ TextRenderUtils.drawStringCenteredScaledMaxWidth(
+ "has a lowest BIN of \u00a76" + lowestPriceStr + "\u00a7r coins",
+ Minecraft.getMinecraft().fontRendererObj,
+ width / 2,
+ height / 2 - 45 + 34,
+ false,
+ 170,
+ 0xffa0a0a0
+ );
+
+ int buyPercentage = 100 - sellingPrice * 100 / lowestPrice;
+ if (buyPercentage <= 0) buyPercentage = 1;
+
+ TextRenderUtils.drawStringCenteredScaledMaxWidth(
+ "Continue selling it for",
+ Minecraft.getMinecraft().fontRendererObj,
+ width / 2,
+ height / 2 - 45 + 50,
+ false,
+ 170,
+ 0xffa0a0a0
+ );
+ TextRenderUtils.drawStringCenteredScaledMaxWidth(
+ "\u00a76" + sellingPriceStr + "\u00a7r coins? (\u00a7c-" + buyPercentage + "%\u00a7r)",
+ Minecraft.getMinecraft().fontRendererObj,
+ width / 2,
+ height / 2 - 45 + 59,
+ false,
+ 170,
+ 0xffa0a0a0
+ );
+
+ RenderUtils.drawFloatingRectDark(width / 2 - 43, height / 2 + 23, 40, 16, false);
+ RenderUtils.drawFloatingRectDark(width / 2 + 3, height / 2 + 23, 40, 16, false);
+
+ TextRenderUtils.drawStringCenteredScaledMaxWidth(
+ EnumChatFormatting.GREEN + "[Y]es",
+ Minecraft.getMinecraft().fontRendererObj,
+ width / 2 - 23,
+ height / 2 + 31,
+ true,
+ 36,
+ 0xff00ff00
+ );
+ TextRenderUtils.drawStringCenteredScaledMaxWidth(
+ EnumChatFormatting.RED + "[n]o",
+ Minecraft.getMinecraft().fontRendererObj,
+ width / 2 + 23,
+ height / 2 + 31,
+ true,
+ 36,
+ 0xffff0000
+ );
+
+ if (sellingTooltip != null) {
+ int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
+ int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
+
+ int sellLineLength = Minecraft.getMinecraft().fontRendererObj.getStringWidth(sellLine);
+
+ if (mouseX >= width / 2 - sellLineLength / 2 && mouseX <= width / 2 + sellLineLength / 2 &&
+ mouseY >= height / 2 - 45 + 20 && mouseY <= height / 2 - 45 + 30) {
+ Utils.drawHoveringText(
+ sellingTooltip,
+ mouseX,
+ mouseY,
+ width,
+ height,
+ -1,
+ Minecraft.getMinecraft().fontRendererObj
+ );
+ }
+ }
+
+ GlStateManager.popMatrix();
+ }
+
+ @Override
+ public boolean mouseInput(int mouseX, int mouseY) {
+ final ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ final int width = scaledResolution.getScaledWidth();
+ final int height = scaledResolution.getScaledHeight();
+
+ if (Mouse.getEventButtonState()) {
+ if (mouseY >= height / 2 + 23 && mouseY <= height / 2 + 23 + 16) {
+ if (mouseX >= width / 2 - 43 && mouseX <= width / 2 - 3) {
+ GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
+ Minecraft.getMinecraft().playerController.windowClick(chest.inventorySlots.windowId,
+ 29, 0, 0, Minecraft.getMinecraft().thePlayer
+ );
+ }
+ showWarning = false;
+ }
+
+ if (mouseX < width / 2 - 90 || mouseX > width / 2 + 90 ||
+ mouseY < height / 2 - 45 || mouseY > height / 2 + 45) {
+ showWarning = false;
+ }
+ }
+
+ return false;
+ }
+
+ @Override
+ public boolean keyboardInput() {
+ if (!Keyboard.getEventKeyState()) {
+ if (Keyboard.getEventKey() == Keyboard.KEY_Y || Keyboard.getEventKey() == Keyboard.KEY_RETURN) {
+ GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
+ Minecraft.getMinecraft().playerController.windowClick(chest.inventorySlots.windowId,
+ 29, 0, 0, Minecraft.getMinecraft().thePlayer
+ );
+ }
+ showWarning = false;
+ }
+
+ return false;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionSortModeWarning.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionSortModeWarning.java
index 3002bce0..4b526185 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionSortModeWarning.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionSortModeWarning.java
@@ -8,68 +8,68 @@ import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiChest;
import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import java.util.List;
public class AuctionSortModeWarning {
-
- private static final AuctionSortModeWarning INSTANCE = new AuctionSortModeWarning();
- public static AuctionSortModeWarning getInstance() {
- return INSTANCE;
- }
-
- private boolean isAuctionBrowser() {
- return NotEnoughUpdates.INSTANCE.config.ahTweaks.enableSortWarning &&
- Minecraft.getMinecraft().currentScreen instanceof GuiChest &&
- (SBInfo.getInstance().lastOpenContainerName.startsWith("Auctions Browser") ||
- SBInfo.getInstance().lastOpenContainerName.startsWith("Auctions: \""));
- }
-
- public void onPostGuiRender() {
- if(isAuctionBrowser()) {
- GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
-
- ItemStack stack = chest.inventorySlots.getSlot(50).getStack();
-
- if(stack != null) {
- List<String> tooltip = stack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
-
- String selectedSort = null;
- for(String line : tooltip) {
- if(line.startsWith("\u00a75\u00a7o\u00a7b\u25B6 ")) {
- selectedSort = Utils.cleanColour(line.substring("\u00a75\u00a7o\u00a7b\u25B6 ".length()));
- }
- }
-
- if(selectedSort != null) {
- if(!selectedSort.trim().equals("Lowest Price")) {
- GlStateManager.disableLighting();
- GlStateManager.pushMatrix();
- GlStateManager.translate(0, 0, 500);
-
- String selectedColour = "\u00a7e";
-
- if(selectedSort.trim().equals("Highest Price")) {
- selectedColour = "\u00a7c";
- }
-
- String warningText = "\u00a7aSort: " + selectedColour + selectedSort;
- int warningLength = Minecraft.getMinecraft().fontRendererObj.getStringWidth(warningText);
-
- int centerX = chest.guiLeft+chest.xSize/2+9;
- int centerY = chest.guiTop+26;
-
- RenderUtils.drawFloatingRectDark(centerX - warningLength/2 - 4, centerY - 6,
- warningLength+8, 12, false);
- TextRenderUtils.drawStringCenteredScaledMaxWidth(warningText, Minecraft.getMinecraft().fontRendererObj,
- centerX, centerY, true, chest.width/2, 0xffffffff);
- GlStateManager.popMatrix();
- }
- }
- }
- }
- }
-
+ private static final AuctionSortModeWarning INSTANCE = new AuctionSortModeWarning();
+
+ public static AuctionSortModeWarning getInstance() {
+ return INSTANCE;
+ }
+
+ private boolean isAuctionBrowser() {
+ return NotEnoughUpdates.INSTANCE.config.ahTweaks.enableSortWarning &&
+ Minecraft.getMinecraft().currentScreen instanceof GuiChest &&
+ (SBInfo.getInstance().lastOpenContainerName.startsWith("Auctions Browser") ||
+ SBInfo.getInstance().lastOpenContainerName.startsWith("Auctions: \""));
+ }
+
+ public void onPostGuiRender() {
+ if (isAuctionBrowser()) {
+ GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
+
+ ItemStack stack = chest.inventorySlots.getSlot(50).getStack();
+
+ if (stack != null) {
+ List<String> tooltip = stack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
+
+ String selectedSort = null;
+ for (String line : tooltip) {
+ if (line.startsWith("\u00a75\u00a7o\u00a7b\u25B6 ")) {
+ selectedSort = Utils.cleanColour(line.substring("\u00a75\u00a7o\u00a7b\u25B6 ".length()));
+ }
+ }
+
+ if (selectedSort != null) {
+ if (!selectedSort.trim().equals("Lowest Price")) {
+ GlStateManager.disableLighting();
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(0, 0, 500);
+
+ String selectedColour = "\u00a7e";
+
+ if (selectedSort.trim().equals("Highest Price")) {
+ selectedColour = "\u00a7c";
+ }
+
+ String warningText = "\u00a7aSort: " + selectedColour + selectedSort;
+ int warningLength = Minecraft.getMinecraft().fontRendererObj.getStringWidth(warningText);
+
+ int centerX = chest.guiLeft + chest.xSize / 2 + 9;
+ int centerY = chest.guiTop + 26;
+
+ RenderUtils.drawFloatingRectDark(centerX - warningLength / 2 - 4, centerY - 6,
+ warningLength + 8, 12, false
+ );
+ TextRenderUtils.drawStringCenteredScaledMaxWidth(warningText, Minecraft.getMinecraft().fontRendererObj,
+ centerX, centerY, true, chest.width / 2, 0xffffffff
+ );
+ GlStateManager.popMatrix();
+ }
+ }
+ }
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/BetterContainers.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/BetterContainers.java
index bc92df0e..c1ce229c 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/BetterContainers.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/BetterContainers.java
@@ -3,11 +3,7 @@ package io.github.moulberry.notenoughupdates.miscfeatures;
import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.NEUEventListener;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
-import io.github.moulberry.notenoughupdates.util.SBInfo;
-import io.github.moulberry.notenoughupdates.util.TexLoc;
-import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.gui.inventory.GuiChest;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.texture.DynamicTexture;
@@ -22,466 +18,530 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
-import org.lwjgl.input.Keyboard;
-import org.lwjgl.opengl.GL11;
-import org.lwjgl.opengl.GL14;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
-import java.io.*;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
-import java.util.Random;
public class BetterContainers {
-
- private static final ResourceLocation TOGGLE_OFF = new ResourceLocation("notenoughupdates:dynamic_54/toggle_off.png");
- private static final ResourceLocation TOGGLE_ON = new ResourceLocation("notenoughupdates:dynamic_54/toggle_on.png");
-
- private static final ResourceLocation DYNAMIC_54_BASE = new ResourceLocation("notenoughupdates:dynamic_54/style1/dynamic_54.png");
- private static final ResourceLocation DYNAMIC_54_SLOT = new ResourceLocation("notenoughupdates:dynamic_54/style1/dynamic_54_slot_ctm.png");
- private static final ResourceLocation DYNAMIC_54_BUTTON = new ResourceLocation("notenoughupdates:dynamic_54/style1/dynamic_54_button_ctm.png");
- private static final ResourceLocation rl = new ResourceLocation("notenoughupdates:dynamic_chest_inventory.png");
- private static boolean loaded = false;
- private static DynamicTexture texture = null;
- private static int textColour = 4210752;
-
- private static int lastClickedSlot = 0;
- private static int clickedSlot = 0;
- private static long clickedSlotMillis = 0;
- public static long lastRenderMillis = 0;
-
- private static int lastInvHashcode = 0;
- private static int lastHashcodeCheck = 0;
-
- public static HashMap<Integer, ItemStack> itemCache = new HashMap<>();
-
- public static int profileViewerStackIndex = -1;
-
- public static void clickSlot(int slot) {
- clickedSlotMillis = System.currentTimeMillis();
- clickedSlot = slot;
- }
-
- public static int getClickedSlot() {
- if(System.currentTimeMillis() - clickedSlotMillis < 500) {
- return clickedSlot;
- }
- return -1;
- }
-
- public static void bindHook(TextureManager textureManager, ResourceLocation location) {
- long currentMillis = System.currentTimeMillis();
-
- if(isChestOpen() && NEUEventListener.inventoryLoaded) {
- int invHashcode = lastInvHashcode;
-
- if(currentMillis - lastHashcodeCheck > 50) {
- Container container = ((GuiChest)Minecraft.getMinecraft().currentScreen).inventorySlots;
- invHashcode = container.getInventory().hashCode();
- }
-
- if((texture != null && lastClickedSlot != getClickedSlot()) || !loaded || lastInvHashcode != invHashcode) {
- lastInvHashcode = invHashcode;
- lastClickedSlot = getClickedSlot();
- generateTex(location);
- }
- if(texture != null && loaded) {
- lastRenderMillis = currentMillis;
-
- GlStateManager.color(1, 1, 1, 1);
- textureManager.loadTexture(rl, texture);
- textureManager.bindTexture(rl);
- return;
- }
- } else if(currentMillis - lastRenderMillis < 200 && texture != null) {
- GlStateManager.color(1, 1, 1, 1);
- textureManager.loadTexture(rl, texture);
- textureManager.bindTexture(rl);
- return;
- }
- GlStateManager.enableBlend();
- textureManager.bindTexture(location);
- }
-
- public static boolean getUsingCache() {
- return false;
- }
-
- public static boolean isBlacklistedInventory() {
- if(!isChestOpen()) return false;
-
- GuiChest eventGui = (GuiChest) Minecraft.getMinecraft().currentScreen;
- ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
- String containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText();
- return containerName.toLowerCase().trim().startsWith("navigate the maze");
- }
-
- public static boolean isOverriding() {
- return isChestOpen() && ((loaded && texture != null) || System.currentTimeMillis() - lastRenderMillis < 200) && !isBlacklistedInventory();
- }
-
- public static boolean isBlankStack(int index, ItemStack stack) {
- if(index != -1 && index == profileViewerStackIndex) {
- return false;
- }
-
- return stack != null && stack.getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) &&
- stack.getItemDamage() == 15 &&
- stack.getDisplayName() != null && stack.getDisplayName().trim().isEmpty();
- }
-
- public static boolean shouldRenderStack(int index, ItemStack stack) {
- return !isBlankStack(index, stack) && !isToggleOff(stack) && !isToggleOn(stack);
- }
-
- public static boolean isButtonStack(int index, ItemStack stack) {
- if(index == profileViewerStackIndex) {
- return true;
- }
-
- return stack != null && stack.getItem() != Item.getItemFromBlock(Blocks.stained_glass_pane)
- && NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack) == null && !isToggleOn(stack) && !isToggleOff(stack);
- }
-
- public static int getTextColour() {
- return textColour;
- }
-
- public static boolean isToggleOn(ItemStack stack) {
- if(stack != null && stack.getTagCompound() != null && stack.getTagCompound().hasKey("display", 10) &&
- stack.getTagCompound().getCompoundTag("display").hasKey("Lore", 9)) {
- NBTTagList lore = stack.getTagCompound().getCompoundTag("display").getTagList("Lore", 8);
- if(lore.tagCount() == 1 && lore.getStringTagAt(0).equalsIgnoreCase(EnumChatFormatting.GRAY+"click to disable!")) {
- return true;
- }
- }
- return false;
- }
-
- public static boolean isToggleOff(ItemStack stack) {
- if(stack != null && stack.getTagCompound() != null && stack.getTagCompound().hasKey("display", 10) &&
- stack.getTagCompound().getCompoundTag("display").hasKey("Lore", 9)) {
- NBTTagList lore = stack.getTagCompound().getCompoundTag("display").getTagList("Lore", 8);
- if(lore.tagCount() == 1 && lore.getStringTagAt(0).equalsIgnoreCase(EnumChatFormatting.GRAY+"click to enable!")) {
- return true;
- }
- }
- return false;
- }
-
- private static void generateTex(ResourceLocation location) {
- if(!hasItem()) return;
-
- loaded = true;
- Container container = ((GuiChest)Minecraft.getMinecraft().currentScreen).inventorySlots;
-
- if(hasNullPane() && container instanceof ContainerChest) {
- int backgroundStyle = NotEnoughUpdates.INSTANCE.config.improvedSBMenu.backgroundStyle+1;
- backgroundStyle = Math.max(1, Math.min(10, backgroundStyle));
- try(BufferedReader reader = new BufferedReader(new InputStreamReader(Minecraft.getMinecraft().getResourceManager().getResource(
- new ResourceLocation("notenoughupdates:dynamic_54/style"+ backgroundStyle+"/dynamic_config.json")).getInputStream(), StandardCharsets.UTF_8))) {
- JsonObject json = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(reader, JsonObject.class);
- String textColourS = json.get("text-colour").getAsString();
- textColour = (int)Long.parseLong(textColourS, 16);
- } catch(Exception e) {
- textColour = 4210752;
- }
-
- try {
- BufferedImage bufferedImageOn = ImageIO.read(Minecraft.getMinecraft().getResourceManager().getResource(TOGGLE_ON).getInputStream());
- BufferedImage bufferedImageOff = ImageIO.read(Minecraft.getMinecraft().getResourceManager().getResource(TOGGLE_OFF).getInputStream());
-
- BufferedImage bufferedImageBase = ImageIO.read(Minecraft.getMinecraft().getResourceManager().getResource(DYNAMIC_54_BASE).getInputStream());
- try {
- bufferedImageBase = ImageIO.read(Minecraft.getMinecraft().getResourceManager().getResource(
- new ResourceLocation("notenoughupdates:dynamic_54/style"+ backgroundStyle+"/dynamic_54.png")).getInputStream());
- } catch(Exception e) {}
- BufferedImage bufferedImageSlot = ImageIO.read(Minecraft.getMinecraft().getResourceManager().getResource(DYNAMIC_54_SLOT).getInputStream());
- try {
- int buttonStyle = NotEnoughUpdates.INSTANCE.config.improvedSBMenu.buttonStyle+1;
- buttonStyle = Math.max(1, Math.min(10, buttonStyle));
- bufferedImageSlot = ImageIO.read(Minecraft.getMinecraft().getResourceManager().getResource(
- new ResourceLocation("notenoughupdates:dynamic_54/style"+buttonStyle+"/dynamic_54_slot_ctm.png")).getInputStream());
- } catch(Exception e) {}
- BufferedImage bufferedImageButton = ImageIO.read(Minecraft.getMinecraft().getResourceManager().getResource(DYNAMIC_54_BUTTON).getInputStream());
- try {
- int buttonStyle = NotEnoughUpdates.INSTANCE.config.improvedSBMenu.buttonStyle+1;
- buttonStyle = Math.max(1, Math.min(10, buttonStyle));
- bufferedImageButton = ImageIO.read(Minecraft.getMinecraft().getResourceManager().getResource(
- new ResourceLocation("notenoughupdates:dynamic_54/style"+buttonStyle+"/dynamic_54_button_ctm.png")).getInputStream());
- } catch(Exception e) {}
-
- int horzTexMult = bufferedImageBase.getWidth()/256;
- int vertTexMult = bufferedImageBase.getWidth()/256;
- BufferedImage bufferedImageNew = new BufferedImage(
- bufferedImageBase.getColorModel(),
- bufferedImageBase.copyData(null),
- bufferedImageBase.isAlphaPremultiplied(),
- null);
- IInventory lower = ((ContainerChest) container).getLowerChestInventory();
- int size = lower.getSizeInventory();
- boolean[][] slots = new boolean[9][size/9];
- boolean[][] buttons = new boolean[9][size/9];
-
- boolean ultrasequencer = lower.getDisplayName().getUnformattedText().startsWith("Ultrasequencer") &&
- !lower.getDisplayName().getUnformattedText().contains("Stakes");
- boolean superpairs = lower.getDisplayName().getUnformattedText().startsWith("Superpairs") &&
- !lower.getDisplayName().getUnformattedText().contains("Stakes");
- for (int index = 0; index < size; index++) {
- ItemStack stack = getStackCached(lower, index);
- buttons[index%9][index/9] = isButtonStack(index, stack);
-
- if(ultrasequencer && stack.getItem() == Items.dye) {
- buttons[index%9][index/9] = false;
- }
-
- if(superpairs && index > 9 && index < size-9) {
- buttons[index%9][index/9] = false;
- }
-
- if(buttons[index%9][index/9] && lastClickedSlot == index) {
- //buttons[index%9][index/9] = false;
- //slots[index%9][index/9] = true;
- } else {
- slots[index%9][index/9] = !isBlankStack(index, stack) && !buttons[index%9][index/9];
- }
- }
- for (int index = 0; index < size; index++) {
- ItemStack stack = getStackCached(lower, index);
- int xi = index%9;
- int yi = index/9;
- if(slots[xi][yi] || buttons[xi][yi]) {
- int x = 7*horzTexMult + xi*18*horzTexMult;
- int y = 17*vertTexMult + yi*18*vertTexMult;
-
- boolean on = isToggleOn(stack);
- boolean off = isToggleOff(stack);
-
- if(on || off) {
- for(int x2=0; x2<18; x2++) {
- for(int y2=0; y2<18; y2++) {
- BufferedImage toggle = on ? bufferedImageOn : bufferedImageOff;
- Color c = new Color(toggle.getRGB(x2, y2), true);
- if(c.getAlpha() < 10) {
- continue;
- }
- bufferedImageNew.setRGB(x+x2, y+y2, c.getRGB());
- }
- }
- continue;
- }
-
- if(buttons[xi][yi]) {
- boolean up = yi > 0 && buttons[xi][yi-1];
- boolean right = xi < buttons.length-1 && buttons[xi+1][yi];
- boolean down = yi < buttons[xi].length-1 && buttons[xi][yi+1];
- boolean left = xi > 0 && buttons[xi-1][yi];
-
- boolean upleft = yi > 0 && xi > 0 && buttons[xi-1][yi-1];
- boolean upright = yi > 0 && xi < buttons.length-1 && buttons[xi+1][yi-1];
- boolean downright = xi < buttons.length-1 && yi < buttons[xi+1].length-1 && buttons[xi+1][yi+1];
- boolean downleft = xi > 0 && yi < buttons[xi-1].length-1 && buttons[xi-1][yi+1];
-
- int ctmIndex = getCTMIndex(up, right, down, left, upleft, upright, downright, downleft);
- int[] rgbs = bufferedImageButton.getRGB((ctmIndex%12)*19*horzTexMult, (ctmIndex/12)*19*vertTexMult,
- 18*horzTexMult, 18*vertTexMult, null, 0, 18*vertTexMult);
- bufferedImageNew.setRGB(x, y, 18*horzTexMult, 18*vertTexMult, rgbs, 0, 18*vertTexMult);
-
- } else {
- boolean up = yi > 0 && slots[xi][yi-1];
- boolean right = xi < slots.length-1 && slots[xi+1][yi];
- boolean down = yi < slots[xi].length-1 && slots[xi][yi+1];
- boolean left = xi > 0 && slots[xi-1][yi];
-
- boolean upleft = yi > 0 && xi > 0 && slots[xi-1][yi-1];
- boolean upright = yi > 0 && xi < slots.length-1 && slots[xi+1][yi-1];
- boolean downright = xi < slots.length-1 && yi < slots[xi+1].length-1 && slots[xi+1][yi+1];
- boolean downleft = xi > 0 && yi < slots[xi-1].length-1 && slots[xi-1][yi+1];
-
- int ctmIndex = getCTMIndex(up, right, down, left, upleft, upright, downright, downleft);
- int[] rgbs = bufferedImageSlot.getRGB((ctmIndex%12)*19*horzTexMult, (ctmIndex/12)*19*vertTexMult,
- 18*horzTexMult, 18*vertTexMult, null, 0, 18*vertTexMult);
- bufferedImageNew.setRGB(x, y, 18*horzTexMult, 18*vertTexMult, rgbs, 0, 18*vertTexMult);
- }
- }
- }
- if(texture != null) {
- bufferedImageNew.getRGB(0, 0, bufferedImageNew.getWidth(), bufferedImageNew.getHeight(),
- texture.getTextureData(), 0, bufferedImageNew.getWidth());
- texture.updateDynamicTexture();
- } else {
- texture = new DynamicTexture(bufferedImageNew);
- }
- return;
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
- texture = null;
- }
-
- public static void reset() {
- loaded = false;
- clickedSlot = -1;
- clickedSlotMillis = 0;
- }
-
- private static boolean isChestOpen() {
- return Minecraft.getMinecraft().currentScreen instanceof GuiChest &&
- NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() &&
- NotEnoughUpdates.INSTANCE.config.improvedSBMenu.enableSbMenus;
- }
-
- private static boolean hasItem() {
- if(!isChestOpen()) return false;
- Container container = ((GuiChest)Minecraft.getMinecraft().currentScreen).inventorySlots;
- if(container instanceof ContainerChest) {
- IInventory lower = ((ContainerChest)container).getLowerChestInventory();
- int size = lower.getSizeInventory();
- for(int index=0; index<size; index++) {
- if(getStackCached(lower, index) != null) return true;
- }
- }
- return false;
- }
-
- private static ItemStack getStackCached(IInventory lower, int index) {
- if(getUsingCache()) {
- return itemCache.get(index);
- } else {
- return lower.getStackInSlot(index);
- }
- }
-
- private static boolean hasNullPane() {
- if(!isChestOpen()) return false;
- Container container = ((GuiChest)Minecraft.getMinecraft().currentScreen).inventorySlots;
- if(container instanceof ContainerChest) {
- IInventory lower = ((ContainerChest)container).getLowerChestInventory();
- int size = lower.getSizeInventory();
- for(int index=0; index<size; index++) {
- if(isBlankStack(index, getStackCached(lower, index))) return true;
- }
- }
- return false;
- }
-
- public static int getCTMIndex(boolean up, boolean right, boolean down, boolean left, boolean upleft, boolean upright, boolean downright, boolean downleft) {
- if(up && right && down && left) {
- if(upleft && upright && downright && downleft) {
- return 26;
- } else if(upleft && upright && downright && !downleft) {
- return 33;
- } else if(upleft && upright && !downright && downleft) {
- return 32;
- } else if(upleft && upright && !downright && !downleft) {
- return 11;
- } else if(upleft && !upright && downright && downleft) {
- return 44;
- } else if(upleft && !upright && downright && !downleft) {
- return 35;
- } else if(upleft && !upright && !downright && downleft) {
- return 10;
- } else if(upleft && !upright && !downright && !downleft) {
- return 20;
- } else if(!upleft && upright && downright && downleft) {
- return 45;
- } else if(!upleft && upright && downright && !downleft) {
- return 23;
- } else if(!upleft && upright && !downright && downleft) {
- return 34;
- } else if(!upleft && upright && !downright && !downleft) {
- return 8;
- } else if(!upleft && !upright && downright && downleft) {
- return 22;
- } else if(!upleft && !upright && downright && !downleft) {
- return 9;
- } else if(!upleft && !upright && !downright && downleft) {
- return 21;
- } else {
- return 46;
- }
- } else if(up && right && down && !left) {
- if(!upright && !downright) {
- return 6;
- } else if(!upright) {
- return 28;
- } else if(!downright) {
- return 30;
- } else {
- return 25;
- }
- } else if(up && right && !down && left) {
- if(!upleft && !upright) {
- return 18;
- } else if(!upleft) {
- return 40;
- } else if(!upright) {
- return 42;
- } else {
- return 38;
- }
- } else if(up && right && !down && !left) {
- if(!upright) {
- return 16;
- } else {
- return 37;
- }
- } else if(up && !right && down && left) {
- if(!upleft && !downleft) {
- return 19;
- } else if(!upleft) {
- return 43;
- } else if(!downleft) {
- return 41;
- } else {
- return 27;
- }
- } else if(up && !right && down && !left) {
- return 24;
- } else if(up && !right && !down && left) {
- if(!upleft) {
- return 17;
- } else {
- return 39;
- }
- } else if(up && !right && !down && !left) {
- return 36;
- } else if(!up && right && down && left) {
- if(!downleft && !downright) {
- return 7;
- } else if(!downleft) {
- return 31;
- } else if(!downright) {
- return 29;
- } else {
- return 14;
- }
- } else if(!up && right && down && !left) {
- if(!downright) {
- return 4;
- } else {
- return 13;
- }
- } else if(!up && right && !down && left) {
- return 2;
- } else if(!up && right && !down && !left) {
- return 1;
- } else if(!up && !right && down && left) {
- if(!downleft) {
- return 5;
- } else {
- return 15;
- }
- } else if(!up && !right && down && !left) {
- return 12;
- } else if(!up && !right && !down && left) {
- return 3;
- } else {
- return 0;
- }
- }
-
+ private static final ResourceLocation TOGGLE_OFF = new ResourceLocation("notenoughupdates:dynamic_54/toggle_off.png");
+ private static final ResourceLocation TOGGLE_ON = new ResourceLocation("notenoughupdates:dynamic_54/toggle_on.png");
+
+ private static final ResourceLocation DYNAMIC_54_BASE = new ResourceLocation(
+ "notenoughupdates:dynamic_54/style1/dynamic_54.png");
+ private static final ResourceLocation DYNAMIC_54_SLOT = new ResourceLocation(
+ "notenoughupdates:dynamic_54/style1/dynamic_54_slot_ctm.png");
+ private static final ResourceLocation DYNAMIC_54_BUTTON = new ResourceLocation(
+ "notenoughupdates:dynamic_54/style1/dynamic_54_button_ctm.png");
+ private static final ResourceLocation rl = new ResourceLocation("notenoughupdates:dynamic_chest_inventory.png");
+ private static boolean loaded = false;
+ private static DynamicTexture texture = null;
+ private static int textColour = 4210752;
+
+ private static int lastClickedSlot = 0;
+ private static int clickedSlot = 0;
+ private static long clickedSlotMillis = 0;
+ public static long lastRenderMillis = 0;
+
+ private static int lastInvHashcode = 0;
+ private static final int lastHashcodeCheck = 0;
+
+ public static HashMap<Integer, ItemStack> itemCache = new HashMap<>();
+
+ public static int profileViewerStackIndex = -1;
+
+ public static void clickSlot(int slot) {
+ clickedSlotMillis = System.currentTimeMillis();
+ clickedSlot = slot;
+ }
+
+ public static int getClickedSlot() {
+ if (System.currentTimeMillis() - clickedSlotMillis < 500) {
+ return clickedSlot;
+ }
+ return -1;
+ }
+
+ public static void bindHook(TextureManager textureManager, ResourceLocation location) {
+ long currentMillis = System.currentTimeMillis();
+
+ if (isChestOpen() && NEUEventListener.inventoryLoaded) {
+ int invHashcode = lastInvHashcode;
+
+ if (currentMillis - lastHashcodeCheck > 50) {
+ Container container = ((GuiChest) Minecraft.getMinecraft().currentScreen).inventorySlots;
+ invHashcode = container.getInventory().hashCode();
+ }
+
+ if ((texture != null && lastClickedSlot != getClickedSlot()) || !loaded || lastInvHashcode != invHashcode) {
+ lastInvHashcode = invHashcode;
+ lastClickedSlot = getClickedSlot();
+ generateTex(location);
+ }
+ if (texture != null && loaded) {
+ lastRenderMillis = currentMillis;
+
+ GlStateManager.color(1, 1, 1, 1);
+ textureManager.loadTexture(rl, texture);
+ textureManager.bindTexture(rl);
+ return;
+ }
+ } else if (currentMillis - lastRenderMillis < 200 && texture != null) {
+ GlStateManager.color(1, 1, 1, 1);
+ textureManager.loadTexture(rl, texture);
+ textureManager.bindTexture(rl);
+ return;
+ }
+ GlStateManager.enableBlend();
+ textureManager.bindTexture(location);
+ }
+
+ public static boolean getUsingCache() {
+ return false;
+ }
+
+ public static boolean isBlacklistedInventory() {
+ if (!isChestOpen()) return false;
+
+ GuiChest eventGui = (GuiChest) Minecraft.getMinecraft().currentScreen;
+ ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
+ String containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText();
+ return containerName.toLowerCase().trim().startsWith("navigate the maze");
+ }
+
+ public static boolean isOverriding() {
+ return isChestOpen() && ((loaded && texture != null) || System.currentTimeMillis() - lastRenderMillis < 200) &&
+ !isBlacklistedInventory();
+ }
+
+ public static boolean isBlankStack(int index, ItemStack stack) {
+ if (index != -1 && index == profileViewerStackIndex) {
+ return false;
+ }
+
+ return stack != null && stack.getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) &&
+ stack.getItemDamage() == 15 &&
+ stack.getDisplayName() != null && stack.getDisplayName().trim().isEmpty();
+ }
+
+ public static boolean shouldRenderStack(int index, ItemStack stack) {
+ return !isBlankStack(index, stack) && !isToggleOff(stack) && !isToggleOn(stack);
+ }
+
+ public static boolean isButtonStack(int index, ItemStack stack) {
+ if (index == profileViewerStackIndex) {
+ return true;
+ }
+
+ return stack != null && stack.getItem() != Item.getItemFromBlock(Blocks.stained_glass_pane)
+ && NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack) == null && !isToggleOn(stack) && !isToggleOff(
+ stack);
+ }
+
+ public static int getTextColour() {
+ return textColour;
+ }
+
+ public static boolean isToggleOn(ItemStack stack) {
+ if (stack != null && stack.getTagCompound() != null && stack.getTagCompound().hasKey("display", 10) &&
+ stack.getTagCompound().getCompoundTag("display").hasKey("Lore", 9)) {
+ NBTTagList lore = stack.getTagCompound().getCompoundTag("display").getTagList("Lore", 8);
+ return lore.tagCount() == 1 && lore.getStringTagAt(0).equalsIgnoreCase(
+ EnumChatFormatting.GRAY + "click to disable!");
+ }
+ return false;
+ }
+
+ public static boolean isToggleOff(ItemStack stack) {
+ if (stack != null && stack.getTagCompound() != null && stack.getTagCompound().hasKey("display", 10) &&
+ stack.getTagCompound().getCompoundTag("display").hasKey("Lore", 9)) {
+ NBTTagList lore = stack.getTagCompound().getCompoundTag("display").getTagList("Lore", 8);
+ return lore.tagCount() == 1 && lore.getStringTagAt(0).equalsIgnoreCase(
+ EnumChatFormatting.GRAY + "click to enable!");
+ }
+ return false;
+ }
+
+ private static void generateTex(ResourceLocation location) {
+ if (!hasItem()) return;
+
+ loaded = true;
+ Container container = ((GuiChest) Minecraft.getMinecraft().currentScreen).inventorySlots;
+
+ if (hasNullPane() && container instanceof ContainerChest) {
+ int backgroundStyle = NotEnoughUpdates.INSTANCE.config.improvedSBMenu.backgroundStyle + 1;
+ backgroundStyle = Math.max(1, Math.min(10, backgroundStyle));
+ try (
+ BufferedReader reader = new BufferedReader(new InputStreamReader(Minecraft
+ .getMinecraft()
+ .getResourceManager()
+ .getResource(
+ new ResourceLocation("notenoughupdates:dynamic_54/style" + backgroundStyle + "/dynamic_config.json"))
+ .getInputStream(), StandardCharsets.UTF_8))
+ ) {
+ JsonObject json = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(reader, JsonObject.class);
+ String textColourS = json.get("text-colour").getAsString();
+ textColour = (int) Long.parseLong(textColourS, 16);
+ } catch (Exception e) {
+ textColour = 4210752;
+ }
+
+ try {
+ BufferedImage bufferedImageOn = ImageIO.read(Minecraft
+ .getMinecraft()
+ .getResourceManager()
+ .getResource(TOGGLE_ON)
+ .getInputStream());
+ BufferedImage bufferedImageOff = ImageIO.read(Minecraft
+ .getMinecraft()
+ .getResourceManager()
+ .getResource(TOGGLE_OFF)
+ .getInputStream());
+
+ BufferedImage bufferedImageBase = ImageIO.read(Minecraft
+ .getMinecraft()
+ .getResourceManager()
+ .getResource(DYNAMIC_54_BASE)
+ .getInputStream());
+ try {
+ bufferedImageBase = ImageIO.read(Minecraft
+ .getMinecraft()
+ .getResourceManager()
+ .getResource(
+ new ResourceLocation("notenoughupdates:dynamic_54/style" + backgroundStyle + "/dynamic_54.png"))
+ .getInputStream());
+ } catch (Exception ignored) {
+ }
+ BufferedImage bufferedImageSlot = ImageIO.read(Minecraft
+ .getMinecraft()
+ .getResourceManager()
+ .getResource(DYNAMIC_54_SLOT)
+ .getInputStream());
+ try {
+ int buttonStyle = NotEnoughUpdates.INSTANCE.config.improvedSBMenu.buttonStyle + 1;
+ buttonStyle = Math.max(1, Math.min(10, buttonStyle));
+ bufferedImageSlot = ImageIO.read(Minecraft
+ .getMinecraft()
+ .getResourceManager()
+ .getResource(
+ new ResourceLocation("notenoughupdates:dynamic_54/style" + buttonStyle + "/dynamic_54_slot_ctm.png"))
+ .getInputStream());
+ } catch (Exception ignored) {
+ }
+ BufferedImage bufferedImageButton = ImageIO.read(Minecraft
+ .getMinecraft()
+ .getResourceManager()
+ .getResource(DYNAMIC_54_BUTTON)
+ .getInputStream());
+ try {
+ int buttonStyle = NotEnoughUpdates.INSTANCE.config.improvedSBMenu.buttonStyle + 1;
+ buttonStyle = Math.max(1, Math.min(10, buttonStyle));
+ bufferedImageButton = ImageIO.read(Minecraft
+ .getMinecraft()
+ .getResourceManager()
+ .getResource(
+ new ResourceLocation("notenoughupdates:dynamic_54/style" + buttonStyle + "/dynamic_54_button_ctm.png"))
+ .getInputStream());
+ } catch (Exception ignored) {
+ }
+
+ int horzTexMult = bufferedImageBase.getWidth() / 256;
+ int vertTexMult = bufferedImageBase.getWidth() / 256;
+ BufferedImage bufferedImageNew = new BufferedImage(
+ bufferedImageBase.getColorModel(),
+ bufferedImageBase.copyData(null),
+ bufferedImageBase.isAlphaPremultiplied(),
+ null
+ );
+ IInventory lower = ((ContainerChest) container).getLowerChestInventory();
+ int size = lower.getSizeInventory();
+ boolean[][] slots = new boolean[9][size / 9];
+ boolean[][] buttons = new boolean[9][size / 9];
+
+ boolean ultrasequencer = lower.getDisplayName().getUnformattedText().startsWith("Ultrasequencer") &&
+ !lower.getDisplayName().getUnformattedText().contains("Stakes");
+ boolean superpairs = lower.getDisplayName().getUnformattedText().startsWith("Superpairs") &&
+ !lower.getDisplayName().getUnformattedText().contains("Stakes");
+ for (int index = 0; index < size; index++) {
+ ItemStack stack = getStackCached(lower, index);
+ buttons[index % 9][index / 9] = isButtonStack(index, stack);
+
+ if (ultrasequencer && stack.getItem() == Items.dye) {
+ buttons[index % 9][index / 9] = false;
+ }
+
+ if (superpairs && index > 9 && index < size - 9) {
+ buttons[index % 9][index / 9] = false;
+ }
+
+ if (buttons[index % 9][index / 9] && lastClickedSlot == index) {
+ //buttons[index%9][index/9] = false;
+ //slots[index%9][index/9] = true;
+ } else {
+ slots[index % 9][index / 9] = !isBlankStack(index, stack) && !buttons[index % 9][index / 9];
+ }
+ }
+ for (int index = 0; index < size; index++) {
+ ItemStack stack = getStackCached(lower, index);
+ int xi = index % 9;
+ int yi = index / 9;
+ if (slots[xi][yi] || buttons[xi][yi]) {
+ int x = 7 * horzTexMult + xi * 18 * horzTexMult;
+ int y = 17 * vertTexMult + yi * 18 * vertTexMult;
+
+ boolean on = isToggleOn(stack);
+ boolean off = isToggleOff(stack);
+
+ if (on || off) {
+ for (int x2 = 0; x2 < 18; x2++) {
+ for (int y2 = 0; y2 < 18; y2++) {
+ BufferedImage toggle = on ? bufferedImageOn : bufferedImageOff;
+ Color c = new Color(toggle.getRGB(x2, y2), true);
+ if (c.getAlpha() < 10) {
+ continue;
+ }
+ bufferedImageNew.setRGB(x + x2, y + y2, c.getRGB());
+ }
+ }
+ continue;
+ }
+
+ if (buttons[xi][yi]) {
+ boolean up = yi > 0 && buttons[xi][yi - 1];
+ boolean right = xi < buttons.length - 1 && buttons[xi + 1][yi];
+ boolean down = yi < buttons[xi].length - 1 && buttons[xi][yi + 1];
+ boolean left = xi > 0 && buttons[xi - 1][yi];
+
+ boolean upleft = yi > 0 && xi > 0 && buttons[xi - 1][yi - 1];
+ boolean upright = yi > 0 && xi < buttons.length - 1 && buttons[xi + 1][yi - 1];
+ boolean downright = xi < buttons.length - 1 && yi < buttons[xi + 1].length - 1 && buttons[xi + 1][yi + 1];
+ boolean downleft = xi > 0 && yi < buttons[xi - 1].length - 1 && buttons[xi - 1][yi + 1];
+
+ int ctmIndex = getCTMIndex(up, right, down, left, upleft, upright, downright, downleft);
+ int[] rgbs = bufferedImageButton.getRGB(
+ (ctmIndex % 12) * 19 * horzTexMult,
+ (ctmIndex / 12) * 19 * vertTexMult,
+ 18 * horzTexMult,
+ 18 * vertTexMult,
+ null,
+ 0,
+ 18 * vertTexMult
+ );
+ bufferedImageNew.setRGB(x, y, 18 * horzTexMult, 18 * vertTexMult, rgbs, 0, 18 * vertTexMult);
+
+ } else {
+ boolean up = yi > 0 && slots[xi][yi - 1];
+ boolean right = xi < slots.length - 1 && slots[xi + 1][yi];
+ boolean down = yi < slots[xi].length - 1 && slots[xi][yi + 1];
+ boolean left = xi > 0 && slots[xi - 1][yi];
+
+ boolean upleft = yi > 0 && xi > 0 && slots[xi - 1][yi - 1];
+ boolean upright = yi > 0 && xi < slots.length - 1 && slots[xi + 1][yi - 1];
+ boolean downright = xi < slots.length - 1 && yi < slots[xi + 1].length - 1 && slots[xi + 1][yi + 1];
+ boolean downleft = xi > 0 && yi < slots[xi - 1].length - 1 && slots[xi - 1][yi + 1];
+
+ int ctmIndex = getCTMIndex(up, right, down, left, upleft, upright, downright, downleft);
+ int[] rgbs = bufferedImageSlot.getRGB(
+ (ctmIndex % 12) * 19 * horzTexMult,
+ (ctmIndex / 12) * 19 * vertTexMult,
+ 18 * horzTexMult,
+ 18 * vertTexMult,
+ null,
+ 0,
+ 18 * vertTexMult
+ );
+ bufferedImageNew.setRGB(x, y, 18 * horzTexMult, 18 * vertTexMult, rgbs, 0, 18 * vertTexMult);
+ }
+ }
+ }
+ if (texture != null) {
+ bufferedImageNew.getRGB(0, 0, bufferedImageNew.getWidth(), bufferedImageNew.getHeight(),
+ texture.getTextureData(), 0, bufferedImageNew.getWidth()
+ );
+ texture.updateDynamicTexture();
+ } else {
+ texture = new DynamicTexture(bufferedImageNew);
+ }
+ return;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ texture = null;
+ }
+
+ public static void reset() {
+ loaded = false;
+ clickedSlot = -1;
+ clickedSlotMillis = 0;
+ }
+
+ private static boolean isChestOpen() {
+ return Minecraft.getMinecraft().currentScreen instanceof GuiChest &&
+ NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() &&
+ NotEnoughUpdates.INSTANCE.config.improvedSBMenu.enableSbMenus;
+ }
+
+ private static boolean hasItem() {
+ if (!isChestOpen()) return false;
+ Container container = ((GuiChest) Minecraft.getMinecraft().currentScreen).inventorySlots;
+ if (container instanceof ContainerChest) {
+ IInventory lower = ((ContainerChest) container).getLowerChestInventory();
+ int size = lower.getSizeInventory();
+ for (int index = 0; index < size; index++) {
+ if (getStackCached(lower, index) != null) return true;
+ }
+ }
+ return false;
+ }
+
+ private static ItemStack getStackCached(IInventory lower, int index) {
+ if (getUsingCache()) {
+ return itemCache.get(index);
+ } else {
+ return lower.getStackInSlot(index);
+ }
+ }
+
+ private static boolean hasNullPane() {
+ if (!isChestOpen()) return false;
+ Container container = ((GuiChest) Minecraft.getMinecraft().currentScreen).inventorySlots;
+ if (container instanceof ContainerChest) {
+ IInventory lower = ((ContainerChest) container).getLowerChestInventory();
+ int size = lower.getSizeInventory();
+ for (int index = 0; index < size; index++) {
+ if (isBlankStack(index, getStackCached(lower, index))) return true;
+ }
+ }
+ return false;
+ }
+
+ public static int getCTMIndex(
+ boolean up,
+ boolean right,
+ boolean down,
+ boolean left,
+ boolean upleft,
+ boolean upright,
+ boolean downright,
+ boolean downleft
+ ) {
+ if (up && right && down && left) {
+ if (upleft && upright && downright && downleft) {
+ return 26;
+ } else if (upleft && upright && downright && !downleft) {
+ return 33;
+ } else if (upleft && upright && !downright && downleft) {
+ return 32;
+ } else if (upleft && upright && !downright && !downleft) {
+ return 11;
+ } else if (upleft && !upright && downright && downleft) {
+ return 44;
+ } else if (upleft && !upright && downright && !downleft) {
+ return 35;
+ } else if (upleft && !upright && !downright && downleft) {
+ return 10;
+ } else if (upleft && !upright && !downright && !downleft) {
+ return 20;
+ } else if (!upleft && upright && downright && downleft) {
+ return 45;
+ } else if (!upleft && upright && downright && !downleft) {
+ return 23;
+ } else if (!upleft && upright && !downright && downleft) {
+ return 34;
+ } else if (!upleft && upright && !downright && !downleft) {
+ return 8;
+ } else if (!upleft && !upright && downright && downleft) {
+ return 22;
+ } else if (!upleft && !upright && downright && !downleft) {
+ return 9;
+ } else if (!upleft && !upright && !downright && downleft) {
+ return 21;
+ } else {
+ return 46;
+ }
+ } else if (up && right && down && !left) {
+ if (!upright && !downright) {
+ return 6;
+ } else if (!upright) {
+ return 28;
+ } else if (!downright) {
+ return 30;
+ } else {
+ return 25;
+ }
+ } else if (up && right && !down && left) {
+ if (!upleft && !upright) {
+ return 18;
+ } else if (!upleft) {
+ return 40;
+ } else if (!upright) {
+ return 42;
+ } else {
+ return 38;
+ }
+ } else if (up && right && !down && !left) {
+ if (!upright) {
+ return 16;
+ } else {
+ return 37;
+ }
+ } else if (up && !right && down && left) {
+ if (!upleft && !downleft) {
+ return 19;
+ } else if (!upleft) {
+ return 43;
+ } else if (!downleft) {
+ return 41;
+ } else {
+ return 27;
+ }
+ } else if (up && !right && down && !left) {
+ return 24;
+ } else if (up && !right && !down && left) {
+ if (!upleft) {
+ return 17;
+ } else {
+ return 39;
+ }
+ } else if (up && !right && !down && !left) {
+ return 36;
+ } else if (!up && right && down && left) {
+ if (!downleft && !downright) {
+ return 7;
+ } else if (!downleft) {
+ return 31;
+ } else if (!downright) {
+ return 29;
+ } else {
+ return 14;
+ }
+ } else if (!up && right && down && !left) {
+ if (!downright) {
+ return 4;
+ } else {
+ return 13;
+ }
+ } else if (!up && right && !down && left) {
+ return 2;
+ } else if (!up && right && !down && !left) {
+ return 1;
+ } else if (!up && !right && down && left) {
+ if (!downleft) {
+ return 5;
+ } else {
+ return 15;
+ }
+ } else if (!up && !right && down && !left) {
+ return 12;
+ } else if (!up && !right && !down && left) {
+ return 3;
+ } else {
+ return 0;
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CollectionLogManager.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CollectionLogManager.java
index 00809d87..c550ce53 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CollectionLogManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CollectionLogManager.java
@@ -10,37 +10,35 @@ import net.minecraft.entity.item.EntityArmorStand;
import java.util.regex.Matcher;
public class CollectionLogManager {
-
- private static CollectionLogManager INSTANCE = new CollectionLogManager();
-
- public static CollectionLogManager getInstance() {
- return INSTANCE;
- }
-
- public void onEntityMetadataUpdated(int entityId) {
- System.out.println("entity created:"+entityId);
- WorldClient world = Minecraft.getMinecraft().theWorld;
- if(world != null) {
- Entity entity = world.getEntityByID(entityId);
-
- if(entity instanceof EntityArmorStand && entity.hasCustomName()) {
- String customName = entity.getName();
- System.out.println("got name:"+customName);
- for(CollectionConstant.DropEntry entry : Constants.COLLECTIONLOG.dropdata) {
- System.out.println("iter entry");
- if(entry.type.equalsIgnoreCase("itemdrop")) {
- Matcher matcher = entry.regex.matcher(customName);
- if(matcher.matches()) {
- System.out.println("Match found!");
- System.out.println("Count: "+matcher.group("count"));
- System.out.println("Name: "+matcher.group("itemname"));
- } else {
- System.out.println("Doesn't match: " + customName);
- }
- }
- }
- }
- }
- }
-
+ private static final CollectionLogManager INSTANCE = new CollectionLogManager();
+
+ public static CollectionLogManager getInstance() {
+ return INSTANCE;
+ }
+
+ public void onEntityMetadataUpdated(int entityId) {
+ System.out.println("entity created:" + entityId);
+ WorldClient world = Minecraft.getMinecraft().theWorld;
+ if (world != null) {
+ Entity entity = world.getEntityByID(entityId);
+
+ if (entity instanceof EntityArmorStand && entity.hasCustomName()) {
+ String customName = entity.getName();
+ System.out.println("got name:" + customName);
+ for (CollectionConstant.DropEntry entry : Constants.COLLECTIONLOG.dropdata) {
+ System.out.println("iter entry");
+ if (entry.type.equalsIgnoreCase("itemdrop")) {
+ Matcher matcher = entry.regex.matcher(customName);
+ if (matcher.matches()) {
+ System.out.println("Match found!");
+ System.out.println("Count: " + matcher.group("count"));
+ System.out.println("Name: " + matcher.group("itemname"));
+ } else {
+ System.out.println("Doesn't match: " + customName);
+ }
+ }
+ }
+ }
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java
index b2cd7cb2..4586d190 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java
@@ -10,147 +10,159 @@ import java.util.ArrayList;
import java.util.List;
public class CrystalMetalDetectorSolver {
- private static final Minecraft mc = Minecraft.getMinecraft();
- private static BlockPos prevPlayerPos;
- private static double prevDistToTreasure = 0;
- private static List<BlockPos> possibleBlocks = new ArrayList<>();
- private static final List<BlockPos> locations = new ArrayList<>();
-
- private static Boolean chestRecentlyFound = false;
- private static long chestLastFoundMillis = 0;
-
- public static void process(IChatComponent message) {
- // Delay to keep old chest location from being treated as the new chest location
- if (chestRecentlyFound) {
- long currentTimeMillis = System.currentTimeMillis();
- if (chestLastFoundMillis == 0) {
- chestLastFoundMillis = currentTimeMillis;
- return;
- } else if (currentTimeMillis - chestLastFoundMillis < 1000) {
- return;
- }
-
- chestLastFoundMillis = 0;
- chestRecentlyFound = false;
- }
-
- if (SBInfo.getInstance().getLocation() != null && SBInfo.getInstance().getLocation().equals("crystal_hollows")
- && message.getUnformattedText().contains("TREASURE: ")) {
- double distToTreasure = Double.parseDouble(message.getUnformattedText().split("TREASURE: ")[1].split("m")[0].replaceAll("(?!\\.)\\D", ""));
- if (NotEnoughUpdates.INSTANCE.config.mining.metalDetectorEnabled && prevDistToTreasure == distToTreasure &&
- prevPlayerPos.getX() == mc.thePlayer.getPosition().getX() &&
- prevPlayerPos.getY() == mc.thePlayer.getPosition().getY() &&
- prevPlayerPos.getZ() == mc.thePlayer.getPosition().getZ() && !locations.contains(mc.thePlayer.getPosition())) {
- if (possibleBlocks.size() == 0) {
- locations.add(mc.thePlayer.getPosition());
- for (int zOffset = (int) Math.floor(-distToTreasure); zOffset <= Math.ceil(distToTreasure); zOffset++) {
- for (int y = 65; y <= 75; y++) {
- double calculatedDist = 0;
- int xOffset = 0;
- while (calculatedDist < distToTreasure) {
- BlockPos pos = new BlockPos(Math.floor(mc.thePlayer.posX) + xOffset,
- y, Math.floor(mc.thePlayer.posZ) + zOffset);
- calculatedDist = getPlayerPos().distanceTo(new Vec3(pos).addVector(0D, 1D, 0D));
- if (round(calculatedDist, 1) == distToTreasure && !possibleBlocks.contains(pos) && treasureAllowed(pos) && mc.theWorld.
- getBlockState(pos.add(0, 1, 0)).getBlock().getRegistryName().equals("minecraft:air")) {
- possibleBlocks.add(pos);
- }
- xOffset++;
- }
- xOffset = 0;
- calculatedDist = 0;
- while (calculatedDist < distToTreasure) {
- BlockPos pos = new BlockPos(Math.floor(mc.thePlayer.posX) - xOffset,
- y, Math.floor(mc.thePlayer.posZ) + zOffset);
- calculatedDist = getPlayerPos().distanceTo(new Vec3(pos).addVector(0D, 1D, 0D));
- if (round(calculatedDist, 1) == distToTreasure && !possibleBlocks.contains(pos) && treasureAllowed(pos) && mc.theWorld.
- getBlockState(pos.add(0, 1, 0)).getBlock().getRegistryName().equals("minecraft:air")) {
- possibleBlocks.add(pos);
- }
- xOffset++;
- }
- }
- }
- sendMessage();
- } else if (possibleBlocks.size() != 1) {
- locations.add(mc.thePlayer.getPosition());
- List<BlockPos> temp = new ArrayList<>();
- for (BlockPos pos : possibleBlocks) {
- if (round(getPlayerPos().distanceTo(new Vec3(pos).addVector(0D, 1D, 0D)), 1) == distToTreasure) {
- temp.add(pos);
- }
- }
- possibleBlocks = temp;
- sendMessage();
- } else {
- BlockPos pos = possibleBlocks.get(0);
- if (Math.abs(distToTreasure - (getPlayerPos().distanceTo(new Vec3(pos)))) > 5) {
- mc.thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "[NEU] Previous solution is invalid."));
- reset(false);
- }
- }
-
- }
-
- prevPlayerPos = mc.thePlayer.getPosition();
- prevDistToTreasure = distToTreasure;
- }
- }
-
- public static void reset(Boolean chestFound) {
- chestRecentlyFound = chestFound;
- possibleBlocks.clear();
- locations.clear();
- }
-
- public static void render(float partialTicks) {
- int beaconRGB = 0xffdf00;
-
- if (SBInfo.getInstance().getLocation() != null && SBInfo.getInstance().getLocation().equals("crystal_hollows") &&
- SBInfo.getInstance().location.equals("Mines of Divan")) {
-
- if (possibleBlocks.size() == 1) {
- BlockPos block = possibleBlocks.get(0);
-
- RenderUtils.renderBeaconBeam(block.add(0,1,0), beaconRGB, 1.0f, partialTicks);
- RenderUtils.renderWayPoint("Treasure", possibleBlocks.get(0).add(0, 2.5, 0), partialTicks);
- } else if (possibleBlocks.size() > 1 && NotEnoughUpdates.INSTANCE.config.mining.metalDetectorShowPossible) {
- for (BlockPos block : possibleBlocks) {
- RenderUtils.renderBeaconBeam(block.add(0,1,0), beaconRGB, 1.0f, partialTicks);
- RenderUtils.renderWayPoint("Possible Treasure Location", block.add(0, 2.5, 0), partialTicks);
- }
- }
- }
- }
-
- private static double round(double value, int precision) {
- int scale = (int) Math.pow(10, precision);
- return (double) Math.round(value * scale) / scale;
- }
-
- private static void sendMessage() {
- if (possibleBlocks.size() > 1) {
- mc.thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "[NEU] Need another position to find solution. Possible blocks: "
- + possibleBlocks.size()));
- } else if (possibleBlocks.size() == 0) {
- mc.thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "[NEU] Failed to find solution."));
- reset(false);
- } else {
- mc.thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "[NEU] Found solution."));
- }
- }
-
- private static Vec3 getPlayerPos() {
- return new Vec3(mc.thePlayer.posX, mc.thePlayer.posY + (mc.thePlayer.getEyeHeight() - mc.thePlayer.getDefaultEyeHeight()), mc.thePlayer.posZ);
- }
-
- private static boolean treasureAllowed(BlockPos pos) {
- return mc.theWorld.getBlockState(pos).getBlock().getRegistryName().equals("minecraft:gold_block") ||
- mc.theWorld.getBlockState(pos).getBlock().getRegistryName().equals("minecraft:prismarine") ||
- mc.theWorld.getBlockState(pos).getBlock().getRegistryName().equals("minecraft:chest") ||
- mc.theWorld.getBlockState(pos).getBlock().getRegistryName().equals("minecraft:stained_glass") ||
- mc.theWorld.getBlockState(pos).getBlock().getRegistryName().equals("minecraft:stained_glass_pane") ||
- mc.theWorld.getBlockState(pos).getBlock().getRegistryName().equals("minecraft:wool") ||
- mc.theWorld.getBlockState(pos).getBlock().getRegistryName().equals("minecraft:stained_hardened_clay");
- }
+ private static final Minecraft mc = Minecraft.getMinecraft();
+ private static BlockPos prevPlayerPos;
+ private static double prevDistToTreasure = 0;
+ private static List<BlockPos> possibleBlocks = new ArrayList<>();
+ private static final List<BlockPos> locations = new ArrayList<>();
+
+ private static Boolean chestRecentlyFound = false;
+ private static long chestLastFoundMillis = 0;
+
+ public static void process(IChatComponent message) {
+ // Delay to keep old chest location from being treated as the new chest location
+ if (chestRecentlyFound) {
+ long currentTimeMillis = System.currentTimeMillis();
+ if (chestLastFoundMillis == 0) {
+ chestLastFoundMillis = currentTimeMillis;
+ return;
+ } else if (currentTimeMillis - chestLastFoundMillis < 1000) {
+ return;
+ }
+
+ chestLastFoundMillis = 0;
+ chestRecentlyFound = false;
+ }
+
+ if (SBInfo.getInstance().getLocation() != null && SBInfo.getInstance().getLocation().equals("crystal_hollows")
+ && message.getUnformattedText().contains("TREASURE: ")) {
+ double distToTreasure = Double.parseDouble(message
+ .getUnformattedText()
+ .split("TREASURE: ")[1].split("m")[0].replaceAll("(?!\\.)\\D", ""));
+ if (NotEnoughUpdates.INSTANCE.config.mining.metalDetectorEnabled && prevDistToTreasure == distToTreasure &&
+ prevPlayerPos.getX() == mc.thePlayer.getPosition().getX() &&
+ prevPlayerPos.getY() == mc.thePlayer.getPosition().getY() &&
+ prevPlayerPos.getZ() == mc.thePlayer.getPosition().getZ() && !locations.contains(mc.thePlayer.getPosition())) {
+ if (possibleBlocks.size() == 0) {
+ locations.add(mc.thePlayer.getPosition());
+ for (int zOffset = (int) Math.floor(-distToTreasure); zOffset <= Math.ceil(distToTreasure); zOffset++) {
+ for (int y = 65; y <= 75; y++) {
+ double calculatedDist = 0;
+ int xOffset = 0;
+ while (calculatedDist < distToTreasure) {
+ BlockPos pos = new BlockPos(Math.floor(mc.thePlayer.posX) + xOffset,
+ y, Math.floor(mc.thePlayer.posZ) + zOffset
+ );
+ calculatedDist = getPlayerPos().distanceTo(new Vec3(pos).addVector(0D, 1D, 0D));
+ if (round(calculatedDist, 1) == distToTreasure && !possibleBlocks.contains(pos) &&
+ treasureAllowed(pos) && mc.theWorld.
+ getBlockState(pos.add(0, 1, 0)).getBlock().getRegistryName().equals("minecraft:air")) {
+ possibleBlocks.add(pos);
+ }
+ xOffset++;
+ }
+ xOffset = 0;
+ calculatedDist = 0;
+ while (calculatedDist < distToTreasure) {
+ BlockPos pos = new BlockPos(Math.floor(mc.thePlayer.posX) - xOffset,
+ y, Math.floor(mc.thePlayer.posZ) + zOffset
+ );
+ calculatedDist = getPlayerPos().distanceTo(new Vec3(pos).addVector(0D, 1D, 0D));
+ if (round(calculatedDist, 1) == distToTreasure && !possibleBlocks.contains(pos) &&
+ treasureAllowed(pos) && mc.theWorld.
+ getBlockState(pos.add(0, 1, 0)).getBlock().getRegistryName().equals("minecraft:air")) {
+ possibleBlocks.add(pos);
+ }
+ xOffset++;
+ }
+ }
+ }
+ sendMessage();
+ } else if (possibleBlocks.size() != 1) {
+ locations.add(mc.thePlayer.getPosition());
+ List<BlockPos> temp = new ArrayList<>();
+ for (BlockPos pos : possibleBlocks) {
+ if (round(getPlayerPos().distanceTo(new Vec3(pos).addVector(0D, 1D, 0D)), 1) == distToTreasure) {
+ temp.add(pos);
+ }
+ }
+ possibleBlocks = temp;
+ sendMessage();
+ } else {
+ BlockPos pos = possibleBlocks.get(0);
+ if (Math.abs(distToTreasure - (getPlayerPos().distanceTo(new Vec3(pos)))) > 5) {
+ mc.thePlayer.addChatMessage(new ChatComponentText(
+ EnumChatFormatting.RED + "[NEU] Previous solution is invalid."));
+ reset(false);
+ }
+ }
+
+ }
+
+ prevPlayerPos = mc.thePlayer.getPosition();
+ prevDistToTreasure = distToTreasure;
+ }
+ }
+
+ public static void reset(Boolean chestFound) {
+ chestRecentlyFound = chestFound;
+ possibleBlocks.clear();
+ locations.clear();
+ }
+
+ public static void render(float partialTicks) {
+ int beaconRGB = 0x1fd8f1;
+
+ if (SBInfo.getInstance().getLocation() != null && SBInfo.getInstance().getLocation().equals("crystal_hollows") &&
+ SBInfo.getInstance().location.equals("Mines of Divan")) {
+
+ if (possibleBlocks.size() == 1) {
+ BlockPos block = possibleBlocks.get(0);
+
+ RenderUtils.renderBeaconBeam(block.add(0, 1, 0), beaconRGB, 1.0f, partialTicks);
+ RenderUtils.renderWayPoint("Treasure", possibleBlocks.get(0).add(0, 2.5, 0), partialTicks);
+ } else if (possibleBlocks.size() > 1 && NotEnoughUpdates.INSTANCE.config.mining.metalDetectorShowPossible) {
+ for (BlockPos block : possibleBlocks) {
+ RenderUtils.renderBeaconBeam(block.add(0, 1, 0), beaconRGB, 1.0f, partialTicks);
+ RenderUtils.renderWayPoint("Possible Treasure Location", block.add(0, 2.5, 0), partialTicks);
+ }
+ }
+ }
+ }
+
+ private static double round(double value, int precision) {
+ int scale = (int) Math.pow(10, precision);
+ return (double) Math.round(value * scale) / scale;
+ }
+
+ private static void sendMessage() {
+ if (possibleBlocks.size() > 1) {
+ mc.thePlayer.addChatMessage(new ChatComponentText(
+ EnumChatFormatting.YELLOW + "[NEU] Need another position to find solution. Possible blocks: "
+ + possibleBlocks.size()));
+ } else if (possibleBlocks.size() == 0) {
+ mc.thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "[NEU] Failed to find solution."));
+ reset(false);
+ } else {
+ mc.thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "[NEU] Found solution."));
+ }
+ }
+
+ private static Vec3 getPlayerPos() {
+ return new Vec3(
+ mc.thePlayer.posX,
+ mc.thePlayer.posY + (mc.thePlayer.getEyeHeight() - mc.thePlayer.getDefaultEyeHeight()),
+ mc.thePlayer.posZ
+ );
+ }
+
+ private static boolean treasureAllowed(BlockPos pos) {
+ return mc.theWorld.getBlockState(pos).getBlock().getRegistryName().equals("minecraft:gold_block") ||
+ mc.theWorld.getBlockState(pos).getBlock().getRegistryName().equals("minecraft:prismarine") ||
+ mc.theWorld.getBlockState(pos).getBlock().getRegistryName().equals("minecraft:chest") ||
+ mc.theWorld.getBlockState(pos).getBlock().getRegistryName().equals("minecraft:stained_glass") ||
+ mc.theWorld.getBlockState(pos).getBlock().getRegistryName().equals("minecraft:stained_glass_pane") ||
+ mc.theWorld.getBlockState(pos).getBlock().getRegistryName().equals("minecraft:wool") ||
+ mc.theWorld.getBlockState(pos).getBlock().getRegistryName().equals("minecraft:stained_hardened_clay");
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalOverlay.java
index f3a33aa9..2b095c42 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalOverlay.java
@@ -6,7 +6,6 @@ import io.github.moulberry.notenoughupdates.util.SpecialColour;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.client.renderer.vertex.VertexFormatElement;
@@ -25,347 +24,445 @@ import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.nio.ByteBuffer;
-import java.util.*;
+import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
+import java.util.Set;
public class CrystalOverlay {
-
- private enum CrystalType {
- FARMING_MINION(8, 0xDAA520),
- MINING_MINION(40, 0x6e5a49),
- FORAGING_MINION(12, 0x01a552),
- DESERT(16, 0xfff178),
- FISHING(15, 0x1972a6),
- WART(5, 0x821530),
- WHEAT(6, 0xff9d00);
-
- CrystalType(int radius, int rgb) {
- this.radius = radius;
- this.rgb = rgb;
- }
-
- public Set<BlockPos> getCircleOffsets() {
- if(circleOffsets != null) return circleOffsets;
- circleOffsets = new HashSet<>();
-
- for(int x=-radius; x<=radius; x++) {
- for(int y=-radius; y<=radius; y++) {
- for(int z=-radius; z<=radius; z++) {
- float distSq = (x-0.5f)*(x-0.5f) + y*y + (z-0.5f)*(z-0.5f);
- if(distSq > (radius-1)*(radius-1) && distSq < radius*radius) {
- circleOffsets.add(new BlockPos(x, y, z));
- }
- }
- }
- }
-
- return circleOffsets;
- }
-
- public ReverseWorldRenderer getOverlayVBO() {
- if(overlayVBO != null) return overlayVBO;
-
- EntityPlayerSP p = Minecraft.getMinecraft().thePlayer;
- if(p == null) return null;
-
- if(!crystals.containsKey(this)) {
- return null;
- }
-
- //per vertex = 6
- //per size = 4
- //per block = 8
- //total per block = 196
-
- ReverseWorldRenderer worldRenderer = new ReverseWorldRenderer(196*getCircleOffsets().size());
- worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
-
- String col = SpecialColour.special(0, 180, rgb);
- for(BlockPos offset : getCircleOffsets()) {
- BlockPos overlayPos = new BlockPos(offset.getX(), offset.getY(), offset.getZ());
-
- AxisAlignedBB bb = new AxisAlignedBB(
- overlayPos.getX(),
- overlayPos.getY(),
- overlayPos.getZ(),
- overlayPos.getX()+1,
- overlayPos.getY()+1,
- overlayPos.getZ()+1
- ).expand(0.001f*(this.ordinal()+1), 0.001f*(this.ordinal()+1), 0.001f*(this.ordinal()+1));
- uploadFilledBoundingBox(bb, 1f, col, worldRenderer);
- }
-
- overlayVBO = worldRenderer;
- return overlayVBO;
- }
-
- ReverseWorldRenderer overlayVBO = null;
- Set<BlockPos> circleOffsets = null;
- int updates = 0;
- int rgb;
- int radius;
- }
-
- private static double posLastUpdateX;
- private static double posLastUpdateY;
- private static double posLastUpdateZ;
-
- private static HashMap<String, CrystalType> skullId = new HashMap<>();
- static {
- skullId.put("d9c3168a-8654-3dd8-b297-4d3b7e55b95a", CrystalType.FARMING_MINION);
- skullId.put("949d100c-aa74-3b09-a642-af5529f808aa", CrystalType.MINING_MINION);
- skullId.put("bd79a474-cf07-3f8c-b5a4-98657c33520a", CrystalType.FORAGING_MINION);
- skullId.put("2e474ee3-5361-3218-84db-880eb1cface1", CrystalType.FISHING);
- }
-
- public static long displayMillis = 0;
-
- public static long lastMiningUpdate = 0;
-
- public static HashMap<CrystalType, BlockPos> crystals = new HashMap<>();
-
- public static void tick() {
- if(!NotEnoughUpdates.INSTANCE.config.itemOverlays.enableCrystalOverlay) return;
- if(Minecraft.getMinecraft().theWorld == null) return;
-
- EntityPlayerSP p = Minecraft.getMinecraft().thePlayer;
- if(p == null) return;
-
- long currentTime = System.currentTimeMillis();
-
- if(NotEnoughUpdates.INSTANCE.config.itemOverlays.alwaysShowCrystal) {
- displayMillis = currentTime;
- } else {
- if(currentTime - displayMillis > 10*1000) {
- crystals.clear();
- displayMillis = -1;
- }
-
- ItemStack held = p.getHeldItem();
- String internal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held);
- if(internal != null) {
- if(internal.endsWith("_CRYSTAL") && !internal.equals("POWER_CRYSTAL")) {
- displayMillis = currentTime;
- }
- }
-
- if(displayMillis < 0) {
- return;
- }
- }
-
-
- Set<CrystalType> foundTypes = new HashSet<>();
- for(Entity entity : Minecraft.getMinecraft().theWorld.loadedEntityList) {
- if(entity instanceof EntityArmorStand) {
- EntityArmorStand armorStand = (EntityArmorStand) entity;
-
- if(armorStand.isChild() && armorStand.getEquipmentInSlot(4) != null) {
- ItemStack helmet = armorStand.getEquipmentInSlot(4);
-
- if(helmet.getItem() == Items.skull && helmet.hasTagCompound()) {
- NBTTagCompound tag = helmet.getTagCompound();
- if(tag.hasKey("SkullOwner", 10)) {
- NBTTagCompound skullOwner = tag.getCompoundTag("SkullOwner");
- if(skullOwner.hasKey("Id", 8)) {
- String id = skullOwner.getString("Id");
-
- if(skullId.containsKey(id)) {
- CrystalType type = skullId.get(id);
- foundTypes.add(type);
- BlockPos pos = new BlockPos(armorStand.posX, armorStand.posY+0.5f, armorStand.posZ);
-
- if(crystals.containsKey(type)) {
- BlockPos old = crystals.get(type);
- if(old.equals(pos)) {
- type.updates = 0;
- } else {
- if(++type.updates >= 3) {
- type.updates = 0;
- crystals.put(type, pos);
- }
- }
- } else {
- crystals.put(type, pos);
- }
- }
- }
- }
- }
- }
- }
- }
- crystals.keySet().retainAll(foundTypes);
- }
-
- @SubscribeEvent
- public void onTick(TickEvent.ClientTickEvent event) {
- if(!NotEnoughUpdates.INSTANCE.config.itemOverlays.enableCrystalOverlay) return;
-
- if(displayMillis < 0) {
- return;
- }
-
- EntityPlayerSP p = Minecraft.getMinecraft().thePlayer;
- if(p == null) return;
-
- if(event.phase == TickEvent.Phase.START) {
- double dX = p.posX - posLastUpdateX;
- double dY = p.posY - posLastUpdateY;
- double dZ = p.posZ - posLastUpdateZ;
-
- if(dX*dX + dY*dY + dZ*dZ < 1) {
- return;
- }
-
- posLastUpdateX = p.posX;
- posLastUpdateY = p.posY;
- posLastUpdateZ = p.posZ;
-
- for(CrystalType type : crystals.keySet()) {
- if(type == CrystalType.MINING_MINION) {
- long currentTime = System.currentTimeMillis();
- if(currentTime - lastMiningUpdate < 1000) {
- continue;
- }
- lastMiningUpdate = currentTime;
- }
-
- ReverseWorldRenderer worldRenderer = type.getOverlayVBO();
- if(worldRenderer != null) {
- BlockPos crystal = crystals.get(type);
-
- worldRenderer.setTranslation(0, 0,0 );
- worldRenderer.sortVertexData(
- (float)p.posX-crystal.getX(),
- (float)p.posY-crystal.getY(),
- (float)p.posZ-crystal.getZ());
+ private enum CrystalType {
+ FARMING_MINION(8, 0xDAA520),
+ MINING_MINION(40, 0x6e5a49),
+ FORAGING_MINION(12, 0x01a552),
+ DESERT(16, 0xfff178),
+ FISHING(15, 0x1972a6),
+ WART(5, 0x821530),
+ WHEAT(6, 0xff9d00);
+
+ CrystalType(int radius, int rgb) {
+ this.radius = radius;
+ this.rgb = rgb;
+ }
+
+ public Set<BlockPos> getCircleOffsets() {
+ if (circleOffsets != null) return circleOffsets;
+ circleOffsets = new HashSet<>();
+
+ for (int x = -radius; x <= radius; x++) {
+ for (int y = -radius; y <= radius; y++) {
+ for (int z = -radius; z <= radius; z++) {
+ float distSq = (x - 0.5f) * (x - 0.5f) + y * y + (z - 0.5f) * (z - 0.5f);
+ if (distSq > (radius - 1) * (radius - 1) && distSq < radius * radius) {
+ circleOffsets.add(new BlockPos(x, y, z));
+ }
+ }
+ }
+ }
+
+ return circleOffsets;
+ }
+
+ public ReverseWorldRenderer getOverlayVBO() {
+ if (overlayVBO != null) return overlayVBO;
+
+ EntityPlayerSP p = Minecraft.getMinecraft().thePlayer;
+ if (p == null) return null;
+
+ if (!crystals.containsKey(this)) {
+ return null;
+ }
+
+ //per vertex = 6
+ //per size = 4
+ //per block = 8
+ //total per block = 196
+
+ ReverseWorldRenderer worldRenderer = new ReverseWorldRenderer(196 * getCircleOffsets().size());
+ worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
+
+ String col = SpecialColour.special(0, 180, rgb);
+ for (BlockPos offset : getCircleOffsets()) {
+ BlockPos overlayPos = new BlockPos(offset.getX(), offset.getY(), offset.getZ());
+
+ AxisAlignedBB bb = new AxisAlignedBB(
+ overlayPos.getX(),
+ overlayPos.getY(),
+ overlayPos.getZ(),
+ overlayPos.getX() + 1,
+ overlayPos.getY() + 1,
+ overlayPos.getZ() + 1
+ ).expand(0.001f * (this.ordinal() + 1), 0.001f * (this.ordinal() + 1), 0.001f * (this.ordinal() + 1));
+ uploadFilledBoundingBox(bb, 1f, col, worldRenderer);
+ }
+
+ overlayVBO = worldRenderer;
+ return overlayVBO;
+ }
+
+ ReverseWorldRenderer overlayVBO = null;
+ Set<BlockPos> circleOffsets = null;
+ int updates = 0;
+ int rgb;
+ int radius;
+ }
+
+ private static double posLastUpdateX;
+ private static double posLastUpdateY;
+ private static double posLastUpdateZ;
+
+ private static final HashMap<String, CrystalType> skullId = new HashMap<String, CrystalType>() {{
+ put("d9c3168a-8654-3dd8-b297-4d3b7e55b95a", CrystalType.FARMING_MINION);
+ put("949d100c-aa74-3b09-a642-af5529f808aa", CrystalType.MINING_MINION);
+ put("bd79a474-cf07-3f8c-b5a4-98657c33520a", CrystalType.FORAGING_MINION);
+ put("2e474ee3-5361-3218-84db-880eb1cface1", CrystalType.FISHING);
+ }};
+
+ public static long displayMillis = 0;
+
+ public static long lastMiningUpdate = 0;
+
+ public static HashMap<CrystalType, BlockPos> crystals = new HashMap<>();
+
+ public static void tick() {
+ if (!NotEnoughUpdates.INSTANCE.config.itemOverlays.enableCrystalOverlay) return;
+ if (Minecraft.getMinecraft().theWorld == null) return;
+
+ EntityPlayerSP p = Minecraft.getMinecraft().thePlayer;
+ if (p == null) return;
+
+ long currentTime = System.currentTimeMillis();
+
+ if (NotEnoughUpdates.INSTANCE.config.itemOverlays.alwaysShowCrystal) {
+ displayMillis = currentTime;
+ } else {
+ if (currentTime - displayMillis > 10 * 1000) {
+ crystals.clear();
+ displayMillis = -1;
+ }
+
+ ItemStack held = p.getHeldItem();
+ String internal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held);
+ if (internal != null) {
+ if (internal.endsWith("_CRYSTAL") && !internal.equals("POWER_CRYSTAL")) {
+ displayMillis = currentTime;
+ }
+ }
+
+ if (displayMillis < 0) {
+ return;
+ }
+ }
+
+ Set<CrystalType> foundTypes = new HashSet<>();
+ for (Entity entity : Minecraft.getMinecraft().theWorld.loadedEntityList) {
+ if (entity instanceof EntityArmorStand) {
+ EntityArmorStand armorStand = (EntityArmorStand) entity;
+
+ if (armorStand.isChild() && armorStand.getEquipmentInSlot(4) != null) {
+ ItemStack helmet = armorStand.getEquipmentInSlot(4);
+
+ if (helmet.getItem() == Items.skull && helmet.hasTagCompound()) {
+ NBTTagCompound tag = helmet.getTagCompound();
+ if (tag.hasKey("SkullOwner", 10)) {
+ NBTTagCompound skullOwner = tag.getCompoundTag("SkullOwner");
+ if (skullOwner.hasKey("Id", 8)) {
+ String id = skullOwner.getString("Id");
+
+ if (skullId.containsKey(id)) {
+ CrystalType type = skullId.get(id);
+ foundTypes.add(type);
+ BlockPos pos = new BlockPos(armorStand.posX, armorStand.posY + 0.5f, armorStand.posZ);
+
+ if (crystals.containsKey(type)) {
+ BlockPos old = crystals.get(type);
+ if (old.equals(pos)) {
+ type.updates = 0;
+ } else {
+ if (++type.updates >= 3) {
+ type.updates = 0;
+ crystals.put(type, pos);
+ }
+ }
+ } else {
+ crystals.put(type, pos);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ crystals.keySet().retainAll(foundTypes);
+ }
+
+ @SubscribeEvent
+ public void onTick(TickEvent.ClientTickEvent event) {
+ if (!NotEnoughUpdates.INSTANCE.config.itemOverlays.enableCrystalOverlay) return;
+
+ if (displayMillis < 0) {
+ return;
+ }
+
+ EntityPlayerSP p = Minecraft.getMinecraft().thePlayer;
+ if (p == null) return;
+
+ if (event.phase == TickEvent.Phase.START) {
+ double dX = p.posX - posLastUpdateX;
+ double dY = p.posY - posLastUpdateY;
+ double dZ = p.posZ - posLastUpdateZ;
+
+ if (dX * dX + dY * dY + dZ * dZ < 1) {
+ return;
+ }
+
+ posLastUpdateX = p.posX;
+ posLastUpdateY = p.posY;
+ posLastUpdateZ = p.posZ;
+
+ for (CrystalType type : crystals.keySet()) {
+ if (type == CrystalType.MINING_MINION) {
+ long currentTime = System.currentTimeMillis();
+ if (currentTime - lastMiningUpdate < 1000) {
+ continue;
+ }
+ lastMiningUpdate = currentTime;
+ }
+
+ ReverseWorldRenderer worldRenderer = type.getOverlayVBO();
+ if (worldRenderer != null) {
+ BlockPos crystal = crystals.get(type);
+
+ worldRenderer.setTranslation(0, 0, 0);
+ worldRenderer.sortVertexData(
+ (float) p.posX - crystal.getX(),
+ (float) p.posY - crystal.getY(),
+ (float) p.posZ - crystal.getZ()
+ );
/*es.submit(() -> worldRenderer.sortVertexData(
(float)p.posX-crystal.getX(),
(float)p.posY-crystal.getY(),
(float)p.posZ-crystal.getZ()));*/
- }
- }
- }
- }
-
- @SubscribeEvent
- public void onRenderLast(RenderWorldLastEvent event) {
- if(!NotEnoughUpdates.INSTANCE.config.itemOverlays.enableCrystalOverlay) return;
-
- if(displayMillis < 0) {
- return;
- }
-
- Entity viewer = Minecraft.getMinecraft().getRenderViewEntity();
- double viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * event.partialTicks;
- double viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * event.partialTicks;
- double viewerZ = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * event.partialTicks;
-
- GlStateManager.enableBlend();
- GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
- GlStateManager.disableTexture2D();
-
- GlStateManager.translate(-viewerX, -viewerY, -viewerZ);
-
- GL11.glPolygonOffset(5, 5);
- for(CrystalType type : crystals.keySet()) {
- ReverseWorldRenderer worldRenderer = type.getOverlayVBO();
- if(worldRenderer != null && worldRenderer.getVertexCount() > 0) {
- BlockPos crystal = crystals.get(type);
- GlStateManager.translate(crystal.getX(), crystal.getY(), crystal.getZ());
-
- VertexFormat vertexformat = worldRenderer.getVertexFormat();
- int stride = vertexformat.getNextOffset();
- ByteBuffer bytebuffer = worldRenderer.getByteBuffer();
- List<VertexFormatElement> list = vertexformat.getElements();
-
- for (int index = 0; index < list.size(); index++) {
- VertexFormatElement vertexformatelement = list.get(index);
- vertexformatelement.getUsage().preDraw(vertexformat, index, stride, bytebuffer);
- }
-
- GL11.glDrawArrays(worldRenderer.getDrawMode(), 0, worldRenderer.getVertexCount());
-
- for (int index = 0; index < list.size(); index++) {
- VertexFormatElement vertexformatelement = list.get(index);
- vertexformatelement.getUsage().postDraw(vertexformat, index, stride, bytebuffer);
- }
-
- GlStateManager.translate(-crystal.getX(), -crystal.getY(), -crystal.getZ());
- }
- }
- GL11.glPolygonOffset(0, 0);
-
- GlStateManager.translate(viewerX, viewerY, viewerZ);
-
- GlStateManager.enableTexture2D();
- }
-
- @SubscribeEvent
- public void onWorldUnload(WorldEvent.Unload event) {
- crystals.clear();
- }
-
- public static void uploadFilledBoundingBox(AxisAlignedBB p_181561_0_, float alpha, String special, ReverseWorldRenderer worldrenderer) {
- Color c = new Color(SpecialColour.specialToChromaRGB(special), true);
-
- //vertical
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.minZ)
- .color(c.getRed()/255f, c.getGreen()/255f, c.getBlue()/255f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.minZ)
- .color(c.getRed()/255f, c.getGreen()/255f, c.getBlue()/255f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.maxZ)
- .color(c.getRed()/255f, c.getGreen()/255f, c.getBlue()/255f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.maxZ)
- .color(c.getRed()/255f, c.getGreen()/255f, c.getBlue()/255f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.maxZ)
- .color(c.getRed()/255f, c.getGreen()/255f, c.getBlue()/255f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.maxZ)
- .color(c.getRed()/255f, c.getGreen()/255f, c.getBlue()/255f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.minZ)
- .color(c.getRed()/255f, c.getGreen()/255f, c.getBlue()/255f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.minZ)
- .color(c.getRed()/255f, c.getGreen()/255f, c.getBlue()/255f, c.getAlpha()/255f*alpha).endVertex();
-
- //x
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.maxZ)
- .color(c.getRed()/255f*0.8f, c.getGreen()/255f*0.8f, c.getBlue()/255f*0.8f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.maxZ)
- .color(c.getRed()/255f*0.8f, c.getGreen()/255f*0.8f, c.getBlue()/255f*0.8f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.minZ)
- .color(c.getRed()/255f*0.8f, c.getGreen()/255f*0.8f, c.getBlue()/255f*0.8f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.minZ)
- .color(c.getRed()/255f*0.8f, c.getGreen()/255f*0.8f, c.getBlue()/255f*0.8f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.minZ)
- .color(c.getRed()/255f*0.8f, c.getGreen()/255f*0.8f, c.getBlue()/255f*0.8f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.minZ)
- .color(c.getRed()/255f*0.8f, c.getGreen()/255f*0.8f, c.getBlue()/255f*0.8f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.maxZ)
- .color(c.getRed()/255f*0.8f, c.getGreen()/255f*0.8f, c.getBlue()/255f*0.8f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.maxZ)
- .color(c.getRed()/255f*0.8f, c.getGreen()/255f*0.8f, c.getBlue()/255f*0.8f, c.getAlpha()/255f*alpha).endVertex();
-
- //z
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.minZ)
- .color(c.getRed()/255f*0.9f, c.getGreen()/255f*0.9f, c.getBlue()/255f*0.9f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.minZ)
- .color(c.getRed()/255f*0.9f, c.getGreen()/255f*0.9f, c.getBlue()/255f*0.9f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.minZ)
- .color(c.getRed()/255f*0.9f, c.getGreen()/255f*0.9f, c.getBlue()/255f*0.9f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.minZ)
- .color(c.getRed()/255f*0.9f, c.getGreen()/255f*0.9f, c.getBlue()/255f*0.9f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.maxZ)
- .color(c.getRed()/255f*0.9f, c.getGreen()/255f*0.9f, c.getBlue()/255f*0.9f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.maxZ)
- .color(c.getRed()/255f*0.9f, c.getGreen()/255f*0.9f, c.getBlue()/255f*0.9f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.maxZ)
- .color(c.getRed()/255f*0.9f, c.getGreen()/255f*0.9f, c.getBlue()/255f*0.9f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.maxZ)
- .color(c.getRed()/255f*0.9f, c.getGreen()/255f*0.9f, c.getBlue()/255f*0.9f, c.getAlpha()/255f*alpha).endVertex();
- }
-
+ }
+ }
+ }
+ }
+
+ @SubscribeEvent
+ public void onRenderLast(RenderWorldLastEvent event) {
+ if (!NotEnoughUpdates.INSTANCE.config.itemOverlays.enableCrystalOverlay) return;
+
+ if (displayMillis < 0) {
+ return;
+ }
+
+ Entity viewer = Minecraft.getMinecraft().getRenderViewEntity();
+ double viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * event.partialTicks;
+ double viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * event.partialTicks;
+ double viewerZ = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * event.partialTicks;
+
+ GlStateManager.enableBlend();
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+ GlStateManager.disableTexture2D();
+
+ GlStateManager.translate(-viewerX, -viewerY, -viewerZ);
+
+ GL11.glPolygonOffset(5, 5);
+ for (CrystalType type : crystals.keySet()) {
+ ReverseWorldRenderer worldRenderer = type.getOverlayVBO();
+ if (worldRenderer != null && worldRenderer.getVertexCount() > 0) {
+ BlockPos crystal = crystals.get(type);
+ GlStateManager.translate(crystal.getX(), crystal.getY(), crystal.getZ());
+
+ VertexFormat vertexformat = worldRenderer.getVertexFormat();
+ int stride = vertexformat.getNextOffset();
+ ByteBuffer bytebuffer = worldRenderer.getByteBuffer();
+ List<VertexFormatElement> list = vertexformat.getElements();
+
+ for (int index = 0; index < list.size(); index++) {
+ VertexFormatElement vertexformatelement = list.get(index);
+ vertexformatelement.getUsage().preDraw(vertexformat, index, stride, bytebuffer);
+ }
+
+ GL11.glDrawArrays(worldRenderer.getDrawMode(), 0, worldRenderer.getVertexCount());
+
+ for (int index = 0; index < list.size(); index++) {
+ VertexFormatElement vertexformatelement = list.get(index);
+ vertexformatelement.getUsage().postDraw(vertexformat, index, stride, bytebuffer);
+ }
+
+ GlStateManager.translate(-crystal.getX(), -crystal.getY(), -crystal.getZ());
+ }
+ }
+ GL11.glPolygonOffset(0, 0);
+
+ GlStateManager.translate(viewerX, viewerY, viewerZ);
+
+ GlStateManager.enableTexture2D();
+ }
+
+ @SubscribeEvent
+ public void onWorldUnload(WorldEvent.Unload event) {
+ crystals.clear();
+ }
+
+ public static void uploadFilledBoundingBox(
+ AxisAlignedBB p_181561_0_,
+ float alpha,
+ String special,
+ ReverseWorldRenderer worldrenderer
+ ) {
+ Color c = new Color(SpecialColour.specialToChromaRGB(special), true);
+
+ //vertical
+ worldrenderer
+ .pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.minZ)
+ .color(c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f, c.getAlpha() / 255f * alpha)
+ .endVertex();
+ worldrenderer
+ .pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.minZ)
+ .color(c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f, c.getAlpha() / 255f * alpha)
+ .endVertex();
+ worldrenderer
+ .pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.maxZ)
+ .color(c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f, c.getAlpha() / 255f * alpha)
+ .endVertex();
+ worldrenderer
+ .pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.maxZ)
+ .color(c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f, c.getAlpha() / 255f * alpha)
+ .endVertex();
+ worldrenderer
+ .pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.maxZ)
+ .color(c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f, c.getAlpha() / 255f * alpha)
+ .endVertex();
+ worldrenderer
+ .pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.maxZ)
+ .color(c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f, c.getAlpha() / 255f * alpha)
+ .endVertex();
+ worldrenderer
+ .pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.minZ)
+ .color(c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f, c.getAlpha() / 255f * alpha)
+ .endVertex();
+ worldrenderer
+ .pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.minZ)
+ .color(c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f, c.getAlpha() / 255f * alpha)
+ .endVertex();
+
+ //x
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.maxZ)
+ .color(
+ c.getRed() / 255f * 0.8f,
+ c.getGreen() / 255f * 0.8f,
+ c.getBlue() / 255f * 0.8f,
+ c.getAlpha() / 255f * alpha
+ ).endVertex();
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.maxZ)
+ .color(
+ c.getRed() / 255f * 0.8f,
+ c.getGreen() / 255f * 0.8f,
+ c.getBlue() / 255f * 0.8f,
+ c.getAlpha() / 255f * alpha
+ ).endVertex();
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.minZ)
+ .color(
+ c.getRed() / 255f * 0.8f,
+ c.getGreen() / 255f * 0.8f,
+ c.getBlue() / 255f * 0.8f,
+ c.getAlpha() / 255f * alpha
+ ).endVertex();
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.minZ)
+ .color(
+ c.getRed() / 255f * 0.8f,
+ c.getGreen() / 255f * 0.8f,
+ c.getBlue() / 255f * 0.8f,
+ c.getAlpha() / 255f * alpha
+ ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.minZ)
+ .color(
+ c.getRed() / 255f * 0.8f,
+ c.getGreen() / 255f * 0.8f,
+ c.getBlue() / 255f * 0.8f,
+ c.getAlpha() / 255f * alpha
+ ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.minZ)
+ .color(
+ c.getRed() / 255f * 0.8f,
+ c.getGreen() / 255f * 0.8f,
+ c.getBlue() / 255f * 0.8f,
+ c.getAlpha() / 255f * alpha
+ ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.maxZ)
+ .color(
+ c.getRed() / 255f * 0.8f,
+ c.getGreen() / 255f * 0.8f,
+ c.getBlue() / 255f * 0.8f,
+ c.getAlpha() / 255f * alpha
+ ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.maxZ)
+ .color(
+ c.getRed() / 255f * 0.8f,
+ c.getGreen() / 255f * 0.8f,
+ c.getBlue() / 255f * 0.8f,
+ c.getAlpha() / 255f * alpha
+ ).endVertex();
+
+ //z
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.minZ)
+ .color(
+ c.getRed() / 255f * 0.9f,
+ c.getGreen() / 255f * 0.9f,
+ c.getBlue() / 255f * 0.9f,
+ c.getAlpha() / 255f * alpha
+ ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.minZ)
+ .color(
+ c.getRed() / 255f * 0.9f,
+ c.getGreen() / 255f * 0.9f,
+ c.getBlue() / 255f * 0.9f,
+ c.getAlpha() / 255f * alpha
+ ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.minZ)
+ .color(
+ c.getRed() / 255f * 0.9f,
+ c.getGreen() / 255f * 0.9f,
+ c.getBlue() / 255f * 0.9f,
+ c.getAlpha() / 255f * alpha
+ ).endVertex();
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.minZ)
+ .color(
+ c.getRed() / 255f * 0.9f,
+ c.getGreen() / 255f * 0.9f,
+ c.getBlue() / 255f * 0.9f,
+ c.getAlpha() / 255f * alpha
+ ).endVertex();
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.maxZ)
+ .color(
+ c.getRed() / 255f * 0.9f,
+ c.getGreen() / 255f * 0.9f,
+ c.getBlue() / 255f * 0.9f,
+ c.getAlpha() / 255f * alpha
+ ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.maxZ)
+ .color(
+ c.getRed() / 255f * 0.9f,
+ c.getGreen() / 255f * 0.9f,
+ c.getBlue() / 255f * 0.9f,
+ c.getAlpha() / 255f * alpha
+ ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.maxZ)
+ .color(
+ c.getRed() / 255f * 0.9f,
+ c.getGreen() / 255f * 0.9f,
+ c.getBlue() / 255f * 0.9f,
+ c.getAlpha() / 255f * alpha
+ ).endVertex();
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.maxZ)
+ .color(
+ c.getRed() / 255f * 0.9f,
+ c.getGreen() / 255f * 0.9f,
+ c.getBlue() / 255f * 0.9f,
+ c.getAlpha() / 255f * alpha
+ ).endVertex();
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java
index d7d27f99..e621cf78 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java
@@ -5,12 +5,9 @@ import io.github.moulberry.notenoughupdates.util.SBInfo;
import io.github.moulberry.notenoughupdates.util.SpecialColour;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.block.Block;
-import net.minecraft.block.BlockCrops;
-import net.minecraft.block.BlockPackedIce;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
-import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.multiplayer.WorldClient;
@@ -19,9 +16,6 @@ import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.texture.TextureUtil;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.resources.model.IBakedModel;
-import net.minecraft.entity.Entity;
-import net.minecraft.entity.EntityLivingBase;
-import net.minecraft.entity.item.EntityArmorStand;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
@@ -31,7 +25,6 @@ import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.*;
-import net.minecraft.world.World;
import net.minecraftforge.client.event.DrawBlockHighlightEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
@@ -43,1175 +36,1286 @@ import org.lwjgl.util.vector.Vector3f;
import java.awt.*;
import java.io.ByteArrayInputStream;
-import java.util.*;
import java.util.List;
+import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class CustomItemEffects {
-
- public static final CustomItemEffects INSTANCE = new CustomItemEffects();
-
- private static final int MAX_BUILDERS_BLOCKS = 241;
-
- private HashSet<BlockPos> zapperBlocks = new HashSet<>();
- private boolean zapperDirty = false;
-
- public long aoteUseMillis = 0;
-
- public long lastUsedHyperion = 0;
-
- private final Pattern etherwarpDistancePattern = Pattern.compile("up to (?<distance>\\d{2}) blocks away\\.");
-
- public int aoteTeleportationMillis = 0;
- public Vector3f aoteTeleportationCurr = null;
-
- public int tpTime = NotEnoughUpdates.INSTANCE.config.itemOverlays.smoothTpMillis;
-
- private int tick;
-
- public long lastMillis = 0;
-
- public Vector3f getCurrentPosition() {
- if(aoteTeleportationMillis <= 0) return null;
- return aoteTeleportationCurr;
- }
-
- @SubscribeEvent
- public void onTick(TickEvent.RenderTickEvent event) {
- if(Minecraft.getMinecraft().thePlayer == null) return;
-
- zapperDirty = true;
-
- long currentTime = System.currentTimeMillis();
- int delta = (int)(currentTime - lastMillis);
- lastMillis = currentTime;
-
- if(delta <= 0) return;
-
- if(aoteTeleportationMillis > tpTime*2) {
- aoteTeleportationMillis = tpTime*2;
- }
- if(aoteTeleportationMillis < 0) aoteTeleportationMillis = 0;
-
- if(currentTime - aoteUseMillis > 1000 && aoteTeleportationMillis <= 0) {
- aoteTeleportationCurr = null;
- }
-
- if(aoteTeleportationCurr != null) {
- if(aoteTeleportationMillis > 0) {
- int deltaMin = Math.min(delta, aoteTeleportationMillis);
-
- float factor = deltaMin/(float)aoteTeleportationMillis;
-
- float dX = aoteTeleportationCurr.x - (float)Minecraft.getMinecraft().thePlayer.posX;
- float dY = aoteTeleportationCurr.y - (float)Minecraft.getMinecraft().thePlayer.posY;
- float dZ = aoteTeleportationCurr.z - (float)Minecraft.getMinecraft().thePlayer.posZ;
-
- aoteTeleportationCurr.x -= dX*factor;
- aoteTeleportationCurr.y -= dY*factor;
- aoteTeleportationCurr.z -= dZ*factor;
-
- if(Minecraft.getMinecraft().theWorld.getBlockState(new BlockPos(aoteTeleportationCurr.x,
- aoteTeleportationCurr.y, aoteTeleportationCurr.z)).getBlock().getMaterial() != Material.air) {
- aoteTeleportationCurr.y = (float)Math.ceil(aoteTeleportationCurr.y);
- }
-
- aoteTeleportationMillis -= deltaMin;
- } else {
- aoteTeleportationCurr.x = (float) Minecraft.getMinecraft().thePlayer.posX;
- aoteTeleportationCurr.y = (float) Minecraft.getMinecraft().thePlayer.posY;
- aoteTeleportationCurr.z = (float) Minecraft.getMinecraft().thePlayer.posZ;
- }
- } else {
- aoteUseMillis = 0;
- aoteTeleportationMillis = 0;
- }
- }
-
- @SubscribeEvent
- public void onPlayerInteract(PlayerInteractEvent event) {
- if(event.action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR || event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
- ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem();
- String internal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held);
- if(internal != null) {
- boolean shadowWarp = false;
- if(internal.equals("HYPERION") || internal.equals("VALKYRIE") || internal.equals("SCYLLA") || internal.equals("ASTRAEA")) {
- NBTTagCompound tag = held.getTagCompound();
- if(tag != null && tag.hasKey("ExtraAttributes", 10)) {
- NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
- if(ea != null && ea.hasKey("ability_scroll", 9)) {
- NBTTagList list = ea.getTagList("ability_scroll", 8);
- for(int i=0; i<list.tagCount(); i++) {
- if(list.getStringTagAt(i).equals("IMPLOSION_SCROLL")) {
- lastUsedHyperion = System.currentTimeMillis();
- } else if(list.getStringTagAt(i).equals("SHADOW_WARP_SCROLL")) {
- shadowWarp = true;
- }
- }
- }
- }
- }
-
- if(usingEtherwarp) {
- lastEtherwarpUse = tick;
- }
-
- if(tpTime <= 0 || Minecraft.getMinecraft().gameSettings.thirdPersonView != 0) return;
-
- boolean aote = NotEnoughUpdates.INSTANCE.config.itemOverlays.enableSmoothAOTE &&
- (internal.equals("ASPECT_OF_THE_END") || internal.equals("ASPECT_OF_THE_VOID"));
- boolean hyp = NotEnoughUpdates.INSTANCE.config.itemOverlays.enableSmoothHyperion && shadowWarp;
- if(usingEtherwarp) {
- tpTime = NotEnoughUpdates.INSTANCE.config.itemOverlays.smoothTpMillisEtherwarp;
- } else {
- tpTime = NotEnoughUpdates.INSTANCE.config.itemOverlays.smoothTpMillis;
- }
- if(usingEtherwarp || aote || hyp) {
- aoteUseMillis = System.currentTimeMillis();
- if(aoteTeleportationCurr == null) {
- aoteTeleportationCurr = new Vector3f();
- aoteTeleportationCurr.x = (float) Minecraft.getMinecraft().thePlayer.posX;
- aoteTeleportationCurr.y = (float) Minecraft.getMinecraft().thePlayer.posY;
- aoteTeleportationCurr.z = (float) Minecraft.getMinecraft().thePlayer.posZ;
- }
- }
- }
- }
- }
-
- @SubscribeEvent
- public void onGameTick(TickEvent.ClientTickEvent event) {
- if(event.phase != TickEvent.Phase.END) return;
-
- if(!usingEtherwarp && wasUsingEtherwarp) {
- if(Minecraft.getMinecraft().thePlayer.rotationYaw > 0) {
- Minecraft.getMinecraft().thePlayer.rotationYaw -= 0.000001;
- } else {
- Minecraft.getMinecraft().thePlayer.rotationYaw += 0.000001;
- }
- }
- wasUsingEtherwarp = usingEtherwarp;
-
- tick++;
- if(tick > Integer.MAX_VALUE/2) tick = 0;
-
-
- }
-
- private float lastPartialTicks = 0;
- private float currentFOVMult = 1;
- private float targetFOVMult = 1;
-
- private float lastPartialDelta = 0;
-
- private float currentSensMult = 1;
- private float targetSensMult = 1;
-
- public float getSensMultiplier() {
- if(targetSensMult < 0) {
- currentSensMult = 1;
- } else {
- float deltaSens = targetSensMult - currentSensMult;
-
- currentSensMult += deltaSens*lastPartialDelta*0.1;// (0.05 * );
- if(currentSensMult < 0.25f) currentSensMult = 0.25f;
- if(currentSensMult > 1) currentSensMult = 1;
- }
- return currentSensMult;
- }
-
- public float getFovMultiplier(float partialTicks) {
- float partialDelta = partialTicks+tick - lastPartialTicks;
- if(partialDelta < 0) partialDelta++;
-
- if(partialDelta > 0) lastPartialDelta = partialDelta;
-
- if(targetFOVMult < 0) {
- currentFOVMult = 1;
- } else {
- float deltaFOV = targetFOVMult - currentFOVMult;
-
- currentFOVMult += deltaFOV*lastPartialDelta*0.2;
- if(currentFOVMult < 0.15f) currentFOVMult = 0.15f;
- if(currentFOVMult > 1) currentFOVMult = 1;
- }
- lastPartialTicks = partialTicks + tick;
- return currentFOVMult;
- }
-
- private boolean wasUsingEtherwarp = false;
- private boolean usingEtherwarp = false;
- private RaycastResult etherwarpRaycast = null;
- private int lastEtherwarpUse = 0;
-
- @SubscribeEvent
- public void onOverlayDrawn(RenderGameOverlayEvent.Post event) {
- if(((event.type == null && Loader.isModLoaded("labymod")) ||
- event.type == RenderGameOverlayEvent.ElementType.CROSSHAIRS)) {
- ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem();
- String heldInternal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held);
-
- if(usingEtherwarp && NotEnoughUpdates.INSTANCE.config.itemOverlays.enableEtherwarpHelperOverlay) {
- String denyTpReason = null;
- if(etherwarpRaycast == null) {
- denyTpReason = "Too far!";
- } else {
- BlockPos pos = etherwarpRaycast.pos;
-
- if(!etherwarpRaycast.state.getBlock().isCollidable() ||
- etherwarpRaycast.state.getBlock().getCollisionBoundingBox(Minecraft.getMinecraft().theWorld, etherwarpRaycast.pos, etherwarpRaycast.state) == null) {
- denyTpReason = "Not solid!";
- } else {
- WorldClient world = Minecraft.getMinecraft().theWorld;
- Block above = world.getBlockState(pos.add(0, 1, 0)).getBlock();
- if(above != Blocks.air && above.isCollidable() &&
- above.getCollisionBoundingBox(Minecraft.getMinecraft().theWorld, pos.add(0, 1, 0),
- world.getBlockState(pos.add(0, 1, 0))) != null ||
- world.getBlockState(pos.add(0, 2, 0)).getBlock() != Blocks.air) {
- denyTpReason = "No air above!";
- }
- }
- }
-
- if(denyTpReason != null) {
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- Utils.drawStringCentered(EnumChatFormatting.RED+"Can't TP: " + denyTpReason,
- Minecraft.getMinecraft().fontRendererObj,
- scaledResolution.getScaledWidth()/2f, scaledResolution.getScaledHeight()/2f+10, true, 0);
- GlStateManager.color(1, 1, 1, 1);
- }
- }
-
- boolean onPrivateIsland = SBInfo.getInstance().getLocation() == null || SBInfo.getInstance().getLocation().equals("dynamic");
-
-
- if(NotEnoughUpdates.INSTANCE.config.itemOverlays.enableWandOverlay &&
- Minecraft.getMinecraft().objectMouseOver != null &&
- Minecraft.getMinecraft().objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && onPrivateIsland) {
-
- IBlockState hover = Minecraft.getMinecraft().theWorld.getBlockState(
- Minecraft.getMinecraft().objectMouseOver.getBlockPos().offset(
- Minecraft.getMinecraft().objectMouseOver.sideHit, 1));
- if(hover.getBlock() == Blocks.air) {
-
- if(heldInternal != null && heldInternal.equals("BUILDERS_WAND")) {
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
-
- HashSet<BlockPos> candidatesOld = new HashSet<>();
- TreeMap<Float, Set<BlockPos>> candidatesOldSorted = new TreeMap<>();
-
- IBlockState match = Minecraft.getMinecraft().theWorld.getBlockState(Minecraft.getMinecraft().objectMouseOver.getBlockPos());
- Item matchItem = Item.getItemFromBlock(match.getBlock());
- if(matchItem != null) {
- ItemStack matchStack = new ItemStack(matchItem, 1,
- match.getBlock().getDamageValue(Minecraft.getMinecraft().theWorld, Minecraft.getMinecraft().objectMouseOver.getBlockPos()));
-
- getBuildersWandCandidates(Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().objectMouseOver, event.partialTicks,
- candidatesOld, candidatesOldSorted, 999-MAX_BUILDERS_BLOCKS);
-
- boolean usingDirtWand = false;
- int itemCount;
- if(match.getBlock() == Blocks.dirt && matchStack.getItemDamage() == 0 && hasDirtWand()) {
- itemCount = candidatesOld.size();
- usingDirtWand = true;
- } else {
- itemCount = countItemsInInventoryAndStorage(matchStack);
- }
-
- if(candidatesOld.size() > MAX_BUILDERS_BLOCKS) {
- Utils.drawStringCentered(EnumChatFormatting.RED.toString()+candidatesOld.size()+"/"+MAX_BUILDERS_BLOCKS,
- Minecraft.getMinecraft().fontRendererObj,
- scaledResolution.getScaledWidth()/2f, scaledResolution.getScaledHeight()/2f+10, true, 0);
- } else {
- String pre = EnumChatFormatting.GREEN.toString();
- if(itemCount < candidatesOld.size()) {
- pre = EnumChatFormatting.RED.toString();
- }
- Utils.drawStringCentered(pre+Math.min(candidatesOld.size(), itemCount)+"/"+
- Math.min(candidatesOld.size(), MAX_BUILDERS_BLOCKS),
- Minecraft.getMinecraft().fontRendererObj,
- scaledResolution.getScaledWidth()/2f, scaledResolution.getScaledHeight()/2f+10, true, 0);
- }
-
- String itemCountS = EnumChatFormatting.DARK_GRAY+"x"+EnumChatFormatting.RESET+itemCount;
- int itemCountLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(itemCountS);
-
- if(NotEnoughUpdates.INSTANCE.config.itemOverlays.wandBlockCount) {
- if(usingDirtWand) {
- Utils.drawItemStack(new ItemStack(Items.gold_nugget), scaledResolution.getScaledWidth()/2 - (itemCountLen+16)/2,
- scaledResolution.getScaledHeight()/2+10+4);
- Minecraft.getMinecraft().fontRendererObj.drawString(itemCountS,
- scaledResolution.getScaledWidth()/2f - (itemCountLen+16)/2f+11, scaledResolution.getScaledHeight()/2f+10+8,
- -1,
- true);
- } else {
- Utils.drawItemStack(matchStack, scaledResolution.getScaledWidth()/2 - (itemCountLen+16)/2,
- scaledResolution.getScaledHeight()/2+10+4);
- Minecraft.getMinecraft().fontRendererObj.drawString(itemCountS,
- scaledResolution.getScaledWidth()/2f - (itemCountLen+16)/2f+16, scaledResolution.getScaledHeight()/2f+10+8,
- -1,
- true);
- }
-
- }
-
- GlStateManager.color(1, 1, 1, 1);
- }
-
- }
- }
- }
- }
- }
- //ethermerge
-
- private class RaycastResult {
- IBlockState state;
- BlockPos pos;
-
- public RaycastResult(IBlockState state, BlockPos pos) {
- this.state = state;
- this.pos = pos;
- }
- }
-
- private RaycastResult raycast(EntityPlayerSP player, float partialTicks, float dist, float step) {
- Vector3f pos = new Vector3f((float)player.posX, (float)player.posY+player.getEyeHeight(), (float)player.posZ);
-
- Vec3 lookVec3 = player.getLook(partialTicks);
-
- Vector3f look = new Vector3f((float)lookVec3.xCoord, (float)lookVec3.yCoord, (float)lookVec3.zCoord);
- look.scale(step / look.length());
-
- int stepCount = (int)Math.ceil(dist/step);
-
- for(int i=0; i<stepCount; i++) {
- Vector3f.add(pos, look, pos);
-
- WorldClient world = Minecraft.getMinecraft().theWorld;
- BlockPos position = new BlockPos(pos.x, pos.y, pos.z);
- IBlockState state = world.getBlockState(position);
-
- if(state.getBlock() != Blocks.air) {
- //Back-step
- Vector3f.sub(pos, look, pos);
- look.scale(0.1f);
-
- for(int j=0; j<10; j++) {
- Vector3f.add(pos, look, pos);
-
- BlockPos position2 = new BlockPos(pos.x, pos.y, pos.z);
- IBlockState state2 = world.getBlockState(position2);
-
- if(state2.getBlock() != Blocks.air) {
- return new RaycastResult(state2, position2);
- }
- }
-
- return new RaycastResult(state, position);
- }
- }
-
- return null;
- }
-
- public int countItemsInInventoryAndStorage(ItemStack match) {
- int count = 0;
-
- for(ItemStack stack : Minecraft.getMinecraft().thePlayer.inventory.mainInventory) {
- if(match.isItemEqual(stack)) {
- count += stack.stackSize;
- }
- }
-
- ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem();
- String heldInternal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held);
-
- if(heldInternal != null && heldInternal.equals("BUILDERS_WAND")) {
- if(held.hasTagCompound() && held.getTagCompound().hasKey("ExtraAttributes", 10) &&
- held.getTagCompound().getCompoundTag("ExtraAttributes").hasKey("builder's_wand_data", 7)) {
- byte[] bytes = held.getTagCompound().getCompoundTag("ExtraAttributes").getByteArray("builder's_wand_data");
- try {
- NBTTagCompound contents_nbt = CompressedStreamTools.readCompressed(new ByteArrayInputStream(bytes));
- NBTTagList items = contents_nbt.getTagList("i", 10);
- for(int j=0; j<items.tagCount(); j++) {
- NBTTagCompound buildersItem = items.getCompoundTagAt(j);
- if(buildersItem.getKeySet().size() > 0) {
- if(buildersItem.getInteger("id") == Item.getIdFromItem(match.getItem()) &&
- buildersItem.getInteger("Damage") == match.getItemDamage()) {
- count += items.getCompoundTagAt(j).getByte("Count");
- }
- }
- }
- } catch(Exception e) {
- return count;
- }
- }
- }
-
- return count;
- }
-
- public boolean hasDirtWand() {
- for(ItemStack stack : Minecraft.getMinecraft().thePlayer.inventory.mainInventory) {
- String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack);
- if(internalname != null && internalname.equals("INFINIDIRT_WAND")) {
- return true;
- }
- }
-
- ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem();
- String heldInternal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held);
-
- if(heldInternal != null && heldInternal.equals("BUILDERS_WAND")) {
- if(held.hasTagCompound() && held.getTagCompound().hasKey("ExtraAttributes", 10) &&
- held.getTagCompound().getCompoundTag("ExtraAttributes").hasKey("builder's_wand_data", 7)) {
- byte[] bytes = held.getTagCompound().getCompoundTag("ExtraAttributes").getByteArray("builder's_wand_data");
- try {
- NBTTagCompound contents_nbt = CompressedStreamTools.readCompressed(new ByteArrayInputStream(bytes));
- NBTTagList items = contents_nbt.getTagList("i", 10);
- for(int j=0; j<items.tagCount(); j++) {
- NBTTagCompound buildersItem = items.getCompoundTagAt(j);
- if(buildersItem.getKeySet().size() > 0) {
- String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalnameFromNBT(buildersItem.getCompoundTag("tag"));
- if(internalname != null && internalname.equals("INFINIDIRT_WAND")) {
- return true;
- }
- }
- }
- } catch(Exception e) {
- }
- }
- }
-
- return false;
- }
-
- private static final List<BlockPos> zapperOffsets = new ArrayList<>();
- static {
- zapperOffsets.add(new BlockPos(0, 0, -1));
- zapperOffsets.add(new BlockPos(0, 0, 1));
- zapperOffsets.add(new BlockPos(-1, 0, 0));
- zapperOffsets.add(new BlockPos(1, 0, 0));
- zapperOffsets.add(new BlockPos(0, 1, 0));
- zapperOffsets.add(new BlockPos(0, -1, 0));
- }
- private static final HashSet<Block> cropBlocksZapper = new HashSet<>();
- private static final HashSet<Block> otherBannedBlocksZapper = new HashSet<>();
- static {
- cropBlocksZapper.add(Blocks.wheat);
- cropBlocksZapper.add(Blocks.carrots);
- cropBlocksZapper.add(Blocks.potatoes);
- cropBlocksZapper.add(Blocks.pumpkin);
- cropBlocksZapper.add(Blocks.pumpkin_stem);
- cropBlocksZapper.add(Blocks.melon_block);
- cropBlocksZapper.add(Blocks.melon_stem);
- cropBlocksZapper.add(Blocks.cactus);
- cropBlocksZapper.add(Blocks.reeds);
- cropBlocksZapper.add(Blocks.nether_wart);
- cropBlocksZapper.add(Blocks.tallgrass);
- cropBlocksZapper.add(Blocks.double_plant);
-
- otherBannedBlocksZapper.add(Blocks.farmland);
- }
-
- @SubscribeEvent
- public void renderBlockOverlay(DrawBlockHighlightEvent event) {
- if(aoteTeleportationCurr != null && aoteTeleportationMillis > 0) {
- event.setCanceled(true);
- }
- usingEtherwarp = false;
- etherwarpRaycast = null;
- float lastFOVMult = this.targetFOVMult;
- this.targetFOVMult = 1;
- this.targetSensMult = 1;
-
- ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem();
- String heldInternal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held);
- if(heldInternal != null) {
- boolean onPrivateIsland = SBInfo.getInstance().getLocation() == null || SBInfo.getInstance().getLocation().equals("dynamic");
- EntityPlayer player = event.player;
- double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double)event.partialTicks;
- double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double)event.partialTicks;
- double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double)event.partialTicks;
-
- if(tick - lastEtherwarpUse > 10) {
- boolean aotv = Minecraft.getMinecraft().thePlayer.isSneaking() &&
- (heldInternal.equals("ASPECT_OF_THE_VOID") || heldInternal.equals("ASPECT_OF_THE_END"));
- if(aotv || heldInternal.equals("ETHERWARP_CONDUIT")) {
- usingEtherwarp = !aotv;
-
- if(aotv) {
- NBTTagCompound tag = held.getTagCompound();
- if(tag != null && tag.hasKey("ExtraAttributes", 10)) {
- NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
- usingEtherwarp = ea.hasKey("ethermerge");
- }
- }
-
- if(usingEtherwarp) {
- int dist = 0;
- for (String line : NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(held.getTagCompound())) {
- String cleaned = Utils.cleanColour(line);
- Matcher matcher = etherwarpDistancePattern.matcher(cleaned);
- if (matcher.matches()) {
- dist = Integer.parseInt(matcher.group("distance"));
- break;
- }
- }
- if (dist != 0) {
- etherwarpRaycast = raycast(Minecraft.getMinecraft().thePlayer, 1f, dist, 0.1f);
-
- if (etherwarpRaycast != null) {
- AxisAlignedBB bb = etherwarpRaycast.state.getBlock().getSelectedBoundingBox(Minecraft.getMinecraft().theWorld, etherwarpRaycast.pos)
- .expand(0.01D, 0.01D, 0.01D).offset(-d0, -d1, -d2);
- drawFilledBoundingBox(bb, 1f, NotEnoughUpdates.INSTANCE.config.itemOverlays.etherwarpHighlightColour);
-
- GlStateManager.disableDepth();
- drawOutlineBoundingBox(bb, 2f, NotEnoughUpdates.INSTANCE.config.itemOverlays.etherwarpHighlightColour);
- GlStateManager.enableDepth();
-
- GlStateManager.depthMask(true);
- GlStateManager.enableTexture2D();
- GlStateManager.disableBlend();
-
- if (NotEnoughUpdates.INSTANCE.config.itemOverlays.etherwarpZoom) {
- float distFactor = 1 - (float) Math.sqrt(etherwarpRaycast.pos.distanceSq(Minecraft.getMinecraft().thePlayer.getPosition())) / 60;
-
- targetFOVMult = distFactor * distFactor * distFactor * 0.75f + 0.25f;
- if (targetFOVMult < 0.25f) targetFOVMult = 0.25f;
-
- targetSensMult = distFactor * 0.76f + 0.25f;
- }
- } else if (NotEnoughUpdates.INSTANCE.config.itemOverlays.etherwarpZoom) {
- targetFOVMult = lastFOVMult;
- }
-
- return;
- }
- }
- }
- }
-
- if(heldInternal.equals("BLOCK_ZAPPER")) {
-
- if (!onPrivateIsland || !NotEnoughUpdates.INSTANCE.config.itemOverlays.enableZapperOverlay ||
- event.target.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) {
- zapperBlocks.clear();
- return;
- }
- if(zapperDirty) {
- zapperDirty = false;
-
- zapperBlocks.clear();
-
- LinkedList<BlockPos> returnablePositions = new LinkedList<>();
-
- BlockPos pos = event.target.getBlockPos();
- IBlockState firstBlockState = Minecraft.getMinecraft().theWorld.getBlockState(pos);
- Block block = firstBlockState.getBlock();
-
- BlockPos above = pos.add(0, 1, 0);
- Block aboveBlock = Minecraft.getMinecraft().theWorld.getBlockState(above).getBlock();
-
- if(!cropBlocksZapper.contains(aboveBlock) && !cropBlocksZapper.contains(block) &&
- !otherBannedBlocksZapper.contains(block) && !block.hasTileEntity(firstBlockState) &&
- block.getBlockHardness(Minecraft.getMinecraft().theWorld, pos) >= 0) {
- for(int i=0; i<164; i++) {
- zapperBlocks.add(pos);
- returnablePositions.remove(pos);
-
- List<BlockPos> availableNeighbors = new ArrayList<>();
-
- for(BlockPos offset : zapperOffsets) {
- BlockPos newPos = pos.add(offset);
-
- if(zapperBlocks.contains(newPos)) continue;
-
- IBlockState state = Minecraft.getMinecraft().theWorld.getBlockState(newPos);
- if(state != null && state.getBlock() == block) {
- above = newPos.add(0, 1, 0);
- aboveBlock = Minecraft.getMinecraft().theWorld.getBlockState(above).getBlock();
- if(!cropBlocksZapper.contains(aboveBlock)) {
- availableNeighbors.add(newPos);
- }
- }
- }
-
- if(availableNeighbors.size() >= 2) {
- returnablePositions.add(pos);
- pos = availableNeighbors.get(0);
- } else if(availableNeighbors.size() == 1) {
- pos = availableNeighbors.get(0);
- } else if(returnablePositions.isEmpty()) {
- break;
- } else {
- i--;
- pos = returnablePositions.getLast();
- }
- }
- }
- }
- for(BlockPos pos : zapperBlocks) {
- Block block = Minecraft.getMinecraft().theWorld.getBlockState(pos).getBlock();
- drawFilledBoundingBox(block.getSelectedBoundingBox(Minecraft.getMinecraft().theWorld, pos)
- .expand(0.001D, 0.001D, 0.001D).offset(-d0, -d1, -d2),
- 1f, NotEnoughUpdates.INSTANCE.config.itemOverlays.zapperOverlayColour);
- }
- GlStateManager.depthMask(true);
- GlStateManager.enableTexture2D();
- GlStateManager.disableBlend();
- } else if(NotEnoughUpdates.INSTANCE.config.itemOverlays.enableTreecapOverlay &&
- (heldInternal.equals("JUNGLE_AXE") || heldInternal.equals("TREECAPITATOR_AXE"))) {
- int maxWood = 10;
- if(heldInternal.equals("TREECAPITATOR_AXE")) maxWood = 35;
-
- if (event.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
- GlStateManager.enableBlend();
- GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
- GlStateManager.color(0.0F, 0.0F, 0.0F, 0.4F);
- GlStateManager.disableTexture2D();
- GlStateManager.depthMask(false);
-
- if(Minecraft.getMinecraft().theWorld.getBlockState(event.target.getBlockPos()).getBlock() == Blocks.log ||
- Minecraft.getMinecraft().theWorld.getBlockState(event.target.getBlockPos()).getBlock() == Blocks.log2) {
-
- int woods = 0;
-
- HashSet<BlockPos> candidatesOld = new HashSet<>();
- LinkedList<BlockPos> candidates = new LinkedList<>();
- LinkedList<BlockPos> candidatesNew = new LinkedList<>();
-
- candidatesNew.add(event.target.getBlockPos());
-
- while(woods < maxWood) {
- if(candidatesNew.isEmpty()) {
- break;
- }
-
- candidates.addAll(candidatesNew);
- candidatesNew.clear();
-
- woods += candidates.size();
- boolean random = woods > maxWood;
-
- while(!candidates.isEmpty()) {
- BlockPos candidate = candidates.pop();
- Block block = Minecraft.getMinecraft().theWorld.getBlockState(candidate).getBlock();
-
- candidatesOld.add(candidate);
-
- for(int x = -1; x <= 1; x++) {
- for(int y = -1; y <= 1; y++) {
- for(int z = -1; z <= 1; z++) {
- if(x != 0 || y != 0 || z != 0) {
- BlockPos posNew = candidate.add(x, y, z);
- if(!candidatesOld.contains(posNew) && !candidates.contains(posNew) && !candidatesNew.contains(posNew)) {
- Block blockNew = Minecraft.getMinecraft().theWorld.getBlockState(posNew).getBlock();
- if(blockNew == Blocks.log || blockNew == Blocks.log2) {
- candidatesNew.add(posNew);
- }
- }
- }
- }
- }
- }
-
- block.setBlockBoundsBasedOnState(Minecraft.getMinecraft().theWorld, candidate);
-
- drawFilledBoundingBox(block.getSelectedBoundingBox(Minecraft.getMinecraft().theWorld, candidate)
- .expand(0.001D, 0.001D, 0.001D).offset(-d0, -d1, -d2),
- random ? 0.5f : 1f, NotEnoughUpdates.INSTANCE.config.itemOverlays.treecapOverlayColour);
- }
- }
- }
-
- GlStateManager.depthMask(true);
- GlStateManager.enableTexture2D();
- GlStateManager.disableBlend();
- }
- } else if(NotEnoughUpdates.INSTANCE.config.itemOverlays.enableWandOverlay) {
- if(heldInternal.equals("BUILDERS_WAND") && onPrivateIsland) {
- int maxBlocks = MAX_BUILDERS_BLOCKS;
- if (event.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
- IBlockState hover = Minecraft.getMinecraft().theWorld.getBlockState(event.target.getBlockPos().offset(event.target.sideHit, 1));
- if(hover.getBlock() == Blocks.air) {
- IBlockState match = Minecraft.getMinecraft().theWorld.getBlockState(event.target.getBlockPos());
- Item matchItem = Item.getItemFromBlock(match.getBlock());
- if(matchItem != null) {
- GlStateManager.enableBlend();
- GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
- GlStateManager.disableTexture2D();
- GlStateManager.depthMask(false);
-
- HashSet<BlockPos> candidatesOld = new HashSet<>();
- TreeMap<Float, Set<BlockPos>> candidatesOldSorted = new TreeMap<>();
-
- getBuildersWandCandidates(player, event.target, event.partialTicks, candidatesOld, candidatesOldSorted, 10);
-
- ItemStack matchStack = new ItemStack(matchItem, 1,
- match.getBlock().getDamageValue(Minecraft.getMinecraft().theWorld, event.target.getBlockPos()));
- int itemCount;
- if(match.getBlock() == Blocks.dirt && matchStack.getItemDamage() == 0 && hasDirtWand()) {
- itemCount = candidatesOld.size();
- } else {
- itemCount = countItemsInInventoryAndStorage(matchStack);
- }
-
- String special = (candidatesOld.size() <= itemCount) ? NotEnoughUpdates.INSTANCE.config.itemOverlays.wandOverlayColour :
- "0:255:255:0:0";
-
- if(candidatesOld.size() <= maxBlocks) {
- for(Set<BlockPos> candidatesSorted : candidatesOldSorted.values()) {
- for(BlockPos candidate : candidatesSorted) {
- match.getBlock().setBlockBoundsBasedOnState(Minecraft.getMinecraft().theWorld, candidate);
- AxisAlignedBB bb = match.getBlock().getSelectedBoundingBox(Minecraft.getMinecraft().theWorld, candidate)
- .offset(event.target.sideHit.getFrontOffsetX(), event.target.sideHit.getFrontOffsetY(),
- event.target.sideHit.getFrontOffsetZ());
-
- drawBlock((int)bb.minX, (int)bb.minY, (int)bb.minZ+1, match, event.partialTicks, 0.75f);
- }
- }
-
- for(BlockPos candidate : candidatesOld) {
- match.getBlock().setBlockBoundsBasedOnState(Minecraft.getMinecraft().theWorld, candidate);
- AxisAlignedBB bb = match.getBlock().getSelectedBoundingBox(Minecraft.getMinecraft().theWorld, candidate)
- .expand(0.001D, 0.001D, 0.001D).offset(-d0, -d1, -d2)
- .offset(event.target.sideHit.getFrontOffsetX(), event.target.sideHit.getFrontOffsetY(),
- event.target.sideHit.getFrontOffsetZ());
-
- drawOutlineBoundingBox(bb, 1f, special);
- }
- }
-
- GlStateManager.depthMask(true);
- GlStateManager.enableTexture2D();
- GlStateManager.disableBlend();
- }
- }
- }
- } else if(heldInternal.equals("INFINIDIRT_WAND") && event.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
- BlockPos hover = event.target.getBlockPos().offset(event.target.sideHit, 1);
- IBlockState hoverState = Minecraft.getMinecraft().theWorld.getBlockState(event.target.getBlockPos().offset(event.target.sideHit, 1));
- if(hoverState.getBlock() == Blocks.air) {
- GlStateManager.enableBlend();
- GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
- GlStateManager.disableTexture2D();
- GlStateManager.depthMask(false);
-
- String special = NotEnoughUpdates.INSTANCE.config.itemOverlays.wandOverlayColour;
-
- AxisAlignedBB bb = Blocks.dirt.getSelectedBoundingBox(Minecraft.getMinecraft().theWorld, hover);
- drawBlock((int)bb.minX, (int)bb.minY, (int)bb.minZ+1, Blocks.dirt.getDefaultState(),
- event.partialTicks, 0.75f);
-
- AxisAlignedBB bbExpanded = Blocks.dirt.getSelectedBoundingBox(Minecraft.getMinecraft().theWorld, hover)
- .expand(0.001D, 0.001D, 0.001D).offset(-d0, -d1, -d2);
- drawOutlineBoundingBox(bbExpanded, 1f, special);
-
- GlStateManager.depthMask(true);
- GlStateManager.enableTexture2D();
- GlStateManager.disableBlend();
- }
- } else if((heldInternal.equals("WATER_BUCKET") || heldInternal.equals("MAGICAL_WATER_BUCKET") && NotEnoughUpdates.INSTANCE.config.itemOverlays.enablePrismapumpOverlay && onPrivateIsland) &&
- event.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
- BlockPos hover = event.target.getBlockPos().offset(event.target.sideHit, 1);
-
- HashSet<BlockPos> verticalSources = new HashSet<>();
- TreeMap<Float, HashMap<BlockPos, EnumFacing>> watersSorted = new TreeMap<>();
-
- for(int xOff=-1; xOff<=1; xOff++) {
- for(int yOff=0; yOff<=1; yOff++) {
- for(int zOff=-1; zOff<=1; zOff++) {
- if((xOff == 0 && yOff == 0) ||
- (xOff == 0 && zOff == 0) ||
- (zOff == 0 && yOff == 0)) {
-
- BlockPos checkPos = hover.add(-xOff, -yOff, -zOff);
- IBlockState check = Minecraft.getMinecraft().theWorld.getBlockState(checkPos);
- if(check.getBlock() == Blocks.prismarine && check.getBlock().getMetaFromState(check) == 2) {
- for(int i=0; i<300; i++) {
- BlockPos renderPos = hover.add(xOff*i, yOff*i, zOff*i);
-
- if(Math.abs(renderPos.getX()) > 128) {
- break;
- }
- if(Math.abs(renderPos.getY()) > 255) {
- break;
- }
- if(Math.abs(renderPos.getZ()) > 128) {
- break;
- }
-
- IBlockState renderState = Minecraft.getMinecraft().theWorld.getBlockState(renderPos);
-
- if(renderState.getBlock() != Blocks.air && renderState.getBlock() != Blocks.water &&
- renderState.getBlock() != Blocks.flowing_water) {
- break;
- }
-
- if(yOff != 0) {
- verticalSources.add(renderPos);
- } else {
- IBlockState belowState = Minecraft.getMinecraft().theWorld.getBlockState(renderPos.add(0, -1, 0));
- if(belowState.getBlock() == Blocks.air) {
- break;
- }
- }
-
- for(EnumFacing facing : EnumFacing.values()) {
- float xDist = (float)(renderPos.getX()+0.5f+0.5f*facing.getFrontOffsetX()-d0);
- float yDist = (float)(renderPos.getY()+0.5f+0.5f*facing.getFrontOffsetY()-d1-player.getEyeHeight());
- float zDist = (float)(renderPos.getZ()+0.5f+0.5f*facing.getFrontOffsetZ()-d2);
-
- float distSq = xDist*xDist + yDist*yDist + zDist*zDist;
-
- watersSorted.computeIfAbsent(distSq, k->new HashMap<>()).put(renderPos, facing);
- }
-
- }
- }
- }
- }
- }
- }
-
- GlStateManager.enableDepth();
- GlStateManager.enableBlend();
- GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
- GlStateManager.disableTexture2D();
- GlStateManager.depthMask(true);
-
- for(HashMap<BlockPos, EnumFacing> blockPoses : watersSorted.values()) {
- for(Map.Entry<BlockPos, EnumFacing> entry : blockPoses.entrySet()) {
- boolean vertical = verticalSources.contains(entry.getKey());
- AxisAlignedBB bbExpanded = Blocks.water.getSelectedBoundingBox(Minecraft.getMinecraft().theWorld, entry.getKey())
- .expand(-0.001D, -0.001D-(vertical?0:0.0625D), -0.001D)
- .offset(-d0, -d1-(vertical?0:0.0625), -d2);
- drawFilledBoundingBoxSide(bbExpanded, entry.getValue(), 1f, "0:100:20:50:160");
- }
- }
-
- GlStateManager.depthMask(true);
- GlStateManager.enableTexture2D();
- GlStateManager.disableBlend();
- } else if((heldInternal.equals("HOE_OF_GREAT_TILLING") || heldInternal.equals("HOE_OF_GREATER_TILLING") && onPrivateIsland) &&
- event.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
- BlockPos target = event.target.getBlockPos();
- IBlockState targetState = Minecraft.getMinecraft().theWorld.getBlockState(target);
-
- int radius = heldInternal.equals("HOE_OF_GREAT_TILLING") ? 1 : 2;
-
- if(targetState.getBlock() == Blocks.dirt || targetState.getBlock() == Blocks.grass) {
- GlStateManager.enableDepth();
- GlStateManager.enableBlend();
- GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
- GlStateManager.disableTexture2D();
- GlStateManager.depthMask(true);
-
- for(int xOff=-radius; xOff<=radius; xOff++) {
- for(int zOff=-radius; zOff<=radius; zOff++) {
- BlockPos renderPos = target.add(xOff, 0, zOff);
- IBlockState renderState = Minecraft.getMinecraft().theWorld.getBlockState(renderPos);
- if(renderState.getBlock() == Blocks.dirt || renderState.getBlock() == Blocks.grass) {
- AxisAlignedBB bbExpanded = Blocks.dirt.getSelectedBoundingBox(Minecraft.getMinecraft().theWorld, renderPos)
- .expand(0.001D, 0.001D, 0.001D)
- .offset(-d0, -d1, -d2);
- drawFilledBoundingBox(bbExpanded, 1f, "0:100:178:34:34");
- }
- }
- }
-
- GlStateManager.depthMask(true);
- GlStateManager.enableTexture2D();
- GlStateManager.disableBlend();
- }
- }
- }
- }
- }
-
- public void getBuildersWandCandidates(EntityPlayer player, MovingObjectPosition target, float partialTicks,
- HashSet<BlockPos> candidatesOld, TreeMap<Float, Set<BlockPos>> candidatesOldSorted, int extraMax) {
- IBlockState match = Minecraft.getMinecraft().theWorld.getBlockState(target.getBlockPos());
-
- candidatesOld.clear();
- candidatesOldSorted.clear();
- LinkedList<BlockPos> candidates = new LinkedList<>();
- LinkedList<BlockPos> candidatesNew = new LinkedList<>();
-
- candidatesNew.add(target.getBlockPos());
-
- double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double)partialTicks;
- double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double)partialTicks;
- double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double)partialTicks;
-
- while(candidatesOld.size() <= MAX_BUILDERS_BLOCKS+extraMax) {
- if(candidatesNew.isEmpty()) {
- break;
- }
-
- candidates.addAll(candidatesNew);
- candidatesNew.clear();
-
- while(!candidates.isEmpty()) {
- if(candidatesOld.size() > MAX_BUILDERS_BLOCKS+extraMax) break;
-
- BlockPos candidate = candidates.pop();
-
- float distSq = (float)((candidate.getX()+0.5f-d0)*(candidate.getX()+0.5f-d0) +
- (candidate.getY()+0.5f-d1-player.getEyeHeight())*(candidate.getY()+0.5f-d1-player.getEyeHeight()) +
- (candidate.getZ()+0.5f-d2)*(candidate.getZ()+0.5f-d2));
- candidatesOldSorted.computeIfAbsent(distSq, k->new HashSet<>()).add(candidate);
-
- candidatesOld.add(candidate);
-
- for(int x = -1; x <= 1; x++) {
- for(int y = -1; y <= 1; y++) {
- for(int z = -1; z <= 1; z++) {
- if(x*x+y*y+z*z == 1) {
- if(((x == 0) && (target.sideHit.getAxis() == EnumFacing.Axis.X)) ||
- ((y == 0) && (target.sideHit.getAxis() == EnumFacing.Axis.Y)) ||
- ((z == 0) && (target.sideHit.getAxis() == EnumFacing.Axis.Z))) {
- if(Minecraft.getMinecraft().theWorld.getBlockState(candidate.add(
- x+target.sideHit.getFrontOffsetX(),
- y+target.sideHit.getFrontOffsetY(),
- z+target.sideHit.getFrontOffsetZ())).getBlock() == Blocks.air) {
- BlockPos posNew = candidate.add(x, y, z);
- if(!candidatesOld.contains(posNew) && !candidates.contains(posNew) && !candidatesNew.contains(posNew)) {
- IBlockState blockNew = Minecraft.getMinecraft().theWorld.getBlockState(posNew);
- if(blockNew == match) {
- candidatesNew.add(posNew);
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
-
- public static void drawBlock(int x, int y, int z, IBlockState state, float partialTicks, float brightness) {
- EntityPlayerSP player = Minecraft.getMinecraft().thePlayer;
- double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double)partialTicks;
- double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double)partialTicks;
- double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double)partialTicks;
-
- BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
-
- GlStateManager.enableTexture2D();
- GlStateManager.disableLighting();
- GlStateManager.enableBlend();
- GlStateManager.blendFunc(770, 771);
-
- GlStateManager.enableDepth();
- GlStateManager.depthMask(true);
- GlStateManager.enableCull();
- GlStateManager.cullFace(GL11.GL_BACK);
-
- GlStateManager.pushMatrix();
- GlStateManager.translate(x-d0, y-d1, z-d2);
-
- int i = state.getBlock().getRenderType();
- if(i == 3) {
- IBakedModel ibakedmodel = blockrendererdispatcher.getModelFromBlockState(state, Minecraft.getMinecraft().theWorld, null);
-
- Block block = state.getBlock();
- block.setBlockBoundsForItemRender();
- GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F);
- int colour = block.getRenderColor(block.getStateForEntityRender(state));
-
- if (EntityRenderer.anaglyphEnable) {
- colour = TextureUtil.anaglyphColor(i);
- }
-
- colour = (colour & 0x00FFFFFF) | (100 << 24); //Set alpha to 100
-
- for (EnumFacing enumfacing : EnumFacing.values()) {
- renderModelBrightnessColorQuads(colour, ibakedmodel.getFaceQuads(enumfacing));
- }
-
- renderModelBrightnessColorQuads(colour, ibakedmodel.getGeneralQuads());
- }
-
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
- GlStateManager.translate(-x+d0, -y+d1, -z+d2);
- GlStateManager.popMatrix();
- }
-
- private static void renderModelBrightnessColorQuads(int c, List<BakedQuad> listQuads) {
- Tessellator tessellator = Tessellator.getInstance();
- WorldRenderer worldrenderer = tessellator.getWorldRenderer();
-
- for (BakedQuad bakedquad : listQuads) {
- worldrenderer.begin(7, DefaultVertexFormats.ITEM);
- worldrenderer.addVertexData(bakedquad.getVertexData());
-
- worldrenderer.putColor4(c);
-
- Vec3i vec3i = bakedquad.getFace().getDirectionVec();
- worldrenderer.putNormal((float)vec3i.getX(), (float)vec3i.getY(), (float)vec3i.getZ());
- tessellator.draw();
- }
- }
-
- public static void drawFilledBoundingBox(AxisAlignedBB p_181561_0_, float alpha, String special) {
- Color c = new Color(SpecialColour.specialToChromaRGB(special), true);
-
- GlStateManager.enableBlend();
- GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
- GlStateManager.disableTexture2D();
-
- Tessellator tessellator = Tessellator.getInstance();
- WorldRenderer worldrenderer = tessellator.getWorldRenderer();
-
- GlStateManager.color(c.getRed()/255f, c.getGreen()/255f, c.getBlue()/255f, c.getAlpha()/255f*alpha);
-
- //vertical
- worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex();
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex();
- tessellator.draw();
- worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
- tessellator.draw();
-
-
- GlStateManager.color(c.getRed()/255f*0.8f, c.getGreen()/255f*0.8f, c.getBlue()/255f*0.8f, c.getAlpha()/255f*alpha);
-
- //x
- worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex();
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex();
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
- tessellator.draw();
- worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex();
- tessellator.draw();
-
-
- GlStateManager.color(c.getRed()/255f*0.9f, c.getGreen()/255f*0.9f, c.getBlue()/255f*0.9f, c.getAlpha()/255f*alpha);
- //z
- worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
- tessellator.draw();
- worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex();
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex();
- tessellator.draw();
- }
-
- public static void drawFilledBoundingBoxSide(AxisAlignedBB p_181561_0_, EnumFacing facing, float alpha, String special) {
- Color c = new Color(SpecialColour.specialToChromaRGB(special), true);
- GlStateManager.color(c.getRed()/255f, c.getGreen()/255f, c.getBlue()/255f, c.getAlpha()/255f*alpha);
-
- GlStateManager.enableBlend();
- GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
- GlStateManager.disableTexture2D();
-
- Tessellator tessellator = Tessellator.getInstance();
- WorldRenderer worldrenderer = tessellator.getWorldRenderer();
- worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
- switch(facing) {
- case UP:
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex();
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex();
- break;
- case DOWN:
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex();
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex();
- break;
- case EAST:
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex();
- break;
- case WEST:
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex();
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex();
- break;
- case SOUTH:
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex();
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex();
- break;
- case NORTH:
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
- break;
- }
- tessellator.draw();
- }
-
- public static void drawOutlineBoundingBox(AxisAlignedBB p_181561_0_, float alpha, String special) {
- Color c = new Color(SpecialColour.specialToChromaRGB(special), true);
- float newAlpha = c.getAlpha()/255f*alpha;
- if(newAlpha > 1) newAlpha = 1;
- GlStateManager.color(c.getRed()/255f, c.getGreen()/255f, c.getBlue()/255f, newAlpha);
-
- GlStateManager.enableBlend();
- GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
- GlStateManager.disableTexture2D();
- GlStateManager.depthMask(false);
-
- GL11.glLineWidth(3);
-
- Tessellator tessellator = Tessellator.getInstance();
- WorldRenderer worldrenderer = tessellator.getWorldRenderer();
- worldrenderer.begin(3, DefaultVertexFormats.POSITION);
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex();
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex();
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
- tessellator.draw();
- worldrenderer.begin(3, DefaultVertexFormats.POSITION);
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex();
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex();
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
- tessellator.draw();
- worldrenderer.begin(1, DefaultVertexFormats.POSITION);
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex();
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex();
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex();
- tessellator.draw();
-
- GL11.glLineWidth(1);
- }
-
+ public static final CustomItemEffects INSTANCE = new CustomItemEffects();
+
+ private static final int MAX_BUILDERS_BLOCKS = 241;
+
+ private final HashSet<BlockPos> zapperBlocks = new HashSet<>();
+ private boolean zapperDirty = false;
+
+ public long aoteUseMillis = 0;
+
+ public long lastUsedHyperion = 0;
+
+ private final Pattern etherwarpDistancePattern = Pattern.compile("up to (?<distance>\\d{2}) blocks away\\.");
+
+ public int aoteTeleportationMillis = 0;
+ public Vector3f aoteTeleportationCurr = null;
+
+ public int tpTime = NotEnoughUpdates.INSTANCE.config.itemOverlays.smoothTpMillis;
+
+ private int tick;
+
+ public long lastMillis = 0;
+
+ public Vector3f getCurrentPosition() {
+ if (aoteTeleportationMillis <= 0) return null;
+ return aoteTeleportationCurr;
+ }
+
+ @SubscribeEvent
+ public void onTick(TickEvent.RenderTickEvent event) {
+ if (Minecraft.getMinecraft().thePlayer == null) return;
+
+ zapperDirty = true;
+
+ long currentTime = System.currentTimeMillis();
+ int delta = (int) (currentTime - lastMillis);
+ lastMillis = currentTime;
+
+ if (delta <= 0) return;
+
+ if (aoteTeleportationMillis > tpTime * 2) {
+ aoteTeleportationMillis = tpTime * 2;
+ }
+ if (aoteTeleportationMillis < 0) aoteTeleportationMillis = 0;
+
+ if (currentTime - aoteUseMillis > 1000 && aoteTeleportationMillis <= 0) {
+ aoteTeleportationCurr = null;
+ }
+
+ if (aoteTeleportationCurr != null) {
+ if (aoteTeleportationMillis > 0) {
+ int deltaMin = Math.min(delta, aoteTeleportationMillis);
+
+ float factor = deltaMin / (float) aoteTeleportationMillis;
+
+ float dX = aoteTeleportationCurr.x - (float) Minecraft.getMinecraft().thePlayer.posX;
+ float dY = aoteTeleportationCurr.y - (float) Minecraft.getMinecraft().thePlayer.posY;
+ float dZ = aoteTeleportationCurr.z - (float) Minecraft.getMinecraft().thePlayer.posZ;
+
+ aoteTeleportationCurr.x -= dX * factor;
+ aoteTeleportationCurr.y -= dY * factor;
+ aoteTeleportationCurr.z -= dZ * factor;
+
+ if (Minecraft.getMinecraft().theWorld.getBlockState(new BlockPos(aoteTeleportationCurr.x,
+ aoteTeleportationCurr.y, aoteTeleportationCurr.z
+ )).getBlock().getMaterial() != Material.air) {
+ aoteTeleportationCurr.y = (float) Math.ceil(aoteTeleportationCurr.y);
+ }
+
+ aoteTeleportationMillis -= deltaMin;
+ } else {
+ aoteTeleportationCurr.x = (float) Minecraft.getMinecraft().thePlayer.posX;
+ aoteTeleportationCurr.y = (float) Minecraft.getMinecraft().thePlayer.posY;
+ aoteTeleportationCurr.z = (float) Minecraft.getMinecraft().thePlayer.posZ;
+ }
+ } else {
+ aoteUseMillis = 0;
+ aoteTeleportationMillis = 0;
+ }
+ }
+
+ @SubscribeEvent
+ public void onPlayerInteract(PlayerInteractEvent event) {
+ if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR ||
+ event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
+ ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem();
+ String internal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held);
+ if (internal != null) {
+ boolean shadowWarp = false;
+ if (internal.equals("HYPERION") || internal.equals("VALKYRIE") || internal.equals("SCYLLA") || internal.equals(
+ "ASTRAEA")) {
+ NBTTagCompound tag = held.getTagCompound();
+ if (tag != null && tag.hasKey("ExtraAttributes", 10)) {
+ NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
+ if (ea != null && ea.hasKey("ability_scroll", 9)) {
+ NBTTagList list = ea.getTagList("ability_scroll", 8);
+ for (int i = 0; i < list.tagCount(); i++) {
+ if (list.getStringTagAt(i).equals("IMPLOSION_SCROLL")) {
+ lastUsedHyperion = System.currentTimeMillis();
+ } else if (list.getStringTagAt(i).equals("SHADOW_WARP_SCROLL")) {
+ shadowWarp = true;
+ }
+ }
+ }
+ }
+ }
+
+ if (usingEtherwarp) {
+ lastEtherwarpUse = tick;
+ }
+
+ if (tpTime <= 0 || Minecraft.getMinecraft().gameSettings.thirdPersonView != 0) return;
+
+ boolean aote = NotEnoughUpdates.INSTANCE.config.itemOverlays.enableSmoothAOTE &&
+ (internal.equals("ASPECT_OF_THE_END") || internal.equals("ASPECT_OF_THE_VOID"));
+ boolean hyp = NotEnoughUpdates.INSTANCE.config.itemOverlays.enableSmoothHyperion && shadowWarp;
+ if (usingEtherwarp) {
+ tpTime = NotEnoughUpdates.INSTANCE.config.itemOverlays.smoothTpMillisEtherwarp;
+ } else {
+ tpTime = NotEnoughUpdates.INSTANCE.config.itemOverlays.smoothTpMillis;
+ }
+ if (usingEtherwarp || aote || hyp) {
+ aoteUseMillis = System.currentTimeMillis();
+ if (aoteTeleportationCurr == null) {
+ aoteTeleportationCurr = new Vector3f();
+ aoteTeleportationCurr.x = (float) Minecraft.getMinecraft().thePlayer.posX;
+ aoteTeleportationCurr.y = (float) Minecraft.getMinecraft().thePlayer.posY;
+ aoteTeleportationCurr.z = (float) Minecraft.getMinecraft().thePlayer.posZ;
+ }
+ }
+ }
+ }
+ }
+
+ @SubscribeEvent
+ public void onGameTick(TickEvent.ClientTickEvent event) {
+ if (event.phase != TickEvent.Phase.END) return;
+
+ if (!usingEtherwarp && wasUsingEtherwarp) {
+ if (Minecraft.getMinecraft().thePlayer.rotationYaw > 0) {
+ Minecraft.getMinecraft().thePlayer.rotationYaw -= 0.000001;
+ } else {
+ Minecraft.getMinecraft().thePlayer.rotationYaw += 0.000001;
+ }
+ }
+ wasUsingEtherwarp = usingEtherwarp;
+
+ tick++;
+ if (tick > Integer.MAX_VALUE / 2) tick = 0;
+
+ }
+
+ private float lastPartialTicks = 0;
+ private float currentFOVMult = 1;
+ private float targetFOVMult = 1;
+
+ private float lastPartialDelta = 0;
+
+ private float currentSensMult = 1;
+ private float targetSensMult = 1;
+
+ public float getSensMultiplier() {
+ if (targetSensMult < 0) {
+ currentSensMult = 1;
+ } else {
+ float deltaSens = targetSensMult - currentSensMult;
+
+ currentSensMult += deltaSens * lastPartialDelta * 0.1;// (0.05 * );
+ if (currentSensMult < 0.25f) currentSensMult = 0.25f;
+ if (currentSensMult > 1) currentSensMult = 1;
+ }
+ return currentSensMult;
+ }
+
+ public float getFovMultiplier(float partialTicks) {
+ float partialDelta = partialTicks + tick - lastPartialTicks;
+ if (partialDelta < 0) partialDelta++;
+
+ if (partialDelta > 0) lastPartialDelta = partialDelta;
+
+ if (targetFOVMult < 0) {
+ currentFOVMult = 1;
+ } else {
+ float deltaFOV = targetFOVMult - currentFOVMult;
+
+ currentFOVMult += deltaFOV * lastPartialDelta * 0.2;
+ if (currentFOVMult < 0.15f) currentFOVMult = 0.15f;
+ if (currentFOVMult > 1) currentFOVMult = 1;
+ }
+ lastPartialTicks = partialTicks + tick;
+ return currentFOVMult;
+ }
+
+ private boolean wasUsingEtherwarp = false;
+ private boolean usingEtherwarp = false;
+ private RaycastResult etherwarpRaycast = null;
+ private int lastEtherwarpUse = 0;
+
+ @SubscribeEvent
+ public void onOverlayDrawn(RenderGameOverlayEvent.Post event) {
+ if (((event.type == null && Loader.isModLoaded("labymod")) ||
+ event.type == RenderGameOverlayEvent.ElementType.CROSSHAIRS)) {
+ ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem();
+ String heldInternal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held);
+
+ if (usingEtherwarp && NotEnoughUpdates.INSTANCE.config.itemOverlays.enableEtherwarpHelperOverlay) {
+ String denyTpReason = null;
+ if (etherwarpRaycast == null) {
+ denyTpReason = "Too far!";
+ } else {
+ BlockPos pos = etherwarpRaycast.pos;
+
+ if (!etherwarpRaycast.state.getBlock().isCollidable() ||
+ etherwarpRaycast.state.getBlock().getCollisionBoundingBox(
+ Minecraft.getMinecraft().theWorld,
+ etherwarpRaycast.pos,
+ etherwarpRaycast.state
+ ) == null) {
+ denyTpReason = "Not solid!";
+ } else {
+ WorldClient world = Minecraft.getMinecraft().theWorld;
+ Block above = world.getBlockState(pos.add(0, 1, 0)).getBlock();
+ if (above != Blocks.air && above.isCollidable() &&
+ above.getCollisionBoundingBox(Minecraft.getMinecraft().theWorld, pos.add(0, 1, 0),
+ world.getBlockState(pos.add(0, 1, 0))
+ ) != null ||
+ world.getBlockState(pos.add(0, 2, 0)).getBlock() != Blocks.air) {
+ denyTpReason = "No air above!";
+ }
+ }
+ }
+
+ if (denyTpReason != null) {
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ Utils.drawStringCentered(EnumChatFormatting.RED + "Can't TP: " + denyTpReason,
+ Minecraft.getMinecraft().fontRendererObj,
+ scaledResolution.getScaledWidth() / 2f, scaledResolution.getScaledHeight() / 2f + 10, true, 0
+ );
+ GlStateManager.color(1, 1, 1, 1);
+ }
+ }
+
+ boolean onPrivateIsland = SBInfo.getInstance().getLocation() == null || SBInfo.getInstance().getLocation().equals(
+ "dynamic");
+
+ if (NotEnoughUpdates.INSTANCE.config.itemOverlays.enableWandOverlay &&
+ Minecraft.getMinecraft().objectMouseOver != null &&
+ Minecraft.getMinecraft().objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK &&
+ onPrivateIsland) {
+
+ IBlockState hover = Minecraft.getMinecraft().theWorld.getBlockState(
+ Minecraft.getMinecraft().objectMouseOver.getBlockPos().offset(
+ Minecraft.getMinecraft().objectMouseOver.sideHit, 1));
+ if (hover.getBlock() == Blocks.air) {
+
+ if (heldInternal != null && heldInternal.equals("BUILDERS_WAND")) {
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+
+ HashSet<BlockPos> candidatesOld = new HashSet<>();
+ TreeMap<Float, Set<BlockPos>> candidatesOldSorted = new TreeMap<>();
+
+ IBlockState match =
+ Minecraft.getMinecraft().theWorld.getBlockState(Minecraft.getMinecraft().objectMouseOver.getBlockPos());
+ Item matchItem = Item.getItemFromBlock(match.getBlock());
+ if (matchItem != null) {
+ ItemStack matchStack = new ItemStack(matchItem, 1,
+ match
+ .getBlock()
+ .getDamageValue(
+ Minecraft.getMinecraft().theWorld,
+ Minecraft.getMinecraft().objectMouseOver.getBlockPos()
+ )
+ );
+
+ getBuildersWandCandidates(
+ Minecraft.getMinecraft().thePlayer,
+ Minecraft.getMinecraft().objectMouseOver,
+ event.partialTicks,
+ candidatesOld,
+ candidatesOldSorted,
+ 999 - MAX_BUILDERS_BLOCKS
+ );
+
+ boolean usingDirtWand = false;
+ int itemCount;
+ if (match.getBlock() == Blocks.dirt && matchStack.getItemDamage() == 0 && hasDirtWand()) {
+ itemCount = candidatesOld.size();
+ usingDirtWand = true;
+ } else {
+ itemCount = countItemsInInventoryAndStorage(matchStack);
+ }
+
+ if (candidatesOld.size() > MAX_BUILDERS_BLOCKS) {
+ Utils.drawStringCentered(
+ EnumChatFormatting.RED.toString() + candidatesOld.size() + "/" + MAX_BUILDERS_BLOCKS,
+ Minecraft.getMinecraft().fontRendererObj,
+ scaledResolution.getScaledWidth() / 2f,
+ scaledResolution.getScaledHeight() / 2f + 10,
+ true,
+ 0
+ );
+ } else {
+ String pre = EnumChatFormatting.GREEN.toString();
+ if (itemCount < candidatesOld.size()) {
+ pre = EnumChatFormatting.RED.toString();
+ }
+ Utils.drawStringCentered(pre + Math.min(candidatesOld.size(), itemCount) + "/" +
+ Math.min(candidatesOld.size(), MAX_BUILDERS_BLOCKS),
+ Minecraft.getMinecraft().fontRendererObj,
+ scaledResolution.getScaledWidth() / 2f, scaledResolution.getScaledHeight() / 2f + 10, true, 0
+ );
+ }
+
+ String itemCountS = EnumChatFormatting.DARK_GRAY + "x" + EnumChatFormatting.RESET + itemCount;
+ int itemCountLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(itemCountS);
+
+ if (NotEnoughUpdates.INSTANCE.config.itemOverlays.wandBlockCount) {
+ if (usingDirtWand) {
+ Utils.drawItemStack(
+ new ItemStack(Items.gold_nugget),
+ scaledResolution.getScaledWidth() / 2 - (itemCountLen + 16) / 2,
+ scaledResolution.getScaledHeight() / 2 + 10 + 4
+ );
+ Minecraft.getMinecraft().fontRendererObj.drawString(
+ itemCountS,
+ scaledResolution.getScaledWidth() / 2f - (itemCountLen + 16) / 2f + 11,
+ scaledResolution.getScaledHeight() / 2f + 10 + 8,
+ -1,
+ true
+ );
+ } else {
+ Utils.drawItemStack(matchStack, scaledResolution.getScaledWidth() / 2 - (itemCountLen + 16) / 2,
+ scaledResolution.getScaledHeight() / 2 + 10 + 4
+ );
+ Minecraft.getMinecraft().fontRendererObj.drawString(
+ itemCountS,
+ scaledResolution.getScaledWidth() / 2f - (itemCountLen + 16) / 2f + 16,
+ scaledResolution.getScaledHeight() / 2f + 10 + 8,
+ -1,
+ true
+ );
+ }
+
+ }
+
+ GlStateManager.color(1, 1, 1, 1);
+ }
+
+ }
+ }
+ }
+ }
+ }
+ //ethermerge
+
+ private static class RaycastResult {
+ IBlockState state;
+ BlockPos pos;
+
+ public RaycastResult(IBlockState state, BlockPos pos) {
+ this.state = state;
+ this.pos = pos;
+ }
+ }
+
+ private RaycastResult raycast(EntityPlayerSP player, float partialTicks, float dist, float step) {
+ Vector3f pos = new Vector3f((float) player.posX, (float) player.posY + player.getEyeHeight(), (float) player.posZ);
+
+ Vec3 lookVec3 = player.getLook(partialTicks);
+
+ Vector3f look = new Vector3f((float) lookVec3.xCoord, (float) lookVec3.yCoord, (float) lookVec3.zCoord);
+ look.scale(step / look.length());
+
+ int stepCount = (int) Math.ceil(dist / step);
+
+ for (int i = 0; i < stepCount; i++) {
+ Vector3f.add(pos, look, pos);
+
+ WorldClient world = Minecraft.getMinecraft().theWorld;
+ BlockPos position = new BlockPos(pos.x, pos.y, pos.z);
+ IBlockState state = world.getBlockState(position);
+
+ if (state.getBlock() != Blocks.air) {
+ //Back-step
+ Vector3f.sub(pos, look, pos);
+ look.scale(0.1f);
+
+ for (int j = 0; j < 10; j++) {
+ Vector3f.add(pos, look, pos);
+
+ BlockPos position2 = new BlockPos(pos.x, pos.y, pos.z);
+ IBlockState state2 = world.getBlockState(position2);
+
+ if (state2.getBlock() != Blocks.air) {
+ return new RaycastResult(state2, position2);
+ }
+ }
+
+ return new RaycastResult(state, position);
+ }
+ }
+
+ return null;
+ }
+
+ public int countItemsInInventoryAndStorage(ItemStack match) {
+ int count = 0;
+
+ for (ItemStack stack : Minecraft.getMinecraft().thePlayer.inventory.mainInventory) {
+ if (match.isItemEqual(stack)) {
+ count += stack.stackSize;
+ }
+ }
+
+ ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem();
+ String heldInternal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held);
+
+ if (heldInternal != null && heldInternal.equals("BUILDERS_WAND")) {
+ if (held.hasTagCompound() && held.getTagCompound().hasKey("ExtraAttributes", 10) &&
+ held.getTagCompound().getCompoundTag("ExtraAttributes").hasKey("builder's_wand_data", 7)) {
+ byte[] bytes = held.getTagCompound().getCompoundTag("ExtraAttributes").getByteArray("builder's_wand_data");
+ try {
+ NBTTagCompound contents_nbt = CompressedStreamTools.readCompressed(new ByteArrayInputStream(bytes));
+ NBTTagList items = contents_nbt.getTagList("i", 10);
+ for (int j = 0; j < items.tagCount(); j++) {
+ NBTTagCompound buildersItem = items.getCompoundTagAt(j);
+ if (buildersItem.getKeySet().size() > 0) {
+ if (buildersItem.getInteger("id") == Item.getIdFromItem(match.getItem()) &&
+ buildersItem.getInteger("Damage") == match.getItemDamage()) {
+ count += items.getCompoundTagAt(j).getByte("Count");
+ }
+ }
+ }
+ } catch (Exception e) {
+ return count;
+ }
+ }
+ }
+
+ return count;
+ }
+
+ public boolean hasDirtWand() {
+ for (ItemStack stack : Minecraft.getMinecraft().thePlayer.inventory.mainInventory) {
+ String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack);
+ if (internalname != null && internalname.equals("INFINIDIRT_WAND")) {
+ return true;
+ }
+ }
+
+ ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem();
+ String heldInternal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held);
+
+ if (heldInternal != null && heldInternal.equals("BUILDERS_WAND")) {
+ if (held.hasTagCompound() && held.getTagCompound().hasKey("ExtraAttributes", 10) &&
+ held.getTagCompound().getCompoundTag("ExtraAttributes").hasKey("builder's_wand_data", 7)) {
+ byte[] bytes = held.getTagCompound().getCompoundTag("ExtraAttributes").getByteArray("builder's_wand_data");
+ try {
+ NBTTagCompound contents_nbt = CompressedStreamTools.readCompressed(new ByteArrayInputStream(bytes));
+ NBTTagList items = contents_nbt.getTagList("i", 10);
+ for (int j = 0; j < items.tagCount(); j++) {
+ NBTTagCompound buildersItem = items.getCompoundTagAt(j);
+ if (buildersItem.getKeySet().size() > 0) {
+ String internalname =
+ NotEnoughUpdates.INSTANCE.manager.getInternalnameFromNBT(buildersItem.getCompoundTag("tag"));
+ if (internalname != null && internalname.equals("INFINIDIRT_WAND")) {
+ return true;
+ }
+ }
+ }
+ } catch (Exception ignored) {
+ }
+ }
+ }
+
+ return false;
+ }
+
+ private static final List<BlockPos> zapperOffsets = new ArrayList<BlockPos>() {{
+ add(new BlockPos(0, 0, -1));
+ add(new BlockPos(0, 0, 1));
+ add(new BlockPos(-1, 0, 0));
+ add(new BlockPos(1, 0, 0));
+ add(new BlockPos(0, 1, 0));
+ add(new BlockPos(0, -1, 0));
+ }};
+
+ private static final HashSet<Block> cropBlocksZapper = new HashSet<Block>() {{
+ add(Blocks.wheat);
+ add(Blocks.carrots);
+ add(Blocks.potatoes);
+ add(Blocks.pumpkin);
+ add(Blocks.pumpkin_stem);
+ add(Blocks.melon_block);
+ add(Blocks.melon_stem);
+ add(Blocks.cactus);
+ add(Blocks.reeds);
+ add(Blocks.nether_wart);
+ add(Blocks.tallgrass);
+ add(Blocks.double_plant);
+ }};
+
+ private static final HashSet<Block> otherBannedBlocksZapper = new HashSet<Block>() {{
+ add(Blocks.farmland);
+ }};
+
+ @SubscribeEvent
+ public void renderBlockOverlay(DrawBlockHighlightEvent event) {
+ if (aoteTeleportationCurr != null && aoteTeleportationMillis > 0) {
+ event.setCanceled(true);
+ }
+ usingEtherwarp = false;
+ etherwarpRaycast = null;
+ float lastFOVMult = this.targetFOVMult;
+ this.targetFOVMult = 1;
+ this.targetSensMult = 1;
+
+ ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem();
+ String heldInternal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held);
+ if (heldInternal != null) {
+ boolean onPrivateIsland = SBInfo.getInstance().getLocation() == null || SBInfo.getInstance().getLocation().equals(
+ "dynamic");
+ EntityPlayer player = event.player;
+ double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double) event.partialTicks;
+ double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double) event.partialTicks;
+ double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double) event.partialTicks;
+
+ if (tick - lastEtherwarpUse > 10) {
+ boolean aotv = Minecraft.getMinecraft().thePlayer.isSneaking() &&
+ (heldInternal.equals("ASPECT_OF_THE_VOID") || heldInternal.equals("ASPECT_OF_THE_END"));
+ if (aotv || heldInternal.equals("ETHERWARP_CONDUIT")) {
+ usingEtherwarp = !aotv;
+
+ if (aotv) {
+ NBTTagCompound tag = held.getTagCompound();
+ if (tag != null && tag.hasKey("ExtraAttributes", 10)) {
+ NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
+ usingEtherwarp = ea.hasKey("ethermerge");
+ }
+ }
+
+ if (usingEtherwarp) {
+ int dist = 0;
+ for (String line : NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(held.getTagCompound())) {
+ String cleaned = Utils.cleanColour(line);
+ Matcher matcher = etherwarpDistancePattern.matcher(cleaned);
+ if (matcher.matches()) {
+ dist = Integer.parseInt(matcher.group("distance"));
+ break;
+ }
+ }
+ if (dist != 0) {
+ etherwarpRaycast = raycast(Minecraft.getMinecraft().thePlayer, 1f, dist, 0.1f);
+
+ if (etherwarpRaycast != null &&
+ NotEnoughUpdates.INSTANCE.config.itemOverlays.enableEtherwarpBlockOverlay) {
+ AxisAlignedBB bb = etherwarpRaycast.state.getBlock().getSelectedBoundingBox(
+ Minecraft.getMinecraft().theWorld,
+ etherwarpRaycast.pos
+ )
+ .expand(0.01D, 0.01D, 0.01D).offset(-d0, -d1, -d2);
+ drawFilledBoundingBox(bb, 1f, NotEnoughUpdates.INSTANCE.config.itemOverlays.etherwarpHighlightColour);
+
+ GlStateManager.disableDepth();
+ drawOutlineBoundingBox(bb, 2f, NotEnoughUpdates.INSTANCE.config.itemOverlays.etherwarpHighlightColour);
+ GlStateManager.enableDepth();
+
+ GlStateManager.depthMask(true);
+ GlStateManager.enableTexture2D();
+ GlStateManager.disableBlend();
+
+ if (NotEnoughUpdates.INSTANCE.config.itemOverlays.etherwarpZoom) {
+ float distFactor = 1 -
+ (float) Math.sqrt(etherwarpRaycast.pos.distanceSq(Minecraft.getMinecraft().thePlayer.getPosition())) /
+ 60;
+
+ targetFOVMult = distFactor * distFactor * distFactor * 0.75f + 0.25f;
+ if (targetFOVMult < 0.25f) targetFOVMult = 0.25f;
+
+ targetSensMult = distFactor * 0.76f + 0.25f;
+ }
+ } else if (NotEnoughUpdates.INSTANCE.config.itemOverlays.etherwarpZoom) {
+ targetFOVMult = lastFOVMult;
+ }
+
+ return;
+ }
+ }
+ }
+ }
+
+ if (heldInternal.equals("BLOCK_ZAPPER")) {
+
+ if (!onPrivateIsland || !NotEnoughUpdates.INSTANCE.config.itemOverlays.enableZapperOverlay ||
+ event.target.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) {
+ zapperBlocks.clear();
+ return;
+ }
+ if (zapperDirty) {
+ zapperDirty = false;
+
+ zapperBlocks.clear();
+
+ LinkedList<BlockPos> returnablePositions = new LinkedList<>();
+
+ BlockPos pos = event.target.getBlockPos();
+ IBlockState firstBlockState = Minecraft.getMinecraft().theWorld.getBlockState(pos);
+ Block block = firstBlockState.getBlock();
+
+ BlockPos above = pos.add(0, 1, 0);
+ Block aboveBlock = Minecraft.getMinecraft().theWorld.getBlockState(above).getBlock();
+
+ if (!cropBlocksZapper.contains(aboveBlock) && !cropBlocksZapper.contains(block) &&
+ !otherBannedBlocksZapper.contains(block) && !block.hasTileEntity(firstBlockState) &&
+ block.getBlockHardness(Minecraft.getMinecraft().theWorld, pos) >= 0) {
+ for (int i = 0; i < 164; i++) {
+ zapperBlocks.add(pos);
+ returnablePositions.remove(pos);
+
+ List<BlockPos> availableNeighbors = new ArrayList<>();
+
+ for (BlockPos offset : zapperOffsets) {
+ BlockPos newPos = pos.add(offset);
+
+ if (zapperBlocks.contains(newPos)) continue;
+
+ IBlockState state = Minecraft.getMinecraft().theWorld.getBlockState(newPos);
+ if (state != null && state.getBlock() == block) {
+ above = newPos.add(0, 1, 0);
+ aboveBlock = Minecraft.getMinecraft().theWorld.getBlockState(above).getBlock();
+ if (!cropBlocksZapper.contains(aboveBlock)) {
+ availableNeighbors.add(newPos);
+ }
+ }
+ }
+
+ if (availableNeighbors.size() >= 2) {
+ returnablePositions.add(pos);
+ pos = availableNeighbors.get(0);
+ } else if (availableNeighbors.size() == 1) {
+ pos = availableNeighbors.get(0);
+ } else if (returnablePositions.isEmpty()) {
+ break;
+ } else {
+ i--;
+ pos = returnablePositions.getLast();
+ }
+ }
+ }
+ }
+ for (BlockPos pos : zapperBlocks) {
+ Block block = Minecraft.getMinecraft().theWorld.getBlockState(pos).getBlock();
+ drawFilledBoundingBox(block.getSelectedBoundingBox(Minecraft.getMinecraft().theWorld, pos)
+ .expand(0.001D, 0.001D, 0.001D).offset(-d0, -d1, -d2),
+ 1f, NotEnoughUpdates.INSTANCE.config.itemOverlays.zapperOverlayColour
+ );
+ }
+ GlStateManager.depthMask(true);
+ GlStateManager.enableTexture2D();
+ GlStateManager.disableBlend();
+ } else if (NotEnoughUpdates.INSTANCE.config.itemOverlays.enableTreecapOverlay &&
+ (heldInternal.equals("JUNGLE_AXE") || heldInternal.equals("TREECAPITATOR_AXE"))) {
+ int maxWood = 10;
+ if (heldInternal.equals("TREECAPITATOR_AXE")) maxWood = 35;
+
+ if (event.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
+ GlStateManager.enableBlend();
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+ GlStateManager.color(0.0F, 0.0F, 0.0F, 0.4F);
+ GlStateManager.disableTexture2D();
+ GlStateManager.depthMask(false);
+
+ if (Minecraft.getMinecraft().theWorld.getBlockState(event.target.getBlockPos()).getBlock() == Blocks.log ||
+ Minecraft.getMinecraft().theWorld.getBlockState(event.target.getBlockPos()).getBlock() == Blocks.log2) {
+
+ int woods = 0;
+
+ HashSet<BlockPos> candidatesOld = new HashSet<>();
+ LinkedList<BlockPos> candidates = new LinkedList<>();
+ LinkedList<BlockPos> candidatesNew = new LinkedList<>();
+
+ candidatesNew.add(event.target.getBlockPos());
+
+ while (woods < maxWood) {
+ if (candidatesNew.isEmpty()) {
+ break;
+ }
+
+ candidates.addAll(candidatesNew);
+ candidatesNew.clear();
+
+ woods += candidates.size();
+ boolean random = woods > maxWood;
+
+ while (!candidates.isEmpty()) {
+ BlockPos candidate = candidates.pop();
+ Block block = Minecraft.getMinecraft().theWorld.getBlockState(candidate).getBlock();
+
+ candidatesOld.add(candidate);
+
+ for (int x = -1; x <= 1; x++) {
+ for (int y = -1; y <= 1; y++) {
+ for (int z = -1; z <= 1; z++) {
+ if (x != 0 || y != 0 || z != 0) {
+ BlockPos posNew = candidate.add(x, y, z);
+ if (!candidatesOld.contains(posNew) && !candidates.contains(posNew) && !candidatesNew.contains(
+ posNew)) {
+ Block blockNew = Minecraft.getMinecraft().theWorld.getBlockState(posNew).getBlock();
+ if (blockNew == Blocks.log || blockNew == Blocks.log2) {
+ candidatesNew.add(posNew);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ block.setBlockBoundsBasedOnState(Minecraft.getMinecraft().theWorld, candidate);
+
+ drawFilledBoundingBox(block.getSelectedBoundingBox(Minecraft.getMinecraft().theWorld, candidate)
+ .expand(0.001D, 0.001D, 0.001D).offset(-d0, -d1, -d2),
+ random ? 0.5f : 1f, NotEnoughUpdates.INSTANCE.config.itemOverlays.treecapOverlayColour
+ );
+ }
+ }
+ }
+
+ GlStateManager.depthMask(true);
+ GlStateManager.enableTexture2D();
+ GlStateManager.disableBlend();
+ }
+ } else if (NotEnoughUpdates.INSTANCE.config.itemOverlays.enableWandOverlay) {
+ if (heldInternal.equals("BUILDERS_WAND") && onPrivateIsland) {
+ int maxBlocks = MAX_BUILDERS_BLOCKS;
+ if (event.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
+ IBlockState hover = Minecraft.getMinecraft().theWorld.getBlockState(event.target
+ .getBlockPos()
+ .offset(event.target.sideHit, 1));
+ if (hover.getBlock() == Blocks.air) {
+ IBlockState match = Minecraft.getMinecraft().theWorld.getBlockState(event.target.getBlockPos());
+ Item matchItem = Item.getItemFromBlock(match.getBlock());
+ if (matchItem != null) {
+ GlStateManager.enableBlend();
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+ GlStateManager.disableTexture2D();
+ GlStateManager.depthMask(false);
+
+ HashSet<BlockPos> candidatesOld = new HashSet<>();
+ TreeMap<Float, Set<BlockPos>> candidatesOldSorted = new TreeMap<>();
+
+ getBuildersWandCandidates(
+ player,
+ event.target,
+ event.partialTicks,
+ candidatesOld,
+ candidatesOldSorted,
+ 10
+ );
+
+ ItemStack matchStack = new ItemStack(matchItem, 1,
+ match.getBlock().getDamageValue(Minecraft.getMinecraft().theWorld, event.target.getBlockPos())
+ );
+ int itemCount;
+ if (match.getBlock() == Blocks.dirt && matchStack.getItemDamage() == 0 && hasDirtWand()) {
+ itemCount = candidatesOld.size();
+ } else {
+ itemCount = countItemsInInventoryAndStorage(matchStack);
+ }
+
+ String special = (candidatesOld.size() <= itemCount)
+ ? NotEnoughUpdates.INSTANCE.config.itemOverlays.wandOverlayColour
+ :
+ "0:255:255:0:0";
+
+ if (candidatesOld.size() <= maxBlocks) {
+ for (Set<BlockPos> candidatesSorted : candidatesOldSorted.values()) {
+ for (BlockPos candidate : candidatesSorted) {
+ match.getBlock().setBlockBoundsBasedOnState(Minecraft.getMinecraft().theWorld, candidate);
+ AxisAlignedBB bb = match.getBlock().getSelectedBoundingBox(
+ Minecraft.getMinecraft().theWorld,
+ candidate
+ )
+ .offset(
+ event.target.sideHit.getFrontOffsetX(),
+ event.target.sideHit.getFrontOffsetY(),
+ event.target.sideHit.getFrontOffsetZ()
+ );
+
+ drawBlock((int) bb.minX, (int) bb.minY, (int) bb.minZ + 1, match, event.partialTicks, 0.75f);
+ }
+ }
+
+ for (BlockPos candidate : candidatesOld) {
+ match.getBlock().setBlockBoundsBasedOnState(Minecraft.getMinecraft().theWorld, candidate);
+ AxisAlignedBB bb = match.getBlock().getSelectedBoundingBox(
+ Minecraft.getMinecraft().theWorld,
+ candidate
+ )
+ .expand(0.001D, 0.001D, 0.001D).offset(-d0, -d1, -d2)
+ .offset(
+ event.target.sideHit.getFrontOffsetX(),
+ event.target.sideHit.getFrontOffsetY(),
+ event.target.sideHit.getFrontOffsetZ()
+ );
+
+ drawOutlineBoundingBox(bb, 1f, special);
+ }
+ }
+
+ GlStateManager.depthMask(true);
+ GlStateManager.enableTexture2D();
+ GlStateManager.disableBlend();
+ }
+ }
+ }
+ } else if (heldInternal.equals("INFINIDIRT_WAND") &&
+ event.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK &&
+ NotEnoughUpdates.INSTANCE.config.itemOverlays.enableDirtWandOverlay) {
+ BlockPos hover = event.target.getBlockPos().offset(event.target.sideHit, 1);
+ IBlockState hoverState = Minecraft.getMinecraft().theWorld.getBlockState(event.target
+ .getBlockPos()
+ .offset(event.target.sideHit, 1));
+ if (hoverState.getBlock() == Blocks.air) {
+ GlStateManager.enableBlend();
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+ GlStateManager.disableTexture2D();
+ GlStateManager.depthMask(false);
+
+ String special = NotEnoughUpdates.INSTANCE.config.itemOverlays.wandOverlayColour;
+
+ AxisAlignedBB bb = Blocks.dirt.getSelectedBoundingBox(Minecraft.getMinecraft().theWorld, hover);
+ drawBlock((int) bb.minX, (int) bb.minY, (int) bb.minZ + 1, Blocks.dirt.getDefaultState(),
+ event.partialTicks, 0.75f
+ );
+
+ AxisAlignedBB bbExpanded = Blocks.dirt.getSelectedBoundingBox(Minecraft.getMinecraft().theWorld, hover)
+ .expand(0.001D, 0.001D, 0.001D).offset(-d0, -d1, -d2);
+ drawOutlineBoundingBox(bbExpanded, 1f, special);
+
+ GlStateManager.depthMask(true);
+ GlStateManager.enableTexture2D();
+ GlStateManager.disableBlend();
+ }
+ } else if ((heldInternal.equals("WATER_BUCKET") || heldInternal.equals("MAGICAL_WATER_BUCKET") &&
+ NotEnoughUpdates.INSTANCE.config.itemOverlays.enablePrismapumpOverlay && onPrivateIsland) &&
+ event.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
+ BlockPos hover = event.target.getBlockPos().offset(event.target.sideHit, 1);
+
+ HashSet<BlockPos> verticalSources = new HashSet<>();
+ TreeMap<Float, HashMap<BlockPos, EnumFacing>> watersSorted = new TreeMap<>();
+
+ for (int xOff = -1; xOff <= 1; xOff++) {
+ for (int yOff = 0; yOff <= 1; yOff++) {
+ for (int zOff = -1; zOff <= 1; zOff++) {
+ if ((xOff == 0 && yOff == 0) ||
+ (xOff == 0 && zOff == 0) ||
+ (zOff == 0 && yOff == 0)) {
+
+ BlockPos checkPos = hover.add(-xOff, -yOff, -zOff);
+ IBlockState check = Minecraft.getMinecraft().theWorld.getBlockState(checkPos);
+ if (check.getBlock() == Blocks.prismarine && check.getBlock().getMetaFromState(check) == 2) {
+ for (int i = 0; i < 300; i++) {
+ BlockPos renderPos = hover.add(xOff * i, yOff * i, zOff * i);
+
+ if (Math.abs(renderPos.getX()) > 128) {
+ break;
+ }
+ if (Math.abs(renderPos.getY()) > 255) {
+ break;
+ }
+ if (Math.abs(renderPos.getZ()) > 128) {
+ break;
+ }
+
+ IBlockState renderState = Minecraft.getMinecraft().theWorld.getBlockState(renderPos);
+
+ if (renderState.getBlock() != Blocks.air && renderState.getBlock() != Blocks.water &&
+ renderState.getBlock() != Blocks.flowing_water) {
+ break;
+ }
+
+ if (yOff != 0) {
+ verticalSources.add(renderPos);
+ } else {
+ IBlockState belowState = Minecraft.getMinecraft().theWorld.getBlockState(renderPos.add(
+ 0,
+ -1,
+ 0
+ ));
+ if (belowState.getBlock() == Blocks.air) {
+ break;
+ }
+ }
+
+ for (EnumFacing facing : EnumFacing.values()) {
+ float xDist = (float) (renderPos.getX() + 0.5f + 0.5f * facing.getFrontOffsetX() - d0);
+ float yDist = (float) (renderPos.getY() + 0.5f + 0.5f * facing.getFrontOffsetY() - d1 -
+ player.getEyeHeight());
+ float zDist = (float) (renderPos.getZ() + 0.5f + 0.5f * facing.getFrontOffsetZ() - d2);
+
+ float distSq = xDist * xDist + yDist * yDist + zDist * zDist;
+
+ watersSorted.computeIfAbsent(distSq, k -> new HashMap<>()).put(renderPos, facing);
+ }
+
+ }
+ }
+ }
+ }
+ }
+ }
+
+ GlStateManager.enableDepth();
+ GlStateManager.enableBlend();
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+ GlStateManager.disableTexture2D();
+ GlStateManager.depthMask(true);
+
+ for (HashMap<BlockPos, EnumFacing> blockPoses : watersSorted.values()) {
+ for (Map.Entry<BlockPos, EnumFacing> entry : blockPoses.entrySet()) {
+ boolean vertical = verticalSources.contains(entry.getKey());
+ AxisAlignedBB bbExpanded = Blocks.water.getSelectedBoundingBox(
+ Minecraft.getMinecraft().theWorld,
+ entry.getKey()
+ )
+ .expand(-0.001D, -0.001D - (vertical ? 0 : 0.0625D), -0.001D)
+ .offset(-d0, -d1 - (vertical ? 0 : 0.0625), -d2);
+ drawFilledBoundingBoxSide(bbExpanded, entry.getValue(), 1f, "0:100:20:50:160");
+ }
+ }
+
+ GlStateManager.depthMask(true);
+ GlStateManager.enableTexture2D();
+ GlStateManager.disableBlend();
+ } else if ((heldInternal.equals("HOE_OF_GREAT_TILLING") || heldInternal.equals("HOE_OF_GREATER_TILLING") &&
+ NotEnoughUpdates.INSTANCE.config.itemOverlays.enableHoeOverlay && onPrivateIsland) &&
+ event.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
+ BlockPos target = event.target.getBlockPos();
+ IBlockState targetState = Minecraft.getMinecraft().theWorld.getBlockState(target);
+
+ int radius = heldInternal.equals("HOE_OF_GREAT_TILLING") ? 1 : 2;
+
+ if (targetState.getBlock() == Blocks.dirt || targetState.getBlock() == Blocks.grass) {
+ GlStateManager.enableDepth();
+ GlStateManager.enableBlend();
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+ GlStateManager.disableTexture2D();
+ GlStateManager.depthMask(true);
+
+ for (int xOff = -radius; xOff <= radius; xOff++) {
+ for (int zOff = -radius; zOff <= radius; zOff++) {
+ BlockPos renderPos = target.add(xOff, 0, zOff);
+ IBlockState renderState = Minecraft.getMinecraft().theWorld.getBlockState(renderPos);
+ if (renderState.getBlock() == Blocks.dirt || renderState.getBlock() == Blocks.grass) {
+ AxisAlignedBB bbExpanded = Blocks.dirt.getSelectedBoundingBox(
+ Minecraft.getMinecraft().theWorld,
+ renderPos
+ )
+ .expand(0.001D, 0.001D, 0.001D)
+ .offset(-d0, -d1, -d2);
+ drawFilledBoundingBox(bbExpanded, 1f, "0:100:178:34:34");
+ }
+ }
+ }
+
+ GlStateManager.depthMask(true);
+ GlStateManager.enableTexture2D();
+ GlStateManager.disableBlend();
+ }
+ }
+ }
+ }
+ }
+
+ public void getBuildersWandCandidates(
+ EntityPlayer player, MovingObjectPosition target, float partialTicks,
+ HashSet<BlockPos> candidatesOld, TreeMap<Float, Set<BlockPos>> candidatesOldSorted, int extraMax
+ ) {
+ IBlockState match = Minecraft.getMinecraft().theWorld.getBlockState(target.getBlockPos());
+
+ candidatesOld.clear();
+ candidatesOldSorted.clear();
+ LinkedList<BlockPos> candidates = new LinkedList<>();
+ LinkedList<BlockPos> candidatesNew = new LinkedList<>();
+
+ candidatesNew.add(target.getBlockPos());
+
+ double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double) partialTicks;
+ double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double) partialTicks;
+ double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double) partialTicks;
+
+ while (candidatesOld.size() <= MAX_BUILDERS_BLOCKS + extraMax) {
+ if (candidatesNew.isEmpty()) {
+ break;
+ }
+
+ candidates.addAll(candidatesNew);
+ candidatesNew.clear();
+
+ while (!candidates.isEmpty()) {
+ if (candidatesOld.size() > MAX_BUILDERS_BLOCKS + extraMax) break;
+
+ BlockPos candidate = candidates.pop();
+
+ float distSq = (float) ((candidate.getX() + 0.5f - d0) * (candidate.getX() + 0.5f - d0) +
+ (candidate.getY() + 0.5f - d1 - player.getEyeHeight()) *
+ (candidate.getY() + 0.5f - d1 - player.getEyeHeight()) +
+ (candidate.getZ() + 0.5f - d2) * (candidate.getZ() + 0.5f - d2));
+ candidatesOldSorted.computeIfAbsent(distSq, k -> new HashSet<>()).add(candidate);
+
+ candidatesOld.add(candidate);
+
+ for (int x = -1; x <= 1; x++) {
+ for (int y = -1; y <= 1; y++) {
+ for (int z = -1; z <= 1; z++) {
+ if (x * x + y * y + z * z == 1) {
+ if (((x == 0) && (target.sideHit.getAxis() == EnumFacing.Axis.X)) ||
+ ((y == 0) && (target.sideHit.getAxis() == EnumFacing.Axis.Y)) ||
+ ((z == 0) && (target.sideHit.getAxis() == EnumFacing.Axis.Z))) {
+ if (Minecraft.getMinecraft().theWorld.getBlockState(candidate.add(
+ x + target.sideHit.getFrontOffsetX(),
+ y + target.sideHit.getFrontOffsetY(),
+ z + target.sideHit.getFrontOffsetZ()
+ )).getBlock() == Blocks.air) {
+ BlockPos posNew = candidate.add(x, y, z);
+ if (!candidatesOld.contains(posNew) && !candidates.contains(posNew) && !candidatesNew.contains(
+ posNew)) {
+ IBlockState blockNew = Minecraft.getMinecraft().theWorld.getBlockState(posNew);
+ if (blockNew == match) {
+ candidatesNew.add(posNew);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public static void drawBlock(int x, int y, int z, IBlockState state, float partialTicks, float brightness) {
+ EntityPlayerSP player = Minecraft.getMinecraft().thePlayer;
+ double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double) partialTicks;
+ double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double) partialTicks;
+ double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double) partialTicks;
+
+ BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
+
+ GlStateManager.enableTexture2D();
+ GlStateManager.disableLighting();
+ GlStateManager.enableBlend();
+ GlStateManager.blendFunc(770, 771);
+
+ GlStateManager.enableDepth();
+ GlStateManager.depthMask(true);
+ GlStateManager.enableCull();
+ GlStateManager.cullFace(GL11.GL_BACK);
+
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(x - d0, y - d1, z - d2);
+
+ int i = state.getBlock().getRenderType();
+ if (i == 3) {
+ IBakedModel ibakedmodel = blockrendererdispatcher.getModelFromBlockState(
+ state,
+ Minecraft.getMinecraft().theWorld,
+ null
+ );
+
+ Block block = state.getBlock();
+ block.setBlockBoundsForItemRender();
+ GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F);
+ int colour = block.getRenderColor(block.getStateForEntityRender(state));
+
+ if (EntityRenderer.anaglyphEnable) {
+ colour = TextureUtil.anaglyphColor(i);
+ }
+
+ colour = (colour & 0x00FFFFFF) | (100 << 24); //Set alpha to 100
+
+ for (EnumFacing enumfacing : EnumFacing.values()) {
+ renderModelBrightnessColorQuads(colour, ibakedmodel.getFaceQuads(enumfacing));
+ }
+
+ renderModelBrightnessColorQuads(colour, ibakedmodel.getGeneralQuads());
+ }
+
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ GlStateManager.translate(-x + d0, -y + d1, -z + d2);
+ GlStateManager.popMatrix();
+ }
+
+ private static void renderModelBrightnessColorQuads(int c, List<BakedQuad> listQuads) {
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+
+ for (BakedQuad bakedquad : listQuads) {
+ worldrenderer.begin(7, DefaultVertexFormats.ITEM);
+ worldrenderer.addVertexData(bakedquad.getVertexData());
+
+ worldrenderer.putColor4(c);
+
+ Vec3i vec3i = bakedquad.getFace().getDirectionVec();
+ worldrenderer.putNormal((float) vec3i.getX(), (float) vec3i.getY(), (float) vec3i.getZ());
+ tessellator.draw();
+ }
+ }
+
+ public static void drawFilledBoundingBox(AxisAlignedBB p_181561_0_, float alpha, String special) {
+ Color c = new Color(SpecialColour.specialToChromaRGB(special), true);
+
+ GlStateManager.enableBlend();
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+ GlStateManager.disableTexture2D();
+
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+
+ GlStateManager.color(c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f, c.getAlpha() / 255f * alpha);
+
+ //vertical
+ worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex();
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex();
+ tessellator.draw();
+ worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
+ tessellator.draw();
+
+ GlStateManager.color(
+ c.getRed() / 255f * 0.8f,
+ c.getGreen() / 255f * 0.8f,
+ c.getBlue() / 255f * 0.8f,
+ c.getAlpha() / 255f * alpha
+ );
+
+ //x
+ worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex();
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex();
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
+ tessellator.draw();
+ worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex();
+ tessellator.draw();
+
+ GlStateManager.color(
+ c.getRed() / 255f * 0.9f,
+ c.getGreen() / 255f * 0.9f,
+ c.getBlue() / 255f * 0.9f,
+ c.getAlpha() / 255f * alpha
+ );
+ //z
+ worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
+ tessellator.draw();
+ worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex();
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex();
+ tessellator.draw();
+ }
+
+ public static void drawFilledBoundingBoxSide(
+ AxisAlignedBB p_181561_0_,
+ EnumFacing facing,
+ float alpha,
+ String special
+ ) {
+ Color c = new Color(SpecialColour.specialToChromaRGB(special), true);
+ GlStateManager.color(c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f, c.getAlpha() / 255f * alpha);
+
+ GlStateManager.enableBlend();
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+ GlStateManager.disableTexture2D();
+
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+ worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
+ switch (facing) {
+ case UP:
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex();
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex();
+ break;
+ case DOWN:
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex();
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex();
+ break;
+ case EAST:
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex();
+ break;
+ case WEST:
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex();
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex();
+ break;
+ case SOUTH:
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex();
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex();
+ break;
+ case NORTH:
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
+ break;
+ }
+ tessellator.draw();
+ }
+
+ public static void drawOutlineBoundingBox(AxisAlignedBB p_181561_0_, float alpha, String special) {
+ Color c = new Color(SpecialColour.specialToChromaRGB(special), true);
+ float newAlpha = c.getAlpha() / 255f * alpha;
+ if (newAlpha > 1) newAlpha = 1;
+ GlStateManager.color(c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f, newAlpha);
+
+ GlStateManager.enableBlend();
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+ GlStateManager.disableTexture2D();
+ GlStateManager.depthMask(false);
+
+ GL11.glLineWidth(3);
+
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+ worldrenderer.begin(3, DefaultVertexFormats.POSITION);
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex();
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex();
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
+ tessellator.draw();
+ worldrenderer.begin(3, DefaultVertexFormats.POSITION);
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex();
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex();
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
+ tessellator.draw();
+ worldrenderer.begin(1, DefaultVertexFormats.POSITION);
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex();
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex();
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex();
+ tessellator.draw();
+
+ GL11.glLineWidth(1);
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomSkulls.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomSkulls.java
index ed4c8919..1157e73a 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomSkulls.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomSkulls.java
@@ -7,37 +7,23 @@ import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.mojang.authlib.GameProfile;
-import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
-import io.github.moulberry.notenoughupdates.util.TexLoc;
-import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
-import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelHumanoidHead;
import net.minecraft.client.model.ModelSkeletonHead;
-import net.minecraft.client.renderer.EntityRenderer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.block.model.*;
import net.minecraft.client.renderer.texture.*;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
-import net.minecraft.client.resources.DefaultPlayerSkin;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.client.resources.IResourceManagerReloadListener;
import net.minecraft.client.resources.model.IBakedModel;
-import net.minecraft.client.resources.model.ModelBakery;
import net.minecraft.client.resources.model.ModelRotation;
import net.minecraft.client.resources.model.SimpleBakedModel;
-import net.minecraft.entity.Entity;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
-import net.minecraftforge.client.event.RenderGameOverlayEvent;
-import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
-import org.lwjgl.input.Keyboard;
-import org.lwjgl.opengl.GL11;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
@@ -48,257 +34,325 @@ import java.nio.charset.StandardCharsets;
import java.util.*;
public class CustomSkulls implements IResourceManagerReloadListener {
-
- private static final CustomSkulls INSTANCE = new CustomSkulls();
-
- public static CustomSkulls getInstance() {
- return INSTANCE;
- }
-
- private ResourceLocation atlas = new ResourceLocation("notenoughupdates:custom_skull_textures_atlas");
- private ResourceLocation configuration = new ResourceLocation("notenoughupdates:custom_skull_textures/customskull.json");
- protected final TextureMap textureMap = new TextureMap("custom_skull_textures");
-
- public static ItemCameraTransforms.TransformType mostRecentTransformType = ItemCameraTransforms.TransformType.NONE;
-
- protected final Map<ResourceLocation, TextureAtlasSprite> sprites = Maps.<ResourceLocation, TextureAtlasSprite>newHashMap();
-
- private final FaceBakery faceBakery = new FaceBakery();
- private final ModelSkeletonHead humanoidHead = new ModelHumanoidHead();
-
- private final HashMap<String, CustomSkull> customSkulls = new HashMap<>();
-
- private final Gson gson = new GsonBuilder().create();
-
- private class CustomSkull {
- private ModelBlock model;
- private IBakedModel modelBaked;
-
- private ResourceLocation texture;
- }
-
- @Override
- public void onResourceManagerReload(IResourceManager resourceManager) {
- customSkulls.clear();
-
- try(BufferedReader reader = new BufferedReader(new InputStreamReader(
- Minecraft.getMinecraft().getResourceManager().getResource(configuration).getInputStream(), StandardCharsets.UTF_8))) {
- JsonObject json = gson.fromJson(reader, JsonObject.class);
-
- if(json == null) return;
-
- for(Map.Entry<String, JsonElement> entry : json.entrySet()) {
- if(entry.getValue().isJsonObject()) {
- JsonObject obj = entry.getValue().getAsJsonObject();
- if(obj.has("model")) {
- String location = obj.get("model").getAsString();
- ResourceLocation loc = new ResourceLocation("notenoughupdates:custom_skull_textures/" + location + ".json");
-
- CustomSkull skull = new CustomSkull();
- skull.model = ModelBlock.deserialize(new InputStreamReader(Minecraft.getMinecraft().getResourceManager().getResource(loc).getInputStream()));
-
- customSkulls.put(entry.getKey(), skull);
- } else if(obj.has("texture")) {
- String location = obj.get("texture").getAsString();
- ResourceLocation loc = new ResourceLocation("notenoughupdates:custom_skull_textures/" + location + ".png");
-
- CustomSkull skull = new CustomSkull();
- skull.texture = loc;
-
- Minecraft.getMinecraft().getTextureManager().deleteTexture(skull.texture);
-
- customSkulls.put(entry.getKey(), skull);
- }
- }
- }
-
- loadSprites();
-
- for(CustomSkull skull : customSkulls.values()) {
- if(skull.model != null) {
- skull.modelBaked = bakeModel(skull.model, ModelRotation.X0_Y0, false);
- }
- }
-
- Minecraft.getMinecraft().getTextureManager().loadTexture(atlas, textureMap);
- } catch(Exception e) {
- }
- }
-
- private void loadSprites() {
- final Set<ResourceLocation> set = this.getAllTextureLocations();
- set.remove(TextureMap.LOCATION_MISSING_TEXTURE);
- IIconCreator iiconcreator = new IIconCreator() {
- public void registerSprites(TextureMap iconRegistry) {
- for(ResourceLocation resourcelocation : set) {
- TextureAtlasSprite textureatlassprite = iconRegistry.registerSprite(resourcelocation);
- CustomSkulls.this.sprites.put(resourcelocation, textureatlassprite);
- }
- }
- };
- this.textureMap.loadSprites(Minecraft.getMinecraft().getResourceManager(), iiconcreator);
- this.sprites.put(new ResourceLocation("missingno"), this.textureMap.getMissingSprite());
- }
-
- protected Set<ResourceLocation> getAllTextureLocations() {
- Set<ResourceLocation> set = new HashSet<>();
-
- for(CustomSkull skull : customSkulls.values()) {
- if(skull.model != null) {
- set.addAll(getTextureLocations(skull.model));
- }
- }
-
- return set;
- }
-
- protected Set<ResourceLocation> getTextureLocations(ModelBlock modelBlock) {
- Set<ResourceLocation> set = Sets.<ResourceLocation>newHashSet();
-
- for(BlockPart blockpart : modelBlock.getElements()) {
- for(BlockPartFace blockpartface : blockpart.mapFaces.values()) {
- ResourceLocation resourcelocation = new ResourceLocation("notenoughupdates", modelBlock.resolveTextureName(blockpartface.texture));
- set.add(resourcelocation);
- }
- }
-
- set.add(new ResourceLocation("notenoughupdates", modelBlock.resolveTextureName("particle")));
- return set;
- }
-
- protected IBakedModel bakeModel(ModelBlock modelBlockIn, net.minecraftforge.client.model.ITransformation modelRotationIn, boolean uvLocked) {
- TextureAtlasSprite textureatlassprite = this.sprites.get(new ResourceLocation("notenoughupdates", modelBlockIn.resolveTextureName("particle")));
- SimpleBakedModel.Builder simplebakedmodel$builder = (new SimpleBakedModel.Builder(modelBlockIn)).setTexture(textureatlassprite);
-
- for(BlockPart blockpart : modelBlockIn.getElements()) {
- for(EnumFacing enumfacing : blockpart.mapFaces.keySet()) {
- BlockPartFace blockpartface = blockpart.mapFaces.get(enumfacing);
- TextureAtlasSprite textureatlassprite1 = this.sprites.get(new ResourceLocation("notenoughupdates", modelBlockIn.resolveTextureName(blockpartface.texture)));
-
- if(blockpartface.cullFace == null || !net.minecraftforge.client.model.TRSRTransformation.isInteger(modelRotationIn.getMatrix())) {
- simplebakedmodel$builder.addGeneralQuad(this.makeBakedQuad(blockpart, blockpartface, textureatlassprite1, enumfacing, modelRotationIn, uvLocked));
- } else {
- simplebakedmodel$builder.addFaceQuad(modelRotationIn.rotate(blockpartface.cullFace), this.makeBakedQuad(blockpart, blockpartface, textureatlassprite1, enumfacing, modelRotationIn, uvLocked));
- }
- }
- }
-
- return simplebakedmodel$builder.makeBakedModel();
- }
-
- private BakedQuad makeBakedQuad(BlockPart p_177589_1_, BlockPartFace p_177589_2_, TextureAtlasSprite p_177589_3_, EnumFacing p_177589_4_, ModelRotation p_177589_5_, boolean p_177589_6_) {
- return makeBakedQuad(p_177589_1_, p_177589_2_, p_177589_3_, p_177589_4_, (net.minecraftforge.client.model.ITransformation) p_177589_5_, p_177589_6_);
- }
-
- protected BakedQuad makeBakedQuad(BlockPart p_177589_1_, BlockPartFace p_177589_2_, TextureAtlasSprite p_177589_3_, EnumFacing p_177589_4_, net.minecraftforge.client.model.ITransformation p_177589_5_, boolean p_177589_6_) {
- return this.faceBakery.makeBakedQuad(p_177589_1_.positionFrom, p_177589_1_.positionTo, p_177589_2_, p_177589_3_, p_177589_4_, p_177589_5_, p_177589_1_.partRotation, p_177589_6_, p_177589_1_.shade);
- }
-
- private void renderModel(IBakedModel model, int color) {
- Tessellator tessellator = Tessellator.getInstance();
- WorldRenderer worldrenderer = tessellator.getWorldRenderer();
- worldrenderer.begin(7, DefaultVertexFormats.ITEM);
-
- for(EnumFacing enumfacing : EnumFacing.values()) {
- this.renderQuads(worldrenderer, model.getFaceQuads(enumfacing), color);
- }
-
- this.renderQuads(worldrenderer, model.getGeneralQuads(), color);
- tessellator.draw();
- }
-
- private void renderQuads(WorldRenderer renderer, List<BakedQuad> quads, int color) {
- int i = 0;
-
- for(int j = quads.size(); i < j; ++i) {
- BakedQuad bakedquad = quads.get(i);
- int k = color;
-
- net.minecraftforge.client.model.pipeline.LightUtil.renderQuadColor(renderer, bakedquad, k);
- }
- }
-
- public boolean renderSkull(float xOffset, float yOffset, float zOffset, EnumFacing placedDirection,
- float rotationDeg, int skullType, GameProfile skullOwner, int damage) {
- if(NotEnoughUpdates.INSTANCE.config.misc.disableSkullRetexturing) {
- return false;
- }
- if(placedDirection != EnumFacing.UP || skullType != 3) {
- return false;
- }
- if(skullOwner == null || skullOwner.getId() == null) {
- return false;
- }
-
- CustomSkull skull = customSkulls.get(skullOwner.getId().toString());
- if(skull == null) {
- return false;
- }
-
- if(skull.modelBaked != null && skull.model != null) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(atlas);
- GlStateManager.pushMatrix();
- GlStateManager.disableCull();
- GlStateManager.enableLighting();
-
- GlStateManager.translate(xOffset + 0.5F, yOffset, zOffset + 0.5F);
-
- GlStateManager.enableRescaleNormal();
- GlStateManager.enableAlpha();
-
- GlStateManager.rotate(rotationDeg, 0, 1, 0);
-
- GlStateManager.translate(0, 0.25f, 0);
-
- if(xOffset == -0.5 && yOffset == 0 && zOffset == -0.5 && rotationDeg == 180) {
- skull.model.getAllTransforms().applyTransform(ItemCameraTransforms.TransformType.HEAD);
- } else {
- skull.model.getAllTransforms().applyTransform(mostRecentTransformType);
- }
-
- GlStateManager.translate(-0.5f, 0, -0.5f);
-
- renderModel(skull.modelBaked, 0xffffffff);
- GlStateManager.popMatrix();
- } else if(skull.texture != null) {
- if( Minecraft.getMinecraft().getTextureManager().getTexture(skull.texture) == null) {
- try {
- BufferedImage image = ImageIO.read(Minecraft.getMinecraft().getResourceManager().getResource(skull.texture).getInputStream());
- int size = Math.max(image.getHeight(), image.getWidth());
-
- Minecraft.getMinecraft().getTextureManager().loadTexture(skull.texture, new AbstractTexture() {
- @Override
- public void loadTexture(IResourceManager resourceManager) {
- TextureUtil.allocateTexture(this.getGlTextureId(), size, size);
-
- int[] rgb = new int[size*size];
-
- image.getRGB(0, 0, image.getWidth(), image.getHeight(), rgb, 0, image.getWidth());
-
- TextureUtil.uploadTexture(this.getGlTextureId(), rgb, size, size);
- }
- });
- } catch(IOException ignored) {}
- }
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(skull.texture);
-
- GlStateManager.pushMatrix();
- GlStateManager.disableCull();
-
- GlStateManager.translate(xOffset + 0.5F, yOffset, zOffset + 0.5F);
-
- float f = 0.0625F;
- GlStateManager.enableRescaleNormal();
- GlStateManager.scale(-1.0F, -1.0F, 1.0F);
- GlStateManager.enableAlpha();
- humanoidHead.render(null, 0.0F, 0.0F, 0.0F, rotationDeg, 0.0F, f);
- GlStateManager.popMatrix();
- } else {
- return false;
- }
-
- return true;
- }
-
+ private static final CustomSkulls INSTANCE = new CustomSkulls();
+
+ public static CustomSkulls getInstance() {
+ return INSTANCE;
+ }
+
+ private final ResourceLocation atlas = new ResourceLocation("notenoughupdates:custom_skull_textures_atlas");
+ private final ResourceLocation configuration = new ResourceLocation(
+ "notenoughupdates:custom_skull_textures/customskull.json");
+ protected final TextureMap textureMap = new TextureMap("custom_skull_textures");
+
+ public static ItemCameraTransforms.TransformType mostRecentTransformType = ItemCameraTransforms.TransformType.NONE;
+
+ protected final Map<ResourceLocation, TextureAtlasSprite> sprites = Maps.newHashMap();
+
+ private final FaceBakery faceBakery = new FaceBakery();
+ private final ModelSkeletonHead humanoidHead = new ModelHumanoidHead();
+
+ private final HashMap<String, CustomSkull> customSkulls = new HashMap<>();
+
+ private final Gson gson = new GsonBuilder().create();
+
+ private static class CustomSkull {
+ private ModelBlock model;
+ private IBakedModel modelBaked;
+
+ private ResourceLocation texture;
+ }
+
+ @Override
+ public void onResourceManagerReload(IResourceManager resourceManager) {
+ customSkulls.clear();
+
+ try (
+ BufferedReader reader = new BufferedReader(new InputStreamReader(
+ Minecraft.getMinecraft().getResourceManager().getResource(configuration).getInputStream(),
+ StandardCharsets.UTF_8
+ ))
+ ) {
+ JsonObject json = gson.fromJson(reader, JsonObject.class);
+
+ if (json == null) return;
+
+ for (Map.Entry<String, JsonElement> entry : json.entrySet()) {
+ if (entry.getValue().isJsonObject()) {
+ JsonObject obj = entry.getValue().getAsJsonObject();
+ if (obj.has("model")) {
+ String location = obj.get("model").getAsString();
+ ResourceLocation loc = new ResourceLocation("notenoughupdates:custom_skull_textures/" + location + ".json");
+
+ CustomSkull skull = new CustomSkull();
+ skull.model = ModelBlock.deserialize(new InputStreamReader(Minecraft
+ .getMinecraft()
+ .getResourceManager()
+ .getResource(loc)
+ .getInputStream()));
+
+ customSkulls.put(entry.getKey(), skull);
+ } else if (obj.has("texture")) {
+ String location = obj.get("texture").getAsString();
+ ResourceLocation loc = new ResourceLocation("notenoughupdates:custom_skull_textures/" + location + ".png");
+
+ CustomSkull skull = new CustomSkull();
+ skull.texture = loc;
+
+ Minecraft.getMinecraft().getTextureManager().deleteTexture(skull.texture);
+
+ customSkulls.put(entry.getKey(), skull);
+ }
+ }
+ }
+
+ loadSprites();
+
+ for (CustomSkull skull : customSkulls.values()) {
+ if (skull.model != null) {
+ skull.modelBaked = bakeModel(skull.model, ModelRotation.X0_Y0, false);
+ }
+ }
+
+ Minecraft.getMinecraft().getTextureManager().loadTexture(atlas, textureMap);
+ } catch (Exception ignored) {
+ }
+ }
+
+ private void loadSprites() {
+ final Set<ResourceLocation> set = this.getAllTextureLocations();
+ set.remove(TextureMap.LOCATION_MISSING_TEXTURE);
+ IIconCreator iiconcreator = iconRegistry -> {
+ for (ResourceLocation resourcelocation : set) {
+ TextureAtlasSprite textureatlassprite = iconRegistry.registerSprite(resourcelocation);
+ CustomSkulls.this.sprites.put(resourcelocation, textureatlassprite);
+ }
+ };
+ this.textureMap.loadSprites(Minecraft.getMinecraft().getResourceManager(), iiconcreator);
+ this.sprites.put(new ResourceLocation("missingno"), this.textureMap.getMissingSprite());
+ }
+
+ protected Set<ResourceLocation> getAllTextureLocations() {
+ Set<ResourceLocation> set = new HashSet<>();
+
+ for (CustomSkull skull : customSkulls.values()) {
+ if (skull.model != null) {
+ set.addAll(getTextureLocations(skull.model));
+ }
+ }
+
+ return set;
+ }
+
+ protected Set<ResourceLocation> getTextureLocations(ModelBlock modelBlock) {
+ Set<ResourceLocation> set = Sets.newHashSet();
+
+ for (BlockPart blockpart : modelBlock.getElements()) {
+ for (BlockPartFace blockpartface : blockpart.mapFaces.values()) {
+ ResourceLocation resourcelocation = new ResourceLocation(
+ "notenoughupdates",
+ modelBlock.resolveTextureName(blockpartface.texture)
+ );
+ set.add(resourcelocation);
+ }
+ }
+
+ set.add(new ResourceLocation("notenoughupdates", modelBlock.resolveTextureName("particle")));
+ return set;
+ }
+
+ protected IBakedModel bakeModel(
+ ModelBlock modelBlockIn,
+ net.minecraftforge.client.model.ITransformation modelRotationIn,
+ boolean uvLocked
+ ) {
+ TextureAtlasSprite textureatlassprite = this.sprites.get(new ResourceLocation(
+ "notenoughupdates",
+ modelBlockIn.resolveTextureName("particle")
+ ));
+ SimpleBakedModel.Builder simplebakedmodel$builder = (new SimpleBakedModel.Builder(modelBlockIn)).setTexture(
+ textureatlassprite);
+
+ for (BlockPart blockpart : modelBlockIn.getElements()) {
+ for (EnumFacing enumfacing : blockpart.mapFaces.keySet()) {
+ BlockPartFace blockpartface = blockpart.mapFaces.get(enumfacing);
+ TextureAtlasSprite textureatlassprite1 = this.sprites.get(new ResourceLocation(
+ "notenoughupdates",
+ modelBlockIn.resolveTextureName(blockpartface.texture)
+ ));
+
+ if (blockpartface.cullFace == null || !net.minecraftforge.client.model.TRSRTransformation.isInteger(
+ modelRotationIn.getMatrix())) {
+ simplebakedmodel$builder.addGeneralQuad(this.makeBakedQuad(
+ blockpart,
+ blockpartface,
+ textureatlassprite1,
+ enumfacing,
+ modelRotationIn,
+ uvLocked
+ ));
+ } else {
+ simplebakedmodel$builder.addFaceQuad(
+ modelRotationIn.rotate(blockpartface.cullFace),
+ this.makeBakedQuad(blockpart, blockpartface, textureatlassprite1, enumfacing, modelRotationIn, uvLocked)
+ );
+ }
+ }
+ }
+
+ return simplebakedmodel$builder.makeBakedModel();
+ }
+
+ private BakedQuad makeBakedQuad(
+ BlockPart p_177589_1_,
+ BlockPartFace p_177589_2_,
+ TextureAtlasSprite p_177589_3_,
+ EnumFacing p_177589_4_,
+ ModelRotation p_177589_5_,
+ boolean p_177589_6_
+ ) {
+ return makeBakedQuad(
+ p_177589_1_,
+ p_177589_2_,
+ p_177589_3_,
+ p_177589_4_,
+ (net.minecraftforge.client.model.ITransformation) p_177589_5_,
+ p_177589_6_
+ );
+ }
+
+ protected BakedQuad makeBakedQuad(
+ BlockPart p_177589_1_,
+ BlockPartFace p_177589_2_,
+ TextureAtlasSprite p_177589_3_,
+ EnumFacing p_177589_4_,
+ net.minecraftforge.client.model.ITransformation p_177589_5_,
+ boolean p_177589_6_
+ ) {
+ return this.faceBakery.makeBakedQuad(
+ p_177589_1_.positionFrom,
+ p_177589_1_.positionTo,
+ p_177589_2_,
+ p_177589_3_,
+ p_177589_4_,
+ p_177589_5_,
+ p_177589_1_.partRotation,
+ p_177589_6_,
+ p_177589_1_.shade
+ );
+ }
+
+ private void renderModel(IBakedModel model, int color) {
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+ worldrenderer.begin(7, DefaultVertexFormats.ITEM);
+
+ for (EnumFacing enumfacing : EnumFacing.values()) {
+ this.renderQuads(worldrenderer, model.getFaceQuads(enumfacing), color);
+ }
+
+ this.renderQuads(worldrenderer, model.getGeneralQuads(), color);
+ tessellator.draw();
+ }
+
+ private void renderQuads(WorldRenderer renderer, List<BakedQuad> quads, int color) {
+ int i = 0;
+
+ for (int j = quads.size(); i < j; ++i) {
+ BakedQuad bakedquad = quads.get(i);
+ int k = color;
+
+ net.minecraftforge.client.model.pipeline.LightUtil.renderQuadColor(renderer, bakedquad, k);
+ }
+ }
+
+ public boolean renderSkull(
+ float xOffset, float yOffset, float zOffset, EnumFacing placedDirection,
+ float rotationDeg, int skullType, GameProfile skullOwner, int damage
+ ) {
+ if (NotEnoughUpdates.INSTANCE.config.misc.disableSkullRetexturing) {
+ return false;
+ }
+ if (placedDirection != EnumFacing.UP || skullType != 3) {
+ return false;
+ }
+ if (skullOwner == null || skullOwner.getId() == null) {
+ return false;
+ }
+
+ CustomSkull skull = customSkulls.get(skullOwner.getId().toString());
+ if (skull == null) {
+ return false;
+ }
+
+ if (skull.modelBaked != null && skull.model != null) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(atlas);
+ GlStateManager.pushMatrix();
+ GlStateManager.disableCull();
+ GlStateManager.enableLighting();
+
+ GlStateManager.translate(xOffset + 0.5F, yOffset, zOffset + 0.5F);
+
+ GlStateManager.enableRescaleNormal();
+ GlStateManager.enableAlpha();
+
+ GlStateManager.rotate(rotationDeg, 0, 1, 0);
+
+ GlStateManager.translate(0, 0.25f, 0);
+
+ if (xOffset == -0.5 && yOffset == 0 && zOffset == -0.5 && rotationDeg == 180) {
+ skull.model.getAllTransforms().applyTransform(ItemCameraTransforms.TransformType.HEAD);
+ } else {
+ skull.model.getAllTransforms().applyTransform(mostRecentTransformType);
+ }
+
+ GlStateManager.translate(-0.5f, 0, -0.5f);
+
+ renderModel(skull.modelBaked, 0xffffffff);
+ GlStateManager.popMatrix();
+ } else if (skull.texture != null) {
+ if (Minecraft.getMinecraft().getTextureManager().getTexture(skull.texture) == null) {
+ try {
+ BufferedImage image = ImageIO.read(Minecraft
+ .getMinecraft()
+ .getResourceManager()
+ .getResource(skull.texture)
+ .getInputStream());
+ int size = Math.max(image.getHeight(), image.getWidth());
+
+ Minecraft.getMinecraft().getTextureManager().loadTexture(skull.texture, new AbstractTexture() {
+ @Override
+ public void loadTexture(IResourceManager resourceManager) {
+ TextureUtil.allocateTexture(this.getGlTextureId(), size, size);
+
+ int[] rgb = new int[size * size];
+
+ image.getRGB(0, 0, image.getWidth(), image.getHeight(), rgb, 0, image.getWidth());
+
+ TextureUtil.uploadTexture(this.getGlTextureId(), rgb, size, size);
+ }
+ });
+ } catch (IOException ignored) {
+ }
+ }
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(skull.texture);
+
+ GlStateManager.pushMatrix();
+ GlStateManager.disableCull();
+
+ GlStateManager.translate(xOffset + 0.5F, yOffset, zOffset + 0.5F);
+
+ float f = 0.0625F;
+ GlStateManager.enableRescaleNormal();
+ GlStateManager.scale(-1.0F, -1.0F, 1.0F);
+ GlStateManager.enableAlpha();
+ humanoidHead.render(null, 0.0F, 0.0F, 0.0F, rotationDeg, 0.0F, f);
+ GlStateManager.popMatrix();
+ } else {
+ return false;
+ }
+
+ return true;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DamageCommas.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DamageCommas.java
index aafcfb4d..9c93b9c5 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DamageCommas.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DamageCommas.java
@@ -9,106 +9,112 @@ import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IChatComponent;
import java.text.NumberFormat;
-import java.util.HashMap;
import java.util.WeakHashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class DamageCommas {
-
- private static final WeakHashMap<EntityLivingBase, ChatComponentText> replacementMap = new WeakHashMap<>();
-
- private static final EnumChatFormatting[] coloursHypixel = {EnumChatFormatting.WHITE, EnumChatFormatting.YELLOW, EnumChatFormatting.GOLD, EnumChatFormatting.RED, EnumChatFormatting.RED, EnumChatFormatting.WHITE};
-
- private static final char STAR = '\u2727';
- private static final Pattern PATTERN_CRIT = Pattern.compile("\u00a7f"+STAR+"((?:\u00a7.\\d)+)\u00a7."+STAR+"(.*)");
- private static final Pattern PATTERN_NO_CRIT = Pattern.compile("\u00a77(\\d+)(.*)");
-
- public static IChatComponent replaceName(EntityLivingBase entity) {
- if(!entity.hasCustomName()) return entity.getDisplayName();
-
- IChatComponent name = entity.getDisplayName();
- if(NotEnoughUpdates.INSTANCE.config.misc.damageIndicatorStyle == 0) return name;
-
- if(replacementMap.containsKey(entity)) {
- ChatComponentText component = replacementMap.get(entity);
- if(component == null) return name;
- return component;
- }
-
- String formatted = name.getFormattedText();
-
- boolean crit = false;
- String numbers;
- String prefix;
- String suffix;
-
- Matcher matcherCrit = PATTERN_CRIT.matcher(formatted);
- if(matcherCrit.matches()) {
- crit = true;
- numbers = StringUtils.cleanColour(matcherCrit.group(1));
- prefix = "\u00a7f"+STAR;
- suffix = "\u00a7f"+STAR+matcherCrit.group(2);
- } else {
- Matcher matcherNoCrit = PATTERN_NO_CRIT.matcher(formatted);
- if(matcherNoCrit.matches()) {
- numbers = matcherNoCrit.group(1);
- prefix = "\u00A77";
- suffix = "\u00A7r"+matcherNoCrit.group(2);
- } else {
- replacementMap.put(entity, null);
- return name;
- }
- }
-
- StringBuilder newFormatted = new StringBuilder();
-
- try {
- int number = Integer.parseInt(numbers);
-
- if(number > 999 && NotEnoughUpdates.INSTANCE.config.misc.damageIndicatorStyle == 2) {
- newFormatted.append(Utils.shortNumberFormat(number, 0));
- } else {
- newFormatted.append(NumberFormat.getIntegerInstance().format(number));
- }
- } catch(NumberFormatException e) {
- replacementMap.put(entity, null);
- return name;
- }
-
- if(crit) {
- StringBuilder newFormattedCrit = new StringBuilder();
-
- int colourIndex = 0;
- for(char c : newFormatted.toString().toCharArray()) {
- if(c == ',') {
- newFormattedCrit.append(EnumChatFormatting.GRAY);
- } else {
- newFormattedCrit.append(coloursHypixel[colourIndex++ % coloursHypixel.length]);
- }
- newFormattedCrit.append(c);
- }
-
- newFormatted = newFormattedCrit;
- }
-
- ChatComponentText finalComponent = new ChatComponentText(prefix+newFormatted.toString()+suffix);
-
- replacementMap.put(entity, finalComponent);
- return finalComponent;
-
- /*if(formatted.startsWith("\u00A7f\u2727")) System.out.println(formatted);
-
- if(formatted.length() >= 7 && (formatted.startsWith("\u00A7f\u2727") || formatted.startsWith("\u00A7f\u2694")) &&
+ private static final WeakHashMap<EntityLivingBase, ChatComponentText> replacementMap = new WeakHashMap<>();
+
+ private static final EnumChatFormatting[] coloursHypixel = {
+ EnumChatFormatting.WHITE,
+ EnumChatFormatting.YELLOW,
+ EnumChatFormatting.GOLD,
+ EnumChatFormatting.RED,
+ EnumChatFormatting.RED,
+ EnumChatFormatting.WHITE
+ };
+
+ private static final char STAR = '\u2727';
+ private static final Pattern PATTERN_CRIT = Pattern.compile(
+ "\u00a7f" + STAR + "((?:\u00a7.\\d)+)\u00a7." + STAR + "(.*)");
+ private static final Pattern PATTERN_NO_CRIT = Pattern.compile("\u00a77(\\d+)(.*)");
+
+ public static IChatComponent replaceName(EntityLivingBase entity) {
+ if (!entity.hasCustomName()) return entity.getDisplayName();
+
+ IChatComponent name = entity.getDisplayName();
+ if (NotEnoughUpdates.INSTANCE.config.misc.damageIndicatorStyle == 0) return name;
+
+ if (replacementMap.containsKey(entity)) {
+ ChatComponentText component = replacementMap.get(entity);
+ if (component == null) return name;
+ return component;
+ }
+
+ String formatted = name.getFormattedText();
+
+ boolean crit = false;
+ String numbers;
+ String prefix;
+ String suffix;
+
+ Matcher matcherCrit = PATTERN_CRIT.matcher(formatted);
+ if (matcherCrit.matches()) {
+ crit = true;
+ numbers = StringUtils.cleanColour(matcherCrit.group(1));
+ prefix = "\u00a7f" + STAR;
+ suffix = "\u00a7f" + STAR + matcherCrit.group(2);
+ } else {
+ Matcher matcherNoCrit = PATTERN_NO_CRIT.matcher(formatted);
+ if (matcherNoCrit.matches()) {
+ numbers = matcherNoCrit.group(1);
+ prefix = "\u00A77";
+ suffix = "\u00A7r" + matcherNoCrit.group(2);
+ } else {
+ replacementMap.put(entity, null);
+ return name;
+ }
+ }
+
+ StringBuilder newFormatted = new StringBuilder();
+
+ try {
+ int number = Integer.parseInt(numbers);
+
+ if (number > 999 && NotEnoughUpdates.INSTANCE.config.misc.damageIndicatorStyle == 2) {
+ newFormatted.append(Utils.shortNumberFormat(number, 0));
+ } else {
+ newFormatted.append(NumberFormat.getIntegerInstance().format(number));
+ }
+ } catch (NumberFormatException e) {
+ replacementMap.put(entity, null);
+ return name;
+ }
+
+ if (crit) {
+ StringBuilder newFormattedCrit = new StringBuilder();
+
+ int colourIndex = 0;
+ for (char c : newFormatted.toString().toCharArray()) {
+ if (c == ',') {
+ newFormattedCrit.append(EnumChatFormatting.GRAY);
+ } else {
+ newFormattedCrit.append(coloursHypixel[colourIndex++ % coloursHypixel.length]);
+ }
+ newFormattedCrit.append(c);
+ }
+
+ newFormatted = newFormattedCrit;
+ }
+
+ ChatComponentText finalComponent = new ChatComponentText(prefix + newFormatted + suffix);
+
+ replacementMap.put(entity, finalComponent);
+ return finalComponent;
+
+ /*if (formatted.startsWith("\u00A7f\u2727")) System.out.println(formatted);
+
+ if (formatted.length() >= 7 && (formatted.startsWith("\u00A7f\u2727") || formatted.startsWith("\u00A7f\u2694")) &&
(formatted.endsWith("\u2727\u00a7r") || formatted.endsWith("\u2694\u00a7r"))) {
- if(NotEnoughUpdates.INSTANCE.config.misc.damageIndicatorStyle == 2) {
- String numbers = Utils.cleanColour(formatted.substring(3, formatted.length()-3)).trim().replaceAll("[^0-9]", "");
+ if (NotEnoughUpdates.INSTANCE.config.misc.damageIndicatorStyle == 2) {
+ String numbers = Utils.cleanColour(formatted.substring(3, formatted.length() - 3)).trim().replaceAll("[^0-9]", "");
try {
int damage = Integer.parseInt(numbers);
String damageString;
- if(damage > 999) {
+ if (damage > 999) {
damageString = Utils.shortNumberFormat(damage, 0);
} else {
damageString = NumberFormat.getIntegerInstance().format(damage);
@@ -116,10 +122,10 @@ public class DamageCommas {
StringBuilder colouredString = new StringBuilder();
int colourIndex = 0;
- for(int i=0; i<damageString.length(); i++) {
+ for (int i = 0; i < damageString.length(); i++) {
int index = damageString.length() - 1 - i;
char c = damageString.charAt(index);
- if(c >= '0' && c <= '9') {
+ if (c >= '0' && c <= '9') {
colouredString.insert(0, c);
colouredString.insert(0, colours[colourIndex++ % colours.length]);
} else {
@@ -127,10 +133,10 @@ public class DamageCommas {
}
}
- ChatComponentText ret = new ChatComponentText("\u00A7f\u2727"+colouredString+"\u00a7r\u2727\u00a7r");
+ ChatComponentText ret = new ChatComponentText("\u00A7f\u2727" + colouredString + "\u00a7r\u2727\u00a7r");
replacementMap.put(hashCode, ret);
return ret;
- } catch(NumberFormatException ignored) {}
+ } catch (NumberFormatException ignored) {}
}
StringBuilder builder = new StringBuilder();
@@ -138,42 +144,42 @@ public class DamageCommas {
boolean colLast = false;
boolean colLastLast;
int numCount = 0;
- for(int i=formatted.length()-4; i>=3; i--) {
+ for (int i = formatted.length() - 4; i >= 3; i--) {
char c = formatted.charAt(i);
colLastLast = colLast;
- if(c == '\u00a7') {
- if(numLast) numCount--;
+ if (c == '\u00a7') {
+ if (numLast) numCount--;
numLast = false;
colLast = true;
- } else if((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f')) {
+ } else if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f')) {
numLast = true;
colLast = false;
numCount++;
} else {
- if(colLast) {
+ if (colLast) {
replacementMap.put(hashCode, null);
return name;
}
numLast = false;
}
- if(colLastLast && numLast && numCount > 1 && (numCount-1) % 3 == 0) builder.append(',');
+ if (colLastLast && numLast && numCount > 1 && (numCount - 1) % 3 == 0) builder.append(',');
builder.append(c);
}
- ChatComponentText ret = new ChatComponentText("\u00A7f\u2727"+builder.reverse().toString()+"\u2727\u00a7r");
+ ChatComponentText ret = new ChatComponentText("\u00A7f\u2727" + builder.reverse().toString() + "\u2727\u00a7r");
replacementMap.put(hashCode, ret);
return ret;
}
- if(formatted.length() >= 5 && formatted.startsWith(EnumChatFormatting.GRAY.toString()) &&
+ if (formatted.length() >= 5 && formatted.startsWith(EnumChatFormatting.GRAY.toString()) &&
formatted.endsWith(EnumChatFormatting.RESET.toString())) {
- String damageS = formatted.substring(2, formatted.length()-2);
+ String damageS = formatted.substring(2, formatted.length() - 2);
- for(int i=0; i<damageS.length(); i++) {
+ for (int i = 0; i < damageS.length(); i++) {
char c = damageS.charAt(i);
- if(c < '0' || c > '9') {
+ if (c < '0' || c > '9') {
replacementMap.put(hashCode, null);
return name;
}
@@ -183,22 +189,21 @@ public class DamageCommas {
int damage = Integer.parseInt(damageS);
String damageFormatted;
- if(NotEnoughUpdates.INSTANCE.config.misc.damageIndicatorStyle == 2 && damage > 999) {
+ if (NotEnoughUpdates.INSTANCE.config.misc.damageIndicatorStyle == 2 && damage > 999) {
damageFormatted = Utils.shortNumberFormat(damage, 0);
} else {
damageFormatted = NumberFormat.getIntegerInstance().format(damage);
}
- ChatComponentText ret = new ChatComponentText(EnumChatFormatting.GRAY+damageFormatted+EnumChatFormatting.RESET);
+ ChatComponentText ret = new ChatComponentText(EnumChatFormatting.GRAY + damageFormatted + EnumChatFormatting.RESET);
replacementMap.put(hashCode, ret);
return ret;
- } catch(Exception e) {
+ } catch (Exception e) {
replacementMap.put(hashCode, null);
return name;
}
}
replacementMap.put(hashCode, null);
return name;*/
- }
-
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesTextures.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesTextures.java
deleted file mode 100644
index b05c430d..00000000
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesTextures.java
+++ /dev/null
@@ -1,407 +0,0 @@
-package io.github.moulberry.notenoughupdates.miscfeatures;
-
-import com.google.gson.*;
-import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
-import io.github.moulberry.notenoughupdates.util.SBInfo;
-import io.github.moulberry.notenoughupdates.util.SpecialColour;
-import net.minecraft.block.BlockClay;
-import net.minecraft.block.BlockColored;
-import net.minecraft.block.BlockHardenedClay;
-import net.minecraft.block.BlockStone;
-import net.minecraft.block.state.IBlockState;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.entity.Entity;
-import net.minecraft.init.Blocks;
-import net.minecraft.item.EnumDyeColor;
-import net.minecraft.util.AxisAlignedBB;
-import net.minecraft.util.BlockPos;
-import net.minecraft.util.MathHelper;
-import net.minecraft.util.ResourceLocation;
-import net.minecraft.world.ChunkCoordIntPair;
-import net.minecraft.world.biome.BiomeGenBase;
-import net.minecraftforge.client.event.RenderWorldLastEvent;
-import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
-import org.lwjgl.input.Keyboard;
-import org.lwjgl.input.Mouse;
-
-import java.io.*;
-import java.nio.charset.StandardCharsets;
-import java.util.*;
-
-public class DwarvenMinesTextures {
-
- private static class IgnoreColumn {
- boolean always;
- int minY;
- int maxY;
-
- public IgnoreColumn(boolean always, int minY, int maxY) {
- this.always = always;
- this.minY = minY;
- this.maxY = maxY;
- }
- }
-
- private static HashSet<ChunkCoordIntPair> ignoredChunks = null;
- private static final HashMap<ChunkCoordIntPair, HashMap<ChunkCoordIntPair, IgnoreColumn>> loadedChunkData = new HashMap<>();
- private static final HashMap<ChunkCoordIntPair, Long> lastRetextureCheck = new HashMap<>();
- private static long time;
- private static boolean error = false;
-
- public static int retexture(BlockPos pos) {
- if(!NotEnoughUpdates.INSTANCE.config.mining.dwarvenTextures) return 0;
- if(error) return 0;
- if(Minecraft.getMinecraft().theWorld == null) return 0;
-
- String location = SBInfo.getInstance().getLocation();
-
- if(location == null) return 0;
- if(location.equals("crystal_hollows")) return 3;
- if(!location.equals("mining_3")) return 0;
-
- IBlockState state = Minecraft.getMinecraft().theWorld.getBlockState(pos);
- boolean titanium = state.getBlock() == Blocks.stone && state.getValue(BlockStone.VARIANT) == BlockStone.EnumType.DIORITE_SMOOTH;
- if(titanium) {
- IBlockState plus = Minecraft.getMinecraft().theWorld.getBlockState(pos.add(1, 0, 0));
- if(plus.getBlock() == Blocks.double_stone_slab) {
- return 1;
- }
- IBlockState minus = Minecraft.getMinecraft().theWorld.getBlockState(pos.add(-1, 0, 0));
- if(minus.getBlock() == Blocks.double_stone_slab) {
- return 1;
- }
- IBlockState above = Minecraft.getMinecraft().theWorld.getBlockState(pos.add(0, 1, 0));
- if(above.getBlock() == Blocks.stone_slab) {
- return 1;
- }
- }
-
- if(titanium || (state.getBlock() == Blocks.stained_hardened_clay && state.getValue(BlockColored.COLOR) == EnumDyeColor.CYAN) ||
- (state.getBlock() == Blocks.wool && state.getValue(BlockColored.COLOR) == EnumDyeColor.GRAY)) {
-
- if(ignoredChunks == null) {
- try {
- ignoredChunks = new HashSet<>();
- ResourceLocation loc = new ResourceLocation("notenoughupdates:dwarven_data/all.json");
- InputStream is = Minecraft.getMinecraft().getResourceManager().getResource(loc).getInputStream();
-
- try(BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) {
- JsonObject json = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(reader, JsonObject.class);
- for(Map.Entry<String, JsonElement> entry : json.entrySet()) {
- String coord = entry.getKey();
- String[] split = coord.split("_");
- int left = Integer.parseInt(split[0]);
- int right = Integer.parseInt(split[1]);
- ignoredChunks.add(new ChunkCoordIntPair(left, right));
- }
- }
- } catch(Exception e) {
- error = true;
- return 1;
- }
- }
- if(ignoredChunks != null) {
- ChunkCoordIntPair pair = new ChunkCoordIntPair(MathHelper.floor_float(pos.getX()/16f),
- MathHelper.floor_float(pos.getZ()/16f));
-
- lastRetextureCheck.put(pair, time);
-
- if(ignoredChunks.contains(pair)) {
- return 1;
- }
- if(titanium) {
- return 2;
- }
-
- if(!loadedChunkData.containsKey(pair)) {
- try {
- HashMap<ChunkCoordIntPair, IgnoreColumn> map = new HashMap<>();
- loadedChunkData.put(pair, map);
-
- ResourceLocation loc = new ResourceLocation("notenoughupdates:dwarven_data/"+
- pair.chunkXPos+"_"+pair.chunkZPos+".json");
- InputStream is = Minecraft.getMinecraft().getResourceManager().getResource(loc).getInputStream();
-
- try(BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) {
- JsonObject json = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(reader, JsonObject.class);
- for(Map.Entry<String, JsonElement> entry : json.entrySet()) {
- String coord = entry.getKey();
- String[] split = coord.split(":");
- int left = Integer.parseInt(split[0]);
- int right = Integer.parseInt(split[1]);
-
- IgnoreColumn ignore = null;
- if(entry.getValue().isJsonPrimitive()) {
- JsonPrimitive prim = entry.getValue().getAsJsonPrimitive();
- if(prim.isBoolean()) {
- ignore = new IgnoreColumn(true, 0, 0);
- } else if(prim.isNumber()) {
- int y = prim.getAsInt();
- ignore = new IgnoreColumn(false, y, y);
- }
- } else if(entry.getValue().isJsonArray()) {
- JsonArray arr = entry.getValue().getAsJsonArray();
- if(arr.size() == 2) {
- int min = arr.get(0).getAsInt();
- int max = arr.get(1).getAsInt();
- ignore = new IgnoreColumn(false, min, max);
- }
- }
- if (ignore != null) {
- ChunkCoordIntPair offset = new ChunkCoordIntPair(left, right);
- map.put(offset, ignore);
- }
- }
- }
- } catch(Exception e) {
- loadedChunkData.put(pair, null);
- }
- }
- if(loadedChunkData.get(pair) != null) {
- HashMap<ChunkCoordIntPair, IgnoreColumn> map = loadedChunkData.get(pair);
- if(map == null) {
- return 0;
- }
-
- int modX = pos.getX() % 16;
- int modZ = pos.getZ() % 16;
- if(modX < 0) modX += 16;
- if(modZ < 0) modZ += 16;
- ChunkCoordIntPair offset = new ChunkCoordIntPair(modX, modZ);
-
- IgnoreColumn ignore = map.get(offset);
- if(ignore != null) {
- if(ignore.always) {
- return 1;
- } else {
- int y = pos.getY();
- if(y >= ignore.minY && y <= ignore.maxY) {
- return 1;
- }
- }
- }
- }
- }
- }
-
- return 2;
- }
-
- /*@SubscribeEvent
- public void onRender(RenderWorldLastEvent event) {
- Entity viewer = Minecraft.getMinecraft().getRenderViewEntity();
- double viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * event.partialTicks;
- double viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * event.partialTicks;
- double viewerZ = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * event.partialTicks;
-
- int x = MathHelper.floor_double(viewer.posX/16f);
- int z = MathHelper.floor_double(viewer.posZ/16f);
- File file = new File("C:/Users/James/Desktop/testfolder/"+x+"_"+z+".json");
-
- int col = 0xff0000;
- if(file.exists()) {
- col = 0x00ff00;
- if(Keyboard.isKeyDown(Keyboard.KEY_K)) {
- file.delete();
- }
-
- }
-
- AxisAlignedBB bb = new AxisAlignedBB(
- MathHelper.floor_double(viewerX/16)*16-viewerX,
- 0-viewerY,
- MathHelper.floor_double(viewerZ/16)*16-viewerZ,
- MathHelper.floor_double(viewerX/16)*16+16-viewerX,
- 255-viewerY,
- MathHelper.floor_double(viewerZ/16)*16+16-viewerZ).expand(0.01f, 0.01f, 0.01f);
-
- GlStateManager.disableCull();
- CustomItemEffects.drawFilledBoundingBox(bb, 1f, SpecialColour.special(0, 100, col));
- GlStateManager.enableCull();
- GlStateManager.enableTexture2D();
- }*/
-
- //Render all blocks - extremeHillsEdge
- //Don't render smooth diorite - extremeHillsPlus
- //Don't render clay - mesaPlateau_F
-
- public static void tick() {
- if(!NotEnoughUpdates.INSTANCE.config.mining.dwarvenTextures) return;
-
- time = System.currentTimeMillis();
- Set<ChunkCoordIntPair> remove = new HashSet<>();
- for(Map.Entry<ChunkCoordIntPair, Long> entry : lastRetextureCheck.entrySet()) {
- if(time - entry.getValue() > 30*1000) {
- remove.add(entry.getKey());
- }
- }
- lastRetextureCheck.keySet().removeAll(remove);
- loadedChunkData.keySet().removeAll(remove);
-
- /*if(Minecraft.getMinecraft().theWorld == null) return;
-
- if(SBInfo.getInstance().getLocation() == null) return;
- if(!SBInfo.getInstance().getLocation().equals("mining_3")) return;
-
- int playerX = (int)Minecraft.getMinecraft().thePlayer.posX;
- int playerZ = (int)Minecraft.getMinecraft().thePlayer.posZ;
-
-
- if(Keyboard.isKeyDown(Keyboard.KEY_C)) {
- ignoredBlocks.clear();
- whitelistBlocks.clear();
- }
- if(Keyboard.isKeyDown(Keyboard.KEY_R)) {
- ignoredChunks.clear();
- }
- if(Keyboard.isKeyDown(Keyboard.KEY_P)) {
- Gson gson = new GsonBuilder().create();
- JsonObject obj = new JsonObject();
-
- for(Map.Entry<ChunkCoordIntPair, HashMap<ChunkCoordIntPair, Set<BlockPos>>> entry : ignoredBlocks.entrySet()) {
- String chunkId = entry.getKey().chunkXPos + "_" + entry.getKey().chunkZPos;
- if(!whitelistBlocks.containsKey(entry.getKey()) || whitelistBlocks.get(entry.getKey()).isEmpty()) {
- obj.addProperty(chunkId, true);
- } else {
- HashMap<ChunkCoordIntPair, Set<BlockPos>> whitelistMap = whitelistBlocks.get(entry.getKey());
- JsonObject subChunkObj = new JsonObject();
-
- for(Map.Entry<ChunkCoordIntPair, Set<BlockPos>> columnEntry : entry.getValue().entrySet()) {
- String columnId = columnEntry.getKey().chunkXPos + ":" + columnEntry.getKey().chunkZPos;
-
- if(!whitelistMap.containsKey(columnEntry.getKey()) || whitelistMap.get(columnEntry.getKey()).isEmpty()) {
- subChunkObj.addProperty(columnId, true);
- } else if(!columnEntry.getValue().isEmpty()) {
- JsonArray whitelistedBlocksInColumn = new JsonArray();
-
- int min = 300;
- int max = 0;
- for(BlockPos pos : columnEntry.getValue()) {
- int y = pos.getY();
- if(y < min) {
- min = y;
- }
- if(y > max) {
- max = y;
- }
- }
- whitelistedBlocksInColumn.add(new JsonPrimitive(min));
- whitelistedBlocksInColumn.add(new JsonPrimitive(max));
- if(min < max) {
- subChunkObj.add(columnId, whitelistedBlocksInColumn);
- } else {
- subChunkObj.addProperty(columnId, min);
- }
- }
- }
- try {
- File file = new File("C:/Users/James/Desktop/testfolder/"+chunkId+".json");
- file.createNewFile();
-
- try(BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8))) {
- writer.write(gson.toJson(subChunkObj));
- }
- } catch(IOException ignored) {
- ignored.printStackTrace();
- }
- }
- }
-
- try {
- File file = new File("C:/Users/James/Desktop/testfolder/all.json");
- file.createNewFile();
-
- try(BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8))) {
- writer.write(gson.toJson(obj));
- }
- } catch(IOException ignored) {
- ignored.printStackTrace();
- }
-
- }
-
- for(int xC=-10; xC<=10; xC++) {
- out:
- for(int zC=-10; zC<=10; zC++) {
- ChunkCoordIntPair pair = new ChunkCoordIntPair(playerX/16+xC, playerZ/16+zC);
-
- if(!ignoredChunks.contains(pair)) {
- ignoredChunks.add(pair);
-
- boolean add = false;
- for(int x=0; x<16; x++) {
- for(int y=0; y<255; y++) {
- for(int z=0; z<16; z++) {
- BlockPos pos = new BlockPos(pair.chunkXPos*16+x, y, pair.chunkZPos*16+z);
- IBlockState state = Minecraft.getMinecraft().theWorld.getBlockState(pos);
-
- ChunkCoordIntPair column = new ChunkCoordIntPair(x, z);
-
- if(state != null && state.getBlock() != Blocks.air) add = true;
-
- if(state != null && ((state.getBlock() == Blocks.stained_hardened_clay &&
- state.getValue(BlockColored.COLOR) == EnumDyeColor.CYAN) ||
- (state.getBlock() == Blocks.wool) && state.getValue(BlockColored.COLOR) == EnumDyeColor.GRAY ||
- (state.getBlock() == Blocks.stone && state.getValue(BlockStone.VARIANT) == BlockStone.EnumType.DIORITE_SMOOTH))) {
-
- boolean hasAir = false;
- for(int xO=-1; xO<=1; xO++) {
- for (int yO = -1; yO <= 1; yO++) {
- for (int zO = -1; zO <= 1; zO++) {
- int tot = Math.abs(xO) + Math.abs(yO) + Math.abs(zO);
- if(tot == 1) {
- BlockPos pos2 = pos.add(xO, yO, zO);
- IBlockState state2 = Minecraft.getMinecraft().theWorld.getBlockState(pos2);
-
- if(state2 == null) {
- continue out;
- } else if(state2.getBlock() == Blocks.air) {
- hasAir = true;
- }
- }
- }
- }
- }
- if(!hasAir) continue;
-
- boolean found = false;
- out2:
- for(int xO=-4; xO<=4; xO++) {
- for(int yO=-4; yO<=4; yO++) {
- for(int zO=-4; zO<=4; zO++) {
- int distSq = xO*xO + yO*yO + zO*zO;
- if(distSq < 4*4) {
- BlockPos pos2 = pos.add(xO, yO, zO);
- IBlockState state2 = Minecraft.getMinecraft().theWorld.getBlockState(pos2);
-
- if(state2 == null) {
- continue out;
- } else if(state2.getBlock() == Blocks.prismarine) {
- ignoredBlocks.computeIfAbsent(pair, k->new HashMap<>())
- .computeIfAbsent(column, k-> new HashSet<>()).remove(pos);
- whitelistBlocks.computeIfAbsent(pair, k->new HashMap<>())
- .computeIfAbsent(column, k-> new HashSet<>()).add(pos);
- found = true;
- break out2;
- }
- }
- }
- }
- }
- if(!found) {
- ignoredBlocks.computeIfAbsent(pair, k->new HashMap<>())
- .computeIfAbsent(column, k-> new HashSet<>()).add(pos);
- }
-
- }
- }
- }
- }
- }
-
- }
- }*/
- }
-
-}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesWaypoints.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesWaypoints.java
index 5c4fb61d..f7f9003c 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesWaypoints.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesWaypoints.java
@@ -8,13 +8,7 @@ import io.github.moulberry.notenoughupdates.util.SBInfo;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
-import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.inventory.GuiChest;
-import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.client.renderer.Tessellator;
-import net.minecraft.client.renderer.WorldRenderer;
-import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
-import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityArmorStand;
import net.minecraft.inventory.ContainerChest;
import net.minecraft.inventory.IInventory;
@@ -25,7 +19,6 @@ import net.minecraftforge.client.event.RenderLivingEvent;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
-import org.lwjgl.opengl.GL11;
import org.lwjgl.util.vector.Vector3f;
import java.util.HashMap;
@@ -36,227 +29,247 @@ import java.util.regex.Pattern;
public class DwarvenMinesWaypoints {
- private HashMap<String, Vector3f> waypointsMap = new HashMap<>();
- {
- waypointsMap.put("Dwarven Village", new Vector3f(-37, 199, -122));
- waypointsMap.put("Miner's Guild", new Vector3f(-74, 220, -122));
- waypointsMap.put("Fetchur", new Vector3f(85, 223, -120));
- waypointsMap.put("Palace Bridge", new Vector3f(129, 186, 8));
- waypointsMap.put("Royal Palace", new Vector3f(129, 194, 194));
- waypointsMap.put("Puzzler", new Vector3f(181, 195, 135));
- waypointsMap.put("Grand Library", new Vector3f(183, 195, 181));
- waypointsMap.put("Barracks of Heroes", new Vector3f(93, 195, 181));
- waypointsMap.put("Royal Mines", new Vector3f(178, 149, 71));
- waypointsMap.put("Cliffside Veins", new Vector3f(40, 136, 17));
- waypointsMap.put("Forge Basin", new Vector3f(0, 169, -2));
- waypointsMap.put("The Forge", new Vector3f(0, 148, -69));
- waypointsMap.put("Rampart's Quarry", new Vector3f(-106, 147, 2));
- waypointsMap.put("Far Reserve", new Vector3f(-160, 148, 17));
- waypointsMap.put("Upper Mines", new Vector3f(-123, 170, -71));
- waypointsMap.put("Goblin Burrows", new Vector3f(-138, 143, 141));
- waypointsMap.put("Great Ice Wall", new Vector3f(0, 127, 160));
- waypointsMap.put("Aristocrat Passage", new Vector3f(129, 150, 137));
- waypointsMap.put("Hanging Court", new Vector3f(91, 186, 129));
- waypointsMap.put("Divan's Gateway", new Vector3f(0, 127, 87));
- waypointsMap.put("Lava Springs", new Vector3f(57, 196, -15));
- waypointsMap.put("The Mist", new Vector3f(0, 75, 82));
- }
+ private final HashMap<String, Vector3f> waypointsMap = new HashMap<String, Vector3f>() {{
+ put("Dwarven Village", new Vector3f(-37, 199, -122));
+ put("Miner's Guild", new Vector3f(-74, 220, -122));
+ put("Fetchur", new Vector3f(85, 223, -120));
+ put("Palace Bridge", new Vector3f(129, 186, 8));
+ put("Royal Palace", new Vector3f(129, 194, 194));
+ put("Puzzler", new Vector3f(181, 195, 135));
+ put("Grand Library", new Vector3f(183, 195, 181));
+ put("Barracks of Heroes", new Vector3f(93, 195, 181));
+ put("Royal Mines", new Vector3f(178, 149, 71));
+ put("Cliffside Veins", new Vector3f(40, 136, 17));
+ put("Forge Basin", new Vector3f(0, 169, -2));
+ put("The Forge", new Vector3f(0, 148, -69));
+ put("Rampart's Quarry", new Vector3f(-106, 147, 2));
+ put("Far Reserve", new Vector3f(-160, 148, 17));
+ put("Upper Mines", new Vector3f(-123, 170, -71));
+ put("Goblin Burrows", new Vector3f(-138, 143, 141));
+ put("Great Ice Wall", new Vector3f(0, 127, 160));
+ put("Aristocrat Passage", new Vector3f(129, 150, 137));
+ put("Hanging Court", new Vector3f(91, 186, 129));
+ put("Divan's Gateway", new Vector3f(0, 127, 87));
+ put("Lava Springs", new Vector3f(57, 196, -15));
+ put("The Mist", new Vector3f(0, 75, 82));
+ }};
- private static final HashSet<String> emissaryNames = new HashSet<>();
- static {
- emissaryNames.add(EnumChatFormatting.GOLD+"Emissary Ceanna"+EnumChatFormatting.RESET);
- emissaryNames.add(EnumChatFormatting.GOLD+"Emissary Carlton"+EnumChatFormatting.RESET);
- emissaryNames.add(EnumChatFormatting.GOLD+"Emissary Wilson"+EnumChatFormatting.RESET);
- emissaryNames.add(EnumChatFormatting.GOLD+"Emissary Lilith"+EnumChatFormatting.RESET);
- emissaryNames.add(EnumChatFormatting.GOLD+"Emissary Frasier"+EnumChatFormatting.RESET);
- emissaryNames.add(EnumChatFormatting.GOLD+"Emissary Eliza"+EnumChatFormatting.RESET);
- emissaryNames.add(EnumChatFormatting.GOLD.toString()+EnumChatFormatting.BOLD+"King Thormyr"+EnumChatFormatting.RESET);
- }
+ private static final HashSet<String> emissaryNames = new HashSet<String>() {{
+ add(EnumChatFormatting.GOLD + "Emissary Ceanna" + EnumChatFormatting.RESET);
+ add(EnumChatFormatting.GOLD + "Emissary Carlton" + EnumChatFormatting.RESET);
+ add(EnumChatFormatting.GOLD + "Emissary Wilson" + EnumChatFormatting.RESET);
+ add(EnumChatFormatting.GOLD + "Emissary Lilith" + EnumChatFormatting.RESET);
+ add(EnumChatFormatting.GOLD + "Emissary Frasier" + EnumChatFormatting.RESET);
+ add(EnumChatFormatting.GOLD + "Emissary Eliza" + EnumChatFormatting.RESET);
+ add(EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + "King Thormyr" + EnumChatFormatting.RESET);
+ }};
- private enum Emissary {
- THORMYR("King Thormyr", 0, new Vector3f(129, 196, 196)),
- CEANNA("Emissary Ceanna", 1, new Vector3f(42, 134, 22)),
- CARLTON("Emissary Carlton", 1, new Vector3f(-73, 153, -11)),
- WILSON("Emissary Wilson", 2, new Vector3f(171, 150, 31)),
- LILITH("Emissary Lilith", 2, new Vector3f(58, 198, -8)),
- FRAISER("Emissary Frasier", 3, new Vector3f(-132, 174, -50)),
- ELIZA("Emissary Eliza", 3, new Vector3f(-37, 200, -131));
+ private enum Emissary {
+ THORMYR("King Thormyr", 0, new Vector3f(129, 196, 196)),
+ CEANNA("Emissary Ceanna", 1, new Vector3f(42, 134, 22)),
+ CARLTON("Emissary Carlton", 1, new Vector3f(-73, 153, -11)),
+ WILSON("Emissary Wilson", 2, new Vector3f(171, 150, 31)),
+ LILITH("Emissary Lilith", 2, new Vector3f(58, 198, -8)),
+ FRAISER("Emissary Frasier", 3, new Vector3f(-132, 174, -50)),
+ ELIZA("Emissary Eliza", 3, new Vector3f(-37, 200, -131));
- String name;
- int minMilestone;
- Vector3f loc;
- Emissary(String name, int minMilestone, Vector3f loc) {
- this.name = name;
- this.minMilestone = minMilestone;
- this.loc = loc;
- }
- }
+ String name;
+ int minMilestone;
+ Vector3f loc;
- private long dynamicMillis = 0;
- private String dynamicLocation = null;
- private String dynamicName = null;
- private final Pattern ghastRegex = Pattern.compile("\u00A7r\u00A7eFind the \u00A7r\u00A76Powder Ghast\u00A7r\u00A7e near the \u00A7r\u00A7b(.+)!");
- private final Pattern fallenStarRegex = Pattern.compile("\u00A7r\u00A75Fallen Star \u00A7r\u00A7ehas crashed at \u00A7r\u00A7b(.+)\u00A7r\u00A7e!");
+ Emissary(String name, int minMilestone, Vector3f loc) {
+ this.name = name;
+ this.minMilestone = minMilestone;
+ this.loc = loc;
+ }
+ }
- @SubscribeEvent
- public void onChat(ClientChatReceivedEvent event) {
- Matcher matcherGhast = ghastRegex.matcher(event.message.getFormattedText());
- if(matcherGhast.find()) {
- dynamicLocation = Utils.cleanColour(matcherGhast.group(1).trim());
- dynamicName = EnumChatFormatting.GOLD+"Powder Ghast";
- dynamicMillis = System.currentTimeMillis();
- } else {
- Matcher matcherStar = fallenStarRegex.matcher(event.message.getFormattedText());
- if(matcherStar.find()) {
- dynamicLocation = Utils.cleanColour(matcherStar.group(1).trim());
- dynamicName = EnumChatFormatting.DARK_PURPLE+"Fallen Star";
- dynamicMillis = System.currentTimeMillis();
- }
- }
- }
+ private long dynamicMillis = 0;
+ private String dynamicLocation = null;
+ private String dynamicName = null;
+ private final Pattern ghastRegex = Pattern.compile(
+ "\u00A7r\u00A7eFind the \u00A7r\u00A76Powder Ghast\u00A7r\u00A7e near the \u00A7r\u00A7b(.+)!");
+ private final Pattern fallenStarRegex = Pattern.compile(
+ "\u00A7r\u00A75Fallen Star \u00A7r\u00A7ehas crashed at \u00A7r\u00A7b(.+)\u00A7r\u00A7e!");
- @SubscribeEvent
- public void onTick(TickEvent.ClientTickEvent event) {
- emissaryRemovedDistSq = -1;
+ @SubscribeEvent
+ public void onChat(ClientChatReceivedEvent event) {
+ Matcher matcherGhast = ghastRegex.matcher(event.message.getFormattedText());
+ if (matcherGhast.find()) {
+ dynamicLocation = Utils.cleanColour(matcherGhast.group(1).trim());
+ dynamicName = EnumChatFormatting.GOLD + "Powder Ghast";
+ dynamicMillis = System.currentTimeMillis();
+ } else {
+ Matcher matcherStar = fallenStarRegex.matcher(event.message.getFormattedText());
+ if (matcherStar.find()) {
+ dynamicLocation = Utils.cleanColour(matcherStar.group(1).trim());
+ dynamicName = EnumChatFormatting.DARK_PURPLE + "Fallen Star";
+ dynamicMillis = System.currentTimeMillis();
+ }
+ }
+ }
- if(SBInfo.getInstance().getLocation() == null) return;
- if(!SBInfo.getInstance().getLocation().equals("mining_3")) return;
+ @SubscribeEvent
+ public void onTick(TickEvent.ClientTickEvent event) {
+ emissaryRemovedDistSq = -1;
+ if (SBInfo.getInstance().getLocation() == null) return;
+ if (!SBInfo.getInstance().getLocation().equals("mining_3")) return;
- NEUConfig.HiddenProfileSpecific hidden = NotEnoughUpdates.INSTANCE.config.getProfileSpecific();
- if(hidden == null) return;
+ NEUConfig.HiddenProfileSpecific hidden = NotEnoughUpdates.INSTANCE.config.getProfileSpecific();
+ if (hidden == null) return;
- if(Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
- GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
- ContainerChest container = (ContainerChest) chest.inventorySlots;
- IInventory lower = container.getLowerChestInventory();
+ if (Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
+ GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
+ ContainerChest container = (ContainerChest) chest.inventorySlots;
+ IInventory lower = container.getLowerChestInventory();
- if(lower.getDisplayName().getFormattedText().contains("Commissions")) {
- for(int i=0; i<lower.getSizeInventory(); i++) {
- ItemStack stack = lower.getStackInSlot(i);
- if(stack == null) continue;
- if(stack.getDisplayName().equals(EnumChatFormatting.YELLOW+"Commission Milestones")) {
- hidden.commissionMilestone = 5;
- String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stack.getTagCompound());
- for(String line : lore) {
- String clean = Utils.cleanColour(line);
- if(clean.equals("Tier I Rewards:")) {
- hidden.commissionMilestone = 0;
- } else if(clean.equals("Tier II Rewards:")) {
- hidden.commissionMilestone = 1;
- } else if(clean.equals("Tier III Rewards:")) {
- hidden.commissionMilestone = 2;
- } else if(clean.equals("Tier IV Rewards:")) {
- hidden.commissionMilestone = 3;
- } else if(clean.equals("Tier V Rewards:")) {
- hidden.commissionMilestone = 4;
- }
- }
- return;
- }
- }
- }
- }
- }
+ if (lower.getDisplayName().getFormattedText().contains("Commissions")) {
+ for (int i = 0; i < lower.getSizeInventory(); i++) {
+ ItemStack stack = lower.getStackInSlot(i);
+ if (stack == null) continue;
+ if (stack.getDisplayName().equals(EnumChatFormatting.YELLOW + "Commission Milestones")) {
+ hidden.commissionMilestone = 5;
+ String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stack.getTagCompound());
+ for (String line : lore) {
+ String clean = Utils.cleanColour(line);
+ switch (clean) {
+ case "Tier I Rewards:":
+ hidden.commissionMilestone = 0;
+ break;
+ case "Tier II Rewards:":
+ hidden.commissionMilestone = 1;
+ break;
+ case "Tier III Rewards:":
+ hidden.commissionMilestone = 2;
+ break;
+ case "Tier IV Rewards:":
+ hidden.commissionMilestone = 3;
+ break;
+ case "Tier V Rewards:":
+ hidden.commissionMilestone = 4;
+ break;
+ }
+ }
+ return;
+ }
+ }
+ }
+ }
+ }
- private boolean commissionFinished = false;
- private double emissaryRemovedDistSq = 0;
+ private boolean commissionFinished = false;
+ private double emissaryRemovedDistSq = 0;
- @SubscribeEvent
- public void onRenderSpecial(RenderLivingEvent.Specials.Pre<EntityArmorStand> event) {
- if(SBInfo.getInstance().getLocation() == null) return;
- if(!SBInfo.getInstance().getLocation().equals("mining_3")) return;
+ @SubscribeEvent
+ public void onRenderSpecial(RenderLivingEvent.Specials.Pre<EntityArmorStand> event) {
+ if (SBInfo.getInstance().getLocation() == null) return;
+ if (!SBInfo.getInstance().getLocation().equals("mining_3")) return;
- if(commissionFinished && event.entity instanceof EntityArmorStand) {
- String name = event.entity.getDisplayName().getFormattedText();
- if(emissaryRemovedDistSq > 0 && name.equals(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"CLICK"+EnumChatFormatting.RESET)) {
- EntityPlayerSP p = Minecraft.getMinecraft().thePlayer;
- double distSq = event.entity.getDistanceSq(p.posX, p.posY, p.posZ);
- if(Math.abs(distSq - emissaryRemovedDistSq) < 1) {
- event.setCanceled(true);
- }
- } else if(emissaryNames.contains(name)) {
- EntityPlayerSP p = Minecraft.getMinecraft().thePlayer;
- double distSq = event.entity.getDistanceSq(p.posX, p.posY, p.posZ);
- if(distSq >= 12*12) {
- emissaryRemovedDistSq = distSq;
- event.setCanceled(true);
- }
- }
- }
- }
+ if (commissionFinished && event.entity instanceof EntityArmorStand) {
+ String name = event.entity.getDisplayName().getFormattedText();
+ if (emissaryRemovedDistSq > 0 && name.equals(
+ EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "CLICK" + EnumChatFormatting.RESET)) {
+ EntityPlayerSP p = Minecraft.getMinecraft().thePlayer;
+ double distSq = event.entity.getDistanceSq(p.posX, p.posY, p.posZ);
+ if (Math.abs(distSq - emissaryRemovedDistSq) < 1) {
+ event.setCanceled(true);
+ }
+ } else if (emissaryNames.contains(name)) {
+ EntityPlayerSP p = Minecraft.getMinecraft().thePlayer;
+ double distSq = event.entity.getDistanceSq(p.posX, p.posY, p.posZ);
+ if (distSq >= 12 * 12) {
+ emissaryRemovedDistSq = distSq;
+ event.setCanceled(true);
+ }
+ }
+ }
+ }
+ @SubscribeEvent
+ public void onRenderLast(RenderWorldLastEvent event) {
+ if (SBInfo.getInstance().getLocation() == null) return;
+ if (!SBInfo.getInstance().getLocation().equals("mining_3")) return;
- @SubscribeEvent
- public void onRenderLast(RenderWorldLastEvent event) {
- if(SBInfo.getInstance().getLocation() == null) return;
- if(!SBInfo.getInstance().getLocation().equals("mining_3")) return;
+ int locWaypoint = NotEnoughUpdates.INSTANCE.config.mining.locWaypoints;
+ if (dynamicLocation != null && dynamicName != null &&
+ System.currentTimeMillis() - dynamicMillis < 30 * 1000) {
+ for (Map.Entry<String, Vector3f> entry : waypointsMap.entrySet()) {
+ if (entry.getKey().equals(dynamicLocation)) {
+ RenderUtils.renderWayPoint(
+ dynamicName,
+ new Vector3f(entry.getValue()).translate(0, 15, 0),
+ event.partialTicks
+ );
+ break;
+ }
+ }
+ }
+ String skyblockLocation = SBInfo.getInstance().location.toLowerCase();
+ if (locWaypoint >= 1) {
+ for (Map.Entry<String, Vector3f> entry : waypointsMap.entrySet()) {
+ if (locWaypoint >= 2) {
+ RenderUtils.renderWayPoint(EnumChatFormatting.AQUA + entry.getKey(), entry.getValue(), event.partialTicks);
+ } else {
+ String commissionLocation = entry.getKey().toLowerCase();
+ for (String commissionName : MiningOverlay.commissionProgress.keySet()) {
+ if (NotEnoughUpdates.INSTANCE.config.mining.hideWaypointIfAtLocation)
+ if (commissionLocation.replace("'", "").equals(skyblockLocation)) continue;
+ if (commissionName.toLowerCase().contains(commissionLocation)) {
+ if (commissionName.contains("Titanium")) {
+ RenderUtils.renderWayPoint(
+ EnumChatFormatting.WHITE + entry.getKey(),
+ entry.getValue(),
+ event.partialTicks
+ );
+ } else {
+ RenderUtils.renderWayPoint(
+ EnumChatFormatting.AQUA + entry.getKey(),
+ entry.getValue(),
+ event.partialTicks
+ );
+ }
+ }
+ }
+ }
+ }
+ }
- int locWaypoint = NotEnoughUpdates.INSTANCE.config.mining.locWaypoints;
+ commissionFinished = NotEnoughUpdates.INSTANCE.config.mining.emissaryWaypoints >= 2;
- if(dynamicLocation != null && dynamicName != null &&
- System.currentTimeMillis() - dynamicMillis < 30*1000) {
- for(Map.Entry<String, Vector3f> entry : waypointsMap.entrySet()) {
- if(entry.getKey().equals(dynamicLocation)) {
- RenderUtils.renderWayPoint(dynamicName, new Vector3f(entry.getValue()).translate(0, 15, 0), event.partialTicks);
- break;
- }
- }
- }
+ if (NotEnoughUpdates.INSTANCE.config.mining.emissaryWaypoints == 0) return;
- if(locWaypoint >= 1) {
- for(Map.Entry<String, Vector3f> entry : waypointsMap.entrySet()) {
- if(locWaypoint >= 2) {
- RenderUtils.renderWayPoint(EnumChatFormatting.AQUA+entry.getKey(), entry.getValue(), event.partialTicks);
- } else {
- for(String commissionName : MiningOverlay.commissionProgress.keySet()) {
- if(commissionName.toLowerCase().contains(entry.getKey().toLowerCase())) {
- if(commissionName.contains("Titanium")) {
- RenderUtils.renderWayPoint(EnumChatFormatting.WHITE+entry.getKey(), entry.getValue(), event.partialTicks);
- } else {
- RenderUtils.renderWayPoint(EnumChatFormatting.AQUA+entry.getKey(), entry.getValue(), event.partialTicks);
- }
- }
- }
- }
- }
- }
+ if (!commissionFinished) {
+ for (float f : MiningOverlay.commissionProgress.values()) {
+ if (f >= 1) {
+ commissionFinished = true;
+ break;
+ }
+ }
+ }
+ if (commissionFinished) {
+ for (Emissary emissary : Emissary.values()) {
- commissionFinished = NotEnoughUpdates.INSTANCE.config.mining.emissaryWaypoints >= 2;
+ NEUConfig.HiddenProfileSpecific hidden = NotEnoughUpdates.INSTANCE.config.getProfileSpecific();
+ if (hidden != null) {
+ if (hidden.commissionMilestone >= emissary.minMilestone) {
- if(NotEnoughUpdates.INSTANCE.config.mining.emissaryWaypoints == 0) return;
-
- if(!commissionFinished) {
- for(float f : MiningOverlay.commissionProgress.values()) {
- if (f >= 1) {
- commissionFinished = true;
- break;
- }
- }
- }
- if(commissionFinished) {
- for(Emissary emissary : Emissary.values()) {
-
- NEUConfig.HiddenProfileSpecific hidden = NotEnoughUpdates.INSTANCE.config.getProfileSpecific();
- if(hidden != null) {
- if(hidden.commissionMilestone >= emissary.minMilestone) {
-
- EntityPlayerSP p = Minecraft.getMinecraft().thePlayer;
- double dX = emissary.loc.x + 0.5f - p.posX;
- double dY = emissary.loc.y + 0.188f - p.posY;
- double dZ = emissary.loc.z + 0.5f - p.posZ;
-
- double distSq = dX*dX + dY*dY + dZ*dZ;
- if(distSq >= 12*12) {
- RenderUtils.renderWayPoint(EnumChatFormatting.GOLD+emissary.name,
- new Vector3f(emissary.loc).translate(0.5f, 2.488f, 0.5f),
- event.partialTicks);
- }
- }
- }
-
- }
- }
- }
+ EntityPlayerSP p = Minecraft.getMinecraft().thePlayer;
+ double dX = emissary.loc.x + 0.5f - p.posX;
+ double dY = emissary.loc.y + 0.188f - p.posY;
+ double dZ = emissary.loc.z + 0.5f - p.posZ;
+ double distSq = dX * dX + dY * dY + dZ * dZ;
+ if (distSq >= 12 * 12) {
+ RenderUtils.renderWayPoint(
+ EnumChatFormatting.GOLD + emissary.name,
+ new Vector3f(emissary.loc).translate(0.5f, 2.488f, 0.5f),
+ event.partialTicks
+ );
+ }
+ }
+ }
+ }
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/EnchantingSolvers.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/EnchantingSolvers.java
index 5b9b3c6b..16b59b05 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/EnchantingSolvers.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/EnchantingSolvers.java
@@ -21,535 +21,556 @@ import net.minecraftforge.fml.common.gameevent.TickEvent;
import java.util.*;
public class EnchantingSolvers {
-
- private static SolverType currentSolver = SolverType.NONE;
-
- private enum SolverType {
- NONE,
- CHRONOMATRON,
- ULTRASEQUENCER,
- SUPERPAIRS
- }
-
- private static final NBTTagCompound enchTag = new NBTTagCompound();
- static {
- enchTag.setTag("ench", new NBTTagList());
- }
-
- //Chronomatron
- private static boolean addToChronomatron = false;
- private static boolean chronomatronStartSeq = false;
- private static List<String> chronomatronOrder = new ArrayList<>();
- private static int chronomatronReplayIndex = 0;
- private static int lastChronomatronSize = 0;
- private static long millisLastClick = 0;
-
- //Ultrasequencer
- private static class UltrasequencerItem {
- ItemStack stack;
- int containerIndex;
-
- public UltrasequencerItem(ItemStack stack, int containerIndex) {
- this.stack = stack;
- this.containerIndex = containerIndex;
- }
- }
-
- private static Map<Integer, UltrasequencerItem> ultraSequencerOrder = new HashMap<>();
- private static int ultrasequencerReplayIndex = 0;
-
- //Superpairs
- private static Map<Integer, ItemStack> superpairStacks = new HashMap<>();
- private static int lastSlotClicked = -1;
- private static HashSet<Integer> successfulMatches = new HashSet<>();
- private static HashSet<Integer> possibleMatches = new HashSet<>();
- private static HashSet<Integer> powerupMatches = new HashSet<>();
-
- @SubscribeEvent
- public void onGuiOpen(GuiOpenEvent event) {
- chronomatronOrder.clear();
- currentSolver = SolverType.NONE;
-
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
- return;
- }
-
- if(event.gui instanceof GuiChest) {
- GuiChest chest = (GuiChest) event.gui;
- ContainerChest container = (ContainerChest) chest.inventorySlots;
- String containerName = container.getLowerChestInventory().getDisplayName().getUnformattedText();
- String lower = containerName.toLowerCase();
-
- if(!lower.contains("stakes")) {
- if(lower.startsWith("chronomatron")) {
- currentSolver = SolverType.CHRONOMATRON;
- } else if(lower.startsWith("ultrasequencer")) {
- currentSolver = SolverType.ULTRASEQUENCER;
- } else if(lower.startsWith("superpairs")) {
- currentSolver = SolverType.SUPERPAIRS;
- }
- }
- }
- }
-
- public static ItemStack overrideStack(IInventory inventory, int slotIndex, ItemStack stack) {
- if(!NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enableEnchantingSolvers) {
- return null;
- }
-
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
- return null;
- }
-
- if(stack != null && stack.getDisplayName() != null) {
- if(Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
- GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
- ContainerChest container = (ContainerChest) chest.inventorySlots;
- IInventory lower = container.getLowerChestInventory();
-
- if(lower != inventory) {
- return null;
- }
-
- String displayName = stack.getDisplayName();
-
- if(currentSolver == SolverType.CHRONOMATRON) {
- ItemStack timerStack = lower.getStackInSlot(lower.getSizeInventory()-5);
- if(timerStack == null) {
- return null;
- }
-
- boolean yepClock = timerStack.getItem() == Items.clock;
- if(yepClock && (addToChronomatron && chronomatronOrder.size() >= lastChronomatronSize+1)) {
- if(chronomatronReplayIndex < chronomatronOrder.size()) {
- String chronomatronCurrent = chronomatronOrder.get(chronomatronReplayIndex);
- if(stack.getItem() == Item.getItemFromBlock(Blocks.stained_glass) ||
- stack.getItem() == Item.getItemFromBlock(Blocks.stained_hardened_clay)) {
- long currentTime = System.currentTimeMillis();
-
- boolean lastSame = chronomatronReplayIndex > 0 &&
- chronomatronCurrent.equals(chronomatronOrder.get(chronomatronReplayIndex-1));
-
- if(chronomatronCurrent.equals(displayName)) {
- if(!lastSame || currentTime - millisLastClick > 300) {
- ItemStack retStack = new ItemStack(Item.getItemFromBlock(Blocks.stained_hardened_clay), 1, stack.getItemDamage());
- retStack.setTagCompound(enchTag);
- retStack.setStackDisplayName(stack.getDisplayName());
- return retStack;
- } else {
- ItemStack retStack = new ItemStack(Item.getItemFromBlock(Blocks.stained_glass), 1, stack.getItemDamage());
- retStack.setStackDisplayName(stack.getDisplayName());
- return retStack;
- }
- } else {
- if(chronomatronReplayIndex+1 < chronomatronOrder.size()) {
- String chronomatronNext = chronomatronOrder.get(chronomatronReplayIndex+1);
- if(chronomatronNext.equals(displayName)) {
- ItemStack retStack = new ItemStack(Item.getItemFromBlock(Blocks.stained_glass), 1, stack.getItemDamage());
- retStack.setStackDisplayName(stack.getDisplayName());
- return retStack;
- }
- }
- ItemStack retStack = new ItemStack(Item.getItemFromBlock(Blocks.stained_glass), 1, 8);
- retStack.setStackDisplayName(stack.getDisplayName());
- return retStack;
- }
- }
-
- }
- }
- } else if(currentSolver == SolverType.ULTRASEQUENCER) {
- ItemStack timerStack = lower.getStackInSlot(lower.getSizeInventory()-5);
- if(timerStack == null) {
- return null;
- }
-
- boolean yepClock = timerStack.getItem() == Items.clock;
- if(stack.getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) && stack.getItemDamage() != 15) {
- if(yepClock) {
- for(int solveIndex : ultraSequencerOrder.keySet()) {
- UltrasequencerItem item = ultraSequencerOrder.get(solveIndex);
- if(item.containerIndex == slotIndex) {
- ItemStack newStack = item.stack;
- if(solveIndex == ultrasequencerReplayIndex) {
- newStack.setTagCompound(enchTag);
- } else {
- newStack.setTagCompound(null);
- }
- return newStack;
- }
- }
- ItemStack retStack = new ItemStack(Item.getItemFromBlock(Blocks.stained_glass_pane), 1, 15);
- retStack.setStackDisplayName(stack.getDisplayName());
- return retStack;
- }
- }
- } else if(currentSolver == SolverType.SUPERPAIRS) {
- if(stack.getItem() == Item.getItemFromBlock(Blocks.stained_glass) &&
- superpairStacks.containsKey(slotIndex)) {
- return superpairStacks.get(slotIndex);
- }
- }
- }
- }
- return null;
- }
-
- public static boolean onStackRender(ItemStack stack, IInventory inventory, int slotIndex, int x, int y) {
- if(!NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enableEnchantingSolvers) {
- return false;
- }
-
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
- return false;
- }
-
- if(stack != null && stack.getDisplayName() != null) {
- if(Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
- GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
- ContainerChest container = (ContainerChest) chest.inventorySlots;
- IInventory lower = container.getLowerChestInventory();
-
- if(lower != inventory) {
- return false;
- }
-
- if(currentSolver == SolverType.ULTRASEQUENCER) {
- ItemStack timerStack = lower.getStackInSlot(lower.getSizeInventory()-5);
- if(timerStack == null) {
- return false;
- }
-
- boolean yepClock = timerStack.getItem() == Items.clock;
- if(stack.getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) && stack.getItemDamage() != 15) {
- if(yepClock) {
- for(int solveIndex : ultraSequencerOrder.keySet()) {
- UltrasequencerItem item = ultraSequencerOrder.get(solveIndex);
- if(item.containerIndex == slotIndex) {
- int meta = 0;
- if(solveIndex == ultrasequencerReplayIndex) {
- meta = NotEnoughUpdates.INSTANCE.config.enchantingSolvers.seqNext;
- } else if(solveIndex == ultrasequencerReplayIndex+1) {
- meta = NotEnoughUpdates.INSTANCE.config.enchantingSolvers.seqUpcoming;
- }
- if(meta > 0) {
- Utils.drawItemStack(new ItemStack(Item.getItemFromBlock(Blocks.stained_glass_pane), 1, meta-1), x, y);
- }
- if(NotEnoughUpdates.INSTANCE.config.enchantingSolvers.seqNumbers &&
- solveIndex >= ultrasequencerReplayIndex) {
- int w = Minecraft.getMinecraft().fontRendererObj.getStringWidth((solveIndex+1)+"");
- GlStateManager.disableDepth();
- GlStateManager.enableBlend();
- GlStateManager.disableLighting();
- Utils.drawStringScaled((solveIndex+1)+"", Minecraft.getMinecraft().fontRendererObj,
- x+8.5f-w/2f, y+8.5f-4, true, 0xffc0c0c0, 1f);
- return true;
- }
- }
- }
- }
- }
- } else if(currentSolver == SolverType.SUPERPAIRS) {
- int meta = 0;
- if(stack.getItem() == Item.getItemFromBlock(Blocks.stained_glass) &&
- superpairStacks.containsKey(slotIndex)) {
- if(possibleMatches.contains(slotIndex)) {
- meta = NotEnoughUpdates.INSTANCE.config.enchantingSolvers.supPossible;
- } else {
- meta = NotEnoughUpdates.INSTANCE.config.enchantingSolvers.supUnmatched;
- }
- } else {
- if(powerupMatches.contains(slotIndex)) {
- meta = NotEnoughUpdates.INSTANCE.config.enchantingSolvers.supPower;
- } else if(successfulMatches.contains(slotIndex)) {
- meta = NotEnoughUpdates.INSTANCE.config.enchantingSolvers.supMatched;
- }
- }
- if(meta > 0) {
- Utils.drawItemStack(new ItemStack(Item.getItemFromBlock(Blocks.stained_glass_pane), 1, meta-1), x, y);
- }
- }
- }
- }
- return false;
- }
-
- public static boolean onStackClick(ItemStack stack, int windowId, int slotId, int mouseButtonClicked, int mode) {
- if(!NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enableEnchantingSolvers) {
- return false;
- }
-
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
- return false;
- }
-
- if(stack != null && stack.getDisplayName() != null) {
- String displayName = stack.getDisplayName();
- if(Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
- GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
- ContainerChest container = (ContainerChest) chest.inventorySlots;
- IInventory lower = container.getLowerChestInventory();
-
- if(currentSolver == SolverType.CHRONOMATRON) {
- ItemStack timerStack = lower.getStackInSlot(lower.getSizeInventory()-5);
- if(timerStack == null) {
- return false;
- }
-
- boolean yepClock = timerStack.getItem() == Items.clock;
- if(timerStack.getItem() == Item.getItemFromBlock(Blocks.glowstone) ||
- (yepClock && (!addToChronomatron || chronomatronOrder.size() < lastChronomatronSize+1))) {
- return true;
- } else if(yepClock) {
- long currentTime = System.currentTimeMillis();
- if(currentTime - millisLastClick < 150) {
- return true;
- }
-
- if(chronomatronReplayIndex < chronomatronOrder.size()) {
- String chronomatronCurrent = chronomatronOrder.get(chronomatronReplayIndex);
- /*if(!NotEnoughUpdates.INSTANCE.config.enchantingSolvers.preventMisclicks ||
- chronomatronCurrent.equals(displayName)) {
- chronomatronReplayIndex++;
- Minecraft.getMinecraft().playerController.windowClick(windowId, slotId,
- 2, mode, Minecraft.getMinecraft().thePlayer);
- millisLastClick = currentTime;
- }*/
- if(chronomatronCurrent.equals(displayName)) {
+ private static SolverType currentSolver = SolverType.NONE;
+
+ private enum SolverType {
+ NONE,
+ CHRONOMATRON,
+ ULTRASEQUENCER,
+ SUPERPAIRS
+ }
+
+ private static final NBTTagCompound enchTag = new NBTTagCompound() {{
+ setTag("ench", new NBTTagList());
+ }};
+
+ // Chronomatron
+ private static boolean addToChronomatron = false;
+ private static boolean chronomatronStartSeq = false;
+ private static final List<String> chronomatronOrder = new ArrayList<>();
+ private static int chronomatronReplayIndex = 0;
+ private static int lastChronomatronSize = 0;
+ private static long millisLastClick = 0;
+
+ // Ultrasequencer
+ private static class UltrasequencerItem {
+ ItemStack stack;
+ int containerIndex;
+
+ public UltrasequencerItem(ItemStack stack, int containerIndex) {
+ this.stack = stack;
+ this.containerIndex = containerIndex;
+ }
+ }
+
+ private static final Map<Integer, UltrasequencerItem> ultraSequencerOrder = new HashMap<>();
+ private static int ultrasequencerReplayIndex = 0;
+
+ // Superpairs
+ private static final Map<Integer, ItemStack> superpairStacks = new HashMap<>();
+ private static int lastSlotClicked = -1;
+ private static final HashSet<Integer> successfulMatches = new HashSet<>();
+ private static final HashSet<Integer> possibleMatches = new HashSet<>();
+ private static final HashSet<Integer> powerupMatches = new HashSet<>();
+
+ @SubscribeEvent
+ public void onGuiOpen(GuiOpenEvent event) {
+ chronomatronOrder.clear();
+ currentSolver = SolverType.NONE;
+
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
+ return;
+ }
+
+ if (event.gui instanceof GuiChest) {
+ GuiChest chest = (GuiChest) event.gui;
+ ContainerChest container = (ContainerChest) chest.inventorySlots;
+ String containerName = container.getLowerChestInventory().getDisplayName().getUnformattedText();
+ String lower = containerName.toLowerCase();
+
+ if (!lower.contains("stakes")) {
+ if (lower.startsWith("chronomatron")) {
+ currentSolver = SolverType.CHRONOMATRON;
+ } else if (lower.startsWith("ultrasequencer")) {
+ currentSolver = SolverType.ULTRASEQUENCER;
+ } else if (lower.startsWith("superpairs")) {
+ currentSolver = SolverType.SUPERPAIRS;
+ }
+ }
+ }
+ }
+
+ public static ItemStack overrideStack(IInventory inventory, int slotIndex, ItemStack stack) {
+ if (!NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enableEnchantingSolvers) {
+ return null;
+ }
+
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
+ return null;
+ }
+
+ if (stack != null && stack.getDisplayName() != null) {
+ if (Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
+ GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
+ ContainerChest container = (ContainerChest) chest.inventorySlots;
+ IInventory lower = container.getLowerChestInventory();
+
+ if (lower != inventory) {
+ return null;
+ }
+
+ String displayName = stack.getDisplayName();
+
+ if (currentSolver == SolverType.CHRONOMATRON) {
+ ItemStack timerStack = lower.getStackInSlot(lower.getSizeInventory() - 5);
+ if (timerStack == null) {
+ return null;
+ }
+
+ boolean yepClock = timerStack.getItem() == Items.clock;
+ if (yepClock && (addToChronomatron && chronomatronOrder.size() >= lastChronomatronSize + 1)) {
+ if (chronomatronReplayIndex < chronomatronOrder.size()) {
+ String chronomatronCurrent = chronomatronOrder.get(chronomatronReplayIndex);
+ if (stack.getItem() == Item.getItemFromBlock(Blocks.stained_glass) ||
+ stack.getItem() == Item.getItemFromBlock(Blocks.stained_hardened_clay)) {
+ long currentTime = System.currentTimeMillis();
+
+ boolean lastSame = chronomatronReplayIndex > 0 &&
+ chronomatronCurrent.equals(chronomatronOrder.get(chronomatronReplayIndex - 1));
+
+ if (chronomatronCurrent.equals(displayName)) {
+ if (!lastSame || currentTime - millisLastClick > 300) {
+ ItemStack retStack = new ItemStack(
+ Item.getItemFromBlock(Blocks.stained_hardened_clay),
+ 1,
+ stack.getItemDamage()
+ );
+ retStack.setTagCompound(enchTag);
+ retStack.setStackDisplayName(stack.getDisplayName());
+ return retStack;
+ } else {
+ ItemStack retStack = new ItemStack(
+ Item.getItemFromBlock(Blocks.stained_glass),
+ 1,
+ stack.getItemDamage()
+ );
+ retStack.setStackDisplayName(stack.getDisplayName());
+ return retStack;
+ }
+ } else {
+ if (chronomatronReplayIndex + 1 < chronomatronOrder.size() &&
+ NotEnoughUpdates.INSTANCE.config.enchantingSolvers.showNextClick) {
+ String chronomatronNext = chronomatronOrder.get(chronomatronReplayIndex + 1);
+ if (chronomatronNext.equals(displayName)) {
+ ItemStack retStack = new ItemStack(
+ Item.getItemFromBlock(Blocks.stained_glass),
+ 1,
+ stack.getItemDamage()
+ );
+ retStack.setStackDisplayName(stack.getDisplayName());
+ return retStack;
+ }
+ }
+ ItemStack retStack = new ItemStack(Item.getItemFromBlock(Blocks.stained_glass), 1, 8);
+ retStack.setStackDisplayName(stack.getDisplayName());
+ return retStack;
+ }
+ }
+
+ }
+ }
+ } else if (currentSolver == SolverType.ULTRASEQUENCER) {
+ ItemStack timerStack = lower.getStackInSlot(lower.getSizeInventory() - 5);
+ if (timerStack == null) {
+ return null;
+ }
+
+ boolean yepClock = timerStack.getItem() == Items.clock;
+ if (stack.getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) && stack.getItemDamage() != 15) {
+ if (yepClock) {
+ for (int solveIndex : ultraSequencerOrder.keySet()) {
+ UltrasequencerItem item = ultraSequencerOrder.get(solveIndex);
+ if (item.containerIndex == slotIndex) {
+ ItemStack newStack = item.stack;
+ if (solveIndex == ultrasequencerReplayIndex) {
+ newStack.setTagCompound(enchTag);
+ } else {
+ newStack.setTagCompound(null);
+ }
+ return newStack;
+ }
+ }
+ ItemStack retStack = new ItemStack(Item.getItemFromBlock(Blocks.stained_glass_pane), 1, 15);
+ retStack.setStackDisplayName(stack.getDisplayName());
+ return retStack;
+ }
+ }
+ } else if (currentSolver == SolverType.SUPERPAIRS) {
+ if (stack.getItem() == Item.getItemFromBlock(Blocks.stained_glass) &&
+ superpairStacks.containsKey(slotIndex)) {
+ return superpairStacks.get(slotIndex);
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ public static boolean onStackRender(ItemStack stack, IInventory inventory, int slotIndex, int x, int y) {
+ if (!NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enableEnchantingSolvers) {
+ return false;
+ }
+
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
+ return false;
+ }
+
+ if (stack != null && stack.getDisplayName() != null) {
+ if (Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
+ GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
+ ContainerChest container = (ContainerChest) chest.inventorySlots;
+ IInventory lower = container.getLowerChestInventory();
+
+ if (lower != inventory) {
+ return false;
+ }
+
+ if (currentSolver == SolverType.ULTRASEQUENCER) {
+ ItemStack timerStack = lower.getStackInSlot(lower.getSizeInventory() - 5);
+ if (timerStack == null) {
+ return false;
+ }
+
+ boolean yepClock = timerStack.getItem() == Items.clock;
+ if (stack.getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) && stack.getItemDamage() != 15) {
+ if (yepClock) {
+ for (int solveIndex : ultraSequencerOrder.keySet()) {
+ UltrasequencerItem item = ultraSequencerOrder.get(solveIndex);
+ if (item.containerIndex == slotIndex) {
+ int meta = 0;
+ if (solveIndex == ultrasequencerReplayIndex) {
+ meta = NotEnoughUpdates.INSTANCE.config.enchantingSolvers.seqNext;
+ } else if (solveIndex == ultrasequencerReplayIndex + 1) {
+ meta = NotEnoughUpdates.INSTANCE.config.enchantingSolvers.seqUpcoming;
+ }
+ if (meta > 0) {
+ Utils.drawItemStack(
+ new ItemStack(Item.getItemFromBlock(Blocks.stained_glass_pane), 1, meta - 1),
+ x,
+ y
+ );
+ }
+ if (NotEnoughUpdates.INSTANCE.config.enchantingSolvers.seqNumbers &&
+ solveIndex >= ultrasequencerReplayIndex) {
+ int w = Minecraft.getMinecraft().fontRendererObj.getStringWidth((solveIndex + 1) + "");
+ GlStateManager.disableDepth();
+ GlStateManager.enableBlend();
+ GlStateManager.disableLighting();
+ Utils.drawStringScaled((solveIndex + 1) + "", Minecraft.getMinecraft().fontRendererObj,
+ x + 8.5f - w / 2f, y + 8.5f - 4, true, 0xffc0c0c0, 1f
+ );
+ return true;
+ }
+ }
+ }
+ }
+ }
+ } else if (currentSolver == SolverType.SUPERPAIRS) {
+ int meta = 0;
+ if (stack.getItem() == Item.getItemFromBlock(Blocks.stained_glass) &&
+ superpairStacks.containsKey(slotIndex)) {
+ if (possibleMatches.contains(slotIndex)) {
+ meta = NotEnoughUpdates.INSTANCE.config.enchantingSolvers.supPossible;
+ } else {
+ meta = NotEnoughUpdates.INSTANCE.config.enchantingSolvers.supUnmatched;
+ }
+ } else {
+ if (powerupMatches.contains(slotIndex)) {
+ meta = NotEnoughUpdates.INSTANCE.config.enchantingSolvers.supPower;
+ } else if (successfulMatches.contains(slotIndex)) {
+ meta = NotEnoughUpdates.INSTANCE.config.enchantingSolvers.supMatched;
+ }
+ }
+ if (meta > 0) {
+ Utils.drawItemStack(new ItemStack(Item.getItemFromBlock(Blocks.stained_glass_pane), 1, meta - 1), x, y);
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ public static boolean onStackClick(ItemStack stack, int windowId, int slotId, int mouseButtonClicked, int mode) {
+ if (!NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enableEnchantingSolvers) {
+ return false;
+ }
+
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
+ return false;
+ }
+
+ if (stack != null && stack.getDisplayName() != null) {
+ String displayName = stack.getDisplayName();
+ if (Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
+ GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
+ ContainerChest container = (ContainerChest) chest.inventorySlots;
+ IInventory lower = container.getLowerChestInventory();
+
+ if (currentSolver == SolverType.CHRONOMATRON) {
+ ItemStack timerStack = lower.getStackInSlot(lower.getSizeInventory() - 5);
+ if (timerStack == null) {
+ return false;
+ }
+
+ boolean yepClock = timerStack.getItem() == Items.clock;
+ if (timerStack.getItem() == Item.getItemFromBlock(Blocks.glowstone) ||
+ (yepClock && (!addToChronomatron || chronomatronOrder.size() < lastChronomatronSize + 1))) {
+ return true;
+ } else if (yepClock) {
+ long currentTime = System.currentTimeMillis();
+ if (currentTime - millisLastClick < 150) {
+ return true;
+ }
+
+ if (chronomatronReplayIndex < chronomatronOrder.size()) {
+ String chronomatronCurrent = chronomatronOrder.get(chronomatronReplayIndex);
+ if (!NotEnoughUpdates.INSTANCE.config.enchantingSolvers.preventMisclicks1 ||
+ chronomatronCurrent.equals(displayName)) {
+ chronomatronReplayIndex++;
+ Minecraft.getMinecraft().playerController.windowClick(windowId, slotId,
+ 2, mode, Minecraft.getMinecraft().thePlayer
+ );
+ millisLastClick = currentTime;
+ }
+ /*if (chronomatronCurrent.equals(displayName)) {
chronomatronReplayIndex++;
}
Minecraft.getMinecraft().playerController.windowClick(windowId, slotId,
2, mode, Minecraft.getMinecraft().thePlayer);
- millisLastClick = currentTime;
- }
- return true;
- }
- } else if(currentSolver == SolverType.ULTRASEQUENCER) {
- ItemStack timerStack = lower.getStackInSlot(lower.getSizeInventory()-5);
- if(timerStack == null) {
- return false;
- }
-
- boolean yepClock = timerStack.getItem() == Items.clock;
- if(yepClock) {
- UltrasequencerItem current = ultraSequencerOrder.get(ultrasequencerReplayIndex);
- if(current == null) {
- return true;
- }
- long currentTime = System.currentTimeMillis();
- /*if(currentTime - millisLastClick > 150 &&
- (!NotEnoughUpdates.INSTANCE.config.enchantingSolvers.preventMisclicks ||
- current.containerIndex == slotId)) {
- ultrasequencerReplayIndex++;
- Minecraft.getMinecraft().playerController.windowClick(windowId, slotId,
- 2, mode, Minecraft.getMinecraft().thePlayer);
- millisLastClick = currentTime;
- }*/
- if(currentTime - millisLastClick > 150) {
- if(current.containerIndex == slotId) {
+ millisLastClick = currentTime;*/
+ }
+ return true;
+ }
+ } else if (currentSolver == SolverType.ULTRASEQUENCER) {
+ ItemStack timerStack = lower.getStackInSlot(lower.getSizeInventory() - 5);
+ if (timerStack == null) {
+ return false;
+ }
+
+ boolean yepClock = timerStack.getItem() == Items.clock;
+ if (yepClock) {
+ UltrasequencerItem current = ultraSequencerOrder.get(ultrasequencerReplayIndex);
+ if (current == null) {
+ return true;
+ }
+ long currentTime = System.currentTimeMillis();
+ if (currentTime - millisLastClick > 150 &&
+ (!NotEnoughUpdates.INSTANCE.config.enchantingSolvers.preventMisclicks1 ||
+ current.containerIndex == slotId)) {
+ ultrasequencerReplayIndex++;
+ Minecraft.getMinecraft().playerController.windowClick(windowId, slotId,
+ 2, mode, Minecraft.getMinecraft().thePlayer
+ );
+ millisLastClick = currentTime;
+ }
+ /*if (currentTime - millisLastClick > 150) {
+ if (current.containerIndex == slotId) {
ultrasequencerReplayIndex++;
}
Minecraft.getMinecraft().playerController.windowClick(windowId, slotId,
2, mode, Minecraft.getMinecraft().thePlayer);
millisLastClick = currentTime;
- }
- return true;
- } else {
- return true;
- }
- } else if(currentSolver == SolverType.SUPERPAIRS) {
- lastSlotClicked = slotId;
- }
- }
- }
- return false;
- }
-
- public static void processInventoryContents(boolean fromTick) {
- if(currentSolver != SolverType.CHRONOMATRON && !fromTick) return;
-
- if(!NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enableEnchantingSolvers) {
- return;
- }
-
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
- return;
- }
-
- if(Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
- GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
- ContainerChest container = (ContainerChest) chest.inventorySlots;
- IInventory lower = container.getLowerChestInventory();
-
- if(currentSolver == SolverType.CHRONOMATRON) {
- ItemStack timerStack = lower.getStackInSlot(lower.getSizeInventory() - 5);
- if (timerStack == null) {
- return;
- }
-
- String stainedHardenedClayName = null;
- for (int index = 0; index < lower.getSizeInventory(); index++) {
- ItemStack stack = lower.getStackInSlot(index);
- if (stack != null && stack.getItem() == Item.getItemFromBlock(Blocks.stained_hardened_clay)) {
- if (stack.getTagCompound() != null && stack.getTagCompound().hasKey("ench")) {
- if (stainedHardenedClayName != null && !stack.getDisplayName().equals(stainedHardenedClayName)) {
- return;
- }
- stainedHardenedClayName = stack.getDisplayName();
- }
- }
- }
-
- boolean yepClock = timerStack.getItem() == Items.clock;
- if (timerStack.getItem() == Item.getItemFromBlock(Blocks.glowstone) ||
- (yepClock && (!addToChronomatron || chronomatronOrder.size() < lastChronomatronSize + 1))) {
- if (chronomatronStartSeq) {
- chronomatronStartSeq = false;
- addToChronomatron = false;
- lastChronomatronSize = chronomatronOrder.size();
- chronomatronOrder.clear();
- }
-
- if (stainedHardenedClayName != null) {
- if (addToChronomatron) {
- chronomatronOrder.add(stainedHardenedClayName);
- }
- addToChronomatron = false;
- } else {
- addToChronomatron = true;
- chronomatronReplayIndex = 0;
- }
- } else if (yepClock) {
- chronomatronStartSeq = true;
- }
- } else {
- chronomatronStartSeq = true;
- addToChronomatron = true;
- }
- if(currentSolver == SolverType.ULTRASEQUENCER) {
- ItemStack timerStack = lower.getStackInSlot(lower.getSizeInventory() - 5);
- if (timerStack == null) {
- return;
- }
- if(timerStack.getItem() == Item.getItemFromBlock(Blocks.glowstone)) {
- ultrasequencerReplayIndex = 0;
- }
-
- for (int index = 0; index < lower.getSizeInventory(); index++) {
- ItemStack stack = lower.getStackInSlot(index);
- if (stack != null && stack.getItem() == Items.dye) {
- if(ultraSequencerOrder.containsKey(stack.stackSize-1)) {
- UltrasequencerItem ultrasequencerItem = ultraSequencerOrder.get(stack.stackSize-1);
- ultrasequencerItem.containerIndex = index;
- ultrasequencerItem.stack = stack;
- } else {
- ultraSequencerOrder.put(stack.stackSize-1, new UltrasequencerItem(stack, index));
- }
- }
- }
- } else {
- ultraSequencerOrder.clear();
- }
- if(currentSolver == SolverType.SUPERPAIRS) {
- successfulMatches.clear();
- possibleMatches.clear();
- powerupMatches.clear();
- out:
- for (int index = 0; index < lower.getSizeInventory(); index++) {
- ItemStack stack = lower.getStackInSlot(index);
- if(stack == null) continue;
- if (stack.getItem() != Item.getItemFromBlock(Blocks.stained_glass) &&
- stack.getItem() != Item.getItemFromBlock(Blocks.stained_glass_pane)) {
- superpairStacks.put(index, stack);
-
- NBTTagCompound tag = stack.getTagCompound();
- if(tag != null) {
- NBTTagCompound display = tag.getCompoundTag("display");
- if (display.hasKey("Lore", 9)) {
- NBTTagList list = display.getTagList("Lore", 8);
- for (int i = 0; i < list.tagCount(); i++) {
- if(list.getStringTagAt(i).toLowerCase().contains("powerup")) {
- powerupMatches.add(index);
- continue out;
- }
- }
- }
- }
-
- int numMatches = 0;
- for (int index2 = 0; index2 < lower.getSizeInventory(); index2++) {
- ItemStack stack2 = lower.getStackInSlot(index2);
- if(stack2 != null && stack2.getDisplayName().equals(stack.getDisplayName()) &&
- stack.getItem() == stack2.getItem() && stack.getItemDamage() == stack2.getItemDamage()) {
- numMatches++;
- }
- }
- boolean oddMatches = (numMatches % 2) == 1;
-
- if((!oddMatches || index != lastSlotClicked) && !successfulMatches.contains(index)) {
- for (int index2 = 0; index2 < lower.getSizeInventory(); index2++) {
- if(index == index2) continue;
- if(oddMatches && index2 == lastSlotClicked) continue;
-
- ItemStack stack2 = lower.getStackInSlot(index2);
- if(stack2 != null && stack2.getDisplayName().equals(stack.getDisplayName()) &&
- stack.getItem() == stack2.getItem() && stack.getItemDamage() == stack2.getItemDamage()) {
- successfulMatches.add(index);
- successfulMatches.add(index2);
- }
- }
- }
- } else {
- if(superpairStacks.containsKey(index) && superpairStacks.get(index) != null &&
- !possibleMatches.contains(index)) {
- ItemStack stack1 = superpairStacks.get(index);
- for (int index2 = 0; index2 < lower.getSizeInventory(); index2++) {
- if(index == index2) continue;
-
- if(superpairStacks.containsKey(index2) && superpairStacks.get(index2) != null) {
- ItemStack stack2 = superpairStacks.get(index2);
- if(stack1.getDisplayName().equals(stack2.getDisplayName()) &&
- stack1.getItem() == stack2.getItem() && stack1.getItemDamage() == stack2.getItemDamage()) {
- possibleMatches.add(index);
- possibleMatches.add(index2);
- }
- }
- }
- }
- }
- }
- } else {
- superpairStacks.clear();
- successfulMatches.clear();
- powerupMatches.clear();
- lastSlotClicked = -1;
- }
- }
- }
-
-
- @SubscribeEvent
- public void onItemTooltip(ItemTooltipEvent event) {
- if(NotEnoughUpdates.INSTANCE.config.enchantingSolvers.hideTooltips &&
- (currentSolver == SolverType.CHRONOMATRON || currentSolver == SolverType.ULTRASEQUENCER)) {
- String internal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(event.itemStack);
- if(internal == null && event.toolTip.size() > 0 && !event.toolTip.get(0).trim().replaceAll("\\(#.+\\)$", "").trim().contains(" ")) {
- event.toolTip.clear();
- }
- }
- }
-
- @SubscribeEvent
- public void onTick(TickEvent.ClientTickEvent event) {
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) {
- currentSolver = SolverType.NONE;
- }
-
- if(event.phase != TickEvent.Phase.END) {
- return;
- }
-
- processInventoryContents(true);
- }
-
+ }*/
+ return true;
+ } else {
+ return true;
+ }
+ } else if (currentSolver == SolverType.SUPERPAIRS) {
+ lastSlotClicked = slotId;
+ }
+ }
+ }
+ return false;
+ }
+
+ public static void processInventoryContents(boolean fromTick) {
+ if (currentSolver != SolverType.CHRONOMATRON && !fromTick) return;
+
+ if (!NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enableEnchantingSolvers) {
+ return;
+ }
+
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
+ return;
+ }
+
+ if (Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
+ GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
+ ContainerChest container = (ContainerChest) chest.inventorySlots;
+ IInventory lower = container.getLowerChestInventory();
+
+ if (currentSolver == SolverType.CHRONOMATRON) {
+ ItemStack timerStack = lower.getStackInSlot(lower.getSizeInventory() - 5);
+ if (timerStack == null) {
+ return;
+ }
+
+ String stainedHardenedClayName = null;
+ for (int index = 0; index < lower.getSizeInventory(); index++) {
+ ItemStack stack = lower.getStackInSlot(index);
+ if (stack != null && stack.getItem() == Item.getItemFromBlock(Blocks.stained_hardened_clay)) {
+ if (stack.getTagCompound() != null && stack.getTagCompound().hasKey("ench")) {
+ if (stainedHardenedClayName != null && !stack.getDisplayName().equals(stainedHardenedClayName)) {
+ return;
+ }
+ stainedHardenedClayName = stack.getDisplayName();
+ }
+ }
+ }
+
+ boolean yepClock = timerStack.getItem() == Items.clock;
+ if (timerStack.getItem() == Item.getItemFromBlock(Blocks.glowstone) ||
+ (yepClock && (!addToChronomatron || chronomatronOrder.size() < lastChronomatronSize + 1))) {
+ if (chronomatronStartSeq) {
+ chronomatronStartSeq = false;
+ addToChronomatron = false;
+ lastChronomatronSize = chronomatronOrder.size();
+ chronomatronOrder.clear();
+ }
+
+ if (stainedHardenedClayName != null) {
+ if (addToChronomatron) {
+ chronomatronOrder.add(stainedHardenedClayName);
+ }
+ addToChronomatron = false;
+ } else {
+ addToChronomatron = true;
+ chronomatronReplayIndex = 0;
+ }
+ } else if (yepClock) {
+ chronomatronStartSeq = true;
+ }
+ } else {
+ chronomatronStartSeq = true;
+ addToChronomatron = true;
+ }
+ if (currentSolver == SolverType.ULTRASEQUENCER) {
+ ItemStack timerStack = lower.getStackInSlot(lower.getSizeInventory() - 5);
+ if (timerStack == null) {
+ return;
+ }
+ if (timerStack.getItem() == Item.getItemFromBlock(Blocks.glowstone)) {
+ ultrasequencerReplayIndex = 0;
+ }
+
+ for (int index = 0; index < lower.getSizeInventory(); index++) {
+ ItemStack stack = lower.getStackInSlot(index);
+ if (stack != null && stack.getItem() == Items.dye) {
+ if (ultraSequencerOrder.containsKey(stack.stackSize - 1)) {
+ UltrasequencerItem ultrasequencerItem = ultraSequencerOrder.get(stack.stackSize - 1);
+ ultrasequencerItem.containerIndex = index;
+ ultrasequencerItem.stack = stack;
+ } else {
+ ultraSequencerOrder.put(stack.stackSize - 1, new UltrasequencerItem(stack, index));
+ }
+ }
+ }
+ } else {
+ ultraSequencerOrder.clear();
+ }
+ if (currentSolver == SolverType.SUPERPAIRS) {
+ successfulMatches.clear();
+ possibleMatches.clear();
+ powerupMatches.clear();
+ out:
+ for (int index = 0; index < lower.getSizeInventory(); index++) {
+ ItemStack stack = lower.getStackInSlot(index);
+ if (stack == null) continue;
+ if (stack.getItem() != Item.getItemFromBlock(Blocks.stained_glass) &&
+ stack.getItem() != Item.getItemFromBlock(Blocks.stained_glass_pane)) {
+ superpairStacks.put(index, stack);
+
+ NBTTagCompound tag = stack.getTagCompound();
+ if (tag != null) {
+ NBTTagCompound display = tag.getCompoundTag("display");
+ if (display.hasKey("Lore", 9)) {
+ NBTTagList list = display.getTagList("Lore", 8);
+ for (int i = 0; i < list.tagCount(); i++) {
+ if (list.getStringTagAt(i).toLowerCase().contains("powerup")) {
+ powerupMatches.add(index);
+ continue out;
+ }
+ }
+ }
+ }
+
+ int numMatches = 0;
+ for (int index2 = 0; index2 < lower.getSizeInventory(); index2++) {
+ ItemStack stack2 = lower.getStackInSlot(index2);
+ if (stack2 != null && stack2.getDisplayName().equals(stack.getDisplayName()) &&
+ stack.getItem() == stack2.getItem() && stack.getItemDamage() == stack2.getItemDamage()) {
+ numMatches++;
+ }
+ }
+ boolean oddMatches = (numMatches % 2) == 1;
+
+ if ((!oddMatches || index != lastSlotClicked) && !successfulMatches.contains(index)) {
+ for (int index2 = 0; index2 < lower.getSizeInventory(); index2++) {
+ if (index == index2) continue;
+ if (oddMatches && index2 == lastSlotClicked) continue;
+
+ ItemStack stack2 = lower.getStackInSlot(index2);
+ if (stack2 != null && stack2.getDisplayName().equals(stack.getDisplayName()) &&
+ stack.getItem() == stack2.getItem() && stack.getItemDamage() == stack2.getItemDamage()) {
+ successfulMatches.add(index);
+ successfulMatches.add(index2);
+ }
+ }
+ }
+ } else {
+ if (superpairStacks.containsKey(index) && superpairStacks.get(index) != null &&
+ !possibleMatches.contains(index)) {
+ ItemStack stack1 = superpairStacks.get(index);
+ for (int index2 = 0; index2 < lower.getSizeInventory(); index2++) {
+ if (index == index2) continue;
+
+ if (superpairStacks.containsKey(index2) && superpairStacks.get(index2) != null) {
+ ItemStack stack2 = superpairStacks.get(index2);
+ if (stack1.getDisplayName().equals(stack2.getDisplayName()) &&
+ stack1.getItem() == stack2.getItem() && stack1.getItemDamage() == stack2.getItemDamage()) {
+ possibleMatches.add(index);
+ possibleMatches.add(index2);
+ }
+ }
+ }
+ }
+ }
+ }
+ } else {
+ superpairStacks.clear();
+ successfulMatches.clear();
+ powerupMatches.clear();
+ lastSlotClicked = -1;
+ }
+ }
+ }
+
+ @SubscribeEvent
+ public void onItemTooltip(ItemTooltipEvent event) {
+ if (NotEnoughUpdates.INSTANCE.config.enchantingSolvers.hideTooltips &&
+ (currentSolver == SolverType.CHRONOMATRON || currentSolver == SolverType.ULTRASEQUENCER)) {
+ String internal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(event.itemStack);
+ if (internal == null && event.toolTip.size() > 0 && !event.toolTip
+ .get(0)
+ .trim()
+ .replaceAll("\\(#.+\\)$", "")
+ .trim()
+ .contains(" ")) {
+ event.toolTip.clear();
+ }
+ }
+ }
+
+ @SubscribeEvent
+ public void onTick(TickEvent.ClientTickEvent event) {
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) {
+ currentSolver = SolverType.NONE;
+ }
+
+ if (event.phase != TickEvent.Phase.END) {
+ return;
+ }
+
+ processInventoryContents(true);
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java
index ac1d2fd9..725d4b9d 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java
@@ -1,261 +1,330 @@
package io.github.moulberry.notenoughupdates.miscfeatures;
+import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
+import com.google.gson.JsonSyntaxException;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
-import io.github.moulberry.notenoughupdates.commands.SimpleCommand;
+import io.github.moulberry.notenoughupdates.commands.ClientCommandBase;
import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils;
import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.SBInfo;
-import io.github.moulberry.notenoughupdates.util.SpecialColour;
import net.minecraft.client.Minecraft;
-import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
-import net.minecraft.util.*;
+import net.minecraft.util.BlockPos;
+import net.minecraft.util.ChatComponentText;
+import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.client.event.ClientChatReceivedEvent;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import java.io.*;
+import java.lang.reflect.Type;
import java.nio.charset.StandardCharsets;
import java.util.*;
+import java.util.stream.Collectors;
public class FairySouls {
-
- private static HashMap<String, Set<Integer>> foundSouls = new HashMap<>();
- private static List<BlockPos> currentSoulList = null;
- private static List<BlockPos> currentSoulListClose = null;
-
- private static boolean enabled = false;
-
- @SubscribeEvent
- public void onWorldUnload(WorldEvent.Unload event) {
- currentSoulList = null;
- }
-
- public static void load(File file, Gson gson) {
- if(file.exists()) {
- try(BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) {
- HashMap<String, List<Number>> foundSoulsList = gson.fromJson(reader, HashMap.class);
-
- foundSouls = new HashMap<>();
- for(Map.Entry<String, List<Number>> entry : foundSoulsList.entrySet()) {
- HashSet<Integer> set = new HashSet<>();
- for(Number n : entry.getValue()) {
- set.add(n.intValue());
- }
- foundSouls.put(entry.getKey(), set);
- }
-
- return;
- } catch(Exception e) {}
- }
- foundSouls = new HashMap<>();
- }
-
- public static void save(File file, Gson gson) {
- try {
- file.createNewFile();
-
- try(BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8))) {
- writer.write(gson.toJson(foundSouls));
- }
- } catch(IOException ignored) {}
- }
-
- @SubscribeEvent
- public void onChatReceived(ClientChatReceivedEvent event) {
- if(currentSoulList == null) return;
-
- if(event.message.getFormattedText().equals("\u00A7r\u00A7dYou have already found that Fairy Soul!\u00A7r") ||
- event.message.getFormattedText().equals("\u00A7d\u00A7lSOUL! \u00A7fYou found a \u00A7r\u00A7dFairy Soul\u00A7r\u00A7f!\u00A7r")) {
- String location = SBInfo.getInstance().getLocation();
- if(location == null) return;
-
- int closestIndex = -1;
- double closestDistSq = 10*10;
- for(int i=0; i<currentSoulList.size(); i++) {
- BlockPos pos = currentSoulList.get(i);
-
- double distSq = pos.distanceSq(Minecraft.getMinecraft().thePlayer.getPosition());
-
- if(distSq < closestDistSq) {
- closestDistSq = distSq;
- closestIndex = i;
- }
- }
- if(closestIndex != -1) {
- Set<Integer> found = foundSouls.computeIfAbsent(location, k -> new HashSet<>());
- found.add(closestIndex);
- }
- }
- }
-
- public static void tick() {
- if(!enabled) return;
-
- if(Minecraft.getMinecraft().theWorld == null) {
- currentSoulList = null;
- return;
- }
-
- JsonObject fairySouls = Constants.FAIRYSOULS;
- if(fairySouls == null) return;
-
- String location = SBInfo.getInstance().getLocation();
- if(location == null) {
- currentSoulList = null;
- return;
- }
-
- if(currentSoulList == null) {
- if(fairySouls.has(location) && fairySouls.get(location).isJsonArray()) {
- JsonArray locations = fairySouls.get(location).getAsJsonArray();
- currentSoulList = new ArrayList<>();
- for(int i=0; i<locations.size(); i++) {
- try {
- String coord = locations.get(i).getAsString();
-
- String[] split = coord.split(",");
- if(split.length == 3) {
- String xS = split[0];
- String yS = split[1];
- String zS = split[2];
-
- int x = Integer.parseInt(xS);
- int y = Integer.parseInt(yS);
- int z = Integer.parseInt(zS);
-
- currentSoulList.add(new BlockPos(x, y , z));
- }
- } catch(Exception ignored) {}
- }
- }
- }
-
- if(currentSoulList != null && !currentSoulList.isEmpty()) {
- TreeMap<Double, BlockPos> distanceSqMap = new TreeMap<>();
-
- Set<Integer> found = foundSouls.computeIfAbsent(location, k -> new HashSet<>());
-
- for(int i=0; i<currentSoulList.size(); i++) {
- if(found.contains(i)) continue;
-
- BlockPos pos = currentSoulList.get(i);
- double distSq = pos.distanceSq(Minecraft.getMinecraft().thePlayer.getPosition());
- distanceSqMap.put(distSq, pos);
- }
-
- int maxSouls = 15;
- int souls = 0;
- currentSoulListClose = new ArrayList<>();
- for(BlockPos pos : distanceSqMap.values()) {
- currentSoulListClose.add(pos);
- if(++souls >= maxSouls) break;
- }
- }
- }
-
- @SubscribeEvent
- public void onRenderLast(RenderWorldLastEvent event) {
- if(!enabled) return;
-
- String location = SBInfo.getInstance().getLocation();
- if(location == null) return;
- if(currentSoulList == null || currentSoulList.isEmpty()) return;
-
- Set<Integer> found = foundSouls.computeIfAbsent(location, k -> new HashSet<>());
-
- int rgb = 0xa839ce;
- for(int i=0; i<currentSoulListClose.size(); i++) {
- BlockPos currentSoul = currentSoulListClose.get(i);
- RenderUtils.renderBeaconBeamOrBoundingBox(currentSoul, rgb, 1.0f, event.partialTicks);
- }
- }
-
- public static class FairySoulsCommandAlt extends SimpleCommand {
- public FairySoulsCommandAlt() {
- super("fairysouls", fairysoulRunnable);
- }
- }
-
- public static class FairySoulsCommand extends SimpleCommand {
-
- public FairySoulsCommand() {
- super("neusouls", fairysoulRunnable);
- }
- }
-
- private static SimpleCommand.ProcessCommandRunnable fairysoulRunnable = new SimpleCommand.ProcessCommandRunnable() {
- @Override
- public void processCommand(ICommandSender sender, String[] args) {
- if(args.length != 1) {
- printHelp();
- return;
- }
- String subcommand = args[0].toLowerCase();
-
- switch (subcommand) {
- case "help":
- printHelp();
- return;
- case "on":
- case "enable":
- print(EnumChatFormatting.DARK_PURPLE+"Enabled fairy soul waypoints");
- enabled = true;
- return;
- case "off":
- case "disable":
- print(EnumChatFormatting.DARK_PURPLE+"Disabled fairy soul waypoints");
- enabled = false;
- return;
- case "clear": {
- String location = SBInfo.getInstance().getLocation();
- if(currentSoulList == null || location == null) {
- print(EnumChatFormatting.RED+"No fairy souls found in your current world");
- } else {
- Set<Integer> found = foundSouls.computeIfAbsent(location, k -> new HashSet<>());
- for(int i=0; i<currentSoulList.size(); i++) {
- found.add(i);
- }
- print(EnumChatFormatting.DARK_PURPLE+"Marked all fairy souls as found");
- }
- }
- return;
- case "unclear":
- String location = SBInfo.getInstance().getLocation();
- if(location == null) {
- print(EnumChatFormatting.RED+"No fairy souls found in your current world");
- } else {
- print(EnumChatFormatting.DARK_PURPLE+"Marked all fairy souls as not found");
- foundSouls.remove(location);
- }
- return;
- }
-
- print(EnumChatFormatting.RED+"Unknown subcommand: " + subcommand);
- }
- };
-
- private static void print(String s) {
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(s));
- }
-
- private static void printHelp() {
- print("");
- print(EnumChatFormatting.DARK_PURPLE.toString()+EnumChatFormatting.BOLD+" NEU Fairy Soul Waypoint Guide");
- print(EnumChatFormatting.LIGHT_PURPLE+"Shows waypoints for every fairy soul in your world");
- print(EnumChatFormatting.LIGHT_PURPLE+"Clicking a fairy soul automatically removes it from the list");
- if(!NotEnoughUpdates.INSTANCE.config.hidden.dev) {
- print(EnumChatFormatting.DARK_RED + "" + EnumChatFormatting.OBFUSCATED + "Ab" + EnumChatFormatting.RESET + EnumChatFormatting.DARK_RED + "!" + EnumChatFormatting.RESET + EnumChatFormatting.RED + " This feature cannot and will not work in Dungeons. " + EnumChatFormatting.DARK_RED + "!" + EnumChatFormatting.OBFUSCATED + "Ab");
- }
- print(EnumChatFormatting.GOLD.toString()+EnumChatFormatting.BOLD+" Commands:");
- print(EnumChatFormatting.YELLOW+"/neusouls help - Display this message");
- print(EnumChatFormatting.YELLOW+"/neusouls on/off - Enable/disable the waypoint markers");
- print(EnumChatFormatting.YELLOW+"/neusouls clear/unclear - Marks every waypoint in your current world as completed/uncompleted");
- print("");
- }
-
+ private static final String unknownProfile = "unknown";
+ private static List<BlockPos> currentSoulList = null;
+ private static List<BlockPos> currentSoulListClose = null;
+ private static HashMap<String, HashMap<String, Set<Integer>>> loadedFoundSouls = new HashMap<>();
+
+ private static HashMap<String, Set<Integer>> getFoundSoulsForProfile() {
+ String profile = SBInfo.getInstance().currentProfile;
+ if (profile == null) {
+ if (loadedFoundSouls.containsKey(unknownProfile))
+ return loadedFoundSouls.get(unknownProfile);
+ } else {
+ profile = profile.toLowerCase(Locale.getDefault());
+ if (loadedFoundSouls.containsKey(unknownProfile)) {
+ HashMap<String, Set<Integer>> unknownProfileData = loadedFoundSouls.remove(unknownProfile);
+ loadedFoundSouls.put(profile, unknownProfileData);
+ return unknownProfileData;
+ }
+ if (loadedFoundSouls.containsKey(profile)) {
+ return loadedFoundSouls.get(profile);
+ } else {
+ //create a new entry for this profile
+ HashMap<String, Set<Integer>> profileData = new HashMap<>();
+ loadedFoundSouls.put(profile, profileData);
+ return profileData;
+ }
+ }
+ return new HashMap<>();
+ }
+
+ public static void load(File file, Gson gson) {
+ loadedFoundSouls = new HashMap<>();
+ String fileContent;
+ try {
+ fileContent = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))
+ .lines()
+ .collect(Collectors.joining(System.lineSeparator()));
+ } catch (FileNotFoundException e) {
+ return;
+ }
+
+ try {
+ //noinspection UnstableApiUsage
+ Type multiProfileSoulsType = new TypeToken<HashMap<String, HashMap<String, Set<Integer>>>>() {}.getType();
+ loadedFoundSouls = gson.fromJson(fileContent, multiProfileSoulsType);
+ } catch (JsonSyntaxException e) {
+ //The file is in the old format, convert it to the new one and set the profile to unknown
+ try {
+ //noinspection UnstableApiUsage
+ Type singleProfileSoulsType = new TypeToken<HashMap<String, Set<Integer>>>() {}.getType();
+ loadedFoundSouls.put(unknownProfile, gson.fromJson(fileContent, singleProfileSoulsType));
+ } catch (JsonSyntaxException e2) {
+ System.err.println("Can't read file containing collected fairy souls, resetting.");
+ }
+ }
+ }
+
+ public static void save(File file, Gson gson) {
+ try {
+ //noinspection ResultOfMethodCallIgnored
+ file.createNewFile();
+
+ try (
+ BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
+ new FileOutputStream(file),
+ StandardCharsets.UTF_8
+ ))
+ ) {
+ writer.write(gson.toJson(loadedFoundSouls));
+ }
+ } catch (IOException ignored) {
+ }
+ }
+
+ public static void tick() {
+ if (!NotEnoughUpdates.INSTANCE.config.misc.fariySoul) return;
+
+ if (Minecraft.getMinecraft().theWorld == null) {
+ currentSoulList = null;
+ return;
+ }
+
+ JsonObject fairySouls = Constants.FAIRYSOULS;
+ if (fairySouls == null) return;
+
+ String location = SBInfo.getInstance().getLocation();
+ if (location == null) {
+ currentSoulList = null;
+ return;
+ }
+
+ if (currentSoulList == null) {
+ if (fairySouls.has(location) && fairySouls.get(location).isJsonArray()) {
+ JsonArray locations = fairySouls.get(location).getAsJsonArray();
+ currentSoulList = new ArrayList<>();
+ for (int i = 0; i < locations.size(); i++) {
+ try {
+ String coord = locations.get(i).getAsString();
+
+ String[] split = coord.split(",");
+ if (split.length == 3) {
+ String xS = split[0];
+ String yS = split[1];
+ String zS = split[2];
+
+ int x = Integer.parseInt(xS);
+ int y = Integer.parseInt(yS);
+ int z = Integer.parseInt(zS);
+
+ currentSoulList.add(new BlockPos(x, y, z));
+ }
+ } catch (Exception ignored) {
+ }
+ }
+ }
+ }
+
+ if (currentSoulList != null && !currentSoulList.isEmpty()) {
+ TreeMap<Double, BlockPos> distanceSqMap = new TreeMap<>();
+
+ HashMap<String, Set<Integer>> foundSouls = getFoundSoulsForProfile();
+
+ Set<Integer> found = foundSouls.computeIfAbsent(location, k -> new HashSet<>());
+
+ for (int i = 0; i < currentSoulList.size(); i++) {
+ if (found.contains(i)) continue;
+
+ BlockPos pos = currentSoulList.get(i);
+ double distSq = pos.distanceSq(Minecraft.getMinecraft().thePlayer.getPosition());
+ distanceSqMap.put(distSq, pos);
+ }
+
+ int maxSouls = 15;
+ int souls = 0;
+ currentSoulListClose = new ArrayList<>();
+ for (BlockPos pos : distanceSqMap.values()) {
+ currentSoulListClose.add(pos);
+ if (++souls >= maxSouls) break;
+ }
+ }
+ }
+
+ private static void print(String s) {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(s));
+ }
+
+ private static void printHelp() {
+ print("");
+ print(EnumChatFormatting.DARK_PURPLE.toString() + EnumChatFormatting.BOLD + " NEU Fairy Soul Waypoint Guide");
+ print(EnumChatFormatting.LIGHT_PURPLE + "Shows waypoints for every fairy soul in your world");
+ print(EnumChatFormatting.LIGHT_PURPLE + "Clicking a fairy soul automatically removes it from the list");
+ if (!NotEnoughUpdates.INSTANCE.config.hidden.dev) {
+ print(EnumChatFormatting.DARK_RED + "" + EnumChatFormatting.OBFUSCATED + "Ab" + EnumChatFormatting.RESET +
+ EnumChatFormatting.DARK_RED + "!" + EnumChatFormatting.RESET + EnumChatFormatting.RED +
+ " This feature cannot and will not work in Dungeons. " + EnumChatFormatting.DARK_RED + "!" +
+ EnumChatFormatting.OBFUSCATED + "Ab");
+ }
+ print(EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + " Commands:");
+ print(EnumChatFormatting.YELLOW + "/neusouls help - Display this message");
+ print(EnumChatFormatting.YELLOW + "/neusouls on/off - Enable/disable the waypoint markers");
+ print(EnumChatFormatting.YELLOW +
+ "/neusouls clear/unclear - Marks every waypoint in your current world as completed/uncompleted");
+ print("");
+ }
+
+ @SubscribeEvent
+ public void onWorldUnload(WorldEvent.Unload event) {
+ currentSoulList = null;
+ }
+
+ @SubscribeEvent
+ public void onChatReceived(ClientChatReceivedEvent event) {
+ if (currentSoulList == null) return;
+
+ if (event.message.getFormattedText().equals("\u00A7r\u00A7dYou have already found that Fairy Soul!\u00A7r") ||
+ event.message.getFormattedText().equals(
+ "\u00A7d\u00A7lSOUL! \u00A7fYou found a \u00A7r\u00A7dFairy Soul\u00A7r\u00A7f!\u00A7r")) {
+ String location = SBInfo.getInstance().getLocation();
+ if (location == null) return;
+
+ int closestIndex = -1;
+ double closestDistSq = 10 * 10;
+ for (int i = 0; i < currentSoulList.size(); i++) {
+ BlockPos pos = currentSoulList.get(i);
+
+ double distSq = pos.distanceSq(Minecraft.getMinecraft().thePlayer.getPosition());
+
+ if (distSq < closestDistSq) {
+ closestDistSq = distSq;
+ closestIndex = i;
+ }
+ }
+ if (closestIndex != -1) {
+ HashMap<String, Set<Integer>> foundSouls = getFoundSoulsForProfile();
+ Set<Integer> found = foundSouls.computeIfAbsent(location, k -> new HashSet<>());
+ found.add(closestIndex);
+ }
+ }
+ }
+
+ @SubscribeEvent
+ public void onRenderLast(RenderWorldLastEvent event) {
+ if (!NotEnoughUpdates.INSTANCE.config.misc.fariySoul) return;
+
+ String location = SBInfo.getInstance().getLocation();
+ if (location == null) return;
+ if (currentSoulList == null || currentSoulList.isEmpty()) return;
+
+ int rgb = 0xa839ce;
+ for (BlockPos currentSoul : currentSoulListClose) {
+ RenderUtils.renderBeaconBeamOrBoundingBox(currentSoul, rgb, 1.0f, event.partialTicks);
+ }
+ }
+
+ public static class FairySoulsCommand extends ClientCommandBase {
+
+ public FairySoulsCommand() {
+ super("neusouls");
+ }
+
+ @Override
+ public List<String> getCommandAliases() {
+ return Collections.singletonList("fairysouls");
+ }
+
+ @Override
+ public void processCommand(ICommandSender sender, String[] args) throws CommandException {
+ if (args.length != 1) {
+ printHelp();
+ return;
+ }
+ String subcommand = args[0].toLowerCase();
+
+ switch (subcommand) {
+ case "help":
+ printHelp();
+ return;
+ case "on":
+ case "enable":
+ print(EnumChatFormatting.DARK_PURPLE + "Enabled fairy soul waypoints");
+ NotEnoughUpdates.INSTANCE.config.misc.fariySoul = true;
+ return;
+ case "off":
+ case "disable":
+ print(EnumChatFormatting.DARK_PURPLE + "Disabled fairy soul waypoints");
+ NotEnoughUpdates.INSTANCE.config.misc.fariySoul = false;
+ return;
+ case "clear": {
+ String location = SBInfo.getInstance().getLocation();
+ if (currentSoulList == null || location == null) {
+ print(EnumChatFormatting.RED + "No fairy souls found in your current world");
+ } else {
+ HashMap<String, Set<Integer>> foundSouls = getFoundSoulsForProfile();
+ Set<Integer> found = foundSouls.computeIfAbsent(location, k -> new HashSet<>());
+ for (int i = 0; i < currentSoulList.size(); i++) {
+ found.add(i);
+ }
+ String profileName = SBInfo.getInstance().currentProfile;
+ if (profileName == null) {
+ if (loadedFoundSouls.containsKey(unknownProfile)) {
+ loadedFoundSouls.get(unknownProfile).put(location, found);
+ }
+ } else {
+ profileName = profileName.toLowerCase();
+ if (!loadedFoundSouls.containsKey(profileName)) {
+ HashMap<String, Set<Integer>> profileData = new HashMap<>();
+ loadedFoundSouls.put(profileName, profileData);
+ }
+ loadedFoundSouls.get(profileName).put(location, found);
+ }
+ print(EnumChatFormatting.DARK_PURPLE + "Marked all fairy souls as found");
+ }
+ }
+ return;
+ case "unclear":
+ String location = SBInfo.getInstance().getLocation();
+ if (location == null) {
+ print(EnumChatFormatting.RED + "No fairy souls found in your current world");
+ } else {
+ String profileName = SBInfo.getInstance().currentProfile;
+ if (profileName == null) {
+ if (loadedFoundSouls.containsKey(unknownProfile)) {
+ loadedFoundSouls.get(unknownProfile).remove(location);
+ }
+ } else {
+ profileName = profileName.toLowerCase();
+ if (!loadedFoundSouls.containsKey(profileName)) {
+ HashMap<String, Set<Integer>> profileData = new HashMap<>();
+ loadedFoundSouls.put(profileName, profileData);
+ }
+ loadedFoundSouls.get(profileName).remove(location);
+ }
+ print(EnumChatFormatting.DARK_PURPLE + "Marked all fairy souls as not found");
+ }
+ return;
+ }
+
+ print(EnumChatFormatting.RED + "Unknown subcommand: " + subcommand);
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FancyPortals.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FancyPortals.java
index a9be6fd5..12e65e65 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FancyPortals.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FancyPortals.java
@@ -1,14 +1,8 @@
package io.github.moulberry.notenoughupdates.miscfeatures;
-import io.github.moulberry.notenoughupdates.cosmetics.CapeNode;
-import io.github.moulberry.notenoughupdates.util.ReverseWorldRenderer;
-import io.github.moulberry.notenoughupdates.util.TexLoc;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
-import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.gui.Gui;
-import net.minecraft.client.gui.ScaledResolution;
-import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderGlobal;
import net.minecraft.client.renderer.WorldRenderer;
@@ -17,172 +11,167 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.client.renderer.vertex.VertexFormatElement;
import net.minecraft.entity.Entity;
-import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
-import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.play.server.S07PacketRespawn;
-import net.minecraft.util.BlockPos;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
-import net.minecraftforge.client.event.GuiScreenEvent;
import net.minecraftforge.client.event.RenderLivingEvent;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.glu.Project;
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.nio.ByteBuffer;
import java.util.List;
public class FancyPortals {
-
- private static ResourceLocation[] RENDERS = new ResourceLocation[6];
-
- static {
- for(int i=0; i<6; i++) {
- RENDERS[i] = new ResourceLocation("notenoughupdates:portal_panoramas/nether/pansc-"+(i+1)+".png");
- }
- }
-
- public static int perspectiveId = -1;
- public static boolean overridePerspective() {
- if(perspectiveId >= 0 && !Keyboard.isKeyDown(Keyboard.KEY_K)) {
- if(perspectiveId == 0) {
- GlStateManager.matrixMode(5889);
- GlStateManager.loadIdentity();
- GlStateManager.ortho(0.0D, 7, 7, 0.0D, -100D, 100D);
- GlStateManager.scale(1, 1, -1);
- GlStateManager.matrixMode(5888);
- GlStateManager.loadIdentity();
- GlStateManager.translate(3.5F, 3.5F, -1.0F);
- GlStateManager.rotate(-90, 1, 0, 0);
- } else if(perspectiveId <= 4) {
- GlStateManager.matrixMode(5889);
- GlStateManager.loadIdentity();
- Project.gluPerspective(90, 1, 0.05F, 160 * MathHelper.SQRT_2);
- GlStateManager.matrixMode(5888);
- GlStateManager.loadIdentity();
- GlStateManager.rotate(perspectiveId*90, 0, 1, 0);
- GlStateManager.translate(0, -3.5f, 0);
- } else {
- GlStateManager.matrixMode(5889);
- GlStateManager.loadIdentity();
- Project.gluPerspective(90, 1, 0.05F, 160 * MathHelper.SQRT_2);
- GlStateManager.matrixMode(5888);
- GlStateManager.loadIdentity();
- GlStateManager.rotate(-90, 1, 0, 0);
- GlStateManager.translate(0, -3.5f, 0);
- }
-
- return true;
- }
- return false;
- }
-
- private static WorldRenderer surfaceWorldRenderer = null;
-
- private static WorldRenderer getSurfaceWorldRenderer() {
- if(surfaceWorldRenderer != null && !Keyboard.isKeyDown(Keyboard.KEY_O)) {
- return surfaceWorldRenderer;
- }
-
- surfaceWorldRenderer = createSurfaceWorldRenderer();
-
- return surfaceWorldRenderer;
- }
-
- private static void drawPoint(WorldRenderer worldRenderer, int x, int y) {
- float xDist = 1-Math.abs(x-50)/50f;
- float yDist = 1-Math.abs(y-50)/50f;
- float distToEdge = Math.min(xDist, yDist);
-
- float z = 0.4142f;
- if(distToEdge < 1/3.5f) {
- if(y > 50 && yDist < xDist) {
- float circleH = 1.414f - distToEdge*3.5f*1.414f;
- z = (float)Math.sqrt(2f-circleH*circleH);
- z *= 0.4142f / 1.4142f;
- } else {
- float circleH = 1 - distToEdge*3.5f;
- z = (float)Math.sqrt(2f-circleH*circleH)-1;
- }
- }
-
- worldRenderer.pos(x*7/100f, y*7/100f, z).tex(x/100f, y/100f).endVertex();
- }
-
- private static WorldRenderer createSurfaceWorldRenderer() {
- WorldRenderer worldRenderer = new WorldRenderer(20*100*100);
- worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
-
- for(int x=0; x<100; x++) {
- for(int y=0; y<100; y++) {
- drawPoint(worldRenderer, x, y);
- drawPoint(worldRenderer, x, y+1);
- drawPoint(worldRenderer, x+1, y+1);
- drawPoint(worldRenderer, x+1, y);
- }
- }
-
- return worldRenderer;
- }
-
- private static long overridingRenderMillis = -1;
-
- public static void onRespawnPacket(S07PacketRespawn packet) {
- if(true) return;
- if (packet.getDimensionID() != Minecraft.getMinecraft().thePlayer.dimension) {
- overridingRenderMillis = System.currentTimeMillis();
- }
- }
-
- public static boolean shouldRenderLoadingScreen() {
- return false;
- }
-
- public static boolean shouldRenderWorldOverlay() {
- if(overridingRenderMillis > 0) {
- if(Minecraft.getMinecraft().theWorld != null && Minecraft.getMinecraft().thePlayer != null) {
- RenderGlobal renderGlobal = Minecraft.getMinecraft().renderGlobal;
- int loaded = 0;
- for(RenderGlobal.ContainerLocalRenderInformation info : renderGlobal.renderInfos) {
- CompiledChunk compiledchunk = info.renderChunk.compiledChunk;
-
- if (compiledchunk != CompiledChunk.DUMMY && !compiledchunk.isEmpty()) {
- if(++loaded >= 5) {
- overridingRenderMillis = -1;
- return false;
- }
- }
- }
- }
- if(System.currentTimeMillis() - overridingRenderMillis > 1000) {
- overridingRenderMillis = -1;
- return false;
- }
- return true;
- }
- return false;
- }
-
- public static void onUpdateCameraAndRender(float partialTicks, long nanoTime) {
- if(overridingRenderMillis > 0) {
- if(Minecraft.getMinecraft().theWorld != null && Minecraft.getMinecraft().thePlayer != null) {
- Minecraft.getMinecraft().thePlayer.timeInPortal = 0.3f;
- Minecraft.getMinecraft().thePlayer.prevTimeInPortal = 0.3f;
- }
-
- GlStateManager.rotate(90, 0, 1, 0);
- renderWorld();
-
- Minecraft.getMinecraft().ingameGUI.renderGameOverlay(partialTicks);
- }
- }
-
- @SubscribeEvent
- public void onRenderEntityYeeter(RenderLivingEvent.Pre<EntityLivingBase> event) {
+ private static final ResourceLocation[] RENDERS = new ResourceLocation[6];
+
+ static {
+ for (int i = 0; i < 6; i++) {
+ RENDERS[i] = new ResourceLocation("notenoughupdates:portal_panoramas/nether/pansc-" + (i + 1) + ".png");
+ }
+ }
+
+ public static int perspectiveId = -1;
+
+ public static boolean overridePerspective() {
+ if (perspectiveId >= 0 && !Keyboard.isKeyDown(Keyboard.KEY_K)) {
+ if (perspectiveId == 0) {
+ GlStateManager.matrixMode(5889);
+ GlStateManager.loadIdentity();
+ GlStateManager.ortho(0.0D, 7, 7, 0.0D, -100D, 100D);
+ GlStateManager.scale(1, 1, -1);
+ GlStateManager.matrixMode(5888);
+ GlStateManager.loadIdentity();
+ GlStateManager.translate(3.5F, 3.5F, -1.0F);
+ GlStateManager.rotate(-90, 1, 0, 0);
+ } else if (perspectiveId <= 4) {
+ GlStateManager.matrixMode(5889);
+ GlStateManager.loadIdentity();
+ Project.gluPerspective(90, 1, 0.05F, 160 * MathHelper.SQRT_2);
+ GlStateManager.matrixMode(5888);
+ GlStateManager.loadIdentity();
+ GlStateManager.rotate(perspectiveId * 90, 0, 1, 0);
+ GlStateManager.translate(0, -3.5f, 0);
+ } else {
+ GlStateManager.matrixMode(5889);
+ GlStateManager.loadIdentity();
+ Project.gluPerspective(90, 1, 0.05F, 160 * MathHelper.SQRT_2);
+ GlStateManager.matrixMode(5888);
+ GlStateManager.loadIdentity();
+ GlStateManager.rotate(-90, 1, 0, 0);
+ GlStateManager.translate(0, -3.5f, 0);
+ }
+
+ return true;
+ }
+ return false;
+ }
+
+ private static WorldRenderer surfaceWorldRenderer = null;
+
+ private static WorldRenderer getSurfaceWorldRenderer() {
+ if (surfaceWorldRenderer != null && !Keyboard.isKeyDown(Keyboard.KEY_O)) {
+ return surfaceWorldRenderer;
+ }
+
+ surfaceWorldRenderer = createSurfaceWorldRenderer();
+
+ return surfaceWorldRenderer;
+ }
+
+ private static void drawPoint(WorldRenderer worldRenderer, int x, int y) {
+ float xDist = 1 - Math.abs(x - 50) / 50f;
+ float yDist = 1 - Math.abs(y - 50) / 50f;
+ float distToEdge = Math.min(xDist, yDist);
+
+ float z = 0.4142f;
+ if (distToEdge < 1 / 3.5f) {
+ if (y > 50 && yDist < xDist) {
+ float circleH = 1.414f - distToEdge * 3.5f * 1.414f;
+ z = (float) Math.sqrt(2f - circleH * circleH);
+ z *= 0.4142f / 1.4142f;
+ } else {
+ float circleH = 1 - distToEdge * 3.5f;
+ z = (float) Math.sqrt(2f - circleH * circleH) - 1;
+ }
+ }
+
+ worldRenderer.pos(x * 7 / 100f, y * 7 / 100f, z).tex(x / 100f, y / 100f).endVertex();
+ }
+
+ private static WorldRenderer createSurfaceWorldRenderer() {
+ WorldRenderer worldRenderer = new WorldRenderer(20 * 100 * 100);
+ worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
+
+ for (int x = 0; x < 100; x++) {
+ for (int y = 0; y < 100; y++) {
+ drawPoint(worldRenderer, x, y);
+ drawPoint(worldRenderer, x, y + 1);
+ drawPoint(worldRenderer, x + 1, y + 1);
+ drawPoint(worldRenderer, x + 1, y);
+ }
+ }
+
+ return worldRenderer;
+ }
+
+ private static long overridingRenderMillis = -1;
+
+ public static void onRespawnPacket(S07PacketRespawn packet) {
+ if (true) return;
+ if (packet.getDimensionID() != Minecraft.getMinecraft().thePlayer.dimension) {
+ overridingRenderMillis = System.currentTimeMillis();
+ }
+ }
+
+ public static boolean shouldRenderLoadingScreen() {
+ return false;
+ }
+
+ public static boolean shouldRenderWorldOverlay() {
+ if (overridingRenderMillis > 0) {
+ if (Minecraft.getMinecraft().theWorld != null && Minecraft.getMinecraft().thePlayer != null) {
+ RenderGlobal renderGlobal = Minecraft.getMinecraft().renderGlobal;
+ int loaded = 0;
+ for (RenderGlobal.ContainerLocalRenderInformation info : renderGlobal.renderInfos) {
+ CompiledChunk compiledchunk = info.renderChunk.compiledChunk;
+
+ if (compiledchunk != CompiledChunk.DUMMY && !compiledchunk.isEmpty()) {
+ if (++loaded >= 5) {
+ overridingRenderMillis = -1;
+ return false;
+ }
+ }
+ }
+ }
+ if (System.currentTimeMillis() - overridingRenderMillis > 1000) {
+ overridingRenderMillis = -1;
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
+
+ public static void onUpdateCameraAndRender(float partialTicks, long nanoTime) {
+ if (overridingRenderMillis > 0) {
+ if (Minecraft.getMinecraft().theWorld != null && Minecraft.getMinecraft().thePlayer != null) {
+ Minecraft.getMinecraft().thePlayer.timeInPortal = 0.3f;
+ Minecraft.getMinecraft().thePlayer.prevTimeInPortal = 0.3f;
+ }
+
+ GlStateManager.rotate(90, 0, 1, 0);
+ renderWorld();
+
+ Minecraft.getMinecraft().ingameGUI.renderGameOverlay(partialTicks);
+ }
+ }
+
+ @SubscribeEvent
+ public void onRenderEntityYeeter(RenderLivingEvent.Pre<EntityLivingBase> event) {
/*if(!Keyboard.isKeyDown(Keyboard.KEY_G)) return;
event.setCanceled(true);
if(event.entity instanceof EntityPlayer) {
@@ -191,113 +180,114 @@ public class FancyPortals {
event.setCanceled(true);
}
}*/
- }
-
- private static void renderWorld() {
- for(int i=5; i>=0; i--) {
- GlStateManager.pushMatrix();
-
- GlStateManager.disableDepth();
- GlStateManager.disableLighting();
-
-
- GlStateManager.rotate(180, 0, 0, 1);
- GlStateManager.rotate(-90, 0, 1, 0);
-
- if(i != 0) GlStateManager.translate(0, -3.49, 0);
-
- switch (i) {
- case 1:
- GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F); break;
- case 2:
- GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F); break;
- case 3:
- GlStateManager.rotate(-90.0F, 0.0F, 1.0F, 0.0F); break;
- case 5:
- GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F); break;
- case 0:
- GlStateManager.rotate(-90.0F, 1.0F, 0.0F, 0.0F); break;
- }
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(RENDERS[i]);
- GlStateManager.color(1, 1, 1, 1);
- if(i != 0) GlStateManager.translate(0, 0, 3.49);
-
- if(i != 0) {
- GlStateManager.translate(-3.5f, -3.5f, 0);
- WorldRenderer worldRenderer = getSurfaceWorldRenderer();
- VertexFormat vertexformat = worldRenderer.getVertexFormat();
- int stride = vertexformat.getNextOffset();
- ByteBuffer bytebuffer = worldRenderer.getByteBuffer();
- List<VertexFormatElement> list = vertexformat.getElements();
-
- for (int index = 0; index < list.size(); index++) {
- VertexFormatElement vertexformatelement = list.get(index);
- vertexformatelement.getUsage().preDraw(vertexformat, index, stride, bytebuffer);
- }
-
- GL11.glDrawArrays(worldRenderer.getDrawMode(), 0, worldRenderer.getVertexCount());
-
- for (int index = 0; index < list.size(); index++) {
- VertexFormatElement vertexformatelement = list.get(index);
- vertexformatelement.getUsage().postDraw(vertexformat, index, stride, bytebuffer);
- }
- } else {
- Utils.drawTexturedRect(-3.5f, -3.5f, 7, 7, i == 0 ? GL11.GL_NEAREST : GL11.GL_LINEAR);
- }
-
- GlStateManager.enableDepth();
-
- GlStateManager.popMatrix();
- }
- }
-
- @SubscribeEvent
- public void onRenderLast(RenderWorldLastEvent event) {
- if(true) return;
- if(!Minecraft.getMinecraft().getFramebuffer().isStencilEnabled())
- Minecraft.getMinecraft().getFramebuffer().enableStencil();
-
- GL11.glEnable(GL11.GL_STENCIL_TEST);
- GL11.glStencilFunc(GL11.GL_ALWAYS, 1, 0xFF);
- GL11.glStencilOp(GL11.GL_ZERO, GL11.GL_ZERO, GL11.GL_REPLACE);
- GL11.glStencilMask(0xFF);
- GL11.glClear(GL11.GL_STENCIL_BUFFER_BIT);
- GlStateManager.enableDepth();
- GlStateManager.enableCull();
- GlStateManager.cullFace(GL11.GL_BACK);
-
- GL11.glColorMask(false, false, false, false);
-
- Entity viewer = Minecraft.getMinecraft().getRenderViewEntity();
- double viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * event.partialTicks;
- double viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * event.partialTicks;
- double viewerZ = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * event.partialTicks;
- GlStateManager.pushMatrix();
-
- GlStateManager.translate(-viewerX+12+5/16f, -viewerY+100, -viewerZ+39);
- GlStateManager.rotate(90, 0, 1, 0);
- Gui.drawRect(0, 5, 3, 0, 0xffffffff);
- GlStateManager.rotate(180, 0, 1, 0);
- GlStateManager.translate(-3, 0, -6/16f);
- Gui.drawRect(0, 5, 3, 0, 0xffffffff);
-
- GlStateManager.popMatrix();
-
-
- GL11.glColorMask(true, true, true, true);
-
- // Only pass stencil test if equal to 1
- GL11.glStencilMask(0x00);
- GL11.glStencilFunc(GL11.GL_EQUAL, 1, 0xFF);
-
- GlStateManager.translate(-viewerX+12, -viewerY+100, -viewerZ+37.5f);
-
- renderWorld();
-
- GL11.glDisable(GL11.GL_STENCIL_TEST);
- GlStateManager.enableCull();
- }
-
-
+ }
+
+ private static void renderWorld() {
+ for (int i = 5; i >= 0; i--) {
+ GlStateManager.pushMatrix();
+
+ GlStateManager.disableDepth();
+ GlStateManager.disableLighting();
+
+ GlStateManager.rotate(180, 0, 0, 1);
+ GlStateManager.rotate(-90, 0, 1, 0);
+
+ if (i != 0) GlStateManager.translate(0, -3.49, 0);
+
+ switch (i) {
+ case 1:
+ GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F);
+ break;
+ case 2:
+ GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
+ break;
+ case 3:
+ GlStateManager.rotate(-90.0F, 0.0F, 1.0F, 0.0F);
+ break;
+ case 5:
+ GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F);
+ break;
+ case 0:
+ GlStateManager.rotate(-90.0F, 1.0F, 0.0F, 0.0F);
+ break;
+ }
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(RENDERS[i]);
+ GlStateManager.color(1, 1, 1, 1);
+ if (i != 0) GlStateManager.translate(0, 0, 3.49);
+
+ if (i != 0) {
+ GlStateManager.translate(-3.5f, -3.5f, 0);
+ WorldRenderer worldRenderer = getSurfaceWorldRenderer();
+ VertexFormat vertexformat = worldRenderer.getVertexFormat();
+ int stride = vertexformat.getNextOffset();
+ ByteBuffer bytebuffer = worldRenderer.getByteBuffer();
+ List<VertexFormatElement> list = vertexformat.getElements();
+
+ for (int index = 0; index < list.size(); index++) {
+ VertexFormatElement vertexformatelement = list.get(index);
+ vertexformatelement.getUsage().preDraw(vertexformat, index, stride, bytebuffer);
+ }
+
+ GL11.glDrawArrays(worldRenderer.getDrawMode(), 0, worldRenderer.getVertexCount());
+
+ for (int index = 0; index < list.size(); index++) {
+ VertexFormatElement vertexformatelement = list.get(index);
+ vertexformatelement.getUsage().postDraw(vertexformat, index, stride, bytebuffer);
+ }
+ } else {
+ Utils.drawTexturedRect(-3.5f, -3.5f, 7, 7, i == 0 ? GL11.GL_NEAREST : GL11.GL_LINEAR);
+ }
+
+ GlStateManager.enableDepth();
+
+ GlStateManager.popMatrix();
+ }
+ }
+
+ @SubscribeEvent
+ public void onRenderLast(RenderWorldLastEvent event) {
+ if (true) return;
+ if (!Minecraft.getMinecraft().getFramebuffer().isStencilEnabled())
+ Minecraft.getMinecraft().getFramebuffer().enableStencil();
+
+ GL11.glEnable(GL11.GL_STENCIL_TEST);
+ GL11.glStencilFunc(GL11.GL_ALWAYS, 1, 0xFF);
+ GL11.glStencilOp(GL11.GL_ZERO, GL11.GL_ZERO, GL11.GL_REPLACE);
+ GL11.glStencilMask(0xFF);
+ GL11.glClear(GL11.GL_STENCIL_BUFFER_BIT);
+ GlStateManager.enableDepth();
+ GlStateManager.enableCull();
+ GlStateManager.cullFace(GL11.GL_BACK);
+
+ GL11.glColorMask(false, false, false, false);
+
+ Entity viewer = Minecraft.getMinecraft().getRenderViewEntity();
+ double viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * event.partialTicks;
+ double viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * event.partialTicks;
+ double viewerZ = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * event.partialTicks;
+ GlStateManager.pushMatrix();
+
+ GlStateManager.translate(-viewerX + 12 + 5 / 16f, -viewerY + 100, -viewerZ + 39);
+ GlStateManager.rotate(90, 0, 1, 0);
+ Gui.drawRect(0, 5, 3, 0, 0xffffffff);
+ GlStateManager.rotate(180, 0, 1, 0);
+ GlStateManager.translate(-3, 0, -6 / 16f);
+ Gui.drawRect(0, 5, 3, 0, 0xffffffff);
+
+ GlStateManager.popMatrix();
+
+ GL11.glColorMask(true, true, true, true);
+
+ // Only pass stencil test if equal to 1
+ GL11.glStencilMask(0x00);
+ GL11.glStencilFunc(GL11.GL_EQUAL, 1, 0xFF);
+
+ GlStateManager.translate(-viewerX + 12, -viewerY + 100, -viewerZ + 37.5f);
+
+ renderWorld();
+
+ GL11.glDisable(GL11.GL_STENCIL_TEST);
+ GlStateManager.enableCull();
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java
index de7ffe5e..34e849d0 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java
@@ -6,7 +6,6 @@ import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.ISound;
import net.minecraft.client.audio.PositionedSound;
-import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.audio.SoundCategory;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.GlStateManager;
@@ -25,560 +24,607 @@ import org.lwjgl.opengl.GL11;
import java.util.*;
public class FishingHelper {
-
- private static final FishingHelper INSTANCE = new FishingHelper();
-
- public static FishingHelper getInstance() {
- return INSTANCE;
- }
-
- public static class WakeChain {
- public int particleNum = 0;
- public long lastUpdate;
- public double currentAngle;
- public double currentX;
- public double currentZ;
-
- public final HashMap<Integer, Double> distances = new HashMap<>();
-
- public WakeChain(long lastUpdate, double currentAngle, double currentX, double currentZ) {
- this.lastUpdate = lastUpdate;
- this.currentAngle = currentAngle;
- this.currentX = currentX;
- this.currentZ = currentZ;
- }
- }
-
- public enum PlayerWarningState {
- NOTHING,
- FISH_INCOMING,
- FISH_HOOKED
- }
- public PlayerWarningState warningState = PlayerWarningState.NOTHING;
- private int hookedWarningStateTicks = 0;
-
- public final HashMap<Integer, EntityFishHook> hookEntities = new HashMap<>();
- public final HashMap<WakeChain, List<Integer>> chains = new HashMap<>();
-
- private long lastCastRodMillis = 0;
- private int pingDelayTicks = 0;
- private final List<Integer> pingDelayList = new ArrayList<>();
- private int buildupSoundDelay = 0;
-
- private static final ResourceLocation FISHING_WARNING_EXCLAM = new ResourceLocation("notenoughupdates:fishing_warning_exclam.png");
- public void onRenderBobber(EntityFishHook hook) {
- if(Minecraft.getMinecraft().thePlayer.fishEntity == hook && warningState != PlayerWarningState.NOTHING) {
-
- if(!NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarning && warningState == PlayerWarningState.FISH_INCOMING) return;
- if(!NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarningR && warningState == PlayerWarningState.FISH_HOOKED) return;
-
- GlStateManager.disableCull();
- GlStateManager.disableLighting();
- GL11.glDepthFunc(GL11.GL_ALWAYS);
- GlStateManager.scale(1, -1, 1);
-
- float offset = warningState == PlayerWarningState.FISH_HOOKED ? 0.5f : 0f;
-
- float centerOffset = 0.5f/8f;
- Minecraft.getMinecraft().getTextureManager().bindTexture(FISHING_WARNING_EXCLAM);
- Utils.drawTexturedRect(centerOffset - 4f/8f, -20/8f, 1f, 2f, 0+offset, 0.5f+offset, 0, 1, GL11.GL_NEAREST);
-
- GlStateManager.scale(1, -1, 1);
- GL11.glDepthFunc(GL11.GL_LEQUAL);
- GlStateManager.enableLighting();
- GlStateManager.enableCull();
- }
- }
-
- public void addEntity(int entityId, Entity entity) {
- if(entity instanceof EntityFishHook) {
- hookEntities.put(entityId, (EntityFishHook) entity);
-
- if(((EntityFishHook) entity).angler == Minecraft.getMinecraft().thePlayer) {
- long currentTime = System.currentTimeMillis();
- long delay = currentTime - lastCastRodMillis;
- if(delay > 0 && delay < 500) {
- if(delay > 300) delay = 300;
- pingDelayList.add(0, (int)delay);
- }
- }
- }
- }
-
- public void removeEntity(int entityId) {
- hookEntities.remove(entityId);
- }
-
- @SubscribeEvent
- public void onWorldUnload(WorldEvent.Unload event) {
- hookEntities.clear();
- chains.clear();
- }
-
- @SubscribeEvent
- public void onPlayerInteract(PlayerInteractEvent event) {
- if(event.action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR &&
- event.entityPlayer == Minecraft.getMinecraft().thePlayer) {
-
- ItemStack heldItem = event.entityPlayer.getHeldItem();
-
- if(heldItem != null && heldItem.getItem() == Items.fishing_rod) {
- long currentTime = System.currentTimeMillis();
- if(currentTime - lastCastRodMillis > 500) {
- lastCastRodMillis = currentTime;
- }
- }
-
- }
- }
-
- private int tickCounter = 0;
- @SubscribeEvent
- public void onTick(TickEvent.ClientTickEvent event) {
- if(Minecraft.getMinecraft().thePlayer != null && event.phase == TickEvent.Phase.END) {
- if(buildupSoundDelay > 0) buildupSoundDelay--;
-
- if(NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarning || NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarningR) {
- if(Minecraft.getMinecraft().thePlayer.fishEntity != null) {
- if(!pingDelayList.isEmpty()) {
- while(pingDelayList.size() > 5) pingDelayList.remove(pingDelayList.size()-1);
-
- int totalMS = 0;
- for(int delay : pingDelayList) {
- totalMS += delay;
- }
-
- int averageMS = totalMS / pingDelayList.size();
- pingDelayTicks = (int)Math.floor(averageMS/50f);
- }
- }
-
- if(hookedWarningStateTicks > 0) {
- hookedWarningStateTicks--;
- warningState = PlayerWarningState.FISH_HOOKED;
- } else {
- warningState = PlayerWarningState.NOTHING;
- if(Minecraft.getMinecraft().thePlayer.fishEntity != null) {
- int fishEntityId = Minecraft.getMinecraft().thePlayer.fishEntity.getEntityId();
- for(Map.Entry<WakeChain, List<Integer>> entry : chains.entrySet()) {
- if(entry.getKey().particleNum >= 3 && entry.getValue().contains(fishEntityId)) {
- warningState = PlayerWarningState.FISH_INCOMING;
- break;
- }
- }
- }
- }
- }
-
- if(tickCounter++ >= 20) {
- long currentTime = System.currentTimeMillis();
- tickCounter = 0;
-
- Set<Integer> toRemoveEnt = new HashSet<>();
- for(Map.Entry<Integer, EntityFishHook> entry : hookEntities.entrySet()) {
- if(entry.getValue().isDead) {
- toRemoveEnt.add(entry.getKey());
- }
- }
- hookEntities.keySet().removeAll(toRemoveEnt);
-
- Set<WakeChain> toRemoveChain = new HashSet<>();
- for(Map.Entry<WakeChain, List<Integer>> entry : chains.entrySet()) {
- if(currentTime - entry.getKey().lastUpdate > 200 ||
- entry.getValue().isEmpty() ||
- Collections.disjoint(entry.getValue(), hookEntities.keySet())) {
- toRemoveChain.add(entry.getKey());
- }
- }
- chains.keySet().removeAll(toRemoveChain);
- }
- }
- }
-
- private double calculateAngleFromOffsets(double xOffset, double zOffset) {
- double angleX = Math.toDegrees(Math.acos(xOffset / 0.04f));
- double angleZ = Math.toDegrees(Math.asin(zOffset / 0.04f));
-
- if(xOffset < 0) {
- angleZ = 180 - angleZ;
- }
- if(zOffset < 0) {
- angleX = 360 - angleX;
- }
-
- angleX %= 360;
- angleZ %= 360;
- if(angleX < 0) angleX += 360;
- if(angleZ < 0) angleZ += 360;
-
- double dist = angleX - angleZ;
- if(dist < -180) dist += 360;
- if(dist > 180) dist -= 360;
-
- return angleZ + dist/2;
- }
-
- private boolean checkAngleWithinRange(double angle1, double angle2, double range) {
- double dist = Math.abs(angle1 - angle2);
- if(dist > 180) dist = 360 - dist;
-
- return dist <= range;
- }
-
- private enum HookPossibleRet {
- NOT_POSSIBLE,
- EITHER,
- ANGLE1,
- ANGLE2
- }
-
- private HookPossibleRet isHookPossible(EntityFishHook hook, double particleX, double particleY, double particleZ, double angle1, double angle2) {
- double dY = particleY - hook.posY;
- if(Math.abs(dY) > 0.5f) {
- return HookPossibleRet.NOT_POSSIBLE;
- }
-
- double dX = particleX - hook.posX;
- double dZ = particleZ - hook.posZ;
- double dist = Math.sqrt(dX*dX + dZ*dZ);
-
- if(dist < 0.2) {
- return HookPossibleRet.EITHER;
- } else {
- float angleAllowance = (float)Math.toDegrees(Math.atan2(0.03125f, dist))*1.5f;
- float angleHook = (float) Math.toDegrees(Math.atan2(dX, dZ));
- angleHook %= 360;
- if(angleHook < 0) angleHook += 360;
-
- if(checkAngleWithinRange(angle1, angleHook, angleAllowance)) {
- return HookPossibleRet.ANGLE1;
- } else if(checkAngleWithinRange(angle2, angleHook, angleAllowance)) {
- return HookPossibleRet.ANGLE2;
- }
- }
- return HookPossibleRet.NOT_POSSIBLE;
- }
-
- public static EnumParticleTypes type = EnumParticleTypes.BARRIER;
-
- private static final float ZERO_PITCH = 1.0f;
- private static final float MAX_PITCH = 0.1f;
- private static final float MAX_DISTANCE = 5f;
- private float calculatePitchFromDistance(float d) {
- if(d < 0.1f) d = 0.1f;
- if(d > MAX_DISTANCE) d = MAX_DISTANCE;
-
- return 1/(d + (1/(ZERO_PITCH-MAX_PITCH))) * (1 - d/MAX_DISTANCE) + MAX_PITCH;
- }
-
- public boolean onSpawnParticle(EnumParticleTypes particleType, double x, double y, double z, double xOffset, double yOffset, double zOffset) {
-
- if(!NotEnoughUpdates.INSTANCE.config.fishing.hideOtherPlayerAll &&
- !NotEnoughUpdates.INSTANCE.config.fishing.enableCustomParticles &&
- !NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarning &&
- !NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarningR) {
- return false;
- }
- if(hookEntities.isEmpty()) {
- return false;
- }
-
-
- if((particleType == EnumParticleTypes.WATER_WAKE|| particleType == EnumParticleTypes.SMOKE_NORMAL) && Math.abs(yOffset - 0.01f) < 0.001f) {
- double angle1 = calculateAngleFromOffsets(xOffset, -zOffset);
- double angle2 = calculateAngleFromOffsets(-xOffset, zOffset);
-
-
- final List<Integer> possibleHooks1 = new ArrayList<>();
- final List<Integer> possibleHooks2 = new ArrayList<>();
-
- for(EntityFishHook hook : hookEntities.values()) {
- if(hook.isDead) continue;
- if(possibleHooks1.contains(hook.getEntityId())) continue;
- if(possibleHooks2.contains(hook.getEntityId())) continue;
-
- HookPossibleRet ret = isHookPossible(hook, x, y, z, angle1, angle2);
- if(ret == HookPossibleRet.ANGLE1) {
- possibleHooks1.add(hook.getEntityId());
- } else if(ret == HookPossibleRet.ANGLE2) {
- possibleHooks2.add(hook.getEntityId());
- } else if(ret == HookPossibleRet.EITHER) {
- possibleHooks1.add(hook.getEntityId());
- possibleHooks2.add(hook.getEntityId());
- }
- }
-
- if(!possibleHooks1.isEmpty() || !possibleHooks2.isEmpty()) {
- long currentTime = System.currentTimeMillis();
-
- boolean isMainPlayer = false;
-
- boolean foundChain = false;
- for(Map.Entry<WakeChain, List<Integer>> entry : chains.entrySet()) {
- WakeChain chain = entry.getKey();
-
- if(currentTime - chain.lastUpdate > 200) continue;
-
- double updateAngle;
- List<Integer> possibleHooks;
- if(checkAngleWithinRange(chain.currentAngle, angle1, 16)) {
- possibleHooks = possibleHooks1;
- updateAngle = angle1;
- } else if(checkAngleWithinRange(chain.currentAngle, angle2, 16)) {
- possibleHooks = possibleHooks2;
- updateAngle = angle2;
- } else {
- continue;
- }
-
- if(!Collections.disjoint(entry.getValue(), possibleHooks)) {
- HashSet<Integer> newHooks = new HashSet<>();
-
- for(int hookEntityId : possibleHooks) {
- if(entry.getValue().contains(hookEntityId) && chain.distances.containsKey(hookEntityId)) {
- EntityFishHook entity = hookEntities.get(hookEntityId);
-
- if(entity != null && !entity.isDead) {
- double oldDistance = chain.distances.get(hookEntityId);
-
- double dX = entity.posX - x;
- double dZ = entity.posZ - z;
- double newDistance = Math.sqrt(dX*dX + dZ*dZ);
-
- double delta = oldDistance - newDistance;
-
- if(newDistance < 0.2 || (delta > -0.1 && delta < 0.3)) {
- if((NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarning || NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarningR) &&
- Minecraft.getMinecraft().thePlayer.fishEntity != null &&
- Minecraft.getMinecraft().thePlayer.fishEntity.getEntityId() == hookEntityId &&
- chain.particleNum > 3) {
-
- if(newDistance <= 0.2f + 0.1f*pingDelayTicks && NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarningR) {
- if(NotEnoughUpdates.INSTANCE.config.fishing.incomingFishHookedSounds &&
- hookedWarningStateTicks <= 0) {
- float vol = NotEnoughUpdates.INSTANCE.config.fishing.incomingFishHookedSoundsVol/100f;
- if(vol > 0) {
- if(vol > 1) vol = 1;
- final float volF = vol;
-
- ISound sound = new PositionedSound(new ResourceLocation("note.pling")) {{
- volume = volF;
- pitch = 2f;
- repeat = false;
- repeatDelay = 0;
- attenuationType = ISound.AttenuationType.NONE;
- }};
-
- float oldLevel = Minecraft.getMinecraft().gameSettings.getSoundLevel(SoundCategory.RECORDS);
- Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.RECORDS, 1);
- Minecraft.getMinecraft().getSoundHandler().playSound(sound);
- Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.RECORDS, oldLevel);
- }
- }
-
- hookedWarningStateTicks = 12;
- } else if(newDistance >= 0.4f + 0.1f*pingDelayTicks && NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarning) {
- if(NotEnoughUpdates.INSTANCE.config.fishing.incomingFishIncSounds &&
- buildupSoundDelay <= 0) {
- float vol = NotEnoughUpdates.INSTANCE.config.fishing.incomingFishIncSoundsVol/100f;
- if(vol > 0) {
- if(vol > 1) vol = 1;
- final float volF = vol;
-
- ISound sound = new PositionedSound(new ResourceLocation("note.pling")) {{
- volume = volF;
- pitch = calculatePitchFromDistance((float)newDistance - (0.3f+0.1f*pingDelayTicks));
- repeat = false;
- repeatDelay = 0;
- attenuationType = ISound.AttenuationType.NONE;
- }};
-
- float oldLevel = Minecraft.getMinecraft().gameSettings.getSoundLevel(SoundCategory.RECORDS);
- Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.RECORDS, 1);
- Minecraft.getMinecraft().getSoundHandler().playSound(sound);
- Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.RECORDS, oldLevel);
- buildupSoundDelay = 4;
- }
- }
- }
- }
-
- chain.distances.put(hookEntityId, newDistance);
- newHooks.add(hookEntityId);
- }
- }
-
- }
- }
- if(newHooks.isEmpty()) {
- continue;
- }
-
- entry.getValue().retainAll(newHooks);
- chain.distances.keySet().retainAll(newHooks);
-
- for(int i : entry.getValue()) {
- EntityFishHook hook = hookEntities.get(i);
- if(hook != null && hook.angler == Minecraft.getMinecraft().thePlayer) {
- isMainPlayer = true;
- break;
- }
- }
-
- chain.lastUpdate = currentTime;
- chain.particleNum++;
- chain.currentAngle = updateAngle;
-
- foundChain = true;
- }
- }
-
-
- if(!foundChain) {
- possibleHooks1.removeAll(possibleHooks2);
- if(!possibleHooks1.isEmpty()) {
- for(int i : possibleHooks1) {
- EntityFishHook hook = hookEntities.get(i);
- if(hook != null && hook.angler == Minecraft.getMinecraft().thePlayer) {
- isMainPlayer = true;
- break;
- }
- }
-
- WakeChain chain = new WakeChain(currentTime, angle1, x, z);
- for(int hookEntityId : possibleHooks1) {
- EntityFishHook entity = hookEntities.get(hookEntityId);
-
- if(entity != null && !entity.isDead) {
- double dX = entity.posX - x;
- double dZ = entity.posZ - z;
- double newDistance = Math.sqrt(dX*dX + dZ*dZ);
- chain.distances.put(hookEntityId, newDistance);
- }
- }
- chains.put(chain, possibleHooks1);
- } else if(!possibleHooks2.isEmpty()) {
- for(int i : possibleHooks2) {
- EntityFishHook hook = hookEntities.get(i);
- if(hook != null && hook.angler == Minecraft.getMinecraft().thePlayer) {
- isMainPlayer = true;
- break;
- }
- }
-
- WakeChain chain = new WakeChain(currentTime, angle2, x, z);
- for(int hookEntityId : possibleHooks2) {
- EntityFishHook entity = hookEntities.get(hookEntityId);
-
- if(entity != null && !entity.isDead) {
- double dX = entity.posX - x;
- double dZ = entity.posZ - z;
- double newDistance = Math.sqrt(dX*dX + dZ*dZ);
- chain.distances.put(hookEntityId, newDistance);
- }
- }
- chains.put(chain, possibleHooks2);
- }
- }
-
- int particleTypeI;
- String particleCustomColour;
- if(isMainPlayer) {
- particleTypeI = NotEnoughUpdates.INSTANCE.config.fishing.yourParticleType;
- particleCustomColour = NotEnoughUpdates.INSTANCE.config.fishing.yourParticleColour;
- } else if(NotEnoughUpdates.INSTANCE.config.fishing.hideOtherPlayerAll) {
- return true;
- } else {
- particleTypeI = NotEnoughUpdates.INSTANCE.config.fishing.otherParticleType;
- particleCustomColour = NotEnoughUpdates.INSTANCE.config.fishing.otherParticleColour;
- }
-
- if(!NotEnoughUpdates.INSTANCE.config.fishing.enableCustomParticles) {
- return false;
- }
-
- int argb = SpecialColour.specialToChromaRGB(particleCustomColour);
-
- if(particleTypeI == 0) {
- return false;
- } else if(particleTypeI == 1) {
- return true;
- }
-
- if (Minecraft.getMinecraft() != null && Minecraft.getMinecraft().getRenderViewEntity() != null && Minecraft.getMinecraft().effectRenderer != null) {
- int i = Minecraft.getMinecraft().gameSettings.particleSetting;
-
- if (i == 1 && Minecraft.getMinecraft().theWorld.rand.nextInt(3) == 0) {
- return true;
- }
-
- if(i >= 2) {
- return true;
- }
-
- double xDist = Minecraft.getMinecraft().getRenderViewEntity().posX - x;
- double yDist = Minecraft.getMinecraft().getRenderViewEntity().posY - y;
- double zDist = Minecraft.getMinecraft().getRenderViewEntity().posZ - z;
- double distSq = xDist*xDist + yDist*yDist + zDist*zDist;
-
- if(distSq < 32*32) {
- boolean customColour = false;
- double yVel = 0;
-
- switch(particleTypeI) {
- case 2:
- particleType = EnumParticleTypes.FIREWORKS_SPARK;
- customColour = true;
- yVel = 0.05;
- break;
- case 3:
- particleType = EnumParticleTypes.SPELL_MOB;
- customColour = true;
- break;
- case 4:
- particleType = EnumParticleTypes.REDSTONE;
- customColour = true;
- break;
- case 5:
- particleType = EnumParticleTypes.FLAME;
- yVel = 0.015;
- break;
- case 6:
- particleType = EnumParticleTypes.CRIT;
- yVel = 0.05;
- break;
- case 7:
- particleType = EnumParticleTypes.CRIT_MAGIC;
- yVel = 0.05;
- break;
- }
-
- if(customColour && (((argb >> 24) & 0xFF) < 10)) {
- return true;
- }
-
- EntityFX fx = Minecraft.getMinecraft().effectRenderer.spawnEffectParticle(particleType.getParticleID(), x, y, z, 0, 0, 0);
-
- fx.motionX = Math.random() * 0.02 - 0.01;
- fx.motionY = yVel;
- fx.motionZ = Math.random() * 0.02 - 0.01;
-
- if(customColour) {
- float red = ((argb >> 16) & 0xFF) / 255f;
- float green = ((argb >> 8) & 0xFF) / 255f;
- float blue = (argb & 0xFF) / 255f;
- float alpha = ((argb >> 24) & 0xFF) / 255f;
- fx.setRBGColorF(red, green, blue);
- fx.setAlphaF(alpha);
- }
- }
- }
-
- return true;
- }
- }
-
- return false;
- }
-
+ private static final FishingHelper INSTANCE = new FishingHelper();
+
+ public static FishingHelper getInstance() {
+ return INSTANCE;
+ }
+
+ public static class WakeChain {
+ public int particleNum = 0;
+ public long lastUpdate;
+ public double currentAngle;
+ public double currentX;
+ public double currentZ;
+
+ public final HashMap<Integer, Double> distances = new HashMap<>();
+
+ public WakeChain(long lastUpdate, double currentAngle, double currentX, double currentZ) {
+ this.lastUpdate = lastUpdate;
+ this.currentAngle = currentAngle;
+ this.currentX = currentX;
+ this.currentZ = currentZ;
+ }
+ }
+
+ public enum PlayerWarningState {
+ NOTHING,
+ FISH_INCOMING,
+ FISH_HOOKED
+ }
+
+ public PlayerWarningState warningState = PlayerWarningState.NOTHING;
+ private int hookedWarningStateTicks = 0;
+
+ public final HashMap<Integer, EntityFishHook> hookEntities = new HashMap<>();
+ public final HashMap<WakeChain, List<Integer>> chains = new HashMap<>();
+
+ private long lastCastRodMillis = 0;
+ private int pingDelayTicks = 0;
+ private final List<Integer> pingDelayList = new ArrayList<>();
+ private int buildupSoundDelay = 0;
+
+ private static final ResourceLocation FISHING_WARNING_EXCLAM = new ResourceLocation(
+ "notenoughupdates:fishing_warning_exclam.png");
+
+ public void onRenderBobber(EntityFishHook hook) {
+ if (Minecraft.getMinecraft().thePlayer.fishEntity == hook && warningState != PlayerWarningState.NOTHING) {
+
+ if (!NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarning &&
+ warningState == PlayerWarningState.FISH_INCOMING)
+ return;
+ if (!NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarningR &&
+ warningState == PlayerWarningState.FISH_HOOKED)
+ return;
+
+ GlStateManager.disableCull();
+ GlStateManager.disableLighting();
+ GL11.glDepthFunc(GL11.GL_ALWAYS);
+ GlStateManager.scale(1, -1, 1);
+
+ float offset = warningState == PlayerWarningState.FISH_HOOKED ? 0.5f : 0f;
+
+ float centerOffset = 0.5f / 8f;
+ Minecraft.getMinecraft().getTextureManager().bindTexture(FISHING_WARNING_EXCLAM);
+ Utils.drawTexturedRect(
+ centerOffset - 4f / 8f,
+ -20 / 8f,
+ 1f,
+ 2f,
+ 0 + offset,
+ 0.5f + offset,
+ 0,
+ 1,
+ GL11.GL_NEAREST
+ );
+
+ GlStateManager.scale(1, -1, 1);
+ GL11.glDepthFunc(GL11.GL_LEQUAL);
+ GlStateManager.enableLighting();
+ GlStateManager.enableCull();
+ }
+ }
+
+ public void addEntity(int entityId, Entity entity) {
+ if (entity instanceof EntityFishHook) {
+ hookEntities.put(entityId, (EntityFishHook) entity);
+
+ if (((EntityFishHook) entity).angler == Minecraft.getMinecraft().thePlayer) {
+ long currentTime = System.currentTimeMillis();
+ long delay = currentTime - lastCastRodMillis;
+ if (delay > 0 && delay < 500) {
+ if (delay > 300) delay = 300;
+ pingDelayList.add(0, (int) delay);
+ }
+ }
+ }
+ }
+
+ public void removeEntity(int entityId) {
+ hookEntities.remove(entityId);
+ }
+
+ @SubscribeEvent
+ public void onWorldUnload(WorldEvent.Unload event) {
+ hookEntities.clear();
+ chains.clear();
+ }
+
+ @SubscribeEvent
+ public void onPlayerInteract(PlayerInteractEvent event) {
+ if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR &&
+ event.entityPlayer == Minecraft.getMinecraft().thePlayer) {
+
+ ItemStack heldItem = event.entityPlayer.getHeldItem();
+
+ if (heldItem != null && heldItem.getItem() == Items.fishing_rod) {
+ long currentTime = System.currentTimeMillis();
+ if (currentTime - lastCastRodMillis > 500) {
+ lastCastRodMillis = currentTime;
+ }
+ }
+ }
+ }
+
+ private int tickCounter = 0;
+
+ @SubscribeEvent
+ public void onTick(TickEvent.ClientTickEvent event) {
+ if (Minecraft.getMinecraft().thePlayer != null && event.phase == TickEvent.Phase.END) {
+ if (buildupSoundDelay > 0) buildupSoundDelay--;
+
+ if (NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarning ||
+ NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarningR) {
+ if (Minecraft.getMinecraft().thePlayer.fishEntity != null) {
+ if (!pingDelayList.isEmpty()) {
+ while (pingDelayList.size() > 5) pingDelayList.remove(pingDelayList.size() - 1);
+
+ int totalMS = 0;
+ for (int delay : pingDelayList) {
+ totalMS += delay;
+ }
+
+ int averageMS = totalMS / pingDelayList.size();
+ pingDelayTicks = (int) Math.floor(averageMS / 50f);
+ }
+ }
+
+ if (hookedWarningStateTicks > 0) {
+ hookedWarningStateTicks--;
+ warningState = PlayerWarningState.FISH_HOOKED;
+ } else {
+ warningState = PlayerWarningState.NOTHING;
+ if (Minecraft.getMinecraft().thePlayer.fishEntity != null) {
+ int fishEntityId = Minecraft.getMinecraft().thePlayer.fishEntity.getEntityId();
+ for (Map.Entry<WakeChain, List<Integer>> entry : chains.entrySet()) {
+ if (entry.getKey().particleNum >= 3 && entry.getValue().contains(fishEntityId)) {
+ warningState = PlayerWarningState.FISH_INCOMING;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ if (tickCounter++ >= 20) {
+ long currentTime = System.currentTimeMillis();
+ tickCounter = 0;
+
+ Set<Integer> toRemoveEnt = new HashSet<>();
+ for (Map.Entry<Integer, EntityFishHook> entry : hookEntities.entrySet()) {
+ if (entry.getValue().isDead) {
+ toRemoveEnt.add(entry.getKey());
+ }
+ }
+ hookEntities.keySet().removeAll(toRemoveEnt);
+
+ Set<WakeChain> toRemoveChain = new HashSet<>();
+ for (Map.Entry<WakeChain, List<Integer>> entry : chains.entrySet()) {
+ if (currentTime - entry.getKey().lastUpdate > 200 ||
+ entry.getValue().isEmpty() ||
+ Collections.disjoint(entry.getValue(), hookEntities.keySet())) {
+ toRemoveChain.add(entry.getKey());
+ }
+ }
+ chains.keySet().removeAll(toRemoveChain);
+ }
+ }
+ }
+
+ private double calculateAngleFromOffsets(double xOffset, double zOffset) {
+ double angleX = Math.toDegrees(Math.acos(xOffset / 0.04f));
+ double angleZ = Math.toDegrees(Math.asin(zOffset / 0.04f));
+
+ if (xOffset < 0) {
+ angleZ = 180 - angleZ;
+ }
+ if (zOffset < 0) {
+ angleX = 360 - angleX;
+ }
+
+ angleX %= 360;
+ angleZ %= 360;
+ if (angleX < 0) angleX += 360;
+ if (angleZ < 0) angleZ += 360;
+
+ double dist = angleX - angleZ;
+ if (dist < -180) dist += 360;
+ if (dist > 180) dist -= 360;
+
+ return angleZ + dist / 2;
+ }
+
+ private boolean checkAngleWithinRange(double angle1, double angle2, double range) {
+ double dist = Math.abs(angle1 - angle2);
+ if (dist > 180) dist = 360 - dist;
+
+ return dist <= range;
+ }
+
+ private enum HookPossibleRet {
+ NOT_POSSIBLE,
+ EITHER,
+ ANGLE1,
+ ANGLE2
+ }
+
+ private HookPossibleRet isHookPossible(
+ EntityFishHook hook,
+ double particleX,
+ double particleY,
+ double particleZ,
+ double angle1,
+ double angle2
+ ) {
+ double dY = particleY - hook.posY;
+ if (Math.abs(dY) > 0.5f) {
+ return HookPossibleRet.NOT_POSSIBLE;
+ }
+
+ double dX = particleX - hook.posX;
+ double dZ = particleZ - hook.posZ;
+ double dist = Math.sqrt(dX * dX + dZ * dZ);
+
+ if (dist < 0.2) {
+ return HookPossibleRet.EITHER;
+ } else {
+ float angleAllowance = (float) Math.toDegrees(Math.atan2(0.03125f, dist)) * 1.5f;
+ float angleHook = (float) Math.toDegrees(Math.atan2(dX, dZ));
+ angleHook %= 360;
+ if (angleHook < 0) angleHook += 360;
+
+ if (checkAngleWithinRange(angle1, angleHook, angleAllowance)) {
+ return HookPossibleRet.ANGLE1;
+ } else if (checkAngleWithinRange(angle2, angleHook, angleAllowance)) {
+ return HookPossibleRet.ANGLE2;
+ }
+ }
+ return HookPossibleRet.NOT_POSSIBLE;
+ }
+
+ public static EnumParticleTypes type = EnumParticleTypes.BARRIER;
+
+ private static final float ZERO_PITCH = 1.0f;
+ private static final float MAX_PITCH = 0.1f;
+ private static final float MAX_DISTANCE = 5f;
+
+ private float calculatePitchFromDistance(float d) {
+ if (d < 0.1f) d = 0.1f;
+ if (d > MAX_DISTANCE) d = MAX_DISTANCE;
+
+ return 1 / (d + (1 / (ZERO_PITCH - MAX_PITCH))) * (1 - d / MAX_DISTANCE) + MAX_PITCH;
+ }
+
+ public boolean onSpawnParticle(
+ EnumParticleTypes particleType,
+ double x,
+ double y,
+ double z,
+ double xOffset,
+ double yOffset,
+ double zOffset
+ ) {
+
+ if (!NotEnoughUpdates.INSTANCE.config.fishing.hideOtherPlayerAll &&
+ !NotEnoughUpdates.INSTANCE.config.fishing.enableCustomParticles &&
+ !NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarning &&
+ !NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarningR) {
+ return false;
+ }
+ if (hookEntities.isEmpty()) {
+ return false;
+ }
+
+ if ((particleType == EnumParticleTypes.WATER_WAKE || particleType == EnumParticleTypes.SMOKE_NORMAL) && Math.abs(
+ yOffset - 0.01f) < 0.001f) {
+ double angle1 = calculateAngleFromOffsets(xOffset, -zOffset);
+ double angle2 = calculateAngleFromOffsets(-xOffset, zOffset);
+
+ final List<Integer> possibleHooks1 = new ArrayList<>();
+ final List<Integer> possibleHooks2 = new ArrayList<>();
+
+ for (EntityFishHook hook : hookEntities.values()) {
+ if (hook.isDead) continue;
+ if (possibleHooks1.contains(hook.getEntityId())) continue;
+ if (possibleHooks2.contains(hook.getEntityId())) continue;
+
+ HookPossibleRet ret = isHookPossible(hook, x, y, z, angle1, angle2);
+ if (ret == HookPossibleRet.ANGLE1) {
+ possibleHooks1.add(hook.getEntityId());
+ } else if (ret == HookPossibleRet.ANGLE2) {
+ possibleHooks2.add(hook.getEntityId());
+ } else if (ret == HookPossibleRet.EITHER) {
+ possibleHooks1.add(hook.getEntityId());
+ possibleHooks2.add(hook.getEntityId());
+ }
+ }
+
+ if (!possibleHooks1.isEmpty() || !possibleHooks2.isEmpty()) {
+ long currentTime = System.currentTimeMillis();
+
+ boolean isMainPlayer = false;
+
+ boolean foundChain = false;
+ for (Map.Entry<WakeChain, List<Integer>> entry : chains.entrySet()) {
+ WakeChain chain = entry.getKey();
+
+ if (currentTime - chain.lastUpdate > 200) continue;
+
+ double updateAngle;
+ List<Integer> possibleHooks;
+ if (checkAngleWithinRange(chain.currentAngle, angle1, 16)) {
+ possibleHooks = possibleHooks1;
+ updateAngle = angle1;
+ } else if (checkAngleWithinRange(chain.currentAngle, angle2, 16)) {
+ possibleHooks = possibleHooks2;
+ updateAngle = angle2;
+ } else {
+ continue;
+ }
+
+ if (!Collections.disjoint(entry.getValue(), possibleHooks)) {
+ HashSet<Integer> newHooks = new HashSet<>();
+
+ for (int hookEntityId : possibleHooks) {
+ if (entry.getValue().contains(hookEntityId) && chain.distances.containsKey(hookEntityId)) {
+ EntityFishHook entity = hookEntities.get(hookEntityId);
+
+ if (entity != null && !entity.isDead) {
+ double oldDistance = chain.distances.get(hookEntityId);
+
+ double dX = entity.posX - x;
+ double dZ = entity.posZ - z;
+ double newDistance = Math.sqrt(dX * dX + dZ * dZ);
+
+ double delta = oldDistance - newDistance;
+
+ if (newDistance < 0.2 || (delta > -0.1 && delta < 0.3)) {
+ if ((NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarning ||
+ NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarningR) &&
+ Minecraft.getMinecraft().thePlayer.fishEntity != null &&
+ Minecraft.getMinecraft().thePlayer.fishEntity.getEntityId() == hookEntityId &&
+ chain.particleNum > 3) {
+ float lavaOffset = 0.1f;
+ if (particleType == EnumParticleTypes.SMOKE_NORMAL) {
+ lavaOffset = 0.03f;
+ } else if (particleType == EnumParticleTypes.WATER_WAKE) {
+ lavaOffset = 0.1f;
+ }
+ if (newDistance <= 0.2f + lavaOffset * pingDelayTicks &&
+ NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarningR) {
+ if (NotEnoughUpdates.INSTANCE.config.fishing.incomingFishHookedSounds &&
+ hookedWarningStateTicks <= 0) {
+ float vol = NotEnoughUpdates.INSTANCE.config.fishing.incomingFishHookedSoundsVol / 100f;
+ if (vol > 0) {
+ if (vol > 1) vol = 1;
+ final float volF = vol;
+
+ ISound sound = new PositionedSound(new ResourceLocation("note.pling")) {{
+ volume = volF;
+ pitch = 2f;
+ repeat = false;
+ repeatDelay = 0;
+ attenuationType = ISound.AttenuationType.NONE;
+ }};
+
+ float oldLevel = Minecraft.getMinecraft().gameSettings.getSoundLevel(SoundCategory.RECORDS);
+ Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.RECORDS, 1);
+ Minecraft.getMinecraft().getSoundHandler().playSound(sound);
+ Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.RECORDS, oldLevel);
+ }
+ }
+
+ hookedWarningStateTicks = 12;
+ } else if (newDistance >= 0.4f + 0.1f * pingDelayTicks &&
+ NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarning) {
+ if (NotEnoughUpdates.INSTANCE.config.fishing.incomingFishIncSounds &&
+ buildupSoundDelay <= 0) {
+ float vol = NotEnoughUpdates.INSTANCE.config.fishing.incomingFishIncSoundsVol / 100f;
+ if (vol > 0) {
+ if (vol > 1) vol = 1;
+ final float volF = vol;
+
+ ISound sound = new PositionedSound(new ResourceLocation("note.pling")) {{
+ volume = volF;
+ pitch = calculatePitchFromDistance((float) newDistance - (0.3f + 0.1f * pingDelayTicks));
+ repeat = false;
+ repeatDelay = 0;
+ attenuationType = ISound.AttenuationType.NONE;
+ }};
+
+ float oldLevel = Minecraft.getMinecraft().gameSettings.getSoundLevel(SoundCategory.RECORDS);
+ Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.RECORDS, 1);
+ Minecraft.getMinecraft().getSoundHandler().playSound(sound);
+ Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.RECORDS, oldLevel);
+ buildupSoundDelay = 4;
+ }
+ }
+ }
+ }
+
+ chain.distances.put(hookEntityId, newDistance);
+ newHooks.add(hookEntityId);
+ }
+ }
+
+ }
+ }
+ if (newHooks.isEmpty()) {
+ continue;
+ }
+
+ entry.getValue().retainAll(newHooks);
+ chain.distances.keySet().retainAll(newHooks);
+
+ for (int i : entry.getValue()) {
+ EntityFishHook hook = hookEntities.get(i);
+ if (hook != null && hook.angler == Minecraft.getMinecraft().thePlayer) {
+ isMainPlayer = true;
+ break;
+ }
+ }
+
+ chain.lastUpdate = currentTime;
+ chain.particleNum++;
+ chain.currentAngle = updateAngle;
+
+ foundChain = true;
+ }
+ }
+
+ if (!foundChain) {
+ possibleHooks1.removeAll(possibleHooks2);
+ if (!possibleHooks1.isEmpty()) {
+ for (int i : possibleHooks1) {
+ EntityFishHook hook = hookEntities.get(i);
+ if (hook != null && hook.angler == Minecraft.getMinecraft().thePlayer) {
+ isMainPlayer = true;
+ break;
+ }
+ }
+
+ WakeChain chain = new WakeChain(currentTime, angle1, x, z);
+ for (int hookEntityId : possibleHooks1) {
+ EntityFishHook entity = hookEntities.get(hookEntityId);
+
+ if (entity != null && !entity.isDead) {
+ double dX = entity.posX - x;
+ double dZ = entity.posZ - z;
+ double newDistance = Math.sqrt(dX * dX + dZ * dZ);
+ chain.distances.put(hookEntityId, newDistance);
+ }
+ }
+ chains.put(chain, possibleHooks1);
+ } else if (!possibleHooks2.isEmpty()) {
+ for (int i : possibleHooks2) {
+ EntityFishHook hook = hookEntities.get(i);
+ if (hook != null && hook.angler == Minecraft.getMinecraft().thePlayer) {
+ isMainPlayer = true;
+ break;
+ }
+ }
+
+ WakeChain chain = new WakeChain(currentTime, angle2, x, z);
+ for (int hookEntityId : possibleHooks2) {
+ EntityFishHook entity = hookEntities.get(hookEntityId);
+
+ if (entity != null && !entity.isDead) {
+ double dX = entity.posX - x;
+ double dZ = entity.posZ - z;
+ double newDistance = Math.sqrt(dX * dX + dZ * dZ);
+ chain.distances.put(hookEntityId, newDistance);
+ }
+ }
+ chains.put(chain, possibleHooks2);
+ }
+ }
+
+ int particleTypeI;
+ String particleCustomColour;
+ if (isMainPlayer) {
+ particleTypeI = NotEnoughUpdates.INSTANCE.config.fishing.yourParticleType;
+ particleCustomColour = NotEnoughUpdates.INSTANCE.config.fishing.yourParticleColour;
+ } else if (NotEnoughUpdates.INSTANCE.config.fishing.hideOtherPlayerAll) {
+ return true;
+ } else {
+ particleTypeI = NotEnoughUpdates.INSTANCE.config.fishing.otherParticleType;
+ particleCustomColour = NotEnoughUpdates.INSTANCE.config.fishing.otherParticleColour;
+ }
+
+ if (!NotEnoughUpdates.INSTANCE.config.fishing.enableCustomParticles) {
+ return false;
+ }
+
+ int argb = SpecialColour.specialToChromaRGB(particleCustomColour);
+
+ if (particleTypeI == 0) {
+ return false;
+ } else if (particleTypeI == 1) {
+ return true;
+ }
+
+ if (Minecraft.getMinecraft() != null && Minecraft.getMinecraft().getRenderViewEntity() != null &&
+ Minecraft.getMinecraft().effectRenderer != null) {
+ int i = Minecraft.getMinecraft().gameSettings.particleSetting;
+
+ if (i == 1 && Minecraft.getMinecraft().theWorld.rand.nextInt(3) == 0) {
+ return true;
+ }
+
+ if (i >= 2) {
+ return true;
+ }
+
+ double xDist = Minecraft.getMinecraft().getRenderViewEntity().posX - x;
+ double yDist = Minecraft.getMinecraft().getRenderViewEntity().posY - y;
+ double zDist = Minecraft.getMinecraft().getRenderViewEntity().posZ - z;
+ double distSq = xDist * xDist + yDist * yDist + zDist * zDist;
+
+ if (distSq < 32 * 32) {
+ boolean customColour = false;
+ double yVel = 0;
+
+ switch (particleTypeI) {
+ case 2:
+ particleType = EnumParticleTypes.FIREWORKS_SPARK;
+ customColour = true;
+ yVel = 0.05;
+ break;
+ case 3:
+ particleType = EnumParticleTypes.SPELL_MOB;
+ customColour = true;
+ break;
+ case 4:
+ particleType = EnumParticleTypes.REDSTONE;
+ customColour = true;
+ break;
+ case 5:
+ particleType = EnumParticleTypes.FLAME;
+ yVel = 0.015;
+ break;
+ case 6:
+ particleType = EnumParticleTypes.CRIT;
+ yVel = 0.05;
+ break;
+ case 7:
+ particleType = EnumParticleTypes.CRIT_MAGIC;
+ yVel = 0.05;
+ break;
+ }
+
+ if (customColour && (((argb >> 24) & 0xFF) < 10)) {
+ return true;
+ }
+
+ EntityFX fx = Minecraft.getMinecraft().effectRenderer.spawnEffectParticle(
+ particleType.getParticleID(),
+ x,
+ y,
+ z,
+ 0,
+ 0,
+ 0
+ );
+
+ fx.motionX = Math.random() * 0.02 - 0.01;
+ fx.motionY = yVel;
+ fx.motionZ = Math.random() * 0.02 - 0.01;
+
+ if (customColour) {
+ float red = ((argb >> 16) & 0xFF) / 255f;
+ float green = ((argb >> 8) & 0xFF) / 255f;
+ float blue = (argb & 0xFF) / 255f;
+ float alpha = ((argb >> 24) & 0xFF) / 255f;
+ fx.setRBGColorF(red, green, blue);
+ fx.setAlphaF(alpha);
+ }
+ }
+ }
+
+ return true;
+ }
+ }
+
+ return false;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java
index 7a37c0ce..96522d34 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java
@@ -11,201 +11,197 @@ import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
-import java.util.*;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class ItemCooldowns {
-
- private static Map<ItemStack, Float> durabilityOverrideMap = new HashMap<>();
- public static long pickaxeUseCooldownMillisRemaining = -1;
- private static long treecapitatorCooldownMillisRemaining = -1;
- private static long lastMillis = 0;
-
- public static long pickaxeCooldown = -1;
-
- public static TreeMap<Long, BlockPos> blocksClicked = new TreeMap<>();
-
- private static int tickCounter = 0;
-
- @SubscribeEvent
- public void tick(TickEvent.ClientTickEvent event) {
- if(event.phase == TickEvent.Phase.END && NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
- if(tickCounter++ >= 20*10) {
- tickCounter = 0;
- pickaxeCooldown = -1;
- }
-
- long currentTime = System.currentTimeMillis();
-
- Long key;
- while((key = blocksClicked.floorKey(currentTime - 1500)) != null) {
- blocksClicked.remove(key);
- }
-
- long millisDelta = currentTime - lastMillis;
- lastMillis = currentTime;
-
- durabilityOverrideMap.clear();
-
- if(pickaxeUseCooldownMillisRemaining >= 0) {
- pickaxeUseCooldownMillisRemaining -= millisDelta;
- }
- if(treecapitatorCooldownMillisRemaining >= 0) {
- treecapitatorCooldownMillisRemaining -= millisDelta;
- }
- }
- }
-
- @SubscribeEvent
- public void onWorldUnload(WorldEvent.Load event) {
- blocksClicked.clear();
- if(pickaxeCooldown > 0) pickaxeUseCooldownMillisRemaining = 60*1000;
- pickaxeCooldown = -1;
- }
-
- public static long getTreecapCooldownWithPet(){
- if (!NotEnoughUpdates.INSTANCE.config.itemOverlays.enableCooldownInItemDurability){
- return 0;
- }
-
- PetInfoOverlay.Pet pet = PetInfoOverlay.getCurrentPet();
- if (NotEnoughUpdates.INSTANCE.config.itemOverlays.enableMonkeyCheck && pet != null) {
- if (pet.petLevel != null &&
- pet.petType.equalsIgnoreCase("monkey") &&
- pet.rarity.equals(PetInfoOverlay.Rarity.LEGENDARY)
- ) {
- return 2000 - (int) (2000 * (0.005 * (int) pet.petLevel.level));
- }
- }
- return 2000;
- }
-
- public static void blockClicked(BlockPos pos) {
- long currentTime = System.currentTimeMillis();
- blocksClicked.put(currentTime, pos);
- }
-
- public static void processBlockChangePacket(S23PacketBlockChange packetIn) {
- BlockPos pos = packetIn.getBlockPosition();
-
- if(blocksClicked.containsValue(pos)) {
- IBlockState oldState = Minecraft.getMinecraft().theWorld.getBlockState(pos);
- if(oldState.getBlock() != packetIn.getBlockState().getBlock()) {
- onBlockMined(pos);
- }
- }
- }
-
- public static void onBlockMined(BlockPos pos) {
- ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem();
- String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held);
- if(internalname != null) {
- if(treecapitatorCooldownMillisRemaining < 0 &&
- (internalname.equals("TREECAPITATOR_AXE") || internalname.equals("JUNGLE_AXE"))) {
- treecapitatorCooldownMillisRemaining = getTreecapCooldownWithPet();
- }
- }
- }
-
- private static Pattern PICKAXE_ABILITY_REGEX = Pattern.compile("\\u00a7r\\u00a7aYou used your " +
- "\\u00a7r\\u00a7..+ \\u00a7r\\u00a7aPickaxe Ability!\\u00a7r");
-
- private static Pattern PICKAXE_COOLDOWN_LORE_REGEX = Pattern.compile("\\u00a78Cooldown: \\u00a7a(\\d+)s");
-
- private static boolean isPickaxe(String internalname) {
- if(internalname == null) return false;
-
- if(internalname.endsWith("_PICKAXE")) {
- return true;
- } else if(internalname.contains("_DRILL_")) {
- char lastChar = internalname.charAt(internalname.length()-1);
- if(lastChar >= '0' && lastChar <= '9') {
- return true;
- }
- } else if(internalname.equals("DIVAN_DRILL")){
- return true;
- } else if(internalname.equals("GEMSTONE_GAUNTLET")){
- return true;
- }
- return false;
- }
-
- private static void updatePickaxeCooldown() {
- if(pickaxeCooldown == -1 && NotEnoughUpdates.INSTANCE.config.itemOverlays.pickaxeAbility) {
- for(ItemStack stack : Minecraft.getMinecraft().thePlayer.inventory.mainInventory) {
- if(stack != null && stack.hasTagCompound()) {
- String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack);
- if(isPickaxe(internalname)) {
- for(String line : NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stack.getTagCompound())) {
- Matcher matcher = PICKAXE_COOLDOWN_LORE_REGEX.matcher(line);
- if(matcher.find()) {
- try {
- pickaxeCooldown = Integer.parseInt(matcher.group(1));
- return;
- } catch(Exception ignored) {}
- }
- }
- }
- }
- }
- pickaxeCooldown = 0;
- }
- }
-
-
- @SubscribeEvent
- public void onChatMessage(ClientChatReceivedEvent event) {
- if(pickaxeCooldown != 0 && PICKAXE_ABILITY_REGEX.matcher(event.message.getFormattedText()).matches() && NotEnoughUpdates.INSTANCE.config.itemOverlays.pickaxeAbility) {
- updatePickaxeCooldown();
- pickaxeUseCooldownMillisRemaining = pickaxeCooldown*1000;
- }
- }
-
- public static float getDurabilityOverride(ItemStack stack) {
- if(Minecraft.getMinecraft().theWorld == null) return -1;
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return -1;
-
- if(durabilityOverrideMap.containsKey(stack)) {
- return durabilityOverrideMap.get(stack);
- }
-
- String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack);
- if(internalname == null) {
- durabilityOverrideMap.put(stack, -1f);
- return -1;
- }
-
- if(isPickaxe(internalname)) {
- updatePickaxeCooldown();
-
- if(pickaxeUseCooldownMillisRemaining < 0) {
- durabilityOverrideMap.put(stack, -1f);
- return -1;
- }
-
- if(pickaxeUseCooldownMillisRemaining > pickaxeCooldown*1000) {
- return stack.getItemDamage();
- }
- float dura = (float)(pickaxeUseCooldownMillisRemaining/(pickaxeCooldown*1000.0));
- durabilityOverrideMap.put(stack, dura);
- return dura;
- } else if(internalname.equals("TREECAPITATOR_AXE") || internalname.equals("JUNGLE_AXE")) {
- if(treecapitatorCooldownMillisRemaining < 0) {
- durabilityOverrideMap.put(stack, -1f);
- return -1;
- }
-
- if(treecapitatorCooldownMillisRemaining > getTreecapCooldownWithPet()) {
- return stack.getItemDamage();
- }
- float dura = (treecapitatorCooldownMillisRemaining/(float)getTreecapCooldownWithPet());
- durabilityOverrideMap.put(stack, dura);
- return dura;
- }
-
- durabilityOverrideMap.put(stack, -1f);
- return -1;
- }
-
+ private static final Map<ItemStack, Float> durabilityOverrideMap = new HashMap<>();
+ public static long pickaxeUseCooldownMillisRemaining = -1;
+ private static long treecapitatorCooldownMillisRemaining = -1;
+ private static long lastMillis = 0;
+
+ public static long pickaxeCooldown = -1;
+
+ public static TreeMap<Long, BlockPos> blocksClicked = new TreeMap<>();
+
+ private static int tickCounter = 0;
+
+ @SubscribeEvent
+ public void tick(TickEvent.ClientTickEvent event) {
+ if (event.phase == TickEvent.Phase.END && NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
+ if (tickCounter++ >= 20 * 10) {
+ tickCounter = 0;
+ pickaxeCooldown = -1;
+ }
+
+ long currentTime = System.currentTimeMillis();
+
+ Long key;
+ while ((key = blocksClicked.floorKey(currentTime - 1500)) != null) {
+ blocksClicked.remove(key);
+ }
+
+ long millisDelta = currentTime - lastMillis;
+ lastMillis = currentTime;
+
+ durabilityOverrideMap.clear();
+
+ if (pickaxeUseCooldownMillisRemaining >= 0) {
+ pickaxeUseCooldownMillisRemaining -= millisDelta;
+ }
+ if (treecapitatorCooldownMillisRemaining >= 0) {
+ treecapitatorCooldownMillisRemaining -= millisDelta;
+ }
+ }
+ }
+
+ @SubscribeEvent
+ public void onWorldUnload(WorldEvent.Load event) {
+ blocksClicked.clear();
+ if (pickaxeCooldown > 0) pickaxeUseCooldownMillisRemaining = 60 * 1000;
+ pickaxeCooldown = -1;
+ }
+
+ public static long getTreecapCooldownWithPet() {
+ if (!NotEnoughUpdates.INSTANCE.config.itemOverlays.enableCooldownInItemDurability) {
+ return 0;
+ }
+
+ PetInfoOverlay.Pet pet = PetInfoOverlay.getCurrentPet();
+ if (NotEnoughUpdates.INSTANCE.config.itemOverlays.enableMonkeyCheck && pet != null) {
+ if (pet.petLevel != null &&
+ pet.petType.equalsIgnoreCase("monkey") &&
+ pet.rarity.equals(PetInfoOverlay.Rarity.LEGENDARY)
+ ) {
+ return 2000 - (int) (2000 * (0.005 * (int) pet.petLevel.level));
+ }
+ }
+ return 2000;
+ }
+
+ public static void blockClicked(BlockPos pos) {
+ long currentTime = System.currentTimeMillis();
+ blocksClicked.put(currentTime, pos);
+ }
+
+ public static void processBlockChangePacket(S23PacketBlockChange packetIn) {
+ BlockPos pos = packetIn.getBlockPosition();
+
+ if (blocksClicked.containsValue(pos)) {
+ IBlockState oldState = Minecraft.getMinecraft().theWorld.getBlockState(pos);
+ if (oldState.getBlock() != packetIn.getBlockState().getBlock()) {
+ onBlockMined(pos);
+ }
+ }
+ }
+
+ public static void onBlockMined(BlockPos pos) {
+ ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem();
+ String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held);
+ if (internalname != null) {
+ if (treecapitatorCooldownMillisRemaining < 0 &&
+ (internalname.equals("TREECAPITATOR_AXE") || internalname.equals("JUNGLE_AXE"))) {
+ treecapitatorCooldownMillisRemaining = getTreecapCooldownWithPet();
+ }
+ }
+ }
+
+ private static final Pattern PICKAXE_ABILITY_REGEX = Pattern.compile("\\u00a7r\\u00a7aYou used your " +
+ "\\u00a7r\\u00a7..+ \\u00a7r\\u00a7aPickaxe Ability!\\u00a7r");
+
+ private static final Pattern PICKAXE_COOLDOWN_LORE_REGEX = Pattern.compile("\\u00a78Cooldown: \\u00a7a(\\d+)s");
+
+ private static boolean isPickaxe(String internalname) {
+ if (internalname == null) return false;
+
+ if (internalname.endsWith("_PICKAXE")) {
+ return true;
+ } else if (internalname.contains("_DRILL_")) {
+ char lastChar = internalname.charAt(internalname.length() - 1);
+ return lastChar >= '0' && lastChar <= '9';
+ } else if (internalname.equals("DIVAN_DRILL")) {
+ return true;
+ } else return internalname.equals("GEMSTONE_GAUNTLET");
+ }
+
+ private static void updatePickaxeCooldown() {
+ if (pickaxeCooldown == -1 && NotEnoughUpdates.INSTANCE.config.itemOverlays.pickaxeAbility) {
+ for (ItemStack stack : Minecraft.getMinecraft().thePlayer.inventory.mainInventory) {
+ if (stack != null && stack.hasTagCompound()) {
+ String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack);
+ if (isPickaxe(internalname)) {
+ for (String line : NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stack.getTagCompound())) {
+ Matcher matcher = PICKAXE_COOLDOWN_LORE_REGEX.matcher(line);
+ if (matcher.find()) {
+ try {
+ pickaxeCooldown = Integer.parseInt(matcher.group(1));
+ return;
+ } catch (Exception ignored) {
+ }
+ }
+ }
+ }
+ }
+ }
+ pickaxeCooldown = 0;
+ }
+ }
+
+ @SubscribeEvent
+ public void onChatMessage(ClientChatReceivedEvent event) {
+ if (pickaxeCooldown != 0 && PICKAXE_ABILITY_REGEX.matcher(event.message.getFormattedText()).matches() &&
+ NotEnoughUpdates.INSTANCE.config.itemOverlays.pickaxeAbility) {
+ updatePickaxeCooldown();
+ pickaxeUseCooldownMillisRemaining = pickaxeCooldown * 1000;
+ }
+ }
+
+ public static float getDurabilityOverride(ItemStack stack) {
+ if (Minecraft.getMinecraft().theWorld == null) return -1;
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return -1;
+
+ if (durabilityOverrideMap.containsKey(stack)) {
+ return durabilityOverrideMap.get(stack);
+ }
+
+ String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack);
+ if (internalname == null) {
+ durabilityOverrideMap.put(stack, -1f);
+ return -1;
+ }
+
+ if (isPickaxe(internalname)) {
+ updatePickaxeCooldown();
+
+ if (pickaxeUseCooldownMillisRemaining < 0) {
+ durabilityOverrideMap.put(stack, -1f);
+ return -1;
+ }
+
+ if (pickaxeUseCooldownMillisRemaining > pickaxeCooldown * 1000) {
+ return stack.getItemDamage();
+ }
+ float dura = (float) (pickaxeUseCooldownMillisRemaining / (pickaxeCooldown * 1000.0));
+ durabilityOverrideMap.put(stack, dura);
+ return dura;
+ } else if (internalname.equals("TREECAPITATOR_AXE") || internalname.equals("JUNGLE_AXE")) {
+ if (treecapitatorCooldownMillisRemaining < 0) {
+ durabilityOverrideMap.put(stack, -1f);
+ return -1;
+ }
+
+ if (treecapitatorCooldownMillisRemaining > getTreecapCooldownWithPet()) {
+ return stack.getItemDamage();
+ }
+ float dura = (treecapitatorCooldownMillisRemaining / (float) getTreecapCooldownWithPet());
+ durabilityOverrideMap.put(stack, dura);
+ return dura;
+ }
+
+ durabilityOverrideMap.put(stack, -1f);
+ return -1;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCustomizeManager.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCustomizeManager.java
index 7006df74..655364ef 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCustomizeManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCustomizeManager.java
@@ -24,256 +24,285 @@ import java.util.HashMap;
import java.util.function.Consumer;
public class ItemCustomizeManager {
+ public static class ReloadListener implements IResourceManagerReloadListener {
+ @Override
+ public void onResourceManagerReload(IResourceManager resourceManager) {
+ ItemCustomizeManager.loadedCustomGlintTexture = false;
+ }
+ }
- public static class ReloadListener implements IResourceManagerReloadListener {
- @Override
- public void onResourceManagerReload(IResourceManager resourceManager) {
- ItemCustomizeManager.loadedCustomGlintTexture = false;
- }
- }
+ public static boolean disableTextureBinding = false;
- public static boolean disableTextureBinding = false;
+ private static ResourceLocation CUSTOM_GLINT_TEXTURE = new ResourceLocation(
+ "notenoughupdates:dynamic/custom_glint_texture");
+ private static boolean loadedCustomGlintTexture = false;
- private static ResourceLocation CUSTOM_GLINT_TEXTURE = new ResourceLocation("notenoughupdates:dynamic/custom_glint_texture");
- private static boolean loadedCustomGlintTexture = false;
+ public static final String DEFAULT_GLINT_COLOR = ChromaColour.special(0, 0xcc, 0x6419FF);
+ //A050FF 0x8040cc 100,25,255 64,19
- public static final String DEFAULT_GLINT_COLOR = ChromaColour.special(0, 0xcc, 0x6419FF); //A050FF 0x8040cc 100,25,255 64,19
+ private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
+ private static ItemDataMap itemDataMap = new ItemDataMap();
+ private static final HashMap<Integer, String> itemUuidCache = new HashMap<>();
- private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
- private static ItemDataMap itemDataMap = new ItemDataMap();
- private static HashMap<Integer, String> itemUuidCache = new HashMap<>();
+ public static class ItemDataMap {
+ public HashMap<String, ItemData> itemData = new HashMap<>();
+ }
- public static class ItemDataMap {
- public HashMap<String, ItemData> itemData = new HashMap<>();
- }
+ public static class ItemData {
+ public String customName = null;
+ public String customNamePrefix = "";
+ public boolean overrideEnchantGlint = false;
+ public boolean enchantGlintValue;
- public static class ItemData {
- public String customName = null;
- public String customNamePrefix = "";
- public boolean overrideEnchantGlint = false;
- public boolean enchantGlintValue;
+ public String customGlintColour = DEFAULT_GLINT_COLOR;
- public String customGlintColour = DEFAULT_GLINT_COLOR;
+ public String customLeatherColour = null;
+ }
- public String customLeatherColour = null;
- }
+ public static void putItemData(String uuid, ItemData data) {
+ itemDataMap.itemData.put(uuid, data);
+ }
- public static void putItemData(String uuid, ItemData data) {
- itemDataMap.itemData.put(uuid, data);
- }
-
- public static void setCustomBlendFunc(String colour) {
+ public static void setCustomBlendFunc(String colour) {
/*int argb = ChromaColour.specialToChromaRGB(colour);
float[] hsv = Color.RGBtoHSB((argb >> 16) & 0xff, (argb >> 8) & 0xff, argb & 0xff, null);
GL14.glBlendColor(1, 1, 1, hsv[2]);*/
- GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_CONSTANT_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
- //GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE, GL11.GL_ONE);
- }
-
- private static void renderEffect(Consumer<Integer> renderModelCallback, int color) {
- GL11.glPushMatrix();
-
- GlStateManager.enableBlend();
- GlStateManager.depthMask(false);
- GlStateManager.depthFunc(GL11.GL_EQUAL);
- GlStateManager.disableLighting();
- Minecraft.getMinecraft().getTextureManager().bindTexture(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);
-
- GlStateManager.matrixMode(5890);
- GlStateManager.pushMatrix();
- GlStateManager.scale(8.0F, 8.0F, 8.0F);
- float f = (float)(Minecraft.getSystemTime() % 3000L) / 3000.0F / 8.0F;
- GlStateManager.translate(f, 0.0F, 0.0F);
- GlStateManager.rotate(-50.0F, 0.0F, 0.0F, 1.0F);
- renderModelCallback.accept(color);
- GlStateManager.matrixMode(5890);
- GlStateManager.popMatrix();
-
- GlStateManager.pushMatrix();
- GlStateManager.scale(8.0F, 8.0F, 8.0F);
- float f1 = (float)(Minecraft.getSystemTime() % 4873L) / 4873.0F / 8.0F;
- GlStateManager.translate(-f1, 0.0F, 0.0F);
- GlStateManager.rotate(10.0F, 0.0F, 0.0F, 1.0F);
- renderModelCallback.accept(color);
- GlStateManager.matrixMode(5890);
- GlStateManager.popMatrix();
-
- GlStateManager.matrixMode(5888);
- GlStateManager.blendFunc(770, 771);
- GlStateManager.enableLighting();
- GlStateManager.depthFunc(515);
- GlStateManager.depthMask(true);
- Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
-
- GL11.glPopMatrix();
- }
-
- private static void renderArmorGlint(Runnable renderModelCallback, float existed, int color) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(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);
- GlStateManager.enableBlend();
- GlStateManager.depthFunc(514);
- GlStateManager.depthMask(false);
- float f1 = 0.5F;
- GlStateManager.color(f1, f1, f1, 1.0F);
-
- for (int i = 0; i < 2; ++i)
- {
- GlStateManager.disableLighting();
-
- float red = ((color >> 16) & 0xFF) / 255f;
- float green = ((color >> 8) & 0xFF) / 255f;
- float blue = (color & 0xFF) / 255f;
- float alpha = ((color >> 24) & 0xFF) / 255f;
-
- GlStateManager.color(red, green, blue, alpha);
- GlStateManager.matrixMode(5890);
- GlStateManager.loadIdentity();
- float f3 = 0.33333334F;
- GlStateManager.scale(f3, f3, f3);
- GlStateManager.rotate(30.0F - (float)i * 60.0F, 0.0F, 0.0F, 1.0F);
- GlStateManager.translate(0.0F, existed * (0.001F + (float)i * 0.003F) * 20.0F, 0.0F);
- GlStateManager.matrixMode(5888);
- renderModelCallback.run();
- }
-
- GlStateManager.matrixMode(5890);
- GlStateManager.loadIdentity();
- GlStateManager.matrixMode(5888);
- GlStateManager.enableLighting();
- GlStateManager.depthMask(true);
- GlStateManager.depthFunc(515);
- GlStateManager.disableBlend();
- }
-
- public static void pre() {
- GlStateManager.matrixMode(GL11.GL_MODELVIEW);
- }
-
- public static boolean render3DGlint(String customEnchantGlint, float existed, Runnable renderModelCallback) {
- if(customEnchantGlint != null) {
- int colour = ChromaColour.specialToChromaRGB(customEnchantGlint);
-
- float[] hsv = Color.RGBtoHSB((colour >> 16) & 0xff, (colour >> 8) & 0xff, colour & 0xff, null);
- GL14.glBlendColor(1, 1, 1, hsv[2]);
-
- GlStateManager.tryBlendFuncSeparate(GL11.GL_ZERO, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ZERO, GL11.GL_ONE_MINUS_SRC_ALPHA);
- int alphaValue = (int)((1-hsv[2]*hsv[2])*0xff) * ((colour >> 24) & 0xff) / 0xff;
- renderArmorGlint(renderModelCallback, existed, alphaValue << 24);
- GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE, GL11.GL_ONE);
- renderArmorGlint(renderModelCallback, existed, colour);
-
- return true;
- }
- return false;
- }
-
- public static boolean renderEffectHook(String customEnchantGlint, Consumer<Integer> renderModelCallback) {
- if(customEnchantGlint != null) {
- int colour = ChromaColour.specialToChromaRGB(customEnchantGlint);
-
- float[] hsv = Color.RGBtoHSB((colour >> 16) & 0xff, (colour >> 8) & 0xff, colour & 0xff, null);
- GL14.glBlendColor(1, 1, 1, hsv[2]);
-
- GL11.glPushMatrix();
-
- GlStateManager.tryBlendFuncSeparate(GL11.GL_ZERO, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ZERO, GL11.GL_ONE_MINUS_SRC_ALPHA);
- int alphaValue = (int)((1-hsv[2]*hsv[2])*0xff) * ((colour >> 24) & 0xff) / 0xff;
- renderEffect(renderModelCallback, alphaValue << 24);
- GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE, GL11.GL_ONE);
- renderEffect(renderModelCallback, colour);
-
- GL11.glPopMatrix();
-
- return true;
- }
- return false;
- }
-
- public static ResourceLocation getCustomGlintTexture() {
- if(!loadedCustomGlintTexture) {
- loadedCustomGlintTexture = true;
-
- final ResourceLocation RES_ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png");
-
- try {
- BufferedImage originalGlint = ImageIO.read(Minecraft.getMinecraft().getResourceManager().getResource(RES_ITEM_GLINT).getInputStream());
- BufferedImage newGlint = new BufferedImage(originalGlint.getWidth(), originalGlint.getHeight(), BufferedImage.TYPE_INT_ARGB);
-
- for(int x=0; x<originalGlint.getWidth(); x++) {
- for(int y=0; y<originalGlint.getHeight(); y++) {
- int argb = originalGlint.getRGB(x, y);
-
- int avgRGB = ((((argb >> 16) & 0xff) + ((argb >> 8) & 0xff) + (argb & 0xff))/3) & 0xff;
-
- int newArgb = (avgRGB << 24) | (avgRGB << 16) | (avgRGB << 8) | avgRGB;
-
- newGlint.setRGB(x, y, newArgb);
- }
- }
-
- Minecraft.getMinecraft().getTextureManager().loadTexture(CUSTOM_GLINT_TEXTURE, new DynamicTexture(newGlint));
- } catch(Exception e) {
- e.printStackTrace();
- CUSTOM_GLINT_TEXTURE = RES_ITEM_GLINT;
- }
- }
- return CUSTOM_GLINT_TEXTURE;
- }
-
- private static String getUuidForItem(ItemStack stack) {
- if(!stack.hasTagCompound()) return null;
-
- int nbtHash = stack.getTagCompound().hashCode();
-
- if(itemUuidCache.containsKey(nbtHash)) {
- return itemUuidCache.get(nbtHash);
- }
-
- String uuid = NotEnoughUpdates.INSTANCE.manager.getUUIDForItem(stack);
-
- itemUuidCache.put(nbtHash, uuid);
- return uuid;
- }
-
- public static ItemData getDataForItem(ItemStack stack) {
- if(stack == null) return null;
-
- String uuid = getUuidForItem(stack);
-
- if(uuid == null) {
- return null;
- } else {
- return itemDataMap.itemData.get(uuid);
- }
- }
-
- public static void tick() {
- itemUuidCache.clear();
- disableTextureBinding = false;
- }
-
- public static void loadCustomization(File file) {
- try(BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) {
- itemDataMap = GSON.fromJson(reader, ItemDataMap.class);
- } catch(Exception ignored) {}
- if(itemDataMap == null) {
- itemDataMap = new ItemDataMap();
- }
- }
-
- public static void saveCustomization(File file) {
- try {
- file.createNewFile();
- try(BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8))) {
- writer.write(GSON.toJson(itemDataMap));
- }
- } catch(Exception ignored) {}
- }
-
+ GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_CONSTANT_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ //GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE, GL11.GL_ONE);
+ }
+
+ private static void renderEffect(Consumer<Integer> renderModelCallback, int color) {
+ GL11.glPushMatrix();
+
+ GlStateManager.enableBlend();
+ GlStateManager.depthMask(false);
+ GlStateManager.depthFunc(GL11.GL_EQUAL);
+ GlStateManager.disableLighting();
+ Minecraft.getMinecraft().getTextureManager().bindTexture(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);
+
+ GlStateManager.matrixMode(5890);
+ GlStateManager.pushMatrix();
+ GlStateManager.scale(8.0F, 8.0F, 8.0F);
+ float f = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F / 8.0F;
+ GlStateManager.translate(f, 0.0F, 0.0F);
+ GlStateManager.rotate(-50.0F, 0.0F, 0.0F, 1.0F);
+ renderModelCallback.accept(color);
+ GlStateManager.matrixMode(5890);
+ GlStateManager.popMatrix();
+
+ GlStateManager.pushMatrix();
+ GlStateManager.scale(8.0F, 8.0F, 8.0F);
+ float f1 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F / 8.0F;
+ GlStateManager.translate(-f1, 0.0F, 0.0F);
+ GlStateManager.rotate(10.0F, 0.0F, 0.0F, 1.0F);
+ renderModelCallback.accept(color);
+ GlStateManager.matrixMode(5890);
+ GlStateManager.popMatrix();
+
+ GlStateManager.matrixMode(5888);
+ GlStateManager.blendFunc(770, 771);
+ GlStateManager.enableLighting();
+ GlStateManager.depthFunc(515);
+ GlStateManager.depthMask(true);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
+
+ GL11.glPopMatrix();
+ }
+
+ private static void renderArmorGlint(Runnable renderModelCallback, float existed, int color) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(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);
+ GlStateManager.enableBlend();
+ GlStateManager.depthFunc(514);
+ GlStateManager.depthMask(false);
+ float f1 = 0.5F;
+ GlStateManager.color(f1, f1, f1, 1.0F);
+
+ for (int i = 0; i < 2; ++i) {
+ GlStateManager.disableLighting();
+
+ float red = ((color >> 16) & 0xFF) / 255f;
+ float green = ((color >> 8) & 0xFF) / 255f;
+ float blue = (color & 0xFF) / 255f;
+ float alpha = ((color >> 24) & 0xFF) / 255f;
+
+ GlStateManager.color(red, green, blue, alpha);
+ GlStateManager.matrixMode(5890);
+ GlStateManager.loadIdentity();
+ float f3 = 0.33333334F;
+ GlStateManager.scale(f3, f3, f3);
+ GlStateManager.rotate(30.0F - (float) i * 60.0F, 0.0F, 0.0F, 1.0F);
+ GlStateManager.translate(0.0F, existed * (0.001F + (float) i * 0.003F) * 20.0F, 0.0F);
+ GlStateManager.matrixMode(5888);
+ renderModelCallback.run();
+ }
+
+ GlStateManager.matrixMode(5890);
+ GlStateManager.loadIdentity();
+ GlStateManager.matrixMode(5888);
+ GlStateManager.enableLighting();
+ GlStateManager.depthMask(true);
+ GlStateManager.depthFunc(515);
+ GlStateManager.disableBlend();
+ }
+
+ public static void pre() {
+ GlStateManager.matrixMode(GL11.GL_MODELVIEW);
+ }
+
+ public static boolean render3DGlint(String customEnchantGlint, float existed, Runnable renderModelCallback) {
+ if (customEnchantGlint != null) {
+ int colour = ChromaColour.specialToChromaRGB(customEnchantGlint);
+
+ float[] hsv = Color.RGBtoHSB((colour >> 16) & 0xff, (colour >> 8) & 0xff, colour & 0xff, null);
+ GL14.glBlendColor(1, 1, 1, hsv[2]);
+
+ GlStateManager.tryBlendFuncSeparate(
+ GL11.GL_ZERO,
+ GL11.GL_ONE_MINUS_SRC_ALPHA,
+ GL11.GL_ZERO,
+ GL11.GL_ONE_MINUS_SRC_ALPHA
+ );
+ int alphaValue = (int) ((1 - hsv[2] * hsv[2]) * 0xff) * ((colour >> 24) & 0xff) / 0xff;
+ renderArmorGlint(renderModelCallback, existed, alphaValue << 24);
+ GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE, GL11.GL_ONE);
+ renderArmorGlint(renderModelCallback, existed, colour);
+
+ return true;
+ }
+ return false;
+ }
+
+ public static boolean renderEffectHook(String customEnchantGlint, Consumer<Integer> renderModelCallback) {
+ if (customEnchantGlint != null) {
+ int colour = ChromaColour.specialToChromaRGB(customEnchantGlint);
+
+ float[] hsv = Color.RGBtoHSB((colour >> 16) & 0xff, (colour >> 8) & 0xff, colour & 0xff, null);
+ GL14.glBlendColor(1, 1, 1, hsv[2]);
+
+ GL11.glPushMatrix();
+
+ GlStateManager.tryBlendFuncSeparate(
+ GL11.GL_ZERO,
+ GL11.GL_ONE_MINUS_SRC_ALPHA,
+ GL11.GL_ZERO,
+ GL11.GL_ONE_MINUS_SRC_ALPHA
+ );
+ int alphaValue = (int) ((1 - hsv[2] * hsv[2]) * 0xff) * ((colour >> 24) & 0xff) / 0xff;
+ renderEffect(renderModelCallback, alphaValue << 24);
+ GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE, GL11.GL_ONE);
+ renderEffect(renderModelCallback, colour);
+
+ GL11.glPopMatrix();
+
+ return true;
+ }
+ return false;
+ }
+
+ public static ResourceLocation getCustomGlintTexture() {
+ if (!loadedCustomGlintTexture) {
+ loadedCustomGlintTexture = true;
+
+ final ResourceLocation RES_ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png");
+
+ try {
+ BufferedImage originalGlint = ImageIO.read(Minecraft
+ .getMinecraft()
+ .getResourceManager()
+ .getResource(RES_ITEM_GLINT)
+ .getInputStream());
+ BufferedImage newGlint = new BufferedImage(
+ originalGlint.getWidth(),
+ originalGlint.getHeight(),
+ BufferedImage.TYPE_INT_ARGB
+ );
+
+ for (int x = 0; x < originalGlint.getWidth(); x++) {
+ for (int y = 0; y < originalGlint.getHeight(); y++) {
+ int argb = originalGlint.getRGB(x, y);
+
+ int avgRGB = ((((argb >> 16) & 0xff) + ((argb >> 8) & 0xff) + (argb & 0xff)) / 3) & 0xff;
+
+ int newArgb = (avgRGB << 24) | (avgRGB << 16) | (avgRGB << 8) | avgRGB;
+
+ newGlint.setRGB(x, y, newArgb);
+ }
+ }
+
+ Minecraft.getMinecraft().getTextureManager().loadTexture(CUSTOM_GLINT_TEXTURE, new DynamicTexture(newGlint));
+ } catch (Exception e) {
+ e.printStackTrace();
+ CUSTOM_GLINT_TEXTURE = RES_ITEM_GLINT;
+ }
+ }
+ return CUSTOM_GLINT_TEXTURE;
+ }
+
+ private static String getUuidForItem(ItemStack stack) {
+ if (!stack.hasTagCompound()) return null;
+
+ int nbtHash = stack.getTagCompound().hashCode();
+
+ if (itemUuidCache.containsKey(nbtHash)) {
+ return itemUuidCache.get(nbtHash);
+ }
+
+ String uuid = NotEnoughUpdates.INSTANCE.manager.getUUIDForItem(stack);
+
+ itemUuidCache.put(nbtHash, uuid);
+ return uuid;
+ }
+
+ public static ItemData getDataForItem(ItemStack stack) {
+ if (stack == null) return null;
+
+ String uuid = getUuidForItem(stack);
+
+ if (uuid == null) {
+ return null;
+ } else {
+ return itemDataMap.itemData.get(uuid);
+ }
+ }
+
+ public static void tick() {
+ itemUuidCache.clear();
+ disableTextureBinding = false;
+ }
+
+ public static void loadCustomization(File file) {
+ try (
+ BufferedReader reader = new BufferedReader(new InputStreamReader(
+ new FileInputStream(file),
+ StandardCharsets.UTF_8
+ ))
+ ) {
+ itemDataMap = GSON.fromJson(reader, ItemDataMap.class);
+ } catch (Exception ignored) {
+ }
+ if (itemDataMap == null) {
+ itemDataMap = new ItemDataMap();
+ }
+ }
+
+ public static void saveCustomization(File file) {
+ try {
+ file.createNewFile();
+ try (
+ BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
+ new FileOutputStream(file),
+ StandardCharsets.UTF_8
+ ))
+ ) {
+ writer.write(GSON.toJson(itemDataMap));
+ }
+ } catch (Exception ignored) {
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemRarityHalo.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemRarityHalo.java
index 244d6906..88c7261c 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemRarityHalo.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemRarityHalo.java
@@ -25,228 +25,292 @@ import java.nio.IntBuffer;
import java.util.HashMap;
public class ItemRarityHalo {
-
- public static Framebuffer itemFramebuffer1 = null;
- public static Framebuffer itemFramebuffer2 = null;
- public static HashMap<ItemStack, Integer> itemHaloTexMap = new HashMap<>();
- public static Matrix4f projectionMatrix = null;
-
- public static Shader colourShader = null;
- public static Shader blurShaderHorz = null;
- public static Shader blurShaderVert = null;
-
- private static int oldScaledResolution = 0;
-
- public static void onItemRender(ItemStack stack, int x, int y) {
- if(x == 0 && y == 0) return;
-
- if(!OpenGlHelper.isFramebufferEnabled() || !OpenGlHelper.areShadersSupported()) return;
- NotEnoughUpdates neu = NotEnoughUpdates.INSTANCE;
- if(!neu.isOnSkyblock()) return;
- //if(neu.manager.config.itemHighlightOpacity.value <= 1) return;
- if(neu.manager.getInternalNameForItem(stack) == null) return;
-
- ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
- int size = 16*scaledresolution.getScaleFactor();
-
- if(projectionMatrix == null) {
- projectionMatrix = Utils.createProjectionMatrix(size, size);
- }
-
- itemFramebuffer1 = checkFramebufferSizes(itemFramebuffer1, size, size);
- itemFramebuffer2 = checkFramebufferSizes(itemFramebuffer2, size, size);
-
- try {
- if(colourShader == null) {
- colourShader = new Shader(new NEUResourceManager(Minecraft.getMinecraft().getResourceManager()),
- "setrgbtoalpha", itemFramebuffer1, itemFramebuffer2);
- upload(colourShader, size, size);
- }
-
- if(blurShaderHorz == null) {
- blurShaderHorz = new Shader(new NEUResourceManager(Minecraft.getMinecraft().getResourceManager()),
- "blur", itemFramebuffer2, itemFramebuffer1);
- blurShaderHorz.getShaderManager().getShaderUniform("BlurDir").set(1, 0);
- blurShaderHorz.getShaderManager().getShaderUniform("Radius").set(5f);
- blurShaderHorz.getShaderManager().getShaderUniform("AlphaMult").set(2f);
- upload(blurShaderHorz, size, size);
- }
-
- if(blurShaderVert == null) {
- blurShaderVert = new Shader(new NEUResourceManager(Minecraft.getMinecraft().getResourceManager()),
- "blur", itemFramebuffer1, itemFramebuffer2);
- blurShaderVert.getShaderManager().getShaderUniform("BlurDir").set(0, 1);
- blurShaderVert.getShaderManager().getShaderUniform("Radius").set(5f);
- blurShaderVert.getShaderManager().getShaderUniform("AlphaMult").set(2f);
- upload(blurShaderVert, size, size);
- }
- } catch(Exception e) { return; }
-
- if(oldScaledResolution != scaledresolution.getScaleFactor()) {
- resetItemHaloCache();
- oldScaledResolution = scaledresolution.getScaleFactor();
- }
-
- int currentBuffer = GL11.glGetInteger(GL30.GL_FRAMEBUFFER_BINDING);
- IntBuffer currentViewport = BufferUtils.createIntBuffer(16);
- GL11.glGetInteger(GL11.GL_VIEWPORT, currentViewport);
- try {
- if(!itemHaloTexMap.containsKey(stack)) {
- int texture1 = TextureUtil.glGenTextures();
- int texture2 = TextureUtil.glGenTextures();
-
- GlStateManager.bindTexture(texture1);
- GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, size, size, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, ((ByteBuffer)null));
- itemFramebuffer1.bindFramebuffer(false);
- OpenGlHelper.glFramebufferTexture2D(OpenGlHelper.GL_FRAMEBUFFER, OpenGlHelper.GL_COLOR_ATTACHMENT0, 3553, texture1, 0);
-
- GlStateManager.bindTexture(texture2);
- GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, size, size, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, ((ByteBuffer)null));
- itemFramebuffer2.bindFramebuffer(false);
- OpenGlHelper.glFramebufferTexture2D(OpenGlHelper.GL_FRAMEBUFFER, OpenGlHelper.GL_COLOR_ATTACHMENT0, 3553, texture2, 0);
-
- itemFramebuffer1.framebufferClear();
- itemFramebuffer2.framebufferClear();
-
- GlStateManager.pushMatrix(); {
- GlStateManager.matrixMode(5889);
- GlStateManager.loadIdentity();
- GlStateManager.ortho(0.0D, size, size, 0.0D, 1000.0D, 3000.0D);
- GlStateManager.matrixMode(5888);
- GlStateManager.loadIdentity();
- GlStateManager.translate(0.0F, 0.0F, -2000.0F);
-
- GL11.glScalef(scaledresolution.getScaleFactor(), scaledresolution.getScaleFactor(), 1);
-
- itemFramebuffer1.bindFramebuffer(true);
-
- RenderItem itemRender = Minecraft.getMinecraft().getRenderItem();
- RenderHelper.enableGUIStandardItemLighting();
- float zLevel = itemRender.zLevel;
- itemRender.zLevel = -145; //Negates the z-offset of the below method.
- itemRender.renderItemAndEffectIntoGUI(stack, 0, 0);
- itemRender.zLevel = zLevel;
- RenderHelper.disableStandardItemLighting();
- } GlStateManager.popMatrix();
-
- GlStateManager.pushMatrix(); {
- GL45.glTextureBarrier(); GL11.glFlush(); GL11.glFinish();
- executeShader(colourShader);
- //GL45.glTextureBarrier(); GL11.glFlush(); GL11.glFinish();
- //executeShader(blurShaderHorz);
- //GL45.glTextureBarrier(); GL11.glFlush(); GL11.glFinish();
- //executeShader(blurShaderVert);
- //GL45.glTextureBarrier(); GL11.glFlush(); GL11.glFinish();
- } GlStateManager.popMatrix();
-
- GlStateManager.matrixMode(5889);
- GlStateManager.loadIdentity();
- GlStateManager.ortho(0.0D, scaledresolution.getScaledWidth_double(), scaledresolution.getScaledHeight_double(), 0.0D, 1000.0D, 3000.0D);
- GlStateManager.matrixMode(5888);
-
- OpenGlHelper.glBindFramebuffer(OpenGlHelper.GL_FRAMEBUFFER, currentBuffer);
- GlStateManager.viewport(currentViewport.get(), currentViewport.get(), currentViewport.get(), currentViewport.get());
-
- //TextureUtil.deleteTexture(texture1);
- itemHaloTexMap.put(stack, texture2);
- }
-
- OpenGlHelper.glBindFramebuffer(OpenGlHelper.GL_FRAMEBUFFER, currentBuffer);
- GlStateManager.viewport(currentViewport.get(), currentViewport.get(), currentViewport.get(), currentViewport.get());
-
- GlStateManager.bindTexture(itemHaloTexMap.get(stack));
- Color color = Utils.getPrimaryColour(stack.getDisplayName());
- //GlStateManager.color(color.getRed()/255f, color.getGreen()/255f, color.getBlue()/255f,
- // NotEnoughUpdates.INSTANCE.manager.config.itemHighlightOpacity.value.floatValue()/255f);
- Utils.drawTexturedRect(x, y, 16, 16,
- 0, 1, 1, 0, GL11.GL_NEAREST);
- GlStateManager.bindTexture(0);
- } catch(Exception e) {
- e.printStackTrace();
- OpenGlHelper.glBindFramebuffer(OpenGlHelper.GL_FRAMEBUFFER, currentBuffer);
- GlStateManager.viewport(currentViewport.get(), currentViewport.get(), currentViewport.get(), currentViewport.get());
- }
- }
-
- private static Framebuffer checkFramebufferSizes(Framebuffer framebuffer, int width, int height) {
- if(framebuffer == null || framebuffer.framebufferWidth != width || framebuffer.framebufferHeight != height) {
- if(framebuffer == null) {
- framebuffer = new Framebuffer(width, height, true);
- } else {
- framebuffer.createBindFramebuffer(width, height);
- }
- framebuffer.setFramebufferFilter(GL11.GL_NEAREST);
- }
- return framebuffer;
- }
-
- public static void resetItemHaloCache() {
- ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
- int size = 16*scaledresolution.getScaleFactor();
-
- for(int tex : itemHaloTexMap.values()) {
- TextureUtil.deleteTexture(tex);
- }
- itemHaloTexMap.clear();
-
- if(NotEnoughUpdates.INSTANCE.isOnSkyblock()) {
- projectionMatrix = Utils.createProjectionMatrix(size, size);
- upload(colourShader, size, size);
- upload(blurShaderHorz, size, size);
- upload(blurShaderVert, size, size);
- }
- }
-
- private static void upload(Shader shader, int width, int height) {
- if(shader == null) return;
- shader.getShaderManager().getShaderUniformOrDefault("ProjMat").set(projectionMatrix);
- shader.getShaderManager().getShaderUniformOrDefault("InSize").set(width, height);
- shader.getShaderManager().getShaderUniformOrDefault("OutSize").set(width, height);
- shader.getShaderManager().getShaderUniformOrDefault("ScreenSize").set((float)width, (float)height);
- }
-
- private static void executeShader(Shader shader) {
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
- GlStateManager.disableBlend();
- GlStateManager.disableDepth();
- GlStateManager.disableAlpha();
- GlStateManager.disableFog();
- GlStateManager.disableLighting();
- GlStateManager.disableColorMaterial();
- GlStateManager.enableTexture2D();
- GlStateManager.bindTexture(0);
-
- float f = (float)shader.framebufferOut.framebufferTextureWidth;
- float f1 = (float)shader.framebufferOut.framebufferTextureHeight;
- GlStateManager.viewport(0, 0, (int)f, (int)f1);
-
- shader.getShaderManager().useShader();
- shader.getShaderManager().addSamplerTexture("DiffuseSampler", shader.framebufferIn);
-
- shader.framebufferOut.framebufferClear();
- shader.framebufferOut.bindFramebuffer(false);
-
- GlStateManager.depthMask(false);
-
- GlStateManager.enableAlpha();
- GlStateManager.enableBlend();
- GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
-
- Tessellator tessellator = Tessellator.getInstance();
- WorldRenderer worldrenderer = tessellator.getWorldRenderer();
- worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
- worldrenderer.pos(0.0D, (double)f1, 500.0D).color(255, 255, 255, 255).endVertex();
- worldrenderer.pos((double)f, (double)f1, 500.0D).color(255, 255, 255, 255).endVertex();
- worldrenderer.pos((double)f, 0.0D, 500.0D).color(255, 255, 255, 255).endVertex();
- worldrenderer.pos(0.0D, 0.0D, 500.0D).color(255, 255, 255, 255).endVertex();
- tessellator.draw();
-
- GlStateManager.depthMask(true);
-
- shader.getShaderManager().endShader();
-
- shader.framebufferOut.unbindFramebuffer();
- shader.framebufferIn.unbindFramebufferTexture();
- }
-
+ public static Framebuffer itemFramebuffer1 = null;
+ public static Framebuffer itemFramebuffer2 = null;
+ public static HashMap<ItemStack, Integer> itemHaloTexMap = new HashMap<>();
+ public static Matrix4f projectionMatrix = null;
+
+ public static Shader colourShader = null;
+ public static Shader blurShaderHorz = null;
+ public static Shader blurShaderVert = null;
+
+ private static int oldScaledResolution = 0;
+
+ public static void onItemRender(ItemStack stack, int x, int y) {
+ if (x == 0 && y == 0) return;
+
+ if (!OpenGlHelper.isFramebufferEnabled() || !OpenGlHelper.areShadersSupported()) return;
+ NotEnoughUpdates neu = NotEnoughUpdates.INSTANCE;
+ if (!neu.isOnSkyblock()) return;
+ //if(neu.manager.config.itemHighlightOpacity.value <= 1) return;
+ if (neu.manager.getInternalNameForItem(stack) == null) return;
+
+ ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
+ int size = 16 * scaledresolution.getScaleFactor();
+
+ if (projectionMatrix == null) {
+ projectionMatrix = Utils.createProjectionMatrix(size, size);
+ }
+
+ itemFramebuffer1 = checkFramebufferSizes(itemFramebuffer1, size, size);
+ itemFramebuffer2 = checkFramebufferSizes(itemFramebuffer2, size, size);
+
+ try {
+ if (colourShader == null) {
+ colourShader = new Shader(new NEUResourceManager(Minecraft.getMinecraft().getResourceManager()),
+ "setrgbtoalpha", itemFramebuffer1, itemFramebuffer2
+ );
+ upload(colourShader, size, size);
+ }
+
+ if (blurShaderHorz == null) {
+ blurShaderHorz = new Shader(new NEUResourceManager(Minecraft.getMinecraft().getResourceManager()),
+ "blur", itemFramebuffer2, itemFramebuffer1
+ );
+ blurShaderHorz.getShaderManager().getShaderUniform("BlurDir").set(1, 0);
+ blurShaderHorz.getShaderManager().getShaderUniform("Radius").set(5f);
+ blurShaderHorz.getShaderManager().getShaderUniform("AlphaMult").set(2f);
+ upload(blurShaderHorz, size, size);
+ }
+
+ if (blurShaderVert == null) {
+ blurShaderVert = new Shader(new NEUResourceManager(Minecraft.getMinecraft().getResourceManager()),
+ "blur", itemFramebuffer1, itemFramebuffer2
+ );
+ blurShaderVert.getShaderManager().getShaderUniform("BlurDir").set(0, 1);
+ blurShaderVert.getShaderManager().getShaderUniform("Radius").set(5f);
+ blurShaderVert.getShaderManager().getShaderUniform("AlphaMult").set(2f);
+ upload(blurShaderVert, size, size);
+ }
+ } catch (Exception e) {
+ return;
+ }
+
+ if (oldScaledResolution != scaledresolution.getScaleFactor()) {
+ resetItemHaloCache();
+ oldScaledResolution = scaledresolution.getScaleFactor();
+ }
+
+ int currentBuffer = GL11.glGetInteger(GL30.GL_FRAMEBUFFER_BINDING);
+ IntBuffer currentViewport = BufferUtils.createIntBuffer(16);
+ GL11.glGetInteger(GL11.GL_VIEWPORT, currentViewport);
+ try {
+ if (!itemHaloTexMap.containsKey(stack)) {
+ int texture1 = TextureUtil.glGenTextures();
+ int texture2 = TextureUtil.glGenTextures();
+
+ GlStateManager.bindTexture(texture1);
+ GL11.glTexImage2D(
+ GL11.GL_TEXTURE_2D,
+ 0,
+ GL11.GL_RGBA8,
+ size,
+ size,
+ 0,
+ GL11.GL_RGBA,
+ GL11.GL_UNSIGNED_BYTE,
+ ((ByteBuffer) null)
+ );
+ itemFramebuffer1.bindFramebuffer(false);
+ OpenGlHelper.glFramebufferTexture2D(
+ OpenGlHelper.GL_FRAMEBUFFER,
+ OpenGlHelper.GL_COLOR_ATTACHMENT0,
+ 3553,
+ texture1,
+ 0
+ );
+
+ GlStateManager.bindTexture(texture2);
+ GL11.glTexImage2D(
+ GL11.GL_TEXTURE_2D,
+ 0,
+ GL11.GL_RGBA8,
+ size,
+ size,
+ 0,
+ GL11.GL_RGBA,
+ GL11.GL_UNSIGNED_BYTE,
+ ((ByteBuffer) null)
+ );
+ itemFramebuffer2.bindFramebuffer(false);
+ OpenGlHelper.glFramebufferTexture2D(
+ OpenGlHelper.GL_FRAMEBUFFER,
+ OpenGlHelper.GL_COLOR_ATTACHMENT0,
+ 3553,
+ texture2,
+ 0
+ );
+
+ itemFramebuffer1.framebufferClear();
+ itemFramebuffer2.framebufferClear();
+
+ GlStateManager.pushMatrix();
+ {
+ GlStateManager.matrixMode(5889);
+ GlStateManager.loadIdentity();
+ GlStateManager.ortho(0.0D, size, size, 0.0D, 1000.0D, 3000.0D);
+ GlStateManager.matrixMode(5888);
+ GlStateManager.loadIdentity();
+ GlStateManager.translate(0.0F, 0.0F, -2000.0F);
+
+ GL11.glScalef(scaledresolution.getScaleFactor(), scaledresolution.getScaleFactor(), 1);
+
+ itemFramebuffer1.bindFramebuffer(true);
+
+ RenderItem itemRender = Minecraft.getMinecraft().getRenderItem();
+ RenderHelper.enableGUIStandardItemLighting();
+ float zLevel = itemRender.zLevel;
+ itemRender.zLevel = -145; //Negates the z-offset of the below method.
+ itemRender.renderItemAndEffectIntoGUI(stack, 0, 0);
+ itemRender.zLevel = zLevel;
+ RenderHelper.disableStandardItemLighting();
+ }
+ GlStateManager.popMatrix();
+
+ GlStateManager.pushMatrix();
+ {
+ GL45.glTextureBarrier();
+ GL11.glFlush();
+ GL11.glFinish();
+ executeShader(colourShader);
+ //GL45.glTextureBarrier(); GL11.glFlush(); GL11.glFinish();
+ //executeShader(blurShaderHorz);
+ //GL45.glTextureBarrier(); GL11.glFlush(); GL11.glFinish();
+ //executeShader(blurShaderVert);
+ //GL45.glTextureBarrier(); GL11.glFlush(); GL11.glFinish();
+ }
+ GlStateManager.popMatrix();
+
+ GlStateManager.matrixMode(5889);
+ GlStateManager.loadIdentity();
+ GlStateManager.ortho(
+ 0.0D,
+ scaledresolution.getScaledWidth_double(),
+ scaledresolution.getScaledHeight_double(),
+ 0.0D,
+ 1000.0D,
+ 3000.0D
+ );
+ GlStateManager.matrixMode(5888);
+
+ OpenGlHelper.glBindFramebuffer(OpenGlHelper.GL_FRAMEBUFFER, currentBuffer);
+ GlStateManager.viewport(
+ currentViewport.get(),
+ currentViewport.get(),
+ currentViewport.get(),
+ currentViewport.get()
+ );
+
+ //TextureUtil.deleteTexture(texture1);
+ itemHaloTexMap.put(stack, texture2);
+ }
+
+ OpenGlHelper.glBindFramebuffer(OpenGlHelper.GL_FRAMEBUFFER, currentBuffer);
+ GlStateManager.viewport(
+ currentViewport.get(),
+ currentViewport.get(),
+ currentViewport.get(),
+ currentViewport.get()
+ );
+
+ GlStateManager.bindTexture(itemHaloTexMap.get(stack));
+ Color color = Utils.getPrimaryColour(stack.getDisplayName());
+ //GlStateManager.color(color.getRed()/255f, color.getGreen()/255f, color.getBlue()/255f,
+ // NotEnoughUpdates.INSTANCE.manager.config.itemHighlightOpacity.value.floatValue()/255f);
+ Utils.drawTexturedRect(x, y, 16, 16,
+ 0, 1, 1, 0, GL11.GL_NEAREST
+ );
+ GlStateManager.bindTexture(0);
+ } catch (Exception e) {
+ e.printStackTrace();
+ OpenGlHelper.glBindFramebuffer(OpenGlHelper.GL_FRAMEBUFFER, currentBuffer);
+ GlStateManager.viewport(
+ currentViewport.get(),
+ currentViewport.get(),
+ currentViewport.get(),
+ currentViewport.get()
+ );
+ }
+ }
+
+ private static Framebuffer checkFramebufferSizes(Framebuffer framebuffer, int width, int height) {
+ if (framebuffer == null || framebuffer.framebufferWidth != width || framebuffer.framebufferHeight != height) {
+ if (framebuffer == null) {
+ framebuffer = new Framebuffer(width, height, true);
+ } else {
+ framebuffer.createBindFramebuffer(width, height);
+ }
+ framebuffer.setFramebufferFilter(GL11.GL_NEAREST);
+ }
+ return framebuffer;
+ }
+
+ public static void resetItemHaloCache() {
+ ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
+ int size = 16 * scaledresolution.getScaleFactor();
+
+ for (int tex : itemHaloTexMap.values()) {
+ TextureUtil.deleteTexture(tex);
+ }
+ itemHaloTexMap.clear();
+
+ if (NotEnoughUpdates.INSTANCE.isOnSkyblock()) {
+ projectionMatrix = Utils.createProjectionMatrix(size, size);
+ upload(colourShader, size, size);
+ upload(blurShaderHorz, size, size);
+ upload(blurShaderVert, size, size);
+ }
+ }
+
+ private static void upload(Shader shader, int width, int height) {
+ if (shader == null) return;
+ shader.getShaderManager().getShaderUniformOrDefault("ProjMat").set(projectionMatrix);
+ shader.getShaderManager().getShaderUniformOrDefault("InSize").set(width, height);
+ shader.getShaderManager().getShaderUniformOrDefault("OutSize").set(width, height);
+ shader.getShaderManager().getShaderUniformOrDefault("ScreenSize").set((float) width, (float) height);
+ }
+
+ private static void executeShader(Shader shader) {
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ GlStateManager.disableBlend();
+ GlStateManager.disableDepth();
+ GlStateManager.disableAlpha();
+ GlStateManager.disableFog();
+ GlStateManager.disableLighting();
+ GlStateManager.disableColorMaterial();
+ GlStateManager.enableTexture2D();
+ GlStateManager.bindTexture(0);
+
+ float f = (float) shader.framebufferOut.framebufferTextureWidth;
+ float f1 = (float) shader.framebufferOut.framebufferTextureHeight;
+ GlStateManager.viewport(0, 0, (int) f, (int) f1);
+
+ shader.getShaderManager().useShader();
+ shader.getShaderManager().addSamplerTexture("DiffuseSampler", shader.framebufferIn);
+
+ shader.framebufferOut.framebufferClear();
+ shader.framebufferOut.bindFramebuffer(false);
+
+ GlStateManager.depthMask(false);
+
+ GlStateManager.enableAlpha();
+ GlStateManager.enableBlend();
+ GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
+
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+ worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
+ worldrenderer.pos(0.0D, f1, 500.0D).color(255, 255, 255, 255).endVertex();
+ worldrenderer.pos(f, f1, 500.0D).color(255, 255, 255, 255).endVertex();
+ worldrenderer.pos(f, 0.0D, 500.0D).color(255, 255, 255, 255).endVertex();
+ worldrenderer.pos(0.0D, 0.0D, 500.0D).color(255, 255, 255, 255).endVertex();
+ tessellator.draw();
+
+ GlStateManager.depthMask(true);
+
+ shader.getShaderManager().endShader();
+
+ shader.framebufferOut.unbindFramebuffer();
+ shader.framebufferIn.unbindFramebufferTexture();
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/MiningStuff.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/MiningStuff.java
index cfd97d3f..b56737e7 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/MiningStuff.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/MiningStuff.java
@@ -13,7 +13,6 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.Entity;
-import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.init.Blocks;
import net.minecraft.network.play.server.S23PacketBlockChange;
import net.minecraft.util.AxisAlignedBB;
@@ -27,177 +26,184 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import java.util.Map;
public class MiningStuff {
-
- private static BlockPos overlayLoc = null;
- private static long titaniumNotifMillis = 0;
- private static Minecraft mc;
-
-
- public MiningStuff(){
- mc = Minecraft.getMinecraft();
- }
-
- public static void processBlockChangePacket(S23PacketBlockChange packetIn) {
- if(!NotEnoughUpdates.INSTANCE.config.mining.titaniumAlert) {
- return;
- }
-
- IBlockState state = packetIn.getBlockState();
- if(SBInfo.getInstance().getLocation() != null &&
- SBInfo.getInstance().getLocation().startsWith("mining_") &&
- state.getBlock() == Blocks.stone && state.getValue(BlockStone.VARIANT) == BlockStone.EnumType.DIORITE_SMOOTH) {
-
-
- for(Map.Entry<String, Float> entry : MiningOverlay.commissionProgress.entrySet()) {
- String s = entry.getKey();
- if(s.contains("Titanium")) {
- if(entry.getValue() == 1f){
- return;
- }
- BlockPos pos = packetIn.getBlockPosition();
-
- IBlockState existingBlock = Minecraft.getMinecraft().theWorld.getBlockState(pos);
- if(existingBlock == null) return;
- if(existingBlock.getBlock() == Blocks.stone && existingBlock.getValue(BlockStone.VARIANT) == BlockStone.EnumType.DIORITE_SMOOTH) return;
- if(!checkIfAnyIsAir(getAttachedBlocks(pos)) && NotEnoughUpdates.INSTANCE.config.mining.titaniumAlertMustBeVisible) return;
- BlockPos player = Minecraft.getMinecraft().thePlayer.getPosition();
-
- double distSq = pos.distanceSq(player);
-
- if(distSq < 12*12) {
- titaniumNotifMillis = System.currentTimeMillis();
- }
- return;
- }
- }
- }
- }
-
- private static BlockPos[] getAttachedBlocks(BlockPos block){
- BlockPos[] blocks = new BlockPos[6];
- blocks[0] = new BlockPos(block.getX()-1, block.getY(), block.getZ());
- blocks[1] = new BlockPos(block.getX()+1, block.getY(), block.getZ());
- blocks[2] = new BlockPos(block.getX(), block.getY()-1, block.getZ());
- blocks[3] = new BlockPos(block.getX(), block.getY()+1, block.getZ());
- blocks[4] = new BlockPos(block.getX(), block.getY(), block.getZ()-1);
- blocks[5] = new BlockPos(block.getX(), block.getY(), block.getZ()+1);
- return blocks;
- }
-
- private static boolean checkIfAnyIsAir(BlockPos[] blocks){
- for (BlockPos block : blocks) {
- if(mc.theWorld.getBlockState(block).getBlock() instanceof BlockAir){
- return true;
- }
- }
- return false;
- }
-
- @SubscribeEvent
- public void onRenderOverlay(RenderGameOverlayEvent.Post event) {
- if(!NotEnoughUpdates.INSTANCE.config.mining.titaniumAlert) {
- return;
- }
- if(titaniumNotifMillis <= 0) return;
-
- int delta = (int)(System.currentTimeMillis() - titaniumNotifMillis);
- int notifLen = 5000;
- int fadeLen = 500;
- if(delta > 0 && delta < notifLen && event.type == RenderGameOverlayEvent.ElementType.ALL) {
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- int width = scaledResolution.getScaledWidth();
- int height = scaledResolution.getScaledHeight();
-
- GlStateManager.enableBlend();
- GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
-
- GlStateManager.pushMatrix();
- GlStateManager.translate((float)(width / 2), (float)(height / 2), 0.0F);
- GlStateManager.scale(4.0F, 4.0F, 4.0F);
-
- int colour1 = 0xcc;
- int colour2 = 0xff;
-
- double factor = (Math.sin(delta*2*Math.PI/1000)+1)/2;
- int colour = (int)(colour1*factor + colour2*(1-factor));
-
- int alpha = 255;
- if(delta < fadeLen) {
- alpha = delta*255/fadeLen;
- } else if(delta > notifLen-fadeLen) {
- alpha = (notifLen-delta)*255/fadeLen;
- }
-
- if(alpha > 10) {
- TextRenderUtils.drawStringCenteredScaledMaxWidth("Titanium has spawned nearby!", Minecraft.getMinecraft().fontRendererObj,
- 0, 0, true, width/4-20, colour | (colour << 8) | (colour << 16) | (alpha << 24));
- }
-
-
- GlStateManager.popMatrix();
- }
- }
-
- @SubscribeEvent
- public void renderWorldLast(RenderWorldLastEvent event) {
- if(overlayLoc == null) return;
-
- Entity viewer = Minecraft.getMinecraft().getRenderViewEntity();
- double viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * event.partialTicks;
- double viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * event.partialTicks;
- double viewerZ = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * event.partialTicks;
-
- AxisAlignedBB bb = new AxisAlignedBB(
- overlayLoc.getX()-viewerX,
- overlayLoc.getY()-viewerY,
- overlayLoc.getZ()-viewerZ,
- overlayLoc.getX()+1-viewerX,
- overlayLoc.getY()+1-viewerY,
- overlayLoc.getZ()+1-viewerZ).expand(0.01f, 0.01f, 0.01f);
-
- GlStateManager.disableCull();
- CustomItemEffects.drawFilledBoundingBox(bb, 1f, SpecialColour.special(0, 100, 0xff0000));
- GlStateManager.enableCull();
- GlStateManager.enableTexture2D();
- }
-
- @SubscribeEvent
- public void onLoadWorld(WorldEvent.Load event) {
- overlayLoc = null;
- }
-
- @SubscribeEvent
- public void onChatRecevied(ClientChatReceivedEvent event) {
- if(!NotEnoughUpdates.INSTANCE.config.mining.puzzlerSolver) {
- overlayLoc = null;
- return;
- }
-
- if(event.message.getFormattedText().startsWith("\u00A7e[NPC] \u00A7dPuzzler") &&
- event.message.getUnformattedText().contains(":")) {
- String clean = Utils.cleanColour(event.message.getUnformattedText());
- clean = clean.split(":")[1].trim();
-
- BlockPos pos = new BlockPos(181, 195, 135);
-
- for(int i=0; i<clean.length(); i++) {
- char c = clean.charAt(i);
-
- if(c == '\u25C0') { //Left
- pos = pos.add(1, 0, 0);
- } else if(c == '\u25B2') { //Up
- pos = pos.add(0, 0, 1);
- } else if(c == '\u25BC') { //Down
- pos = pos.add(0, 0, -1);
- } else if(c == '\u25B6') { //Right
- pos = pos.add(-1, 0, 0);
- } else {
- return;
- }
- }
-
- overlayLoc = pos;
- }
- }
-
+ private static BlockPos overlayLoc = null;
+ private static long titaniumNotifMillis = 0;
+ private static Minecraft mc;
+
+ public MiningStuff() {
+ mc = Minecraft.getMinecraft();
+ }
+
+ public static void processBlockChangePacket(S23PacketBlockChange packetIn) {
+ if (!NotEnoughUpdates.INSTANCE.config.mining.titaniumAlert) {
+ return;
+ }
+
+ IBlockState state = packetIn.getBlockState();
+ if (SBInfo.getInstance().getLocation() != null &&
+ SBInfo.getInstance().getLocation().startsWith("mining_") &&
+ state.getBlock() == Blocks.stone && state.getValue(BlockStone.VARIANT) == BlockStone.EnumType.DIORITE_SMOOTH) {
+
+ for (Map.Entry<String, Float> entry : MiningOverlay.commissionProgress.entrySet()) {
+ String s = entry.getKey();
+ if (s.contains("Titanium")) {
+ if (entry.getValue() == 1f) {
+ return;
+ }
+ BlockPos pos = packetIn.getBlockPosition();
+
+ IBlockState existingBlock = Minecraft.getMinecraft().theWorld.getBlockState(pos);
+ if (existingBlock == null) return;
+ if (existingBlock.getBlock() == Blocks.stone &&
+ existingBlock.getValue(BlockStone.VARIANT) == BlockStone.EnumType.DIORITE_SMOOTH)
+ return;
+ if (!checkIfAnyIsAir(getAttachedBlocks(pos)) &&
+ NotEnoughUpdates.INSTANCE.config.mining.titaniumAlertMustBeVisible)
+ return;
+ BlockPos player = Minecraft.getMinecraft().thePlayer.getPosition();
+
+ double distSq = pos.distanceSq(player);
+
+ if (distSq < 12 * 12) {
+ titaniumNotifMillis = System.currentTimeMillis();
+ }
+ return;
+ }
+ }
+ }
+ }
+
+ private static BlockPos[] getAttachedBlocks(BlockPos block) {
+ BlockPos[] blocks = new BlockPos[6];
+ blocks[0] = new BlockPos(block.getX() - 1, block.getY(), block.getZ());
+ blocks[1] = new BlockPos(block.getX() + 1, block.getY(), block.getZ());
+ blocks[2] = new BlockPos(block.getX(), block.getY() - 1, block.getZ());
+ blocks[3] = new BlockPos(block.getX(), block.getY() + 1, block.getZ());
+ blocks[4] = new BlockPos(block.getX(), block.getY(), block.getZ() - 1);
+ blocks[5] = new BlockPos(block.getX(), block.getY(), block.getZ() + 1);
+ return blocks;
+ }
+
+ private static boolean checkIfAnyIsAir(BlockPos[] blocks) {
+ for (BlockPos block : blocks) {
+ if (mc.theWorld.getBlockState(block).getBlock() instanceof BlockAir) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @SubscribeEvent
+ public void onRenderOverlay(RenderGameOverlayEvent.Post event) {
+ if (!NotEnoughUpdates.INSTANCE.config.mining.titaniumAlert) {
+ return;
+ }
+ if (titaniumNotifMillis <= 0) return;
+
+ int delta = (int) (System.currentTimeMillis() - titaniumNotifMillis);
+ int notifLen = 5000;
+ int fadeLen = 500;
+ if (delta > 0 && delta < notifLen && event.type == RenderGameOverlayEvent.ElementType.ALL) {
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ int width = scaledResolution.getScaledWidth();
+ int height = scaledResolution.getScaledHeight();
+
+ GlStateManager.enableBlend();
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+
+ GlStateManager.pushMatrix();
+ GlStateManager.translate((float) (width / 2), (float) (height / 2), 0.0F);
+ GlStateManager.scale(4.0F, 4.0F, 4.0F);
+
+ int colour1 = 0xcc;
+ int colour2 = 0xff;
+
+ double factor = (Math.sin(delta * 2 * Math.PI / 1000) + 1) / 2;
+ int colour = (int) (colour1 * factor + colour2 * (1 - factor));
+
+ int alpha = 255;
+ if (delta < fadeLen) {
+ alpha = delta * 255 / fadeLen;
+ } else if (delta > notifLen - fadeLen) {
+ alpha = (notifLen - delta) * 255 / fadeLen;
+ }
+
+ if (alpha > 10) {
+ TextRenderUtils.drawStringCenteredScaledMaxWidth(
+ "Titanium has spawned nearby!",
+ Minecraft.getMinecraft().fontRendererObj,
+ 0,
+ 0,
+ true,
+ width / 4 - 20,
+ colour | (colour << 8) | (colour << 16) | (alpha << 24)
+ );
+ }
+
+ GlStateManager.popMatrix();
+ }
+ }
+
+ @SubscribeEvent
+ public void renderWorldLast(RenderWorldLastEvent event) {
+ if (overlayLoc == null) return;
+
+ Entity viewer = Minecraft.getMinecraft().getRenderViewEntity();
+ double viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * event.partialTicks;
+ double viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * event.partialTicks;
+ double viewerZ = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * event.partialTicks;
+
+ AxisAlignedBB bb = new AxisAlignedBB(
+ overlayLoc.getX() - viewerX,
+ overlayLoc.getY() - viewerY,
+ overlayLoc.getZ() - viewerZ,
+ overlayLoc.getX() + 1 - viewerX,
+ overlayLoc.getY() + 1 - viewerY,
+ overlayLoc.getZ() + 1 - viewerZ
+ ).expand(0.01f, 0.01f, 0.01f);
+
+ GlStateManager.disableCull();
+ CustomItemEffects.drawFilledBoundingBox(bb, 1f, SpecialColour.special(0, 100, 0xff0000));
+ GlStateManager.enableCull();
+ GlStateManager.enableTexture2D();
+ }
+
+ @SubscribeEvent
+ public void onLoadWorld(WorldEvent.Load event) {
+ overlayLoc = null;
+ }
+
+ @SubscribeEvent
+ public void onChatReceived(ClientChatReceivedEvent event) {
+ if (!NotEnoughUpdates.INSTANCE.config.mining.puzzlerSolver) {
+ overlayLoc = null;
+ return;
+ }
+
+ if (event.message.getFormattedText().startsWith("\u00A7e[NPC] \u00A7dPuzzler") &&
+ event.message.getUnformattedText().contains(":")) {
+ String clean = Utils.cleanColour(event.message.getUnformattedText());
+ clean = clean.split(":")[1].trim();
+
+ BlockPos pos = new BlockPos(181, 195, 135);
+
+ for (int i = 0; i < clean.length(); i++) {
+ char c = clean.charAt(i);
+
+ if (c == '\u25C0') { //Left
+ pos = pos.add(1, 0, 0);
+ } else if (c == '\u25B2') { //Up
+ pos = pos.add(0, 0, 1);
+ } else if (c == '\u25BC') { //Down
+ pos = pos.add(0, 0, -1);
+ } else if (c == '\u25B6') { //Right
+ pos = pos.add(-1, 0, 0);
+ } else {
+ return;
+ }
+ }
+
+ overlayLoc = pos;
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/NPCRetexturing.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/NPCRetexturing.java
index a0b0cd64..05d75c26 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/NPCRetexturing.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/NPCRetexturing.java
@@ -4,12 +4,11 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.AbstractClientPlayer;
-import net.minecraft.client.renderer.block.model.ModelBlock;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.client.resources.IResourceManagerReloadListener;
-import net.minecraft.client.resources.model.ModelRotation;
import net.minecraft.util.ResourceLocation;
import java.io.BufferedReader;
@@ -19,80 +18,82 @@ import java.util.HashMap;
import java.util.Map;
public class NPCRetexturing implements IResourceManagerReloadListener {
+ private static final NPCRetexturing INSTANCE = new NPCRetexturing();
- private static final NPCRetexturing INSTANCE = new NPCRetexturing();
+ private static final ResourceLocation npcRetexturingJson = new ResourceLocation(
+ "notenoughupdates:npccustomtextures/config.json");
- private static final ResourceLocation npcRetexturingJson = new ResourceLocation("notenoughupdates:npccustomtextures/config.json");
+ private final Gson gson = new GsonBuilder().create();
- private final Gson gson = new GsonBuilder().create();
+ public static class Skin {
+ public ResourceLocation skinLocation;
+ public boolean skinny;
- public static class Skin {
- public ResourceLocation skinLocation;
- public boolean skinny;
+ public Skin(ResourceLocation skinLocation, boolean skinny) {
+ this.skinLocation = skinLocation;
+ this.skinny = skinny;
+ }
+ }
- public Skin(ResourceLocation skinLocation, boolean skinny) {
- this.skinLocation = skinLocation;
- this.skinny = skinny;
- }
- }
+ private final HashMap<AbstractClientPlayer, Skin> skinOverrideCache = new HashMap<>();
+ private final HashMap<String, Skin> skinMap = new HashMap<>();
- private HashMap<AbstractClientPlayer, Skin> skinOverrideCache = new HashMap<>();
- private HashMap<String, Skin> skinMap = new HashMap<>();
+ private boolean gettingSkin = false;
- private boolean gettingSkin = false;
+ public Skin getSkin(AbstractClientPlayer player) {
+ if (gettingSkin) return null;
- public Skin getSkin(AbstractClientPlayer player) {
- if(gettingSkin) return null;
+ if (player.getUniqueID().version() == 4 && !NotEnoughUpdates.INSTANCE.config.hidden.npcRetextureOnSelf) return null;
- if(player.getUniqueID().version() == 4) return null;
+ if (skinOverrideCache.containsKey(player)) {
+ return skinOverrideCache.get(player);
+ }
- if(skinOverrideCache.containsKey(player)) {
- return skinOverrideCache.get(player);
- }
+ gettingSkin = true;
+ ResourceLocation loc = player.getLocationSkin();
+ gettingSkin = false;
- gettingSkin = true;
- ResourceLocation loc = player.getLocationSkin();
- gettingSkin = false;
+ if (skinMap.containsKey(loc.getResourcePath()) && !NotEnoughUpdates.INSTANCE.config.misc.disableNPCRetexturing) {
+ Skin skin = skinMap.get(loc.getResourcePath());
+ skinOverrideCache.put(player, skin);
+ return skin;
+ }
- if(skinMap.containsKey(loc.getResourcePath())) {
- Skin skin = skinMap.get(loc.getResourcePath());
- skinOverrideCache.put(player, skin);
- return skin;
- }
+ skinOverrideCache.put(player, null);
+ return null;
+ }
- skinOverrideCache.put(player, null);
- return null;
- }
+ public void tick() {
+ skinOverrideCache.clear();
+ }
- public void tick() {
- skinOverrideCache.clear();
- }
+ @Override
+ public void onResourceManagerReload(IResourceManager resourceManager) {
+ skinMap.clear();
- @Override
- public void onResourceManagerReload(IResourceManager resourceManager) {
- skinMap.clear();
+ try (
+ BufferedReader reader = new BufferedReader(new InputStreamReader(
+ Minecraft.getMinecraft().getResourceManager().getResource(npcRetexturingJson).getInputStream(),
+ StandardCharsets.UTF_8
+ ))
+ ) {
+ JsonObject json = gson.fromJson(reader, JsonObject.class);
- try(BufferedReader reader = new BufferedReader(new InputStreamReader(
- Minecraft.getMinecraft().getResourceManager().getResource(npcRetexturingJson).getInputStream(), StandardCharsets.UTF_8))) {
- JsonObject json = gson.fromJson(reader, JsonObject.class);
+ if (json == null) return;
- if(json == null) return;
+ for (Map.Entry<String, JsonElement> entry : json.entrySet()) {
+ if (entry.getValue().isJsonObject()) {
+ JsonObject val = entry.getValue().getAsJsonObject();
- for(Map.Entry<String, JsonElement> entry : json.entrySet()) {
- if(entry.getValue().isJsonObject()) {
- JsonObject val = entry.getValue().getAsJsonObject();
-
- Skin skin = new Skin(new ResourceLocation(val.get("skin").getAsString()), val.get("skinny").getAsBoolean());
- skinMap.put("skins/"+entry.getKey(), skin);
- }
- }
- } catch(Exception e) {
- }
- }
-
-
- public static NPCRetexturing getInstance() {
- return INSTANCE;
- }
+ Skin skin = new Skin(new ResourceLocation(val.get("skin").getAsString()), val.get("skinny").getAsBoolean());
+ skinMap.put("skins/" + entry.getKey(), skin);
+ }
+ }
+ } catch (Exception ignored) {
+ }
+ }
+ public static NPCRetexturing getInstance() {
+ return INSTANCE;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/NullzeeSphere.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/NullzeeSphere.java
index 7e297c58..927111b3 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/NullzeeSphere.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/NullzeeSphere.java
@@ -23,212 +23,312 @@ import java.util.List;
import java.util.Set;
public class NullzeeSphere {
-
- public static boolean enabled = false;
- public static float size = 20;
- public static BlockPos centerPos = new BlockPos(0, 0, 0);
-
- public static ReverseWorldRenderer overlayVBO = null;
-
- public ReverseWorldRenderer getOverlayVBO() {
- if(overlayVBO != null) return overlayVBO;
-
- EntityPlayerSP p = Minecraft.getMinecraft().thePlayer;
- if(p == null) return null;
-
- //per vertex = 6
- //per size = 4
- //per block = 8
- //total per block = 196
-
- Set<BlockPos> circleOffsets = getCircleOffsets(size);
-
- ReverseWorldRenderer worldRenderer = new ReverseWorldRenderer(196*circleOffsets.size());
- worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
-
- String col = SpecialColour.special(0, 180, 0xffff9900);
- for(BlockPos offset : circleOffsets) {
- BlockPos overlayPos = new BlockPos(offset.getX(), offset.getY(), offset.getZ());
-
- AxisAlignedBB bb = new AxisAlignedBB(
- overlayPos.getX(),
- overlayPos.getY(),
- overlayPos.getZ(),
- overlayPos.getX()+1,
- overlayPos.getY()+1,
- overlayPos.getZ()+1
- ).expand(0.001f, 0.001f, 0.001f);
- uploadFilledBoundingBox(bb, 1f, col, worldRenderer);
- }
-
- overlayVBO = worldRenderer;
- return overlayVBO;
- }
-
- public Set<BlockPos> getCircleOffsets(float radius) {
- Set<BlockPos> circleOffsets = new HashSet<>();
-
- int radiusI = (int)Math.ceil(radius)+1;
- for(int x=-radiusI; x<=radiusI; x++) {
- for(int y=-radiusI; y<=radiusI; y++) {
- for(int z=-radiusI; z<=radiusI; z++) {
- float distSq = x*x + y*y + z*z;
- if(distSq >= (radius-0.5)*(radius-0.5) && distSq <= (radius+0.5)*(radius+0.5)) {
- circleOffsets.add(new BlockPos(x, y, z));
- }
- }
- }
- }
-
- return circleOffsets;
- }
-
- long lastUpdate = 0;
-
- private static double posLastUpdateX;
- private static double posLastUpdateY;
- private static double posLastUpdateZ;
-
- @SubscribeEvent
- public void onTick(TickEvent.ClientTickEvent event) {
- if(!enabled) return;
-
- EntityPlayerSP p = Minecraft.getMinecraft().thePlayer;
- if(p == null) return;
-
- if(event.phase == TickEvent.Phase.START) {
- double dX = p.posX - posLastUpdateX;
- double dY = p.posY - posLastUpdateY;
- double dZ = p.posZ - posLastUpdateZ;
-
- if(dX*dX + dY*dY + dZ*dZ < 1) {
- return;
- }
-
- posLastUpdateX = p.posX;
- posLastUpdateY = p.posY;
- posLastUpdateZ = p.posZ;
-
- long currentTime = System.currentTimeMillis();
- if(currentTime - lastUpdate < 250) {
- return;
- }
- lastUpdate = currentTime;
-
- ReverseWorldRenderer worldRenderer = getOverlayVBO();
- if(worldRenderer != null) {
- worldRenderer.setTranslation(0, 0,0 );
- worldRenderer.sortVertexData(
- (float)p.posX-centerPos.getX(),
- (float)p.posY-centerPos.getY(),
- (float)p.posZ-centerPos.getZ());
-
- }
- }
- }
-
- @SubscribeEvent
- public void onRenderLast(RenderWorldLastEvent event) {
- if(!enabled) return;
-
- Entity viewer = Minecraft.getMinecraft().getRenderViewEntity();
- double viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * event.partialTicks;
- double viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * event.partialTicks;
- double viewerZ = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * event.partialTicks;
-
- GlStateManager.enableBlend();
- GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
- GlStateManager.disableTexture2D();
-
- GlStateManager.translate(-viewerX, -viewerY, -viewerZ);
-
- GL11.glPolygonOffset(5, 5);
- ReverseWorldRenderer worldRenderer = getOverlayVBO();
- if(worldRenderer != null && worldRenderer.getVertexCount() > 0) {
- GlStateManager.translate(centerPos.getX(), centerPos.getY(), centerPos.getZ());
-
- VertexFormat vertexformat = worldRenderer.getVertexFormat();
- int stride = vertexformat.getNextOffset();
- ByteBuffer bytebuffer = worldRenderer.getByteBuffer();
- List<VertexFormatElement> list = vertexformat.getElements();
-
- for (int index = 0; index < list.size(); index++) {
- VertexFormatElement vertexformatelement = list.get(index);
- vertexformatelement.getUsage().preDraw(vertexformat, index, stride, bytebuffer);
- }
-
- GL11.glDrawArrays(worldRenderer.getDrawMode(), 0, worldRenderer.getVertexCount());
-
- for (int index = 0; index < list.size(); index++) {
- VertexFormatElement vertexformatelement = list.get(index);
- vertexformatelement.getUsage().postDraw(vertexformat, index, stride, bytebuffer);
- }
-
- GlStateManager.translate(-centerPos.getX(), -centerPos.getY(), -centerPos.getZ());
- }
- GL11.glPolygonOffset(0, 0);
-
- GlStateManager.translate(viewerX, viewerY, viewerZ);
-
- GlStateManager.enableTexture2D();
- }
-
- public static void uploadFilledBoundingBox(AxisAlignedBB p_181561_0_, float alpha, String special, ReverseWorldRenderer worldrenderer) {
- Color c = new Color(SpecialColour.specialToChromaRGB(special), true);
-
- //vertical
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.minZ)
- .color(c.getRed()/255f, c.getGreen()/255f, c.getBlue()/255f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.minZ)
- .color(c.getRed()/255f, c.getGreen()/255f, c.getBlue()/255f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.maxZ)
- .color(c.getRed()/255f, c.getGreen()/255f, c.getBlue()/255f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.maxZ)
- .color(c.getRed()/255f, c.getGreen()/255f, c.getBlue()/255f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.maxZ)
- .color(c.getRed()/255f, c.getGreen()/255f, c.getBlue()/255f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.maxZ)
- .color(c.getRed()/255f, c.getGreen()/255f, c.getBlue()/255f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.minZ)
- .color(c.getRed()/255f, c.getGreen()/255f, c.getBlue()/255f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.minZ)
- .color(c.getRed()/255f, c.getGreen()/255f, c.getBlue()/255f, c.getAlpha()/255f*alpha).endVertex();
-
- //x
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.maxZ)
- .color(c.getRed()/255f*0.8f, c.getGreen()/255f*0.8f, c.getBlue()/255f*0.8f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.maxZ)
- .color(c.getRed()/255f*0.8f, c.getGreen()/255f*0.8f, c.getBlue()/255f*0.8f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.minZ)
- .color(c.getRed()/255f*0.8f, c.getGreen()/255f*0.8f, c.getBlue()/255f*0.8f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.minZ)
- .color(c.getRed()/255f*0.8f, c.getGreen()/255f*0.8f, c.getBlue()/255f*0.8f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.minZ)
- .color(c.getRed()/255f*0.8f, c.getGreen()/255f*0.8f, c.getBlue()/255f*0.8f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.minZ)
- .color(c.getRed()/255f*0.8f, c.getGreen()/255f*0.8f, c.getBlue()/255f*0.8f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.maxZ)
- .color(c.getRed()/255f*0.8f, c.getGreen()/255f*0.8f, c.getBlue()/255f*0.8f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.maxZ)
- .color(c.getRed()/255f*0.8f, c.getGreen()/255f*0.8f, c.getBlue()/255f*0.8f, c.getAlpha()/255f*alpha).endVertex();
-
- //z
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.minZ)
- .color(c.getRed()/255f*0.9f, c.getGreen()/255f*0.9f, c.getBlue()/255f*0.9f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.minZ)
- .color(c.getRed()/255f*0.9f, c.getGreen()/255f*0.9f, c.getBlue()/255f*0.9f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.minZ)
- .color(c.getRed()/255f*0.9f, c.getGreen()/255f*0.9f, c.getBlue()/255f*0.9f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.minZ)
- .color(c.getRed()/255f*0.9f, c.getGreen()/255f*0.9f, c.getBlue()/255f*0.9f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.maxZ)
- .color(c.getRed()/255f*0.9f, c.getGreen()/255f*0.9f, c.getBlue()/255f*0.9f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.maxZ)
- .color(c.getRed()/255f*0.9f, c.getGreen()/255f*0.9f, c.getBlue()/255f*0.9f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.maxZ)
- .color(c.getRed()/255f*0.9f, c.getGreen()/255f*0.9f, c.getBlue()/255f*0.9f, c.getAlpha()/255f*alpha).endVertex();
- worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.maxZ)
- .color(c.getRed()/255f*0.9f, c.getGreen()/255f*0.9f, c.getBlue()/255f*0.9f, c.getAlpha()/255f*alpha).endVertex();
- }
-
+ public static boolean enabled = false;
+ public static float size = 20;
+ public static BlockPos centerPos = new BlockPos(0, 0, 0);
+
+ public static ReverseWorldRenderer overlayVBO = null;
+
+ public ReverseWorldRenderer getOverlayVBO() {
+ if (overlayVBO != null) return overlayVBO;
+
+ EntityPlayerSP p = Minecraft.getMinecraft().thePlayer;
+ if (p == null) return null;
+
+ //per vertex = 6
+ //per size = 4
+ //per block = 8
+ //total per block = 196
+
+ Set<BlockPos> circleOffsets = getCircleOffsets(size);
+
+ ReverseWorldRenderer worldRenderer = new ReverseWorldRenderer(196 * circleOffsets.size());
+ worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
+
+ String col = SpecialColour.special(0, 180, 0xffff9900);
+ for (BlockPos offset : circleOffsets) {
+ BlockPos overlayPos = new BlockPos(offset.getX(), offset.getY(), offset.getZ());
+
+ AxisAlignedBB bb = new AxisAlignedBB(
+ overlayPos.getX(),
+ overlayPos.getY(),
+ overlayPos.getZ(),
+ overlayPos.getX() + 1,
+ overlayPos.getY() + 1,
+ overlayPos.getZ() + 1
+ ).expand(0.001f, 0.001f, 0.001f);
+ uploadFilledBoundingBox(bb, 1f, col, worldRenderer);
+ }
+
+ overlayVBO = worldRenderer;
+ return overlayVBO;
+ }
+
+ public Set<BlockPos> getCircleOffsets(float radius) {
+ Set<BlockPos> circleOffsets = new HashSet<>();
+
+ int radiusI = (int) Math.ceil(radius) + 1;
+ for (int x = -radiusI; x <= radiusI; x++) {
+ for (int y = -radiusI; y <= radiusI; y++) {
+ for (int z = -radiusI; z <= radiusI; z++) {
+ float distSq = x * x + y * y + z * z;
+ if (distSq >= (radius - 0.5) * (radius - 0.5) && distSq <= (radius + 0.5) * (radius + 0.5)) {
+ circleOffsets.add(new BlockPos(x, y, z));
+ }
+ }
+ }
+ }
+
+ return circleOffsets;
+ }
+
+ long lastUpdate = 0;
+
+ private static double posLastUpdateX;
+ private static double posLastUpdateY;
+ private static double posLastUpdateZ;
+
+ @SubscribeEvent
+ public void onTick(TickEvent.ClientTickEvent event) {
+ if (!enabled) return;
+
+ EntityPlayerSP p = Minecraft.getMinecraft().thePlayer;
+ if (p == null) return;
+
+ if (event.phase == TickEvent.Phase.START) {
+ double dX = p.posX - posLastUpdateX;
+ double dY = p.posY - posLastUpdateY;
+ double dZ = p.posZ - posLastUpdateZ;
+
+ if (dX * dX + dY * dY + dZ * dZ < 1) {
+ return;
+ }
+
+ posLastUpdateX = p.posX;
+ posLastUpdateY = p.posY;
+ posLastUpdateZ = p.posZ;
+
+ long currentTime = System.currentTimeMillis();
+ if (currentTime - lastUpdate < 250) {
+ return;
+ }
+ lastUpdate = currentTime;
+
+ ReverseWorldRenderer worldRenderer = getOverlayVBO();
+ if (worldRenderer != null) {
+ worldRenderer.setTranslation(0, 0, 0);
+ worldRenderer.sortVertexData(
+ (float) p.posX - centerPos.getX(),
+ (float) p.posY - centerPos.getY(),
+ (float) p.posZ - centerPos.getZ()
+ );
+
+ }
+ }
+ }
+
+ @SubscribeEvent
+ public void onRenderLast(RenderWorldLastEvent event) {
+ if (!enabled) return;
+
+ Entity viewer = Minecraft.getMinecraft().getRenderViewEntity();
+ double viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * event.partialTicks;
+ double viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * event.partialTicks;
+ double viewerZ = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * event.partialTicks;
+
+ GlStateManager.enableBlend();
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+ GlStateManager.disableTexture2D();
+
+ GlStateManager.translate(-viewerX, -viewerY, -viewerZ);
+
+ GL11.glPolygonOffset(5, 5);
+ ReverseWorldRenderer worldRenderer = getOverlayVBO();
+ if (worldRenderer != null && worldRenderer.getVertexCount() > 0) {
+ GlStateManager.translate(centerPos.getX(), centerPos.getY(), centerPos.getZ());
+
+ VertexFormat vertexformat = worldRenderer.getVertexFormat();
+ int stride = vertexformat.getNextOffset();
+ ByteBuffer bytebuffer = worldRenderer.getByteBuffer();
+ List<VertexFormatElement> list = vertexformat.getElements();
+
+ for (int index = 0; index < list.size(); index++) {
+ VertexFormatElement vertexformatelement = list.get(index);
+ vertexformatelement.getUsage().preDraw(vertexformat, index, stride, bytebuffer);
+ }
+
+ GL11.glDrawArrays(worldRenderer.getDrawMode(), 0, worldRenderer.getVertexCount());
+
+ for (int index = 0; index < list.size(); index++) {
+ VertexFormatElement vertexformatelement = list.get(index);
+ vertexformatelement.getUsage().postDraw(vertexformat, index, stride, bytebuffer);
+ }
+
+ GlStateManager.translate(-centerPos.getX(), -centerPos.getY(), -centerPos.getZ());
+ }
+ GL11.glPolygonOffset(0, 0);
+
+ GlStateManager.translate(viewerX, viewerY, viewerZ);
+
+ GlStateManager.enableTexture2D();
+ }
+
+ public static void uploadFilledBoundingBox(
+ AxisAlignedBB p_181561_0_,
+ float alpha,
+ String special,
+ ReverseWorldRenderer worldrenderer
+ ) {
+ Color c = new Color(SpecialColour.specialToChromaRGB(special), true);
+
+ //vertical
+ worldrenderer
+ .pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.minZ)
+ .color(c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f, c.getAlpha() / 255f * alpha)
+ .endVertex();
+ worldrenderer
+ .pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.minZ)
+ .color(c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f, c.getAlpha() / 255f * alpha)
+ .endVertex();
+ worldrenderer
+ .pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.maxZ)
+ .color(c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f, c.getAlpha() / 255f * alpha)
+ .endVertex();
+ worldrenderer
+ .pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.maxZ)
+ .color(c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f, c.getAlpha() / 255f * alpha)
+ .endVertex();
+ worldrenderer
+ .pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.maxZ)
+ .color(c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f, c.getAlpha() / 255f * alpha)
+ .endVertex();
+ worldrenderer
+ .pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.maxZ)
+ .color(c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f, c.getAlpha() / 255f * alpha)
+ .endVertex();
+ worldrenderer
+ .pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.minZ)
+ .color(c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f, c.getAlpha() / 255f * alpha)
+ .endVertex();
+ worldrenderer
+ .pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.minZ)
+ .color(c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f, c.getAlpha() / 255f * alpha)
+ .endVertex();
+
+ //x
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.maxZ)
+ .color(
+ c.getRed() / 255f * 0.8f,
+ c.getGreen() / 255f * 0.8f,
+ c.getBlue() / 255f * 0.8f,
+ c.getAlpha() / 255f * alpha
+ ).endVertex();
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.maxZ)
+ .color(
+ c.getRed() / 255f * 0.8f,
+ c.getGreen() / 255f * 0.8f,
+ c.getBlue() / 255f * 0.8f,
+ c.getAlpha() / 255f * alpha
+ ).endVertex();
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.minZ)
+ .color(
+ c.getRed() / 255f * 0.8f,
+ c.getGreen() / 255f * 0.8f,
+ c.getBlue() / 255f * 0.8f,
+ c.getAlpha() / 255f * alpha
+ ).endVertex();
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.minZ)
+ .color(
+ c.getRed() / 255f * 0.8f,
+ c.getGreen() / 255f * 0.8f,
+ c.getBlue() / 255f * 0.8f,
+ c.getAlpha() / 255f * alpha
+ ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.minZ)
+ .color(
+ c.getRed() / 255f * 0.8f,
+ c.getGreen() / 255f * 0.8f,
+ c.getBlue() / 255f * 0.8f,
+ c.getAlpha() / 255f * alpha
+ ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.minZ)
+ .color(
+ c.getRed() / 255f * 0.8f,
+ c.getGreen() / 255f * 0.8f,
+ c.getBlue() / 255f * 0.8f,
+ c.getAlpha() / 255f * alpha
+ ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.maxZ)
+ .color(
+ c.getRed() / 255f * 0.8f,
+ c.getGreen() / 255f * 0.8f,
+ c.getBlue() / 255f * 0.8f,
+ c.getAlpha() / 255f * alpha
+ ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.maxZ)
+ .color(
+ c.getRed() / 255f * 0.8f,
+ c.getGreen() / 255f * 0.8f,
+ c.getBlue() / 255f * 0.8f,
+ c.getAlpha() / 255f * alpha
+ ).endVertex();
+
+ //z
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.minZ)
+ .color(
+ c.getRed() / 255f * 0.9f,
+ c.getGreen() / 255f * 0.9f,
+ c.getBlue() / 255f * 0.9f,
+ c.getAlpha() / 255f * alpha
+ ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.minZ)
+ .color(
+ c.getRed() / 255f * 0.9f,
+ c.getGreen() / 255f * 0.9f,
+ c.getBlue() / 255f * 0.9f,
+ c.getAlpha() / 255f * alpha
+ ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.minZ)
+ .color(
+ c.getRed() / 255f * 0.9f,
+ c.getGreen() / 255f * 0.9f,
+ c.getBlue() / 255f * 0.9f,
+ c.getAlpha() / 255f * alpha
+ ).endVertex();
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.minZ)
+ .color(
+ c.getRed() / 255f * 0.9f,
+ c.getGreen() / 255f * 0.9f,
+ c.getBlue() / 255f * 0.9f,
+ c.getAlpha() / 255f * alpha
+ ).endVertex();
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.maxZ)
+ .color(
+ c.getRed() / 255f * 0.9f,
+ c.getGreen() / 255f * 0.9f,
+ c.getBlue() / 255f * 0.9f,
+ c.getAlpha() / 255f * alpha
+ ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.maxZ)
+ .color(
+ c.getRed() / 255f * 0.9f,
+ c.getGreen() / 255f * 0.9f,
+ c.getBlue() / 255f * 0.9f,
+ c.getAlpha() / 255f * alpha
+ ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.maxZ)
+ .color(
+ c.getRed() / 255f * 0.9f,
+ c.getGreen() / 255f * 0.9f,
+ c.getBlue() / 255f * 0.9f,
+ c.getAlpha() / 255f * alpha
+ ).endVertex();
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.maxZ)
+ .color(
+ c.getRed() / 255f * 0.9f,
+ c.getGreen() / 255f * 0.9f,
+ c.getBlue() / 255f * 0.9f,
+ c.getAlpha() / 255f * alpha
+ ).endVertex();
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java
index 29926628..cb2b7031 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java
@@ -3,6 +3,7 @@ package io.github.moulberry.notenoughupdates.miscfeatures;
import com.google.common.collect.Lists;
import com.google.gson.*;
import io.github.moulberry.notenoughupdates.NEUEventListener;
+import io.github.moulberry.notenoughupdates.NEUOverlay;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.core.config.Position;
import io.github.moulberry.notenoughupdates.core.util.lerp.LerpUtils;
@@ -31,7 +32,6 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import org.apache.commons.lang3.text.WordUtils;
-import org.lwjgl.input.Keyboard;
import org.lwjgl.util.vector.Vector2f;
import java.io.*;
@@ -45,237 +45,263 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class PetInfoOverlay extends TextOverlay {
-
- private static final Pattern XP_BOOST_PATTERN = Pattern.compile("PET_ITEM_(COMBAT|FISHING|MINING|FORAGING|ALL|FARMING)_(SKILL|SKILLS)_BOOST_(COMMON|UNCOMMON|RARE|EPIC)");
- private static final Pattern PET_CONTAINER_PAGE = Pattern.compile("\\((\\d)/(\\d)\\) Pets");
- private static final Pattern PET_NAME_PATTERN = Pattern.compile("\u00a77\\[Lvl \\d+] \u00a7(.+)");
- private static final Pattern XP_LINE_PATTERN = Pattern.compile("-------------------- (\\d+(?:,\\d+)*(?:\\.\\d+)?)/(\\d+(?:\\.\\d+)?[B|M|k]?)");
-
- private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
-
- public PetInfoOverlay(Position position, Supplier<List<String>> dummyStrings, Supplier<TextOverlayStyle> styleSupplier) {
- super(position, dummyStrings, styleSupplier);
- }
-
- public enum Rarity {
- COMMON(0, 0, 1, EnumChatFormatting.WHITE),
- UNCOMMON(6, 1, 2, EnumChatFormatting.GREEN),
- RARE(11, 2, 3, EnumChatFormatting.BLUE),
- EPIC(16, 3, 4, EnumChatFormatting.DARK_PURPLE),
- LEGENDARY(20, 4, 5, EnumChatFormatting.GOLD),
- MYTHIC(20, 4, 5, EnumChatFormatting.LIGHT_PURPLE);
-
- public int petOffset;
- public EnumChatFormatting chatFormatting;
- public int petId;
- public int beastcreatMultiplyer;
-
- Rarity(int petOffset, int petId, int beastcreatMultiplyer, EnumChatFormatting chatFormatting) {
- this.chatFormatting = chatFormatting;
- this.petOffset = petOffset;
- this.petId = petId;
- this.beastcreatMultiplyer = beastcreatMultiplyer;
- }
-
- public static Rarity getRarityFromColor(EnumChatFormatting chatFormatting) {
- for(int i = 0; i < Rarity.values().length; i++) {
- if(Rarity.values()[i].chatFormatting.equals(chatFormatting))
- return Rarity.values()[i];
- }
- return COMMON;
- }
- }
-
- public static class Pet {
- public String petType;
- public Rarity rarity;
- public GuiProfileViewer.PetLevel petLevel;
- public String petXpType;
- public String petItem;
- }
-
- private static long lastXpGain = 0;
-
- public static class PetConfig {
- public HashMap<Integer, Pet> petMap = new HashMap<>();
-
- private int selectedPet = -1;
- private int selectedPet2 = -1;
-
- public int tamingLevel = 1;
- public float beastMultiplier = 0;
- }
-
- private static long lastPetSelect = -1;
- private static PetConfig config = new PetConfig();
-
- private static long lastUpdate = 0;
- private static float levelXpLast = 0;
-
- private static LinkedList<Float> xpGainQueue = new LinkedList<>();
- private static float xpGainHourLast = -1;
- private static float xpGainHour = -1;
- private static int pauseCountdown = 0;
-
- private static float xpGainHourSecondPet = -1;
-
- private int xpAddTimer = 0;
-
- public static void loadConfig(File file) {
- try(BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) {
- config = GSON.fromJson(reader, PetConfig.class);
- } catch(Exception ignored) {}
- if(config == null) {
- config = new PetConfig();
- }
- }
-
- public static void saveConfig(File file) {
- try {
- file.createNewFile();
- try(BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8))) {
- writer.write(GSON.toJson(config));
- }
- } catch(Exception ignored) {}
- }
-
- public static void clearPet() {
- config.selectedPet = -1;
- config.selectedPet2 = -1;
- }
-
- public static void setCurrentPet(int index) {
- config.selectedPet2 = config.selectedPet;
- xpGainHourSecondPet = xpGainHour;
- xpGainHourLast = xpGainHour;
- xpGainQueue.clear();
- config.selectedPet = index;
- }
-
- public static Pet getCurrentPet() {
- return config.petMap.get(config.selectedPet);
- }
-
- public static Pet getCurrentPet2() {
- if(!NotEnoughUpdates.INSTANCE.config.petOverlay.dualPets) return null;
- if(config.selectedPet == config.selectedPet2) return null;
- return config.petMap.get(config.selectedPet2);
- }
-
- public float getLevelPercent(Pet pet) {
- DecimalFormat df = new DecimalFormat("#.#", DecimalFormatSymbols.getInstance(Locale.ENGLISH));
- if(pet == null) return 0;
- try {
- return Float.parseFloat(df.format(pet.petLevel.levelPercentage * 100f));
- } catch(Exception ignored) {
- return 0;
- }
- }
-
- private static int getIdForPet(Pet pet) {
- for(Map.Entry<Integer, Pet> entry : config.petMap.entrySet()) {
- if(entry.getValue() == pet) {
- return entry.getKey();
- }
- }
- return -1;
- }
-
- private static int getClosestPetIndex(String petType, int petId, String petItem, float petLevel) {
- Pet pet = getClosestPet(petType, petId, petItem, petLevel);
- if(pet == null) {
- return -1;
- } else {
- return getIdForPet(pet);
- }
- }
-
- private static Pet getClosestPet(String petType, int petId, String petItem, float petLevel) {
- Set<Pet> pets = new HashSet<>();
- for(Pet pet : config.petMap.values()) {
- if(pet.petType.equals(petType) && pet.rarity.petId == petId) {
- pets.add(pet);
- }
- }
-
- if(pets == null || pets.isEmpty()) {
- return null;
- }
-
- if(pets.size() == 1) {
- return pets.iterator().next();
- }
-
- String searchItem = petItem;
-
- Set<Pet> itemMatches = new HashSet<>();
- for(Pet pet : pets) {
- if((searchItem == null && pet.petItem == null) ||
- (searchItem != null && searchItem.equals(pet.petItem))) {
- itemMatches.add(pet);
- }
- }
-
- if(itemMatches.size() == 1) {
- return itemMatches.iterator().next();
- }
- if(itemMatches.size() > 1) {
- pets = itemMatches;
- }
-
- float closestXp = -1;
- Pet closestPet = null;
-
- for(Pet pet : pets) {
- float distXp = Math.abs(pet.petLevel.level - petLevel);
-
- if(closestPet == null || distXp < closestXp) {
- closestXp = distXp;
- closestPet = pet;
- }
- }
-
- if(closestPet != null) {
- return closestPet;
- } else {
- return pets.iterator().next();
- }
- }
-
- private static void getAndSetPet(ProfileViewer.Profile profile) {
- JsonObject skillInfo = profile.getSkillInfo(profile.getLatestProfile());
- JsonObject invInfo = profile.getInventoryInfo(profile.getLatestProfile());
- JsonObject profileInfo = profile.getProfileInformation(profile.getLatestProfile());
- if(invInfo != null && profileInfo != null) {
- JsonObject stats = profileInfo.get("stats").getAsJsonObject();
- boolean hasBeastmasterCrest = false;
- Rarity currentBeastRarity = Rarity.COMMON;
- for(JsonElement talisman : invInfo.get("talisman_bag").getAsJsonArray()) {
- if(talisman.isJsonNull()) continue;
- String internalName = talisman.getAsJsonObject().get("internalname").getAsString();
- if(internalName.startsWith("BEASTMASTER_CREST")) {
- hasBeastmasterCrest = true;
- try {
- Rarity talismanRarity = Rarity.valueOf(internalName.replace("BEASTMASTER_CREST_", ""));
- if(talismanRarity.beastcreatMultiplyer > currentBeastRarity.beastcreatMultiplyer)
- currentBeastRarity = talismanRarity;
- } catch(Exception ignored) {
- }
- }
- }
- if(hasBeastmasterCrest) {
- if(stats.has("mythos_kills")) {
- int mk = stats.get("mythos_kills").getAsInt();
- float petXpBoost = mk > 10000 ? 1f : mk > 7500 ? 0.9f : mk > 5000 ? 0.8f : mk > 2500 ? 0.7f :
- mk > 1000 ? 0.6f : mk > 500 ? 0.5f : mk > 250 ? 0.4f : mk > 100 ? 0.3f : mk > 25 ? 0.2f : 0.1f;
- config.beastMultiplier = petXpBoost * currentBeastRarity.beastcreatMultiplyer;
- } else {
- config.beastMultiplier = 0.1f * currentBeastRarity.beastcreatMultiplyer;
- }
- }
- }
- if(skillInfo != null) config.tamingLevel = skillInfo.get("level_skill_taming").getAsInt();
- //JsonObject petObject = profile.getPetsInfo(profile.getLatestProfile());
+ private static final Pattern XP_BOOST_PATTERN = Pattern.compile(
+ "PET_ITEM_(COMBAT|FISHING|MINING|FORAGING|ALL|FARMING)_(SKILL|SKILLS)_BOOST_(COMMON|UNCOMMON|RARE|EPIC)");
+ private static final Pattern PET_CONTAINER_PAGE = Pattern.compile("\\((\\d)/(\\d)\\) Pets");
+ private static final Pattern PET_NAME_PATTERN = Pattern.compile("\u00a77\\[Lvl \\d+] \u00a7(.+)");
+ private static final Pattern XP_LINE_PATTERN = Pattern.compile(
+ "-------------------- (\\d+(?:,\\d+)*(?:\\.\\d+)?)/(\\d+(?:\\.\\d+)?[B|M|k]?)");
+
+ private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
+
+ public PetInfoOverlay(
+ Position position,
+ Supplier<List<String>> dummyStrings,
+ Supplier<TextOverlayStyle> styleSupplier
+ ) {
+ super(position, dummyStrings, styleSupplier);
+ }
+
+ public enum Rarity {
+ COMMON(0, 0, 1, EnumChatFormatting.WHITE),
+ UNCOMMON(6, 1, 2, EnumChatFormatting.GREEN),
+ RARE(11, 2, 3, EnumChatFormatting.BLUE),
+ EPIC(16, 3, 4, EnumChatFormatting.DARK_PURPLE),
+ LEGENDARY(20, 4, 5, EnumChatFormatting.GOLD),
+ MYTHIC(20, 5, 5, EnumChatFormatting.LIGHT_PURPLE);
+
+ public int petOffset;
+ public EnumChatFormatting chatFormatting;
+ public int petId;
+ public int beastcreatMultiplyer;
+
+ Rarity(int petOffset, int petId, int beastcreatMultiplyer, EnumChatFormatting chatFormatting) {
+ this.chatFormatting = chatFormatting;
+ this.petOffset = petOffset;
+ this.petId = petId;
+ this.beastcreatMultiplyer = beastcreatMultiplyer;
+ }
+
+ public static Rarity getRarityFromColor(EnumChatFormatting chatFormatting) {
+ for (int i = 0; i < Rarity.values().length; i++) {
+ if (Rarity.values()[i].chatFormatting.equals(chatFormatting))
+ return Rarity.values()[i];
+ }
+ return COMMON;
+ }
+ }
+
+ public static class Pet {
+ public String petType;
+ public Rarity rarity;
+ public GuiProfileViewer.PetLevel petLevel;
+ public String petXpType;
+ public String petItem;
+ }
+
+ private static long lastXpGain = 0;
+
+ public static class PetConfig {
+ public HashMap<Integer, Pet> petMap = new HashMap<>();
+
+ private int selectedPet = -1;
+ private int selectedPet2 = -1;
+
+ public int tamingLevel = 1;
+ public float beastMultiplier = 0;
+ }
+
+ private static long lastPetSelect = -1;
+ private static PetConfig config = new PetConfig();
+
+ private static long lastUpdate = 0;
+ private static float levelXpLast = 0;
+
+ private static final LinkedList<Float> xpGainQueue = new LinkedList<>();
+ private static float xpGainHourLast = -1;
+ private static float xpGainHour = -1;
+ private static int pauseCountdown = 0;
+
+ private static float xpGainHourSecondPet = -1;
+
+ private int xpAddTimer = 0;
+
+ public static void loadConfig(File file) {
+ try (
+ BufferedReader reader = new BufferedReader(new InputStreamReader(
+ new FileInputStream(file),
+ StandardCharsets.UTF_8
+ ))
+ ) {
+ config = GSON.fromJson(reader, PetConfig.class);
+ } catch (Exception ignored) {
+ }
+ if (config == null) {
+ config = new PetConfig();
+ }
+ }
+
+ public static void saveConfig(File file) {
+ try {
+ file.createNewFile();
+ try (
+ BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
+ new FileOutputStream(file),
+ StandardCharsets.UTF_8
+ ))
+ ) {
+ writer.write(GSON.toJson(config));
+ }
+ } catch (Exception ignored) {
+ }
+ }
+
+ public static void clearPet() {
+ config.selectedPet = -1;
+ config.selectedPet2 = -1;
+ }
+
+ public static void setCurrentPet(int index) {
+ config.selectedPet2 = config.selectedPet;
+ xpGainHourSecondPet = xpGainHour;
+ xpGainHourLast = xpGainHour;
+ xpGainQueue.clear();
+ config.selectedPet = index;
+ }
+
+ public static Pet getCurrentPet() {
+ return config.petMap.get(config.selectedPet);
+ }
+
+ public static Pet getCurrentPet2() {
+ if (!NotEnoughUpdates.INSTANCE.config.petOverlay.dualPets) return null;
+ if (config.selectedPet == config.selectedPet2) return null;
+ return config.petMap.get(config.selectedPet2);
+ }
+
+ public float getLevelPercent(Pet pet) {
+ DecimalFormat df = new DecimalFormat("#.#", DecimalFormatSymbols.getInstance(Locale.ENGLISH));
+ if (pet == null) return 0;
+ try {
+ return Float.parseFloat(df.format(pet.petLevel.levelPercentage * 100f));
+ } catch (Exception ignored) {
+ return 0;
+ }
+ }
+
+ private static int getIdForPet(Pet pet) {
+ for (Map.Entry<Integer, Pet> entry : config.petMap.entrySet()) {
+ if (entry.getValue() == pet) {
+ return entry.getKey();
+ }
+ }
+ return -1;
+ }
+
+ private static int getClosestPetIndex(String petType, int petId, String petItem, float petLevel) {
+ Pet pet = getClosestPet(petType, petId, petItem, petLevel);
+ if (pet == null) {
+ return -1;
+ } else {
+ return getIdForPet(pet);
+ }
+ }
+
+ private static Pet getClosestPet(String petType, int petId, String petItem, float petLevel) {
+ Set<Pet> pets = new HashSet<Pet>() {{
+ for (Pet pet : config.petMap.values()) {
+ if (pet.petType.equals(petType) && pet.rarity.petId == petId) {
+ add(pet);
+ }
+ }
+ }};
+
+ if (pets == null || pets.isEmpty()) {
+ return null;
+ }
+
+ if (pets.size() == 1) {
+ return pets.iterator().next();
+ }
+
+ String searchItem = petItem;
+
+ Set<Pet> itemMatches = new HashSet<>();
+ for (Pet pet : pets) {
+ if ((searchItem == null && pet.petItem == null) ||
+ (searchItem != null && searchItem.equals(pet.petItem))) {
+ itemMatches.add(pet);
+ }
+ }
+
+ if (itemMatches.size() == 1) {
+ return itemMatches.iterator().next();
+ }
+ if (itemMatches.size() > 1) {
+ pets = itemMatches;
+ }
+
+ float closestXp = -1;
+ Pet closestPet = null;
+
+ for (Pet pet : pets) {
+ float distXp = Math.abs(pet.petLevel.level - petLevel);
+
+ if (closestPet == null || distXp < closestXp) {
+ closestXp = distXp;
+ closestPet = pet;
+ }
+ }
+
+ if (closestPet != null) {
+ return closestPet;
+ } else {
+ return pets.iterator().next();
+ }
+ }
+
+ private static void getAndSetPet(ProfileViewer.Profile profile) {
+ JsonObject skillInfo = profile.getSkillInfo(profile.getLatestProfile());
+ JsonObject invInfo = profile.getInventoryInfo(profile.getLatestProfile());
+ JsonObject profileInfo = profile.getProfileInformation(profile.getLatestProfile());
+ if (invInfo != null && profileInfo != null) {
+ JsonObject stats = profileInfo.get("stats").getAsJsonObject();
+ boolean hasBeastmasterCrest = false;
+ Rarity currentBeastRarity = Rarity.COMMON;
+ for (JsonElement talisman : invInfo.get("talisman_bag").getAsJsonArray()) {
+ if (talisman.isJsonNull()) continue;
+ String internalName = talisman.getAsJsonObject().get("internalname").getAsString();
+ if (internalName.startsWith("BEASTMASTER_CREST")) {
+ hasBeastmasterCrest = true;
+ try {
+ Rarity talismanRarity = Rarity.valueOf(internalName.replace("BEASTMASTER_CREST_", ""));
+ if (talismanRarity.beastcreatMultiplyer > currentBeastRarity.beastcreatMultiplyer)
+ currentBeastRarity = talismanRarity;
+ } catch (Exception ignored) {
+ }
+ }
+ }
+ if (hasBeastmasterCrest) {
+ if (stats.has("mythos_kills")) {
+ int mk = stats.get("mythos_kills").getAsInt();
+ float petXpBoost = mk > 10000 ? 1f : mk > 7500 ? 0.9f : mk > 5000 ? 0.8f : mk > 2500 ? 0.7f :
+ mk > 1000
+ ? 0.6f
+ : mk > 500
+ ? 0.5f
+ : mk > 250
+ ? 0.4f
+ : mk > 100
+ ? 0.3f
+ : mk > 25 ? 0.2f : 0.1f;
+ config.beastMultiplier = petXpBoost * currentBeastRarity.beastcreatMultiplyer;
+ } else {
+ config.beastMultiplier = 0.1f * currentBeastRarity.beastcreatMultiplyer;
+ }
+ }
+ }
+ if (skillInfo != null) config.tamingLevel = skillInfo.get("level_skill_taming").getAsInt();
+ //JsonObject petObject = profile.getPetsInfo(profile.getLatestProfile());
/*JsonObject petsJson = Constants.PETS;
if(petsJson != null) {
if(petObject != null) {
@@ -333,804 +359,880 @@ public class PetInfoOverlay extends TextOverlay {
setActivePet = true;
}
}*/
- }
-
- private float interp(float now, float last) {
- float interp = now;
- if(last >= 0 && last != now) {
- float factor = (System.currentTimeMillis()-lastUpdate)/1000f;
- factor = LerpUtils.clampZeroOne(factor);
- interp = last + (now - last) * factor;
- }
- return interp;
- }
-
- private List<String> createStringsForPet(Pet currentPet, boolean secondPet) {
- float levelXp = currentPet.petLevel.levelXp;
- if(!secondPet) levelXp = interp(currentPet.petLevel.levelXp, levelXpLast);
- if(levelXp < 0) levelXp = 0;
-
- String petName = EnumChatFormatting.GREEN + "[Lvl " + (int) currentPet.petLevel.level + "] " + currentPet.rarity.chatFormatting +
- WordUtils.capitalizeFully(currentPet.petType.replace("_", " "));
-
- String lvlStringShort = EnumChatFormatting.AQUA + "" + roundFloat(levelXp) + "/" +
- roundFloat(currentPet.petLevel.currentLevelRequirement)
- + EnumChatFormatting.YELLOW + " (" + getLevelPercent(currentPet) + "%)";
-
- String lvlString = EnumChatFormatting.AQUA + "" + Utils.shortNumberFormat(levelXp, 0) + "/" +
- Utils.shortNumberFormat(currentPet.petLevel.currentLevelRequirement, 0)
- + EnumChatFormatting.YELLOW + " (" + getLevelPercent(currentPet) + "%)";
-
- float xpGain;
- if(!secondPet) {
- xpGain = interp(xpGainHour, xpGainHourLast);
- } else {
- xpGain = xpGainHourSecondPet;
- }
- if(xpGain < 0) xpGain = 0;
- String xpGainString = EnumChatFormatting.AQUA + "XP/h: " +
- EnumChatFormatting.YELLOW + roundFloat(xpGain);
- if(!secondPet && xpGain > 0 && levelXp != levelXpLast) {
- if(pauseCountdown <= 0) {
- xpGainString += EnumChatFormatting.RED + " (PAUSED)";
- } else {
- pauseCountdown--;
- }
- } else {
- pauseCountdown = 60;
- }
-
- String totalXpString = EnumChatFormatting.AQUA + "Total XP: " + EnumChatFormatting.YELLOW + roundFloat(currentPet.petLevel.totalXp);
-
- String petItemStr = EnumChatFormatting.AQUA+ "Held Item: " + EnumChatFormatting.RED + "None";
- if(currentPet.petItem != null) {
- JsonObject json = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(currentPet.petItem);
- if(json != null) {
- String name = NotEnoughUpdates.INSTANCE.manager.jsonToStack(json).getDisplayName();
- petItemStr = EnumChatFormatting.AQUA + "Held Item: " + name;
- }
- }
-
- String etaStr = null;
- String etaMaxStr = null;
- if(currentPet.petLevel.level < 100) {
- float remaining = currentPet.petLevel.currentLevelRequirement - currentPet.petLevel.levelXp;
- if(remaining > 0) {
- if(xpGain < 1000) {
- etaStr = EnumChatFormatting.AQUA+"Until L"+(int)(currentPet.petLevel.level+1)+": " +
- EnumChatFormatting.YELLOW+"N/A";
- } else {
- etaStr = EnumChatFormatting.AQUA+"Until L"+(int)(currentPet.petLevel.level+1)+": " +
- EnumChatFormatting.YELLOW + Utils.prettyTime((long)(remaining)*1000*60*60/(long)xpGain);
- }
- }
-
- if(currentPet.petLevel.level < 99 || !NotEnoughUpdates.INSTANCE.config.petOverlay.petOverlayText.contains(6)) {
- float remainingMax = currentPet.petLevel.maxXP - currentPet.petLevel.totalXp;
- if(remaining > 0) {
- if(xpGain < 1000) {
- etaMaxStr = EnumChatFormatting.AQUA+"Until L100: " +
- EnumChatFormatting.YELLOW+"N/A";
- } else {
- etaMaxStr = EnumChatFormatting.AQUA+"Until L100: " +
- EnumChatFormatting.YELLOW + Utils.prettyTime((long)(remainingMax)*1000*60*60/(long)xpGain);
- }
- }
- }
- }
-
- List<String> strings = new ArrayList<>();
-
- for(int index : NotEnoughUpdates.INSTANCE.config.petOverlay.petOverlayText) {
- switch(index) {
- case 0:
- strings.add(petName); break;
- case 1:
- strings.add(lvlStringShort); break;
- case 2:
- strings.add(lvlString); break;
- case 3:
- strings.add(xpGainString); break;
- case 4:
- strings.add(totalXpString); break;
- case 5:
- strings.add(petItemStr); break;
- case 6:
- if(etaStr != null) strings.add(etaStr); break;
- case 7:
- if(etaMaxStr != null) strings.add(etaMaxStr); break;
- }
- }
-
- return strings;
- }
-
- @Override
- public void updateFrequent() {
- Pet currentPet = getCurrentPet();
- if(!NotEnoughUpdates.INSTANCE.config.petOverlay.enablePetInfo || currentPet == null) {
- overlayStrings = null;
- } else {
- overlayStrings = new ArrayList<>();
-
- overlayStrings.addAll(createStringsForPet(currentPet, false));
-
- Pet currentPet2 = getCurrentPet2();
- if(currentPet2 != null) {
- overlayStrings.add("");
- overlayStrings.addAll(createStringsForPet(currentPet2, true));
- }
-
- }
- }
-
- public void update() {
- if(!NotEnoughUpdates.INSTANCE.config.petOverlay.enablePetInfo && !NotEnoughUpdates.INSTANCE.config.itemOverlays.enableMonkeyCheck) {
- overlayStrings = null;
- return;
- }
-
- int updateTime = 60000;
-
- if(NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
- ProfileApiSyncer.getInstance().requestResync("petinfo", updateTime, () -> {}, PetInfoOverlay::getAndSetPet);
- }
-
- Pet currentPet = getCurrentPet();
- if(currentPet == null) {
- overlayStrings = null;
- } else {
- lastUpdate = System.currentTimeMillis();
- levelXpLast = currentPet.petLevel.levelXp;
- updatePetLevels();
- }
- }
-
- private static GuiProfileViewer.PetLevel getMaxLevel(JsonArray levels, int offset) {
- float xpTotal = 0;
- float level = 1;
- float currentLevelRequirement = 0;
-
- for(int i=offset; i<offset+99; i++) {
- currentLevelRequirement = levels.get(i).getAsFloat();
- xpTotal += currentLevelRequirement;
- level += 1;
- }
-
- if(level <= 0) {
- level = 1;
- } else if(level > 100) {
- level = 100;
- }
- GuiProfileViewer.PetLevel levelObj = new GuiProfileViewer.PetLevel();
- levelObj.level = level;
- levelObj.currentLevelRequirement = currentLevelRequirement;
- levelObj.maxXP = xpTotal;
- levelObj.levelPercentage = 1;
- levelObj.levelXp = currentLevelRequirement-5;
- levelObj.totalXp = xpTotal-5;
- return levelObj;
- }
-
- private static GuiProfileViewer.PetLevel getLevel(JsonArray levels, int offset, float xpThisLevel, int xpMaxThisLevel) {
- float xpTotal = 0;
- float level = 1;
- float currentLevelRequirement = 0;
- float exp = xpThisLevel;
-
- boolean addLevel = true;
-
- for(int i=offset; i<offset+99; i++) {
- if(addLevel) {
- currentLevelRequirement = levels.get(i).getAsFloat();
- xpTotal += currentLevelRequirement;
-
- if(currentLevelRequirement >= xpMaxThisLevel) {
- addLevel = false;
- } else {
- exp += currentLevelRequirement;
- level += 1;
- }
- } else {
- xpTotal += levels.get(i).getAsFloat();
- }
- }
-
- level += xpThisLevel/currentLevelRequirement;
- if(level <= 0) {
- level = 1;
- } else if(level > 100) {
- level = 100;
- }
- GuiProfileViewer.PetLevel levelObj = new GuiProfileViewer.PetLevel();
- levelObj.level = level;
- levelObj.currentLevelRequirement = currentLevelRequirement;
- levelObj.maxXP = xpTotal;
- levelObj.levelPercentage = xpThisLevel/currentLevelRequirement;
- levelObj.levelXp = xpThisLevel;
- levelObj.totalXp = exp;
- return levelObj;
- }
-
- public static Pet getPetFromStack(String name, String[] lore) {
- if(Constants.PETS == null || Constants.PETS.get("pet_levels") == null || Constants.PETS.get("pet_levels") instanceof JsonNull) {
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("\u00a7cInvalid PET constants. Please run "+EnumChatFormatting.BOLD+"/neuresetrepo"+EnumChatFormatting.RESET+EnumChatFormatting.RED+" and "+EnumChatFormatting.BOLD+"restart your game"+EnumChatFormatting.RESET+EnumChatFormatting.RED+" in order to fix. "+EnumChatFormatting.DARK_RED+EnumChatFormatting.BOLD+"If that doesn't fix it"+EnumChatFormatting.RESET+EnumChatFormatting.RED+", please join discord.gg/moulberry and post in #neu-support"));
- return null;
- }
-
- String petType = null;
- Rarity rarity = null;
- String heldItem = null;
- GuiProfileViewer.PetLevel level = null;
-
- Matcher petNameMatcher = PET_NAME_PATTERN.matcher(name);
- if(petNameMatcher.matches()) {
- String petStringMatch = petNameMatcher.group(1);
-
- char colChar = petStringMatch.charAt(0);
- EnumChatFormatting col = EnumChatFormatting.RESET;
- for(EnumChatFormatting formatting : EnumChatFormatting.values()) {
- if(formatting.toString().equals("\u00a7"+colChar)) {
- col = formatting;
- break;
- }
- }
-
- rarity = Rarity.COMMON;
- if(col != EnumChatFormatting.RESET) {
- rarity = Rarity.getRarityFromColor(col);
- }
-
- petType = Utils.cleanColour(petStringMatch.substring(1))
- .replaceAll("[^\\w ]", "").trim()
- .replace(" ", "_").toUpperCase();
- }
- if(petType == null || rarity == null) {
- return null;
- }
-
- for(String line : lore) {
- Matcher xpLineMatcher = XP_LINE_PATTERN.matcher(Utils.cleanColour(line));
- if(line.startsWith("\u00a76Held Item: ")) {
- String after = line.substring("\u00a76Held Item: ".length());
-
- if(itemMap == null) {
- itemMap = new HashMap<>();
-
- for(Map.Entry<String, JsonObject> entry : NotEnoughUpdates.INSTANCE.manager.getItemInformation().entrySet()) {
- boolean petItem = false;
-
- if(entry.getKey().startsWith("PET_ITEM_")) {
- petItem = true;
- } else {
- ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(entry.getValue());
- if(stack.hasTagCompound()) {
- String[] itemLore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stack.getTagCompound());
-
- for(String itemLoreLine : itemLore) {
- if(itemLoreLine.contains("PET ITEM")) {
- petItem = true;
- break;
- }
- }
- }
- }
-
- if(petItem) {
- ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(entry.getValue());
- itemMap.put(stack.getDisplayName().replace("\u00a7f\u00a7f", ""), entry.getKey());
- }
- }
- }
-
- if(itemMap.containsKey(after)) {
- heldItem = itemMap.get(after);
- }
- } else if(xpLineMatcher.matches()) {
- String xpThisLevelS = xpLineMatcher.group(1);
- String xpMaxThisLevelS = xpLineMatcher.group(2).toLowerCase();
-
- try {
- float xpThisLevel = Float.parseFloat(xpThisLevelS.replace(",", ""));
-
- int mutiplier = 1;
- char end = xpMaxThisLevelS.charAt(xpMaxThisLevelS.length()-1);
- if(end < '0' || end > '9') {
- xpMaxThisLevelS = xpMaxThisLevelS.substring(0, xpMaxThisLevelS.length()-1);
-
- switch(end) {
- case 'k': mutiplier = 1000; break;
- case 'm': mutiplier = 1000000; break;
- case 'b': mutiplier = 1000000000; break;
- }
- }
- int xpMaxThisLevel = (int)(Float.parseFloat(xpMaxThisLevelS) * mutiplier);
-
- level = getLevel(Constants.PETS.get("pet_levels").getAsJsonArray(), rarity.petOffset, xpThisLevel, xpMaxThisLevel);
- } catch(NumberFormatException ignored) {}
- } else if(line.equals("\u00a7b\u00a7lMAX LEVEL")) {
- level = getMaxLevel(Constants.PETS.get("pet_levels").getAsJsonArray(), rarity.petOffset);
- }
- }
-
- if(level != null) {
- Pet pet = new Pet();
- pet.petItem = heldItem;
- pet.petLevel = level;
- pet.rarity = rarity;
- pet.petType = petType;
- JsonObject petTypes = Constants.PETS.get("pet_types").getAsJsonObject();
- pet.petXpType = petTypes.has(pet.petType) ? petTypes.get(pet.petType.toUpperCase()).getAsString().toLowerCase() : "unknown";
-
- return pet;
- }
-
- return null;
- }
-
- private static final HashMap<Integer, Integer> removeMap = new HashMap<>();
-
- @SubscribeEvent
- public void onTick(TickEvent.ClientTickEvent event) {
- if(Minecraft.getMinecraft().currentScreen instanceof GuiChest && NEUEventListener.inventoryLoaded) {
- GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
- ContainerChest container = (ContainerChest) chest.inventorySlots;
- IInventory lower = container.getLowerChestInventory();
- String containerName = lower.getDisplayName().getUnformattedText();
-
- if(lower.getSizeInventory() >= 54) {
- int page = 0;
- int maxPage = 1;
- boolean isPets = false;
-
- if(containerName.equals("Pets")) {
- isPets = true;
- } else {
- Matcher matcher = PET_CONTAINER_PAGE.matcher(containerName);
- if(matcher.matches()) {
- try {
- page = Integer.parseInt(matcher.group(1))-1;
- maxPage = Integer.parseInt(matcher.group(2));
- isPets = true;
- } catch(NumberFormatException ignored) {}
- }
- }
-
- if(isPets) {
- boolean hasItem = false;
- for(int i=0; i<lower.getSizeInventory(); i++) {
- if(lower.getStackInSlot(i) != null) {
- hasItem = true;
- break;
- }
- }
- if(!hasItem) return;
-
- Set<Integer> clear = new HashSet<>();
- for(int i : config.petMap.keySet()) {
- if(i >= maxPage*28) {
- clear.add(i);
- }
- }
- config.petMap.keySet().removeAll(clear);
-
- Set<Integer> removeSet = new HashSet<>();
- long currentTime = System.currentTimeMillis();
- for(int index=0; index<28; index++) {
- int petIndex = page*28+index;
- int itemIndex = 10+index+index/7*2;
-
- ItemStack stack = lower.getStackInSlot(itemIndex);
-
- if(stack == null || !stack.hasTagCompound()) {
- if(index < 27) {
- int itemIndexNext = 10+(index+1)+(index+1)/7*2;
- ItemStack stackNext = lower.getStackInSlot(itemIndexNext);
-
- if(stackNext == null || !stackNext.hasTagCompound()) {
- int old = removeMap.getOrDefault(petIndex, 0);
- if(old >= 20) {
- config.petMap.remove(petIndex);
- } else {
- removeSet.add(petIndex);
- removeMap.put(petIndex, old+1);
- }
- }
- }
- } else {
- String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stack.getTagCompound());
- Pet pet = getPetFromStack(stack.getDisplayName(), lore);
- if(pet != null) {
- config.petMap.put(petIndex, pet);
-
- if(currentTime - lastPetSelect > 500) {
- boolean foundDespawn = false;
- for(String line : lore) {
- if(line.equals("\u00a77\u00a7cClick to despawn ")) {
- config.selectedPet = petIndex;
- foundDespawn = true;
- break;
- }
- }
- if(foundDespawn && config.selectedPet == petIndex) {
- clearPet();
- }
- }
- }
- }
- }
- removeMap.keySet().retainAll(removeSet);
- }
- }
- }
- }
-
- @Override
- protected Vector2f getSize(List<String> strings) {
- if(!NotEnoughUpdates.INSTANCE.config.petOverlay.petOverlayIcon) return super.getSize(strings);
- return super.getSize(strings).translate(25, 0);
- }
-
- @Override
- protected Vector2f getTextOffset() {
- if(!NotEnoughUpdates.INSTANCE.config.petOverlay.petOverlayIcon) return super.getTextOffset();
- if(this.styleSupplier.get() != TextOverlayStyle.BACKGROUND) return super.getTextOffset().translate(30, 0);
- return super.getTextOffset().translate(25, 0);
- }
-
- @Override
- public void renderDummy() {
- super.renderDummy();
-
- if(!NotEnoughUpdates.INSTANCE.config.petOverlay.petOverlayIcon) return;
-
- JsonObject petItem = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("ROCK;0");
- if(petItem != null) {
- Vector2f position = getPosition(overlayWidth, overlayHeight);
- int x = (int)position.x;
- int y = (int)position.y;
-
- ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(petItem);
- GlStateManager.enableDepth();
- GlStateManager.pushMatrix();
- GlStateManager.translate(x-2, y-2, 0);
- GlStateManager.scale(2, 2, 1);
- Utils.drawItemStack(stack, 0, 0);
- GlStateManager.popMatrix();
- }
- }
-
- @Override
- public void render() {
- super.render();
-
- Pet currentPet = getCurrentPet();
- if(currentPet == null) {
- overlayStrings = null;
- return;
- }
-
- if(overlayStrings == null) {
- return;
- }
-
- if(!NotEnoughUpdates.INSTANCE.config.petOverlay.petOverlayIcon) return;
-
- JsonObject petItem = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(currentPet.petType + ";" + currentPet.rarity.petId);
- if(petItem != null) {
- Vector2f position = getPosition(overlayWidth, overlayHeight);
- int x = (int)position.x;
- int y = (int)position.y;
-
- ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(petItem);
- GlStateManager.enableDepth();
- GlStateManager.pushMatrix();
- GlStateManager.translate(x-2, y-2, 0);
- GlStateManager.scale(2, 2, 1);
- Utils.drawItemStack(stack, 0, 0);
- GlStateManager.popMatrix();
- }
-
- Pet currentPet2 = getCurrentPet2();
- if(currentPet2 != null) {
- JsonObject petItem2 = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(currentPet2.petType + ";" + currentPet2.rarity.petId);
- if(petItem2 != null) {
- Vector2f position = getPosition(overlayWidth, overlayHeight);
- int x = (int)position.x;
- int y = (int)position.y + NotEnoughUpdates.INSTANCE.config.petOverlay.petOverlayText.size()*10+10;
-
- ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(petItem2);
- GlStateManager.enableDepth();
- GlStateManager.pushMatrix();
- GlStateManager.translate(x-2, y-2, 0);
- GlStateManager.scale(2, 2, 1);
- Utils.drawItemStack(stack, 0, 0);
- GlStateManager.popMatrix();
- }
- }
- }
-
- public static float getBoostMultiplier(String boostName) {
- if(boostName == null) return 1;
- boostName = boostName.toLowerCase();
- if(boostName.equalsIgnoreCase("PET_ITEM_ALL_SKILLS_BOOST_COMMON")) {
- return 1.1f;
- } else if(boostName.equalsIgnoreCase("ALL_SKILLS_SUPER_BOOST")) {
- return 1.2f;
- } else if(boostName.endsWith("epic")) {
- return 1.5f;
- } else if(boostName.endsWith("rare")) {
- return 1.4f;
- } else if(boostName.endsWith("uncommon")) {
- return 1.3f;
- } else if(boostName.endsWith("common")) {
- return 1.2f;
- } else {
- return 1;
- }
- }
-
- private static List<String> validXpTypes = Lists.newArrayList("mining","foraging","enchanting","farming","combat","fishing","alchemy");
-
- public static void onStackClick(ItemStack stack, int windowId, int slotId, int mouseButtonClicked, int mode) {
- if(mode != 0) return;
- if(mouseButtonClicked != 0 && mouseButtonClicked != 1) return;
-
- int slotIdMod = (slotId-10)%9;
- if(slotId >= 10 && slotId <= 43 && slotIdMod >= 0 && slotIdMod <= 6 && Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
- GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
- ContainerChest container = (ContainerChest) chest.inventorySlots;
- IInventory lower = container.getLowerChestInventory();
- String containerName = lower.getDisplayName().getUnformattedText();
-
- if(lower.getSizeInventory() >= 54 && windowId == container.windowId) {
- int page = 0;
- boolean isPets = false;
-
- if(containerName.equals("Pets")) {
- isPets = true;
- } else {
- Matcher matcher = PET_CONTAINER_PAGE.matcher(containerName);
- if(matcher.matches()) {
- try {
- page = Integer.parseInt(matcher.group(1))-1;
- isPets = true;
- } catch(NumberFormatException ignored) {}
- }
- }
-
- if(isPets) {
- ItemStack removingStack = lower.getStackInSlot(50);
- boolean isRemoving = removingStack != null && removingStack.getItem() == Items.dye && removingStack.getItemDamage() == 10;
-
- int newSelected = (slotId-10)-(slotId-10)/9*2+page*28;
-
- lastPetSelect = System.currentTimeMillis();
-
- if(isRemoving) {
- if(newSelected == config.selectedPet) {
- clearPet();
- } else if(config.selectedPet > newSelected) {
- config.selectedPet--;
- }
- } else {
- setCurrentPet(newSelected);
-
- String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stack.getTagCompound());
- Pet pet = getPetFromStack(stack.getDisplayName(), lore);
- if(pet != null) {
- config.petMap.put(config.selectedPet, pet);
- }
- }
- }
- }
- }
- }
-
- public static float getXpGain(Pet pet, float xp, String xpType) {
- if(pet.petLevel.level >= 100) return 0;
-
- if(validXpTypes == null) validXpTypes = Lists.newArrayList("mining","foraging","enchanting","farming","combat","fishing","alchemy");
- if(!validXpTypes.contains(xpType.toLowerCase())) return 0;
-
- float tamingPercent = 1.0f + (config.tamingLevel / 100f);
- xp = xp * tamingPercent;
- xp = xp + (xp * config.beastMultiplier / 100f);
- if(pet.petXpType != null && !pet.petXpType.equalsIgnoreCase(xpType)) {
- xp = xp / 3f;
-
- if(xpType.equalsIgnoreCase("alchemy") || xpType.equalsIgnoreCase("enchanting")) {
- xp = xp / 4f;
- }
- }
- if(xpType.equalsIgnoreCase("mining") || xpType.equalsIgnoreCase("fishing")) {
- xp = xp * 1.5f;
- }
- if(pet.petItem != null) {
- Matcher petItemMatcher = XP_BOOST_PATTERN.matcher(pet.petItem);
- if((petItemMatcher.matches() && petItemMatcher.group(1).equalsIgnoreCase(xpType))
- || pet.petItem.equalsIgnoreCase("ALL_SKILLS_SUPER_BOOST")) {
- xp = xp * getBoostMultiplier(pet.petItem);
- }
- }
- return xp;
- }
-
- private final HashMap<String, Float> skillInfoMapLast = new HashMap<>();
- public void updatePetLevels() {
- HashMap<String, XPInformation.SkillInfo> skillInfoMap = XPInformation.getInstance().getSkillInfoMap();
-
- long currentTime = System.currentTimeMillis();
-
- float totalGain = 0;
-
- Pet currentPet = getCurrentPet();
- for(Map.Entry<String, XPInformation.SkillInfo> entry : skillInfoMap.entrySet()) {
- if(entry.getValue().level == 50 && entry.getValue().fromApi) continue;
-
- float skillXp = entry.getValue().totalXp;
- if(skillInfoMapLast.containsKey(entry.getKey())) {
- float skillXpLast = skillInfoMapLast.get(entry.getKey());
-
- if(skillXpLast <= 0) {
- skillInfoMapLast.put(entry.getKey(), skillXp);
- } else if(skillXp > skillXpLast) {
- lastXpGain = currentTime;
-
- float deltaXp = skillXp - skillXpLast;
-
- float gain = getXpGain(currentPet, deltaXp, entry.getKey().toUpperCase());
- totalGain += gain;
-
- skillInfoMapLast.put(entry.getKey(), skillXp);
- }
- } else {
- skillInfoMapLast.put(entry.getKey(), skillXp);
- }
- }
-
- xpGainHourLast = xpGainHour;
- if(xpAddTimer > 0 || totalGain > 0) {
- if(totalGain > 0) {
- xpAddTimer = 10;
- } else {
- xpAddTimer--;
- }
-
- currentPet.petLevel.totalXp += totalGain;
-
- xpGainQueue.add(0, totalGain);
- while(xpGainQueue.size() > 30) {
- xpGainQueue.removeLast();
- }
-
- if(xpGainQueue.size() > 1) {
- float tot = 0;
- float greatest = 0;
- for(float f : xpGainQueue) {
- tot += f;
- greatest = Math.max(greatest, f);
- }
-
- xpGainHour = (tot-greatest)*(60*60)/(xpGainQueue.size()-1);
- }
- }
-
- JsonObject petsJson = Constants.PETS;
- if(currentPet != null && petsJson != null) {
- currentPet.petLevel = GuiProfileViewer.getPetLevel(currentPet.petItem, currentPet.rarity.name(), currentPet.petLevel.totalXp);
- }
- }
-
- public String roundFloat(float f) {
- if(f % 1 < 0.05f) {
- return NumberFormat.getNumberInstance().format((int)f);
- } else {
- String s = Utils.floatToString(f, 1);
- if(s.contains(".")) {
- return NumberFormat.getNumberInstance().format((int)f) + '.' + s.split("\\.")[1];
- } else if(s.contains(",")) {
- return NumberFormat.getNumberInstance().format((int)f) + ',' + s.split(",")[1];
- } else {
- return s;
- }
- }
- }
-
- @SubscribeEvent
- public void switchWorld(WorldEvent.Load event) {
- if(NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
- ProfileApiSyncer.getInstance().requestResync("petinfo_quick", 10000, () -> {
- }, PetInfoOverlay::getAndSetPet);
- }
- }
-
- private int lastLevelHovered = 0;
- private String lastItemHovered = null;
-
- private static HashMap<String, String> itemMap = null;
-
- @SubscribeEvent(priority = EventPriority.HIGHEST, receiveCanceled = true)
- public void onTooltip(ItemTooltipEvent event) {
- for(String line : event.toolTip) {
- if(line.startsWith("\u00a7o\u00a77[Lvl ")) {
- lastItemHovered = null;
-
- String after = line.substring("\u00a7o\u00a77[Lvl ".length());
- if(after.contains("]")) {
- String levelStr = after.split("]")[0];
-
- try {
- lastLevelHovered = Integer.parseInt(levelStr.trim());
- } catch(Exception ignored) {}
- }
- } else if(line.startsWith("\u00a75\u00a7o\u00a76Held Item: ")) {
- String after = line.substring("\u00a75\u00a7o\u00a76Held Item: ".length());
-
- if(itemMap == null) {
- itemMap = new HashMap<>();
-
- for(Map.Entry<String, JsonObject> entry : NotEnoughUpdates.INSTANCE.manager.getItemInformation().entrySet()) {
- if(entry.getKey().equals("ALL_SKILLS_SUPER_BOOST") ||
- XP_BOOST_PATTERN.matcher(entry.getKey()).matches()) {
- ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(entry.getValue());
- itemMap.put(stack.getDisplayName(), entry.getKey());
- }
- }
- }
-
- if(itemMap.containsKey(after)) {
- lastItemHovered = itemMap.get(after);
- }
- }
- }
- }
-
- private static final Pattern AUTOPET_EQUIP = Pattern.compile("\u00a7cAutopet \u00a7eequipped your \u00a77\\[Lvl (\\d+)] \u00a7(.{2,})\u00a7e! \u00a7a\u00a7lVIEW RULE\u00a7r");
-
- @SubscribeEvent(priority = EventPriority.HIGHEST)
- public void onChatReceived(ClientChatReceivedEvent event) {
- NEUConfig config = NotEnoughUpdates.INSTANCE.config;
- if(NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && (config.petOverlay.enablePetInfo || config.itemOverlays.enableMonkeyCheck)) {
- if(event.type == 0) {
- String chatMessage = Utils.cleanColour(event.message.getUnformattedText());
-
- Matcher autopetMatcher = AUTOPET_EQUIP.matcher(event.message.getFormattedText());
- if(autopetMatcher.matches()) {
- try {
- lastLevelHovered = Integer.parseInt(autopetMatcher.group(1));
- } catch(NumberFormatException ignored) {}
-
- String petStringMatch = autopetMatcher.group(2);
- char colChar = petStringMatch.charAt(0);
- EnumChatFormatting col = EnumChatFormatting.RESET;
- for(EnumChatFormatting formatting : EnumChatFormatting.values()) {
- if(formatting.toString().equals("\u00a7"+colChar)) {
- col = formatting;
- break;
- }
-
- }
- Rarity rarity = Rarity.COMMON;
- if(col != EnumChatFormatting.RESET) {
- rarity = Rarity.getRarityFromColor(col);
- }
-
- String pet = Utils.cleanColour(petStringMatch.substring(1))
- .replaceAll("[^\\w ]", "").trim()
- .replace(" ", "_").toUpperCase();
-
- setCurrentPet(getClosestPetIndex(pet, rarity.petId, "", lastLevelHovered));
- if(PetInfoOverlay.config.selectedPet == -1) {
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED+"[NEU] Can't find pet \u00a7" + petStringMatch +
- EnumChatFormatting.RED + " try revisiting all pages of /pets."));
- }
- } else if(chatMessage.toLowerCase().startsWith("you despawned your")) {
- clearPet();
- } else if(chatMessage.toLowerCase().contains("switching to profile")) {
- clearPet();
- }
- }
- }
- }
+ }
+
+ private float interp(float now, float last) {
+ float interp = now;
+ if (last >= 0 && last != now) {
+ float factor = (System.currentTimeMillis() - lastUpdate) / 1000f;
+ factor = LerpUtils.clampZeroOne(factor);
+ interp = last + (now - last) * factor;
+ }
+ return interp;
+ }
+
+ private List<String> createStringsForPet(Pet currentPet, boolean secondPet) {
+ float levelXp = currentPet.petLevel.levelXp;
+ if (!secondPet) levelXp = interp(currentPet.petLevel.levelXp, levelXpLast);
+ if (levelXp < 0) levelXp = 0;
+
+ String petName =
+ EnumChatFormatting.GREEN + "[Lvl " + (int) currentPet.petLevel.level + "] " + currentPet.rarity.chatFormatting +
+ WordUtils.capitalizeFully(currentPet.petType.replace("_", " "));
+
+ String lvlStringShort = EnumChatFormatting.AQUA + "" + roundFloat(levelXp) + "/" +
+ roundFloat(currentPet.petLevel.currentLevelRequirement)
+ + EnumChatFormatting.YELLOW + " (" + getLevelPercent(currentPet) + "%)";
+
+ String lvlString = EnumChatFormatting.AQUA + "" + Utils.shortNumberFormat(levelXp, 0) + "/" +
+ Utils.shortNumberFormat(currentPet.petLevel.currentLevelRequirement, 0)
+ + EnumChatFormatting.YELLOW + " (" + getLevelPercent(currentPet) + "%)";
+
+ float xpGain;
+ if (!secondPet) {
+ xpGain = interp(xpGainHour, xpGainHourLast);
+ } else {
+ xpGain = xpGainHourSecondPet;
+ }
+ if (xpGain < 0) xpGain = 0;
+ String xpGainString = EnumChatFormatting.AQUA + "XP/h: " +
+ EnumChatFormatting.YELLOW + roundFloat(xpGain);
+ if (!secondPet && xpGain > 0 && levelXp != levelXpLast) {
+ if (pauseCountdown <= 0) {
+ xpGainString += EnumChatFormatting.RED + " (PAUSED)";
+ } else {
+ pauseCountdown--;
+ }
+ } else {
+ pauseCountdown = 60;
+ }
+
+ String totalXpString =
+ EnumChatFormatting.AQUA + "Total XP: " + EnumChatFormatting.YELLOW + roundFloat(currentPet.petLevel.totalXp);
+
+ String petItemStr = EnumChatFormatting.AQUA + "Held Item: " + EnumChatFormatting.RED + "None";
+ if (currentPet.petItem != null) {
+ JsonObject json = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(currentPet.petItem);
+ if (json != null) {
+ String name = NotEnoughUpdates.INSTANCE.manager.jsonToStack(json).getDisplayName();
+ petItemStr = EnumChatFormatting.AQUA + "Held Item: " + name;
+ }
+ }
+
+ String etaStr = null;
+ String etaMaxStr = null;
+ if (currentPet.petLevel.level < 100) {
+ float remaining = currentPet.petLevel.currentLevelRequirement - currentPet.petLevel.levelXp;
+ if (remaining > 0) {
+ if (xpGain < 1000) {
+ etaStr = EnumChatFormatting.AQUA + "Until L" + (int) (currentPet.petLevel.level + 1) + ": " +
+ EnumChatFormatting.YELLOW + "N/A";
+ } else {
+ etaStr = EnumChatFormatting.AQUA + "Until L" + (int) (currentPet.petLevel.level + 1) + ": " +
+ EnumChatFormatting.YELLOW + Utils.prettyTime((long) (remaining) * 1000 * 60 * 60 / (long) xpGain);
+ }
+ }
+
+ if (currentPet.petLevel.level < 99 || !NotEnoughUpdates.INSTANCE.config.petOverlay.petOverlayText.contains(6)) {
+ float remainingMax = currentPet.petLevel.maxXP - currentPet.petLevel.totalXp;
+ if (remaining > 0) {
+ if (xpGain < 1000) {
+ etaMaxStr = EnumChatFormatting.AQUA + "Until L100: " +
+ EnumChatFormatting.YELLOW + "N/A";
+ } else {
+ etaMaxStr = EnumChatFormatting.AQUA + "Until L100: " +
+ EnumChatFormatting.YELLOW + Utils.prettyTime((long) (remainingMax) * 1000 * 60 * 60 / (long) xpGain);
+ }
+ }
+ }
+ }
+
+ String finalEtaStr = etaStr;
+ String finalEtaMaxStr = etaMaxStr;
+ String finalXpGainString = xpGainString;
+ String finalPetItemStr = petItemStr;
+ return new ArrayList<String>() {{
+ for (int index : NotEnoughUpdates.INSTANCE.config.petOverlay.petOverlayText) {
+ switch (index) {
+ case 0:
+ add(petName);
+ break;
+ case 1:
+ add(lvlStringShort);
+ break;
+ case 2:
+ add(lvlString);
+ break;
+ case 3:
+ add(finalXpGainString);
+ break;
+ case 4:
+ add(totalXpString);
+ break;
+ case 5:
+ add(finalPetItemStr);
+ break;
+ case 6:
+ if (finalEtaStr != null) add(finalEtaStr);
+ break;
+ case 7:
+ if (finalEtaMaxStr != null) add(finalEtaMaxStr);
+ break;
+ }
+ }
+ }};
+ }
+
+ @Override
+ public void updateFrequent() {
+ Pet currentPet = getCurrentPet();
+ if (!NotEnoughUpdates.INSTANCE.config.petOverlay.enablePetInfo || currentPet == null) {
+ overlayStrings = null;
+ } else {
+ overlayStrings = new ArrayList<>();
+
+ overlayStrings.addAll(createStringsForPet(currentPet, false));
+
+ Pet currentPet2 = getCurrentPet2();
+ if (currentPet2 != null) {
+ overlayStrings.add("");
+ overlayStrings.addAll(createStringsForPet(currentPet2, true));
+ }
+
+ }
+ }
+
+ public void update() {
+ if (!NotEnoughUpdates.INSTANCE.config.petOverlay.enablePetInfo &&
+ !NotEnoughUpdates.INSTANCE.config.itemOverlays.enableMonkeyCheck) {
+ overlayStrings = null;
+ return;
+ }
+
+ int updateTime = 60000;
+
+ if (NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
+ ProfileApiSyncer.getInstance().requestResync("petinfo", updateTime, () -> {}, PetInfoOverlay::getAndSetPet);
+ }
+
+ Pet currentPet = getCurrentPet();
+ if (currentPet == null) {
+ overlayStrings = null;
+ } else {
+ lastUpdate = System.currentTimeMillis();
+ levelXpLast = currentPet.petLevel.levelXp;
+ updatePetLevels();
+ }
+ }
+
+ private static GuiProfileViewer.PetLevel getMaxLevel(JsonArray levels, int offset) {
+ float xpTotal = 0;
+ float level = 1;
+ float currentLevelRequirement = 0;
+
+ for (int i = offset; i < offset + 99; i++) {
+ currentLevelRequirement = levels.get(i).getAsFloat();
+ xpTotal += currentLevelRequirement;
+ level += 1;
+ }
+
+ if (level <= 0) {
+ level = 1;
+ } else if (level > 100) {
+ level = 100;
+ }
+ GuiProfileViewer.PetLevel levelObj = new GuiProfileViewer.PetLevel();
+ levelObj.level = level;
+ levelObj.currentLevelRequirement = currentLevelRequirement;
+ levelObj.maxXP = xpTotal;
+ levelObj.levelPercentage = 1;
+ levelObj.levelXp = currentLevelRequirement - 5;
+ levelObj.totalXp = xpTotal - 5;
+ return levelObj;
+ }
+
+ private static GuiProfileViewer.PetLevel getLevel(
+ JsonArray levels,
+ int offset,
+ float xpThisLevel,
+ int xpMaxThisLevel
+ ) {
+ float xpTotal = 0;
+ float level = 1;
+ float currentLevelRequirement = 0;
+ float exp = xpThisLevel;
+
+ boolean addLevel = true;
+
+ for (int i = offset; i < offset + 99; i++) {
+ if (addLevel) {
+ currentLevelRequirement = levels.get(i).getAsFloat();
+ xpTotal += currentLevelRequirement;
+
+ if (currentLevelRequirement >= xpMaxThisLevel) {
+ addLevel = false;
+ } else {
+ exp += currentLevelRequirement;
+ level += 1;
+ }
+ } else {
+ xpTotal += levels.get(i).getAsFloat();
+ }
+ }
+
+ level += xpThisLevel / currentLevelRequirement;
+ if (level <= 0) {
+ level = 1;
+ } else if (level > 100) {
+ level = 100;
+ }
+ GuiProfileViewer.PetLevel levelObj = new GuiProfileViewer.PetLevel();
+ levelObj.level = level;
+ levelObj.currentLevelRequirement = currentLevelRequirement;
+ levelObj.maxXP = xpTotal;
+ levelObj.levelPercentage = xpThisLevel / currentLevelRequirement;
+ levelObj.levelXp = xpThisLevel;
+ levelObj.totalXp = exp;
+ return levelObj;
+ }
+
+ public static Pet getPetFromStack(String name, String[] lore) {
+ if (Constants.PETS == null || Constants.PETS.get("pet_levels") == null ||
+ Constants.PETS.get("pet_levels") instanceof JsonNull) {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
+ "\u00a7cInvalid PET constants. Please run " + EnumChatFormatting.BOLD + "/neuresetrepo" +
+ EnumChatFormatting.RESET + EnumChatFormatting.RED + " and " + EnumChatFormatting.BOLD + "restart your game" +
+ EnumChatFormatting.RESET + EnumChatFormatting.RED + " in order to fix. " + EnumChatFormatting.DARK_RED +
+ EnumChatFormatting.BOLD + "If that doesn't fix it" + EnumChatFormatting.RESET + EnumChatFormatting.RED +
+ ", please join discord.gg/moulberry and post in #neu-support"));
+ return null;
+ }
+
+ String petType = null;
+ Rarity rarity = null;
+ String heldItem = null;
+ GuiProfileViewer.PetLevel level = null;
+
+ Matcher petNameMatcher = PET_NAME_PATTERN.matcher(name);
+ if (petNameMatcher.matches()) {
+ String petStringMatch = petNameMatcher.group(1);
+
+ char colChar = petStringMatch.charAt(0);
+ EnumChatFormatting col = EnumChatFormatting.RESET;
+ for (EnumChatFormatting formatting : EnumChatFormatting.values()) {
+ if (formatting.toString().equals("\u00a7" + colChar)) {
+ col = formatting;
+ break;
+ }
+ }
+
+ rarity = Rarity.COMMON;
+ if (col != EnumChatFormatting.RESET) {
+ rarity = Rarity.getRarityFromColor(col);
+ }
+
+ petType = Utils.cleanColour(petStringMatch.substring(1))
+ .replaceAll("[^\\w ]", "").trim()
+ .replace(" ", "_").toUpperCase();
+ }
+ if (petType == null || rarity == null) {
+ return null;
+ }
+
+ for (String line : lore) {
+ Matcher xpLineMatcher = XP_LINE_PATTERN.matcher(Utils.cleanColour(line));
+ if (line.startsWith("\u00a76Held Item: ")) {
+ String after = line.substring("\u00a76Held Item: ".length());
+
+ if (itemMap == null) {
+ itemMap = new HashMap<>();
+
+ for (Map.Entry<String, JsonObject> entry : NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .entrySet()) {
+ boolean petItem = false;
+
+ if (entry.getKey().startsWith("PET_ITEM_")) {
+ petItem = true;
+ } else {
+ ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(entry.getValue());
+ if (stack.hasTagCompound()) {
+ String[] itemLore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stack.getTagCompound());
+
+ for (String itemLoreLine : itemLore) {
+ if (itemLoreLine.contains("PET ITEM")) {
+ petItem = true;
+ break;
+ }
+ }
+ }
+ }
+
+ if (petItem) {
+ ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(entry.getValue());
+ itemMap.put(stack.getDisplayName().replace("\u00a7f\u00a7f", ""), entry.getKey());
+ }
+ }
+ }
+
+ if (itemMap.containsKey(after)) {
+ heldItem = itemMap.get(after);
+ }
+ } else if (xpLineMatcher.matches()) {
+ String xpThisLevelS = xpLineMatcher.group(1);
+ String xpMaxThisLevelS = xpLineMatcher.group(2).toLowerCase();
+
+ try {
+ float xpThisLevel = Float.parseFloat(xpThisLevelS.replace(",", ""));
+
+ int mutiplier = 1;
+ char end = xpMaxThisLevelS.charAt(xpMaxThisLevelS.length() - 1);
+ if (end < '0' || end > '9') {
+ xpMaxThisLevelS = xpMaxThisLevelS.substring(0, xpMaxThisLevelS.length() - 1);
+
+ switch (end) {
+ case 'k':
+ mutiplier = 1000;
+ break;
+ case 'm':
+ mutiplier = 1000000;
+ break;
+ case 'b':
+ mutiplier = 1000000000;
+ break;
+ }
+ }
+ int xpMaxThisLevel = (int) (Float.parseFloat(xpMaxThisLevelS) * mutiplier);
+
+ level = getLevel(
+ Constants.PETS.get("pet_levels").getAsJsonArray(),
+ rarity.petOffset,
+ xpThisLevel,
+ xpMaxThisLevel
+ );
+ } catch (NumberFormatException ignored) {
+ }
+ } else if (line.equals("\u00a7b\u00a7lMAX LEVEL")) {
+ level = getMaxLevel(Constants.PETS.get("pet_levels").getAsJsonArray(), rarity.petOffset);
+ }
+ }
+
+ if (level != null) {
+ Pet pet = new Pet();
+ pet.petItem = heldItem;
+ pet.petLevel = level;
+ pet.rarity = rarity;
+ pet.petType = petType;
+ JsonObject petTypes = Constants.PETS.get("pet_types").getAsJsonObject();
+ pet.petXpType =
+ petTypes.has(pet.petType) ? petTypes.get(pet.petType.toUpperCase()).getAsString().toLowerCase() : "unknown";
+
+ return pet;
+ }
+
+ return null;
+ }
+
+ private static final HashMap<Integer, Integer> removeMap = new HashMap<>();
+
+ @SubscribeEvent
+ public void onTick(TickEvent.ClientTickEvent event) {
+ if (Minecraft.getMinecraft().currentScreen instanceof GuiChest && NEUEventListener.inventoryLoaded) {
+ GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
+ ContainerChest container = (ContainerChest) chest.inventorySlots;
+ IInventory lower = container.getLowerChestInventory();
+ String containerName = lower.getDisplayName().getUnformattedText();
+
+ if (lower.getSizeInventory() >= 54) {
+ int page = 0;
+ int maxPage = 1;
+ boolean isPets = false;
+
+ if (containerName.equals("Pets")) {
+ isPets = true;
+ } else {
+ Matcher matcher = PET_CONTAINER_PAGE.matcher(containerName);
+ if (matcher.matches()) {
+ try {
+ page = Integer.parseInt(matcher.group(1)) - 1;
+ maxPage = Integer.parseInt(matcher.group(2));
+ isPets = true;
+ } catch (NumberFormatException ignored) {
+ }
+ }
+ }
+
+ if (isPets) {
+ boolean hasItem = false;
+ for (int i = 0; i < lower.getSizeInventory(); i++) {
+ if (lower.getStackInSlot(i) != null) {
+ hasItem = true;
+ break;
+ }
+ }
+ if (!hasItem) return;
+
+ Set<Integer> clear = new HashSet<>();
+ for (int i : config.petMap.keySet()) {
+ if (i >= maxPage * 28) {
+ clear.add(i);
+ }
+ }
+ config.petMap.keySet().removeAll(clear);
+
+ Set<Integer> removeSet = new HashSet<>();
+ long currentTime = System.currentTimeMillis();
+ for (int index = 0; index < 28; index++) {
+ int petIndex = page * 28 + index;
+ int itemIndex = 10 + index + index / 7 * 2;
+
+ ItemStack stack = lower.getStackInSlot(itemIndex);
+
+ if (stack == null || !stack.hasTagCompound()) {
+ if (index < 27) {
+ int itemIndexNext = 10 + (index + 1) + (index + 1) / 7 * 2;
+ ItemStack stackNext = lower.getStackInSlot(itemIndexNext);
+
+ if (stackNext == null || !stackNext.hasTagCompound()) {
+ int old = removeMap.getOrDefault(petIndex, 0);
+ if (old >= 20) {
+ config.petMap.remove(petIndex);
+ } else {
+ removeSet.add(petIndex);
+ removeMap.put(petIndex, old + 1);
+ }
+ }
+ }
+ } else {
+ String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stack.getTagCompound());
+ Pet pet = getPetFromStack(stack.getDisplayName(), lore);
+ if (pet != null) {
+ config.petMap.put(petIndex, pet);
+
+ if (currentTime - lastPetSelect > 500) {
+ boolean foundDespawn = false;
+ for (String line : lore) {
+ if (line.equals("\u00a77\u00a7cClick to despawn.")) {
+ config.selectedPet = petIndex;
+ foundDespawn = true;
+ break;
+ }
+ if (line.equals("\u00a77\u00a77Selected pet: \u00a7cNone")) {
+ clearPet();
+ }
+ }
+ if (!foundDespawn && config.selectedPet == petIndex && currentTime - lastPetSelect > 500) {
+ clearPet();
+ }
+ }
+ }
+ }
+ }
+ removeMap.keySet().retainAll(removeSet);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected Vector2f getSize(List<String> strings) {
+ if (!NotEnoughUpdates.INSTANCE.config.petOverlay.petOverlayIcon) return super.getSize(strings);
+ return super.getSize(strings).translate(25, 0);
+ }
+
+ @Override
+ protected Vector2f getTextOffset() {
+ if (!NotEnoughUpdates.INSTANCE.config.petOverlay.petOverlayIcon) return super.getTextOffset();
+ if (this.styleSupplier.get() != TextOverlayStyle.BACKGROUND) return super.getTextOffset().translate(30, 0);
+ return super.getTextOffset().translate(25, 0);
+ }
+
+ @Override
+ public void renderDummy() {
+ super.renderDummy();
+
+ if (!NotEnoughUpdates.INSTANCE.config.petOverlay.petOverlayIcon) return;
+
+ JsonObject petItem = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("ROCK;0");
+ if (petItem != null) {
+ Vector2f position = getPosition(overlayWidth, overlayHeight);
+ int x = (int) position.x;
+ int y = (int) position.y;
+
+ ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(petItem);
+ GlStateManager.enableDepth();
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(x - 2, y - 2, 0);
+ GlStateManager.scale(2, 2, 1);
+ Utils.drawItemStack(stack, 0, 0);
+ GlStateManager.popMatrix();
+ }
+ }
+
+ @Override
+ public void render() {
+ super.render();
+
+ Pet currentPet = getCurrentPet();
+ if (currentPet == null) {
+ overlayStrings = null;
+ return;
+ }
+
+ if (overlayStrings == null) {
+ return;
+ }
+
+ if (!NotEnoughUpdates.INSTANCE.config.petOverlay.petOverlayIcon) return;
+ int mythicRarity = currentPet.rarity.petId;
+ if (currentPet.rarity.petId == 5) {
+ mythicRarity = 4;
+ }
+ JsonObject petItem = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(
+ currentPet.petType + ";" + mythicRarity);
+ if (petItem != null) {
+ Vector2f position = getPosition(overlayWidth, overlayHeight);
+ int x = (int) position.x;
+ int y = (int) position.y;
+
+ ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(petItem);
+ GlStateManager.enableDepth();
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(x - 2, y - 2, 0);
+ GlStateManager.scale(2, 2, 1);
+ Utils.drawItemStack(stack, 0, 0);
+ GlStateManager.popMatrix();
+ }
+
+ Pet currentPet2 = getCurrentPet2();
+ if (currentPet2 != null) {
+ JsonObject petItem2 = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(
+ currentPet2.petType + ";" + currentPet2.rarity.petId);
+ if (petItem2 != null) {
+ Vector2f position = getPosition(overlayWidth, overlayHeight);
+ int x = (int) position.x;
+ int y = (int) position.y + NotEnoughUpdates.INSTANCE.config.petOverlay.petOverlayText.size() * 10 + 10;
+
+ ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(petItem2);
+ GlStateManager.enableDepth();
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(x - 2, y - 2, 0);
+ GlStateManager.scale(2, 2, 1);
+ Utils.drawItemStack(stack, 0, 0);
+ GlStateManager.popMatrix();
+ }
+ }
+ }
+
+ public static float getBoostMultiplier(String boostName) {
+ if (boostName == null) return 1;
+ boostName = boostName.toLowerCase();
+ if (boostName.equalsIgnoreCase("PET_ITEM_ALL_SKILLS_BOOST_COMMON")) {
+ return 1.1f;
+ } else if (boostName.equalsIgnoreCase("ALL_SKILLS_SUPER_BOOST")) {
+ return 1.2f;
+ } else if (boostName.endsWith("epic")) {
+ return 1.5f;
+ } else if (boostName.endsWith("rare")) {
+ return 1.4f;
+ } else if (boostName.endsWith("uncommon")) {
+ return 1.3f;
+ } else if (boostName.endsWith("common")) {
+ return 1.2f;
+ } else {
+ return 1;
+ }
+ }
+
+ private static List<String> validXpTypes = Lists.newArrayList(
+ "mining",
+ "foraging",
+ "enchanting",
+ "farming",
+ "combat",
+ "fishing",
+ "alchemy"
+ );
+
+ public static void onStackClick(ItemStack stack, int windowId, int slotId, int mouseButtonClicked, int mode) {
+ if (mode != 0) return;
+ if (mouseButtonClicked != 0 && mouseButtonClicked != 1) return;
+
+ int slotIdMod = (slotId - 10) % 9;
+ if (slotId >= 10 && slotId <= 43 && slotIdMod >= 0 && slotIdMod <= 6 &&
+ Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
+ GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
+ ContainerChest container = (ContainerChest) chest.inventorySlots;
+ IInventory lower = container.getLowerChestInventory();
+ String containerName = lower.getDisplayName().getUnformattedText();
+
+ if (lower.getSizeInventory() >= 54 && windowId == container.windowId) {
+ int page = 0;
+ boolean isPets = false;
+
+ if (containerName.equals("Pets")) {
+ isPets = true;
+ } else {
+ Matcher matcher = PET_CONTAINER_PAGE.matcher(containerName);
+ if (matcher.matches()) {
+ try {
+ page = Integer.parseInt(matcher.group(1)) - 1;
+ isPets = true;
+ } catch (NumberFormatException ignored) {
+ }
+ }
+ }
+
+ if (isPets) {
+ ItemStack removingStack = lower.getStackInSlot(50);
+ boolean isRemoving =
+ removingStack != null && removingStack.getItem() == Items.dye && removingStack.getItemDamage() == 10;
+
+ int newSelected = (slotId - 10) - (slotId - 10) / 9 * 2 + page * 28;
+
+ lastPetSelect = System.currentTimeMillis();
+
+ if (isRemoving) {
+ if (newSelected == config.selectedPet) {
+ clearPet();
+ } else if (config.selectedPet > newSelected) {
+ config.selectedPet--;
+ }
+ } else {
+ setCurrentPet(newSelected);
+
+ String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stack.getTagCompound());
+ Pet pet = getPetFromStack(stack.getDisplayName(), lore);
+ if (pet != null) {
+ config.petMap.put(config.selectedPet, pet);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public static float getXpGain(Pet pet, float xp, String xpType) {
+ if (pet.petLevel.level >= 100) return 0;
+
+ if (validXpTypes == null)
+ validXpTypes = Lists.newArrayList("mining", "foraging", "enchanting", "farming", "combat", "fishing", "alchemy");
+ if (!validXpTypes.contains(xpType.toLowerCase())) return 0;
+
+ float tamingPercent = 1.0f + (config.tamingLevel / 100f);
+ xp = xp * tamingPercent;
+ xp = xp + (xp * config.beastMultiplier / 100f);
+ if (pet.petXpType != null && !pet.petXpType.equalsIgnoreCase(xpType)) {
+ xp = xp / 3f;
+
+ if (xpType.equalsIgnoreCase("alchemy") || xpType.equalsIgnoreCase("enchanting")) {
+ xp = xp / 4f;
+ }
+ }
+ if (xpType.equalsIgnoreCase("mining") || xpType.equalsIgnoreCase("fishing")) {
+ xp = xp * 1.5f;
+ }
+ if (pet.petItem != null) {
+ Matcher petItemMatcher = XP_BOOST_PATTERN.matcher(pet.petItem);
+ if ((petItemMatcher.matches() && petItemMatcher.group(1).equalsIgnoreCase(xpType))
+ || pet.petItem.equalsIgnoreCase("ALL_SKILLS_SUPER_BOOST")) {
+ xp = xp * getBoostMultiplier(pet.petItem);
+ }
+ }
+ return xp;
+ }
+
+ private final HashMap<String, Float> skillInfoMapLast = new HashMap<>();
+
+ public void updatePetLevels() {
+ HashMap<String, XPInformation.SkillInfo> skillInfoMap = XPInformation.getInstance().getSkillInfoMap();
+
+ long currentTime = System.currentTimeMillis();
+
+ float totalGain = 0;
+
+ Pet currentPet = getCurrentPet();
+ for (Map.Entry<String, XPInformation.SkillInfo> entry : skillInfoMap.entrySet()) {
+ if (entry.getValue().level == 50 && entry.getValue().fromApi) continue;
+
+ float skillXp = entry.getValue().totalXp;
+ if (skillInfoMapLast.containsKey(entry.getKey())) {
+ float skillXpLast = skillInfoMapLast.get(entry.getKey());
+
+ if (skillXpLast <= 0) {
+ skillInfoMapLast.put(entry.getKey(), skillXp);
+ } else if (skillXp > skillXpLast) {
+ lastXpGain = currentTime;
+
+ float deltaXp = skillXp - skillXpLast;
+
+ float gain = getXpGain(currentPet, deltaXp, entry.getKey().toUpperCase());
+ totalGain += gain;
+
+ skillInfoMapLast.put(entry.getKey(), skillXp);
+ }
+ } else {
+ skillInfoMapLast.put(entry.getKey(), skillXp);
+ }
+ }
+
+ xpGainHourLast = xpGainHour;
+ if (xpAddTimer > 0 || totalGain > 0) {
+ if (totalGain > 0) {
+ xpAddTimer = 10;
+ } else {
+ xpAddTimer--;
+ }
+
+ currentPet.petLevel.totalXp += totalGain;
+
+ xpGainQueue.add(0, totalGain);
+ while (xpGainQueue.size() > 30) {
+ xpGainQueue.removeLast();
+ }
+
+ if (xpGainQueue.size() > 1) {
+ float tot = 0;
+ float greatest = 0;
+ for (float f : xpGainQueue) {
+ tot += f;
+ greatest = Math.max(greatest, f);
+ }
+
+ xpGainHour = (tot - greatest) * (60 * 60) / (xpGainQueue.size() - 1);
+ }
+ }
+
+ JsonObject petsJson = Constants.PETS;
+ if (currentPet != null && petsJson != null) {
+ currentPet.petLevel = GuiProfileViewer.getPetLevel(
+ currentPet.petItem,
+ currentPet.rarity.name(),
+ currentPet.petLevel.totalXp
+ );
+ }
+ }
+
+ public String roundFloat(float f) {
+ if (f % 1 < 0.05f) {
+ return NumberFormat.getNumberInstance().format((int) f);
+ } else {
+ String s = Utils.floatToString(f, 1);
+ if (s.contains(".")) {
+ return NumberFormat.getNumberInstance().format((int) f) + '.' + s.split("\\.")[1];
+ } else if (s.contains(",")) {
+ return NumberFormat.getNumberInstance().format((int) f) + ',' + s.split(",")[1];
+ } else {
+ return s;
+ }
+ }
+ }
+
+ @SubscribeEvent
+ public void switchWorld(WorldEvent.Load event) {
+ if (NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
+ ProfileApiSyncer.getInstance().requestResync("petinfo_quick", 10000, () -> {}, PetInfoOverlay::getAndSetPet);
+ }
+ }
+
+ private int lastLevelHovered = 0;
+ private String lastItemHovered = null;
+
+ private static HashMap<String, String> itemMap = null;
+
+ @SubscribeEvent(priority = EventPriority.HIGHEST, receiveCanceled = true)
+ public void onTooltip(ItemTooltipEvent event) {
+ for (String line : event.toolTip) {
+ if (line.startsWith("\u00a7o\u00a77[Lvl ")) {
+ lastItemHovered = null;
+
+ String after = line.substring("\u00a7o\u00a77[Lvl ".length());
+ if (after.contains("]")) {
+ String levelStr = after.split("]")[0];
+
+ try {
+ lastLevelHovered = Integer.parseInt(levelStr.trim());
+ } catch (Exception ignored) {
+ }
+ }
+ } else if (line.startsWith("\u00a75\u00a7o\u00a76Held Item: ")) {
+ String after = line.substring("\u00a75\u00a7o\u00a76Held Item: ".length());
+
+ if (itemMap == null) {
+ itemMap = new HashMap<>();
+
+ for (Map.Entry<String, JsonObject> entry : NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .entrySet()) {
+ if (entry.getKey().equals("ALL_SKILLS_SUPER_BOOST") ||
+ XP_BOOST_PATTERN.matcher(entry.getKey()).matches()) {
+ ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(entry.getValue());
+ itemMap.put(stack.getDisplayName(), entry.getKey());
+ }
+ }
+ }
+
+ if (itemMap.containsKey(after)) {
+ lastItemHovered = itemMap.get(after);
+ }
+ }
+ }
+ }
+
+ private static final Pattern AUTOPET_EQUIP = Pattern.compile(
+ "\u00a7cAutopet \u00a7eequipped your \u00a77\\[Lvl (\\d+)] \u00a7(.{2,})\u00a7e! \u00a7a\u00a7lVIEW RULE\u00a7r");
+
+ @SubscribeEvent(priority = EventPriority.HIGHEST)
+ public void onChatReceived(ClientChatReceivedEvent event) {
+ NEUConfig config = NotEnoughUpdates.INSTANCE.config;
+ if (NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() &&
+ (config.petOverlay.enablePetInfo || config.itemOverlays.enableMonkeyCheck || config.petOverlay.petInvDisplay)) {
+ if (event.type == 0) {
+ String chatMessage = Utils.cleanColour(event.message.getUnformattedText());
+
+ Matcher autopetMatcher = AUTOPET_EQUIP.matcher(event.message.getFormattedText());
+ if (event.message.getUnformattedText().startsWith("You summoned your") ||
+ System.currentTimeMillis() - NEUOverlay.cachedPetTimer < 500) {
+ NEUOverlay.cachedPetTimer = System.currentTimeMillis();
+ NEUOverlay.shouldUseCachedPet = false;
+ } else if (autopetMatcher.matches()) {
+ NEUOverlay.shouldUseCachedPet = false;
+ try {
+ lastLevelHovered = Integer.parseInt(autopetMatcher.group(1));
+ } catch (NumberFormatException ignored) {
+ }
+
+ String petStringMatch = autopetMatcher.group(2);
+ char colChar = petStringMatch.charAt(0);
+ EnumChatFormatting col = EnumChatFormatting.RESET;
+ for (EnumChatFormatting formatting : EnumChatFormatting.values()) {
+ if (formatting.toString().equals("\u00a7" + colChar)) {
+ col = formatting;
+ break;
+ }
+
+ }
+ Rarity rarity = Rarity.COMMON;
+ if (col != EnumChatFormatting.RESET) {
+ rarity = Rarity.getRarityFromColor(col);
+ }
+
+ String pet = Utils.cleanColour(petStringMatch.substring(1))
+ .replaceAll("[^\\w ]", "").trim()
+ .replace(" ", "_").toUpperCase();
+
+ setCurrentPet(getClosestPetIndex(pet, rarity.petId, "", lastLevelHovered));
+ if (PetInfoOverlay.config.selectedPet == -1) {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
+ EnumChatFormatting.RED + "[NEU] Can't find pet \u00a7" + petStringMatch +
+ EnumChatFormatting.RED + " try revisiting all pages of /pets."));
+ }
+ } else if ((chatMessage.toLowerCase().startsWith("you despawned your")) || (chatMessage.toLowerCase().contains(
+ "switching to profile"))
+ || (chatMessage.toLowerCase().contains("transferring you to a new island..."))) {
+ clearPet();
+ }
+ }
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java
index 7459c4a4..743625f5 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java
@@ -2,7 +2,6 @@ package io.github.moulberry.notenoughupdates.miscfeatures;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
-import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.core.config.KeybindHelper;
import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils;
@@ -20,601 +19,678 @@ import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.inventory.Slot;
-import net.minecraft.item.ItemStack;
-import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.GuiScreenEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
-import net.minecraftforge.fml.common.gameevent.TickEvent;
import org.apache.commons.lang3.tuple.Triple;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.vector.Vector2f;
-import org.lwjgl.util.vector.Vector3f;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.function.Consumer;
-import java.util.zip.GZIPInputStream;
-import java.util.zip.GZIPOutputStream;
public class SlotLocking {
-
- private static final SlotLocking INSTANCE = new SlotLocking();
-
-
- private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
-
- private static final LockedSlot DEFAULT_LOCKED_SLOT = new LockedSlot();
- private final ResourceLocation LOCK = new ResourceLocation("notenoughupdates:slotlocking/lock.png");
- private final ResourceLocation BOUND = new ResourceLocation("notenoughupdates:slotlocking/bound.png");
-
- public static SlotLocking getInstance() {
- return INSTANCE;
- }
-
- public static class LockedSlot {
- public boolean locked = false;
- public int boundTo = -1;
- }
-
- public static class SlotLockData {
- public LockedSlot[] lockedSlots = new LockedSlot[40];
- }
-
- public static class SlotLockProfile {
- int currentProfile = 0;
-
- public SlotLockData[] slotLockData = new SlotLockData[9];
- }
-
- public static class SlotLockingConfig {
- public HashMap<String, SlotLockProfile> profileData = new HashMap<>();
- }
-
- private SlotLockingConfig config = new SlotLockingConfig();
- private boolean lockKeyHeld = false;
- private Slot pairingSlot = null;
-
- private Slot realSlot = null;
-
- public void setRealSlot(Slot slot){
- realSlot = slot;
- }
-
- public Slot getRealSlot(){ return realSlot;}
-
- public void loadConfig(File file) {
- try(BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) {
- config = GSON.fromJson(reader, SlotLockingConfig.class);
- } catch(Exception ignored) { }
- if(config == null) {
- config = new SlotLockingConfig();
- }
- }
-
- public void changedSlot(int slotNumber){
- int pingModifier = NotEnoughUpdates.INSTANCE.config.slotLocking.slotLockSwapDelay;
- if(pingModifier == 0){ return; };
- if(!isSlotIndexLocked(slotNumber)){ return;}
- long currentTimeMilis = System.currentTimeMillis();
-
- for (int i = 0; i < slotChanges.length; i++) {
- if(i != slotNumber && slotChanges[i] != 0 && (slotChanges[i] + (long) pingModifier) > currentTimeMilis){
- slotChanges[i] = 0;
- }
- }
- slotChanges[slotNumber] = currentTimeMilis;
- }
-
- public boolean isSwapedSlotLocked(){
- int pingModifier = NotEnoughUpdates.INSTANCE.config.slotLocking.slotLockSwapDelay;
- if(pingModifier == 0){ return false; };
- long currentTimeMilis = System.currentTimeMillis();
-
- for (int i = 0; i < slotChanges.length; i++) {
- if (slotChanges[i] != 0 && isSlotIndexLocked(i) && (slotChanges[i] + (long) pingModifier) > currentTimeMilis) {
- return true;
- }
- }
- return false;
- }
-
- private long[] slotChanges = new long[9];
-
- public void saveConfig(File file) {
- try {
- file.createNewFile();
- try(BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8))) {
- writer.write(GSON.toJson(config));
- }
- } catch(Exception ignored) {
- ignored.printStackTrace();
- }
- }
-
- private LockedSlot[] getDataForProfile() {
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotLocking) return null;
-
- String profileName = SBInfo.getInstance().currentProfile;
- if(profileName == null) profileName = "generic";
-
- SlotLockProfile profile = config.profileData.computeIfAbsent(profileName,
- k->new SlotLockProfile());
-
- if(profile.currentProfile < 0) profile.currentProfile = 0;
- if(profile.currentProfile >= 9) profile.currentProfile = 8;
-
- if(profile.slotLockData[profile.currentProfile] == null) {
- profile.slotLockData[profile.currentProfile] = new SlotLockData();
- }
-
- return profile.slotLockData[profile.currentProfile].lockedSlots;
- }
-
- private LockedSlot getLockedSlot(LockedSlot[] lockedSlots, int index) {
- if(lockedSlots == null) {
- return DEFAULT_LOCKED_SLOT;
- }
-
- LockedSlot slot = lockedSlots[index];
-
- if(slot == null) {
- return DEFAULT_LOCKED_SLOT;
- }
-
- return slot;
- }
-
- @SubscribeEvent(priority = EventPriority.LOW)
- public void keyboardInput(GuiScreenEvent.KeyboardInputEvent.Pre event) {
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotLocking) {
- return;
- }
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) {
- return;
- }
- GuiContainer container = (GuiContainer) Minecraft.getMinecraft().currentScreen;
-
- int key = NotEnoughUpdates.INSTANCE.config.slotLocking.slotLockKey;
- if(!lockKeyHeld && KeybindHelper.isKeyPressed(key) && !Keyboard.isRepeatEvent()) {
- 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;
-
- Slot slot = container.getSlotAtPosition(mouseX, mouseY);
- if(slot != null && slot.getSlotIndex() != 8 && slot.inventory == Minecraft.getMinecraft().thePlayer.inventory) {
- int slotNum = slot.getSlotIndex();
- if(slotNum >= 0 && slotNum <= 39) {
- boolean isHotbar = slotNum < 9;
- boolean isInventory = !isHotbar && slotNum < 36;
- boolean isArmor = !isHotbar && !isInventory;
-
- if(isInventory || isArmor) {
- pairingSlot = slot;
- } else {
- pairingSlot = null;
- }
-
- LockedSlot[] lockedSlots = getDataForProfile();
-
- if(lockedSlots != null) {
- if(lockedSlots[slotNum] == null) {
- lockedSlots[slotNum] = new LockedSlot();
- }
- lockedSlots[slotNum].locked = !lockedSlots[slotNum].locked;
- lockedSlots[slotNum].boundTo = -1;
-
- if(NotEnoughUpdates.INSTANCE.config.slotLocking.slotLockSound) {
- float vol = NotEnoughUpdates.INSTANCE.config.slotLocking.slotLockSoundVol/100f;
- if(vol > 0) {
- if(vol > 1) vol = 1;
- final float volF = vol;
- final boolean locked = lockedSlots[slotNum].locked;
-
- ISound sound = new PositionedSound(new ResourceLocation("random.orb")) {{
- volume = volF;
- pitch = locked ? 0.943f : 0.1f;
- repeat = false;
- repeatDelay = 0;
- attenuationType = ISound.AttenuationType.NONE;
- }};
-
- float oldLevel = Minecraft.getMinecraft().gameSettings.getSoundLevel(SoundCategory.PLAYERS);
- Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.PLAYERS, 1);
- Minecraft.getMinecraft().getSoundHandler().playSound(sound);
- Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.PLAYERS, oldLevel);
- }
- }
-
- if(isHotbar && lockedSlots[slotNum].locked) {
- for(int i = 9; i <= 39; i++) {
- if(lockedSlots[i] != null && lockedSlots[i].boundTo == slotNum) {
- lockedSlots[i].boundTo = -1;
- }
- }
- }
- }
- }
- }
- }
- lockKeyHeld = KeybindHelper.isKeyDown(key);
- if(!lockKeyHeld) {
- pairingSlot = null;
- }
- }
-
- @SubscribeEvent(priority = EventPriority.LOW)
- public void mouseEvent(GuiScreenEvent.MouseInputEvent.Pre event) {
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotLocking) {
- return;
- }
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) {
- return;
- }
- GuiContainer container = (GuiContainer) Minecraft.getMinecraft().currentScreen;
-
- if(NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotBinding && lockKeyHeld && pairingSlot != null) {
- 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;
-
- Slot slot = container.getSlotAtPosition(mouseX, mouseY);
- if(slot != null && slot.getSlotIndex() != 8 && slot.inventory == Minecraft.getMinecraft().thePlayer.inventory) {
- int slotNum = slot.getSlotIndex();
- if(slotNum >= 0 && slotNum <= 39) {
-
- boolean isHotbar = slotNum < 9;
- boolean isInventory = !isHotbar && slotNum < 36;
- boolean isArmor = !isHotbar && !isInventory;
-
- int pairingNum = pairingSlot.getSlotIndex();
- if(isHotbar && slotNum != pairingNum) {
- LockedSlot[] lockedSlots = getDataForProfile();
- if(lockedSlots != null) {
- if(lockedSlots[slotNum] == null) {
- lockedSlots[slotNum] = new LockedSlot();
- }
- if(!lockedSlots[slotNum].locked) {
- if(lockedSlots[pairingNum] == null) {
- lockedSlots[pairingNum] = new LockedSlot();
- }
-
- lockedSlots[pairingNum].boundTo = slotNum;
- lockedSlots[pairingNum].locked = false;
-
- lockedSlots[slotNum].boundTo = pairingNum;
- }
- }
- }
- }
- } else {
- int pairingNum = pairingSlot.getSlotIndex();
- LockedSlot[] lockedSlots = getDataForProfile();
- if(lockedSlots != null && lockedSlots[pairingNum] != null) {
- if(lockedSlots[pairingNum].boundTo >= 0) {
- lockedSlots[lockedSlots[pairingNum].boundTo] = null;
- }
- lockedSlots[pairingNum] = null;
- }
- }
- }
- }
-
- public void toggleLock(int lockIndex) {
- if(lockIndex == 8) return;
- LockedSlot[] lockedSlots = getDataForProfile();
-
- if(lockedSlots != null) {
- if(lockedSlots[lockIndex] == null) {
- lockedSlots[lockIndex] = new LockedSlot();
- }
- lockedSlots[lockIndex].locked = !lockedSlots[lockIndex].locked;
- lockedSlots[lockIndex].boundTo = -1;
-
- if(NotEnoughUpdates.INSTANCE.config.slotLocking.slotLockSound) {
- float vol = NotEnoughUpdates.INSTANCE.config.slotLocking.slotLockSoundVol/100f;
- if(vol > 0) {
- if(vol > 1) vol = 1;
- final float volF = vol;
- final boolean locked = lockedSlots[lockIndex].locked;
-
- ISound sound = new PositionedSound(new ResourceLocation("random.orb")) {{
- volume = volF;
- pitch = locked ? 0.943f : 0.1f;
- repeat = false;
- repeatDelay = 0;
- attenuationType = ISound.AttenuationType.NONE;
- }};
-
- float oldLevel = Minecraft.getMinecraft().gameSettings.getSoundLevel(SoundCategory.PLAYERS);
- Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.PLAYERS, 1);
- Minecraft.getMinecraft().getSoundHandler().playSound(sound);
- Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.PLAYERS, oldLevel);
- }
- }
-
- if(lockIndex < 9 && lockedSlots[lockIndex].locked) {
- for(int i = 9; i <= 39; i++) {
- if(lockedSlots[i] != null && lockedSlots[i].boundTo == lockIndex) {
- lockedSlots[i].boundTo = -1;
- }
- }
- }
- }
- }
-
- @SubscribeEvent(priority = EventPriority.LOW)
- public void drawScreenEvent(GuiScreenEvent.DrawScreenEvent.Post event) {
- if(NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotBinding && !event.isCanceled() && pairingSlot != null && lockKeyHeld) {
- LockedSlot[] lockedSlots = getDataForProfile();
- LockedSlot lockedSlot = getLockedSlot(lockedSlots, pairingSlot.getSlotIndex());
- if(lockedSlot.boundTo >= 0 && lockedSlot.boundTo < 8) {
- return;
- }
-
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) {
- return;
- }
- GuiContainer container = (GuiContainer) Minecraft.getMinecraft().currentScreen;
-
- int x1 = container.guiLeft+pairingSlot.xDisplayPosition+8;
- int y1 = container.guiTop+pairingSlot.yDisplayPosition+8;
- int x2 = event.mouseX;
- int y2 = event.mouseY;
-
- if(x2 > x1-8 && x2 < x1+8 &&
- y2 > y1-8 && y2 < y1+8) {
- return;
- }
-
- drawLinkArrow(x1, y1, x2, y2);
- }
- }
-
- private void drawLinkArrow(int x1, int y1, int x2, int y2) {
- GlStateManager.color(0x33/255f, 0xee/255f, 0xdd/255f, 1f);
- GlStateManager.disableLighting();
- RenderHelper.disableStandardItemLighting();
- GlStateManager.disableTexture2D();
- GlStateManager.enableBlend();
- GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
-
- GlStateManager.translate(0, 0, 500);
- drawLine(x1, y1, x2, y2);
- GlStateManager.translate(0, 0, -500);
-
- GlStateManager.enableTexture2D();
- }
-
- private void drawLine(int x1, int y1, int x2, int y2) {
- Vector2f vec = new Vector2f(x2 - x1, y2 - y1);
- vec.normalise(vec);
- Vector2f side = new Vector2f(vec.y, -vec.x);
-
- GL11.glLineWidth(1f);
- GL11.glEnable(GL11.GL_LINE_SMOOTH);
-
- Tessellator tessellator = Tessellator.getInstance();
- WorldRenderer worldrenderer = tessellator.getWorldRenderer();
-
- int lines = 6;
- for(int i=0; i<lines; i++) {
- worldrenderer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION);
- worldrenderer.pos(x1-side.x+side.x*i/lines, y1-side.y+side.y*i/lines, 0.0D).endVertex();
- worldrenderer.pos(x2-side.x+side.x*i/lines, y2-side.y+side.y*i/lines, 0.0D).endVertex();
- tessellator.draw();
- }
- }
-
- public void onWindowClick(Slot slotIn, int slotId, int clickedButton, int clickType, Consumer<Triple<Integer, Integer, Integer>> consumer) {
- LockedSlot locked = getLockedSlot(slotIn);
- if(locked == null) {
- return;
- } else if(locked.locked || (clickType == 2 && SlotLocking.getInstance().isSlotIndexLocked(clickedButton))) {
- consumer.accept(null);
- } else if(NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotBinding && clickType == 1 && locked.boundTo != -1) {
- GuiContainer container = (GuiContainer) Minecraft.getMinecraft().currentScreen;
- Slot boundSlot = container.inventorySlots.getSlotFromInventory(Minecraft.getMinecraft().thePlayer.inventory, locked.boundTo);
-
- if(boundSlot == null) {
- return;
- }
-
- LockedSlot boundLocked = getLockedSlot(boundSlot);
-
- int id = slotIn.getSlotIndex();
- if(id >= 9 && locked.boundTo >= 0 && locked.boundTo < 8) {
- if(!boundLocked.locked) {
- consumer.accept(Triple.of(slotId, locked.boundTo, 2));
- if(boundLocked == DEFAULT_LOCKED_SLOT) {
- LockedSlot[] lockedSlots = getDataForProfile();
- lockedSlots[locked.boundTo] = new LockedSlot();
- lockedSlots[locked.boundTo].boundTo = id;
- } else {
- boundLocked.boundTo = id;
- }
- }
- } else if(id >= 0 && id < 8 && locked.boundTo >= 9 && locked.boundTo <= 39) {
- if(boundLocked.locked || boundLocked.boundTo != id) {
- locked.boundTo = -1;
- } else {
- int boundTo = boundSlot.slotNumber;
- consumer.accept(Triple.of(boundTo, id, 2));
- }
- }
- } else if(NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotBinding && locked.boundTo != -1 && NotEnoughUpdates.INSTANCE.config.slotLocking.bindingAlsoLocks) {
- consumer.accept(null);
- }
- }
-
- public void drawSlot(Slot slot) {
- LockedSlot locked = getLockedSlot(slot);
- if(locked != null) {
- if(locked.locked) {
- GlStateManager.translate(0, 0, 400);
- Minecraft.getMinecraft().getTextureManager().bindTexture(LOCK);
- GlStateManager.color(1, 1, 1, 0.5f);
- GlStateManager.depthMask(false);
- RenderUtils.drawTexturedRect(slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, 0, 1, 0, 1, GL11.GL_NEAREST);
- GlStateManager.depthMask(true);
- GlStateManager.enableBlend();
- GlStateManager.translate(0, 0, -400);
- } else if(NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotBinding && slot.canBeHovered() && locked.boundTo >= 0 && locked.boundTo <= 39) {
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) {
- return;
- }
- GuiContainer container = (GuiContainer) Minecraft.getMinecraft().currentScreen;
-
- 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;
-
- Slot boundSlot = container.inventorySlots.getSlotFromInventory(Minecraft.getMinecraft().thePlayer.inventory, locked.boundTo);
- if(boundSlot == null) {
- return;
- }
-
- boolean hoverOverSlot = container.isMouseOverSlot(slot, mouseX, mouseY);
-
- if(hoverOverSlot || slot.getSlotIndex() >= 9) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(BOUND);
- GlStateManager.color(1, 1, 1, 0.7f);
- GlStateManager.depthMask(false);
- RenderUtils.drawTexturedRect(slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, 0, 1, 0, 1, GL11.GL_NEAREST);
- GlStateManager.depthMask(true);
- GlStateManager.enableBlend();
-
- //Rerender Text over Top
- if(slot.getStack() != null) {
- Minecraft.getMinecraft().getRenderItem().renderItemOverlayIntoGUI(Minecraft.getMinecraft().fontRendererObj, slot.getStack(),
- slot.xDisplayPosition, slot.yDisplayPosition, null);
- }
- } else if(pairingSlot != null && lockKeyHeld && slot.getSlotIndex() < 8) {
- int x1 = container.guiLeft+pairingSlot.xDisplayPosition;
- int y1 = container.guiTop+pairingSlot.yDisplayPosition;
-
- if(mouseX <= x1 || mouseX >= x1+16 ||
- mouseY <= y1 || mouseY >= y1+16) {
- Gui.drawRect(slot.xDisplayPosition, slot.yDisplayPosition, slot.xDisplayPosition+16, slot.yDisplayPosition+16, 0x80ffffff);
- }
- }
-
- if(hoverOverSlot) {
- LockedSlot boundLocked = getLockedSlot(boundSlot);
- if(boundLocked == null || boundLocked.locked ||
- (boundSlot.getSlotIndex() >= 9 && boundLocked.boundTo != slot.getSlotIndex())) {
- locked.boundTo = -1;
- return;
- }
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(BOUND);
- GlStateManager.color(1, 1, 1, 0.7f);
- GlStateManager.depthMask(false);
- RenderUtils.drawTexturedRect(boundSlot.xDisplayPosition, boundSlot.yDisplayPosition, 16, 16, 0, 1, 0, 1, GL11.GL_NEAREST);
- GlStateManager.depthMask(true);
- GlStateManager.enableBlend();
-
- //Rerender Text over Top
- if(boundSlot.getStack() != null) {
- Minecraft.getMinecraft().getRenderItem().renderItemOverlayIntoGUI(Minecraft.getMinecraft().fontRendererObj, boundSlot.getStack(),
- boundSlot.xDisplayPosition, boundSlot.yDisplayPosition, null);
- }
-
- int maxIter = 100;
- float x1 = slot.xDisplayPosition+8;
- float y1 = slot.yDisplayPosition+8;
- float x2 = boundSlot.xDisplayPosition+8;
- float y2 = boundSlot.yDisplayPosition+8;
- Vector2f vec = new Vector2f(x2 - x1, y2 - y1);
- vec.normalise(vec);
-
- while(x1 > slot.xDisplayPosition && x1 < slot.xDisplayPosition+16 &&
- y1 > slot.yDisplayPosition && y1 < slot.yDisplayPosition+16) {
- if(maxIter-- < 50) break;
- x1 += vec.x;
- y1 += vec.y;
- }
- while(x2 > boundSlot.xDisplayPosition && x2 < boundSlot.xDisplayPosition+16 &&
- y2 > boundSlot.yDisplayPosition && y2 < boundSlot.yDisplayPosition+16) {
- if(maxIter-- < 0) break;
- x2 -= vec.x;
- y2 -= vec.y;
- }
-
- GlStateManager.translate(0, 0, 200);
- drawLinkArrow((int)x1, (int)y1, (int)x2, (int)y2);
- GlStateManager.translate(0, 0, -200);
- }
- } else if(NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotBinding && slot.getSlotIndex() < 8 && pairingSlot != null && lockKeyHeld) {
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) {
- return;
- }
- GuiContainer container = (GuiContainer) Minecraft.getMinecraft().currentScreen;
-
- 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 x1 = container.guiLeft+pairingSlot.xDisplayPosition;
- int y1 = container.guiTop+pairingSlot.yDisplayPosition;
-
- if(mouseX <= x1 || mouseX >= x1+16 ||
- mouseY <= y1 || mouseY >= y1+16) {
- Gui.drawRect(slot.xDisplayPosition, slot.yDisplayPosition, slot.xDisplayPosition+16, slot.yDisplayPosition+16, 0x80ffffff);
- }
- }
- }
- }
-
- public LockedSlot getLockedSlot(Slot slot) {
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotLocking) return null;
- if(slot == null) {
- return null;
- }
- if(slot.inventory != Minecraft.getMinecraft().thePlayer.inventory) {
- return null;
- }
- int index = slot.getSlotIndex();
- if(index < 0 || index > 39) {
- return null;
- }
- return getLockedSlotIndex(index);
- }
-
- public LockedSlot getLockedSlotIndex(int index) {
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotLocking) {
- return null;
- }
-
- LockedSlot[] lockedSlots = getDataForProfile();
- if(lockedSlots == null) {
- return null;
- }
- return getLockedSlot(lockedSlots, index);
- }
-
- public boolean isSlotLocked(Slot slot) {
- LockedSlot locked = getLockedSlot(slot);
- return locked != null && (locked.locked || (NotEnoughUpdates.INSTANCE.config.slotLocking.bindingAlsoLocks && locked.boundTo != -1));
- }
-
- public boolean isSlotIndexLocked(int index) {
- LockedSlot locked = getLockedSlotIndex(index);
-
- return locked != null && (locked.locked || (NotEnoughUpdates.INSTANCE.config.slotLocking.bindingAlsoLocks && locked.boundTo != -1));
- }
-
-
+ private static final SlotLocking INSTANCE = new SlotLocking();
+
+ private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
+
+ private static final LockedSlot DEFAULT_LOCKED_SLOT = new LockedSlot();
+ private final ResourceLocation LOCK = new ResourceLocation("notenoughupdates:slotlocking/lock.png");
+ private final ResourceLocation BOUND = new ResourceLocation("notenoughupdates:slotlocking/bound.png");
+
+ public static SlotLocking getInstance() {
+ return INSTANCE;
+ }
+
+ public static class LockedSlot {
+ public boolean locked = false;
+ public int boundTo = -1;
+ }
+
+ public static class SlotLockData {
+ public LockedSlot[] lockedSlots = new LockedSlot[40];
+ }
+
+ public static class SlotLockProfile {
+ int currentProfile = 0;
+
+ public SlotLockData[] slotLockData = new SlotLockData[9];
+ }
+
+ public static class SlotLockingConfig {
+ public HashMap<String, SlotLockProfile> profileData = new HashMap<>();
+ }
+
+ private SlotLockingConfig config = new SlotLockingConfig();
+ private boolean lockKeyHeld = false;
+ private Slot pairingSlot = null;
+
+ private Slot realSlot = null;
+
+ public void setRealSlot(Slot slot) {
+ realSlot = slot;
+ }
+
+ public Slot getRealSlot() {return realSlot;}
+
+ public void loadConfig(File file) {
+ try (
+ BufferedReader reader = new BufferedReader(new InputStreamReader(
+ new FileInputStream(file),
+ StandardCharsets.UTF_8
+ ))
+ ) {
+ config = GSON.fromJson(reader, SlotLockingConfig.class);
+ } catch (Exception ignored) {
+ }
+ if (config == null) {
+ config = new SlotLockingConfig();
+ }
+ }
+
+ public void changedSlot(int slotNumber) {
+ int pingModifier = NotEnoughUpdates.INSTANCE.config.slotLocking.slotLockSwapDelay;
+ if (pingModifier == 0) {
+ return;
+ }
+ if (!isSlotIndexLocked(slotNumber)) {
+ return;
+ }
+ long currentTimeMilis = System.currentTimeMillis();
+
+ for (int i = 0; i < slotChanges.length; i++) {
+ if (i != slotNumber && slotChanges[i] != 0 && (slotChanges[i] + (long) pingModifier) > currentTimeMilis) {
+ slotChanges[i] = 0;
+ }
+ }
+ slotChanges[slotNumber] = currentTimeMilis;
+ }
+
+ public boolean isSwapedSlotLocked() {
+ int pingModifier = NotEnoughUpdates.INSTANCE.config.slotLocking.slotLockSwapDelay;
+ if (pingModifier == 0) {
+ return false;
+ }
+ long currentTimeMilis = System.currentTimeMillis();
+
+ for (int i = 0; i < slotChanges.length; i++) {
+ if (slotChanges[i] != 0 && isSlotIndexLocked(i) && (slotChanges[i] + (long) pingModifier) > currentTimeMilis) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private final long[] slotChanges = new long[9];
+
+ public void saveConfig(File file) {
+ try {
+ file.createNewFile();
+ try (
+ BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
+ new FileOutputStream(file),
+ StandardCharsets.UTF_8
+ ))
+ ) {
+ writer.write(GSON.toJson(config));
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private LockedSlot[] getDataForProfile() {
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() ||
+ !NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotLocking)
+ return null;
+
+ String profileName = SBInfo.getInstance().currentProfile;
+ if (profileName == null) profileName = "generic";
+
+ SlotLockProfile profile = config.profileData.computeIfAbsent(
+ profileName,
+ k -> new SlotLockProfile()
+ );
+
+ if (profile.currentProfile < 0) profile.currentProfile = 0;
+ if (profile.currentProfile >= 9) profile.currentProfile = 8;
+
+ if (profile.slotLockData[profile.currentProfile] == null) {
+ profile.slotLockData[profile.currentProfile] = new SlotLockData();
+ }
+
+ return profile.slotLockData[profile.currentProfile].lockedSlots;
+ }
+
+ private LockedSlot getLockedSlot(LockedSlot[] lockedSlots, int index) {
+ if (lockedSlots == null) {
+ return DEFAULT_LOCKED_SLOT;
+ }
+
+ LockedSlot slot = lockedSlots[index];
+
+ if (slot == null) {
+ return DEFAULT_LOCKED_SLOT;
+ }
+
+ return slot;
+ }
+
+ @SubscribeEvent(priority = EventPriority.LOW)
+ public void keyboardInput(GuiScreenEvent.KeyboardInputEvent.Pre event) {
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() ||
+ !NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotLocking) {
+ return;
+ }
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) {
+ return;
+ }
+ GuiContainer container = (GuiContainer) Minecraft.getMinecraft().currentScreen;
+
+ int key = NotEnoughUpdates.INSTANCE.config.slotLocking.slotLockKey;
+ if (!lockKeyHeld && KeybindHelper.isKeyPressed(key) && !Keyboard.isRepeatEvent()) {
+ 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;
+
+ Slot slot = container.getSlotAtPosition(mouseX, mouseY);
+ if (slot != null && slot.getSlotIndex() != 8 && slot.inventory == Minecraft.getMinecraft().thePlayer.inventory) {
+ int slotNum = slot.getSlotIndex();
+ if (slotNum >= 0 && slotNum <= 39) {
+ boolean isHotbar = slotNum < 9;
+ boolean isInventory = !isHotbar && slotNum < 36;
+ boolean isArmor = !isHotbar && !isInventory;
+
+ if (isInventory || isArmor) {
+ pairingSlot = slot;
+ } else {
+ pairingSlot = null;
+ }
+
+ LockedSlot[] lockedSlots = getDataForProfile();
+
+ if (lockedSlots != null) {
+ if (lockedSlots[slotNum] == null) {
+ lockedSlots[slotNum] = new LockedSlot();
+ }
+ lockedSlots[slotNum].locked = !lockedSlots[slotNum].locked;
+ lockedSlots[slotNum].boundTo = -1;
+
+ if (NotEnoughUpdates.INSTANCE.config.slotLocking.slotLockSound) {
+ float vol = NotEnoughUpdates.INSTANCE.config.slotLocking.slotLockSoundVol / 100f;
+ if (vol > 0) {
+ if (vol > 1) vol = 1;
+ final float volF = vol;
+ final boolean locked = lockedSlots[slotNum].locked;
+
+ ISound sound = new PositionedSound(new ResourceLocation("random.orb")) {{
+ volume = volF;
+ pitch = locked ? 0.943f : 0.1f;
+ repeat = false;
+ repeatDelay = 0;
+ attenuationType = ISound.AttenuationType.NONE;
+ }};
+
+ float oldLevel = Minecraft.getMinecraft().gameSettings.getSoundLevel(SoundCategory.PLAYERS);
+ Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.PLAYERS, 1);
+ Minecraft.getMinecraft().getSoundHandler().playSound(sound);
+ Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.PLAYERS, oldLevel);
+ }
+ }
+
+ if (isHotbar && lockedSlots[slotNum].locked) {
+ for (int i = 9; i <= 39; i++) {
+ if (lockedSlots[i] != null && lockedSlots[i].boundTo == slotNum) {
+ lockedSlots[i].boundTo = -1;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ lockKeyHeld = KeybindHelper.isKeyDown(key);
+ if (!lockKeyHeld) {
+ pairingSlot = null;
+ }
+ }
+
+ @SubscribeEvent(priority = EventPriority.LOW)
+ public void mouseEvent(GuiScreenEvent.MouseInputEvent.Pre event) {
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() ||
+ !NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotLocking) {
+ return;
+ }
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) {
+ return;
+ }
+ GuiContainer container = (GuiContainer) Minecraft.getMinecraft().currentScreen;
+
+ if (NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotBinding && lockKeyHeld && pairingSlot != null) {
+ 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;
+
+ Slot slot = container.getSlotAtPosition(mouseX, mouseY);
+ if (slot != null && slot.getSlotIndex() != 8 && slot.inventory == Minecraft.getMinecraft().thePlayer.inventory) {
+ int slotNum = slot.getSlotIndex();
+ if (slotNum >= 0 && slotNum <= 39) {
+
+ boolean isHotbar = slotNum < 9;
+ boolean isInventory = !isHotbar && slotNum < 36;
+ boolean isArmor = !isHotbar && !isInventory;
+
+ int pairingNum = pairingSlot.getSlotIndex();
+ if (isHotbar && slotNum != pairingNum) {
+ LockedSlot[] lockedSlots = getDataForProfile();
+ if (lockedSlots != null) {
+ if (lockedSlots[slotNum] == null) {
+ lockedSlots[slotNum] = new LockedSlot();
+ }
+ if (!lockedSlots[slotNum].locked) {
+ if (lockedSlots[pairingNum] == null) {
+ lockedSlots[pairingNum] = new LockedSlot();
+ }
+
+ lockedSlots[pairingNum].boundTo = slotNum;
+ lockedSlots[pairingNum].locked = false;
+
+ lockedSlots[slotNum].boundTo = pairingNum;
+ }
+ }
+ }
+ }
+ } else {
+ int pairingNum = pairingSlot.getSlotIndex();
+ LockedSlot[] lockedSlots = getDataForProfile();
+ if (lockedSlots != null && lockedSlots[pairingNum] != null) {
+ if (lockedSlots[pairingNum].boundTo >= 0) {
+ lockedSlots[lockedSlots[pairingNum].boundTo] = null;
+ }
+ lockedSlots[pairingNum] = null;
+ }
+ }
+ }
+ }
+
+ public void toggleLock(int lockIndex) {
+ if (lockIndex == 8) return;
+ LockedSlot[] lockedSlots = getDataForProfile();
+
+ if (lockedSlots != null) {
+ if (lockedSlots[lockIndex] == null) {
+ lockedSlots[lockIndex] = new LockedSlot();
+ }
+ lockedSlots[lockIndex].locked = !lockedSlots[lockIndex].locked;
+ lockedSlots[lockIndex].boundTo = -1;
+
+ if (NotEnoughUpdates.INSTANCE.config.slotLocking.slotLockSound) {
+ float vol = NotEnoughUpdates.INSTANCE.config.slotLocking.slotLockSoundVol / 100f;
+ if (vol > 0) {
+ if (vol > 1) vol = 1;
+ final float volF = vol;
+ final boolean locked = lockedSlots[lockIndex].locked;
+
+ ISound sound = new PositionedSound(new ResourceLocation("random.orb")) {{
+ volume = volF;
+ pitch = locked ? 0.943f : 0.1f;
+ repeat = false;
+ repeatDelay = 0;
+ attenuationType = ISound.AttenuationType.NONE;
+ }};
+
+ float oldLevel = Minecraft.getMinecraft().gameSettings.getSoundLevel(SoundCategory.PLAYERS);
+ Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.PLAYERS, 1);
+ Minecraft.getMinecraft().getSoundHandler().playSound(sound);
+ Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.PLAYERS, oldLevel);
+ }
+ }
+
+ if (lockIndex < 9 && lockedSlots[lockIndex].locked) {
+ for (int i = 9; i <= 39; i++) {
+ if (lockedSlots[i] != null && lockedSlots[i].boundTo == lockIndex) {
+ lockedSlots[i].boundTo = -1;
+ }
+ }
+ }
+ }
+ }
+
+ @SubscribeEvent(priority = EventPriority.LOW)
+ public void drawScreenEvent(GuiScreenEvent.DrawScreenEvent.Post event) {
+ if (NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotBinding && !event.isCanceled() && pairingSlot != null &&
+ lockKeyHeld) {
+ LockedSlot[] lockedSlots = getDataForProfile();
+ LockedSlot lockedSlot = getLockedSlot(lockedSlots, pairingSlot.getSlotIndex());
+ if (lockedSlot.boundTo >= 0 && lockedSlot.boundTo < 8) {
+ return;
+ }
+
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) {
+ return;
+ }
+ GuiContainer container = (GuiContainer) Minecraft.getMinecraft().currentScreen;
+
+ int x1 = container.guiLeft + pairingSlot.xDisplayPosition + 8;
+ int y1 = container.guiTop + pairingSlot.yDisplayPosition + 8;
+ int x2 = event.mouseX;
+ int y2 = event.mouseY;
+
+ if (x2 > x1 - 8 && x2 < x1 + 8 &&
+ y2 > y1 - 8 && y2 < y1 + 8) {
+ return;
+ }
+
+ drawLinkArrow(x1, y1, x2, y2);
+ }
+ }
+
+ private void drawLinkArrow(int x1, int y1, int x2, int y2) {
+ GlStateManager.color(0x33 / 255f, 0xee / 255f, 0xdd / 255f, 1f);
+ GlStateManager.disableLighting();
+ RenderHelper.disableStandardItemLighting();
+ GlStateManager.disableTexture2D();
+ GlStateManager.enableBlend();
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+
+ GlStateManager.translate(0, 0, 500);
+ drawLine(x1, y1, x2, y2);
+ GlStateManager.translate(0, 0, -500);
+
+ GlStateManager.enableTexture2D();
+ }
+
+ private void drawLine(int x1, int y1, int x2, int y2) {
+ Vector2f vec = new Vector2f(x2 - x1, y2 - y1);
+ vec.normalise(vec);
+ Vector2f side = new Vector2f(vec.y, -vec.x);
+
+ GL11.glLineWidth(1f);
+ GL11.glEnable(GL11.GL_LINE_SMOOTH);
+
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+
+ int lines = 6;
+ for (int i = 0; i < lines; i++) {
+ worldrenderer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION);
+ worldrenderer.pos(x1 - side.x + side.x * i / lines, y1 - side.y + side.y * i / lines, 0.0D).endVertex();
+ worldrenderer.pos(x2 - side.x + side.x * i / lines, y2 - side.y + side.y * i / lines, 0.0D).endVertex();
+ tessellator.draw();
+ }
+ }
+
+ public void onWindowClick(
+ Slot slotIn,
+ int slotId,
+ int clickedButton,
+ int clickType,
+ Consumer<Triple<Integer, Integer, Integer>> consumer
+ ) {
+ LockedSlot locked = getLockedSlot(slotIn);
+ if (locked == null) {
+ return;
+ } else if (locked.locked || (clickType == 2 && SlotLocking.getInstance().isSlotIndexLocked(clickedButton))) {
+ consumer.accept(null);
+ } else if (NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotBinding && clickType == 1 &&
+ locked.boundTo != -1) {
+ GuiContainer container = (GuiContainer) Minecraft.getMinecraft().currentScreen;
+ Slot boundSlot = container.inventorySlots.getSlotFromInventory(
+ Minecraft.getMinecraft().thePlayer.inventory,
+ locked.boundTo
+ );
+
+ if (boundSlot == null) {
+ return;
+ }
+
+ LockedSlot boundLocked = getLockedSlot(boundSlot);
+
+ int id = slotIn.getSlotIndex();
+ if (id >= 9 && locked.boundTo >= 0 && locked.boundTo < 8) {
+ if (!boundLocked.locked) {
+ consumer.accept(Triple.of(slotId, locked.boundTo, 2));
+ if (boundLocked == DEFAULT_LOCKED_SLOT) {
+ LockedSlot[] lockedSlots = getDataForProfile();
+ lockedSlots[locked.boundTo] = new LockedSlot();
+ lockedSlots[locked.boundTo].boundTo = id;
+ } else {
+ boundLocked.boundTo = id;
+ }
+ }
+ } else if (id >= 0 && id < 8 && locked.boundTo >= 9 && locked.boundTo <= 39) {
+ if (boundLocked.locked || boundLocked.boundTo != id) {
+ locked.boundTo = -1;
+ } else {
+ int boundTo = boundSlot.slotNumber;
+ consumer.accept(Triple.of(boundTo, id, 2));
+ }
+ }
+ } else if (NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotBinding && locked.boundTo != -1 &&
+ NotEnoughUpdates.INSTANCE.config.slotLocking.bindingAlsoLocks) {
+ consumer.accept(null);
+ }
+ }
+
+ public void drawSlot(Slot slot) {
+ LockedSlot locked = getLockedSlot(slot);
+ if (locked != null) {
+ if (locked.locked) {
+ GlStateManager.translate(0, 0, 400);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(LOCK);
+ GlStateManager.color(1, 1, 1, 0.5f);
+ GlStateManager.depthMask(false);
+ RenderUtils.drawTexturedRect(slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, 0, 1, 0, 1, GL11.GL_NEAREST);
+ GlStateManager.depthMask(true);
+ GlStateManager.enableBlend();
+ GlStateManager.translate(0, 0, -400);
+ } else if (NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotBinding && slot.canBeHovered() &&
+ locked.boundTo >= 0 && locked.boundTo <= 39) {
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) {
+ return;
+ }
+ GuiContainer container = (GuiContainer) Minecraft.getMinecraft().currentScreen;
+
+ 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;
+
+ Slot boundSlot = container.inventorySlots.getSlotFromInventory(
+ Minecraft.getMinecraft().thePlayer.inventory,
+ locked.boundTo
+ );
+ if (boundSlot == null) {
+ return;
+ }
+
+ boolean hoverOverSlot = container.isMouseOverSlot(slot, mouseX, mouseY);
+
+ if (hoverOverSlot || slot.getSlotIndex() >= 9) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(BOUND);
+ GlStateManager.color(1, 1, 1, 0.7f);
+ GlStateManager.depthMask(false);
+ RenderUtils.drawTexturedRect(
+ slot.xDisplayPosition,
+ slot.yDisplayPosition,
+ 16,
+ 16,
+ 0,
+ 1,
+ 0,
+ 1,
+ GL11.GL_NEAREST
+ );
+ GlStateManager.depthMask(true);
+ GlStateManager.enableBlend();
+
+ //Rerender Text over Top
+ if (slot.getStack() != null) {
+ Minecraft.getMinecraft().getRenderItem().renderItemOverlayIntoGUI(
+ Minecraft.getMinecraft().fontRendererObj,
+ slot.getStack(),
+ slot.xDisplayPosition,
+ slot.yDisplayPosition,
+ null
+ );
+ }
+ } else if (pairingSlot != null && lockKeyHeld && slot.getSlotIndex() < 8) {
+ int x1 = container.guiLeft + pairingSlot.xDisplayPosition;
+ int y1 = container.guiTop + pairingSlot.yDisplayPosition;
+
+ if (mouseX <= x1 || mouseX >= x1 + 16 ||
+ mouseY <= y1 || mouseY >= y1 + 16) {
+ Gui.drawRect(
+ slot.xDisplayPosition,
+ slot.yDisplayPosition,
+ slot.xDisplayPosition + 16,
+ slot.yDisplayPosition + 16,
+ 0x80ffffff
+ );
+ }
+ }
+
+ if (hoverOverSlot) {
+ LockedSlot boundLocked = getLockedSlot(boundSlot);
+ if (boundLocked == null || boundLocked.locked ||
+ (boundSlot.getSlotIndex() >= 9 && boundLocked.boundTo != slot.getSlotIndex())) {
+ locked.boundTo = -1;
+ return;
+ }
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(BOUND);
+ GlStateManager.color(1, 1, 1, 0.7f);
+ GlStateManager.depthMask(false);
+ RenderUtils.drawTexturedRect(
+ boundSlot.xDisplayPosition,
+ boundSlot.yDisplayPosition,
+ 16,
+ 16,
+ 0,
+ 1,
+ 0,
+ 1,
+ GL11.GL_NEAREST
+ );
+ GlStateManager.depthMask(true);
+ GlStateManager.enableBlend();
+
+ //Rerender Text over Top
+ if (boundSlot.getStack() != null) {
+ Minecraft.getMinecraft().getRenderItem().renderItemOverlayIntoGUI(
+ Minecraft.getMinecraft().fontRendererObj,
+ boundSlot.getStack(),
+ boundSlot.xDisplayPosition,
+ boundSlot.yDisplayPosition,
+ null
+ );
+ }
+
+ int maxIter = 100;
+ float x1 = slot.xDisplayPosition + 8;
+ float y1 = slot.yDisplayPosition + 8;
+ float x2 = boundSlot.xDisplayPosition + 8;
+ float y2 = boundSlot.yDisplayPosition + 8;
+ Vector2f vec = new Vector2f(x2 - x1, y2 - y1);
+ vec.normalise(vec);
+
+ while (x1 > slot.xDisplayPosition && x1 < slot.xDisplayPosition + 16 &&
+ y1 > slot.yDisplayPosition && y1 < slot.yDisplayPosition + 16) {
+ if (maxIter-- < 50) break;
+ x1 += vec.x;
+ y1 += vec.y;
+ }
+ while (x2 > boundSlot.xDisplayPosition && x2 < boundSlot.xDisplayPosition + 16 &&
+ y2 > boundSlot.yDisplayPosition && y2 < boundSlot.yDisplayPosition + 16) {
+ if (maxIter-- < 0) break;
+ x2 -= vec.x;
+ y2 -= vec.y;
+ }
+
+ GlStateManager.translate(0, 0, 200);
+ drawLinkArrow((int) x1, (int) y1, (int) x2, (int) y2);
+ GlStateManager.translate(0, 0, -200);
+ }
+ } else if (NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotBinding && slot.getSlotIndex() < 8 &&
+ pairingSlot != null && lockKeyHeld) {
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) {
+ return;
+ }
+ GuiContainer container = (GuiContainer) Minecraft.getMinecraft().currentScreen;
+
+ 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 x1 = container.guiLeft + pairingSlot.xDisplayPosition;
+ int y1 = container.guiTop + pairingSlot.yDisplayPosition;
+
+ if (mouseX <= x1 || mouseX >= x1 + 16 ||
+ mouseY <= y1 || mouseY >= y1 + 16) {
+ Gui.drawRect(
+ slot.xDisplayPosition,
+ slot.yDisplayPosition,
+ slot.xDisplayPosition + 16,
+ slot.yDisplayPosition + 16,
+ 0x80ffffff
+ );
+ }
+ }
+ }
+ }
+
+ public LockedSlot getLockedSlot(Slot slot) {
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() ||
+ !NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotLocking)
+ return null;
+ if (slot == null) {
+ return null;
+ }
+ if (slot.inventory != Minecraft.getMinecraft().thePlayer.inventory) {
+ return null;
+ }
+ int index = slot.getSlotIndex();
+ if (index < 0 || index > 39) {
+ return null;
+ }
+ return getLockedSlotIndex(index);
+ }
+
+ public LockedSlot getLockedSlotIndex(int index) {
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() ||
+ !NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotLocking) {
+ return null;
+ }
+
+ LockedSlot[] lockedSlots = getDataForProfile();
+ if (lockedSlots == null) {
+ return null;
+ }
+ return getLockedSlot(lockedSlots, index);
+ }
+
+ public boolean isSlotLocked(Slot slot) {
+ LockedSlot locked = getLockedSlot(slot);
+ return locked != null &&
+ (locked.locked || (NotEnoughUpdates.INSTANCE.config.slotLocking.bindingAlsoLocks && locked.boundTo != -1));
+ }
+
+ public boolean isSlotIndexLocked(int index) {
+ LockedSlot locked = getLockedSlotIndex(index);
+
+ return locked != null &&
+ (locked.locked || (NotEnoughUpdates.INSTANCE.config.slotLocking.bindingAlsoLocks && locked.boundTo != -1));
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StorageManager.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StorageManager.java
index 3a3aec6d..94aee789 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StorageManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StorageManager.java
@@ -23,7 +23,8 @@ import net.minecraft.network.play.server.S30PacketWindowItems;
import java.io.*;
import java.lang.reflect.Type;
import java.nio.charset.StandardCharsets;
-import java.util.*;
+import java.util.HashMap;
+import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -31,636 +32,655 @@ import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
public class StorageManager {
-
- private static final StorageManager INSTANCE = new StorageManager();
- private static final Gson GSON = new GsonBuilder()
- .registerTypeAdapter(ItemStack.class, new ItemStackSerializer())
- .registerTypeAdapter(ItemStack.class, new ItemStackDeserilizer()).create();
-
- public static class ItemStackSerializer implements JsonSerializer<ItemStack> {
- @Override
- public JsonElement serialize(ItemStack src, Type typeOfSrc,
- JsonSerializationContext context) {
- NBTTagCompound tag = src.serializeNBT();
- return nbtToJson(tag);
- }
- }
-
- private static final Pattern JSON_FIX_REGEX = Pattern.compile("\"([^,:]+)\":");
-
- public static class ItemStackDeserilizer implements JsonDeserializer<ItemStack> {
- @Override
- public ItemStack deserialize(JsonElement json, Type typeOfT,
- JsonDeserializationContext context) throws JsonParseException {
- try {
- JsonObject object = json.getAsJsonObject();
-
- NBTTagCompound tag = JsonToNBT.getTagFromJson(JSON_FIX_REGEX.matcher(object.toString()).replaceAll("$1:"));
-
- Item item;
- if(tag.hasKey("id", 8)) {
- item = Item.getByNameOrId(tag.getString("id"));
- } else {
- item = Item.getItemById(tag.getShort("id"));
- }
- if(item == null) {
- return null;
- }
- int stackSize = tag.getInteger("Count");
- int damage = tag.getInteger("Damage");
-
- ItemStack stack = new ItemStack(item, stackSize, damage);
-
- if(tag.hasKey("tag")) {
- NBTTagCompound itemTag = tag.getCompoundTag("tag");
- stack.setTagCompound(itemTag);
- }
-
- return stack;
- } catch(Exception e) {
- e.printStackTrace();
- return null;
- }
- }
- }
-
- private static JsonObject nbtToJson(NBTTagCompound NBTTagCompound) {
- return (JsonObject) loadJson(NBTTagCompound);
- }
-
- private static JsonElement loadJson(NBTBase tag) {
- if (tag instanceof NBTTagCompound) {
- NBTTagCompound compoundTag = (NBTTagCompound) tag;
- JsonObject jsonObject = new JsonObject();
- for (String key : compoundTag.getKeySet()) {
- jsonObject.add(key, loadJson(compoundTag.getTag(key)));
- }
- return jsonObject;
- } else if (tag instanceof NBTTagList) {
- NBTTagList listTag = (NBTTagList) tag;
- JsonArray jsonArray = new JsonArray();
- for(int i=0; i<listTag.tagCount(); i++) {
- jsonArray.add(loadJson(listTag.get(i)));
- }
- return jsonArray;
- } else if (tag instanceof NBTTagIntArray) {
- NBTTagIntArray listTag = (NBTTagIntArray) tag;
- int[] arr = listTag.getIntArray();
- JsonArray jsonArray = new JsonArray();
- for(int i=0; i<arr.length; i++) {
- jsonArray.add(new JsonPrimitive(arr[i]));
- }
- return jsonArray;
- } else if (tag instanceof NBTTagByteArray) {
- NBTTagByteArray listTag = (NBTTagByteArray) tag;
- byte[] arr = listTag.getByteArray();
- JsonArray jsonArray = new JsonArray();
- for(int i=0; i<arr.length; i++) {
- jsonArray.add(new JsonPrimitive(arr[i]));
- }
- return jsonArray;
- }else if (tag instanceof NBTTagShort) {
- return new JsonPrimitive(((NBTTagShort) tag).getShort());
- } else if (tag instanceof NBTTagInt) {
- return new JsonPrimitive(((NBTTagInt) tag).getInt());
- } else if (tag instanceof NBTTagLong) {
- return new JsonPrimitive(((NBTTagLong) tag).getLong());
- } else if (tag instanceof NBTTagFloat) {
- return new JsonPrimitive(((NBTTagFloat) tag).getFloat());
- } else if (tag instanceof NBTTagDouble) {
- return new JsonPrimitive(((NBTTagDouble) tag).getDouble());
- } else if (tag instanceof NBTTagByte) {
- return new JsonPrimitive(((NBTTagByte) tag).getByte());
- } else if(tag instanceof NBTTagString){
- return new JsonPrimitive(((NBTTagString)tag).getString());
- } else {
- return new JsonPrimitive("Broken_Json_Deserialize_Tag");
- }
- }
-
- public static StorageManager getInstance() {
- return INSTANCE;
- }
-
- private AtomicInteger searchId = new AtomicInteger(0);
-
- public static class StoragePage {
- public ItemStack[] items = new ItemStack[45];
- public ItemStack backpackDisplayStack;
- public String customTitle;
- public int rows = -1;
- public boolean[] shouldDarkenIfNotSelected = new boolean[45];
-
- public transient boolean matchesSearch;
- public transient int searchedId;
- }
-
- public static int MAX_ENDER_CHEST_PAGES = 9;
-
- public static final ItemStack LOCKED_ENDERCHEST_STACK = Utils.createItemStack(Item.getItemFromBlock(Blocks.stained_glass_pane),
- "\u00a7cLocked Page", 14,
- "\u00a77Unlock more Ender Chest",
- "\u00a77pages in the community",
- "\u00a77shop!");
-
- public static class StorageConfig {
- public HashMap<String, StoragePage[]> pages = new HashMap<>();
- public final HashMap<Integer, Integer> displayToStorageIdMap = new HashMap<>();
- public final HashMap<Integer, Integer> displayToStorageIdMapRender = new HashMap<>();
- }
-
- public StorageConfig storageConfig = new StorageConfig();
-
- private int currentStoragePage = -1;
- public boolean onStorageMenu = false;
-
- private String lastSearch = "";
-
- private boolean[] storagePresent = null;
-
- //TODO: Replace with /storage {id} when hypixel becomes not lazy
- public int desiredStoragePage = -1;
- public long storageOpenSwitchMillis = 0;
-
- private ItemStack[] missingBackpackStacks = new ItemStack[18];
-
- private boolean shouldRenderStorageOverlayCached = false;
-
- private static final Pattern WINDOW_REGEX = Pattern.compile(".+ Backpack (?:\u2726 )?\\((\\d+)/(\\d+)\\)");
- private static final Pattern ECHEST_WINDOW_REGEX = Pattern.compile("Ender Chest \\((\\d+)/(\\d+)\\)");
-
- public void loadConfig(File file) {
- try(BufferedReader reader = new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(file)), StandardCharsets.UTF_8))) {
- storageConfig = GSON.fromJson(reader, StorageConfig.class);
- } catch(Exception ignored) { }
- if(storageConfig == null) {
- storageConfig = new StorageConfig();
- }
- }
-
- public void saveConfig(File file) {
- try {
- file.createNewFile();
- try(BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream(file)), StandardCharsets.UTF_8))) {
- writer.write(GSON.toJson(storageConfig));
- }
- } catch(Exception ignored) {
- ignored.printStackTrace();
- }
- }
-
- public ItemStack getMissingBackpackStack(int storageId) {
- if(missingBackpackStacks[storageId] != null) {
- return missingBackpackStacks[storageId];
- }
-
- ItemStack stack = Utils.createItemStack(Item.getItemFromBlock(Blocks.stained_glass_pane),
- "\u00a7cEmpty Backpack Slot "+(storageId+1), 12,
- "",
- "\u00a7eLeft-click a backpack",
- "\u00a7eitem on this slot to place",
- "\u00a7eit!");
-
- missingBackpackStacks[storageId] = stack;
- return stack;
- }
-
- public boolean shouldRenderStorageOverlay(String containerName) {
- if(!NotEnoughUpdates.INSTANCE.config.storageGUI.enableStorageGUI3) {
- shouldRenderStorageOverlayCached = false;
- return false;
- }
-
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
- shouldRenderStorageOverlayCached = false;
- return false;
- }
-
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) {
- shouldRenderStorageOverlayCached = false;
- return false;
- }
-
- if(getCurrentWindowId() != -1 && getCurrentPageId() != -1) {
- shouldRenderStorageOverlayCached = true;
- return true;
- }
-
- shouldRenderStorageOverlayCached = containerName != null && containerName.trim().startsWith("Storage");
- return shouldRenderStorageOverlayCached;
- }
-
- public boolean shouldRenderStorageOverlayFast() {
- return shouldRenderStorageOverlayCached;
- }
-
- private StoragePage[] getPagesForProfile() {
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return null;
- if(SBInfo.getInstance().currentProfile == null) return null;
-
- return storageConfig.pages.computeIfAbsent(SBInfo.getInstance().currentProfile, k -> new StoragePage[27]);
- }
-
- public StoragePage getPage(int pageIndex, boolean createPage) {
- if(pageIndex == -1) return null;
-
- StoragePage[] pages = getPagesForProfile();
- if(pages == null) return null;
-
- if(createPage && pages[pageIndex] == null) pages[pageIndex] = new StoragePage();
-
- return pages[pageIndex];
- }
-
- public void removePage(int pageIndex) {
- if(pageIndex == -1) return;
-
- StoragePage[] pages = getPagesForProfile();
- if(pages == null) return;
-
- pages[pageIndex] = null;
- }
-
- public StoragePage getCurrentPage() {
- return getPage(getCurrentPageId(), true);
- }
-
- private void setItemSlot(int index, ItemStack item) {
- StoragePage page = getCurrentPage();
- if(page != null) {
- page.items[index] = item;
- }
- }
-
- public int getCurrentPageId() {
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) {
- currentStoragePage = -1;
- return -1;
- }
-
- return currentStoragePage;
- }
-
- public int getCurrentWindowId() {
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) {
- currentStoragePage = -1;
- return -1;
- }
-
- GuiChest chest = (GuiChest)Minecraft.getMinecraft().currentScreen;
-
- return chest.inventorySlots.windowId;
- }
-
- public void sendToPage(int page) {
- if(desiredStoragePage != getCurrentPageId() &&
- System.currentTimeMillis() - storageOpenSwitchMillis < 100) return;
- if(getCurrentPageId() == page) return;
-
- if(page == 0) {
- NotEnoughUpdates.INSTANCE.sendChatMessage("/enderchest");
- } else if(getCurrentWindowId() != -1 && onStorageMenu) {
- if(page < 9) {
- sendMouseClick(getCurrentWindowId(), 9+page);
- } else {
- sendMouseClick(getCurrentWindowId(), 27+page-MAX_ENDER_CHEST_PAGES);
- }
- } else {
- boolean onEnderchest = page < MAX_ENDER_CHEST_PAGES && currentStoragePage < MAX_ENDER_CHEST_PAGES;
- boolean onStorage = page >= MAX_ENDER_CHEST_PAGES && currentStoragePage >= MAX_ENDER_CHEST_PAGES;
- if(currentStoragePage >= 0 && (onEnderchest || (onStorage))) {
- int currentPageDisplay = getDisplayIdForStorageId(currentStoragePage);
- int desiredPageDisplay = getDisplayIdForStorageId(page);
-
- if(onEnderchest && desiredPageDisplay > currentPageDisplay) {
- boolean isLastPage = true;
- for(int pageN=page+1; pageN<MAX_ENDER_CHEST_PAGES; pageN++) {
- if(getDisplayIdForStorageId(pageN) >= 0) {
- isLastPage = false;
- break;
- }
- }
- if(isLastPage) {
- sendMouseClick(getCurrentWindowId(), 8);
- return;
- }
- }
-
- if(onStorage && page == MAX_ENDER_CHEST_PAGES) {
- sendMouseClick(getCurrentWindowId(), 5);
- return;
- } else if(onStorage && desiredPageDisplay == storageConfig.displayToStorageIdMap.size()-1) {
- sendMouseClick(getCurrentWindowId(), 8);
- return;
- } else {
- int delta = desiredPageDisplay - currentPageDisplay;
- if(delta == -1) {
- sendMouseClick(getCurrentWindowId(), 6);
- return;
- } else if(delta == 1) {
- sendMouseClick(getCurrentWindowId(), 7);
- return;
- }
- }
- }
-
- storageOpenSwitchMillis = System.currentTimeMillis();
- desiredStoragePage = page;
-
- NotEnoughUpdates.INSTANCE.sendChatMessage("/storage " + (desiredStoragePage-8));
- }
- }
-
- private void sendMouseClick(int windowId, int slotIndex) {
- EntityPlayerSP playerIn = Minecraft.getMinecraft().thePlayer;
- short short1 = playerIn.openContainer.getNextTransactionID(playerIn.inventory);
- ItemStack itemstack = playerIn.openContainer.getSlot(slotIndex).getStack();
- Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C0EPacketClickWindow(windowId, slotIndex, 0, 0, itemstack, short1));
- }
-
- public int getDisplayIdForStorageId(int storageId) {
- if(storageId < 0) return -1;
- for(Map.Entry<Integer, Integer> entry : storageConfig.displayToStorageIdMap.entrySet()) {
- if(entry.getValue() == storageId) {
- return entry.getKey();
- }
- }
- return -1;
- }
-
- public int getDisplayIdForStorageIdRender(int storageId) {
- if(storageId < 0) return -1;
- for(Map.Entry<Integer, Integer> entry : storageConfig.displayToStorageIdMapRender.entrySet()) {
- if(entry.getValue() == storageId) {
- return entry.getKey();
- }
- }
- return -1;
- }
-
- public boolean onAnyClick() {
- if(onStorageMenu && desiredStoragePage >= 0) {
- if(desiredStoragePage < 9) {
- sendMouseClick(getCurrentWindowId(), 9+desiredStoragePage);
- } else {
- sendMouseClick(getCurrentWindowId(), 27+desiredStoragePage-MAX_ENDER_CHEST_PAGES);
- }
- desiredStoragePage = -1;
- return true;
- }
- return false;
- }
-
- public void openWindowPacket(S2DPacketOpenWindow packet) {
- shouldRenderStorageOverlayCached = false;
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
-
- String windowTitle = Utils.cleanColour(packet.getWindowTitle().getUnformattedText());
-
- Matcher matcher = WINDOW_REGEX.matcher(windowTitle);
- Matcher matcherEchest = ECHEST_WINDOW_REGEX.matcher(windowTitle);
-
- currentStoragePage = -1;
- onStorageMenu = false;
-
- if(windowTitle.trim().equals("Storage")) {
- onStorageMenu = true;
- } else if(matcher.matches()) {
- int page = Integer.parseInt(matcher.group(1));
-
- if(page > 0 && page <= 18) {
- currentStoragePage = page-1+MAX_ENDER_CHEST_PAGES;
-
- int displayId = getDisplayIdForStorageId(currentStoragePage);
- if(displayId >= 0) StorageOverlay.getInstance().scrollToStorage(displayId, false);
-
- StoragePage spage = getCurrentPage();
- if(spage != null) {
- spage.rows = packet.getSlotCount()/9 - 1;
- }
- }
- } else if(matcherEchest.matches()) {
- int page = Integer.parseInt(matcherEchest.group(1));
-
- if(page > 0 && page <= 9) {
- currentStoragePage = page-1;
-
- int displayId = getDisplayIdForStorageId(currentStoragePage);
- if(displayId >= 0) StorageOverlay.getInstance().scrollToStorage(displayId, false);
-
- StoragePage spage = getCurrentPage();
- if(spage != null) {
- spage.rows = packet.getSlotCount()/9 - 1;
- }
- }
- } else {
- StorageOverlay.getInstance().clearSearch();
- return;
- }
- StorageOverlay.getInstance().fastRenderCheck();
-
- }
-
- public void closeWindowPacket(S2EPacketCloseWindow packet) {
- shouldRenderStorageOverlayCached = false;
- }
-
- public void setSlotPacket(S2FPacketSetSlot packet) {
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
- if(getCurrentWindowId() == -1 || getCurrentWindowId() != packet.func_149175_c()) return;
-
- if(getCurrentPageId() != -1) {
- StoragePage page = getCurrentPage();
-
- int slot = packet.func_149173_d();
- if(page != null && slot >= 9 && slot < 9+page.rows*9) {
- setItemSlot(packet.func_149173_d()-9, packet.func_149174_e());
- }
- } else if(onStorageMenu) {
- if(storagePresent == null) {
- storagePresent = new boolean[27];
- }
-
- int slot = packet.func_149173_d();
- ItemStack stack = packet.func_149174_e();
-
- if(slot >= 9 && slot < 18) {
- int index = slot-9;
-
- boolean changed = false;
- if(stack.getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) &&
- stack.getMetadata() == 14) {
- if(storagePresent[index]) changed = true;
- storagePresent[index] = false;
- removePage(index);
- } else {
- if(!storagePresent[index]) changed = true;
- storagePresent[index] = true;
- getPage(index, true).backpackDisplayStack = stack;
- }
-
- if(changed) {
- synchronized(storageConfig.displayToStorageIdMap) {
- storageConfig.displayToStorageIdMap.clear();
- storageConfig.displayToStorageIdMapRender.clear();
- int displayIndex = 0;
- for(int i=0; i<storagePresent.length; i++) {
- if(storagePresent[i]) {
- storageConfig.displayToStorageIdMap.put(displayIndex, i);
- if(lastSearch != null && !lastSearch.isEmpty()){
- StoragePage page = getPage(i, false);
-
- if(page != null) {
- updateSearchForPage(lastSearch, page);
- if(page.matchesSearch) {
- storageConfig.displayToStorageIdMapRender.put(displayIndex++, i);
- }
- }
- } else
- storageConfig.displayToStorageIdMapRender.put(displayIndex++, i);
- }
- }
- }
- }
- }
-
- if(slot >= 27 && slot < 45) {
- int index = (slot-27)%9 + (slot-27)/9*9 + MAX_ENDER_CHEST_PAGES;
-
- boolean changed = false;
-
- if(stack.getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane)) {
- if(storagePresent[index]) changed = true;
- storagePresent[index] = false;
- removePage(index);
- } else {
- if(!storagePresent[index]) changed = true;
- storagePresent[index] = true;
- getPage(index, true).backpackDisplayStack = stack;
- }
-
- if(changed) {
- synchronized(storageConfig.displayToStorageIdMap) {
- storageConfig.displayToStorageIdMap.clear();
- storageConfig.displayToStorageIdMapRender.clear();
- int displayIndex = 0;
- for(int i=0; i<storagePresent.length; i++) {
- if(storagePresent[i]) {
- storageConfig.displayToStorageIdMap.put(displayIndex, i);
- if(lastSearch != null && !lastSearch.isEmpty()){
- StoragePage page = getPage(i, false);
-
- if(page != null) {
- updateSearchForPage(lastSearch, page);
- if(page.matchesSearch) {
- storageConfig.displayToStorageIdMapRender.put(displayIndex++, i);
- }
- }
- } else
- storageConfig.displayToStorageIdMapRender.put(displayIndex++, i);
- }
- }
- }
- }
- }
- }
- }
-
- public void updateSearchForPage(String searchStr, StoragePage page) {
- if(page == null) {
- return;
- }
-
- if(page.rows <= 0) {
- page.matchesSearch = true;
- return;
- }
-
- if(page.searchedId > searchId.get()) {
- page.searchedId = -1;
- return;
- }
- if(page.searchedId == searchId.get()) {
- return;
- }
-
- page.searchedId = searchId.get();
-
- if(searchStr == null || searchStr.trim().isEmpty()) {
- page.matchesSearch = true;
- return;
- }
-
- for(ItemStack stack : page.items) {
- if(stack != null && NotEnoughUpdates.INSTANCE.manager.doesStackMatchSearch(stack, searchStr)) {
- page.matchesSearch = true;
- return;
- }
- }
- page.matchesSearch = false;
- }
-
- public void searchDisplay(String searchStr) {
- if(storagePresent == null) return;
-
- synchronized(storageConfig.displayToStorageIdMapRender) {
- storageConfig.displayToStorageIdMapRender.clear();
-
- lastSearch = searchStr;
- int sid = searchId.incrementAndGet();
- int displayIndex = 0;
- for(int i=0; i<storagePresent.length; i++) {
- if(storagePresent[i]) {
- StoragePage page = getPage(i, false);
- if(page != null) {
- if(page.rows > 0) {
- updateSearchForPage(searchStr, page);
- if(page.matchesSearch) {
- storageConfig.displayToStorageIdMapRender.put(displayIndex++, i);
- }
- } else {
- storageConfig.displayToStorageIdMapRender.put(displayIndex++, i);
- page.matchesSearch = true;
- page.searchedId = sid;
- }
- }
- }
- }
- }
- }
-
- public void setItemsPacket(S30PacketWindowItems packet) {
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
- if(getCurrentWindowId() == -1 || getCurrentWindowId() != packet.func_148911_c()) return;
-
- if(getCurrentPageId() != -1) {
- StoragePage page = getPage(getCurrentPageId(), false);
-
- if(page != null) {
- int max = Math.min(page.rows*9, packet.getItemStacks().length-9);
- for(int i=0; i<max; i++) {
- setItemSlot(i, packet.getItemStacks()[i+9]);
- }
- }
-
- }
- }
-
- public void clientSendWindowClick(C0EPacketClickWindow packet) {
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
- if(getCurrentWindowId() == -1 || getCurrentWindowId() != packet.getWindowId()) return;
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) return;
- ContainerChest containerChest = (ContainerChest)((GuiChest)Minecraft.getMinecraft().currentScreen).inventorySlots;
-
- if(getCurrentPageId() != -1) {
- StoragePage page = getCurrentPage();
- if(page == null) return;
-
- IInventory inv = containerChest.getLowerChestInventory();
- int max = Math.min(9+page.rows*9, inv.getSizeInventory());
- for(int i=9; i<max; i++) {
- setItemSlot(i-9, inv.getStackInSlot(i));
- }
- }
- }
+ private static final StorageManager INSTANCE = new StorageManager();
+ private static final Gson GSON = new GsonBuilder()
+ .registerTypeAdapter(ItemStack.class, new ItemStackSerializer())
+ .registerTypeAdapter(ItemStack.class, new ItemStackDeserilizer()).create();
+
+ public static class ItemStackSerializer implements JsonSerializer<ItemStack> {
+ @Override
+ public JsonElement serialize(ItemStack src, Type typeOfSrc, JsonSerializationContext context) {
+ NBTTagCompound tag = src.serializeNBT();
+ return nbtToJson(tag);
+ }
+ }
+
+ private static final Pattern JSON_FIX_REGEX = Pattern.compile("\"([^,:]+)\":");
+
+ public static class ItemStackDeserilizer implements JsonDeserializer<ItemStack> {
+ @Override
+ public ItemStack deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
+ throws JsonParseException {
+ try {
+ JsonObject object = json.getAsJsonObject();
+
+ NBTTagCompound tag = JsonToNBT.getTagFromJson(JSON_FIX_REGEX.matcher(object.toString()).replaceAll("$1:"));
+
+ Item item;
+ if (tag.hasKey("id", 8)) {
+ item = Item.getByNameOrId(tag.getString("id"));
+ } else {
+ item = Item.getItemById(tag.getShort("id"));
+ }
+ if (item == null) {
+ return null;
+ }
+ int stackSize = tag.getInteger("Count");
+ int damage = tag.getInteger("Damage");
+
+ ItemStack stack = new ItemStack(item, stackSize, damage);
+
+ if (tag.hasKey("tag")) {
+ NBTTagCompound itemTag = tag.getCompoundTag("tag");
+ stack.setTagCompound(itemTag);
+ }
+
+ return stack;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+ }
+
+ private static JsonObject nbtToJson(NBTTagCompound NBTTagCompound) {
+ return (JsonObject) loadJson(NBTTagCompound);
+ }
+
+ private static JsonElement loadJson(NBTBase tag) {
+ if (tag instanceof NBTTagCompound) {
+ NBTTagCompound compoundTag = (NBTTagCompound) tag;
+ JsonObject jsonObject = new JsonObject();
+ for (String key : compoundTag.getKeySet()) {
+ jsonObject.add(key, loadJson(compoundTag.getTag(key)));
+ }
+ return jsonObject;
+ } else if (tag instanceof NBTTagList) {
+ NBTTagList listTag = (NBTTagList) tag;
+ JsonArray jsonArray = new JsonArray();
+ for (int i = 0; i < listTag.tagCount(); i++) {
+ jsonArray.add(loadJson(listTag.get(i)));
+ }
+ return jsonArray;
+ } else if (tag instanceof NBTTagIntArray) {
+ NBTTagIntArray listTag = (NBTTagIntArray) tag;
+ int[] arr = listTag.getIntArray();
+ JsonArray jsonArray = new JsonArray();
+ for (int j : arr) {
+ jsonArray.add(new JsonPrimitive(j));
+ }
+ return jsonArray;
+ } else if (tag instanceof NBTTagByteArray) {
+ NBTTagByteArray listTag = (NBTTagByteArray) tag;
+ byte[] arr = listTag.getByteArray();
+ JsonArray jsonArray = new JsonArray();
+ for (byte b : arr) {
+ jsonArray.add(new JsonPrimitive(b));
+ }
+ return jsonArray;
+ } else if (tag instanceof NBTTagShort) {
+ return new JsonPrimitive(((NBTTagShort) tag).getShort());
+ } else if (tag instanceof NBTTagInt) {
+ return new JsonPrimitive(((NBTTagInt) tag).getInt());
+ } else if (tag instanceof NBTTagLong) {
+ return new JsonPrimitive(((NBTTagLong) tag).getLong());
+ } else if (tag instanceof NBTTagFloat) {
+ return new JsonPrimitive(((NBTTagFloat) tag).getFloat());
+ } else if (tag instanceof NBTTagDouble) {
+ return new JsonPrimitive(((NBTTagDouble) tag).getDouble());
+ } else if (tag instanceof NBTTagByte) {
+ return new JsonPrimitive(((NBTTagByte) tag).getByte());
+ } else if (tag instanceof NBTTagString) {
+ return new JsonPrimitive(((NBTTagString) tag).getString());
+ } else {
+ return new JsonPrimitive("Broken_Json_Deserialize_Tag");
+ }
+ }
+
+ public static StorageManager getInstance() {
+ return INSTANCE;
+ }
+
+ private final AtomicInteger searchId = new AtomicInteger(0);
+
+ public static class StoragePage {
+ public ItemStack[] items = new ItemStack[45];
+ public ItemStack backpackDisplayStack;
+ public String customTitle;
+ public int rows = -1;
+ public boolean[] shouldDarkenIfNotSelected = new boolean[45];
+
+ public transient boolean matchesSearch;
+ public transient int searchedId;
+ }
+
+ public static int MAX_ENDER_CHEST_PAGES = 9;
+
+ public static final ItemStack LOCKED_ENDERCHEST_STACK =
+ Utils.createItemStack(Item.getItemFromBlock(Blocks.stained_glass_pane),
+ "\u00a7cLocked Page", 14,
+ "\u00a77Unlock more Ender Chest",
+ "\u00a77pages in the community",
+ "\u00a77shop!"
+ );
+
+ public static class StorageConfig {
+ public HashMap<String, StoragePage[]> pages = new HashMap<>();
+ public final HashMap<Integer, Integer> displayToStorageIdMap = new HashMap<>();
+ public final HashMap<Integer, Integer> displayToStorageIdMapRender = new HashMap<>();
+ }
+
+ public StorageConfig storageConfig = new StorageConfig();
+
+ private int currentStoragePage = -1;
+ public boolean onStorageMenu = false;
+
+ private String lastSearch = "";
+
+ private boolean[] storagePresent = null;
+
+ //TODO: Replace with /storage {id} when hypixel becomes not lazy
+ public int desiredStoragePage = -1;
+ public long storageOpenSwitchMillis = 0;
+
+ private final ItemStack[] missingBackpackStacks = new ItemStack[18];
+
+ private boolean shouldRenderStorageOverlayCached = false;
+
+ private static final Pattern WINDOW_REGEX = Pattern.compile(".+ Backpack (?:\u2726 )?\\((\\d+)/(\\d+)\\)");
+ private static final Pattern ECHEST_WINDOW_REGEX = Pattern.compile("Ender Chest \\((\\d+)/(\\d+)\\)");
+
+ public void loadConfig(File file) {
+ try (
+ BufferedReader reader = new BufferedReader(new InputStreamReader(
+ new GZIPInputStream(new FileInputStream(file)),
+ StandardCharsets.UTF_8
+ ))
+ ) {
+ storageConfig = GSON.fromJson(reader, StorageConfig.class);
+ } catch (Exception ignored) {
+ }
+ if (storageConfig == null) {
+ storageConfig = new StorageConfig();
+ }
+ }
+
+ public void saveConfig(File file) {
+ try {
+ file.createNewFile();
+ try (
+ BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
+ new GZIPOutputStream(new FileOutputStream(file)),
+ StandardCharsets.UTF_8
+ ))
+ ) {
+ writer.write(GSON.toJson(storageConfig));
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public ItemStack getMissingBackpackStack(int storageId) {
+ if (missingBackpackStacks[storageId] != null) {
+ return missingBackpackStacks[storageId];
+ }
+
+ ItemStack stack = Utils.createItemStack(Item.getItemFromBlock(Blocks.stained_glass_pane),
+ "\u00a7cEmpty Backpack Slot " + (storageId + 1), 12,
+ "",
+ "\u00a7eLeft-click a backpack",
+ "\u00a7eitem on this slot to place",
+ "\u00a7eit!"
+ );
+
+ missingBackpackStacks[storageId] = stack;
+ return stack;
+ }
+
+ public boolean shouldRenderStorageOverlay(String containerName) {
+ if (!NotEnoughUpdates.INSTANCE.config.storageGUI.enableStorageGUI3) {
+ shouldRenderStorageOverlayCached = false;
+ return false;
+ }
+
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
+ shouldRenderStorageOverlayCached = false;
+ return false;
+ }
+
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) {
+ shouldRenderStorageOverlayCached = false;
+ return false;
+ }
+
+ if (getCurrentWindowId() != -1 && getCurrentPageId() != -1) {
+ shouldRenderStorageOverlayCached = true;
+ return true;
+ }
+
+ shouldRenderStorageOverlayCached = containerName != null && containerName.trim().startsWith("Storage");
+ return shouldRenderStorageOverlayCached;
+ }
+
+ public boolean shouldRenderStorageOverlayFast() {
+ return shouldRenderStorageOverlayCached;
+ }
+
+ private StoragePage[] getPagesForProfile() {
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return null;
+ if (SBInfo.getInstance().currentProfile == null) return null;
+
+ return storageConfig.pages.computeIfAbsent(SBInfo.getInstance().currentProfile, k -> new StoragePage[27]);
+ }
+
+ public StoragePage getPage(int pageIndex, boolean createPage) {
+ if (pageIndex == -1) return null;
+
+ StoragePage[] pages = getPagesForProfile();
+ if (pages == null) return null;
+
+ if (createPage && pages[pageIndex] == null) pages[pageIndex] = new StoragePage();
+
+ return pages[pageIndex];
+ }
+
+ public void removePage(int pageIndex) {
+ if (pageIndex == -1) return;
+
+ StoragePage[] pages = getPagesForProfile();
+ if (pages == null) return;
+
+ pages[pageIndex] = null;
+ }
+
+ public StoragePage getCurrentPage() {
+ return getPage(getCurrentPageId(), true);
+ }
+
+ private void setItemSlot(int index, ItemStack item) {
+ StoragePage page = getCurrentPage();
+ if (page != null) {
+ page.items[index] = item;
+ }
+ }
+
+ public int getCurrentPageId() {
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) {
+ currentStoragePage = -1;
+ return -1;
+ }
+
+ return currentStoragePage;
+ }
+
+ public int getCurrentWindowId() {
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) {
+ currentStoragePage = -1;
+ return -1;
+ }
+
+ GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
+
+ return chest.inventorySlots.windowId;
+ }
+
+ public void sendToPage(int page) {
+ if (desiredStoragePage != getCurrentPageId() &&
+ System.currentTimeMillis() - storageOpenSwitchMillis < 100) return;
+ if (getCurrentPageId() == page) return;
+
+ if (page == 0) {
+ NotEnoughUpdates.INSTANCE.sendChatMessage("/enderchest");
+ } else if (getCurrentWindowId() != -1 && onStorageMenu) {
+ if (page < 9) {
+ sendMouseClick(getCurrentWindowId(), 9 + page);
+ } else {
+ sendMouseClick(getCurrentWindowId(), 27 + page - MAX_ENDER_CHEST_PAGES);
+ }
+ } else {
+ boolean onEnderchest = page < MAX_ENDER_CHEST_PAGES && currentStoragePage < MAX_ENDER_CHEST_PAGES;
+ boolean onStorage = page >= MAX_ENDER_CHEST_PAGES && currentStoragePage >= MAX_ENDER_CHEST_PAGES;
+ if (currentStoragePage >= 0 && (onEnderchest || (onStorage))) {
+ int currentPageDisplay = getDisplayIdForStorageId(currentStoragePage);
+ int desiredPageDisplay = getDisplayIdForStorageId(page);
+
+ if (onEnderchest && desiredPageDisplay > currentPageDisplay) {
+ boolean isLastPage = true;
+ for (int pageN = page + 1; pageN < MAX_ENDER_CHEST_PAGES; pageN++) {
+ if (getDisplayIdForStorageId(pageN) >= 0) {
+ isLastPage = false;
+ break;
+ }
+ }
+ if (isLastPage) {
+ sendMouseClick(getCurrentWindowId(), 8);
+ return;
+ }
+ }
+
+ if (onStorage && page == MAX_ENDER_CHEST_PAGES) {
+ sendMouseClick(getCurrentWindowId(), 5);
+ return;
+ } else if (onStorage && desiredPageDisplay == storageConfig.displayToStorageIdMap.size() - 1) {
+ sendMouseClick(getCurrentWindowId(), 8);
+ return;
+ } else {
+ int delta = desiredPageDisplay - currentPageDisplay;
+ if (delta == -1) {
+ sendMouseClick(getCurrentWindowId(), 6);
+ return;
+ } else if (delta == 1) {
+ sendMouseClick(getCurrentWindowId(), 7);
+ return;
+ }
+ }
+ }
+
+ storageOpenSwitchMillis = System.currentTimeMillis();
+ desiredStoragePage = page;
+
+ NotEnoughUpdates.INSTANCE.sendChatMessage("/storage " + (desiredStoragePage - 8));
+ }
+ }
+
+ private void sendMouseClick(int windowId, int slotIndex) {
+ EntityPlayerSP playerIn = Minecraft.getMinecraft().thePlayer;
+ short short1 = playerIn.openContainer.getNextTransactionID(playerIn.inventory);
+ ItemStack itemstack = playerIn.openContainer.getSlot(slotIndex).getStack();
+ Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C0EPacketClickWindow(
+ windowId,
+ slotIndex,
+ 0,
+ 0,
+ itemstack,
+ short1
+ ));
+ }
+
+ public int getDisplayIdForStorageId(int storageId) {
+ if (storageId < 0) return -1;
+ for (Map.Entry<Integer, Integer> entry : storageConfig.displayToStorageIdMap.entrySet()) {
+ if (entry.getValue() == storageId) {
+ return entry.getKey();
+ }
+ }
+ return -1;
+ }
+
+ public int getDisplayIdForStorageIdRender(int storageId) {
+ if (storageId < 0) return -1;
+ for (Map.Entry<Integer, Integer> entry : storageConfig.displayToStorageIdMapRender.entrySet()) {
+ if (entry.getValue() == storageId) {
+ return entry.getKey();
+ }
+ }
+ return -1;
+ }
+
+ public boolean onAnyClick() {
+ if (onStorageMenu && desiredStoragePage >= 0) {
+ if (desiredStoragePage < 9) {
+ sendMouseClick(getCurrentWindowId(), 9 + desiredStoragePage);
+ } else {
+ sendMouseClick(getCurrentWindowId(), 27 + desiredStoragePage - MAX_ENDER_CHEST_PAGES);
+ }
+ desiredStoragePage = -1;
+ return true;
+ }
+ return false;
+ }
+
+ public void openWindowPacket(S2DPacketOpenWindow packet) {
+ shouldRenderStorageOverlayCached = false;
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
+
+ String windowTitle = Utils.cleanColour(packet.getWindowTitle().getUnformattedText());
+
+ Matcher matcher = WINDOW_REGEX.matcher(windowTitle);
+ Matcher matcherEchest = ECHEST_WINDOW_REGEX.matcher(windowTitle);
+
+ currentStoragePage = -1;
+ onStorageMenu = false;
+
+ if (windowTitle.trim().equals("Storage")) {
+ onStorageMenu = true;
+ } else if (matcher.matches()) {
+ int page = Integer.parseInt(matcher.group(1));
+
+ if (page > 0 && page <= 18) {
+ currentStoragePage = page - 1 + MAX_ENDER_CHEST_PAGES;
+
+ int displayId = getDisplayIdForStorageId(currentStoragePage);
+ if (displayId >= 0) StorageOverlay.getInstance().scrollToStorage(displayId, false);
+
+ StoragePage spage = getCurrentPage();
+ if (spage != null) {
+ spage.rows = packet.getSlotCount() / 9 - 1;
+ }
+ }
+ } else if (matcherEchest.matches()) {
+ int page = Integer.parseInt(matcherEchest.group(1));
+
+ if (page > 0 && page <= 9) {
+ currentStoragePage = page - 1;
+
+ int displayId = getDisplayIdForStorageId(currentStoragePage);
+ if (displayId >= 0) StorageOverlay.getInstance().scrollToStorage(displayId, false);
+
+ StoragePage spage = getCurrentPage();
+ if (spage != null) {
+ spage.rows = packet.getSlotCount() / 9 - 1;
+ }
+ }
+ } else {
+ StorageOverlay.getInstance().clearSearch();
+ return;
+ }
+ StorageOverlay.getInstance().fastRenderCheck();
+
+ }
+
+ public void closeWindowPacket(S2EPacketCloseWindow packet) {
+ shouldRenderStorageOverlayCached = false;
+ }
+
+ public void setSlotPacket(S2FPacketSetSlot packet) {
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
+ if (getCurrentWindowId() == -1 || getCurrentWindowId() != packet.func_149175_c()) return;
+
+ if (getCurrentPageId() != -1) {
+ StoragePage page = getCurrentPage();
+
+ int slot = packet.func_149173_d();
+ if (page != null && slot >= 9 && slot < 9 + page.rows * 9) {
+ setItemSlot(packet.func_149173_d() - 9, packet.func_149174_e());
+ }
+ } else if (onStorageMenu) {
+ if (storagePresent == null) {
+ storagePresent = new boolean[27];
+ }
+
+ int slot = packet.func_149173_d();
+ ItemStack stack = packet.func_149174_e();
+
+ if (slot >= 9 && slot < 18) {
+ int index = slot - 9;
+
+ boolean changed = false;
+ if (stack.getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) &&
+ stack.getMetadata() == 14) {
+ if (storagePresent[index]) changed = true;
+ storagePresent[index] = false;
+ removePage(index);
+ } else {
+ if (!storagePresent[index]) changed = true;
+ storagePresent[index] = true;
+ getPage(index, true).backpackDisplayStack = stack;
+ }
+
+ if (changed) {
+ synchronized (storageConfig.displayToStorageIdMap) {
+ storageConfig.displayToStorageIdMap.clear();
+ storageConfig.displayToStorageIdMapRender.clear();
+ int displayIndex = 0;
+ for (int i = 0; i < storagePresent.length; i++) {
+ if (storagePresent[i]) {
+ storageConfig.displayToStorageIdMap.put(displayIndex, i);
+ if (lastSearch != null && !lastSearch.isEmpty()) {
+ StoragePage page = getPage(i, false);
+
+ if (page != null) {
+ updateSearchForPage(lastSearch, page);
+ if (page.matchesSearch) {
+ storageConfig.displayToStorageIdMapRender.put(displayIndex++, i);
+ }
+ }
+ } else
+ storageConfig.displayToStorageIdMapRender.put(displayIndex++, i);
+ }
+ }
+ }
+ }
+ }
+
+ if (slot >= 27 && slot < 45) {
+ int index = (slot - 27) % 9 + (slot - 27) / 9 * 9 + MAX_ENDER_CHEST_PAGES;
+
+ boolean changed = false;
+
+ if (stack.getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane)) {
+ if (storagePresent[index]) changed = true;
+ storagePresent[index] = false;
+ removePage(index);
+ } else {
+ if (!storagePresent[index]) changed = true;
+ storagePresent[index] = true;
+ getPage(index, true).backpackDisplayStack = stack;
+ }
+
+ if (changed) {
+ synchronized (storageConfig.displayToStorageIdMap) {
+ storageConfig.displayToStorageIdMap.clear();
+ storageConfig.displayToStorageIdMapRender.clear();
+ int displayIndex = 0;
+ for (int i = 0; i < storagePresent.length; i++) {
+ if (storagePresent[i]) {
+ storageConfig.displayToStorageIdMap.put(displayIndex, i);
+ if (lastSearch != null && !lastSearch.isEmpty()) {
+ StoragePage page = getPage(i, false);
+
+ if (page != null) {
+ updateSearchForPage(lastSearch, page);
+ if (page.matchesSearch) {
+ storageConfig.displayToStorageIdMapRender.put(displayIndex++, i);
+ }
+ }
+ } else
+ storageConfig.displayToStorageIdMapRender.put(displayIndex++, i);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public void updateSearchForPage(String searchStr, StoragePage page) {
+ if (page == null) {
+ return;
+ }
+
+ if (page.rows <= 0) {
+ page.matchesSearch = true;
+ return;
+ }
+
+ if (page.searchedId > searchId.get()) {
+ page.searchedId = -1;
+ return;
+ }
+ if (page.searchedId == searchId.get()) {
+ return;
+ }
+
+ page.searchedId = searchId.get();
+
+ if (searchStr == null || searchStr.trim().isEmpty()) {
+ page.matchesSearch = true;
+ return;
+ }
+
+ for (ItemStack stack : page.items) {
+ if (stack != null && NotEnoughUpdates.INSTANCE.manager.doesStackMatchSearch(stack, searchStr)) {
+ page.matchesSearch = true;
+ return;
+ }
+ }
+ page.matchesSearch = false;
+ }
+
+ public void searchDisplay(String searchStr) {
+ if (storagePresent == null) return;
+
+ synchronized (storageConfig.displayToStorageIdMapRender) {
+ storageConfig.displayToStorageIdMapRender.clear();
+
+ lastSearch = searchStr;
+ int sid = searchId.incrementAndGet();
+ int displayIndex = 0;
+ for (int i = 0; i < storagePresent.length; i++) {
+ if (storagePresent[i]) {
+ StoragePage page = getPage(i, false);
+ if (page != null) {
+ if (page.rows > 0) {
+ updateSearchForPage(searchStr, page);
+ if (page.matchesSearch) {
+ storageConfig.displayToStorageIdMapRender.put(displayIndex++, i);
+ }
+ } else {
+ storageConfig.displayToStorageIdMapRender.put(displayIndex++, i);
+ page.matchesSearch = true;
+ page.searchedId = sid;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public void setItemsPacket(S30PacketWindowItems packet) {
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
+ if (getCurrentWindowId() == -1 || getCurrentWindowId() != packet.func_148911_c()) return;
+
+ if (getCurrentPageId() != -1) {
+ StoragePage page = getPage(getCurrentPageId(), false);
+
+ if (page != null) {
+ int max = Math.min(page.rows * 9, packet.getItemStacks().length - 9);
+ for (int i = 0; i < max; i++) {
+ setItemSlot(i, packet.getItemStacks()[i + 9]);
+ }
+ }
+
+ }
+ }
+
+ public void clientSendWindowClick(C0EPacketClickWindow packet) {
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
+ if (getCurrentWindowId() == -1 || getCurrentWindowId() != packet.getWindowId()) return;
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) return;
+ ContainerChest containerChest = (ContainerChest) ((GuiChest) Minecraft.getMinecraft().currentScreen).inventorySlots;
+
+ if (getCurrentPageId() != -1) {
+ StoragePage page = getCurrentPage();
+ if (page == null) return;
+
+ IInventory inv = containerChest.getLowerChestInventory();
+ int max = Math.min(9 + page.rows * 9, inv.getSizeInventory());
+ for (int i = 9; i < max; i++) {
+ setItemSlot(i - 9, inv.getStackInSlot(i));
+ }
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StreamerMode.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StreamerMode.java
index 40b75e50..064f41ca 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StreamerMode.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StreamerMode.java
@@ -2,39 +2,34 @@ package io.github.moulberry.notenoughupdates.miscfeatures;
import io.github.moulberry.notenoughupdates.util.Utils;
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintWriter;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class StreamerMode {
-
- private static final Pattern lobbyPattern = Pattern.compile("(mini|mega|m|M)([0-9]{1,3}[A-Z])");
-
- public static String filterLobbyNames(String line) {
- Matcher matcher = lobbyPattern.matcher(line);
- if(matcher.find() && matcher.groupCount() == 2) {
- String lobbyType = matcher.group(1);
- String lobbyId = matcher.group(2);
- long lobbyNum = Long.parseLong(lobbyId.substring(0, lobbyId.length()-1));
-
- long obfLobbyNum = (lobbyNum*9182739 + 11) % 500;
- char obfLobbyLetter = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".charAt((int)(obfLobbyNum%26));
-
- line = line.replaceAll("(mini|mega|m|M)([0-9]{1,3}[A-Z])", lobbyType+obfLobbyNum+obfLobbyLetter);
- }
- return line;
- }
-
- public static String filterScoreboard(String line) {
- line = filterLobbyNames(Utils.cleanDuplicateColourCodes(line));
- return line;
- }
-
- public static String filterChat(String line) {
- line = filterLobbyNames(line);
- return line;
- }
-
+ private static final Pattern lobbyPattern = Pattern.compile("(mini|mega|m|M)([0-9]{1,3}[A-Z])");
+
+ public static String filterLobbyNames(String line) {
+ Matcher matcher = lobbyPattern.matcher(line);
+ if (matcher.find() && matcher.groupCount() == 2) {
+ String lobbyType = matcher.group(1);
+ String lobbyId = matcher.group(2);
+ long lobbyNum = Long.parseLong(lobbyId.substring(0, lobbyId.length() - 1));
+
+ long obfLobbyNum = (lobbyNum * 9182739 + 11) % 500;
+ char obfLobbyLetter = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".charAt((int) (obfLobbyNum % 26));
+
+ line = line.replaceAll("(mini|mega|m|M)([0-9]{1,3}[A-Z])", lobbyType + obfLobbyNum + obfLobbyLetter);
+ }
+ return line;
+ }
+
+ public static String filterScoreboard(String line) {
+ line = filterLobbyNames(Utils.cleanDuplicateColourCodes(line));
+ return line;
+ }
+
+ public static String filterChat(String line) {
+ line = filterLobbyNames(line);
+ return line;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SunTzu.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SunTzu.java
index 8b690765..27cf42ac 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SunTzu.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SunTzu.java
@@ -12,82 +12,88 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import java.util.Random;
public class SunTzu {
-
- private static boolean enabled = false;
- private static int quoteNum = 0;
-
- private static Random rand = new Random();
-
- private static String[] quotes = new String[] {
- "Appear weak when you are strong, and strong when you are weak.",
- "The supreme art of war is to subdue the enemy without fighting.",
- "If you know the enemy and know yourself, you need not fear the result of a hundred battles.",
- "Let your plans be dark and impenetrable as night, and when you move, fall like a thunderbolt.",
- "All warfare is based on deception.",
- "In the midst of chaos, there is also opportunity.",
- "The greatest victory is that which requires no battle.",
- "To know your Enemy, you must become your Enemy.",
- "There is no instance of a nation benefitting from prolonged warfare.",
- "Even the finest sword plunged into salt water will eventually rust.",
- "Opportunities multiply as they are seized.",
- "When the enemy is relaxed, make them toil. When full, starve them. When settled, make them move.",
- "He who wishes to fight must first count the cost",
- "If you wait by the river long enough, the bodies of your enemies will float by.",
- "Be extremely subtle even to the point of formlessness. Be extremely mysterious even to the point of soundlessness. Thereby you can be the director of the opponent's fate.",
- "Build your opponent a golden bridge to retreat across.",
- "The wise warrior avoids the battle.",
- "Great results, can be achieved with small forces.",
- "Attack is the secret of defense; defense is the planning of an attack.",
- "Subscribe to Moulberry on YouTube."
- };
-
- public static void setEnabled(boolean enabled) {
- SunTzu.enabled = enabled;
- }
-
- public static void randomizeQuote() {
- for(int i=0; i<3; i++) {
- int newQuote = rand.nextInt(quotes.length);
-
- if(newQuote != quoteNum) {
- quoteNum = newQuote;
- return;
- }
- }
- }
-
- private static String getQuote() {
- return quotes[quoteNum];
- }
-
- @SubscribeEvent
- public void onOverlayDrawn(RenderGameOverlayEvent event) {
- if(enabled && ((event.type == null && Loader.isModLoaded("labymod")) ||
- event.type == RenderGameOverlayEvent.ElementType.ALL)) {
- if(Minecraft.getMinecraft().gameSettings.showDebugInfo ||
- (Minecraft.getMinecraft().gameSettings.keyBindPlayerList.isKeyDown() &&
- (!Minecraft.getMinecraft().isIntegratedServerRunning() ||
- Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap().size() > 1))) {
- return;
- }
-
- ScaledResolution sr = Utils.pushGuiScale(2);
-
- int height = Utils.renderStringTrimWidth(EnumChatFormatting.YELLOW+getQuote(), Minecraft.getMinecraft().fontRendererObj,
- true, sr.getScaledWidth()/2-100, 5, 200, -1, -1);
- String sunTzu = "- Sun Tzu, The Art of War";
- int sunTzuLength = Minecraft.getMinecraft().fontRendererObj.getStringWidth(sunTzu);
- Minecraft.getMinecraft().fontRendererObj.drawString(EnumChatFormatting.GOLD+sunTzu,
- sr.getScaledWidth()/2f+100-sunTzuLength, 15+height, 0, true);
-
- Utils.pushGuiScale(-1);
- }
- }
-
- @SubscribeEvent
- public void switchWorld(WorldEvent.Load event) {
- randomizeQuote();
- }
-
-
+ private static boolean enabled = false;
+ private static int quoteNum = 0;
+
+ private static final Random rand = new Random();
+
+ private static final String[] quotes = new String[]{
+ "Appear weak when you are strong, and strong when you are weak.",
+ "The supreme art of war is to subdue the enemy without fighting.",
+ "If you know the enemy and know yourself, you need not fear the result of a hundred battles.",
+ "Let your plans be dark and impenetrable as night, and when you move, fall like a thunderbolt.",
+ "All warfare is based on deception.",
+ "In the midst of chaos, there is also opportunity.",
+ "The greatest victory is that which requires no battle.",
+ "To know your Enemy, you must become your Enemy.",
+ "There is no instance of a nation benefitting from prolonged warfare.",
+ "Even the finest sword plunged into salt water will eventually rust.",
+ "Opportunities multiply as they are seized.",
+ "When the enemy is relaxed, make them toil. When full, starve them. When settled, make them move.",
+ "He who wishes to fight must first count the cost",
+ "If you wait by the river long enough, the bodies of your enemies will float by.",
+ "Be extremely subtle even to the point of formlessness. Be extremely mysterious even to the point of soundlessness. Thereby you can be the director of the opponent's fate.",
+ "Build your opponent a golden bridge to retreat across.",
+ "The wise warrior avoids the battle.",
+ "Great results, can be achieved with small forces.",
+ "Attack is the secret of defense; defense is the planning of an attack.",
+ "Subscribe to Moulberry on YouTube."
+ };
+
+ public static void setEnabled(boolean enabled) {
+ SunTzu.enabled = enabled;
+ }
+
+ public static void randomizeQuote() {
+ for (int i = 0; i < 3; i++) {
+ int newQuote = rand.nextInt(quotes.length);
+
+ if (newQuote != quoteNum) {
+ quoteNum = newQuote;
+ return;
+ }
+ }
+ }
+
+ private static String getQuote() {
+ return quotes[quoteNum];
+ }
+
+ @SubscribeEvent
+ public void onOverlayDrawn(RenderGameOverlayEvent event) {
+ if (enabled && ((event.type == null && Loader.isModLoaded("labymod")) ||
+ event.type == RenderGameOverlayEvent.ElementType.ALL)) {
+ if (Minecraft.getMinecraft().gameSettings.showDebugInfo ||
+ (Minecraft.getMinecraft().gameSettings.keyBindPlayerList.isKeyDown() &&
+ (!Minecraft.getMinecraft().isIntegratedServerRunning() ||
+ Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap().size() > 1))) {
+ return;
+ }
+
+ ScaledResolution sr = Utils.pushGuiScale(2);
+
+ int height = Utils.renderStringTrimWidth(
+ EnumChatFormatting.YELLOW + getQuote(),
+ Minecraft.getMinecraft().fontRendererObj,
+ true,
+ sr.getScaledWidth() / 2 - 100,
+ 5,
+ 200,
+ -1,
+ -1
+ );
+ String sunTzu = "- Sun Tzu, The Art of War";
+ int sunTzuLength = Minecraft.getMinecraft().fontRendererObj.getStringWidth(sunTzu);
+ Minecraft.getMinecraft().fontRendererObj.drawString(EnumChatFormatting.GOLD + sunTzu,
+ sr.getScaledWidth() / 2f + 100 - sunTzuLength, 15 + height, 0, true
+ );
+
+ Utils.pushGuiScale(-1);
+ }
+ }
+
+ @SubscribeEvent
+ public void switchWorld(WorldEvent.Load event) {
+ randomizeQuote();
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/CrystalHollowsTextures.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/CrystalHollowsTextures.java
new file mode 100644
index 00000000..36858276
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/CrystalHollowsTextures.java
@@ -0,0 +1,22 @@
+package io.github.moulberry.notenoughupdates.miscfeatures.customblockzones;
+
+import net.minecraft.util.BlockPos;
+
+public class CrystalHollowsTextures implements IslandZoneSubdivider {
+ public SpecialBlockZone getSpecialZoneForBlock(String location, BlockPos pos) {
+ if (pos.getY() < 65) {
+ return SpecialBlockZone.CRYSTAL_HOLLOWS_MAGMA_FIELDS;
+ } else if (pos.getX() < 565 && pos.getX() > 461 && pos.getZ() < 566 && pos.getZ() > 460 && pos.getY() > 64) {
+ return SpecialBlockZone.CRYSTAL_HOLLOWS_NUCLEUS;
+ } else if (pos.getX() < 513 && pos.getZ() < 513 && pos.getY() > 64) {
+ return SpecialBlockZone.CRYSTAL_HOLLOWS_JUNGLE;
+ } else if (pos.getX() < 513 && pos.getZ() > 512 && pos.getY() > 64) {
+ return SpecialBlockZone.CRYSTAL_HOLLOWS_GOBLIN_HIDEOUT;
+ } else if (pos.getX() > 512 && pos.getZ() < 513 && pos.getY() > 64) {
+ return SpecialBlockZone.CRYSTAL_HOLLOWS_MITHRIL_DEPOSIT;
+ } else if (pos.getX() > 512 && pos.getZ() > 512 && pos.getY() > 64) {
+ return SpecialBlockZone.CRYSTAL_HOLLOWS_PRECURSOR_REMNANTS;
+ }
+ return null;
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/CustomBiomes.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/CustomBiomes.java
new file mode 100644
index 00000000..9a6f9cac
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/CustomBiomes.java
@@ -0,0 +1,152 @@
+package io.github.moulberry.notenoughupdates.miscfeatures.customblockzones;
+
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.events.OnBlockBreakSoundEffect;
+import io.github.moulberry.notenoughupdates.util.SBInfo;
+import net.minecraft.block.BlockColored;
+import net.minecraft.block.BlockStone;
+import net.minecraft.block.state.IBlockState;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.entity.EntityPlayerSP;
+import net.minecraft.client.multiplayer.WorldClient;
+import net.minecraft.init.Blocks;
+import net.minecraft.item.EnumDyeColor;
+import net.minecraft.util.BlockPos;
+import net.minecraft.world.biome.BiomeGenBase;
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class CustomBiomes {
+
+ public static final CustomBiomes INSTANCE = new CustomBiomes();
+
+ private final Map<String, IslandZoneSubdivider> subdividers = new HashMap<>();
+
+ private CustomBiomes() {
+ subdividers.put("crystal_hollows", new CrystalHollowsTextures());
+ subdividers.put("mining_3", new DwarvenMinesTextures());
+ }
+
+ //Biome Prefix: NeuAreaBiomeName
+ //Example: NeuCHJungle
+
+ public BiomeGenBase getCustomBiome(BlockPos pos) {
+ SpecialBlockZone specialZone = getSpecialZone(pos);
+ if (specialZone != null) {
+ if ((specialZone.isDwarvenMines() && NotEnoughUpdates.INSTANCE.config.mining.dwarvenTextures)
+ || (specialZone.isCrystalHollows() && NotEnoughUpdates.INSTANCE.config.mining.crystalHollowTextures))
+ return specialZone.getCustomBiome();
+ }
+ return null;
+ }
+
+ /**
+ * Finds the special zone for the give block position
+ * <p>
+ * Returns null on error
+ */
+ public SpecialBlockZone getSpecialZone(BlockPos pos) {
+ if (Minecraft.getMinecraft().theWorld == null) return null;
+ String location = SBInfo.getInstance().getLocation();
+ IslandZoneSubdivider subdivider = subdividers.get(location);
+ if (subdivider == null) return SpecialBlockZone.NON_SPECIAL_ZONE;
+ return subdivider.getSpecialZoneForBlock(location, pos);
+ }
+
+ @SubscribeEvent
+ public void onBreakSound(OnBlockBreakSoundEffect event) {
+ SpecialBlockZone specialZone = getSpecialZone(event.getPosition());
+ boolean hasMithrilSounds = NotEnoughUpdates.INSTANCE.config.mining.mithrilSounds;
+ boolean hasCrystalSounds = NotEnoughUpdates.INSTANCE.config.mining.gemstoneSounds;
+ if (specialZone != null) {
+ CustomBlockSounds.CustomSoundEvent customSound = null;
+ if (specialZone.hasMithril() && isBreakableMithril(event.getBlock()) && hasMithrilSounds &&
+ SBInfo.getInstance().getLocation().equals("mining_3")) {
+ customSound = CustomBlockSounds.mithrilBreak;
+ }
+ if (specialZone.hasMithril() && isMithrilHollows(event.getBlock()) && hasMithrilSounds &&
+ SBInfo.getInstance().getLocation().equals("crystal_hollows")) {
+ customSound = CustomBlockSounds.mithrilBreak;
+ }
+ if (specialZone.hasTitanium() && isTitanium(event.getBlock()) && hasMithrilSounds) {
+ customSound = CustomBlockSounds.titaniumBreak;
+ }
+
+ if (specialZone.hasGemstones() && isGemstone(event.getBlock(), EnumDyeColor.RED) && hasCrystalSounds) {
+ customSound = CustomBlockSounds.gemstoneBreakRuby;
+ }
+ if (specialZone.hasGemstones() && isGemstone(event.getBlock(), EnumDyeColor.YELLOW) && hasCrystalSounds) {
+ customSound = CustomBlockSounds.gemstoneBreakTopaz;
+ }
+ if (specialZone.hasGemstones() && isGemstone(event.getBlock(), EnumDyeColor.PINK) && hasCrystalSounds) {
+ customSound = CustomBlockSounds.gemstoneBreakJasper;
+ }
+ if (specialZone.hasGemstones() && isGemstone(event.getBlock(), EnumDyeColor.LIGHT_BLUE) && hasCrystalSounds) {
+ customSound = CustomBlockSounds.gemstoneBreakSapphire;
+ }
+ if (specialZone.hasGemstones() && isGemstone(event.getBlock(), EnumDyeColor.ORANGE) && hasCrystalSounds) {
+ customSound = CustomBlockSounds.gemstoneBreakAmber;
+ }
+ if (specialZone.hasGemstones() && isGemstone(event.getBlock(), EnumDyeColor.PURPLE) && hasCrystalSounds) {
+ customSound = CustomBlockSounds.gemstoneBreakAmethyst;
+ }
+ if (specialZone.hasGemstones() && isGemstone(event.getBlock(), EnumDyeColor.LIME) && hasCrystalSounds) {
+ customSound = CustomBlockSounds.gemstoneBreakJade;
+ }
+
+ if (customSound != null) {
+ if (customSound.shouldReplace()) {
+ event.setSound(customSound.replaceSoundEvent(event.getSound()));
+ } else {
+ event.setCanceled(true);
+ }
+ }
+ }
+ }
+
+ public static boolean isTitanium(IBlockState state) {
+ return state.getBlock() == Blocks.stone && state.getValue(BlockStone.VARIANT) == BlockStone.EnumType.DIORITE_SMOOTH;
+ }
+
+ public static boolean isMithril(IBlockState state) {
+ return isBreakableMithril(state)
+ || state.getBlock() == Blocks.bedrock;
+ }
+
+ public static boolean isBreakableMithril(IBlockState state) {
+ return (state.getBlock() == Blocks.stained_hardened_clay && state.getValue(BlockColored.COLOR) == EnumDyeColor.CYAN)
+ || (state.getBlock() == Blocks.wool && state.getValue(BlockColored.COLOR) == EnumDyeColor.GRAY)
+ || (state.getBlock() == Blocks.wool && state.getValue(BlockColored.COLOR) == EnumDyeColor.LIGHT_BLUE)
+ || state.getBlock() == Blocks.prismarine;
+ }
+
+ public static boolean isMithrilHollows(IBlockState state) {
+ return state.getBlock() == Blocks.prismarine
+ || (state.getBlock() == Blocks.wool && state.getValue(BlockColored.COLOR) == EnumDyeColor.LIGHT_BLUE);
+ }
+
+ public static boolean isGemstone(IBlockState state, EnumDyeColor color) {
+ return ((state.getBlock() == Blocks.stained_glass || state.getBlock() == Blocks.stained_glass_pane) &&
+ state.getValue(BlockColored.COLOR) == color);
+ }
+
+ @SubscribeEvent
+ public void onLocationChange(LocationChangeEvent event) {
+ WorldClient world = Minecraft.getMinecraft().theWorld;
+ String location = event.newLocation;
+ if (world == null) return;
+ if (location == null) return;
+ switch (location.intern()) {
+ case "crystal_hollows":
+ case "mining_3":
+ //if has custom biome, do chunk update or something
+ EntityPlayerSP player = Minecraft.getMinecraft().thePlayer;
+ if (player == null) return;
+
+ world.markBlocksDirtyVertical((int) player.posX, (int) player.posX, (int) player.posZ, (int) player.posZ);
+ }
+ }
+
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/CustomBlockSounds.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/CustomBlockSounds.java
new file mode 100644
index 00000000..dec011d3
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/CustomBlockSounds.java
@@ -0,0 +1,104 @@
+package io.github.moulberry.notenoughupdates.miscfeatures.customblockzones;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonObject;
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.audio.ISound;
+import net.minecraft.client.audio.PositionedSoundRecord;
+import net.minecraft.client.resources.IResource;
+import net.minecraft.client.resources.IResourceManager;
+import net.minecraft.client.resources.IResourceManagerReloadListener;
+import net.minecraft.util.ResourceLocation;
+
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+
+public class CustomBlockSounds {
+
+ static Gson gson = new Gson();
+
+ static List<CustomSoundEvent> allCustomSoundEvents = new ArrayList<>();
+
+ public static final CustomSoundEvent mithrilBreak = newCustomSoundEvent("mithril");
+ public static final CustomSoundEvent gemstoneBreakRuby = newCustomSoundEvent("gemstoneRuby");
+ public static final CustomSoundEvent gemstoneBreakAmber = newCustomSoundEvent("gemstoneAmber");
+ public static final CustomSoundEvent gemstoneBreakAmethyst = newCustomSoundEvent("gemstoneAmethyst");
+ public static final CustomSoundEvent gemstoneBreakSapphire = newCustomSoundEvent("gemstoneSapphire");
+ public static final CustomSoundEvent gemstoneBreakJade = newCustomSoundEvent("gemstoneJade");
+ public static final CustomSoundEvent gemstoneBreakTopaz = newCustomSoundEvent("gemstoneTopaz");
+ public static final CustomSoundEvent gemstoneBreakJasper = newCustomSoundEvent("gemstoneJasper");
+ public static final CustomSoundEvent titaniumBreak = newCustomSoundEvent("titanium");
+
+ public static class ReloaderListener implements IResourceManagerReloadListener {
+ @Override
+ public void onResourceManagerReload(IResourceManager iResourceManager) {
+ allCustomSoundEvents.forEach(CustomSoundEvent::reload);
+ }
+ }
+
+ public static class CustomSoundEvent {
+ public ResourceLocation soundEvent;
+ public ResourceLocation configFile;
+ private boolean loaded = false;
+ private int timer = 0;
+ private long lastReplaced = 0L;
+
+ public CustomSoundEvent() {
+ allCustomSoundEvents.add(this);
+ }
+
+ public boolean shouldReplace() {
+ if (!loaded) reload();
+ if (timer < 0) return true;
+ long now = System.currentTimeMillis();
+ if (now - lastReplaced >= timer) {
+ lastReplaced = now;
+ return true;
+ }
+ return false;
+ }
+
+ public ISound replaceSoundEvent(ISound sound) {
+ return new PositionedSoundRecord(
+ this.soundEvent,
+ sound.getPitch(), sound.getVolume(),
+ sound.getXPosF(), sound.getYPosF(), sound.getZPosF()
+ );
+ }
+
+ public void reload() {
+ loaded = true;
+ IResource resource;
+ try {
+ resource = Minecraft.getMinecraft().getResourceManager().getResource(configFile);
+ } catch (IOException e) {
+ timer = -1;
+ return;
+ }
+ try (Reader r = new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8)) {
+ JsonObject jsonObject = gson.fromJson(r, JsonObject.class);
+ timer = jsonObject.getAsJsonPrimitive("debouncer").getAsInt() * 1000 / 20;
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ }
+
+ private static CustomSoundEvent newCustomSoundEvent(String soundEvent) {
+ CustomSoundEvent event = new CustomSoundEvent();
+ event.soundEvent = new ResourceLocation("notenoughupdates", soundEvent + ".break");
+ event.configFile = new ResourceLocation(
+ "notenoughupdates",
+ "sounds/" + soundEvent.toLowerCase(Locale.ROOT) + "break.json"
+ );
+ return event;
+ }
+
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/DwarvenMinesTextures.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/DwarvenMinesTextures.java
new file mode 100644
index 00000000..faf7eabe
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/DwarvenMinesTextures.java
@@ -0,0 +1,194 @@
+package io.github.moulberry.notenoughupdates.miscfeatures.customblockzones;
+
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import net.minecraft.block.state.IBlockState;
+import net.minecraft.client.Minecraft;
+import net.minecraft.init.Blocks;
+import net.minecraft.util.BlockPos;
+import net.minecraft.util.EnumFacing;
+import net.minecraft.util.MathHelper;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.world.ChunkCoordIntPair;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import static io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.CustomBiomes.isMithril;
+import static io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.CustomBiomes.isTitanium;
+
+public class DwarvenMinesTextures implements IslandZoneSubdivider {
+
+ private static class IgnoreColumn {
+ boolean always;
+ int minY;
+ int maxY;
+
+ public IgnoreColumn(boolean always, int minY, int maxY) {
+ this.always = always;
+ this.minY = minY;
+ this.maxY = maxY;
+ }
+ }
+
+ private Set<ChunkCoordIntPair> ignoredChunks = null;
+ private final Map<ChunkCoordIntPair, Map<ChunkCoordIntPair, IgnoreColumn>> loadedChunkData = new HashMap<>();
+ private boolean error = false;
+
+ private IBlockState getBlock(BlockPos pos) {
+ return Minecraft.getMinecraft().theWorld.getBlockState(pos);
+ }
+
+ private boolean isDoubleSlab(IBlockState state) {
+ return state.getBlock() == Blocks.double_stone_slab;
+ }
+
+ private Reader getUTF8Resource(ResourceLocation location) throws IOException {
+ return new BufferedReader(new InputStreamReader(Minecraft
+ .getMinecraft()
+ .getResourceManager()
+ .getResource(location)
+ .getInputStream(), StandardCharsets.UTF_8));
+ }
+
+ private void loadIgnoredChunks() {
+ ignoredChunks = new HashSet<>();
+ try (Reader reader = getUTF8Resource(new ResourceLocation("notenoughupdates:dwarven_data/all.json"))) {
+ JsonObject json = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(reader, JsonObject.class);
+ for (Map.Entry<String, JsonElement> entry : json.entrySet()) {
+ String coord = entry.getKey();
+ String[] split = coord.split("_");
+ int left = Integer.parseInt(split[0]);
+ int right = Integer.parseInt(split[1]);
+ ignoredChunks.add(new ChunkCoordIntPair(left, right));
+ }
+ } catch (IOException e) {
+ ignoredChunks = null;
+ error = true;
+ System.out.println("NEU failed to load dwarven mines ignore chunks: ");
+ e.printStackTrace();
+ }
+ }
+
+ private Set<ChunkCoordIntPair> getIgnoredChunks() {
+ if (ignoredChunks == null)
+ synchronized (this) {
+ if (ignoredChunks != null) return ignoredChunks;
+ loadIgnoredChunks();
+ }
+ return ignoredChunks;
+ }
+
+ private IgnoreColumn parseIgnoreColumn(JsonElement element) {
+ if (element.isJsonPrimitive()) {
+ JsonPrimitive prim = element.getAsJsonPrimitive();
+ if (prim.isBoolean()) {
+ return new IgnoreColumn(true, 0, 0);
+ } else if (prim.isNumber()) {
+ int y = prim.getAsInt();
+ return new IgnoreColumn(false, y, y);
+ }
+ }
+ if (element.isJsonArray()) {
+ JsonArray arr = element.getAsJsonArray();
+ if (arr.size() == 2) {
+ int min = arr.get(0).getAsInt();
+ int max = arr.get(1).getAsInt();
+ return new IgnoreColumn(false, min, max);
+ }
+ }
+ return null;
+ }
+
+ private Map<ChunkCoordIntPair, IgnoreColumn> loadChunkData(ChunkCoordIntPair pair) {
+ Map<ChunkCoordIntPair, IgnoreColumn> map = new HashMap<>();
+ try {
+ ResourceLocation loc = new ResourceLocation("notenoughupdates:dwarven_data/" +
+ pair.chunkXPos + "_" + pair.chunkZPos + ".json");
+
+ try (Reader reader = getUTF8Resource(loc)) {
+ JsonObject json = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(reader, JsonObject.class);
+ for (Map.Entry<String, JsonElement> entry : json.entrySet()) {
+ String coord = entry.getKey();
+ String[] split = coord.split(":");
+ int left = Integer.parseInt(split[0]);
+ int right = Integer.parseInt(split[1]);
+
+ IgnoreColumn ignore = parseIgnoreColumn(entry.getValue());
+ if (ignore != null) {
+ ChunkCoordIntPair offset = new ChunkCoordIntPair(left, right);
+ map.put(offset, ignore);
+ }
+ }
+ }
+ } catch (Exception e) {
+ }
+ return map;
+ }
+
+ private Map<ChunkCoordIntPair, IgnoreColumn> getChunkData(ChunkCoordIntPair chunkCoordinates) {
+ synchronized (this) {
+ return loadedChunkData.computeIfAbsent(chunkCoordinates, this::loadChunkData);
+ }
+ }
+
+ @Override
+ public SpecialBlockZone getSpecialZoneForBlock(String location, BlockPos pos) {
+ if (error) return null;
+ IBlockState block = getBlock(pos);
+ boolean isTitanium = isTitanium(block);
+ boolean isMithril = isMithril(block);
+ if (isTitanium) {
+ for (EnumFacing direction : EnumFacing.values())
+ if (isDoubleSlab(getBlock(pos.offset(direction))))
+ return SpecialBlockZone.DWARVEN_MINES_NON_MITHRIL;
+ }
+ if (!isMithril && !isTitanium) return SpecialBlockZone.DWARVEN_MINES_NON_MITHRIL;
+
+ Set<ChunkCoordIntPair> ignoredChunks = getIgnoredChunks();
+ if (ignoredChunks == null)
+ return null;
+ ChunkCoordIntPair pair = new ChunkCoordIntPair(
+ MathHelper.floor_float(pos.getX() / 16f),
+ MathHelper.floor_float(pos.getZ() / 16f)
+ );
+
+ if (ignoredChunks.contains(pair)) {
+ return SpecialBlockZone.DWARVEN_MINES_NON_MITHRIL;
+ }
+ if (isTitanium) {
+ return SpecialBlockZone.DWARVEN_MINES_MITHRIL;
+ }
+
+ Map<ChunkCoordIntPair, IgnoreColumn> chunkData = getChunkData(pair);
+ if (chunkData == null || error) return null;
+
+ int modX = pos.getX() % 16;
+ int modZ = pos.getZ() % 16;
+ if (modX < 0) modX += 16;
+ if (modZ < 0) modZ += 16;
+ ChunkCoordIntPair subChunkCoordinates = new ChunkCoordIntPair(modX, modZ);
+
+ IgnoreColumn ignore = chunkData.get(subChunkCoordinates);
+ if (ignore != null) {
+ if (ignore.always) {
+ return SpecialBlockZone.DWARVEN_MINES_NON_MITHRIL;
+ }
+ int y = pos.getY();
+ if (ignore.minY <= y && y <= ignore.maxY) {
+ return SpecialBlockZone.DWARVEN_MINES_NON_MITHRIL;
+ }
+ }
+ return SpecialBlockZone.DWARVEN_MINES_MITHRIL;
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/IslandZoneSubdivider.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/IslandZoneSubdivider.java
new file mode 100644
index 00000000..8b00bc85
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/IslandZoneSubdivider.java
@@ -0,0 +1,7 @@
+package io.github.moulberry.notenoughupdates.miscfeatures.customblockzones;
+
+import net.minecraft.util.BlockPos;
+
+public interface IslandZoneSubdivider {
+ SpecialBlockZone getSpecialZoneForBlock(String location, BlockPos position);
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/LocationChangeEvent.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/LocationChangeEvent.java
new file mode 100644
index 00000000..c6f5e9c0
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/LocationChangeEvent.java
@@ -0,0 +1,13 @@
+package io.github.moulberry.notenoughupdates.miscfeatures.customblockzones;
+
+import net.minecraftforge.fml.common.eventhandler.Event;
+
+public class LocationChangeEvent extends Event {
+ public final String newLocation;
+ public final String oldLocation;
+
+ public LocationChangeEvent(String newLocation, String oldLocation) {
+ this.newLocation = newLocation;
+ this.oldLocation = oldLocation;
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/SpecialBlockZone.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/SpecialBlockZone.java
new file mode 100644
index 00000000..f4e8f1fc
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/customblockzones/SpecialBlockZone.java
@@ -0,0 +1,67 @@
+package io.github.moulberry.notenoughupdates.miscfeatures.customblockzones;
+
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import net.minecraft.world.biome.BiomeGenBase;
+
+public enum SpecialBlockZone {
+ DWARVEN_MINES_NON_MITHRIL(BiomeGenBase.extremeHillsPlus, false, false, false, true, false),
+ DWARVEN_MINES_MITHRIL(BiomeGenBase.extremeHillsEdge, true, true, false, true, false),
+ CRYSTAL_HOLLOWS_MAGMA_FIELDS(NotEnoughUpdates.crystalHollowsMagmaFields, true, false, true, false, true),
+ CRYSTAL_HOLLOWS_NUCLEUS(NotEnoughUpdates.crystalHollowsCrystalNucleus, true, false, true, false, true),
+ CRYSTAL_HOLLOWS_JUNGLE(NotEnoughUpdates.crystalHollowsJungle, true, false, true, false, true),
+ CRYSTAL_HOLLOWS_GOBLIN_HIDEOUT(NotEnoughUpdates.crystalHollowsGoblinHoldout, true, false, true, false, true),
+ CRYSTAL_HOLLOWS_MITHRIL_DEPOSIT(NotEnoughUpdates.crystalHollowsMithrilDeposit, true, false, true, false, true),
+ CRYSTAL_HOLLOWS_PRECURSOR_REMNANTS(NotEnoughUpdates.crystalHollowsPrecursorRemnants, true, false, true, false, true),
+ NON_SPECIAL_ZONE(null, false, false, false, false, false);
+
+ private final BiomeGenBase customBiome;
+ private final boolean hasMithril;
+ private final boolean hasTitanium;
+ private final boolean hasGemstones;
+ private final boolean isDwarvenMines;
+ private final boolean isCrystalHollows;
+
+ SpecialBlockZone(
+ BiomeGenBase customBiome,
+ boolean hasMithril,
+ boolean hasTitanium,
+ boolean hasGemstones,
+ boolean isDwarvenMines,
+ boolean isCrystalHollows
+ ) {
+ this.customBiome = customBiome;
+ this.hasMithril = hasMithril;
+ this.hasTitanium = hasTitanium;
+ this.hasGemstones = hasGemstones;
+ this.isDwarvenMines = isDwarvenMines;
+ this.isCrystalHollows = isCrystalHollows;
+ }
+
+ public BiomeGenBase getCustomBiome() {
+ return customBiome;
+ }
+
+ public boolean hasMithril() {
+ return hasMithril;
+ }
+
+ public boolean hasTitanium() {
+ return hasTitanium;
+ }
+
+ public boolean hasGemstones() {
+ return hasGemstones;
+ }
+
+ public boolean isDwarvenMines() {
+ return isDwarvenMines;
+ }
+
+ public boolean isCrystalHollows() {
+ return isCrystalHollows;
+ }
+
+ public boolean isMiningZone() {
+ return isCrystalHollows || isDwarvenMines;
+ }
+}
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 f5e784a4..8996dc7a 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java
@@ -5,6 +5,7 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.NEUEventListener;
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.profileviewer.PlayerStats;
import io.github.moulberry.notenoughupdates.util.Constants;
@@ -32,679 +33,948 @@ import org.lwjgl.opengl.GL14;
import java.awt.*;
import java.io.ByteArrayInputStream;
import java.io.IOException;
-import java.util.*;
import java.util.List;
+import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import static io.github.moulberry.notenoughupdates.util.GuiTextures.*;
+import static io.github.moulberry.notenoughupdates.util.GuiTextures.accessory_bag_overlay;
public class AccessoryBagOverlay {
-
- private static final int TAB_BASIC = 0;
- private static final int TAB_TOTAL = 1;
- private static final int TAB_BONUS = 2;
- private static final int TAB_DUP = 3;
- private static final int TAB_MISSING = 4;
- private static final int TAB_OPTIMIZER = 5;
-
- private static final ItemStack[] TAB_STACKS = new ItemStack[] {
- Utils.createItemStack(Items.dye, EnumChatFormatting.DARK_AQUA+"Basic Information",
- 10, EnumChatFormatting.GREEN+"- Talis count by rarity"),
- Utils.createItemStack(Items.diamond_sword, EnumChatFormatting.DARK_AQUA+"Total Stat Bonuses",
- 0),
- Utils.createItemStack(Item.getItemFromBlock(Blocks.anvil), EnumChatFormatting.DARK_AQUA+"Total Stat Bonuses (from reforges)",
- 0),
- Utils.createItemStack(Items.dye, EnumChatFormatting.DARK_AQUA+"Duplicates",
- 8),
- Utils.createItemStack(Item.getItemFromBlock(Blocks.barrier), EnumChatFormatting.DARK_AQUA+"Missing",
- 0),
- Utils.createItemStack(Item.getItemFromBlock(Blocks.redstone_block), EnumChatFormatting.DARK_AQUA+"Optimizer",
- 0),
- };
-
- private static int currentTab = TAB_BASIC;
-
- public static boolean mouseClick() {
- if(Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
- GuiChest eventGui = (GuiChest) Minecraft.getMinecraft().currentScreen;
- ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
- String containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText();
- if(!containerName.trim().startsWith("Accessory Bag")) {
- return false;
- }
- } else {
- return false;
- }
-
- if(!Mouse.getEventButtonState()) return false;
- try {
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
-
- int width = scaledResolution.getScaledWidth();
- int height = scaledResolution.getScaledHeight();
-
- int mouseX = Mouse.getX() / scaledResolution.getScaleFactor();
- int mouseY = height - Mouse.getY() / scaledResolution.getScaleFactor();
-
- int xSize = (int) Utils.getField(GuiContainer.class, Minecraft.getMinecraft().currentScreen, "xSize", "field_146999_f");
- int ySize = (int) Utils.getField(GuiContainer.class, Minecraft.getMinecraft().currentScreen, "ySize", "field_147000_g");
- int guiLeft = (int) Utils.getField(GuiContainer.class, Minecraft.getMinecraft().currentScreen, "guiLeft", "field_147003_i");
- int guiTop = (int) Utils.getField(GuiContainer.class, Minecraft.getMinecraft().currentScreen, "guiTop", "field_147009_r");
-
- if(mouseX < guiLeft+xSize+3 || mouseX > guiLeft+xSize+80+28) return false;
- if(mouseY < guiTop || mouseY > guiTop+166) return false;
-
- if(mouseX > guiLeft+xSize+83 && mouseY < guiTop+20*TAB_MISSING+22) {
- currentTab = (mouseY - guiTop)/20;
- if(currentTab < 0) currentTab = 0;
- if(currentTab > TAB_MISSING) currentTab = TAB_MISSING;
- }
-
- if(currentTab == TAB_OPTIMIZER) {
- int x = guiLeft+xSize+3;
- int y = guiTop;
-
- if(mouseY > y+92 && mouseY < y+103) {
- if(mouseX > x+5 && mouseX < x+75) {
- mainWeapon = (int)Math.floor((mouseX-x-5)/70f*9);
- if(mainWeapon < 1) {
- mainWeapon = 1;
- } else if(mainWeapon > 9) {
- mainWeapon = 9;
- }
- }
- }
-
- if(mouseX > x+5 && mouseX < x+35 || mouseX > x+45 && mouseX < x+75) {
- boolean set = mouseX > x+5 && mouseX < x+35;
-
- if(mouseY > y+32 && mouseY < y+43) {
- forceCC = set;
- } else if(mouseY > y+52 && mouseY < y+63) {
- forceAS = set;
- } else if(mouseY > y+72 && mouseY < y+83) {
- useGodPot = set;
- } else if(mouseY > y+92 && mouseY < y+103) {
- allowShaded = set;
- }
- }
- }
-
- return true;
- } catch(Exception e) {
- return false;
- }
- }
-
- public static void resetCache() {
- accessoryStacks = new HashSet<>();
- pagesVisited = new HashSet<>();
- talismanCountRarity = null;
- totalStats = null;
- reforgeStats = null;
- duplicates = null;
- missing = null;
- }
-
- private static Set<ItemStack> accessoryStacks = new HashSet<>();
- private static Set<Integer> pagesVisited = new HashSet<>();
-
- public static void renderVisitOverlay(int x, int y) {
- Utils.drawStringCenteredScaledMaxWidth("Please visit all", Minecraft.getMinecraft().fontRendererObj, x+40, y+78, true, 70, -1);
- Utils.drawStringCenteredScaledMaxWidth("pages of the bag", Minecraft.getMinecraft().fontRendererObj, x+40, y+86, true, 70, -1);
- }
-
- private static TreeMap<Integer, Integer> talismanCountRarity = null;
- public static void renderBasicOverlay(int x, int y) {
- if(talismanCountRarity == null) {
- talismanCountRarity = new TreeMap<>();
- for(ItemStack stack : accessoryStacks) {
- int rarity = getRarity(stack);
- if(rarity >= 0) {
- talismanCountRarity.put(rarity, talismanCountRarity.getOrDefault(rarity, 0)+1);
- }
- }
- }
-
- Utils.drawStringCenteredScaledMaxWidth("# By Rarity", Minecraft.getMinecraft().fontRendererObj, x+40, y+12, false, 70,
- new Color(80, 80, 80).getRGB());
-
- int yIndex = 0;
- for(Map.Entry<Integer, Integer> entry : talismanCountRarity.descendingMap().entrySet()) {
- String rarityName = Utils.rarityArrC[entry.getKey()];
- Utils.renderAlignedString(rarityName, EnumChatFormatting.WHITE.toString()+entry.getValue(), x+5, y+20+11*yIndex, 70);
- yIndex++;
- }
- }
-
-
- private static PlayerStats.Stats totalStats = null;
- public static void renderTotalStatsOverlay(int x, int y) {
- if(totalStats == null) {
- totalStats = new PlayerStats.Stats();
- for(ItemStack stack : accessoryStacks) {
- if(stack != null) totalStats.add(getStatForItem(stack, STAT_PATTERN_MAP, true));
- }
- }
-
- Utils.drawStringCenteredScaledMaxWidth("Total Stats", Minecraft.getMinecraft().fontRendererObj, x+40, y+12, false, 70,
- new Color(80, 80, 80).getRGB());
- int yIndex = 0;
- for(int i=0; i<PlayerStats.defaultStatNames.length; i++) {
- String statName = PlayerStats.defaultStatNames[i];
- String statNamePretty = PlayerStats.defaultStatNamesPretty[i];
-
- int val = Math.round(totalStats.get(statName));
-
- if(Math.abs(val) < 1E-5) continue;
-
- GlStateManager.color(1, 1, 1, 1);
- GlStateManager.enableBlend();
- GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
- Utils.renderAlignedString(statNamePretty, EnumChatFormatting.WHITE.toString()+val, x+5, y+20+11*yIndex, 70);
-
- yIndex++;
- }
- }
-
- private static PlayerStats.Stats reforgeStats = null;
- public static void renderReforgeStatsOverlay(int x, int y) {
- if(reforgeStats == null) {
- reforgeStats = new PlayerStats.Stats();
- for(ItemStack stack : accessoryStacks) {
- if(stack != null) reforgeStats.add(getStatForItem(stack, STAT_PATTERN_MAP_BONUS, false));
- }
- }
-
- Utils.drawStringCenteredScaledMaxWidth("Reforge Stats", Minecraft.getMinecraft().fontRendererObj, x+40, y+12, false, 70,
- new Color(80, 80, 80).getRGB());
- int yIndex = 0;
- for(int i=0; i<PlayerStats.defaultStatNames.length; i++) {
- String statName = PlayerStats.defaultStatNames[i];
- String statNamePretty = PlayerStats.defaultStatNamesPretty[i];
-
- int val = Math.round(reforgeStats.get(statName));
-
- if(Math.abs(val) < 1E-5) continue;
-
- GlStateManager.color(1, 1, 1, 1);
- GlStateManager.enableBlend();
- GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
- Utils.renderAlignedString(statNamePretty, EnumChatFormatting.WHITE.toString()+val, x+5, y+20+11*yIndex, 70);
-
- yIndex++;
- }
- }
-
- private static Set<ItemStack> duplicates = null;
- public static void renderDuplicatesOverlay(int x, int y) {
- if(duplicates == null) {
- JsonObject misc = Constants.MISC;
- if(misc == null) {
- Utils.drawStringCenteredScaledMaxWidth("Duplicates: ERROR", Minecraft.getMinecraft().fontRendererObj, x+40, y+12, false, 70,
- new Color(80, 80, 80).getRGB());
- return;
- }
- JsonElement talisman_upgrades_element = misc.get("talisman_upgrades");
- if(talisman_upgrades_element == null) {
- Utils.drawStringCenteredScaledMaxWidth("Duplicates: ERROR", Minecraft.getMinecraft().fontRendererObj, x+40, y+12, false, 70,
- new Color(80, 80, 80).getRGB());
- return;
- }
- JsonObject talisman_upgrades = talisman_upgrades_element.getAsJsonObject();
-
- duplicates = new HashSet<>();
-
- Set<String> prevInternalnames = new HashSet<>();
- for(ItemStack stack : accessoryStacks) {
- String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack);
-
- if(prevInternalnames.contains(internalname)) {
- duplicates.add(stack);
- continue;
- }
- prevInternalnames.add(internalname);
-
- if(talisman_upgrades.has(internalname)) {
- JsonArray upgrades = talisman_upgrades.get(internalname).getAsJsonArray();
- for(ItemStack stack2 : accessoryStacks) {
- if(stack != stack2) {
- String internalname2 = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack2);
- for(int j=0; j<upgrades.size(); j++) {
- String upgrade = upgrades.get(j).getAsString();
- if(internalname2.equals(upgrade)) {
- duplicates.add(stack);
- break;
- }
- }
- }
- }
- }
- }
- }
- if(duplicates.isEmpty()) {
- Utils.drawStringCenteredScaledMaxWidth("No Duplicates", Minecraft.getMinecraft().fontRendererObj, x+40, y+12, false, 70,
- new Color(80, 80, 80).getRGB());
- } else {
- Utils.drawStringCenteredScaledMaxWidth("Duplicates: " + duplicates.size(), Minecraft.getMinecraft().fontRendererObj, x+40, y+12, false, 70,
- new Color(80, 80, 80).getRGB());
-
- int yIndex = 0;
- for(ItemStack duplicate : duplicates) {
- String s = duplicate.getDisplayName();
- Utils.renderShadowedString(s, x+40, y+20+11*yIndex, 70);
- if(duplicates.size() > 11) {
- if(++yIndex >= 10) break;
- } else {
- if(++yIndex >= 11) break;
- }
- }
-
- if(duplicates.size() > 11) {
- Utils.drawStringCenteredScaledMaxWidth("+" + (duplicates.size()-10) + " More",
- Minecraft.getMinecraft().fontRendererObj, x+40, y+16+121, false, 70,
- new Color(80, 80, 80).getRGB());
- }
- }
- }
-
- private static List<ItemStack> missing = null;
- public static void renderMissingOverlay(int x, int y) {
- if(missing == null) {
- JsonObject misc = Constants.MISC;
- if(misc == null) {
- Utils.drawStringCenteredScaledMaxWidth("Duplicates: ERROR", Minecraft.getMinecraft().fontRendererObj, x+40, y+12, false, 70,
- new Color(80, 80, 80).getRGB());
- return;
- }
- JsonElement talisman_upgrades_element = misc.get("talisman_upgrades");
- if(talisman_upgrades_element == null) {
- Utils.drawStringCenteredScaledMaxWidth("Duplicates: ERROR", Minecraft.getMinecraft().fontRendererObj, x+40, y+12, false, 70,
- new Color(80, 80, 80).getRGB());
- return;
- }
- JsonObject talisman_upgrades = talisman_upgrades_element.getAsJsonObject();
-
- missing = new ArrayList<>();
-
- List<String> missingInternal = new ArrayList<>();
- for(Map.Entry<String, JsonObject> entry : NotEnoughUpdates.INSTANCE.manager.getItemInformation().entrySet()) {
- if(entry.getValue().has("lore")) {
- if(checkItemType(entry.getValue().get("lore").getAsJsonArray(), "ACCESSORY", "HATCCESSORY", "DUNGEON ACCESSORY") >= 0) {
- missingInternal.add(entry.getKey());
- }
- }
- }
-
- for(ItemStack stack : accessoryStacks) {
- String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack);
- missingInternal.remove(internalname);
-
- for(Map.Entry<String, JsonElement> talisman_upgrade_element : talisman_upgrades.entrySet()) {
- JsonArray upgrades = talisman_upgrade_element.getValue().getAsJsonArray();
- for(int j=0; j<upgrades.size(); j++) {
- String upgrade = upgrades.get(j).getAsString();
- if(internalname.equals(upgrade)) {
- missingInternal.remove(talisman_upgrade_element.getKey());
- break;
- }
- }
- }
- }
-
- missingInternal.sort(getItemComparator());
-
- Set<String> missingDisplayNames = new HashSet<>();
- for(String internal : missingInternal) {
- boolean hasDup = false;
-
- if(talisman_upgrades.has(internal)) {
- JsonArray upgrades = talisman_upgrades.get(internal).getAsJsonArray();
- for(int j=0; j<upgrades.size(); j++) {
- String upgrade = upgrades.get(j).getAsString();
- if(missingInternal.contains(upgrade)) {
- hasDup = true;
- break;
- }
- }
- }
-
- ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(internal), false);
-
- if(missingDisplayNames.contains(stack.getDisplayName())) continue;
- missingDisplayNames.add(stack.getDisplayName());
-
- if(hasDup) {
- stack.setStackDisplayName(stack.getDisplayName()+"*");
- }
- missing.add(stack);
- }
- }
- if(missing.isEmpty()) {
- Utils.drawStringCenteredScaledMaxWidth("No Missing", Minecraft.getMinecraft().fontRendererObj, x+40, y+12, false, 70,
- new Color(80, 80, 80).getRGB());
- } else {
- Utils.drawStringCenteredScaledMaxWidth("Missing: " + missing.size(), Minecraft.getMinecraft().fontRendererObj, x+40, y+12, false, 70,
- new Color(80, 80, 80).getRGB());
-
- 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);
- for(int xO = -1; xO <= 1; xO++) {
- for(int yO = -1; yO <= 1; yO++) {
- int col = 0xff202020;
- //if(xO != 0 && yO != 0) col = 0xff252525;
- Minecraft.getMinecraft().fontRendererObj.drawString(clean, x+5+xO, y+20+11*yIndex+yO, col, false);
- }
- }
- Minecraft.getMinecraft().fontRendererObj.drawString(s, x+5, y+20+11*yIndex, 0xffffff, false);
- if(missing.size() > 11) {
- if(++yIndex >= 10) break;
- } else {
- if(++yIndex >= 11) break;
- }
- }
-
- if(missing.size() > 11) {
- Utils.drawStringCenteredScaledMaxWidth("Show All",
- Minecraft.getMinecraft().fontRendererObj, x+40, y+16+121, false, 70,
- new Color(80, 80, 80).getRGB());
-
- 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;
-
- if(mouseX > x && mouseX < x+80 &&
- mouseY > y+11+121 && mouseY < y+21+121) {
- List<String> text = new ArrayList<>();
- StringBuilder line = new StringBuilder();
- int leftMaxSize = 0;
- int middleMaxSize = 0;
- for(int i=0; i<missing.size(); i += 3) {
- leftMaxSize = Math.max(leftMaxSize, Minecraft.getMinecraft().fontRendererObj.
- getStringWidth(missing.get(i).getDisplayName()));
- }
- for(int i=1; i<missing.size(); i += 3) {
- middleMaxSize = Math.max(middleMaxSize, Minecraft.getMinecraft().fontRendererObj.
- getStringWidth(missing.get(i).getDisplayName()));
- }
- for(int i=0; i<missing.size(); i++) {
- if(i % 3 == 0 && i > 0) {
- text.add(line.toString());
- line = new StringBuilder();
- }
- StringBuilder name = new StringBuilder(missing.get(i).getDisplayName());
- int nameLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(name.toString());
-
- int padSize = -1;
- if(i % 3 == 0) padSize = leftMaxSize;
- if(i % 3 == 1) padSize = middleMaxSize;
- if(padSize > 0) {
- float padNum = (padSize - nameLen) / 4.0f;
- int remainder = (int)((padNum % 1) * 4);
- while(padNum >= 1) {
- if(remainder > 0) {
- name.append(EnumChatFormatting.BOLD).append(" ");
- remainder--;
- } else {
- name.append(EnumChatFormatting.RESET).append(" ");
- }
- padNum--;
- }
- }
- line.append('\u00A7').append(Utils.getPrimaryColourCode(missing.get(i).getDisplayName()));
- if(i < 9) {
- line.append((char)('\u2776'+i)).append(' ');
- } else {
- line.append("\u2b24 ");
- }
- line.append(name);
- if(i % 3 < 2) line.append(" ");
- }
-
- GlStateManager.pushMatrix();
- GlStateManager.scale(2f/scaledresolution.getScaleFactor(), 2f/scaledresolution.getScaleFactor(), 1);
- Utils.drawHoveringText(text,
- mouseX*scaledresolution.getScaleFactor()/2,
- mouseY*scaledresolution.getScaleFactor()/2,
- scaledWidth*scaledresolution.getScaleFactor()/2,
- scaledHeight*scaledresolution.getScaleFactor()/2, -1, Minecraft.getMinecraft().fontRendererObj);
- GlStateManager.popMatrix();
- }
- }
- }
- }
-
- private static boolean forceCC = false;
- private static boolean forceAS = false;
- private static boolean useGodPot = true;
- private static boolean allowShaded = true;
- private static int mainWeapon = 1;
-
- public static void renderOptimizerOverlay(int x, int y) {
- Utils.drawStringCenteredScaledMaxWidth("Optimizer", Minecraft.getMinecraft().fontRendererObj, x+40, y+12, false, 70,
- new Color(80, 80, 80).getRGB());
-
- int light = new Color(220, 220, 220).getRGB();
- int dark = new Color(170, 170, 170).getRGB();
-
- Gui.drawRect(x+5, y+32, x+35, y+43, forceCC?dark:light);
- Gui.drawRect(x+45, y+32, x+75, y+43, forceCC?light:dark);
-
- Gui.drawRect(x+5, y+52, x+35, y+63, forceAS?dark:light);
- Gui.drawRect(x+45, y+52, x+75, y+63, forceAS?light:dark);
-
- Gui.drawRect(x+5, y+72, x+35, y+83, useGodPot?dark:light);
- Gui.drawRect(x+45, y+72, x+75, y+83, useGodPot?light:dark);
-
- Gui.drawRect(x+5, y+92, x+35, y+103, allowShaded?dark:light);
- Gui.drawRect(x+45, y+92, x+75, y+103, allowShaded?light:dark);
-
- Gui.drawRect(x+5, y+102, x+75, y+113, light);
- Gui.drawRect(x+5+(int)((mainWeapon-1)/9f*70), y+102, x+5+(int)(mainWeapon/9f*70), y+113, dark);
-
- Utils.drawStringCenteredScaledMaxWidth("Force 100% CC", Minecraft.getMinecraft().fontRendererObj, x+40, y+27, false, 70,
- new Color(80, 80, 80).getRGB());
- Utils.drawStringCenteredScaledMaxWidth((forceCC?EnumChatFormatting.GREEN:EnumChatFormatting.GRAY)+"YES",
- Minecraft.getMinecraft().fontRendererObj, x+20, y+37,
- true, 30, new Color(80, 80, 80).getRGB());
- Utils.drawStringCenteredScaledMaxWidth((forceCC?EnumChatFormatting.GRAY:EnumChatFormatting.RED)+"NO", Minecraft.getMinecraft().fontRendererObj, x+60, y+37,
- true, 30, new Color(80, 80, 80).getRGB());
-
- Utils.drawStringCenteredScaledMaxWidth("Force 100% ATKSPEED", Minecraft.getMinecraft().fontRendererObj, x+40, y+47, false, 70,
- new Color(80, 80, 80).getRGB());
- Utils.drawStringCenteredScaledMaxWidth((forceAS?EnumChatFormatting.GREEN:EnumChatFormatting.GRAY)+"YES", Minecraft.getMinecraft().fontRendererObj, x+20, y+57,
- true, 30, new Color(80, 80, 80).getRGB());
- Utils.drawStringCenteredScaledMaxWidth((forceAS?EnumChatFormatting.GRAY:EnumChatFormatting.RED)+"NO", Minecraft.getMinecraft().fontRendererObj, x+60, y+57,
- true, 30, new Color(80, 80, 80).getRGB());
-
- Utils.drawStringCenteredScaledMaxWidth("Use God Potion", Minecraft.getMinecraft().fontRendererObj, x+40, y+67, false, 70,
- new Color(80, 80, 80).getRGB());
- Utils.drawStringCenteredScaledMaxWidth((useGodPot?EnumChatFormatting.GREEN:EnumChatFormatting.GRAY)+"YES", Minecraft.getMinecraft().fontRendererObj, x+20, y+77,
- true, 30, new Color(80, 80, 80).getRGB());
- Utils.drawStringCenteredScaledMaxWidth((useGodPot?EnumChatFormatting.GRAY:EnumChatFormatting.RED)+"NO", Minecraft.getMinecraft().fontRendererObj, x+60, y+77,
- true, 30, new Color(80, 80, 80).getRGB());
-
- Utils.drawStringCenteredScaledMaxWidth("Use God Potion", Minecraft.getMinecraft().fontRendererObj, x+40, y+87, false, 70,
- new Color(80, 80, 80).getRGB());
- Utils.drawStringCenteredScaledMaxWidth((allowShaded?EnumChatFormatting.GREEN:EnumChatFormatting.GRAY)+"YES",
- Minecraft.getMinecraft().fontRendererObj, x+20, y+97,
- true, 30, new Color(80, 80, 80).getRGB());
- Utils.drawStringCenteredScaledMaxWidth((allowShaded?EnumChatFormatting.GRAY:EnumChatFormatting.RED)+"NO",
- Minecraft.getMinecraft().fontRendererObj, x+60, y+97,
- true, 30, new Color(80, 80, 80).getRGB());
-
- Utils.drawStringCenteredScaledMaxWidth("Main Weapon", Minecraft.getMinecraft().fontRendererObj, x+40, y+107, false, 70,
- new Color(80, 80, 80).getRGB());
- Utils.drawStringCenteredScaled("1 2 3 4 5 6 7 8 9",
- Minecraft.getMinecraft().fontRendererObj, x+40, y+117,
- true, 70, new Color(80, 80, 80).getRGB());
- }
-
- private static Comparator<String> getItemComparator() {
- return (o1, o2) -> {
- float cost1;
- JsonObject o1Auc = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfo(o1);
- if(o1Auc != null && o1Auc.has("price")) {
- cost1 = o1Auc.get("price").getAsFloat();
- } else {
- cost1 = NotEnoughUpdates.INSTANCE.manager.auctionManager.getCraftCost(o1).craftCost;
- }
- float cost2;
- JsonObject o2Auc = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfo(o2);
- if(o2Auc != null && o2Auc.has("price")) {
- cost2 = o2Auc.get("price").getAsFloat();
- } else {
- cost2 = NotEnoughUpdates.INSTANCE.manager.auctionManager.getCraftCost(o2).craftCost;
- }
-
- if(cost1 == -1 && cost2 == -1) return o1.compareTo(o2);
- if(cost1 == -1) return 1;
- if(cost2 == -1) return -1;
-
- if(cost1 < cost2) return -1;
- if(cost1 > cost2) return 1;
-
- return o1.compareTo(o2);
- };
- }
- private static boolean inAccessoryBag = false;
- public static boolean isInAccessoryBag(){
- return inAccessoryBag;
- }
-
- public static void renderOverlay() {
- inAccessoryBag = false;
- if(Minecraft.getMinecraft().currentScreen instanceof GuiChest && NEUEventListener.inventoryLoaded) {
- GuiChest eventGui = (GuiChest) Minecraft.getMinecraft().currentScreen;
- ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
- String containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText();
- if(containerName.trim().startsWith("Accessory Bag")) {
- inAccessoryBag = true;
- try {
- int xSize = (int) Utils.getField(GuiContainer.class, eventGui, "xSize", "field_146999_f");
- int ySize = (int) Utils.getField(GuiContainer.class, eventGui, "ySize", "field_147000_g");
- int guiLeft = (int) Utils.getField(GuiContainer.class, eventGui, "guiLeft", "field_147003_i");
- int guiTop = (int) Utils.getField(GuiContainer.class, eventGui, "guiTop", "field_147009_r");
-
- if(accessoryStacks.isEmpty()) {
- for(ItemStack stack : Minecraft.getMinecraft().thePlayer.inventory.mainInventory) {
- if(stack != null && isAccessory(stack)) {
- accessoryStacks.add(stack);
- }
- }
- }
-
- if(containerName.trim().contains("(")) {
- String first = containerName.trim().split("\\(")[1].split("/")[0];
- Integer currentPageNumber = Integer.parseInt(first);
- //System.out.println("current:"+currentPageNumber);
- if(!pagesVisited.contains(currentPageNumber)) {
- boolean hasStack = false;
- if(Minecraft.getMinecraft().thePlayer.openContainer instanceof ContainerChest) {
- IInventory inv = ((ContainerChest)Minecraft.getMinecraft().thePlayer.openContainer).getLowerChestInventory();
- for(int i=0; i<inv.getSizeInventory(); i++) {
- ItemStack stack = inv.getStackInSlot(i);
- if(stack != null) {
- hasStack = true;
- if(isAccessory(stack)) {
- accessoryStacks.add(stack);
- }
- }
- }
- }
-
- if(hasStack) pagesVisited.add(currentPageNumber);
- }
-
- String second = containerName.trim().split("/")[1].split("\\)")[0];
- //System.out.println(second + ":" + pagesVisited.size());
- if(Integer.parseInt(second) > pagesVisited.size()) {
- GlStateManager.color(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(accessory_bag_overlay);
- Utils.drawTexturedRect(guiLeft+xSize+3, guiTop, 80, 149, 0, 80/256f, 0, 149/256f, GL11.GL_NEAREST);
-
- renderVisitOverlay(guiLeft+xSize+3, guiTop);
- return;
- }
- } else if(pagesVisited.isEmpty()) {
- boolean hasStack = false;
- if(Minecraft.getMinecraft().thePlayer.openContainer instanceof ContainerChest) {
- IInventory inv = ((ContainerChest)Minecraft.getMinecraft().thePlayer.openContainer).getLowerChestInventory();
- for(int i=0; i<inv.getSizeInventory(); i++) {
- ItemStack stack = inv.getStackInSlot(i);
- if(stack != null) {
- hasStack = true;
- if(isAccessory(stack)) {
- accessoryStacks.add(stack);
- }
- }
- }
- }
-
- if(hasStack) pagesVisited.add(1);
- }
-
- GlStateManager.disableLighting();
-
- for(int i=0; i<=TAB_MISSING; i++) {
- if(i != currentTab) {
- GlStateManager.color(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(accessory_bag_overlay);
- Utils.drawTexturedRect(guiLeft+xSize+80, guiTop+20*i, 25, 22,
- 80/256f, 105/256f, 0, 22/256f, GL11.GL_NEAREST);
- Utils.drawItemStack(TAB_STACKS[i], guiLeft+xSize+80+5, guiTop+20*i+3);
- }
- }
-
- GlStateManager.color(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(accessory_bag_overlay);
- Utils.drawTexturedRect(guiLeft+xSize+3, guiTop, 80, 149, 0, 80/256f, 0, 149/256f, GL11.GL_NEAREST);
-
- if(pagesVisited.size() < 1) {
- renderVisitOverlay(guiLeft+xSize+3, guiTop);
- return;
- }
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(accessory_bag_overlay);
- Utils.drawTexturedRect(guiLeft+xSize+80, guiTop+20*currentTab, 28, 22,
- 80/256f, 108/256f, 22/256f, 44/256f, GL11.GL_NEAREST);
- Utils.drawItemStack(TAB_STACKS[currentTab], guiLeft+xSize+80+8, guiTop+20*currentTab+3);
-
- switch (currentTab) {
- case TAB_BASIC:
- renderBasicOverlay(guiLeft+xSize+3, guiTop); return;
- case TAB_TOTAL:
- renderTotalStatsOverlay(guiLeft+xSize+3, guiTop); return;
- case TAB_BONUS:
- renderReforgeStatsOverlay(guiLeft+xSize+3, guiTop); return;
- case TAB_DUP:
- renderDuplicatesOverlay(guiLeft+xSize+3, guiTop); return;
- case TAB_MISSING:
- renderMissingOverlay(guiLeft+xSize+3, guiTop); return;
- case TAB_OPTIMIZER:
- renderOptimizerOverlay(guiLeft+xSize+3, guiTop); return;
- }
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
- }
- }
+ private static final int TAB_BASIC = 0;
+ private static final int TAB_TOTAL = 1;
+ private static final int TAB_BONUS = 2;
+ private static final int TAB_DUP = 3;
+ private static final int TAB_MISSING = 4;
+ private static final int TAB_OPTIMIZER = 5;
+
+ private static final ItemStack[] TAB_STACKS = new ItemStack[]{
+ Utils.createItemStack(Items.dye, EnumChatFormatting.DARK_AQUA + "Basic Information",
+ 10, EnumChatFormatting.GREEN + "- Talis count by rarity"
+ ),
+ Utils.createItemStack(Items.diamond_sword, EnumChatFormatting.DARK_AQUA + "Total Stat Bonuses",
+ 0
+ ),
+ Utils.createItemStack(
+ Item.getItemFromBlock(Blocks.anvil),
+ EnumChatFormatting.DARK_AQUA + "Total Stat Bonuses (from reforges)",
+ 0
+ ),
+ Utils.createItemStack(Items.dye, EnumChatFormatting.DARK_AQUA + "Duplicates",
+ 8
+ ),
+ Utils.createItemStack(Item.getItemFromBlock(Blocks.barrier), EnumChatFormatting.DARK_AQUA + "Missing",
+ 0
+ ),
+ Utils.createItemStack(Item.getItemFromBlock(Blocks.redstone_block), EnumChatFormatting.DARK_AQUA + "Optimizer",
+ 0
+ ),
+ };
+
+ private static int currentTab = TAB_BASIC;
+
+ public static boolean mouseClick() {
+ if (Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
+ GuiChest eventGui = (GuiChest) Minecraft.getMinecraft().currentScreen;
+ ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
+ String containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText();
+ if (!containerName.trim().startsWith("Accessory Bag")) {
+ return false;
+ }
+ } else {
+ return false;
+ }
+
+ if (!Mouse.getEventButtonState()) return false;
+ try {
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+
+ int width = scaledResolution.getScaledWidth();
+ int height = scaledResolution.getScaledHeight();
+
+ int mouseX = Mouse.getX() / scaledResolution.getScaleFactor();
+ int mouseY = height - Mouse.getY() / scaledResolution.getScaleFactor();
+
+ int xSize =
+ (int) Utils.getField(GuiContainer.class, Minecraft.getMinecraft().currentScreen, "xSize", "field_146999_f");
+ int ySize =
+ (int) Utils.getField(GuiContainer.class, Minecraft.getMinecraft().currentScreen, "ySize", "field_147000_g");
+ int guiLeft =
+ (int) Utils.getField(GuiContainer.class, Minecraft.getMinecraft().currentScreen, "guiLeft", "field_147003_i");
+ int guiTop =
+ (int) Utils.getField(GuiContainer.class, Minecraft.getMinecraft().currentScreen, "guiTop", "field_147009_r");
+
+ if (mouseX < guiLeft + xSize + 3 || mouseX > guiLeft + xSize + 80 + 28) return false;
+ if (mouseY < guiTop || mouseY > guiTop + 166) return false;
+
+ if (mouseX > guiLeft + xSize + 83 && mouseY < guiTop + 20 * TAB_MISSING + 22) {
+ currentTab = (mouseY - guiTop) / 20;
+ if (currentTab < 0) currentTab = 0;
+ if (currentTab > TAB_MISSING) currentTab = TAB_MISSING;
+ }
+
+ if (currentTab == TAB_OPTIMIZER) {
+ int x = guiLeft + xSize + 3;
+ int y = guiTop;
+
+ if (mouseY > y + 92 && mouseY < y + 103) {
+ if (mouseX > x + 5 && mouseX < x + 75) {
+ mainWeapon = (int) Math.floor((mouseX - x - 5) / 70f * 9);
+ if (mainWeapon < 1) {
+ mainWeapon = 1;
+ } else if (mainWeapon > 9) {
+ mainWeapon = 9;
+ }
+ }
+ }
+
+ if (mouseX > x + 5 && mouseX < x + 35 || mouseX > x + 45 && mouseX < x + 75) {
+ boolean set = mouseX > x + 5 && mouseX < x + 35;
+
+ if (mouseY > y + 32 && mouseY < y + 43) {
+ forceCC = set;
+ } else if (mouseY > y + 52 && mouseY < y + 63) {
+ forceAS = set;
+ } else if (mouseY > y + 72 && mouseY < y + 83) {
+ useGodPot = set;
+ } else if (mouseY > y + 92 && mouseY < y + 103) {
+ allowShaded = set;
+ }
+ }
+ }
+
+ return true;
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
+ public static void resetCache() {
+ accessoryStacks = new HashSet<>();
+ pagesVisited = new HashSet<>();
+ talismanCountRarity = null;
+ totalStats = null;
+ reforgeStats = null;
+ duplicates = null;
+ missing = null;
+ }
+
+ private static Set<ItemStack> accessoryStacks = new HashSet<>();
+ private static Set<Integer> pagesVisited = new HashSet<>();
+
+ public static void renderVisitOverlay(int x, int y) {
+ Utils.drawStringCenteredScaledMaxWidth(
+ "Please visit all",
+ Minecraft.getMinecraft().fontRendererObj,
+ x + 40,
+ y + 78,
+ true,
+ 70,
+ -1
+ );
+ Utils.drawStringCenteredScaledMaxWidth(
+ "pages of the bag",
+ Minecraft.getMinecraft().fontRendererObj,
+ x + 40,
+ y + 86,
+ true,
+ 70,
+ -1
+ );
+ }
+
+ private static TreeMap<Integer, Integer> talismanCountRarity = null;
+
+ public static void renderBasicOverlay(int x, int y) {
+ if (talismanCountRarity == null) {
+ talismanCountRarity = new TreeMap<>();
+ for (ItemStack stack : accessoryStacks) {
+ int rarity = getRarity(stack);
+ if (rarity >= 0) {
+ talismanCountRarity.put(rarity, talismanCountRarity.getOrDefault(rarity, 0) + 1);
+ }
+ }
+ }
+
+ Utils.drawStringCenteredScaledMaxWidth(
+ "# By Rarity",
+ Minecraft.getMinecraft().fontRendererObj,
+ x + 40,
+ y + 12,
+ false,
+ 70,
+ new Color(80, 80, 80).getRGB()
+ );
+
+ int yIndex = 0;
+ for (Map.Entry<Integer, Integer> entry : talismanCountRarity.descendingMap().entrySet()) {
+ String rarityName = Utils.rarityArrC[entry.getKey()];
+ Utils.renderAlignedString(
+ rarityName,
+ EnumChatFormatting.WHITE.toString() + entry.getValue(),
+ x + 5,
+ y + 20 + 11 * yIndex,
+ 70
+ );
+ yIndex++;
+ }
+ }
+
+ private static PlayerStats.Stats totalStats = null;
+
+ public static void renderTotalStatsOverlay(int x, int y) {
+ if (totalStats == null) {
+ totalStats = new PlayerStats.Stats();
+ for (ItemStack stack : accessoryStacks) {
+ if (stack != null) totalStats.add(getStatForItem(stack, STAT_PATTERN_MAP, true));
+ }
+ }
+
+ Utils.drawStringCenteredScaledMaxWidth(
+ "Total Stats",
+ Minecraft.getMinecraft().fontRendererObj,
+ x + 40,
+ y + 12,
+ false,
+ 70,
+ new Color(80, 80, 80).getRGB()
+ );
+ int yIndex = 0;
+ for (int i = 0; i < PlayerStats.defaultStatNames.length; i++) {
+ String statName = PlayerStats.defaultStatNames[i];
+ String statNamePretty = PlayerStats.defaultStatNamesPretty[i];
+
+ int val = Math.round(totalStats.get(statName));
+
+ if (Math.abs(val) < 1E-5) continue;
+
+ GlStateManager.color(1, 1, 1, 1);
+ GlStateManager.enableBlend();
+ GL14.glBlendFuncSeparate(
+ GL11.GL_SRC_ALPHA,
+ GL11.GL_ONE_MINUS_SRC_ALPHA,
+ GL11.GL_ONE,
+ GL11.GL_ONE_MINUS_SRC_ALPHA
+ );
+ Utils.renderAlignedString(
+ statNamePretty,
+ EnumChatFormatting.WHITE.toString() + val,
+ x + 5,
+ y + 20 + 11 * yIndex,
+ 70
+ );
+
+ yIndex++;
+ }
+ }
+
+ private static PlayerStats.Stats reforgeStats = null;
+
+ public static void renderReforgeStatsOverlay(int x, int y) {
+ if (reforgeStats == null) {
+ reforgeStats = new PlayerStats.Stats();
+ for (ItemStack stack : accessoryStacks) {
+ if (stack != null) reforgeStats.add(getStatForItem(stack, STAT_PATTERN_MAP_BONUS, false));
+ }
+ }
+
+ Utils.drawStringCenteredScaledMaxWidth(
+ "Reforge Stats",
+ Minecraft.getMinecraft().fontRendererObj,
+ x + 40,
+ y + 12,
+ false,
+ 70,
+ new Color(80, 80, 80).getRGB()
+ );
+ int yIndex = 0;
+ for (int i = 0; i < PlayerStats.defaultStatNames.length; i++) {
+ String statName = PlayerStats.defaultStatNames[i];
+ String statNamePretty = PlayerStats.defaultStatNamesPretty[i];
+
+ int val = Math.round(reforgeStats.get(statName));
+
+ if (Math.abs(val) < 1E-5) continue;
+
+ GlStateManager.color(1, 1, 1, 1);
+ GlStateManager.enableBlend();
+ GL14.glBlendFuncSeparate(
+ GL11.GL_SRC_ALPHA,
+ GL11.GL_ONE_MINUS_SRC_ALPHA,
+ GL11.GL_ONE,
+ GL11.GL_ONE_MINUS_SRC_ALPHA
+ );
+ Utils.renderAlignedString(
+ statNamePretty,
+ EnumChatFormatting.WHITE.toString() + val,
+ x + 5,
+ y + 20 + 11 * yIndex,
+ 70
+ );
+
+ yIndex++;
+ }
+ }
+
+ private static Set<ItemStack> duplicates = null;
+
+ public static void renderDuplicatesOverlay(int x, int y) {
+ if (duplicates == null) {
+ JsonObject misc = Constants.MISC;
+ if (misc == null) {
+ Utils.drawStringCenteredScaledMaxWidth(
+ "Duplicates: ERROR",
+ Minecraft.getMinecraft().fontRendererObj,
+ x + 40,
+ y + 12,
+ false,
+ 70,
+ new Color(80, 80, 80).getRGB()
+ );
+ return;
+ }
+ JsonElement talisman_upgrades_element = misc.get("talisman_upgrades");
+ if (talisman_upgrades_element == null) {
+ Utils.drawStringCenteredScaledMaxWidth(
+ "Duplicates: ERROR",
+ Minecraft.getMinecraft().fontRendererObj,
+ x + 40,
+ y + 12,
+ false,
+ 70,
+ new Color(80, 80, 80).getRGB()
+ );
+ return;
+ }
+ JsonObject talisman_upgrades = talisman_upgrades_element.getAsJsonObject();
+
+ duplicates = new HashSet<>();
+
+ Set<String> prevInternalnames = new HashSet<>();
+ for (ItemStack stack : accessoryStacks) {
+ String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack);
+
+ if (prevInternalnames.contains(internalname)) {
+ duplicates.add(stack);
+ continue;
+ }
+ prevInternalnames.add(internalname);
+
+ if (talisman_upgrades.has(internalname)) {
+ JsonArray upgrades = talisman_upgrades.get(internalname).getAsJsonArray();
+ for (ItemStack stack2 : accessoryStacks) {
+ if (stack != stack2) {
+ String internalname2 = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack2);
+ for (int j = 0; j < upgrades.size(); j++) {
+ String upgrade = upgrades.get(j).getAsString();
+ if (internalname2.equals(upgrade)) {
+ duplicates.add(stack);
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ if (duplicates.isEmpty()) {
+ Utils.drawStringCenteredScaledMaxWidth(
+ "No Duplicates",
+ Minecraft.getMinecraft().fontRendererObj,
+ x + 40,
+ y + 12,
+ false,
+ 70,
+ new Color(80, 80, 80).getRGB()
+ );
+ } else {
+ Utils.drawStringCenteredScaledMaxWidth(
+ "Duplicates: " + duplicates.size(),
+ Minecraft.getMinecraft().fontRendererObj,
+ x + 40,
+ y + 12,
+ false,
+ 70,
+ new Color(80, 80, 80).getRGB()
+ );
+
+ int yIndex = 0;
+ for (ItemStack duplicate : duplicates) {
+ String s = duplicate.getDisplayName();
+ Utils.renderShadowedString(s, x + 40, y + 20 + 11 * yIndex, 70);
+ if (duplicates.size() > 11) {
+ if (++yIndex >= 10) break;
+ } else {
+ if (++yIndex >= 11) break;
+ }
+ }
+
+ if (duplicates.size() > 11) {
+ Utils.drawStringCenteredScaledMaxWidth("+" + (duplicates.size() - 10) + " More",
+ Minecraft.getMinecraft().fontRendererObj, x + 40, y + 16 + 121, false, 70,
+ new Color(80, 80, 80).getRGB()
+ );
+ }
+ }
+ }
+
+ private static List<ItemStack> missing = null;
+
+ public static void renderMissingOverlay(int x, int y) {
+ if (missing == null) {
+ JsonObject misc = Constants.MISC;
+ if (misc == null) {
+ Utils.drawStringCenteredScaledMaxWidth(
+ "Duplicates: ERROR",
+ Minecraft.getMinecraft().fontRendererObj,
+ x + 40,
+ y + 12,
+ false,
+ 70,
+ new Color(80, 80, 80).getRGB()
+ );
+ return;
+ }
+ JsonElement talisman_upgrades_element = misc.get("talisman_upgrades");
+ if (talisman_upgrades_element == null) {
+ Utils.drawStringCenteredScaledMaxWidth(
+ "Duplicates: ERROR",
+ Minecraft.getMinecraft().fontRendererObj,
+ x + 40,
+ y + 12,
+ false,
+ 70,
+ new Color(80, 80, 80).getRGB()
+ );
+ return;
+ }
+ JsonObject talisman_upgrades = talisman_upgrades_element.getAsJsonObject();
+
+ missing = new ArrayList<>();
+
+ List<String> missingInternal = new ArrayList<>();
+ for (Map.Entry<String, JsonObject> entry : NotEnoughUpdates.INSTANCE.manager.getItemInformation().entrySet()) {
+ if (entry.getValue().has("lore")) {
+ if (checkItemType(
+ entry.getValue().get("lore").getAsJsonArray(),
+ "ACCESSORY",
+ "HATCCESSORY",
+ "DUNGEON ACCESSORY"
+ ) >= 0) {
+ missingInternal.add(entry.getKey());
+ }
+ }
+ }
+
+ for (ItemStack stack : accessoryStacks) {
+ String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack);
+ missingInternal.remove(internalname);
+
+ for (Map.Entry<String, JsonElement> talisman_upgrade_element : talisman_upgrades.entrySet()) {
+ JsonArray upgrades = talisman_upgrade_element.getValue().getAsJsonArray();
+ for (int j = 0; j < upgrades.size(); j++) {
+ String upgrade = upgrades.get(j).getAsString();
+ if (internalname.equals(upgrade)) {
+ missingInternal.remove(talisman_upgrade_element.getKey());
+ break;
+ }
+ }
+ }
+ }
+
+ missingInternal.sort(getItemComparator());
+
+ Set<String> missingDisplayNames = new HashSet<>();
+ for (String internal : missingInternal) {
+ boolean hasDup = false;
+
+ if (talisman_upgrades.has(internal)) {
+ JsonArray upgrades = talisman_upgrades.get(internal).getAsJsonArray();
+ for (int j = 0; j < upgrades.size(); j++) {
+ String upgrade = upgrades.get(j).getAsString();
+ if (missingInternal.contains(upgrade)) {
+ hasDup = true;
+ break;
+ }
+ }
+ }
+
+ ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get(internal), false);
+
+ if (missingDisplayNames.contains(stack.getDisplayName())) continue;
+ missingDisplayNames.add(stack.getDisplayName());
+
+ if (hasDup) {
+ stack.setStackDisplayName(stack.getDisplayName() + "*");
+ }
+ missing.add(stack);
+ }
+ }
+ if (missing.isEmpty()) {
+ Utils.drawStringCenteredScaledMaxWidth(
+ "No Missing",
+ Minecraft.getMinecraft().fontRendererObj,
+ x + 40,
+ y + 12,
+ false,
+ 70,
+ new Color(80, 80, 80).getRGB()
+ );
+ } else {
+ Utils.drawStringCenteredScaledMaxWidth(
+ "Missing: " + missing.size(),
+ Minecraft.getMinecraft().fontRendererObj,
+ x + 40,
+ y + 12,
+ false,
+ 70,
+ new Color(80, 80, 80).getRGB()
+ );
+
+ 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);
+ for (int xO = -1; xO <= 1; xO++) {
+ for (int yO = -1; yO <= 1; yO++) {
+ int col = 0xff202020;
+ //if(xO != 0 && yO != 0) col = 0xff252525;
+ Minecraft.getMinecraft().fontRendererObj.drawString(
+ clean,
+ x + 5 + xO,
+ y + 20 + 11 * yIndex + yO,
+ col,
+ false
+ );
+ }
+ }
+ Minecraft.getMinecraft().fontRendererObj.drawString(s, x + 5, y + 20 + 11 * yIndex, 0xffffff, false);
+ if (missing.size() > 11) {
+ if (++yIndex >= 10) break;
+ } else {
+ if (++yIndex >= 11) break;
+ }
+ }
+
+ if (missing.size() > 11) {
+ Utils.drawStringCenteredScaledMaxWidth("Show All",
+ Minecraft.getMinecraft().fontRendererObj, x + 40, y + 16 + 121, false, 70,
+ new Color(80, 80, 80).getRGB()
+ );
+
+ 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;
+
+ if (mouseX > x && mouseX < x + 80 &&
+ mouseY > y + 11 + 121 && mouseY < y + 21 + 121) {
+ List<String> text = new ArrayList<>();
+ StringBuilder line = new StringBuilder();
+ int leftMaxSize = 0;
+ int middleMaxSize = 0;
+ for (int i = 0; i < missing.size(); i += 3) {
+ leftMaxSize = Math.max(leftMaxSize, Minecraft.getMinecraft().fontRendererObj.
+ getStringWidth(missing.get(i).getDisplayName()));
+ }
+ for (int i = 1; i < missing.size(); i += 3) {
+ middleMaxSize = Math.max(middleMaxSize, Minecraft.getMinecraft().fontRendererObj.
+ getStringWidth(missing.get(i).getDisplayName()));
+ }
+ for (int i = 0; i < missing.size(); i++) {
+ if (i % 3 == 0 && i > 0) {
+ text.add(line.toString());
+ line = new StringBuilder();
+ }
+ StringBuilder name = new StringBuilder(missing.get(i).getDisplayName());
+ int nameLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(name.toString());
+
+ int padSize = -1;
+ if (i % 3 == 0) padSize = leftMaxSize;
+ if (i % 3 == 1) padSize = middleMaxSize;
+ if (padSize > 0) {
+ float padNum = (padSize - nameLen) / 4.0f;
+ int remainder = (int) ((padNum % 1) * 4);
+ while (padNum >= 1) {
+ if (remainder > 0) {
+ name.append(EnumChatFormatting.BOLD).append(" ");
+ remainder--;
+ } else {
+ name.append(EnumChatFormatting.RESET).append(" ");
+ }
+ padNum--;
+ }
+ }
+ line.append('\u00A7').append(Utils.getPrimaryColourCode(missing.get(i).getDisplayName()));
+ if (i < 9) {
+ line.append((char) ('\u2776' + i)).append(' ');
+ } else {
+ line.append("\u2b24 ");
+ }
+ line.append(name);
+ if (i % 3 < 2) line.append(" ");
+ }
+
+ GlStateManager.pushMatrix();
+ GlStateManager.scale(2f / scaledresolution.getScaleFactor(), 2f / scaledresolution.getScaleFactor(), 1);
+ Utils.drawHoveringText(text,
+ mouseX * scaledresolution.getScaleFactor() / 2,
+ mouseY * scaledresolution.getScaleFactor() / 2,
+ scaledWidth * scaledresolution.getScaleFactor() / 2,
+ scaledHeight * scaledresolution.getScaleFactor() / 2, -1, Minecraft.getMinecraft().fontRendererObj
+ );
+ GlStateManager.popMatrix();
+ }
+ }
+ }
+ }
+
+ private static boolean forceCC = false;
+ private static boolean forceAS = false;
+ private static boolean useGodPot = true;
+ private static boolean allowShaded = true;
+ private static int mainWeapon = 1;
+
+ public static void renderOptimizerOverlay(int x, int y) {
+ Utils.drawStringCenteredScaledMaxWidth(
+ "Optimizer",
+ Minecraft.getMinecraft().fontRendererObj,
+ x + 40,
+ y + 12,
+ false,
+ 70,
+ new Color(80, 80, 80).getRGB()
+ );
+
+ int light = new Color(220, 220, 220).getRGB();
+ int dark = new Color(170, 170, 170).getRGB();
+
+ Gui.drawRect(x + 5, y + 32, x + 35, y + 43, forceCC ? dark : light);
+ Gui.drawRect(x + 45, y + 32, x + 75, y + 43, forceCC ? light : dark);
+
+ Gui.drawRect(x + 5, y + 52, x + 35, y + 63, forceAS ? dark : light);
+ Gui.drawRect(x + 45, y + 52, x + 75, y + 63, forceAS ? light : dark);
+
+ Gui.drawRect(x + 5, y + 72, x + 35, y + 83, useGodPot ? dark : light);
+ Gui.drawRect(x + 45, y + 72, x + 75, y + 83, useGodPot ? light : dark);
+
+ Gui.drawRect(x + 5, y + 92, x + 35, y + 103, allowShaded ? dark : light);
+ Gui.drawRect(x + 45, y + 92, x + 75, y + 103, allowShaded ? light : dark);
+
+ Gui.drawRect(x + 5, y + 102, x + 75, y + 113, light);
+ Gui.drawRect(
+ x + 5 + (int) ((mainWeapon - 1) / 9f * 70),
+ y + 102,
+ x + 5 + (int) (mainWeapon / 9f * 70),
+ y + 113,
+ dark
+ );
+
+ Utils.drawStringCenteredScaledMaxWidth(
+ "Force 100% CC",
+ Minecraft.getMinecraft().fontRendererObj,
+ x + 40,
+ y + 27,
+ false,
+ 70,
+ new Color(80, 80, 80).getRGB()
+ );
+ Utils.drawStringCenteredScaledMaxWidth((forceCC ? EnumChatFormatting.GREEN : EnumChatFormatting.GRAY) + "YES",
+ Minecraft.getMinecraft().fontRendererObj, x + 20, y + 37,
+ true, 30, new Color(80, 80, 80).getRGB()
+ );
+ Utils.drawStringCenteredScaledMaxWidth(
+ (forceCC ? EnumChatFormatting.GRAY : EnumChatFormatting.RED) + "NO",
+ Minecraft.getMinecraft().fontRendererObj,
+ x + 60,
+ y + 37,
+ true,
+ 30,
+ new Color(80, 80, 80).getRGB()
+ );
+
+ Utils.drawStringCenteredScaledMaxWidth(
+ "Force 100% ATKSPEED",
+ Minecraft.getMinecraft().fontRendererObj,
+ x + 40,
+ y + 47,
+ false,
+ 70,
+ new Color(80, 80, 80).getRGB()
+ );
+ Utils.drawStringCenteredScaledMaxWidth(
+ (forceAS ? EnumChatFormatting.GREEN : EnumChatFormatting.GRAY) + "YES",
+ Minecraft.getMinecraft().fontRendererObj,
+ x + 20,
+ y + 57,
+ true,
+ 30,
+ new Color(80, 80, 80).getRGB()
+ );
+ Utils.drawStringCenteredScaledMaxWidth(
+ (forceAS ? EnumChatFormatting.GRAY : EnumChatFormatting.RED) + "NO",
+ Minecraft.getMinecraft().fontRendererObj,
+ x + 60,
+ y + 57,
+ true,
+ 30,
+ new Color(80, 80, 80).getRGB()
+ );
+
+ Utils.drawStringCenteredScaledMaxWidth(
+ "Use God Potion",
+ Minecraft.getMinecraft().fontRendererObj,
+ x + 40,
+ y + 67,
+ false,
+ 70,
+ new Color(80, 80, 80).getRGB()
+ );
+ Utils.drawStringCenteredScaledMaxWidth(
+ (useGodPot ? EnumChatFormatting.GREEN : EnumChatFormatting.GRAY) + "YES",
+ Minecraft.getMinecraft().fontRendererObj,
+ x + 20,
+ y + 77,
+ true,
+ 30,
+ new Color(80, 80, 80).getRGB()
+ );
+ Utils.drawStringCenteredScaledMaxWidth(
+ (useGodPot ? EnumChatFormatting.GRAY : EnumChatFormatting.RED) + "NO",
+ Minecraft.getMinecraft().fontRendererObj,
+ x + 60,
+ y + 77,
+ true,
+ 30,
+ new Color(80, 80, 80).getRGB()
+ );
+
+ Utils.drawStringCenteredScaledMaxWidth(
+ "Use God Potion",
+ Minecraft.getMinecraft().fontRendererObj,
+ x + 40,
+ y + 87,
+ false,
+ 70,
+ new Color(80, 80, 80).getRGB()
+ );
+ Utils.drawStringCenteredScaledMaxWidth((allowShaded ? EnumChatFormatting.GREEN : EnumChatFormatting.GRAY) + "YES",
+ Minecraft.getMinecraft().fontRendererObj, x + 20, y + 97,
+ true, 30, new Color(80, 80, 80).getRGB()
+ );
+ Utils.drawStringCenteredScaledMaxWidth((allowShaded ? EnumChatFormatting.GRAY : EnumChatFormatting.RED) + "NO",
+ Minecraft.getMinecraft().fontRendererObj, x + 60, y + 97,
+ true, 30, new Color(80, 80, 80).getRGB()
+ );
+
+ Utils.drawStringCenteredScaledMaxWidth(
+ "Main Weapon",
+ Minecraft.getMinecraft().fontRendererObj,
+ x + 40,
+ y + 107,
+ false,
+ 70,
+ new Color(80, 80, 80).getRGB()
+ );
+ Utils.drawStringCenteredScaled("1 2 3 4 5 6 7 8 9",
+ Minecraft.getMinecraft().fontRendererObj, x + 40, y + 117,
+ true, 70, new Color(80, 80, 80).getRGB()
+ );
+ }
+
+ private static Comparator<String> getItemComparator() {
+ return (o1, o2) -> {
+ float cost1;
+ JsonObject o1Auc = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfo(o1);
+ if (o1Auc != null && o1Auc.has("price")) {
+ cost1 = o1Auc.get("price").getAsFloat();
+ } else {
+ APIManager.CraftInfo info = NotEnoughUpdates.INSTANCE.manager.auctionManager.getCraftCost(o1);
+ if (info != null)
+ cost1 = info.craftCost;
+ else
+ cost1 = 0;
+ }
+ float cost2;
+ JsonObject o2Auc = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfo(o2);
+ if (o2Auc != null && o2Auc.has("price")) {
+ cost2 = o2Auc.get("price").getAsFloat();
+ } else {
+ APIManager.CraftInfo info = NotEnoughUpdates.INSTANCE.manager.auctionManager.getCraftCost(o2);
+ if (info != null)
+ cost2 = info.craftCost;
+ else
+ cost2 = 0;
+ }
+
+ if (cost1 == -1 && cost2 == -1) return o1.compareTo(o2);
+ if (cost1 == -1) return 1;
+ if (cost2 == -1) return -1;
+
+ if (cost1 < cost2) return -1;
+ if (cost1 > cost2) return 1;
+
+ return o1.compareTo(o2);
+ };
+ }
+
+ private static boolean inAccessoryBag = false;
+
+ public static boolean isInAccessoryBag() {
+ return inAccessoryBag;
+ }
+
+ public static void renderOverlay() {
+ inAccessoryBag = false;
+ if (Minecraft.getMinecraft().currentScreen instanceof GuiChest && NEUEventListener.inventoryLoaded) {
+ GuiChest eventGui = (GuiChest) Minecraft.getMinecraft().currentScreen;
+ ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
+ String containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText();
+ if (containerName.trim().startsWith("Accessory Bag")) {
+ inAccessoryBag = true;
+ try {
+ int xSize = (int) Utils.getField(GuiContainer.class, eventGui, "xSize", "field_146999_f");
+ int ySize = (int) Utils.getField(GuiContainer.class, eventGui, "ySize", "field_147000_g");
+ int guiLeft = (int) Utils.getField(GuiContainer.class, eventGui, "guiLeft", "field_147003_i");
+ int guiTop = (int) Utils.getField(GuiContainer.class, eventGui, "guiTop", "field_147009_r");
+
+ if (accessoryStacks.isEmpty()) {
+ for (ItemStack stack : Minecraft.getMinecraft().thePlayer.inventory.mainInventory) {
+ if (stack != null && isAccessory(stack)) {
+ accessoryStacks.add(stack);
+ }
+ }
+ }
+
+ if (containerName.trim().contains("(")) {
+ String first = containerName.trim().split("\\(")[1].split("/")[0];
+ Integer currentPageNumber = Integer.parseInt(first);
+ //System.out.println("current:"+currentPageNumber);
+ if (!pagesVisited.contains(currentPageNumber)) {
+ boolean hasStack = false;
+ if (Minecraft.getMinecraft().thePlayer.openContainer instanceof ContainerChest) {
+ IInventory inv =
+ ((ContainerChest) Minecraft.getMinecraft().thePlayer.openContainer).getLowerChestInventory();
+ for (int i = 0; i < inv.getSizeInventory(); i++) {
+ ItemStack stack = inv.getStackInSlot(i);
+ if (stack != null) {
+ hasStack = true;
+ if (isAccessory(stack)) {
+ accessoryStacks.add(stack);
+ }
+ }
+ }
+ }
+
+ if (hasStack) pagesVisited.add(currentPageNumber);
+ }
+
+ String second = containerName.trim().split("/")[1].split("\\)")[0];
+ //System.out.println(second + ":" + pagesVisited.size());
+ if (Integer.parseInt(second) > pagesVisited.size()) {
+ GlStateManager.color(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(accessory_bag_overlay);
+ Utils.drawTexturedRect(
+ guiLeft + xSize + 3,
+ guiTop,
+ 80,
+ 149,
+ 0,
+ 80 / 256f,
+ 0,
+ 149 / 256f,
+ GL11.GL_NEAREST
+ );
+
+ renderVisitOverlay(guiLeft + xSize + 3, guiTop);
+ return;
+ }
+ } else if (pagesVisited.isEmpty()) {
+ boolean hasStack = false;
+ if (Minecraft.getMinecraft().thePlayer.openContainer instanceof ContainerChest) {
+ IInventory inv =
+ ((ContainerChest) Minecraft.getMinecraft().thePlayer.openContainer).getLowerChestInventory();
+ for (int i = 0; i < inv.getSizeInventory(); i++) {
+ ItemStack stack = inv.getStackInSlot(i);
+ if (stack != null) {
+ hasStack = true;
+ if (isAccessory(stack)) {
+ accessoryStacks.add(stack);
+ }
+ }
+ }
+ }
+
+ if (hasStack) pagesVisited.add(1);
+ }
+
+ GlStateManager.disableLighting();
+
+ for (int i = 0; i <= TAB_MISSING; i++) {
+ if (i != currentTab) {
+ GlStateManager.color(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(accessory_bag_overlay);
+ Utils.drawTexturedRect(guiLeft + xSize + 80, guiTop + 20 * i, 25, 22,
+ 80 / 256f, 105 / 256f, 0, 22 / 256f, GL11.GL_NEAREST
+ );
+ Utils.drawItemStack(TAB_STACKS[i], guiLeft + xSize + 80 + 5, guiTop + 20 * i + 3);
+ }
+ }
+
+ GlStateManager.color(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(accessory_bag_overlay);
+ Utils.drawTexturedRect(guiLeft + xSize + 3, guiTop, 80, 149, 0, 80 / 256f, 0, 149 / 256f, GL11.GL_NEAREST);
+
+ if (pagesVisited.size() < 1) {
+ renderVisitOverlay(guiLeft + xSize + 3, guiTop);
+ return;
+ }
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(accessory_bag_overlay);
+ Utils.drawTexturedRect(guiLeft + xSize + 80, guiTop + 20 * currentTab, 28, 22,
+ 80 / 256f, 108 / 256f, 22 / 256f, 44 / 256f, GL11.GL_NEAREST
+ );
+ Utils.drawItemStack(TAB_STACKS[currentTab], guiLeft + xSize + 80 + 8, guiTop + 20 * currentTab + 3);
+
+ switch (currentTab) {
+ case TAB_BASIC:
+ renderBasicOverlay(guiLeft + xSize + 3, guiTop);
+ return;
+ case TAB_TOTAL:
+ renderTotalStatsOverlay(guiLeft + xSize + 3, guiTop);
+ return;
+ case TAB_BONUS:
+ renderReforgeStatsOverlay(guiLeft + xSize + 3, guiTop);
+ return;
+ case TAB_DUP:
+ renderDuplicatesOverlay(guiLeft + xSize + 3, guiTop);
+ return;
+ case TAB_MISSING:
+ renderMissingOverlay(guiLeft + xSize + 3, guiTop);
+ return;
+ case TAB_OPTIMIZER:
+ renderOptimizerOverlay(guiLeft + xSize + 3, guiTop);
+ return;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
/*private static void renderAlignedString(String first, String second, float x, float y, int length) {
FontRenderer fontRendererObj = Minecraft.getMinecraft().fontRendererObj;
@@ -752,217 +1022,192 @@ public class AccessoryBagOverlay {
}
}*/
- private static final String STAT_PATTERN_BONUS_END = ": (?:\\+|-)[0-9]+(?:\\.[0-9]+)?\\%? \\(((?:\\+|-)[0-9]+)%?";
-
- private static final Pattern HEALTH_PATTERN_BONUS = Pattern.compile("^Health"+STAT_PATTERN_BONUS_END);
- private static final Pattern DEFENCE_PATTERN_BONUS = Pattern.compile("^Defense"+STAT_PATTERN_BONUS_END);
- private static final Pattern STRENGTH_PATTERN_BONUS = Pattern.compile("^Strength"+STAT_PATTERN_BONUS_END);
- private static final Pattern SPEED_PATTERN_BONUS = Pattern.compile("^Speed"+STAT_PATTERN_BONUS_END);
- private static final Pattern CC_PATTERN_BONUS = Pattern.compile("^Crit Chance"+STAT_PATTERN_BONUS_END);
- private static final Pattern CD_PATTERN_BONUS = Pattern.compile("^Crit Damage"+STAT_PATTERN_BONUS_END);
- private static final Pattern ATKSPEED_PATTERN_BONUS = Pattern.compile("^Bonus Attack Speed"+STAT_PATTERN_BONUS_END);
- private static final Pattern INTELLIGENCE_PATTERN_BONUS = Pattern.compile("^Intelligence"+STAT_PATTERN_BONUS_END);
- private static final Pattern SCC_PATTERN_BONUS = Pattern.compile("^Sea Creature Chance"+STAT_PATTERN_BONUS_END);
- private static final Pattern FEROCITY_PATTERN_BONUS = Pattern.compile("^Ferocity"+STAT_PATTERN_BONUS_END);
- private static final Pattern MINING_FORTUNE_PATTERN_BONUS = Pattern.compile("^Mining Fortune"+STAT_PATTERN_BONUS_END);
- private static final Pattern MINING_SPEED_PATTERN_BONUS = Pattern.compile("^Mining Speed"+STAT_PATTERN_BONUS_END);
- private static final Pattern MAGIC_FIND_PATTERN_BONUS = Pattern.compile("^Magic Find"+STAT_PATTERN_BONUS_END);
- private static final HashMap<String, Pattern> STAT_PATTERN_MAP_BONUS = new HashMap<>();
- static {
- STAT_PATTERN_MAP_BONUS.put("health", HEALTH_PATTERN_BONUS);
- STAT_PATTERN_MAP_BONUS.put("defence", DEFENCE_PATTERN_BONUS);
- STAT_PATTERN_MAP_BONUS.put("strength", STRENGTH_PATTERN_BONUS);
- STAT_PATTERN_MAP_BONUS.put("speed", SPEED_PATTERN_BONUS);
- STAT_PATTERN_MAP_BONUS.put("crit_chance", CC_PATTERN_BONUS);
- STAT_PATTERN_MAP_BONUS.put("crit_damage", CD_PATTERN_BONUS);
- STAT_PATTERN_MAP_BONUS.put("bonus_attack_speed", ATKSPEED_PATTERN_BONUS);
- STAT_PATTERN_MAP_BONUS.put("intelligence", INTELLIGENCE_PATTERN_BONUS);
- STAT_PATTERN_MAP_BONUS.put("sea_creature_chance", SCC_PATTERN_BONUS);
- STAT_PATTERN_MAP_BONUS.put("ferocity", FEROCITY_PATTERN_BONUS);
- STAT_PATTERN_MAP_BONUS.put("mining_fortune", MINING_FORTUNE_PATTERN_BONUS);
- STAT_PATTERN_MAP_BONUS.put("mining_speed", MINING_SPEED_PATTERN_BONUS);
- STAT_PATTERN_MAP_BONUS.put("magic_find", MAGIC_FIND_PATTERN_BONUS);
- }
-
-
- private static final String STAT_PATTERN_END = ": ((?:\\+|-)([0-9]+(\\.[0-9]+)?))%?";
-
- private static final Pattern HEALTH_PATTERN = Pattern.compile("^Health"+STAT_PATTERN_END);
- private static final Pattern DEFENCE_PATTERN = Pattern.compile("^Defense"+STAT_PATTERN_END);
- private static final Pattern STRENGTH_PATTERN = Pattern.compile("^Strength"+STAT_PATTERN_END);
- private static final Pattern SPEED_PATTERN = Pattern.compile("^Speed"+STAT_PATTERN_END);
- private static final Pattern CC_PATTERN = Pattern.compile("^Crit Chance"+STAT_PATTERN_END);
- private static final Pattern CD_PATTERN = Pattern.compile("^Crit Damage"+STAT_PATTERN_END);
- private static final Pattern ATKSPEED_PATTERN = Pattern.compile("^Bonus Attack Speed"+STAT_PATTERN_END);
- private static final Pattern INTELLIGENCE_PATTERN = Pattern.compile("^Intelligence"+STAT_PATTERN_END);
- private static final Pattern SCC_PATTERN = Pattern.compile("^Sea Creature Chance"+STAT_PATTERN_END);
- private static final Pattern FEROCITY_PATTERN = Pattern.compile("^Ferocity"+STAT_PATTERN_END);
- private static final Pattern MINING_FORTUNE_PATTERN = Pattern.compile("^Mining Fortune"+STAT_PATTERN_END);
- private static final Pattern MINING_SPEED_PATTERN = Pattern.compile("^Mining Speed"+STAT_PATTERN_END);
- private static final Pattern MAGIC_FIND_PATTERN = Pattern.compile("^Magic Find"+STAT_PATTERN_END);
-
- private static final HashMap<String, Pattern> STAT_PATTERN_MAP = new HashMap<>();
- static {
- STAT_PATTERN_MAP.put("health", HEALTH_PATTERN);
- STAT_PATTERN_MAP.put("defence", DEFENCE_PATTERN);
- STAT_PATTERN_MAP.put("strength", STRENGTH_PATTERN);
- STAT_PATTERN_MAP.put("speed", SPEED_PATTERN);
- STAT_PATTERN_MAP.put("crit_chance", CC_PATTERN);
- STAT_PATTERN_MAP.put("crit_damage", CD_PATTERN);
- STAT_PATTERN_MAP.put("bonus_attack_speed", ATKSPEED_PATTERN);
- STAT_PATTERN_MAP.put("intelligence", INTELLIGENCE_PATTERN);
- STAT_PATTERN_MAP.put("sea_creature_chance", SCC_PATTERN);
- STAT_PATTERN_MAP.put("ferocity", FEROCITY_PATTERN);
- STAT_PATTERN_MAP.put("mining_fortune", MINING_FORTUNE_PATTERN);
- STAT_PATTERN_MAP.put("mining_speed", MINING_SPEED_PATTERN);
- STAT_PATTERN_MAP.put("magic_find", MAGIC_FIND_PATTERN);
- }
- private static PlayerStats.Stats getStatForItem(ItemStack stack, HashMap<String, Pattern> patternMap, boolean addExtras) {
- String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack);
- NBTTagCompound tag = stack.getTagCompound();
- PlayerStats.Stats stats = new PlayerStats.Stats();
-
- if(internalname == null) {
- return stats;
- }
-
- if(tag != null) {
- NBTTagCompound display = tag.getCompoundTag("display");
- if (display.hasKey("Lore", 9)) {
- NBTTagList list = display.getTagList("Lore", 8);
- for (int i = 0; i < list.tagCount(); i++) {
- String line = list.getStringTagAt(i);
- for(Map.Entry<String, Pattern> entry : patternMap.entrySet()) {
- Matcher matcher = entry.getValue().matcher(Utils.cleanColour(line));
- if(matcher.find()) {
- float bonus = Float.parseFloat(matcher.group(1));
- stats.addStat(entry.getKey(), bonus);
- }
- }
- }
- }
- }
-
- if(!addExtras) return stats;
-
- if(internalname.equals("DAY_CRYSTAL") || internalname.equals("NIGHT_CRYSTAL")) {
- stats.addStat(PlayerStats.STRENGTH, 2.5f);
- stats.addStat(PlayerStats.DEFENCE, 2.5f);
- }
-
- if(internalname.equals("NEW_YEAR_CAKE_BAG") && tag != null && tag.hasKey("ExtraAttributes", 10)) {
- NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
-
- byte[] bytes = null;
- for (String key : ea.getKeySet()) {
- if (key.endsWith("backpack_data") || key.equals("new_year_cake_bag_data")) {
- bytes = ea.getByteArray(key);
- try {
- NBTTagCompound contents_nbt = CompressedStreamTools.readCompressed(new ByteArrayInputStream(bytes));
- NBTTagList items = contents_nbt.getTagList("i", 10);
- HashSet<Integer> cakes = new HashSet<>();
- for(int j=0; j<items.tagCount(); j++) {
- if(items.getCompoundTagAt(j).getKeySet().size() > 0) {
- NBTTagCompound nbt = items.getCompoundTagAt(j).getCompoundTag("tag");
- if(nbt != null && nbt.hasKey("ExtraAttributes", 10)) {
- NBTTagCompound ea2 = nbt.getCompoundTag("ExtraAttributes");
- if (ea2.hasKey("new_years_cake")) {
- cakes.add(ea2.getInteger("new_years_cake"));
- }
- }
- }
- }
- stats.addStat(PlayerStats.HEALTH, cakes.size());
- } catch(IOException e) {
- e.printStackTrace();
- return stats;
- }
- break;
- }
- }
- }
- return stats;
- }
-
-// private static String[] rarityArr = new String[] {
-// "COMMON", "UNCOMMON", "RARE", "EPIC", "LEGENDARY", "MYTHIC", "SPECIAL", "VERY SPECIAL", "SUPREME"
-// };
-// private static String[] rarityArrC = new String[] {
-// EnumChatFormatting.WHITE+EnumChatFormatting.BOLD.toString()+"COMMON",
-// EnumChatFormatting.GREEN+EnumChatFormatting.BOLD.toString()+"UNCOMMON",
-// EnumChatFormatting.BLUE+EnumChatFormatting.BOLD.toString()+"RARE",
-// EnumChatFormatting.DARK_PURPLE+EnumChatFormatting.BOLD.toString()+"EPIC",
-// EnumChatFormatting.GOLD+EnumChatFormatting.BOLD.toString()+"LEGENDARY",
-// EnumChatFormatting.LIGHT_PURPLE+EnumChatFormatting.BOLD.toString()+"MYTHIC",
-// EnumChatFormatting.RED+EnumChatFormatting.BOLD.toString()+"SPECIAL",
-// EnumChatFormatting.RED+EnumChatFormatting.BOLD.toString()+"VERY SPECIAL",
-// EnumChatFormatting.DARK_RED+EnumChatFormatting.BOLD.toString()+"SUPREME",
-// };
- public static int checkItemType(ItemStack stack, boolean contains, String... typeMatches) {
- NBTTagCompound tag = stack.getTagCompound();
- if(tag != null) {
- NBTTagCompound display = tag.getCompoundTag("display");
- if (display.hasKey("Lore", 9)) {
- NBTTagList list = display.getTagList("Lore", 8);
- for (int i = list.tagCount()-1; i >= 0; i--) {
- String line = list.getStringTagAt(i);
- for(String rarity : Utils.rarityArr) {
- for(int j=0; j<typeMatches.length; j++) {
- if(contains) {
- if(line.trim().contains(rarity + " " + typeMatches[j])) {
- return j;
- } else if(line.trim().contains(rarity + " DUNGEON " + typeMatches[j])) {
- return j;
- }
- } else {
- if(line.trim().endsWith(rarity + " " + typeMatches[j])) {
- return j;
- } else if(line.trim().endsWith(rarity + " DUNGEON " + typeMatches[j])) {
- return j;
- }
- }
- }
- }
- }
- }
- }
- return -1;
- }
- private static int checkItemType(JsonArray lore, String... typeMatches) {
- for(int i=lore.size()-1; i>=0; i--) {
- String line = lore.get(i).getAsString();
-
- for(String rarity : Utils.rarityArr) {
- for(int j=0; j<typeMatches.length; j++) {
- if(line.trim().endsWith(rarity + " " + typeMatches[j])) {
- return j;
- }
- }
- }
- }
- return -1;
- }
-
- public static boolean isAccessory(ItemStack stack) {
- return checkItemType(stack, true, "ACCESSORY", "HATCCESSORY") >= 0;
- }
-
- public static int getRarity(ItemStack stack) {
- NBTTagCompound tag = stack.getTagCompound();
- if(tag != null) {
- NBTTagCompound display = tag.getCompoundTag("display");
- if (display.hasKey("Lore", 9)) {
- NBTTagList list = display.getTagList("Lore", 8);
- for (int i = list.tagCount(); i >= 0; i--) {
- String line = list.getStringTagAt(i);
- for(int j=0; j<Utils.rarityArrC.length; j++) {
- if(line.contains(Utils.rarityArrC[j])) {
- return j;
- }
- }
- }
- }
- }
- return -1;
- }
+ 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]+)%?";
+ put("health", Pattern.compile("^Health" + STAT_PATTERN_BONUS_END));
+ put("defence", Pattern.compile("^Defense" + STAT_PATTERN_BONUS_END));
+ put("strength", Pattern.compile("^Strength" + STAT_PATTERN_BONUS_END));
+ put("speed", Pattern.compile("^Speed" + STAT_PATTERN_BONUS_END));
+ put("crit_chance", Pattern.compile("^Crit Chance" + STAT_PATTERN_BONUS_END));
+ put("crit_damage", Pattern.compile("^Crit Damage" + STAT_PATTERN_BONUS_END));
+ put("bonus_attack_speed", Pattern.compile("^Bonus Attack Speed" + STAT_PATTERN_BONUS_END));
+ put("intelligence", Pattern.compile("^Intelligence" + STAT_PATTERN_BONUS_END));
+ put("sea_creature_chance", Pattern.compile("^Sea Creature Chance" + STAT_PATTERN_BONUS_END));
+ put("ferocity", Pattern.compile("^Ferocity" + STAT_PATTERN_BONUS_END));
+ put("mining_fortune", Pattern.compile("^Mining Fortune" + STAT_PATTERN_BONUS_END));
+ put("mining_speed", Pattern.compile("^Mining Speed" + STAT_PATTERN_BONUS_END));
+ put("magic_find", Pattern.compile("^Magic Find" + STAT_PATTERN_BONUS_END));
+ }};
+
+ private static final HashMap<String, Pattern> STAT_PATTERN_MAP = new HashMap<String, Pattern>() {{
+ String STAT_PATTERN_END = ": ((?:\\+|-)([0-9]+(\\.[0-9]+)?))%?";
+ put("health", Pattern.compile("^Health" + STAT_PATTERN_END));
+ put("defence", Pattern.compile("^Defense" + STAT_PATTERN_END));
+ put("strength", Pattern.compile("^Strength" + STAT_PATTERN_END));
+ put("speed", Pattern.compile("^Speed" + STAT_PATTERN_END));
+ put("crit_chance", Pattern.compile("^Crit Chance" + STAT_PATTERN_END));
+ put("crit_damage", Pattern.compile("^Crit Damage" + STAT_PATTERN_END));
+ put("bonus_attack_speed", Pattern.compile("^Bonus Attack Speed" + STAT_PATTERN_END));
+ put("intelligence", Pattern.compile("^Intelligence" + STAT_PATTERN_END));
+ put("sea_creature_chance", Pattern.compile("^Sea Creature Chance" + STAT_PATTERN_END));
+ put("ferocity", Pattern.compile("^Ferocity" + STAT_PATTERN_END));
+ put("mining_fortune", Pattern.compile("^Mining Fortune" + STAT_PATTERN_END));
+ put("mining_speed", Pattern.compile("^Mining Speed" + STAT_PATTERN_END));
+ put("magic_find", Pattern.compile("^Magic Find" + STAT_PATTERN_END));
+ }};
+
+ private static PlayerStats.Stats getStatForItem(
+ ItemStack stack,
+ HashMap<String, Pattern> patternMap,
+ boolean addExtras
+ ) {
+ String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack);
+ NBTTagCompound tag = stack.getTagCompound();
+ PlayerStats.Stats stats = new PlayerStats.Stats();
+
+ if (internalname == null) {
+ return stats;
+ }
+
+ if (tag != null) {
+ NBTTagCompound display = tag.getCompoundTag("display");
+ if (display.hasKey("Lore", 9)) {
+ NBTTagList list = display.getTagList("Lore", 8);
+ for (int i = 0; i < list.tagCount(); i++) {
+ String line = list.getStringTagAt(i);
+ for (Map.Entry<String, Pattern> entry : patternMap.entrySet()) {
+ Matcher matcher = entry.getValue().matcher(Utils.cleanColour(line));
+ if (matcher.find()) {
+ float bonus = Float.parseFloat(matcher.group(1));
+ stats.addStat(entry.getKey(), bonus);
+ }
+ }
+ }
+ }
+ }
+
+ if (!addExtras) return stats;
+
+ if (internalname.equals("DAY_CRYSTAL") || internalname.equals("NIGHT_CRYSTAL")) {
+ stats.addStat(PlayerStats.STRENGTH, 2.5f);
+ stats.addStat(PlayerStats.DEFENCE, 2.5f);
+ }
+
+ if (internalname.equals("NEW_YEAR_CAKE_BAG") && tag != null && tag.hasKey("ExtraAttributes", 10)) {
+ NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
+
+ byte[] bytes = null;
+ for (String key : ea.getKeySet()) {
+ if (key.endsWith("backpack_data") || key.equals("new_year_cake_bag_data")) {
+ bytes = ea.getByteArray(key);
+ try {
+ NBTTagCompound contents_nbt = CompressedStreamTools.readCompressed(new ByteArrayInputStream(bytes));
+ NBTTagList items = contents_nbt.getTagList("i", 10);
+ HashSet<Integer> cakes = new HashSet<>();
+ for (int j = 0; j < items.tagCount(); j++) {
+ if (items.getCompoundTagAt(j).getKeySet().size() > 0) {
+ NBTTagCompound nbt = items.getCompoundTagAt(j).getCompoundTag("tag");
+ if (nbt != null && nbt.hasKey("ExtraAttributes", 10)) {
+ NBTTagCompound ea2 = nbt.getCompoundTag("ExtraAttributes");
+ if (ea2.hasKey("new_years_cake")) {
+ cakes.add(ea2.getInteger("new_years_cake"));
+ }
+ }
+ }
+ }
+ stats.addStat(PlayerStats.HEALTH, cakes.size());
+ } catch (IOException e) {
+ e.printStackTrace();
+ return stats;
+ }
+ break;
+ }
+ }
+ }
+ return stats;
+ }
+
+ // private static String[] rarityArr = new String[] {
+ // "COMMON", "UNCOMMON", "RARE", "EPIC", "LEGENDARY", "MYTHIC", "SPECIAL", "VERY SPECIAL", "SUPREME"
+ // };
+ // private static String[] rarityArrC = new String[] {
+ // EnumChatFormatting.WHITE+EnumChatFormatting.BOLD.toString()+"COMMON",
+ // EnumChatFormatting.GREEN+EnumChatFormatting.BOLD.toString()+"UNCOMMON",
+ // EnumChatFormatting.BLUE+EnumChatFormatting.BOLD.toString()+"RARE",
+ // EnumChatFormatting.DARK_PURPLE+EnumChatFormatting.BOLD.toString()+"EPIC",
+ // EnumChatFormatting.GOLD+EnumChatFormatting.BOLD.toString()+"LEGENDARY",
+ // EnumChatFormatting.LIGHT_PURPLE+EnumChatFormatting.BOLD.toString()+"MYTHIC",
+ // EnumChatFormatting.RED+EnumChatFormatting.BOLD.toString()+"SPECIAL",
+ // EnumChatFormatting.RED+EnumChatFormatting.BOLD.toString()+"VERY SPECIAL",
+ // EnumChatFormatting.DARK_RED+EnumChatFormatting.BOLD.toString()+"SUPREME",
+ // };
+
+ public static int checkItemType(ItemStack stack, boolean contains, String... typeMatches) {
+ NBTTagCompound tag = stack.getTagCompound();
+ if (tag != null) {
+ NBTTagCompound display = tag.getCompoundTag("display");
+ if (display.hasKey("Lore", 9)) {
+ NBTTagList list = display.getTagList("Lore", 8);
+ for (int i = list.tagCount() - 1; i >= 0; i--) {
+ String line = list.getStringTagAt(i);
+ for (String rarity : Utils.rarityArr) {
+ for (int j = 0; j < typeMatches.length; j++) {
+ if (contains) {
+ if (line.trim().contains(rarity + " " + typeMatches[j])) {
+ return j;
+ } else if (line.trim().contains(rarity + " DUNGEON " + typeMatches[j])) {
+ return j;
+ }
+ } else {
+ if (line.trim().endsWith(rarity + " " + typeMatches[j])) {
+ return j;
+ } else if (line.trim().endsWith(rarity + " DUNGEON " + typeMatches[j])) {
+ return j;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return -1;
+ }
+
+ private static int checkItemType(JsonArray lore, String... typeMatches) {
+ for (int i = lore.size() - 1; i >= 0; i--) {
+ String line = lore.get(i).getAsString();
+
+ for (String rarity : Utils.rarityArr) {
+ for (int j = 0; j < typeMatches.length; j++) {
+ if (line.trim().endsWith(rarity + " " + typeMatches[j])) {
+ return j;
+ }
+ }
+ }
+ }
+ return -1;
+ }
+
+ public static boolean isAccessory(ItemStack stack) {
+ return checkItemType(stack, true, "ACCESSORY", "HATCCESSORY") >= 0;
+ }
+
+ public static int getRarity(ItemStack stack) {
+ NBTTagCompound tag = stack.getTagCompound();
+ if (tag != null) {
+ NBTTagCompound display = tag.getCompoundTag("display");
+ if (display.hasKey("Lore", 9)) {
+ NBTTagList list = display.getTagList("Lore", 8);
+ for (int i = list.tagCount(); i >= 0; i--) {
+ String line = list.getStringTagAt(i);
+ for (int j = 0; j < Utils.rarityArrC.length; j++) {
+ if (line.contains(Utils.rarityArrC[j])) {
+ return j;
+ }
+ }
+ }
+ }
+ }
+ return -1;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java
index 3305cd13..98d8f11d 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java
@@ -15,7 +15,6 @@ import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.gui.inventory.GuiChest;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.shader.Framebuffer;
import net.minecraft.client.shader.Shader;
import net.minecraft.init.Items;
@@ -36,1356 +35,1408 @@ import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
-import static io.github.moulberry.notenoughupdates.util.GuiTextures.*;
-
import java.io.File;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-public class CalendarOverlay {
-
- private static final ResourceLocation BACKGROUND = new ResourceLocation("notenoughupdates:calendar/background.png");
- private static final ResourceLocation DISPLAYBAR = new ResourceLocation("notenoughupdates:calendar/displaybar.png");
- private static final ResourceLocation TOAST = new ResourceLocation("notenoughupdates:calendar/toast.png");
-
- private static JsonObject farmingEventTypes = null;
-
- private static boolean enabled = false;
-
- public static void setEnabled(boolean enabled) {
- CalendarOverlay.enabled = enabled;
- }
-
- public static boolean isEnabled() {
- return enabled;
- }
-
- private int guiLeft = -1;
- private int guiTop = -1;
- private int xSize = 168;
- private int ySize = 170;
-
- private class SBEvent {
- String id;
- String display;
- ItemStack stack;
- List<String> desc;
- long lastsFor;
-
- public SBEvent(String id, String display, ItemStack stack, List<String> desc) {
- this(id, display, stack, desc, -1);
- }
-
- public SBEvent(String id, String display, ItemStack stack, List<String> desc, long lastsFor) {
- this.id = id;
- this.display = display;
- this.stack = stack;
- this.desc = desc;
- this.lastsFor = lastsFor;
- }
- }
-
- private int jingleIndex = -1;
-
- private TreeMap<Long, Set<SBEvent>> eventMap = new TreeMap<>();
- private List<String> jfFavouriteSelect = null;
- private int jfFavouriteSelectIndex = 0;
- private int jfFavouriteSelectX = 0;
- private int jfFavouriteSelectY = 0;
-
- private boolean drawTimerForeground = false;
-
- private static long spookyStart = 0;
-
- private static long SECOND = 1000;
- private static long MINUTE = SECOND*60;
- private static long HOUR = MINUTE*60;
- private static long DAY = HOUR*24;
-
- private static long DA_OFFSET = 1000*60*55;
- private static long JF_OFFSET = 1000*60*15;
-
- private static ItemStack DA_STACK;
- private static ItemStack JF_STACK;
- static {
- NBTTagCompound tag = new NBTTagCompound();
- tag.setString("event_id", "dark_auction");
- //tag.setTag("ench", new NBTTagList());
-
- DA_STACK = new ItemStack(Items.netherbrick);
- DA_STACK.setTagCompound(tag);
-
- tag.setString("event_id", "jacob_farming");
- JF_STACK = new ItemStack(Items.wheat);
- JF_STACK.setTagCompound(tag);
- }
-
- public long getTimeOffset(String time) {
- long offset = 0;
-
- StringBuilder numS = new StringBuilder();
- for(int timeIndex=0; timeIndex<time.length(); timeIndex++) {
- char c = time.charAt(timeIndex);
-
- if(c >= '0' && c <= '9') {
- numS.append(c);
- } else {
- try {
- int num = Integer.parseInt(numS.toString());
- switch (c) {
- case 'd':
- offset += num * DAY; continue;
- case 'h':
- offset += num * HOUR; continue;
- case 'm':
- offset += num * MINUTE; continue;
- case 's':
- offset += num * SECOND; continue;
- }
- } catch(Exception ignored) {}
- numS = new StringBuilder();
- }
- }
-
- return offset;
- }
-
- private static Pattern CALENDAR_PATTERN = Pattern.compile("([A-Za-z ]+), Year ([0-9]+)");
- private static long SKYBLOCK_START = 1559829300000L; //Day 0, Year 0
-
- @SubscribeEvent
- public void tick(TickEvent.ClientTickEvent event) {
- if(event.phase != TickEvent.Phase.START) return;
-
- if(jingleIndex == 0) {
- if (NotEnoughUpdates.INSTANCE.config.calendar.eventNotificationSounds) {
- Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(
- new ResourceLocation("notenoughupdates:calendar_notif_jingle")
- ));
- Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(
- new ResourceLocation("notenoughupdates:calendar_notif_in")
- ));
- }
- jingleIndex = -15*20;
- } else if(jingleIndex >= 1) {
- if (NotEnoughUpdates.INSTANCE.config.calendar.eventNotificationSounds) {
- Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(
- new ResourceLocation("notenoughupdates:calendar_notif_in")
- ));
- }
- jingleIndex = -15*20;
- } else if(jingleIndex < -1) {
- jingleIndex++;
- }
- if(jingleIndex == -20*6-10) {
- if(NotEnoughUpdates.INSTANCE.config.calendar.eventNotificationSounds) {
- Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(
- new ResourceLocation("notenoughupdates:calendar_notif_out")
- ));
- }
- }
-
- if(farmingEventTypes == null) {
- farmingEventTypes = NotEnoughUpdates.INSTANCE.manager.getJsonFromFile(new File(NotEnoughUpdates.INSTANCE.manager.configLocation,
- "farmingEventTypes.json"));
- if(farmingEventTypes == null) {
- farmingEventTypes = new JsonObject();
- }
- }
-
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) {
- jfFavouriteSelect = null;
- if(eventMap.isEmpty() || eventMap.size() <= 20) {
- long currentTime = System.currentTimeMillis();
- long floorHour = (currentTime/HOUR)*HOUR;
- for(int i=0; i<15; i++) {
- long daEvent = floorHour+i*HOUR+DA_OFFSET;
- long jfEvent = floorHour+i*HOUR+JF_OFFSET;
-
- if(daEvent > currentTime) {
- eventMap.computeIfAbsent(daEvent, k->new HashSet<>()).add(new SBEvent("dark_auction",
- EnumChatFormatting.DARK_PURPLE+"Dark Auction", DA_STACK, null, MINUTE*5));
- }
- if(jfEvent > currentTime) {
- SBEvent jf = new SBEvent("jacob_farming",
- EnumChatFormatting.YELLOW+"Jacob's Farming Contest", JF_STACK, null, MINUTE*20);
- if(farmingEventTypes != null && farmingEventTypes.has(""+jfEvent) &&
- farmingEventTypes.get(""+jfEvent).isJsonArray()) {
- JsonArray arr = farmingEventTypes.get(""+jfEvent).getAsJsonArray();
- jf.desc = new ArrayList<>();
- for(JsonElement e : arr) {
- jf.desc.add(EnumChatFormatting.YELLOW+"\u25CB "+e.getAsString());
- jf.id += ":" + e.getAsString();
- }
- }
- eventMap.computeIfAbsent(jfEvent, k->new HashSet<>()).add(jf);
- }
- }
- }
- return;
- }
-
- GuiChest eventGui = (GuiChest) Minecraft.getMinecraft().currentScreen;
- ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
- String containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText();
-
- Matcher matcher = CALENDAR_PATTERN.matcher(Utils.cleanColour(containerName));
- if(farmingEventTypes != null && matcher.matches()) {
- try {
- int year = Integer.parseInt(matcher.group(2));
- int skyblockDays = year * 12 * 31;
-
- String month = matcher.group(1);
- boolean spring = month.endsWith("Spring");
- boolean summer = month.endsWith("Summer");
- boolean autumn = month.endsWith("Autumn");
- boolean winter = month.endsWith("Winter");
- if(spring || summer || autumn || winter) {
- if(spring) {
- skyblockDays += 1*31;
- } else if(summer) {
- skyblockDays += 4*31;
- } else if(autumn) {
- skyblockDays += 7*31;
- } else {
- skyblockDays += 10*31;
- }
- if(month.startsWith("Early")) {
- skyblockDays -= 31;
- } else if(month.startsWith("Late")) {
- skyblockDays += 31;
- }
-
- long start = SKYBLOCK_START + skyblockDays*20*MINUTE;
-
- boolean changed = false;
- for(int i=0; i<31; i++) {
- ItemStack item = cc.getLowerChestInventory().getStackInSlot(1+(i%7)+(i/7)*9);
-
- JsonArray array = new JsonArray();
- if(item.getTagCompound() != null) {
- NBTTagCompound tag = item.getTagCompound();
-
- if(tag.hasKey("display", 10)) {
- NBTTagCompound display = tag.getCompoundTag("display");
- if (display.hasKey("Lore", 9)) {
- NBTTagList list = display.getTagList("Lore", 8);
- for(int j=0; j<list.tagCount(); j++) {
- String line = list.getStringTagAt(j);
- if(line.startsWith(EnumChatFormatting.YELLOW+"\u25CB")) {
- array.add(new JsonPrimitive(Utils.cleanColour(line.substring(4))));
- }
- }
- }
- }
- }
- if(array.size() == 3) {
- String prop = String.valueOf(start + i*20*MINUTE);
- if(!farmingEventTypes.has(prop) || !farmingEventTypes.get(prop).isJsonArray() ||
- farmingEventTypes.get(prop).getAsJsonArray().equals(array)) {
- changed = true;
- }
- farmingEventTypes.add(prop, array);
- }
- }
- if(changed) {
- File f = new File(NotEnoughUpdates.INSTANCE.manager.configLocation,
- "farmingEventTypes.json");
- NotEnoughUpdates.INSTANCE.manager.writeJson(farmingEventTypes, f);
- }
- }
- } catch(Exception ignored) {
- ignored.printStackTrace();
- }
- }
-
- if(!enabled) {
- jfFavouriteSelect = null;
- if(eventMap.isEmpty() || eventMap.size() <= 20) {
- long currentTime = System.currentTimeMillis();
- long floorHour = (currentTime/HOUR)*HOUR;
- for(int i=0; i<15; i++) {
- long daEvent = floorHour+i*HOUR+DA_OFFSET;
- long jfEvent = floorHour+i*HOUR+JF_OFFSET;
-
- if(daEvent > currentTime) {
- eventMap.computeIfAbsent(daEvent, k->new HashSet<>()).add(new SBEvent("dark_auction",
- EnumChatFormatting.DARK_PURPLE+"Dark Auction", DA_STACK, null, MINUTE*5));
- }
- if(jfEvent > currentTime) {
- SBEvent jf = new SBEvent("jacob_farming",
- EnumChatFormatting.YELLOW+"Jacob's Farming Contest", JF_STACK, null, MINUTE*20);
- if(farmingEventTypes != null && farmingEventTypes.has(""+jfEvent) &&
- farmingEventTypes.get(""+jfEvent).isJsonArray()) {
- JsonArray arr = farmingEventTypes.get(""+jfEvent).getAsJsonArray();
- jf.desc = new ArrayList<>();
- for(JsonElement e : arr) {
- jf.desc.add(EnumChatFormatting.YELLOW+"\u25CB "+e.getAsString());
- jf.id += ":" + e.getAsString();
- }
- }
- eventMap.computeIfAbsent(jfEvent, k->new HashSet<>()).add(jf);
- }
- }
- }
- return;
- }
-
- if(!containerName.trim().equals("Calendar and Events")) {
- setEnabled(false);
- return;
- }
-
- eventMap.clear();
-
- long currentTime = System.currentTimeMillis();
- long floorHour = (currentTime/HOUR)*HOUR;
- for(int i=0; i<15; i++) {
- long daEvent = floorHour+i*HOUR+DA_OFFSET;
- long jfEvent = floorHour+i*HOUR+JF_OFFSET;
-
- if(daEvent > currentTime) {
- eventMap.computeIfAbsent(daEvent, k->new HashSet<>()).add(new SBEvent("dark_auction",
- EnumChatFormatting.DARK_PURPLE+"Dark Auction", DA_STACK, null, MINUTE*5));
- }
- if(jfEvent > currentTime) {
- SBEvent jf = new SBEvent("jacob_farming",
- EnumChatFormatting.YELLOW+"Jacob's Farming Contest", JF_STACK, null, MINUTE*20);
- if(farmingEventTypes != null && farmingEventTypes.has(""+jfEvent) &&
- farmingEventTypes.get(""+jfEvent).isJsonArray()) {
- JsonArray arr = farmingEventTypes.get(""+jfEvent).getAsJsonArray();
- jf.desc = new ArrayList<>();
- for(JsonElement e : arr) {
- jf.desc.add(EnumChatFormatting.YELLOW+"\u25CB "+e.getAsString());
- jf.id += ":" + e.getAsString();
- }
- }
- eventMap.computeIfAbsent(jfEvent, k->new HashSet<>()).add(jf);
- }
- }
-
- String lastsForText = EnumChatFormatting.GRAY+"Event lasts for "+EnumChatFormatting.YELLOW;
- String startsInText = EnumChatFormatting.GRAY+"Starts in: "+EnumChatFormatting.YELLOW;
- for(int i=0; i<21; i++) {
- int itemIndex = 10+i+(i/7)*2;
- ItemStack item = cc.getLowerChestInventory().getStackInSlot(itemIndex);
-
- if(item != null && item.getTagCompound() != null) {
- NBTTagCompound tag = item.getTagCompound();
-
- if(tag.hasKey("display", 10)) {
- NBTTagCompound display = tag.getCompoundTag("display");
- if (display.hasKey("Lore", 9)) {
- NBTTagList list = display.getTagList("Lore", 8);
-
- String first = list.getStringTagAt(0);
- if(first.startsWith(startsInText)) {
- String time = Utils.cleanColour(first.substring(startsInText.length()));
- long eventTime = currentTime + getTimeOffset(time);
-
- long lastsFor = -1;
-
- List<String> desc = new ArrayList<>();
- boolean foundBreak = false;
- for(int index=1; index<list.tagCount(); index++) {
- String line = list.getStringTagAt(index);
- if(foundBreak) {
- desc.add(line);
- } else {
- if(line.startsWith(lastsForText)) {
- String lastsForS = Utils.cleanColour(line.substring(lastsForText.length()));
- lastsFor = getTimeOffset(lastsForS);
- }
- if(Utils.cleanColour(line).trim().length() == 0) {
- foundBreak = true;
- }
- }
- }
- eventMap.computeIfAbsent(eventTime, k->new HashSet<>()).add(new SBEvent(
- getIdForDisplayName(item.getDisplayName()), item.getDisplayName(),
- item, desc, lastsFor));
- }
- }
- }
- }
- }
- }
-
- private static String getIdForDisplayName(String displayName) {
- return Utils.cleanColour(displayName)
- .toLowerCase()
- .replaceAll("[0-9]+th", "")
- .replaceAll("[0-9]+nd", "")
- .replaceAll("[0-9]+rd", "")
- .replaceAll("[0-9]+st", "")
- .replaceAll("[^a-z ]", "")
- .trim()
- .replace(" ", "_");
- }
-
-
- @SubscribeEvent
- public void onGuiScreenMouse(GuiScreenEvent.MouseInputEvent.Pre event) {
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- int width = scaledResolution.getScaledWidth();
- int height = scaledResolution.getScaledHeight();
- int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
- int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
-
- if(!enabled) {
- if(Mouse.getEventButtonState() && NotEnoughUpdates.INSTANCE.config.calendar.showEventTimerInInventory &&
- Minecraft.getMinecraft().currentScreen instanceof GuiContainer) {
- xSize = 168;
- ySize = 20;
-
- guiLeft = (width - xSize)/2;
- guiTop = 5;
-
- if(mouseX >= guiLeft && mouseX <= guiLeft+xSize) {
- if(mouseY >= guiTop && mouseY <= guiTop+ySize) {
- ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/neucalendar");
- }
- }
- }
-
- return;
- }
-
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) {
- return;
- }
-
- GuiChest eventGui = (GuiChest) Minecraft.getMinecraft().currentScreen;
- ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
- String containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText();
- if(!containerName.trim().equals("Calendar and Events")) {
- setEnabled(false);
- return;
- }
-
- event.setCanceled(true);
-
- xSize = 168;
- ySize = 170;
- guiLeft = (width - xSize) / 2;
- guiTop = (height - ySize) / 2;
-
- if(Mouse.getEventButtonState()) {
- if(jfFavouriteSelect != null) {
- FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
- int arrowLen = fr.getStringWidth("> ");
- int selectSizeX = 0;
- int selectStringIndex = 0;
- for (String s : jfFavouriteSelect) {
- int sWidth = fr.getStringWidth(s);
- if (selectStringIndex + 1 == jfFavouriteSelectIndex) sWidth += arrowLen;
- if (sWidth > selectSizeX) {
- selectSizeX = sWidth;
- }
- selectStringIndex++;
- }
- selectSizeX += +10;
-
- if(mouseX > jfFavouriteSelectX && mouseX < jfFavouriteSelectX + selectSizeX &&
- mouseY > jfFavouriteSelectY && mouseY < jfFavouriteSelectY + 18 + jfFavouriteSelect.size() * 10) {
- jfFavouriteSelectIndex = Math.max(0, (mouseY - jfFavouriteSelectY - 5)/10);
-
- List<String> eventFavourites = NotEnoughUpdates.INSTANCE.config.hidden.eventFavourites;
- String id = null;
- if(jfFavouriteSelectIndex == 0) {
- id = "jacob_farming";
- } else if(jfFavouriteSelectIndex-1 < jfFavouriteSelect.size()) {
- id = "jacob_farming:"+jfFavouriteSelect.get(jfFavouriteSelectIndex-1);
- }
- if(id != null) {
- if (eventFavourites.contains(id)) {
- eventFavourites.remove(id);
- } else {
- eventFavourites.add(id);
- }
- }
- } else {
- jfFavouriteSelect = null;
- }
- }
- if(mouseY >= guiTop+26 && mouseY <= guiTop+26+141) {
- if(mouseX >= guiLeft+151 && mouseX <= guiLeft+151+14) {
- if(mouseY <= guiTop+26+70) {
- Minecraft.getMinecraft().playerController.windowClick(cc.windowId,
- 50, 2, 3, Minecraft.getMinecraft().thePlayer);
- } else {
- Minecraft.getMinecraft().playerController.windowClick(cc.windowId,
- 45, 2, 3, Minecraft.getMinecraft().thePlayer);
- }
- }
- }
- }
- }
-
- @SubscribeEvent
- public void onGuiScreenKeyboard(GuiScreenEvent.KeyboardInputEvent.Pre event) {
- if(Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
- if(jfFavouriteSelect != null) {
- jfFavouriteSelect = null;
- event.setCanceled(true);
- }
- } else {
- if (!enabled) {
- return;
- }
-
- if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) {
- return;
- }
-
- GuiChest eventGui = (GuiChest) Minecraft.getMinecraft().currentScreen;
- ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
- String containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText();
- if (!containerName.trim().equals("Calendar and Events")) {
- setEnabled(false);
- return;
- }
-
- event.setCanceled(true);
- xSize = 168;
- ySize = 170;
-
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- int width = scaledResolution.getScaledWidth();
- int height = scaledResolution.getScaledHeight();
- int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
- int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
- guiLeft = (width - xSize) / 2;
- guiTop = (height - ySize) / 2;
-
- int keyPressed = Keyboard.getEventKey() == 0 ? Keyboard.getEventCharacter() + 256 : Keyboard.getEventKey();
- if(Keyboard.getEventKeyState()) {
- if(jfFavouriteSelect != null) {
- if(keyPressed == Keyboard.KEY_DOWN) {
- jfFavouriteSelectIndex++;
- jfFavouriteSelectIndex %= jfFavouriteSelect.size()+1;
- } else if(keyPressed == Keyboard.KEY_UP) {
- jfFavouriteSelectIndex--;
- if(jfFavouriteSelectIndex < 0) jfFavouriteSelectIndex = jfFavouriteSelect.size();
- } else if(keyPressed == Keyboard.KEY_RIGHT || keyPressed == Keyboard.KEY_RETURN) {
- List<String> eventFavourites = NotEnoughUpdates.INSTANCE.config.hidden.eventFavourites;
- String id = null;
- if(jfFavouriteSelectIndex == 0) {
- id = "jacob_farming";
- } else if(jfFavouriteSelectIndex-1 < jfFavouriteSelect.size()) {
- id = "jacob_farming:"+jfFavouriteSelect.get(jfFavouriteSelectIndex-1);
- }
- if(id != null) {
- if (eventFavourites.contains(id)) {
- eventFavourites.remove(id);
- } else {
- eventFavourites.add(id);
- }
- }
- } else if(keyPressed == Keyboard.KEY_LEFT ||
- keyPressed == NotEnoughUpdates.INSTANCE.manager.keybindFavourite.getKeyCode()) {
- jfFavouriteSelect = null;
- }
- } else if(keyPressed == NotEnoughUpdates.INSTANCE.manager.keybindFavourite.getKeyCode()) {
- String id = null;
-
- //Daily Events
- int index = 0;
- out:
- for (Map.Entry<Long, Set<SBEvent>> sbEvents : eventMap.entrySet()) {
- for (SBEvent sbEvent : sbEvents.getValue()) {
- int x = guiLeft + 29 + 17 * (index % 3);
- int y = guiTop + 44 + 17 * (index / 3);
-
- if (mouseX >= x && mouseX <= x + 16) {
- if (mouseY >= y && mouseY <= y + 16) {
- id = sbEvent.id;
- }
- }
-
- if (++index >= 21) break out;
- }
- }
-
- //Special Events
- for (int i = 0; i < 21; i++) {
- int itemIndex = 10 + i + (i / 7) * 2;
- ItemStack item = cc.getLowerChestInventory().getStackInSlot(itemIndex);
- if (item == null) continue;
-
- int x = guiLeft + 89 + 17 * (i % 3);
- int y = guiTop + 44 + 17 * (i / 3);
-
- if (mouseX >= x && mouseX <= x + 16) {
- if (mouseY >= y && mouseY <= y + 16) {
- id = getIdForDisplayName(item.getDisplayName());
- }
- }
- }
-
- if (id != null) {
- String[] split = id.split(":");
- if(split.length > 1 && split[0].equals("jacob_farming")) {
- jfFavouriteSelect = new ArrayList<>();
- for(int i=1; i<split.length; i++) {
- jfFavouriteSelect.add(split[i]);
- }
- jfFavouriteSelectIndex = 0;
- jfFavouriteSelectX = mouseX;
- jfFavouriteSelectY = mouseY;
- } else {
- List<String> eventFavourites = NotEnoughUpdates.INSTANCE.config.hidden.eventFavourites;
- if (eventFavourites.contains(id)) {
- eventFavourites.remove(id);
- } else {
- eventFavourites.add(id);
- }
- }
- }
- }
- }
- }
- }
-
- @SubscribeEvent(priority = EventPriority.LOW)
- public void onGuiDraw(RenderGameOverlayEvent.Post event) {
- if(NotEnoughUpdates.INSTANCE.config.calendar.eventNotifications &&
- event.type == RenderGameOverlayEvent.ElementType.ALL) {
- GlStateManager.pushMatrix();
- GlStateManager.translate(0, 0, 10);
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer) && NotEnoughUpdates.INSTANCE.isOnSkyblock()) {
- long currentTime = System.currentTimeMillis();
-
- long timeUntilNext = 0;
- SBEvent nextEvent = null;
- long timeUntilFirst = 0;
- SBEvent firstEvent = null;
-
- List<String> eventFavourites = NotEnoughUpdates.INSTANCE.config.hidden.eventFavourites;
-
- //Daily Events
- out:
- for(Map.Entry<Long, Set<SBEvent>> sbEvents : eventMap.entrySet()) {
- for(SBEvent sbEvent : sbEvents.getValue()) {
- long timeUntilMillis = sbEvents.getKey() - currentTime;
-
- if(timeUntilMillis < -10*SECOND) {
- continue;
- }
-
- if(firstEvent == null) {
- firstEvent = sbEvent;
- timeUntilFirst = timeUntilMillis;
- }
-
- String[] split = sbEvent.id.split(":");
- boolean containsId = false;
- for(int i=1; i<split.length; i++) {
- if(eventFavourites.contains(split[0]+":"+split[i])) {
- containsId = true;
- break;
- }
- }
- if(eventFavourites.isEmpty() || eventFavourites.contains(split[0]) || containsId) {
- nextEvent = sbEvent;
- timeUntilNext = timeUntilMillis;
- break out;
- }
- }
- }
-
- if(nextEvent != null) {
- renderToast(nextEvent, timeUntilNext);
- }
- }
- GlStateManager.translate(0, 0, -10);
- GlStateManager.popMatrix();
- }
- }
-
- public boolean renderToast(SBEvent event, long timeUntil) {
- if(!NotEnoughUpdates.INSTANCE.config.calendar.eventNotifications) {
- return false;
- }
-
- long currentTime = System.currentTimeMillis();
- if(currentTime - spookyStart > 0 && currentTime - spookyStart < HOUR &&
- NotEnoughUpdates.INSTANCE.config.calendar.spookyNightNotification) {
- long delta = (currentTime - SKYBLOCK_START) % (20*MINUTE) - 19*50*SECOND - 10*SECOND;
- if(delta < 500 && delta > -8500) {
- event = new SBEvent("spooky_festival_7pm", "Spooky Festival 7pm", new ItemStack(Items.bone), null);
- timeUntil = delta;
- }
- }
-
- if(event.id.equals("dark_auction")) {
- timeUntil -= 30*1000;
- }
-
- FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- int width = scaledResolution.getScaledWidth();
- int height = scaledResolution.getScaledHeight();
-
- int ySize = 32;
- int xSize = 160;
- int guiLeft = (width - xSize)/2;
- int guiTop = 5;
-
- boolean preNotification = false;
- long preNotificationTime = SECOND*NotEnoughUpdates.INSTANCE.config.calendar.startingSoonTime;
-
- if(preNotificationTime > 500 && timeUntil > 500) {
- timeUntil = timeUntil - preNotificationTime;
- preNotification = true;
- }
-
- if(timeUntil < 500 && timeUntil > -8500) {
- if(jingleIndex == -1) {
- if(preNotification) {
- jingleIndex = 1;
- } else {
- jingleIndex = 0;
- }
- }
-
- float offset;
- float factor = 0;
- if(timeUntil > 0) {
- factor = (timeUntil/500f);
- } else if(timeUntil < -8000) {
- factor = -((timeUntil+8000)/500f);
- }
- factor = (float)(1.06f/(1+Math.exp(-7*(factor-0.5f)))-0.03f);
- offset = -(ySize+5)*factor;
- float y = guiTop+offset;
-
- GlStateManager.color(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(TOAST);
- Utils.drawTexturedRect(guiLeft, y, xSize, ySize, GL11.GL_NEAREST);
-
- GlStateManager.translate(0, y, 0);
- Utils.drawItemStack(event.stack, guiLeft+6, 8);
- GlStateManager.translate(0, -y, 0);
-
- if(preNotification) {
- String starting = EnumChatFormatting.YELLOW+"Event Starting in "+prettyTime(preNotificationTime, true)+"!";
- int startingWidth = fr.getStringWidth(starting);
- fr.drawString(starting, Math.max(guiLeft+23, width/2f-startingWidth/2f), y+7, -1, false);
- } else {
- Utils.drawStringCentered(EnumChatFormatting.YELLOW+"Event Starting Now!", fr, width/2, y+11, false, -1);
- }
-
- int displayWidth = fr.getStringWidth(event.display);
- fr.drawString(event.display, Math.max(guiLeft+23, width/2f-displayWidth/2f), y+17, -1, false);
-
-
- return true;
- }
- return false;
- }
-
- @SubscribeEvent
- public void onGuiScreenDrawTimer(GuiScreenEvent.BackgroundDrawnEvent event) {
- if(!drawTimerForeground) {
- drawTimer();
- }
- GlStateManager.color(1, 1, 1, 1);
- GlStateManager.enableBlend();
- }
-
- @SubscribeEvent
- public void onGuiScreenDrawTimer(GuiScreenEvent.DrawScreenEvent.Post event) {
- if(drawTimerForeground) {
- drawTimer();
- }
- }
-
- public void drawTimer() {
- GlStateManager.pushMatrix();
- GlStateManager.translate(0, 0, 10);
- if(Minecraft.getMinecraft().currentScreen instanceof GuiContainer && NotEnoughUpdates.INSTANCE.isOnSkyblock()) {
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- int width = scaledResolution.getScaledWidth();
- int height = scaledResolution.getScaledHeight();
- int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
- int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
- long currentTime = System.currentTimeMillis();
-
- xSize = 168;
- ySize = 20;
-
- long timeUntilNext = 0;
- SBEvent nextEvent = null;
- long timeUntilFirst = 0;
- SBEvent firstEvent = null;
- List<SBEvent> nextFavourites = new ArrayList<>();
- List<Long> nextFavouritesTime = new ArrayList<>();
- long timeUntilMajor = 0;
- SBEvent nextMajorEvent = null;
-
- List<String> eventFavourites = NotEnoughUpdates.INSTANCE.config.hidden.eventFavourites;
-
- guiLeft = (width - xSize)/2;
- guiTop = 5;
-
- //Daily Events
- out:
- for(Map.Entry<Long, Set<SBEvent>> sbEvents : eventMap.entrySet()) {
- for(SBEvent sbEvent : sbEvents.getValue()) {
- long timeUntilMillis = sbEvents.getKey() - currentTime;
-
- if(timeUntilMillis < -10*SECOND) {
- continue;
- }
-
- if(sbEvent.id.equals("spooky_festival")) {
- if(sbEvents.getKey() > currentTime-HOUR && (sbEvents.getKey() < spookyStart || spookyStart == 0)) {
- spookyStart = sbEvents.getKey();
- }
- }
-
- if(nextMajorEvent == null && !sbEvent.id.split(":")[0].equals("jacob_farming") &&
- !sbEvent.id.equals("dark_auction")) {
- nextMajorEvent = sbEvent;
- timeUntilMajor = timeUntilMillis;
- }
-
- if(firstEvent == null) {
- firstEvent = sbEvent;
- timeUntilFirst = timeUntilMillis;
- }
-
- String[] split = sbEvent.id.split(":");
- boolean containsId = false;
- for(int i=1; i<split.length; i++) {
- if(eventFavourites.contains(split[0]+":"+split[i])) {
- containsId = true;
- break;
- }
- }
- if(eventFavourites.isEmpty() || eventFavourites.contains(split[0]) || containsId) {
- if(nextEvent == null) {
- nextEvent = sbEvent;
- timeUntilNext = timeUntilMillis;
- }
- if(nextFavourites.size() < 3) {
- nextFavourites.add(sbEvent);
- nextFavouritesTime.add(timeUntilMillis);
- }
- }
-
- if(nextFavourites.size() >= 3 && nextMajorEvent != null) {
- break out;
- }
- }
- }
-
- if(nextEvent == null && firstEvent != null) {
- String[] split = firstEvent.id.split(":");
- if(eventFavourites.contains(split[0])) {
- nextEvent = firstEvent;
- timeUntilNext = timeUntilFirst;
- }
- }
-
- if(nextEvent != null) {
- GlStateManager.translate(0, 0, 50);
- boolean toastRendered = renderToast(nextEvent, timeUntilNext);
- GlStateManager.translate(0, 0, -50);
- if(!toastRendered && !enabled && NotEnoughUpdates.INSTANCE.config.calendar.showEventTimerInInventory) {
- List<String> tooltipToDisplay = null;
- FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
-
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
- GlStateManager.disableFog();
- GlStateManager.disableLighting();
- GlStateManager.disableColorMaterial();
-
- renderBlurredBackground(10, width, height, guiLeft+3, guiTop+3, xSize-6, ySize-6);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(DISPLAYBAR);
- Utils.drawTexturedRect(guiLeft, guiTop, xSize, 20, GL11.GL_NEAREST);
-
- String nextS = EnumChatFormatting.YELLOW+"Next: ";
- int nextSLen = fr.getStringWidth(nextS);
- fr.drawString(nextS, guiLeft+8, guiTop+6, -1, false);
-
- String until = " "+EnumChatFormatting.YELLOW+prettyTime(timeUntilNext, false);
- int untilLen = fr.getStringWidth(until);
-
- fr.drawString(until, guiLeft+xSize-8-untilLen, guiTop+6, -1, false);
-
- int eventTitleLen = xSize-16-untilLen-nextSLen;
- int displayWidth = fr.getStringWidth(nextEvent.display);
- int spaceLen = fr.getCharWidth(' ');
- if(displayWidth > eventTitleLen) {
- GL11.glEnable(GL11.GL_SCISSOR_TEST);
- GL11.glScissor((guiLeft+8+nextSLen)*scaledResolution.getScaleFactor(),
- 0,
- eventTitleLen*scaledResolution.getScaleFactor(),
- Minecraft.getMinecraft().displayHeight);
- fr.drawString(nextEvent.display + " " + nextEvent.display,
- guiLeft+8+nextSLen-(float)(currentTime/50.0 % (displayWidth+spaceLen)), guiTop+6, -1, false);
- GL11.glDisable(GL11.GL_SCISSOR_TEST);
- } else {
- if(guiLeft+xSize-8-untilLen > (width+displayWidth)/2) {
- Utils.drawStringCentered(nextEvent.display, fr,width/2f, guiTop+10, false, -1);
- } else {
- fr.drawString(nextEvent.display, guiLeft+8+nextSLen, guiTop+6, -1, false);
- }
- }
-
- if(mouseX > guiLeft && mouseX < guiLeft+168) {
- if(mouseY > guiTop && mouseY < guiTop+20) {
- tooltipToDisplay = new ArrayList<>();
- for(int i=0; i<nextFavourites.size(); i++) {
- SBEvent sbEvent = nextFavourites.get(i);
- long timeUntil = nextFavouritesTime.get(i);
-
- tooltipToDisplay.add(sbEvent.display);
- tooltipToDisplay.add(EnumChatFormatting.GRAY+"Starts in: "+EnumChatFormatting.YELLOW+prettyTime(timeUntil, false));
- if(sbEvent.lastsFor >= 0) {
- tooltipToDisplay.add( EnumChatFormatting.GRAY+"Lasts for: "+EnumChatFormatting.YELLOW+
- prettyTime(sbEvent.lastsFor, true));
- }
- if(sbEvent.id.split(":")[0].equals("jacob_farming") && sbEvent.desc != null) {
- tooltipToDisplay.addAll(sbEvent.desc);
- }
- if(nextMajorEvent != null || i < nextFavourites.size()-1) {
- tooltipToDisplay.add("");
- }
- }
- if(nextMajorEvent != null) {
- tooltipToDisplay.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Next Major:");
- tooltipToDisplay.add(nextMajorEvent.display);
- tooltipToDisplay.add(EnumChatFormatting.GRAY+"Starts in: "+EnumChatFormatting.YELLOW+prettyTime(timeUntilMajor, false));
- if(nextMajorEvent.lastsFor >= 0) {
- tooltipToDisplay.add( EnumChatFormatting.GRAY+"Lasts for: "+EnumChatFormatting.YELLOW+
- prettyTime(nextMajorEvent.lastsFor, true));
- }
- }
-
-
- }
- }
-
- drawTimerForeground = false;
- if(tooltipToDisplay != null) {
- drawTimerForeground = true;
- GlStateManager.translate(0, 0, 100);
- Utils.drawHoveringText(tooltipToDisplay, mouseX, Math.max(17, mouseY), width, height, -1, fr);
- GlStateManager.translate(0, 0, -100);
- }
- }
- }
- }
- GlStateManager.translate(0, 0, -10);
- GlStateManager.popMatrix();
- }
-
- private void renderBlurredBackground(float blurStrength, int screenWidth, int screenHeight,
- int x, int y, int blurWidth, int blurHeight) {
- BackgroundBlur.renderBlurredBackground(blurStrength, screenWidth, screenHeight, x, y, blurWidth, blurHeight);
- Gui.drawRect(x, y, x+blurWidth, y+blurHeight, 0xc8101010);
- GlStateManager.color(1, 1, 1, 1);
- }
-
- @SubscribeEvent
- public void onGuiDraw(GuiScreenEvent.DrawScreenEvent.Pre event) {
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) {
- return;
- }
-
- if(!enabled) {
- return;
- }
-
- GuiChest eventGui = (GuiChest) Minecraft.getMinecraft().currentScreen;
- ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
- String containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText();
- if(!containerName.trim().equals("Calendar and Events")) {
- setEnabled(false);
- return;
- }
-
- event.setCanceled(true);
-
- List<String> tooltipToDisplay = null;
- int mouseX = event.mouseX;
- int mouseY = event.mouseY;
- long currentTime = System.currentTimeMillis();
-
- xSize = 168;
- ySize = 170;
-
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- int width = scaledResolution.getScaledWidth();
- int height = scaledResolution.getScaledHeight();
- guiLeft = (width - xSize)/2;
- guiTop = (height - ySize)/2;
-
- Utils.drawGradientRect(0, 0, width, height, -1072689136, -804253680);
-
- renderBlurredBackground(10, width, height, guiLeft+3, guiTop+3, 162, 14);
- renderBlurredBackground(10, width, height, guiLeft+3, guiTop+26, 14, 141);
- renderBlurredBackground(10, width, height, guiLeft+151, guiTop+26, 14, 141);
- renderBlurredBackground(10, width, height, guiLeft+26, guiTop+26, 116, 141);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(BACKGROUND);
- Utils.drawTexturedRect(guiLeft, guiTop, xSize, ySize, GL11.GL_NEAREST);
-
- GlStateManager.translate(0, 0, 10);
-
- FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
-
- fr.drawString("Daily", guiLeft+29, guiTop+30, 0xffffaa00);
- int specialLen = fr.getStringWidth("Special");
- fr.drawString("Special", guiLeft+139-specialLen, guiTop+30, 0xffffaa00);
-
- ItemStack mayorStack = cc.getLowerChestInventory().getStackInSlot(46);
- if(mayorStack != null) {
- String mayor = mayorStack.getDisplayName();
- float verticalHeight = Utils.getVerticalHeight(mayor);
- Utils.drawStringVertical(mayor, fr, guiLeft+8, guiTop+96-verticalHeight/2,
- false, -1);
- }
-
- String calendar = EnumChatFormatting.GREEN+"Calendar";
- float calendarHeight = Utils.getVerticalHeight(calendar);
- Utils.drawStringVertical(calendar, fr, guiLeft+xSize-12, guiTop+60-calendarHeight/2,
- false, -1);
-
- String rewards = EnumChatFormatting.GOLD+"Rewards";
- float rewardsHeight = Utils.getVerticalHeight(rewards);
- Utils.drawStringVertical(rewards, fr, guiLeft+xSize-12, guiTop+132-rewardsHeight/2,
- false, -1);
-
- if(mouseY >= guiTop+26 && mouseY <= guiTop+26+141) {
- if(mouseX >= guiLeft+3 && mouseX <= guiLeft+3+14) {
- if(mayorStack != null) tooltipToDisplay = mayorStack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
- } else if(mouseX >= guiLeft+151 && mouseX <= guiLeft+151+14) {
- if(mouseY <= guiTop+26+70) {
- ItemStack calendarStack = cc.getLowerChestInventory().getStackInSlot(50);
- if(calendarStack != null) tooltipToDisplay = calendarStack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
- } else {
- ItemStack rewardsStack = cc.getLowerChestInventory().getStackInSlot(45);
- if(rewardsStack != null) tooltipToDisplay = rewardsStack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
- }
- }
- }
-
- long timeUntilNext = 0;
- SBEvent nextEvent = null;
- long timeUntilFirst = 0;
- SBEvent firstEvent = null;
- List<String> eventFavourites = NotEnoughUpdates.INSTANCE.config.hidden.eventFavourites;
-
- //Daily Events
- int index = 0;
- out:
- for(Map.Entry<Long, Set<SBEvent>> sbEvents : eventMap.entrySet()) {
- for(SBEvent sbEvent : sbEvents.getValue()) {
- long timeUntilMillis = sbEvents.getKey() - currentTime;
-
- int x = guiLeft+29+17*(index%3);
- int y = guiTop+44+17*(index/3);
-
- if(sbEvent.id.equals("spooky_festival")) {
- if(sbEvents.getKey() > currentTime-HOUR && (sbEvents.getKey() < spookyStart || spookyStart == 0)) {
- spookyStart = sbEvents.getKey();
- }
- }
-
- if(index >= 21) {
- if(nextEvent != null) break;
- if(eventFavourites.isEmpty()) {
- nextEvent = sbEvent;
- timeUntilNext = timeUntilMillis;
- } else if(eventFavourites.contains(sbEvent.id)) {
- nextEvent = sbEvent;
- timeUntilNext = timeUntilMillis;
- }
- continue;
- }
-
- if(firstEvent == null) {
- firstEvent = sbEvent;
- timeUntilFirst = timeUntilMillis;
- }
-
- String[] split = sbEvent.id.split(":");
- boolean containsId = false;
- for(int i=1; i<split.length; i++) {
- if(eventFavourites.contains(split[0]+":"+split[i])) {
- containsId = true;
- break;
- }
- }
- if(eventFavourites.isEmpty()) {
- if(nextEvent == null) {
- nextEvent = sbEvent;
- timeUntilNext = timeUntilMillis;
- }
- } else if(eventFavourites.contains(split[0]) || containsId) {
- if(nextEvent == null) {
- nextEvent = sbEvent;
- timeUntilNext = timeUntilMillis;
- }
-
- GlStateManager.depthMask(false);
- GlStateManager.translate(0, 0, -2);
- Gui.drawRect(x, y, x+16, y+16, 0xcfffbf49);
- GlStateManager.translate(0, 0, 2);
- GlStateManager.depthMask(true);
- }
-
- Utils.drawItemStackWithText(sbEvent.stack, x, y, ""+(index+1));
-
- if(mouseX >= x && mouseX <= x+16) {
- if(mouseY >= y && mouseY <= y+16) {
- tooltipToDisplay = Utils.createList(sbEvent.display,
- EnumChatFormatting.GRAY+"Starts in: "+EnumChatFormatting.YELLOW+prettyTime(timeUntilMillis, false));
- if(sbEvent.lastsFor >= 0) {
- tooltipToDisplay.add( EnumChatFormatting.GRAY+"Lasts for: "+EnumChatFormatting.YELLOW+
- prettyTime(sbEvent.lastsFor, true));
- }
- if(sbEvent.desc != null) {
- tooltipToDisplay.add("");
- tooltipToDisplay.addAll(sbEvent.desc);
- }
- }
- }
-
- index++;
- }
- }
-
- //Special Events
- for(int i=0; i<21; i++) {
- int itemIndex = 10+i+(i/7)*2;
- ItemStack item = cc.getLowerChestInventory().getStackInSlot(itemIndex);
- if(item == null) continue;
-
- String eventId = getIdForDisplayName(item.getDisplayName());
-
- NBTTagCompound tag = item.getTagCompound();
- tag.setString("event_id", eventId);
- item.setTagCompound(tag);
-
- int x = guiLeft+89+17*(i%3);
- int y = guiTop+44+17*(i/3);
-
- if(eventFavourites.contains(eventId)) {
- GlStateManager.depthMask(false);
- GlStateManager.translate(0, 0, -2);
- Gui.drawRect(x, y, x+16, y+16, 0xcfffbf49);
- GlStateManager.translate(0, 0, 2);
- GlStateManager.depthMask(true);
- }
-
- Utils.drawItemStackWithText(item, x, y, ""+(i+1));
-
- if(mouseX >= x && mouseX <= x+16) {
- if(mouseY >= y && mouseY <= y+16) {
- tooltipToDisplay = item.getTooltip(Minecraft.getMinecraft().thePlayer, false);
- }
- }
- }
-
- if(nextEvent == null) {
- nextEvent = firstEvent;
- timeUntilNext = timeUntilFirst;
- }
-
- if(nextEvent != null) {
- String nextS = EnumChatFormatting.YELLOW+"Next: ";
- int nextSLen = fr.getStringWidth(nextS);
- fr.drawString(nextS, guiLeft+8, guiTop+6, -1, false);
-
- String until = " "+EnumChatFormatting.YELLOW+prettyTime(timeUntilNext, false);
- int untilLen = fr.getStringWidth(until);
-
- fr.drawString(until, guiLeft+xSize-8-untilLen, guiTop+6, -1, false);
-
- int eventTitleLen = xSize-16-untilLen-nextSLen;
- int displayWidth = fr.getStringWidth(nextEvent.display);
- int spaceLen = fr.getCharWidth(' ');
- if(displayWidth > eventTitleLen) {
- GL11.glEnable(GL11.GL_SCISSOR_TEST);
- GL11.glScissor((guiLeft+8+nextSLen)*scaledResolution.getScaleFactor(),
- 0,
- eventTitleLen*scaledResolution.getScaleFactor(),
- Minecraft.getMinecraft().displayHeight);
- fr.drawString(nextEvent.display + " " + nextEvent.display,
- guiLeft+8+nextSLen-(float)(currentTime/50.0 % (displayWidth+spaceLen)), guiTop+6, -1, false);
- GL11.glDisable(GL11.GL_SCISSOR_TEST);
- } else {
- fr.drawString(nextEvent.display, guiLeft+8+nextSLen, guiTop+6, -1, false);
- }
-
- if(mouseX > guiLeft && mouseX < guiLeft+168) {
- if(mouseY > guiTop && mouseY < guiTop+20) {
- tooltipToDisplay = Utils.createList(nextEvent.display,
- EnumChatFormatting.GRAY+"Starts in: "+EnumChatFormatting.YELLOW+prettyTime(timeUntilNext, false));
- if(nextEvent.lastsFor >= 0) {
- tooltipToDisplay.add( EnumChatFormatting.GRAY+"Lasts for: "+EnumChatFormatting.YELLOW+
- prettyTime(nextEvent.lastsFor, true));
- }
- if(nextEvent.desc != null) {
- tooltipToDisplay.add("");
- tooltipToDisplay.addAll(nextEvent.desc);
- }
- }
- }
- }
-
- GlStateManager.color(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(help);
- Utils.drawTexturedRect(guiLeft+xSize-18, guiTop+ySize+2, 16, 16, GL11.GL_LINEAR);
-
- if(mouseX >= guiLeft+xSize-18 && mouseX < guiLeft+xSize-2) {
- if(mouseY >= guiTop+ySize+2 && mouseY <= guiTop+ySize+18) {
- tooltipToDisplay = new ArrayList<>();
- tooltipToDisplay.add(EnumChatFormatting.AQUA+"NEU Calendar Help");
- tooltipToDisplay.add(EnumChatFormatting.YELLOW+"This calendar displays various skyblock events");
- tooltipToDisplay.add(EnumChatFormatting.YELLOW+"'Daily' events are events that happen frequently");
- tooltipToDisplay.add(EnumChatFormatting.YELLOW+"'Special' events are events that happen infrequently");
- tooltipToDisplay.add(EnumChatFormatting.YELLOW+"");
- tooltipToDisplay.add(EnumChatFormatting.YELLOW+"The eventbar at the top will also show in your inventory");
- tooltipToDisplay.add(EnumChatFormatting.YELLOW+"");
- tooltipToDisplay.add(EnumChatFormatting.YELLOW+"Press 'F' on an event to mark it as a favourite");
- tooltipToDisplay.add(EnumChatFormatting.YELLOW+"Favourited events will show over normal events");
- tooltipToDisplay.add(EnumChatFormatting.YELLOW+"Favourited events will also give a notification when it");
- tooltipToDisplay.add(EnumChatFormatting.YELLOW+"is about to start and when it does start");
- tooltipToDisplay.add(EnumChatFormatting.YELLOW+"");
- tooltipToDisplay.add(EnumChatFormatting.DARK_GRAY+"In order to show crop types for Jacob's Farming");
- tooltipToDisplay.add(EnumChatFormatting.DARK_GRAY+"contest, visit the full skyblock calendar and go all");
- tooltipToDisplay.add(EnumChatFormatting.DARK_GRAY+"the way to the end of the skyblock year");
- Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, fr);
- tooltipToDisplay = null;
- }
- }
-
- if(jfFavouriteSelect != null) {
- int arrowLen = fr.getStringWidth("> ");
- int selectSizeX = 0;
- int selectStringIndex=0;
- for(String s : jfFavouriteSelect) {
- int sWidth = fr.getStringWidth(s);
- if(selectStringIndex+1 == jfFavouriteSelectIndex) sWidth += arrowLen;
- if(sWidth > selectSizeX) {
- selectSizeX = sWidth;
- }
- selectStringIndex++;
- }
- selectSizeX += +10;
-
- GlStateManager.translate(0, 0, 19);
-
- Gui.drawRect(jfFavouriteSelectX+2, jfFavouriteSelectY+2, jfFavouriteSelectX+selectSizeX+2,
- jfFavouriteSelectY+18+jfFavouriteSelect.size()*10+2, 0xa0000000);
-
- GlStateManager.depthFunc(GL11.GL_LESS);
- GlStateManager.translate(0, 0, 1);
- Gui.drawRect(jfFavouriteSelectX+1, jfFavouriteSelectY+1, jfFavouriteSelectX+selectSizeX-1,
- jfFavouriteSelectY+18+jfFavouriteSelect.size()*10-1, 0xffc0c0c0);
- Gui.drawRect(jfFavouriteSelectX, jfFavouriteSelectY, jfFavouriteSelectX+selectSizeX-1,
- jfFavouriteSelectY+18+jfFavouriteSelect.size()*10-1, 0xfff0f0f0);
- Gui.drawRect(jfFavouriteSelectX, jfFavouriteSelectY, jfFavouriteSelectX+selectSizeX,
- jfFavouriteSelectY+18+jfFavouriteSelect.size()*10, 0xff909090);
- GlStateManager.depthFunc(GL11.GL_LEQUAL);
-
- String all = (NotEnoughUpdates.INSTANCE.config.hidden.eventFavourites.contains("jacob_farming")?
- EnumChatFormatting.DARK_GREEN:EnumChatFormatting.DARK_GRAY)+"All";
- if(jfFavouriteSelectIndex == 0) {
- fr.drawString(EnumChatFormatting.BLACK+"> "+all, jfFavouriteSelectX+5, jfFavouriteSelectY+5, 0xff000000);
- } else {
- fr.drawString(all, jfFavouriteSelectX+5, jfFavouriteSelectY+5, 0xff000000);
- }
-
- fr.drawString(EnumChatFormatting.BLACK+"> ", jfFavouriteSelectX+6,
- jfFavouriteSelectY+10*jfFavouriteSelectIndex+5, 0xff000000);
-
- selectStringIndex=0;
- for(String s : jfFavouriteSelect) {
- EnumChatFormatting colour = NotEnoughUpdates.INSTANCE.config.hidden.eventFavourites.contains("jacob_farming:"+s)
- ? EnumChatFormatting.DARK_GREEN : EnumChatFormatting.DARK_GRAY;
- s = (selectStringIndex+1 == jfFavouriteSelectIndex ? EnumChatFormatting.BLACK+"> " : "") + colour + s;
- fr.drawString(s, jfFavouriteSelectX+5, jfFavouriteSelectY+10*selectStringIndex+15, 0xff000000);
- selectStringIndex++;
- }
- GlStateManager.translate(0, 0, -20);
- } else if(tooltipToDisplay != null) {
- Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, fr);
- }
-
- GlStateManager.translate(0, 0, -10);
-
- }
-
- private String prettyTime(long millis, boolean trimmed) {
- long seconds = millis / 1000 % 60;
- long minutes = (millis / 1000 / 60) % 60;
- long hours = (millis / 1000 / 60 / 60) % 24;
- long days = (millis / 1000 / 60 / 60 / 24);
-
- String endsIn = "";
- if(millis < 0) {
- endsIn += "Now!";
- } else if(minutes == 0 && hours == 0 && days == 0) {
- endsIn += seconds + "s";
- } else if(hours==0 && days==0) {
- if(trimmed && seconds == 0) {
- endsIn += minutes + "m";
- } else {
- endsIn += minutes + "m" + seconds + "s";
- }
- } else if(days==0) {
- if(hours <= 6) {
- if(trimmed && seconds == 0) {
- if(minutes == 0) {
- endsIn += hours + "h";
- } else {
- endsIn += hours + "h" + minutes + "m";
- }
- } else {
- endsIn += hours + "h" + minutes + "m" + seconds + "s";
- }
- } else {
- endsIn += hours + "h";
- }
- } else {
- endsIn += days + "d" + hours + "h";
- }
-
- return endsIn;
- }
-
- Shader blurShaderHorz = null;
- Framebuffer blurOutputHorz = null;
- Shader blurShaderVert = null;
- Framebuffer blurOutputVert = null;
-
- /**
- * Creates a projection matrix that projects from our coordinate space [0->width; 0->height] to OpenGL coordinate
- * space [-1 -> 1; 1 -> -1] (Note: flipped y-axis).
- *
- * This is so that we can render to and from the framebuffer in a way that is familiar to us, instead of needing to
- * apply scales and translations manually.
- */
- private Matrix4f createProjectionMatrix(int width, int height) {
- Matrix4f projMatrix = new Matrix4f();
- projMatrix.setIdentity();
- projMatrix.m00 = 2.0F / (float)width;
- projMatrix.m11 = 2.0F / (float)(-height);
- projMatrix.m22 = -0.0020001999F;
- projMatrix.m33 = 1.0F;
- projMatrix.m03 = -1.0F;
- projMatrix.m13 = 1.0F;
- projMatrix.m23 = -1.0001999F;
- return projMatrix;
- }
+import static io.github.moulberry.notenoughupdates.util.GuiTextures.help;
+public class CalendarOverlay {
+ private static final ResourceLocation BACKGROUND = new ResourceLocation("notenoughupdates:calendar/background.png");
+ private static final ResourceLocation DISPLAYBAR = new ResourceLocation("notenoughupdates:calendar/displaybar.png");
+ private static final ResourceLocation TOAST = new ResourceLocation("notenoughupdates:calendar/toast.png");
+
+ private static JsonObject farmingEventTypes = null;
+
+ private static boolean enabled = false;
+
+ public static void setEnabled(boolean enabled) {
+ CalendarOverlay.enabled = enabled;
+ }
+
+ public static boolean isEnabled() {
+ return enabled;
+ }
+
+ private int guiLeft = -1;
+ private int guiTop = -1;
+ private int xSize = 168;
+ private int ySize = 170;
+
+ private static class SBEvent {
+ String id;
+ String display;
+ ItemStack stack;
+ List<String> desc;
+ long lastsFor;
+
+ public SBEvent(String id, String display, ItemStack stack, List<String> desc) {
+ this(id, display, stack, desc, -1);
+ }
+
+ public SBEvent(String id, String display, ItemStack stack, List<String> desc, long lastsFor) {
+ this.id = id;
+ this.display = display;
+ this.stack = stack;
+ this.desc = desc;
+ this.lastsFor = lastsFor;
+ }
+ }
+
+ private int jingleIndex = -1;
+
+ private final TreeMap<Long, Set<SBEvent>> eventMap = new TreeMap<>();
+ private List<String> jfFavouriteSelect = null;
+ private int jfFavouriteSelectIndex = 0;
+ private int jfFavouriteSelectX = 0;
+ private int jfFavouriteSelectY = 0;
+
+ private boolean drawTimerForeground = false;
+
+ private static long spookyStart = 0;
+
+ private static final long SECOND = 1000;
+ private static final long MINUTE = SECOND * 60;
+ private static final long HOUR = MINUTE * 60;
+ private static final long DAY = HOUR * 24;
+
+ private static final long DA_OFFSET = 1000 * 60 * 55;
+ private static final long JF_OFFSET = 1000 * 60 * 15;
+
+ private static final ItemStack DA_STACK;
+ private static final ItemStack JF_STACK;
+
+ static {
+ NBTTagCompound tag = new NBTTagCompound();
+ tag.setString("event_id", "dark_auction");
+ //tag.setTag("ench", new NBTTagList());
+
+ DA_STACK = new ItemStack(Items.netherbrick);
+ DA_STACK.setTagCompound(tag);
+
+ tag.setString("event_id", "jacob_farming");
+ JF_STACK = new ItemStack(Items.wheat);
+ JF_STACK.setTagCompound(tag);
+ }
+
+ public long getTimeOffset(String time) {
+ long offset = 0;
+
+ StringBuilder numS = new StringBuilder();
+ for (int timeIndex = 0; timeIndex < time.length(); timeIndex++) {
+ char c = time.charAt(timeIndex);
+
+ if (c >= '0' && c <= '9') {
+ numS.append(c);
+ } else {
+ try {
+ int num = Integer.parseInt(numS.toString());
+ switch (c) {
+ case 'd':
+ offset += num * DAY;
+ continue;
+ case 'h':
+ offset += num * HOUR;
+ continue;
+ case 'm':
+ offset += num * MINUTE;
+ continue;
+ case 's':
+ offset += num * SECOND;
+ continue;
+ }
+ } catch (Exception ignored) {
+ }
+ numS = new StringBuilder();
+ }
+ }
+
+ return offset;
+ }
+
+ private static final Pattern CALENDAR_PATTERN = Pattern.compile("([A-Za-z ]+), Year ([0-9]+)");
+ private static final long SKYBLOCK_START = 1559829300000L; //Day 0, Year 0
+
+ @SubscribeEvent
+ public void tick(TickEvent.ClientTickEvent event) {
+ if (event.phase != TickEvent.Phase.START) return;
+
+ if (jingleIndex == 0) {
+ if (NotEnoughUpdates.INSTANCE.config.calendar.eventNotificationSounds) {
+ Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(
+ new ResourceLocation("notenoughupdates:calendar_notif_jingle")
+ ));
+ Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(
+ new ResourceLocation("notenoughupdates:calendar_notif_in")
+ ));
+ }
+ jingleIndex = -15 * 20;
+ } else if (jingleIndex >= 1) {
+ if (NotEnoughUpdates.INSTANCE.config.calendar.eventNotificationSounds) {
+ Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(
+ new ResourceLocation("notenoughupdates:calendar_notif_in")
+ ));
+ }
+ jingleIndex = -15 * 20;
+ } else if (jingleIndex < -1) {
+ jingleIndex++;
+ }
+ if (jingleIndex == -20 * 6 - 10) {
+ if (NotEnoughUpdates.INSTANCE.config.calendar.eventNotificationSounds) {
+ Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(
+ new ResourceLocation("notenoughupdates:calendar_notif_out")
+ ));
+ }
+ }
+
+ if (farmingEventTypes == null) {
+ farmingEventTypes = NotEnoughUpdates.INSTANCE.manager.getJsonFromFile(new File(
+ NotEnoughUpdates.INSTANCE.manager.configLocation,
+ "farmingEventTypes.json"
+ ));
+ if (farmingEventTypes == null) {
+ farmingEventTypes = new JsonObject();
+ }
+ }
+
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) {
+ jfFavouriteSelect = null;
+ if (eventMap.isEmpty() || eventMap.size() <= 20) {
+ long currentTime = System.currentTimeMillis();
+ long floorHour = (currentTime / HOUR) * HOUR;
+ for (int i = 0; i < 15; i++) {
+ long daEvent = floorHour + i * HOUR + DA_OFFSET;
+ long jfEvent = floorHour + i * HOUR + JF_OFFSET;
+
+ if (daEvent > currentTime) {
+ eventMap.computeIfAbsent(daEvent, k -> new HashSet<>()).add(new SBEvent("dark_auction",
+ EnumChatFormatting.DARK_PURPLE + "Dark Auction", DA_STACK, null, MINUTE * 5
+ ));
+ }
+ if (jfEvent > currentTime) {
+ SBEvent jf = new SBEvent("jacob_farming",
+ EnumChatFormatting.YELLOW + "Jacob's Farming Contest", JF_STACK, null, MINUTE * 20
+ );
+ if (farmingEventTypes != null && farmingEventTypes.has("" + jfEvent) &&
+ farmingEventTypes.get("" + jfEvent).isJsonArray()) {
+ JsonArray arr = farmingEventTypes.get("" + jfEvent).getAsJsonArray();
+ jf.desc = new ArrayList<>();
+ for (JsonElement e : arr) {
+ jf.desc.add(EnumChatFormatting.YELLOW + "\u25CB " + e.getAsString());
+ jf.id += ":" + e.getAsString();
+ }
+ }
+ eventMap.computeIfAbsent(jfEvent, k -> new HashSet<>()).add(jf);
+ }
+ }
+ }
+ return;
+ }
+
+ GuiChest eventGui = (GuiChest) Minecraft.getMinecraft().currentScreen;
+ ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
+ String containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText();
+
+ Matcher matcher = CALENDAR_PATTERN.matcher(Utils.cleanColour(containerName));
+ if (farmingEventTypes != null && matcher.matches()) {
+ try {
+ int year = Integer.parseInt(matcher.group(2));
+ int skyblockDays = year * 12 * 31;
+
+ String month = matcher.group(1);
+ boolean spring = month.endsWith("Spring");
+ boolean summer = month.endsWith("Summer");
+ boolean autumn = month.endsWith("Autumn");
+ boolean winter = month.endsWith("Winter");
+ if (spring || summer || autumn || winter) {
+ if (spring) {
+ skyblockDays += 1 * 31;
+ } else if (summer) {
+ skyblockDays += 4 * 31;
+ } else if (autumn) {
+ skyblockDays += 7 * 31;
+ } else {
+ skyblockDays += 10 * 31;
+ }
+ if (month.startsWith("Early")) {
+ skyblockDays -= 31;
+ } else if (month.startsWith("Late")) {
+ skyblockDays += 31;
+ }
+
+ long start = SKYBLOCK_START + skyblockDays * 20 * MINUTE;
+
+ boolean changed = false;
+ for (int i = 0; i < 31; i++) {
+ ItemStack item = cc.getLowerChestInventory().getStackInSlot(1 + (i % 7) + (i / 7) * 9);
+
+ JsonArray array = new JsonArray();
+ if (item.getTagCompound() != null) {
+ NBTTagCompound tag = item.getTagCompound();
+
+ if (tag.hasKey("display", 10)) {
+ NBTTagCompound display = tag.getCompoundTag("display");
+ if (display.hasKey("Lore", 9)) {
+ NBTTagList list = display.getTagList("Lore", 8);
+ for (int j = 0; j < list.tagCount(); j++) {
+ String line = list.getStringTagAt(j);
+ if (line.startsWith(EnumChatFormatting.YELLOW + "\u25CB")) {
+ array.add(new JsonPrimitive(Utils.cleanColour(line.substring(4))));
+ }
+ }
+ }
+ }
+ }
+ if (array.size() == 3) {
+ String prop = String.valueOf(start + i * 20 * MINUTE);
+ if (!farmingEventTypes.has(prop) || !farmingEventTypes.get(prop).isJsonArray() ||
+ farmingEventTypes.get(prop).getAsJsonArray().equals(array)) {
+ changed = true;
+ }
+ farmingEventTypes.add(prop, array);
+ }
+ }
+ if (changed) {
+ File f = new File(
+ NotEnoughUpdates.INSTANCE.manager.configLocation,
+ "farmingEventTypes.json"
+ );
+ NotEnoughUpdates.INSTANCE.manager.writeJson(farmingEventTypes, f);
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ if (!enabled) {
+ jfFavouriteSelect = null;
+ if (eventMap.isEmpty() || eventMap.size() <= 20) {
+ long currentTime = System.currentTimeMillis();
+ long floorHour = (currentTime / HOUR) * HOUR;
+ for (int i = 0; i < 15; i++) {
+ long daEvent = floorHour + i * HOUR + DA_OFFSET;
+ long jfEvent = floorHour + i * HOUR + JF_OFFSET;
+
+ if (daEvent > currentTime) {
+ eventMap.computeIfAbsent(daEvent, k -> new HashSet<>()).add(new SBEvent("dark_auction",
+ EnumChatFormatting.DARK_PURPLE + "Dark Auction", DA_STACK, null, MINUTE * 5
+ ));
+ }
+ if (jfEvent > currentTime) {
+ SBEvent jf = new SBEvent("jacob_farming",
+ EnumChatFormatting.YELLOW + "Jacob's Farming Contest", JF_STACK, null, MINUTE * 20
+ );
+ if (farmingEventTypes != null && farmingEventTypes.has("" + jfEvent) &&
+ farmingEventTypes.get("" + jfEvent).isJsonArray()) {
+ JsonArray arr = farmingEventTypes.get("" + jfEvent).getAsJsonArray();
+ jf.desc = new ArrayList<>();
+ for (JsonElement e : arr) {
+ jf.desc.add(EnumChatFormatting.YELLOW + "\u25CB " + e.getAsString());
+ jf.id += ":" + e.getAsString();
+ }
+ }
+ eventMap.computeIfAbsent(jfEvent, k -> new HashSet<>()).add(jf);
+ }
+ }
+ }
+ return;
+ }
+
+ if (!containerName.trim().equals("Calendar and Events")) {
+ setEnabled(false);
+ return;
+ }
+
+ eventMap.clear();
+
+ long currentTime = System.currentTimeMillis();
+ long floorHour = (currentTime / HOUR) * HOUR;
+ for (int i = 0; i < 15; i++) {
+ long daEvent = floorHour + i * HOUR + DA_OFFSET;
+ long jfEvent = floorHour + i * HOUR + JF_OFFSET;
+
+ if (daEvent > currentTime) {
+ eventMap.computeIfAbsent(daEvent, k -> new HashSet<>()).add(new SBEvent("dark_auction",
+ EnumChatFormatting.DARK_PURPLE + "Dark Auction", DA_STACK, null, MINUTE * 5
+ ));
+ }
+ if (jfEvent > currentTime) {
+ SBEvent jf = new SBEvent("jacob_farming",
+ EnumChatFormatting.YELLOW + "Jacob's Farming Contest", JF_STACK, null, MINUTE * 20
+ );
+ if (farmingEventTypes != null && farmingEventTypes.has("" + jfEvent) &&
+ farmingEventTypes.get("" + jfEvent).isJsonArray()) {
+ JsonArray arr = farmingEventTypes.get("" + jfEvent).getAsJsonArray();
+ jf.desc = new ArrayList<>();
+ for (JsonElement e : arr) {
+ jf.desc.add(EnumChatFormatting.YELLOW + "\u25CB " + e.getAsString());
+ jf.id += ":" + e.getAsString();
+ }
+ }
+ eventMap.computeIfAbsent(jfEvent, k -> new HashSet<>()).add(jf);
+ }
+ }
+
+ String lastsForText = EnumChatFormatting.GRAY + "Event lasts for " + EnumChatFormatting.YELLOW;
+ String startsInText = EnumChatFormatting.GRAY + "Starts in: " + EnumChatFormatting.YELLOW;
+ for (int i = 0; i < 21; i++) {
+ int itemIndex = 10 + i + (i / 7) * 2;
+ ItemStack item = cc.getLowerChestInventory().getStackInSlot(itemIndex);
+
+ if (item != null && item.getTagCompound() != null) {
+ NBTTagCompound tag = item.getTagCompound();
+
+ if (tag.hasKey("display", 10)) {
+ NBTTagCompound display = tag.getCompoundTag("display");
+ if (display.hasKey("Lore", 9)) {
+ NBTTagList list = display.getTagList("Lore", 8);
+
+ String first = list.getStringTagAt(0);
+ if (first.startsWith(startsInText)) {
+ String time = Utils.cleanColour(first.substring(startsInText.length()));
+ long eventTime = currentTime + getTimeOffset(time);
+
+ long lastsFor = -1;
+
+ List<String> desc = new ArrayList<>();
+ boolean foundBreak = false;
+ for (int index = 1; index < list.tagCount(); index++) {
+ String line = list.getStringTagAt(index);
+ if (foundBreak) {
+ desc.add(line);
+ } else {
+ if (line.startsWith(lastsForText)) {
+ String lastsForS = Utils.cleanColour(line.substring(lastsForText.length()));
+ lastsFor = getTimeOffset(lastsForS);
+ }
+ if (Utils.cleanColour(line).trim().length() == 0) {
+ foundBreak = true;
+ }
+ }
+ }
+ eventMap.computeIfAbsent(eventTime, k -> new HashSet<>()).add(new SBEvent(
+ getIdForDisplayName(item.getDisplayName()), item.getDisplayName(),
+ item, desc, lastsFor
+ ));
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private static String getIdForDisplayName(String displayName) {
+ return Utils.cleanColour(displayName)
+ .toLowerCase()
+ .replaceAll("[0-9]+th", "")
+ .replaceAll("[0-9]+nd", "")
+ .replaceAll("[0-9]+rd", "")
+ .replaceAll("[0-9]+st", "")
+ .replaceAll("[^a-z ]", "")
+ .trim()
+ .replace(" ", "_");
+ }
+
+ @SubscribeEvent
+ public void onGuiScreenMouse(GuiScreenEvent.MouseInputEvent.Pre event) {
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ int width = scaledResolution.getScaledWidth();
+ int height = scaledResolution.getScaledHeight();
+ int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
+ int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
+
+ if (!enabled) {
+ if (Mouse.getEventButtonState() && NotEnoughUpdates.INSTANCE.config.calendar.showEventTimerInInventory &&
+ Minecraft.getMinecraft().currentScreen instanceof GuiContainer) {
+ xSize = 168;
+ ySize = 20;
+
+ guiLeft = (width - xSize) / 2;
+ guiTop = 5;
+
+ if (mouseX >= guiLeft && mouseX <= guiLeft + xSize) {
+ if (mouseY >= guiTop && mouseY <= guiTop + ySize) {
+ ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/neucalendar");
+ }
+ }
+ }
+
+ return;
+ }
+
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) {
+ return;
+ }
+
+ GuiChest eventGui = (GuiChest) Minecraft.getMinecraft().currentScreen;
+ ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
+ String containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText();
+ if (!containerName.trim().equals("Calendar and Events")) {
+ setEnabled(false);
+ return;
+ }
+
+ event.setCanceled(true);
+
+ xSize = 168;
+ ySize = 170;
+ guiLeft = (width - xSize) / 2;
+ guiTop = (height - ySize) / 2;
+
+ if (Mouse.getEventButtonState()) {
+ if (jfFavouriteSelect != null) {
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+ int arrowLen = fr.getStringWidth("> ");
+ int selectSizeX = 0;
+ int selectStringIndex = 0;
+ for (String s : jfFavouriteSelect) {
+ int sWidth = fr.getStringWidth(s);
+ if (selectStringIndex + 1 == jfFavouriteSelectIndex) sWidth += arrowLen;
+ if (sWidth > selectSizeX) {
+ selectSizeX = sWidth;
+ }
+ selectStringIndex++;
+ }
+ selectSizeX += +10;
+
+ if (mouseX > jfFavouriteSelectX && mouseX < jfFavouriteSelectX + selectSizeX &&
+ mouseY > jfFavouriteSelectY && mouseY < jfFavouriteSelectY + 18 + jfFavouriteSelect.size() * 10) {
+ jfFavouriteSelectIndex = Math.max(0, (mouseY - jfFavouriteSelectY - 5) / 10);
+
+ List<String> eventFavourites = NotEnoughUpdates.INSTANCE.config.hidden.eventFavourites;
+ String id = null;
+ if (jfFavouriteSelectIndex == 0) {
+ id = "jacob_farming";
+ } else if (jfFavouriteSelectIndex - 1 < jfFavouriteSelect.size()) {
+ id = "jacob_farming:" + jfFavouriteSelect.get(jfFavouriteSelectIndex - 1);
+ }
+ if (id != null) {
+ if (eventFavourites.contains(id)) {
+ eventFavourites.remove(id);
+ } else {
+ eventFavourites.add(id);
+ }
+ }
+ } else {
+ jfFavouriteSelect = null;
+ }
+ }
+ if (mouseY >= guiTop + 26 && mouseY <= guiTop + 26 + 141) {
+ if (mouseX >= guiLeft + 151 && mouseX <= guiLeft + 151 + 14) {
+ if (mouseY <= guiTop + 26 + 70) {
+ Minecraft.getMinecraft().playerController.windowClick(cc.windowId,
+ 50, 2, 3, Minecraft.getMinecraft().thePlayer
+ );
+ } else {
+ Minecraft.getMinecraft().playerController.windowClick(cc.windowId,
+ 45, 2, 3, Minecraft.getMinecraft().thePlayer
+ );
+ }
+ }
+ }
+ }
+ }
+
+ @SubscribeEvent
+ public void onGuiScreenKeyboard(GuiScreenEvent.KeyboardInputEvent.Pre event) {
+ if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
+ if (jfFavouriteSelect != null) {
+ jfFavouriteSelect = null;
+ event.setCanceled(true);
+ }
+ } else {
+ if (!enabled) {
+ return;
+ }
+
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) {
+ return;
+ }
+
+ GuiChest eventGui = (GuiChest) Minecraft.getMinecraft().currentScreen;
+ ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
+ String containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText();
+ if (!containerName.trim().equals("Calendar and Events")) {
+ setEnabled(false);
+ return;
+ }
+
+ event.setCanceled(true);
+ xSize = 168;
+ ySize = 170;
+
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ int width = scaledResolution.getScaledWidth();
+ int height = scaledResolution.getScaledHeight();
+ int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
+ int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
+ guiLeft = (width - xSize) / 2;
+ guiTop = (height - ySize) / 2;
+
+ int keyPressed = Keyboard.getEventKey() == 0 ? Keyboard.getEventCharacter() + 256 : Keyboard.getEventKey();
+ if (Keyboard.getEventKeyState()) {
+ if (jfFavouriteSelect != null) {
+ if (keyPressed == Keyboard.KEY_DOWN) {
+ jfFavouriteSelectIndex++;
+ jfFavouriteSelectIndex %= jfFavouriteSelect.size() + 1;
+ } else if (keyPressed == Keyboard.KEY_UP) {
+ jfFavouriteSelectIndex--;
+ if (jfFavouriteSelectIndex < 0) jfFavouriteSelectIndex = jfFavouriteSelect.size();
+ } else if (keyPressed == Keyboard.KEY_RIGHT || keyPressed == Keyboard.KEY_RETURN) {
+ List<String> eventFavourites = NotEnoughUpdates.INSTANCE.config.hidden.eventFavourites;
+ String id = null;
+ if (jfFavouriteSelectIndex == 0) {
+ id = "jacob_farming";
+ } else if (jfFavouriteSelectIndex - 1 < jfFavouriteSelect.size()) {
+ id = "jacob_farming:" + jfFavouriteSelect.get(jfFavouriteSelectIndex - 1);
+ }
+ if (id != null) {
+ if (eventFavourites.contains(id)) {
+ eventFavourites.remove(id);
+ } else {
+ eventFavourites.add(id);
+ }
+ }
+ } else if (keyPressed == Keyboard.KEY_LEFT ||
+ keyPressed == NotEnoughUpdates.INSTANCE.manager.keybindFavourite.getKeyCode()) {
+ jfFavouriteSelect = null;
+ }
+ } else if (keyPressed == NotEnoughUpdates.INSTANCE.manager.keybindFavourite.getKeyCode()) {
+ String id = null;
+
+ //Daily Events
+ int index = 0;
+ out:
+ for (Map.Entry<Long, Set<SBEvent>> sbEvents : eventMap.entrySet()) {
+ for (SBEvent sbEvent : sbEvents.getValue()) {
+ int x = guiLeft + 29 + 17 * (index % 3);
+ int y = guiTop + 44 + 17 * (index / 3);
+
+ if (mouseX >= x && mouseX <= x + 16) {
+ if (mouseY >= y && mouseY <= y + 16) {
+ id = sbEvent.id;
+ }
+ }
+
+ if (++index >= 21) break out;
+ }
+ }
+
+ //Special Events
+ for (int i = 0; i < 21; i++) {
+ int itemIndex = 10 + i + (i / 7) * 2;
+ ItemStack item = cc.getLowerChestInventory().getStackInSlot(itemIndex);
+ if (item == null) continue;
+
+ int x = guiLeft + 89 + 17 * (i % 3);
+ int y = guiTop + 44 + 17 * (i / 3);
+
+ if (mouseX >= x && mouseX <= x + 16) {
+ if (mouseY >= y && mouseY <= y + 16) {
+ id = getIdForDisplayName(item.getDisplayName());
+ }
+ }
+ }
+
+ if (id != null) {
+ String[] split = id.split(":");
+ if (split.length > 1 && split[0].equals("jacob_farming")) {
+ jfFavouriteSelect = new ArrayList<>();
+ for (int i = 1; i < split.length; i++) {
+ jfFavouriteSelect.add(split[i]);
+ }
+ jfFavouriteSelectIndex = 0;
+ jfFavouriteSelectX = mouseX;
+ jfFavouriteSelectY = mouseY;
+ } else {
+ List<String> eventFavourites = NotEnoughUpdates.INSTANCE.config.hidden.eventFavourites;
+ if (eventFavourites.contains(id)) {
+ eventFavourites.remove(id);
+ } else {
+ eventFavourites.add(id);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ @SubscribeEvent(priority = EventPriority.LOW)
+ public void onGuiDraw(RenderGameOverlayEvent.Post event) {
+ if (NotEnoughUpdates.INSTANCE.config.calendar.eventNotifications &&
+ event.type == RenderGameOverlayEvent.ElementType.ALL) {
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(0, 0, 10);
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer) &&
+ NotEnoughUpdates.INSTANCE.isOnSkyblock()) {
+ long currentTime = System.currentTimeMillis();
+
+ long timeUntilNext = 0;
+ SBEvent nextEvent = null;
+ long timeUntilFirst = 0;
+ SBEvent firstEvent = null;
+
+ List<String> eventFavourites = NotEnoughUpdates.INSTANCE.config.hidden.eventFavourites;
+
+ //Daily Events
+ out:
+ for (Map.Entry<Long, Set<SBEvent>> sbEvents : eventMap.entrySet()) {
+ for (SBEvent sbEvent : sbEvents.getValue()) {
+ long timeUntilMillis = sbEvents.getKey() - currentTime;
+
+ if (timeUntilMillis < -10 * SECOND) {
+ continue;
+ }
+
+ if (firstEvent == null) {
+ firstEvent = sbEvent;
+ timeUntilFirst = timeUntilMillis;
+ }
+
+ String[] split = sbEvent.id.split(":");
+ boolean containsId = false;
+ for (int i = 1; i < split.length; i++) {
+ if (eventFavourites.contains(split[0] + ":" + split[i])) {
+ containsId = true;
+ break;
+ }
+ }
+ if (eventFavourites.isEmpty() || eventFavourites.contains(split[0]) || containsId) {
+ nextEvent = sbEvent;
+ timeUntilNext = timeUntilMillis;
+ break out;
+ }
+ }
+ }
+
+ if (nextEvent != null) {
+ renderToast(nextEvent, timeUntilNext);
+ }
+ }
+ GlStateManager.translate(0, 0, -10);
+ GlStateManager.popMatrix();
+ }
+ }
+
+ public boolean renderToast(SBEvent event, long timeUntil) {
+ if (!NotEnoughUpdates.INSTANCE.config.calendar.eventNotifications) {
+ return false;
+ }
+
+ long currentTime = System.currentTimeMillis();
+ if (currentTime - spookyStart > 0 && currentTime - spookyStart < HOUR &&
+ NotEnoughUpdates.INSTANCE.config.calendar.spookyNightNotification) {
+ long delta = (currentTime - SKYBLOCK_START) % (20 * MINUTE) - 19 * 50 * SECOND - 10 * SECOND;
+ if (delta < 500 && delta > -8500) {
+ event = new SBEvent("spooky_festival_7pm", "Spooky Festival 7pm", new ItemStack(Items.bone), null);
+ timeUntil = delta;
+ }
+ }
+
+ if (event.id.equals("dark_auction")) {
+ timeUntil -= 30 * 1000;
+ }
+
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ int width = scaledResolution.getScaledWidth();
+ int height = scaledResolution.getScaledHeight();
+
+ int ySize = 32;
+ int xSize = 160;
+ int guiLeft = (width - xSize) / 2;
+ int guiTop = 5;
+
+ boolean preNotification = false;
+ long preNotificationTime = SECOND * NotEnoughUpdates.INSTANCE.config.calendar.startingSoonTime;
+
+ if (preNotificationTime > 500 && timeUntil > 500) {
+ timeUntil = timeUntil - preNotificationTime;
+ preNotification = true;
+ }
+
+ if (timeUntil < 500 && timeUntil > -8500) {
+ if (jingleIndex == -1) {
+ if (preNotification) {
+ jingleIndex = 1;
+ } else {
+ jingleIndex = 0;
+ }
+ }
+
+ float offset;
+ float factor = 0;
+ if (timeUntil > 0) {
+ factor = (timeUntil / 500f);
+ } else if (timeUntil < -8000) {
+ factor = -((timeUntil + 8000) / 500f);
+ }
+ factor = (float) (1.06f / (1 + Math.exp(-7 * (factor - 0.5f))) - 0.03f);
+ offset = -(ySize + 5) * factor;
+ float y = guiTop + offset;
+
+ GlStateManager.color(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(TOAST);
+ Utils.drawTexturedRect(guiLeft, y, xSize, ySize, GL11.GL_NEAREST);
+
+ GlStateManager.translate(0, y, 0);
+ Utils.drawItemStack(event.stack, guiLeft + 6, 8);
+ GlStateManager.translate(0, -y, 0);
+
+ if (preNotification) {
+ String starting = EnumChatFormatting.YELLOW + "Event Starting in " + prettyTime(preNotificationTime, true) +
+ "!";
+ int startingWidth = fr.getStringWidth(starting);
+ fr.drawString(starting, Math.max(guiLeft + 23, width / 2f - startingWidth / 2f), y + 7, -1, false);
+ } else {
+ Utils.drawStringCentered(EnumChatFormatting.YELLOW + "Event Starting Now!", fr, width / 2, y + 11, false, -1);
+ }
+
+ int displayWidth = fr.getStringWidth(event.display);
+ fr.drawString(event.display, Math.max(guiLeft + 23, width / 2f - displayWidth / 2f), y + 17, -1, false);
+
+ return true;
+ }
+ return false;
+ }
+
+ @SubscribeEvent
+ public void onGuiScreenDrawTimer(GuiScreenEvent.BackgroundDrawnEvent event) {
+ if (!drawTimerForeground) {
+ drawTimer();
+ }
+ GlStateManager.color(1, 1, 1, 1);
+ GlStateManager.enableBlend();
+ }
+
+ @SubscribeEvent
+ public void onGuiScreenDrawTimer(GuiScreenEvent.DrawScreenEvent.Post event) {
+ if (drawTimerForeground) {
+ drawTimer();
+ }
+ }
+
+ public void drawTimer() {
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(0, 0, 10);
+ if (Minecraft.getMinecraft().currentScreen instanceof GuiContainer && NotEnoughUpdates.INSTANCE.isOnSkyblock()) {
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ int width = scaledResolution.getScaledWidth();
+ int height = scaledResolution.getScaledHeight();
+ int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
+ int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
+ long currentTime = System.currentTimeMillis();
+
+ xSize = 168;
+ ySize = 20;
+
+ long timeUntilNext = 0;
+ SBEvent nextEvent = null;
+ long timeUntilFirst = 0;
+ SBEvent firstEvent = null;
+ List<SBEvent> nextFavourites = new ArrayList<>();
+ List<Long> nextFavouritesTime = new ArrayList<>();
+ long timeUntilMajor = 0;
+ SBEvent nextMajorEvent = null;
+
+ List<String> eventFavourites = NotEnoughUpdates.INSTANCE.config.hidden.eventFavourites;
+
+ guiLeft = (width - xSize) / 2;
+ guiTop = 5;
+
+ //Daily Events
+ out:
+ for (Map.Entry<Long, Set<SBEvent>> sbEvents : eventMap.entrySet()) {
+ for (SBEvent sbEvent : sbEvents.getValue()) {
+ long timeUntilMillis = sbEvents.getKey() - currentTime;
+
+ if (timeUntilMillis < -10 * SECOND) {
+ continue;
+ }
+
+ if (sbEvent.id.equals("spooky_festival")) {
+ if (sbEvents.getKey() > currentTime - HOUR && (sbEvents.getKey() < spookyStart || spookyStart == 0)) {
+ spookyStart = sbEvents.getKey();
+ }
+ }
+
+ if (nextMajorEvent == null && !sbEvent.id.split(":")[0].equals("jacob_farming") &&
+ !sbEvent.id.equals("dark_auction")) {
+ nextMajorEvent = sbEvent;
+ timeUntilMajor = timeUntilMillis;
+ }
+
+ if (firstEvent == null) {
+ firstEvent = sbEvent;
+ timeUntilFirst = timeUntilMillis;
+ }
+
+ String[] split = sbEvent.id.split(":");
+ boolean containsId = false;
+ for (int i = 1; i < split.length; i++) {
+ if (eventFavourites.contains(split[0] + ":" + split[i])) {
+ containsId = true;
+ break;
+ }
+ }
+ if (eventFavourites.isEmpty() || eventFavourites.contains(split[0]) || containsId) {
+ if (nextEvent == null) {
+ nextEvent = sbEvent;
+ timeUntilNext = timeUntilMillis;
+ }
+ if (nextFavourites.size() < 3) {
+ nextFavourites.add(sbEvent);
+ nextFavouritesTime.add(timeUntilMillis);
+ }
+ }
+
+ if (nextFavourites.size() >= 3 && nextMajorEvent != null) {
+ break out;
+ }
+ }
+ }
+
+ if (nextEvent == null && firstEvent != null) {
+ String[] split = firstEvent.id.split(":");
+ if (eventFavourites.contains(split[0])) {
+ nextEvent = firstEvent;
+ timeUntilNext = timeUntilFirst;
+ }
+ }
+
+ if (nextEvent != null) {
+ GlStateManager.translate(0, 0, 50);
+ boolean toastRendered = renderToast(nextEvent, timeUntilNext);
+ GlStateManager.translate(0, 0, -50);
+ if (!toastRendered && !enabled && NotEnoughUpdates.INSTANCE.config.calendar.showEventTimerInInventory) {
+ List<String> tooltipToDisplay = null;
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ GlStateManager.disableFog();
+ GlStateManager.disableLighting();
+ GlStateManager.disableColorMaterial();
+
+ renderBlurredBackground(10, width, height, guiLeft + 3, guiTop + 3, xSize - 6, ySize - 6);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(DISPLAYBAR);
+ Utils.drawTexturedRect(guiLeft, guiTop, xSize, 20, GL11.GL_NEAREST);
+
+ String nextS = EnumChatFormatting.YELLOW + "Next: ";
+ int nextSLen = fr.getStringWidth(nextS);
+ fr.drawString(nextS, guiLeft + 8, guiTop + 6, -1, false);
+
+ String until = " " + EnumChatFormatting.YELLOW + prettyTime(timeUntilNext, false);
+ int untilLen = fr.getStringWidth(until);
+
+ fr.drawString(until, guiLeft + xSize - 8 - untilLen, guiTop + 6, -1, false);
+
+ int eventTitleLen = xSize - 16 - untilLen - nextSLen;
+ int displayWidth = fr.getStringWidth(nextEvent.display);
+ int spaceLen = fr.getCharWidth(' ');
+ if (displayWidth > eventTitleLen) {
+ GL11.glEnable(GL11.GL_SCISSOR_TEST);
+ GL11.glScissor(
+ (guiLeft + 8 + nextSLen) * scaledResolution.getScaleFactor(),
+ 0,
+ eventTitleLen * scaledResolution.getScaleFactor(),
+ Minecraft.getMinecraft().displayHeight
+ );
+ fr.drawString(nextEvent.display + " " + nextEvent.display,
+ guiLeft + 8 + nextSLen - (float) (currentTime / 50.0 % (displayWidth + spaceLen)), guiTop + 6, -1, false
+ );
+ GL11.glDisable(GL11.GL_SCISSOR_TEST);
+ } else {
+ if (guiLeft + xSize - 8 - untilLen > (width + displayWidth) / 2) {
+ Utils.drawStringCentered(nextEvent.display, fr, width / 2f, guiTop + 10, false, -1);
+ } else {
+ fr.drawString(nextEvent.display, guiLeft + 8 + nextSLen, guiTop + 6, -1, false);
+ }
+ }
+
+ if (mouseX > guiLeft && mouseX < guiLeft + 168) {
+ if (mouseY > guiTop && mouseY < guiTop + 20) {
+ tooltipToDisplay = new ArrayList<>();
+ for (int i = 0; i < nextFavourites.size(); i++) {
+ SBEvent sbEvent = nextFavourites.get(i);
+ long timeUntil = nextFavouritesTime.get(i);
+
+ tooltipToDisplay.add(sbEvent.display);
+ tooltipToDisplay.add(
+ EnumChatFormatting.GRAY + "Starts in: " + EnumChatFormatting.YELLOW + prettyTime(timeUntil, false));
+ if (sbEvent.lastsFor >= 0) {
+ tooltipToDisplay.add(EnumChatFormatting.GRAY + "Lasts for: " + EnumChatFormatting.YELLOW +
+ prettyTime(sbEvent.lastsFor, true));
+ }
+ if (sbEvent.id.split(":")[0].equals("jacob_farming") && sbEvent.desc != null) {
+ tooltipToDisplay.addAll(sbEvent.desc);
+ }
+ if (nextMajorEvent != null || i < nextFavourites.size() - 1) {
+ tooltipToDisplay.add("");
+ }
+ }
+ if (nextMajorEvent != null) {
+ tooltipToDisplay.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "Next Major:");
+ tooltipToDisplay.add(nextMajorEvent.display);
+ tooltipToDisplay.add(EnumChatFormatting.GRAY + "Starts in: " + EnumChatFormatting.YELLOW +
+ prettyTime(timeUntilMajor, false));
+ if (nextMajorEvent.lastsFor >= 0) {
+ tooltipToDisplay.add(EnumChatFormatting.GRAY + "Lasts for: " + EnumChatFormatting.YELLOW +
+ prettyTime(nextMajorEvent.lastsFor, true));
+ }
+ }
+
+ }
+ }
+
+ drawTimerForeground = false;
+ if (tooltipToDisplay != null) {
+ drawTimerForeground = true;
+ GlStateManager.translate(0, 0, 100);
+ Utils.drawHoveringText(tooltipToDisplay, mouseX, Math.max(17, mouseY), width, height, -1, fr);
+ GlStateManager.translate(0, 0, -100);
+ }
+ }
+ }
+ }
+ GlStateManager.translate(0, 0, -10);
+ GlStateManager.popMatrix();
+ }
+
+ private void renderBlurredBackground(
+ float blurStrength,
+ int screenWidth,
+ int screenHeight,
+ int x,
+ int y,
+ int blurWidth,
+ int blurHeight
+ ) {
+ BackgroundBlur.renderBlurredBackground(blurStrength, screenWidth, screenHeight, x, y, blurWidth, blurHeight);
+ Gui.drawRect(x, y, x + blurWidth, y + blurHeight, 0xc8101010);
+ GlStateManager.color(1, 1, 1, 1);
+ }
+
+ @SubscribeEvent
+ public void onGuiDraw(GuiScreenEvent.DrawScreenEvent.Pre event) {
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) {
+ return;
+ }
+
+ if (!enabled) {
+ return;
+ }
+
+ GuiChest eventGui = (GuiChest) Minecraft.getMinecraft().currentScreen;
+ ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
+ String containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText();
+ if (!containerName.trim().equals("Calendar and Events")) {
+ setEnabled(false);
+ return;
+ }
+
+ event.setCanceled(true);
+
+ List<String> tooltipToDisplay = null;
+ int mouseX = event.mouseX;
+ int mouseY = event.mouseY;
+ long currentTime = System.currentTimeMillis();
+
+ xSize = 168;
+ ySize = 170;
+
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ int width = scaledResolution.getScaledWidth();
+ int height = scaledResolution.getScaledHeight();
+ guiLeft = (width - xSize) / 2;
+ guiTop = (height - ySize) / 2;
+
+ Utils.drawGradientRect(0, 0, width, height, -1072689136, -804253680);
+
+ renderBlurredBackground(10, width, height, guiLeft + 3, guiTop + 3, 162, 14);
+ renderBlurredBackground(10, width, height, guiLeft + 3, guiTop + 26, 14, 141);
+ renderBlurredBackground(10, width, height, guiLeft + 151, guiTop + 26, 14, 141);
+ renderBlurredBackground(10, width, height, guiLeft + 26, guiTop + 26, 116, 141);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(BACKGROUND);
+ Utils.drawTexturedRect(guiLeft, guiTop, xSize, ySize, GL11.GL_NEAREST);
+
+ GlStateManager.translate(0, 0, 10);
+
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+
+ fr.drawString("Daily", guiLeft + 29, guiTop + 30, 0xffffaa00);
+ int specialLen = fr.getStringWidth("Special");
+ fr.drawString("Special", guiLeft + 139 - specialLen, guiTop + 30, 0xffffaa00);
+
+ ItemStack mayorStack = cc.getLowerChestInventory().getStackInSlot(46);
+ if (mayorStack != null) {
+ String mayor = mayorStack.getDisplayName();
+ float verticalHeight = Utils.getVerticalHeight(mayor);
+ Utils.drawStringVertical(mayor, fr, guiLeft + 8, guiTop + 96 - verticalHeight / 2,
+ false, -1
+ );
+ }
+
+ String calendar = EnumChatFormatting.GREEN + "Calendar";
+ float calendarHeight = Utils.getVerticalHeight(calendar);
+ Utils.drawStringVertical(calendar, fr, guiLeft + xSize - 12, guiTop + 60 - calendarHeight / 2,
+ false, -1
+ );
+
+ String rewards = EnumChatFormatting.GOLD + "Rewards";
+ float rewardsHeight = Utils.getVerticalHeight(rewards);
+ Utils.drawStringVertical(rewards, fr, guiLeft + xSize - 12, guiTop + 132 - rewardsHeight / 2,
+ false, -1
+ );
+
+ if (mouseY >= guiTop + 26 && mouseY <= guiTop + 26 + 141) {
+ if (mouseX >= guiLeft + 3 && mouseX <= guiLeft + 3 + 14) {
+ if (mayorStack != null)
+ tooltipToDisplay = mayorStack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ } else if (mouseX >= guiLeft + 151 && mouseX <= guiLeft + 151 + 14) {
+ if (mouseY <= guiTop + 26 + 70) {
+ ItemStack calendarStack = cc.getLowerChestInventory().getStackInSlot(50);
+ if (calendarStack != null)
+ tooltipToDisplay = calendarStack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ } else {
+ ItemStack rewardsStack = cc.getLowerChestInventory().getStackInSlot(45);
+ if (rewardsStack != null)
+ tooltipToDisplay = rewardsStack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ }
+ }
+ }
+
+ long timeUntilNext = 0;
+ SBEvent nextEvent = null;
+ long timeUntilFirst = 0;
+ SBEvent firstEvent = null;
+ List<String> eventFavourites = NotEnoughUpdates.INSTANCE.config.hidden.eventFavourites;
+
+ //Daily Events
+ int index = 0;
+ out:
+ for (Map.Entry<Long, Set<SBEvent>> sbEvents : eventMap.entrySet()) {
+ for (SBEvent sbEvent : sbEvents.getValue()) {
+ long timeUntilMillis = sbEvents.getKey() - currentTime;
+
+ int x = guiLeft + 29 + 17 * (index % 3);
+ int y = guiTop + 44 + 17 * (index / 3);
+
+ if (sbEvent.id.equals("spooky_festival")) {
+ if (sbEvents.getKey() > currentTime - HOUR && (sbEvents.getKey() < spookyStart || spookyStart == 0)) {
+ spookyStart = sbEvents.getKey();
+ }
+ }
+
+ if (index >= 21) {
+ if (nextEvent != null) break;
+ if (eventFavourites.isEmpty()) {
+ nextEvent = sbEvent;
+ timeUntilNext = timeUntilMillis;
+ } else if (eventFavourites.contains(sbEvent.id)) {
+ nextEvent = sbEvent;
+ timeUntilNext = timeUntilMillis;
+ }
+ continue;
+ }
+
+ if (firstEvent == null) {
+ firstEvent = sbEvent;
+ timeUntilFirst = timeUntilMillis;
+ }
+
+ String[] split = sbEvent.id.split(":");
+ boolean containsId = false;
+ for (int i = 1; i < split.length; i++) {
+ if (eventFavourites.contains(split[0] + ":" + split[i])) {
+ containsId = true;
+ break;
+ }
+ }
+ if (eventFavourites.isEmpty()) {
+ if (nextEvent == null) {
+ nextEvent = sbEvent;
+ timeUntilNext = timeUntilMillis;
+ }
+ } else if (eventFavourites.contains(split[0]) || containsId) {
+ if (nextEvent == null) {
+ nextEvent = sbEvent;
+ timeUntilNext = timeUntilMillis;
+ }
+
+ GlStateManager.depthMask(false);
+ GlStateManager.translate(0, 0, -2);
+ Gui.drawRect(x, y, x + 16, y + 16, 0xcfffbf49);
+ GlStateManager.translate(0, 0, 2);
+ GlStateManager.depthMask(true);
+ }
+
+ Utils.drawItemStackWithText(sbEvent.stack, x, y, "" + (index + 1));
+
+ if (mouseX >= x && mouseX <= x + 16) {
+ if (mouseY >= y && mouseY <= y + 16) {
+ tooltipToDisplay = Utils.createList(
+ sbEvent.display,
+ EnumChatFormatting.GRAY + "Starts in: " + EnumChatFormatting.YELLOW + prettyTime(timeUntilMillis, false)
+ );
+ if (sbEvent.lastsFor >= 0) {
+ tooltipToDisplay.add(EnumChatFormatting.GRAY + "Lasts for: " + EnumChatFormatting.YELLOW +
+ prettyTime(sbEvent.lastsFor, true));
+ }
+ if (sbEvent.desc != null) {
+ tooltipToDisplay.add("");
+ tooltipToDisplay.addAll(sbEvent.desc);
+ }
+ }
+ }
+
+ index++;
+ }
+ }
+
+ //Special Events
+ for (int i = 0; i < 21; i++) {
+ int itemIndex = 10 + i + (i / 7) * 2;
+ ItemStack item = cc.getLowerChestInventory().getStackInSlot(itemIndex);
+ if (item == null) continue;
+
+ String eventId = getIdForDisplayName(item.getDisplayName());
+
+ NBTTagCompound tag = item.getTagCompound();
+ tag.setString("event_id", eventId);
+ item.setTagCompound(tag);
+
+ int x = guiLeft + 89 + 17 * (i % 3);
+ int y = guiTop + 44 + 17 * (i / 3);
+
+ if (eventFavourites.contains(eventId)) {
+ GlStateManager.depthMask(false);
+ GlStateManager.translate(0, 0, -2);
+ Gui.drawRect(x, y, x + 16, y + 16, 0xcfffbf49);
+ GlStateManager.translate(0, 0, 2);
+ GlStateManager.depthMask(true);
+ }
+
+ Utils.drawItemStackWithText(item, x, y, "" + (i + 1));
+
+ if (mouseX >= x && mouseX <= x + 16) {
+ if (mouseY >= y && mouseY <= y + 16) {
+ tooltipToDisplay = item.getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ }
+ }
+ }
+
+ if (nextEvent == null) {
+ nextEvent = firstEvent;
+ timeUntilNext = timeUntilFirst;
+ }
+
+ if (nextEvent != null) {
+ String nextS = EnumChatFormatting.YELLOW + "Next: ";
+ int nextSLen = fr.getStringWidth(nextS);
+ fr.drawString(nextS, guiLeft + 8, guiTop + 6, -1, false);
+
+ String until = " " + EnumChatFormatting.YELLOW + prettyTime(timeUntilNext, false);
+ int untilLen = fr.getStringWidth(until);
+
+ fr.drawString(until, guiLeft + xSize - 8 - untilLen, guiTop + 6, -1, false);
+
+ int eventTitleLen = xSize - 16 - untilLen - nextSLen;
+ int displayWidth = fr.getStringWidth(nextEvent.display);
+ int spaceLen = fr.getCharWidth(' ');
+ if (displayWidth > eventTitleLen) {
+ GL11.glEnable(GL11.GL_SCISSOR_TEST);
+ GL11.glScissor(
+ (guiLeft + 8 + nextSLen) * scaledResolution.getScaleFactor(),
+ 0,
+ eventTitleLen * scaledResolution.getScaleFactor(),
+ Minecraft.getMinecraft().displayHeight
+ );
+ fr.drawString(nextEvent.display + " " + nextEvent.display,
+ guiLeft + 8 + nextSLen - (float) (currentTime / 50.0 % (displayWidth + spaceLen)), guiTop + 6, -1, false
+ );
+ GL11.glDisable(GL11.GL_SCISSOR_TEST);
+ } else {
+ fr.drawString(nextEvent.display, guiLeft + 8 + nextSLen, guiTop + 6, -1, false);
+ }
+
+ if (mouseX > guiLeft && mouseX < guiLeft + 168) {
+ if (mouseY > guiTop && mouseY < guiTop + 20) {
+ tooltipToDisplay = Utils.createList(
+ nextEvent.display,
+ EnumChatFormatting.GRAY + "Starts in: " + EnumChatFormatting.YELLOW + prettyTime(timeUntilNext, false)
+ );
+ if (nextEvent.lastsFor >= 0) {
+ tooltipToDisplay.add(EnumChatFormatting.GRAY + "Lasts for: " + EnumChatFormatting.YELLOW +
+ prettyTime(nextEvent.lastsFor, true));
+ }
+ if (nextEvent.desc != null) {
+ tooltipToDisplay.add("");
+ tooltipToDisplay.addAll(nextEvent.desc);
+ }
+ }
+ }
+ }
+
+ GlStateManager.color(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(help);
+ Utils.drawTexturedRect(guiLeft + xSize - 18, guiTop + ySize + 2, 16, 16, GL11.GL_LINEAR);
+
+ if (mouseX >= guiLeft + xSize - 18 && mouseX < guiLeft + xSize - 2) {
+ if (mouseY >= guiTop + ySize + 2 && mouseY <= guiTop + ySize + 18) {
+ tooltipToDisplay = new ArrayList<>();
+ tooltipToDisplay.add(EnumChatFormatting.AQUA + "NEU Calendar Help");
+ tooltipToDisplay.add(EnumChatFormatting.YELLOW + "This calendar displays various skyblock events");
+ tooltipToDisplay.add(EnumChatFormatting.YELLOW + "'Daily' events are events that happen frequently");
+ tooltipToDisplay.add(EnumChatFormatting.YELLOW + "'Special' events are events that happen infrequently");
+ tooltipToDisplay.add(EnumChatFormatting.YELLOW + "");
+ tooltipToDisplay.add(EnumChatFormatting.YELLOW + "The eventbar at the top will also show in your inventory");
+ tooltipToDisplay.add(EnumChatFormatting.YELLOW + "");
+ tooltipToDisplay.add(EnumChatFormatting.YELLOW + "Press 'F' on an event to mark it as a favourite");
+ tooltipToDisplay.add(EnumChatFormatting.YELLOW + "Favourited events will show over normal events");
+ tooltipToDisplay.add(EnumChatFormatting.YELLOW + "Favourited events will also give a notification when it");
+ tooltipToDisplay.add(EnumChatFormatting.YELLOW + "is about to start and when it does start");
+ tooltipToDisplay.add(EnumChatFormatting.YELLOW + "");
+ tooltipToDisplay.add(EnumChatFormatting.DARK_GRAY + "In order to show crop types for Jacob's Farming");
+ tooltipToDisplay.add(EnumChatFormatting.DARK_GRAY + "contest, visit the full skyblock calendar and go all");
+ tooltipToDisplay.add(EnumChatFormatting.DARK_GRAY + "the way to the end of the skyblock year");
+ Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, fr);
+ tooltipToDisplay = null;
+ }
+ }
+
+ if (jfFavouriteSelect != null) {
+ int arrowLen = fr.getStringWidth("> ");
+ int selectSizeX = 0;
+ int selectStringIndex = 0;
+ for (String s : jfFavouriteSelect) {
+ int sWidth = fr.getStringWidth(s);
+ if (selectStringIndex + 1 == jfFavouriteSelectIndex) sWidth += arrowLen;
+ if (sWidth > selectSizeX) {
+ selectSizeX = sWidth;
+ }
+ selectStringIndex++;
+ }
+ selectSizeX += +10;
+
+ GlStateManager.translate(0, 0, 19);
+
+ Gui.drawRect(jfFavouriteSelectX + 2, jfFavouriteSelectY + 2, jfFavouriteSelectX + selectSizeX + 2,
+ jfFavouriteSelectY + 18 + jfFavouriteSelect.size() * 10 + 2, 0xa0000000
+ );
+
+ GlStateManager.depthFunc(GL11.GL_LESS);
+ GlStateManager.translate(0, 0, 1);
+ Gui.drawRect(jfFavouriteSelectX + 1, jfFavouriteSelectY + 1, jfFavouriteSelectX + selectSizeX - 1,
+ jfFavouriteSelectY + 18 + jfFavouriteSelect.size() * 10 - 1, 0xffc0c0c0
+ );
+ Gui.drawRect(jfFavouriteSelectX, jfFavouriteSelectY, jfFavouriteSelectX + selectSizeX - 1,
+ jfFavouriteSelectY + 18 + jfFavouriteSelect.size() * 10 - 1, 0xfff0f0f0
+ );
+ Gui.drawRect(jfFavouriteSelectX, jfFavouriteSelectY, jfFavouriteSelectX + selectSizeX,
+ jfFavouriteSelectY + 18 + jfFavouriteSelect.size() * 10, 0xff909090
+ );
+ GlStateManager.depthFunc(GL11.GL_LEQUAL);
+
+ String all = (NotEnoughUpdates.INSTANCE.config.hidden.eventFavourites.contains("jacob_farming") ?
+ EnumChatFormatting.DARK_GREEN : EnumChatFormatting.DARK_GRAY) + "All";
+ if (jfFavouriteSelectIndex == 0) {
+ fr.drawString(
+ EnumChatFormatting.BLACK + "> " + all,
+ jfFavouriteSelectX + 5,
+ jfFavouriteSelectY + 5,
+ 0xff000000
+ );
+ } else {
+ fr.drawString(all, jfFavouriteSelectX + 5, jfFavouriteSelectY + 5, 0xff000000);
+ }
+
+ fr.drawString(EnumChatFormatting.BLACK + "> ", jfFavouriteSelectX + 6,
+ jfFavouriteSelectY + 10 * jfFavouriteSelectIndex + 5, 0xff000000
+ );
+
+ selectStringIndex = 0;
+ for (String s : jfFavouriteSelect) {
+ EnumChatFormatting colour = NotEnoughUpdates.INSTANCE.config.hidden.eventFavourites.contains(
+ "jacob_farming:" + s)
+ ? EnumChatFormatting.DARK_GREEN : EnumChatFormatting.DARK_GRAY;
+ s = (selectStringIndex + 1 == jfFavouriteSelectIndex ? EnumChatFormatting.BLACK + "> " : "") + colour + s;
+ fr.drawString(s, jfFavouriteSelectX + 5, jfFavouriteSelectY + 10 * selectStringIndex + 15, 0xff000000);
+ selectStringIndex++;
+ }
+ GlStateManager.translate(0, 0, -20);
+ } else if (tooltipToDisplay != null) {
+ Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, fr);
+ }
+
+ GlStateManager.translate(0, 0, -10);
+
+ }
+
+ private String prettyTime(long millis, boolean trimmed) {
+ long seconds = millis / 1000 % 60;
+ long minutes = (millis / 1000 / 60) % 60;
+ long hours = (millis / 1000 / 60 / 60) % 24;
+ long days = (millis / 1000 / 60 / 60 / 24);
+
+ String endsIn = "";
+ if (millis < 0) {
+ endsIn += "Now!";
+ } else if (minutes == 0 && hours == 0 && days == 0) {
+ endsIn += seconds + "s";
+ } else if (hours == 0 && days == 0) {
+ if (trimmed && seconds == 0) {
+ endsIn += minutes + "m";
+ } else {
+ endsIn += minutes + "m" + seconds + "s";
+ }
+ } else if (days == 0) {
+ if (hours <= 6) {
+ if (trimmed && seconds == 0) {
+ if (minutes == 0) {
+ endsIn += hours + "h";
+ } else {
+ endsIn += hours + "h" + minutes + "m";
+ }
+ } else {
+ endsIn += hours + "h" + minutes + "m" + seconds + "s";
+ }
+ } else {
+ endsIn += hours + "h";
+ }
+ } else {
+ endsIn += days + "d" + hours + "h";
+ }
+
+ return endsIn;
+ }
+
+ Shader blurShaderHorz = null;
+ Framebuffer blurOutputHorz = null;
+ Shader blurShaderVert = null;
+ Framebuffer blurOutputVert = null;
+
+ /**
+ * Creates a projection matrix that projects from our coordinate space [0->width; 0->height] to OpenGL coordinate
+ * space [-1 -> 1; 1 -> -1] (Note: flipped y-axis).
+ * <p>
+ * This is so that we can render to and from the framebuffer in a way that is familiar to us, instead of needing to
+ * apply scales and translations manually.
+ */
+ private Matrix4f createProjectionMatrix(int width, int height) {
+ Matrix4f projMatrix = new Matrix4f();
+ projMatrix.setIdentity();
+ projMatrix.m00 = 2.0F / (float) width;
+ projMatrix.m11 = 2.0F / (float) (-height);
+ projMatrix.m22 = -0.0020001999F;
+ projMatrix.m33 = 1.0F;
+ projMatrix.m03 = -1.0F;
+ projMatrix.m13 = 1.0F;
+ projMatrix.m23 = -1.0001999F;
+ return projMatrix;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java
index 0fbf9406..f5838052 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java
@@ -1,7 +1,6 @@
package io.github.moulberry.notenoughupdates.miscgui;
import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
@@ -44,1611 +43,1863 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class GuiCustomEnchant extends Gui {
-
- private static final GuiCustomEnchant INSTANCE = new GuiCustomEnchant();
- private static final ResourceLocation TEXTURE = new ResourceLocation("notenoughupdates:custom_enchant_gui.png");
- private static final ResourceLocation ENCHANTMENT_TABLE_BOOK_TEXTURE = new ResourceLocation("textures/entity/enchanting_table_book.png");
- private static final ModelBook MODEL_BOOK = new ModelBook();
-
- private static final int EXPERIENCE_ORB_COUNT = 30;
-
- private static final Pattern XP_COST_PATTERN = Pattern.compile("\\u00a73(\\d+) Exp Levels");
-
- private enum EnchantState {
- NO_ITEM,
- ADDING_ENCHANT,
- SWITCHING_DONT_UPDATE,
- INVALID_ITEM,
- HAS_ITEM
- }
-
- private class Enchantment {
- public int slotIndex;
- public String enchantName;
- public String enchId;
- public List<String> displayLore;
- public int level;
- public int xpCost = -1;
- public boolean overMaxLevel = false;
- public boolean conflicts = false;
-
- public Enchantment(int slotIndex, String enchantName, String enchId, List<String> displayLore, int level,
- boolean useMaxLevelForCost, boolean checkConflicts) {
- this.slotIndex = slotIndex;
- this.enchantName = enchantName;
- this.enchId = enchId;
- this.displayLore = displayLore;
- this.level = level;
-
- if(Constants.ENCHANTS != null) {
- if(checkConflicts && Constants.ENCHANTS.has("enchant_pools")) {
- JsonArray pools = Constants.ENCHANTS.getAsJsonArray("enchant_pools");
- out:
- for(int i=0; i<pools.size(); i++) {
- JsonArray pool = pools.get(i).getAsJsonArray();
-
- boolean hasThis = false;
- boolean hasApplied = false;
-
- for(int j=0; j<pool.size(); j++) {
- String enchIdPoolElement = pool.get(j).getAsString();
- if(enchId.equalsIgnoreCase(enchIdPoolElement)) {
- hasThis = true;
- } else if(playerEnchantIds.containsKey(enchIdPoolElement)) {
- hasApplied = true;
- }
- if(hasThis && hasApplied) {
- this.conflicts = true;
- break out;
- }
- }
- }
- }
-
- if(level >= 1 && Constants.ENCHANTS.has("enchants_xp_cost")) {
- JsonObject allCosts = Constants.ENCHANTS.getAsJsonObject("enchants_xp_cost");
- if(allCosts.has(enchId)) {
- JsonArray costs = allCosts.getAsJsonArray(enchId);
-
- if(costs.size() >= 1) {
- if(useMaxLevelForCost) {
- this.xpCost = costs.get(costs.size()-1).getAsInt();
- } else if(level-1 < costs.size()) {
- this.xpCost = costs.get(level-1).getAsInt();
- } else {
- overMaxLevel = true;
- }
- }
- }
-
- }
- }
- }
- }
-
- public static class ExperienceOrb {
- public float x;
- public float y;
- public float xLast;
- public float yLast;
- public float xVel;
- public float yVel;
-
- public int type;
- public int rotationDeg;
- }
-
- private List<ExperienceOrb> orbs = new ArrayList<>();
- private int orbTargetX = 0;
- private int orbTargetY = 0;
-
- private int guiLeft;
- private int guiTop;
- private boolean shouldOverrideFast = false;
-
- public float pageOpen;
- public float pageOpenLast;
- public float pageOpenRandom;
- public float pageOpenVelocity;
- public float bookOpen;
- public float bookOpenLast;
-
- private int currentPage;
- private int expectedMaxPage;
-
- private boolean isScrollingLeft = true;
-
- private ItemStack enchantingItem = null;
-
- private int removingEnchantPlayerLevel = -1;
-
- private GuiElementTextField searchField = new GuiElementTextField("", GuiElementTextField.SCISSOR_TEXT);
-
- private HashMap<String, Integer> playerEnchantIds = new HashMap<>();
-
- private boolean searchRemovedFromApplicable = false;
- private boolean searchRemovedFromRemovable = false;
- private List<Enchantment> applicable = new ArrayList<>();
- private List<Enchantment> removable = new ArrayList<>();
-
- private HashMap<Integer, Enchantment> enchanterEnchLevels = new HashMap<>();
- private Enchantment enchanterCurrentEnch = null;
-
- public Random random = new Random();
-
- private EnchantState currentState = EnchantState.NO_ITEM;
- private EnchantState lastState = EnchantState.NO_ITEM;
-
- private LerpingInteger leftScroll = new LerpingInteger(0, 150);
- private LerpingInteger rightScroll = new LerpingInteger(0, 150);
-
- private LerpingFloat arrowAmount = new LerpingFloat(0, 100);
-
- private static final int X_SIZE = 364;
- private static final int Y_SIZE = 215;
-
- private int clickedScrollOffset = -1;
- private boolean isClickedScrollLeft = true;
-
- private boolean isChangingEnchLevel = false;
-
- private long cancelButtonAnimTime = 0;
- private long confirmButtonAnimTime = 0;
-
- public static GuiCustomEnchant getInstance() {
- return INSTANCE;
- }
-
- public boolean shouldOverride(String containerName) {
- shouldOverrideFast = NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enableTableGUI &&
- containerName != null &&
- NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() &&
- containerName.equalsIgnoreCase("Enchant Item");
- if(!shouldOverrideFast) {
- currentState = EnchantState.NO_ITEM;
- applicable.clear();
- removable.clear();
- expectedMaxPage = 1;
- }
- return shouldOverrideFast;
- }
-
- private int tickCounter = 0;
- public void tick() {
- GuiContainer chest = ((GuiContainer)Minecraft.getMinecraft().currentScreen);
- ContainerChest cc = (ContainerChest) chest.inventorySlots;
-
- ItemStack stack = cc.getLowerChestInventory().getStackInSlot(23);
- ItemStack enchantGuideStack = cc.getLowerChestInventory().getStackInSlot(50);
- ItemStack enchantingItemStack = cc.getLowerChestInventory().getStackInSlot(19);
-
- int lastPage = currentPage;
-
- this.lastState = currentState;
- if(enchantGuideStack != null && enchantGuideStack.getItem() != Items.book && enchantingItem != null) {
- currentState = EnchantState.ADDING_ENCHANT;
- } else if(stack == null || enchantingItemStack == null) {
- if(currentState == EnchantState.SWITCHING_DONT_UPDATE || currentState == EnchantState.NO_ITEM) {
- currentState = EnchantState.NO_ITEM;
- } else {
- currentState = EnchantState.SWITCHING_DONT_UPDATE;
- }
- } else if(stack.getItem() != Items.dye) {
- ItemStack sanityCheckStack = cc.getLowerChestInventory().getStackInSlot(12);
- if(sanityCheckStack == null || sanityCheckStack.getItem() == Items.enchanted_book) {
- currentState = EnchantState.HAS_ITEM;
- enchantingItem = enchantingItemStack;
- } else {
- currentState = EnchantState.SWITCHING_DONT_UPDATE;
- }
- } else if(stack.getItemDamage() == 1) {
- currentState = EnchantState.INVALID_ITEM;
- } else {
- currentState = EnchantState.NO_ITEM;
- }
-
- if(currentState == EnchantState.HAS_ITEM) {
- ItemStack pageUpStack = cc.getLowerChestInventory().getStackInSlot(17);
- ItemStack pageDownStack = cc.getLowerChestInventory().getStackInSlot(35);
- if(pageUpStack != null && pageDownStack != null) {
- currentPage = 0;
- boolean upIsGlass = pageUpStack.getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane);
- boolean downIsGlass = pageDownStack.getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane);
- int page = -1;
-
- expectedMaxPage = 1;
- if(!downIsGlass) {
- try {
- page = Integer.parseInt(Utils.getRawTooltip(pageDownStack).get(1).substring(11))-1;
- expectedMaxPage = page+1;
- } catch(Exception ignored) {}
- }
- if(page == -1 && !upIsGlass) {
- try {
- page = Integer.parseInt(Utils.getRawTooltip(pageUpStack).get(1).substring(11))+1;
- expectedMaxPage = page;
- } catch(Exception ignored) {}
- }
- if(page == -1) {
- currentPage = 1;
- } else {
- currentPage = page;
- }
- }
- }
-
- List<ExperienceOrb> toRemove = new ArrayList<>();
- for(ExperienceOrb orb : orbs) {
- float targetDeltaX = guiLeft+orbTargetX - orb.x;
- float targetDeltaY = guiTop+orbTargetY - orb.y;
-
- float length = (float)Math.sqrt(targetDeltaX*targetDeltaX + targetDeltaY*targetDeltaY);
-
- if(length < 8 && orb.xVel*orb.xVel+orb.yVel*orb.yVel < 20) {
- toRemove.add(orb);
- continue;
- }
-
- orb.xVel += targetDeltaX*2/length;
- orb.yVel += targetDeltaY*2/length;
-
- orb.xVel *= 0.90;
- orb.yVel *= 0.90;
-
- orb.xLast = orb.x;
- orb.yLast = orb.y;
- orb.x += orb.xVel;
- orb.y += orb.yVel;
- }
- orbs.removeAll(toRemove);
-
- if(++tickCounter >= 20) {
- tickCounter = 0;
- }
-
- boolean updateItems = tickCounter == 0;
-
- if(currentState == EnchantState.ADDING_ENCHANT) {
- if(arrowAmount.getTarget() != 1) {
- arrowAmount.setTarget(1);
- arrowAmount.resetTimer();
- }
- } else {
- if(arrowAmount.getTarget() != 0) {
- arrowAmount.setTarget(0);
- arrowAmount.resetTimer();
- }
- }
-
- Set<EnchantState> allowedSwitchStates = Sets.newHashSet(EnchantState.ADDING_ENCHANT, EnchantState.HAS_ITEM, EnchantState.SWITCHING_DONT_UPDATE);
- if(lastState != currentState || lastPage != currentPage) {
- if(!allowedSwitchStates.contains(lastState) || !allowedSwitchStates.contains(currentState)) {
- leftScroll.setValue(0);
- rightScroll.setValue(0);
- }
- updateItems = true;
- }
-
- if(updateItems && currentState != EnchantState.SWITCHING_DONT_UPDATE) {
- enchanterEnchLevels.clear();
-
- if(enchantingItem != null) {
- playerEnchantIds.clear();
- NBTTagCompound tag = enchantingItem.getTagCompound();
- if(tag != null) {
- NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
- if(ea != null) {
- NBTTagCompound enchantments = ea.getCompoundTag("enchantments");
- if(enchantments != null) {
- for(String enchId : enchantments.getKeySet()) {
- playerEnchantIds.put(enchId, enchantments.getInteger(enchId));
- }
- }
- }
- }
- }
-
- if(currentState == EnchantState.ADDING_ENCHANT) {
- removingEnchantPlayerLevel = -1;
- boolean updateLevel = enchanterCurrentEnch == null;
- for(int i=0; i<27; i++) {
- int slotIndex = 9 + i;
- ItemStack book = cc.getLowerChestInventory().getStackInSlot(slotIndex);
- if(book != null && book.getItem() == Items.enchanted_book) {
- NBTTagCompound tagBook = book.getTagCompound();
- if(tagBook != null) {
- NBTTagCompound ea = tagBook.getCompoundTag("ExtraAttributes");
- if(ea != null) {
- NBTTagCompound enchantments = ea.getCompoundTag("enchantments");
- if(enchantments != null) {
- for(String enchId : enchantments.getKeySet()) {
- String name = Utils.cleanColour(book.getDisplayName());
- if(name.equalsIgnoreCase("Bane of Arthropods")) {
- name = "Bane of Arth.";
- } else if(name.equalsIgnoreCase("Projectile Protection")) {
- name = "Projectile Prot";
- } else if(name.equalsIgnoreCase("Blast Protection")) {
- name = "Blast Prot";
- }
- Enchantment enchantment = new Enchantment(slotIndex, name, enchId,
- Utils.getRawTooltip(book), enchantments.getInteger(enchId), false, true);
- enchantment.displayLore.remove(0);
-
- if(removingEnchantPlayerLevel == -1 && playerEnchantIds.containsKey(enchId)) {
- removingEnchantPlayerLevel = playerEnchantIds.get(enchId);
- }
-
- if(removingEnchantPlayerLevel >= 0 && enchantment.level < removingEnchantPlayerLevel) {
- continue;
- }
-
- if(enchanterCurrentEnch == null) {
- enchanterCurrentEnch = enchantment;
- } else if(updateLevel) {
- if(removingEnchantPlayerLevel < 0 && enchantment.level > enchanterCurrentEnch.level) {
- enchanterCurrentEnch = enchantment;
- } else if(removingEnchantPlayerLevel >= 0 && enchantment.level < enchanterCurrentEnch.level) {
- enchanterCurrentEnch = enchantment;
- }
- }
-
- enchanterEnchLevels.put(enchantment.level, enchantment);
- }
- }
- }
- }
- }
- }
- if(enchanterCurrentEnch != null && removingEnchantPlayerLevel >= 0) {
- for(String line : enchanterCurrentEnch.displayLore) {
- Matcher matcher = XP_COST_PATTERN.matcher(line);
- if(matcher.find()) {
- enchanterCurrentEnch.xpCost = Integer.parseInt(matcher.group(1));
- }
- }
- }
- } else {
- isChangingEnchLevel = false;
- enchanterCurrentEnch = null;
-
- searchRemovedFromRemovable = false;
- searchRemovedFromApplicable = false;
- applicable.clear();
- removable.clear();
- if(currentState == EnchantState.HAS_ITEM) {
- for(int i=0; i<15; i++) {
- int slotIndex = 12 + (i%5) + (i/5)*9;
- ItemStack book = cc.getLowerChestInventory().getStackInSlot(slotIndex);
- if(book != null) {
- NBTTagCompound tagBook = book.getTagCompound();
- if(tagBook != null) {
- NBTTagCompound ea = tagBook.getCompoundTag("ExtraAttributes");
- if(ea != null) {
- NBTTagCompound enchantments = ea.getCompoundTag("enchantments");
- if(enchantments != null) {
- for(String enchId : enchantments.getKeySet()) {
- String name = Utils.cleanColour(book.getDisplayName());
-
- if(searchField.getText().trim().isEmpty() ||
- name.toLowerCase().contains(searchField.getText().trim().toLowerCase())) {
- if(name.equalsIgnoreCase("Bane of Arthropods")) {
- name = "Bane of Arth.";
- } else if(name.equalsIgnoreCase("Projectile Protection")) {
- name = "Projectile Prot";
- } else if(name.equalsIgnoreCase("Blast Protection")) {
- name = "Blast Prot";
- } else if(name.equalsIgnoreCase("Luck of the Sea")) {
- name = "Luck of Sea";
- }
-
- if(playerEnchantIds.containsKey(enchId)) {
- Enchantment enchantment = new Enchantment(slotIndex, name, enchId,
- Utils.getRawTooltip(book), playerEnchantIds.get(enchId), false, false);
- if(!enchantment.overMaxLevel) {
- removable.add(enchantment);
- }
- } else {
- Enchantment enchantment = new Enchantment(slotIndex, name, enchId,
- Utils.getRawTooltip(book), enchantments.getInteger(enchId), true, true);
- applicable.add(enchantment);
- }
- } else {
- if(playerEnchantIds.containsKey(enchId)) {
- searchRemovedFromRemovable = true;
- } else {
- searchRemovedFromApplicable = true;
- }
- }
-
- }
- }
- }
- }
- }
- }
- NEUConfig cfg = NotEnoughUpdates.INSTANCE.config;
- int mult = cfg.enchantingSolvers.enchantOrdering == 0 ? 1 : -1;
- Comparator<Enchantment> comparator = cfg.enchantingSolvers.enchantSorting == 0 ?
- Comparator.comparingInt(e -> mult*e.xpCost) :
- (c1, c2) -> mult*c1.enchId.toLowerCase().compareTo(c2.enchId.toLowerCase());
- removable.sort(comparator);
- applicable.sort(comparator);
- }
- }
- }
-
- //Update book model state
- if (lastState != currentState) {
- while (true) {
- this.pageOpenRandom += (float)(this.random.nextInt(4) - this.random.nextInt(4));
-
- if (this.pageOpen > this.pageOpenRandom + 1.0F || this.pageOpen < this.pageOpenRandom - 1.0F) {
- break;
- }
- }
- }
-
- this.pageOpenLast = this.pageOpen;
- this.bookOpenLast = this.bookOpen;
-
- if (currentState == EnchantState.HAS_ITEM || currentState == EnchantState.ADDING_ENCHANT) {
- this.bookOpen += 0.2F;
- } else {
- this.bookOpen -= 0.2F;
- }
-
- this.bookOpen = MathHelper.clamp_float(this.bookOpen, 0.0F, 1.0F);
- float f1 = (this.pageOpenRandom - this.pageOpen) * 0.4F;
- f1 = MathHelper.clamp_float(f1, -0.2F, 0.2F);
- this.pageOpenVelocity += (f1 - this.pageOpenVelocity) * 0.9F;
- this.pageOpen += this.pageOpenVelocity;
- }
-
-
- private List<String> createTooltip(String title, int selectedOption, String... options) {
- String selPrefix = EnumChatFormatting.DARK_AQUA + " \u25b6 ";
- String unselPrefix = EnumChatFormatting.GRAY.toString();
-
- for(int i=0; i<options.length; i++) {
- if(i == selectedOption) {
- options[i] = selPrefix + options[i];
- } else {
- options[i] = unselPrefix + options[i];
- }
- }
-
- List list = Lists.newArrayList(options);
- list.add(0, "");
- list.add(0, EnumChatFormatting.GREEN+title);
- return list;
- }
-
- public void render(float partialTicks) {
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) return;
-
- long currentTime = System.currentTimeMillis();
- int playerXpLevel = Minecraft.getMinecraft().thePlayer.experienceLevel;
-
- GuiContainer chest = ((GuiContainer)Minecraft.getMinecraft().currentScreen);
- ContainerChest cc = (ContainerChest) chest.inventorySlots;
-
- leftScroll.tick();
- rightScroll.tick();
- arrowAmount.tick();
-
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- int width = scaledResolution.getScaledWidth();
- int height = scaledResolution.getScaledHeight();
- int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
- int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
-
- guiLeft = (width-X_SIZE)/2;
- guiTop = (height-Y_SIZE)/2;
-
- List<String> tooltipToDisplay = null;
- boolean disallowClick = false;
- ItemStack stackOnMouse = Minecraft.getMinecraft().thePlayer.inventory.getItemStack();
- int itemHoverX = -1;
- int itemHoverY = -1;
- boolean hoverLocked = false;
-
- drawGradientRect(0, 0, width, height, 0xc0101010, 0xd0101010);
-
- //Base Texture
- Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(guiLeft, guiTop, X_SIZE, Y_SIZE,
- 0, X_SIZE/512f, 0, Y_SIZE/512f, GL11.GL_NEAREST);
-
- Minecraft.getMinecraft().fontRendererObj.drawString("Applicable", guiLeft+7, guiTop+7, 0x404040, false);
- Minecraft.getMinecraft().fontRendererObj.drawString("Removable", guiLeft+247, guiTop+7, 0x404040, false);
-
- //Page Text
- if(currentState == EnchantState.HAS_ITEM || currentState == EnchantState.ADDING_ENCHANT) {
- String pageStr = "Page: "+currentPage+"/"+expectedMaxPage;
- int pageStrLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(pageStr);
- Utils.drawStringCentered(pageStr, Minecraft.getMinecraft().fontRendererObj,
- guiLeft+X_SIZE/2, guiTop+14, false, 0x404040);
-
- //Page Arrows
- Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(guiLeft+X_SIZE/2-pageStrLen/2-2-15, guiTop+6, 15, 15,
- 0, 15/512f, 372/512f, 387/512f, GL11.GL_NEAREST);
- Utils.drawTexturedRect(guiLeft+X_SIZE/2+pageStrLen/2+2, guiTop+6, 15, 15,
- 15/512f, 30/512f, 372/512f, 387/512f, GL11.GL_NEAREST);
- }
-
- //Settings Buttons
- Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
- GlStateManager.color(1, 1, 1, 1);
- //On Settings Button
- Utils.drawTexturedRect(guiLeft+295, guiTop+147, 16, 16,
- 0, 16/512f, 387/512f, (387+16)/512f, GL11.GL_NEAREST);
- //Incompatible Settings Button
- float incompatibleMinU = NotEnoughUpdates.INSTANCE.config.enchantingSolvers.incompatibleEnchants*16/512f;
- Utils.drawTexturedRect(guiLeft+295+18, guiTop+147, 16, 16,
- incompatibleMinU, incompatibleMinU+16/512f, 403/512f, (403+16)/512f, GL11.GL_NEAREST);
- //Sorting Settings Button
- float sortingMinU = NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enchantSorting*16/512f;
- Utils.drawTexturedRect(guiLeft+295, guiTop+147+18, 16, 16,
- sortingMinU, sortingMinU+16/512f, 419/512f, (419+16)/512f, GL11.GL_NEAREST);
- //Ordering Settings Button
- float orderingMinU = NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enchantOrdering*16/512f;
- Utils.drawTexturedRect(guiLeft+295+18, guiTop+147+18, 16, 16,
- orderingMinU, orderingMinU+16/512f, 435/512f, (435+16)/512f, GL11.GL_NEAREST);
-
- if(mouseX >= guiLeft+294 && mouseX < guiLeft+294+36 &&
- mouseY >= guiTop+146 && mouseY < guiTop+146+36) {
- int index = (mouseX-(guiLeft+295))/18 + (mouseY-(guiTop+147))/18*2;
- switch (index) {
- case 0:
- Gui.drawRect(guiLeft+295, guiTop+147, guiLeft+295+16, guiTop+147+16, 0x80ffffff);
- tooltipToDisplay = createTooltip("Enable GUI", 0, "On", "Off");
- break;
- case 1:
- Gui.drawRect(guiLeft+295+18, guiTop+147, guiLeft+295+16+18, guiTop+147+16, 0x80ffffff);
+ private static final GuiCustomEnchant INSTANCE = new GuiCustomEnchant();
+ private static final ResourceLocation TEXTURE = new ResourceLocation("notenoughupdates:custom_enchant_gui.png");
+ private static final ResourceLocation ENCHANTMENT_TABLE_BOOK_TEXTURE = new ResourceLocation(
+ "textures/entity/enchanting_table_book.png");
+ private static final ModelBook MODEL_BOOK = new ModelBook();
+
+ private static final int EXPERIENCE_ORB_COUNT = 30;
+
+ private static final Pattern XP_COST_PATTERN = Pattern.compile("\\u00a73(\\d+) Exp Levels");
+
+ private enum EnchantState {
+ NO_ITEM,
+ ADDING_ENCHANT,
+ SWITCHING_DONT_UPDATE,
+ INVALID_ITEM,
+ HAS_ITEM
+ }
+
+ private class Enchantment {
+ public int slotIndex;
+ public String enchantName;
+ public String enchId;
+ public List<String> displayLore;
+ public int level;
+ public int xpCost = -1;
+ public boolean overMaxLevel = false;
+ public boolean conflicts = false;
+
+ public Enchantment(
+ int slotIndex, String enchantName, String enchId, List<String> displayLore, int level,
+ boolean useMaxLevelForCost, boolean checkConflicts
+ ) {
+ this.slotIndex = slotIndex;
+ this.enchantName = enchantName;
+ this.enchId = enchId;
+ this.displayLore = displayLore;
+ this.level = level;
+
+ if (Constants.ENCHANTS != null) {
+ if (checkConflicts && Constants.ENCHANTS.has("enchant_pools")) {
+ JsonArray pools = Constants.ENCHANTS.getAsJsonArray("enchant_pools");
+ out:
+ for (int i = 0; i < pools.size(); i++) {
+ JsonArray pool = pools.get(i).getAsJsonArray();
+
+ boolean hasThis = false;
+ boolean hasApplied = false;
+
+ for (int j = 0; j < pool.size(); j++) {
+ String enchIdPoolElement = pool.get(j).getAsString();
+ if (enchId.equalsIgnoreCase(enchIdPoolElement)) {
+ hasThis = true;
+ } else if (playerEnchantIds.containsKey(enchIdPoolElement)) {
+ hasApplied = true;
+ }
+ if (hasThis && hasApplied) {
+ this.conflicts = true;
+ break out;
+ }
+ }
+ }
+ }
+
+ if (level >= 1 && Constants.ENCHANTS.has("enchants_xp_cost")) {
+ JsonObject allCosts = Constants.ENCHANTS.getAsJsonObject("enchants_xp_cost");
+ if (allCosts.has(enchId)) {
+ JsonArray costs = allCosts.getAsJsonArray(enchId);
+
+ if (costs.size() >= 1) {
+ if (useMaxLevelForCost) {
+ this.xpCost = costs.get(costs.size() - 1).getAsInt();
+ } else if (level - 1 < costs.size()) {
+ this.xpCost = costs.get(level - 1).getAsInt();
+ } else {
+ overMaxLevel = true;
+ }
+ }
+ }
+
+ }
+ }
+ }
+ }
+
+ public static class ExperienceOrb {
+ public float x;
+ public float y;
+ public float xLast;
+ public float yLast;
+ public float xVel;
+ public float yVel;
+
+ public int type;
+ public int rotationDeg;
+ }
+
+ private final List<ExperienceOrb> orbs = new ArrayList<>();
+ private int orbTargetX = 0;
+ private int orbTargetY = 0;
+
+ private int guiLeft;
+ private int guiTop;
+ private boolean shouldOverrideFast = false;
+
+ public float pageOpen;
+ public float pageOpenLast;
+ public float pageOpenRandom;
+ public float pageOpenVelocity;
+ public float bookOpen;
+ public float bookOpenLast;
+
+ private int currentPage;
+ private int expectedMaxPage;
+
+ private boolean isScrollingLeft = true;
+
+ private ItemStack enchantingItem = null;
+
+ private int removingEnchantPlayerLevel = -1;
+
+ private final GuiElementTextField searchField = new GuiElementTextField("", GuiElementTextField.SCISSOR_TEXT);
+
+ private final HashMap<String, Integer> playerEnchantIds = new HashMap<>();
+
+ private boolean searchRemovedFromApplicable = false;
+ private boolean searchRemovedFromRemovable = false;
+ private final List<Enchantment> applicable = new ArrayList<>();
+ private final List<Enchantment> removable = new ArrayList<>();
+
+ private final HashMap<Integer, Enchantment> enchanterEnchLevels = new HashMap<>();
+ private Enchantment enchanterCurrentEnch = null;
+
+ public Random random = new Random();
+
+ private EnchantState currentState = EnchantState.NO_ITEM;
+ private EnchantState lastState = EnchantState.NO_ITEM;
+
+ private final LerpingInteger leftScroll = new LerpingInteger(0, 150);
+ private final LerpingInteger rightScroll = new LerpingInteger(0, 150);
+
+ private final LerpingFloat arrowAmount = new LerpingFloat(0, 100);
+
+ private static final int X_SIZE = 364;
+ private static final int Y_SIZE = 215;
+
+ private int clickedScrollOffset = -1;
+ private boolean isClickedScrollLeft = true;
+
+ private boolean isChangingEnchLevel = false;
+
+ private long cancelButtonAnimTime = 0;
+ private long confirmButtonAnimTime = 0;
+
+ public static GuiCustomEnchant getInstance() {
+ return INSTANCE;
+ }
+
+ public boolean shouldOverride(String containerName) {
+ shouldOverrideFast = NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enableTableGUI &&
+ Objects.equals("Enchant Item", containerName) &&
+ NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard();
+ if (!shouldOverrideFast) {
+ currentState = EnchantState.NO_ITEM;
+ applicable.clear();
+ removable.clear();
+ expectedMaxPage = 1;
+ }
+ return shouldOverrideFast;
+ }
+
+ private int tickCounter = 0;
+
+ public void tick() {
+ GuiContainer chest = ((GuiContainer) Minecraft.getMinecraft().currentScreen);
+ ContainerChest cc = (ContainerChest) chest.inventorySlots;
+
+ ItemStack stack = cc.getLowerChestInventory().getStackInSlot(23);
+ ItemStack enchantGuideStack = cc.getLowerChestInventory().getStackInSlot(50);
+ ItemStack enchantingItemStack = cc.getLowerChestInventory().getStackInSlot(19);
+
+ int lastPage = currentPage;
+
+ this.lastState = currentState;
+ if (enchantGuideStack != null && enchantGuideStack.getItem() != Items.book && enchantingItem != null) {
+ currentState = EnchantState.ADDING_ENCHANT;
+ } else if (stack == null || enchantingItemStack == null) {
+ if (currentState == EnchantState.SWITCHING_DONT_UPDATE || currentState == EnchantState.NO_ITEM) {
+ currentState = EnchantState.NO_ITEM;
+ } else {
+ currentState = EnchantState.SWITCHING_DONT_UPDATE;
+ }
+ } else if (stack.getItem() != Items.dye) {
+ ItemStack sanityCheckStack = cc.getLowerChestInventory().getStackInSlot(12);
+ if (sanityCheckStack == null || sanityCheckStack.getItem() == Items.enchanted_book) {
+ currentState = EnchantState.HAS_ITEM;
+ enchantingItem = enchantingItemStack;
+ } else {
+ currentState = EnchantState.SWITCHING_DONT_UPDATE;
+ }
+ } else if (stack.getItemDamage() == 1) {
+ currentState = EnchantState.INVALID_ITEM;
+ } else {
+ currentState = EnchantState.NO_ITEM;
+ }
+
+ if (currentState == EnchantState.HAS_ITEM) {
+ ItemStack pageUpStack = cc.getLowerChestInventory().getStackInSlot(17);
+ ItemStack pageDownStack = cc.getLowerChestInventory().getStackInSlot(35);
+ if (pageUpStack != null && pageDownStack != null) {
+ currentPage = 0;
+ boolean upIsGlass = pageUpStack.getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane);
+ boolean downIsGlass = pageDownStack.getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane);
+ int page = -1;
+
+ expectedMaxPage = 1;
+ if (!downIsGlass) {
+ try {
+ page = Integer.parseInt(Utils.getRawTooltip(pageDownStack).get(1).substring(11)) - 1;
+ expectedMaxPage = page + 1;
+ } catch (Exception ignored) {
+ }
+ }
+ if (page == -1 && !upIsGlass) {
+ try {
+ page = Integer.parseInt(Utils.getRawTooltip(pageUpStack).get(1).substring(11)) + 1;
+ expectedMaxPage = page;
+ } catch (Exception ignored) {
+ }
+ }
+ if (page == -1) {
+ currentPage = 1;
+ } else {
+ currentPage = page;
+ }
+ }
+ }
+
+ List<ExperienceOrb> toRemove = new ArrayList<>();
+ for (ExperienceOrb orb : orbs) {
+ float targetDeltaX = guiLeft + orbTargetX - orb.x;
+ float targetDeltaY = guiTop + orbTargetY - orb.y;
+
+ float length = (float) Math.sqrt(targetDeltaX * targetDeltaX + targetDeltaY * targetDeltaY);
+
+ if (length < 8 && orb.xVel * orb.xVel + orb.yVel * orb.yVel < 20) {
+ toRemove.add(orb);
+ continue;
+ }
+
+ orb.xVel += targetDeltaX * 2 / length;
+ orb.yVel += targetDeltaY * 2 / length;
+
+ orb.xVel *= 0.90;
+ orb.yVel *= 0.90;
+
+ orb.xLast = orb.x;
+ orb.yLast = orb.y;
+ orb.x += orb.xVel;
+ orb.y += orb.yVel;
+ }
+ orbs.removeAll(toRemove);
+
+ if (++tickCounter >= 20) {
+ tickCounter = 0;
+ }
+
+ boolean updateItems = tickCounter == 0;
+
+ if (currentState == EnchantState.ADDING_ENCHANT) {
+ if (arrowAmount.getTarget() != 1) {
+ arrowAmount.setTarget(1);
+ arrowAmount.resetTimer();
+ }
+ } else {
+ if (arrowAmount.getTarget() != 0) {
+ arrowAmount.setTarget(0);
+ arrowAmount.resetTimer();
+ }
+ }
+
+ // Set<EnchantState> allowedSwitchStates = Sets.newHashSet(EnchantState.ADDING_ENCHANT, EnchantState.HAS_ITEM, EnchantState.SWITCHING_DONT_UPDATE);
+ if (lastState != currentState || lastPage != currentPage) {
+ // if (!allowedSwitchStates.contains(lastState) || !allowedSwitchStates.contains(currentState)) {
+ leftScroll.setValue(0);
+ rightScroll.setValue(0);
+ // }
+ updateItems = true;
+ }
+
+ if (updateItems && currentState != EnchantState.SWITCHING_DONT_UPDATE) {
+ enchanterEnchLevels.clear();
+
+ if (enchantingItem != null) {
+ playerEnchantIds.clear();
+ NBTTagCompound tag = enchantingItem.getTagCompound();
+ if (tag != null) {
+ NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
+ if (ea != null) {
+ NBTTagCompound enchantments = ea.getCompoundTag("enchantments");
+ if (enchantments != null) {
+ for (String enchId : enchantments.getKeySet()) {
+ playerEnchantIds.put(enchId, enchantments.getInteger(enchId));
+ }
+ }
+ }
+ }
+ }
+
+ if (currentState == EnchantState.ADDING_ENCHANT) {
+ removingEnchantPlayerLevel = -1;
+ boolean updateLevel = enchanterCurrentEnch == null;
+ for (int i = 0; i < 27; i++) {
+ int slotIndex = 9 + i;
+ ItemStack book = cc.getLowerChestInventory().getStackInSlot(slotIndex);
+ if (book != null && book.getItem() == Items.enchanted_book) {
+ NBTTagCompound tagBook = book.getTagCompound();
+ if (tagBook != null) {
+ NBTTagCompound ea = tagBook.getCompoundTag("ExtraAttributes");
+ if (ea != null) {
+ NBTTagCompound enchantments = ea.getCompoundTag("enchantments");
+ if (enchantments != null) {
+ for (String enchId : enchantments.getKeySet()) {
+ String name = Utils.cleanColour(book.getDisplayName());
+ if (name.equalsIgnoreCase("Bane of Arthropods")) {
+ name = "Bane of Arth.";
+ } else if (name.equalsIgnoreCase("Projectile Protection")) {
+ name = "Projectile Prot";
+ } else if (name.equalsIgnoreCase("Blast Protection")) {
+ name = "Blast Prot";
+ }
+ Enchantment enchantment = new Enchantment(slotIndex, name, enchId,
+ Utils.getRawTooltip(book), enchantments.getInteger(enchId), false, true
+ );
+ enchantment.displayLore.remove(0);
+
+ if (removingEnchantPlayerLevel == -1 && playerEnchantIds.containsKey(enchId)) {
+ removingEnchantPlayerLevel = playerEnchantIds.get(enchId);
+ }
+
+ if (removingEnchantPlayerLevel >= 0 && enchantment.level < removingEnchantPlayerLevel) {
+ continue;
+ }
+
+ if (enchanterCurrentEnch == null) {
+ enchanterCurrentEnch = enchantment;
+ } else if (updateLevel) {
+ if (removingEnchantPlayerLevel < 0 && enchantment.level > enchanterCurrentEnch.level) {
+ enchanterCurrentEnch = enchantment;
+ } else if (removingEnchantPlayerLevel >= 0 && enchantment.level < enchanterCurrentEnch.level) {
+ enchanterCurrentEnch = enchantment;
+ }
+ }
+
+ enchanterEnchLevels.put(enchantment.level, enchantment);
+ }
+ }
+ }
+ }
+ }
+ }
+ if (enchanterCurrentEnch != null && removingEnchantPlayerLevel >= 0) {
+ for (String line : enchanterCurrentEnch.displayLore) {
+ Matcher matcher = XP_COST_PATTERN.matcher(line);
+ if (matcher.find()) {
+ enchanterCurrentEnch.xpCost = Integer.parseInt(matcher.group(1));
+ }
+ }
+ }
+ } else {
+ isChangingEnchLevel = false;
+ enchanterCurrentEnch = null;
+
+ searchRemovedFromRemovable = false;
+ searchRemovedFromApplicable = false;
+ applicable.clear();
+ removable.clear();
+ if (currentState == EnchantState.HAS_ITEM) {
+ for (int i = 0; i < 15; i++) {
+ int slotIndex = 12 + (i % 5) + (i / 5) * 9;
+ ItemStack book = cc.getLowerChestInventory().getStackInSlot(slotIndex);
+ if (book != null) {
+ NBTTagCompound tagBook = book.getTagCompound();
+ if (tagBook != null) {
+ NBTTagCompound ea = tagBook.getCompoundTag("ExtraAttributes");
+ if (ea != null) {
+ NBTTagCompound enchantments = ea.getCompoundTag("enchantments");
+ if (enchantments != null) {
+ for (String enchId : enchantments.getKeySet()) {
+ String name = Utils.cleanColour(book.getDisplayName());
+
+ if (searchField.getText().trim().isEmpty() ||
+ name.toLowerCase().contains(searchField.getText().trim().toLowerCase())) {
+ if (name.equalsIgnoreCase("Bane of Arthropods")) {
+ name = "Bane of Arth.";
+ } else if (name.equalsIgnoreCase("Projectile Protection")) {
+ name = "Projectile Prot";
+ } else if (name.equalsIgnoreCase("Blast Protection")) {
+ name = "Blast Prot";
+ } else if (name.equalsIgnoreCase("Luck of the Sea")) {
+ name = "Luck of Sea";
+ }
+
+ if (playerEnchantIds.containsKey(enchId)) {
+ Enchantment enchantment = new Enchantment(slotIndex, name, enchId,
+ Utils.getRawTooltip(book), playerEnchantIds.get(enchId), false, false
+ );
+ if (!enchantment.overMaxLevel) {
+ removable.add(enchantment);
+ }
+ } else {
+ Enchantment enchantment = new Enchantment(slotIndex, name, enchId,
+ Utils.getRawTooltip(book), enchantments.getInteger(enchId), true, true
+ );
+ applicable.add(enchantment);
+ }
+ } else {
+ if (playerEnchantIds.containsKey(enchId)) {
+ searchRemovedFromRemovable = true;
+ } else {
+ searchRemovedFromApplicable = true;
+ }
+ }
+
+ }
+ }
+ }
+ }
+ }
+ }
+ NEUConfig cfg = NotEnoughUpdates.INSTANCE.config;
+ int mult = cfg.enchantingSolvers.enchantOrdering == 0 ? 1 : -1;
+ Comparator<Enchantment> comparator = cfg.enchantingSolvers.enchantSorting == 0 ?
+ Comparator.comparingInt(e -> mult * e.xpCost) :
+ (c1, c2) -> mult *
+ c1.enchId.toLowerCase().compareTo(c2.enchId.toLowerCase());
+ removable.sort(comparator);
+ applicable.sort(comparator);
+ }
+ }
+ }
+
+ //Update book model state
+ if (lastState != currentState) {
+ while (true) {
+ this.pageOpenRandom += (float) (this.random.nextInt(4) - this.random.nextInt(4));
+
+ if (this.pageOpen > this.pageOpenRandom + 1.0F || this.pageOpen < this.pageOpenRandom - 1.0F) {
+ break;
+ }
+ }
+ }
+
+ this.pageOpenLast = this.pageOpen;
+ this.bookOpenLast = this.bookOpen;
+
+ if (currentState == EnchantState.HAS_ITEM || currentState == EnchantState.ADDING_ENCHANT) {
+ this.bookOpen += 0.2F;
+ } else {
+ this.bookOpen -= 0.2F;
+ }
+
+ this.bookOpen = MathHelper.clamp_float(this.bookOpen, 0.0F, 1.0F);
+ float f1 = (this.pageOpenRandom - this.pageOpen) * 0.4F;
+ f1 = MathHelper.clamp_float(f1, -0.2F, 0.2F);
+ this.pageOpenVelocity += (f1 - this.pageOpenVelocity) * 0.9F;
+ this.pageOpen += this.pageOpenVelocity;
+ }
+
+ private List<String> createTooltip(String title, int selectedOption, String... options) {
+ String selPrefix = EnumChatFormatting.DARK_AQUA + " \u25b6 ";
+ String unselPrefix = EnumChatFormatting.GRAY.toString();
+
+ for (int i = 0; i < options.length; i++) {
+ if (i == selectedOption) {
+ options[i] = selPrefix + options[i];
+ } else {
+ options[i] = unselPrefix + options[i];
+ }
+ }
+
+ List<String> list = Lists.newArrayList(options);
+ list.add(0, "");
+ list.add(0, EnumChatFormatting.GREEN + title);
+ return list;
+ }
+
+ public void render(float partialTicks) {
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) return;
+
+ long currentTime = System.currentTimeMillis();
+ int playerXpLevel = Minecraft.getMinecraft().thePlayer.experienceLevel;
+
+ GuiContainer chest = ((GuiContainer) Minecraft.getMinecraft().currentScreen);
+ ContainerChest cc = (ContainerChest) chest.inventorySlots;
+
+ leftScroll.tick();
+ rightScroll.tick();
+ arrowAmount.tick();
+
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ int width = scaledResolution.getScaledWidth();
+ int height = scaledResolution.getScaledHeight();
+ int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
+ int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
+
+ guiLeft = (width - X_SIZE) / 2;
+ guiTop = (height - Y_SIZE) / 2;
+
+ List<String> tooltipToDisplay = null;
+ boolean disallowClick = false;
+ ItemStack stackOnMouse = Minecraft.getMinecraft().thePlayer.inventory.getItemStack();
+ int itemHoverX = -1;
+ int itemHoverY = -1;
+ boolean hoverLocked = false;
+
+ drawGradientRect(0, 0, width, height, 0xc0101010, 0xd0101010);
+
+ //Base Texture
+ Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(guiLeft, guiTop, X_SIZE, Y_SIZE,
+ 0, X_SIZE / 512f, 0, Y_SIZE / 512f, GL11.GL_NEAREST
+ );
+
+ Minecraft.getMinecraft().fontRendererObj.drawString("Applicable", guiLeft + 7, guiTop + 7, 0x404040, false);
+ Minecraft.getMinecraft().fontRendererObj.drawString("Removable", guiLeft + 247, guiTop + 7, 0x404040, false);
+
+ //Page Text
+ if (currentState == EnchantState.HAS_ITEM || currentState == EnchantState.ADDING_ENCHANT) {
+ String pageStr = "Page: " + currentPage + "/" + expectedMaxPage;
+ int pageStrLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(pageStr);
+ Utils.drawStringCentered(pageStr, Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + X_SIZE / 2, guiTop + 14, false, 0x404040
+ );
+
+ //Page Arrows
+ Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(guiLeft + X_SIZE / 2 - pageStrLen / 2 - 2 - 15, guiTop + 6, 15, 15,
+ 0, 15 / 512f, 372 / 512f, 387 / 512f, GL11.GL_NEAREST
+ );
+ Utils.drawTexturedRect(guiLeft + X_SIZE / 2 + pageStrLen / 2 + 2, guiTop + 6, 15, 15,
+ 15 / 512f, 30 / 512f, 372 / 512f, 387 / 512f, GL11.GL_NEAREST
+ );
+ }
+
+ //Settings Buttons
+ Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
+ GlStateManager.color(1, 1, 1, 1);
+ //On Settings Button
+ Utils.drawTexturedRect(guiLeft + 295, guiTop + 147, 16, 16,
+ 0, 16 / 512f, 387 / 512f, (387 + 16) / 512f, GL11.GL_NEAREST
+ );
+ //Incompatible Settings Button
+ /*float incompatibleMinU = NotEnoughUpdates.INSTANCE.config.enchantingSolvers.incompatibleEnchants * 16 / 512f;
+ Utils.drawTexturedRect(guiLeft + 295 + 18, guiTop + 147, 16, 16,
+ incompatibleMinU, incompatibleMinU + 16 / 512f, 403 / 512f, (403 + 16) / 512f, GL11.GL_NEAREST);*/
+ //Sorting Settings Button
+ float sortingMinU = NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enchantSorting * 16 / 512f;
+ Utils.drawTexturedRect(guiLeft + 295, guiTop + 147 + 18, 16, 16,
+ sortingMinU, sortingMinU + 16 / 512f, 419 / 512f, (419 + 16) / 512f, GL11.GL_NEAREST
+ );
+ //Ordering Settings Button
+ float orderingMinU = NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enchantOrdering * 16 / 512f;
+ Utils.drawTexturedRect(guiLeft + 295 + 18, guiTop + 147 + 18, 16, 16,
+ orderingMinU, orderingMinU + 16 / 512f, 435 / 512f, (435 + 16) / 512f, GL11.GL_NEAREST
+ );
+
+ if (mouseX >= guiLeft + 294 && mouseX < guiLeft + 294 + 36 &&
+ mouseY >= guiTop + 146 && mouseY < guiTop + 146 + 36) {
+ int index = (mouseX - (guiLeft + 295)) / 18 + (mouseY - (guiTop + 147)) / 18 * 2;
+ switch (index) {
+ case 0:
+ Gui.drawRect(guiLeft + 295, guiTop + 147, guiLeft + 295 + 16, guiTop + 147 + 16, 0x80ffffff);
+ tooltipToDisplay = createTooltip("Enable GUI", 0, "On", "Off");
+ break;
+ /*case 1:
+ Gui.drawRect(guiLeft + 295 + 18, guiTop + 147, guiLeft + 295 + 16 + 18, guiTop + 147 + 16, 0x80ffffff);
tooltipToDisplay = createTooltip("Incompatible Enchants",
NotEnoughUpdates.INSTANCE.config.enchantingSolvers.incompatibleEnchants,
"Highlight", "Hide");
- tooltipToDisplay.add(1, EnumChatFormatting.GRAY+"How to display enchants that are");
- tooltipToDisplay.add(2, EnumChatFormatting.GRAY+"incompatible with your current item,");
- tooltipToDisplay.add(3, EnumChatFormatting.GRAY+"eg. Smite on a sword with Sharpness");
- break;
- case 2:
- Gui.drawRect(guiLeft+295, guiTop+147+18, guiLeft+295+16, guiTop+147+16+18, 0x80ffffff);
- tooltipToDisplay = createTooltip("Sort enchants...",
- NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enchantSorting,
- "By Cost", "Alphabetically");
- break;
- case 3:
- Gui.drawRect(guiLeft+295+18, guiTop+147+18, guiLeft+295+16+18, guiTop+147+16+18, 0x80ffffff);
- tooltipToDisplay = createTooltip("Order enchants...",
- NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enchantOrdering,
- "Ascending", "Descending");
- break;
- }
- }
-
- //Left scroll bar
- {
- int offset;
- if(applicable.size() <= 6) {
- offset = 0;
- } else if(isScrollingLeft && clickedScrollOffset >= 0) {
- offset = mouseY - clickedScrollOffset;
- if(offset < 0) offset = 0;
- if(offset > 96-15) offset = 96-15;
- } else {
- offset = Math.round((96-15) * (leftScroll.getValue() / (float)((applicable.size()-6)*16)));
- }
- Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(guiLeft+104, guiTop+18+offset, 12, 15,
- 0, 12/512f, 313/512f, (313+15)/512f, GL11.GL_NEAREST);
- }
- //Right scroll bar
- {
- int offset;
- if(removable.size() <= 6) {
- offset = 0;
- } else if(!isScrollingLeft && clickedScrollOffset >= 0) {
- offset = mouseY - clickedScrollOffset;
- if(offset < 0) offset = 0;
- if(offset > 96-15) offset = 96-15;
- } else {
- offset = Math.round((96-15) * (rightScroll.getValue() / (float)((removable.size()-6)*16)));
- }
- Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(guiLeft+344, guiTop+18+offset, 12, 15,
- 0, 12/512f, 313/512f, (313+15)/512f, GL11.GL_NEAREST);
- }
-
- //Enchant book model
- renderEnchantBook(scaledResolution, partialTicks);
-
- //Can't be enchanted text
- if(currentState == EnchantState.INVALID_ITEM) {
- GlStateManager.disableDepth();
- Utils.drawStringCentered("This item can't", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+X_SIZE/2, guiTop+88, true, 0xffff5555);
- Utils.drawStringCentered("be enchanted", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+X_SIZE/2, guiTop+98, true, 0xffff5555);
- GlStateManager.enableDepth();
- }
-
- //Enchant arrow
- if(arrowAmount.getValue() > 0) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
- GlStateManager.color(1, 1, 1, 1);
- float w = 22 * arrowAmount.getValue();
- if(removingEnchantPlayerLevel < 0) {
- Utils.drawTexturedRect(guiLeft+134, guiTop+58, w, 16,
- 0, w/512f, 297/512f, (297+16)/512f, GL11.GL_NEAREST);
- } else {
- Utils.drawTexturedRect(guiLeft+230-w, guiTop+58, w, 16,
- (44-w)/512f, 44/512f, 297/512f, (297+16)/512f, GL11.GL_NEAREST);
- }
- }
-
- //Text if no enchants appear
- if(currentState == EnchantState.HAS_ITEM || currentState == EnchantState.ADDING_ENCHANT) {
- if(applicable.isEmpty() && removable.isEmpty() && searchRemovedFromApplicable) {
- Utils.drawStringCentered("Can't find that", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+8+48, guiTop+28, true, 0xffff5555);
- Utils.drawStringCentered("enchant, perhaps", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+8+48, guiTop+38, true, 0xffff5555);
- Utils.drawStringCentered("it is on", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+8+48, guiTop+48, true, 0xffff5555);
- Utils.drawStringCentered("another page?", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+8+48, guiTop+58, true, 0xffff5555);
- } else if(applicable.isEmpty() && !searchRemovedFromApplicable) {
- Utils.drawStringCentered("No applicable", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+8+48, guiTop+28, true, 0xffff5555);
- Utils.drawStringCentered("enchants on", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+8+48, guiTop+38, true, 0xffff5555);
- Utils.drawStringCentered("this page...", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+8+48, guiTop+48, true, 0xffff5555);
- }
- if(applicable.isEmpty() && removable.isEmpty() && searchRemovedFromRemovable) {
- Utils.drawStringCentered("Can't find that", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+248+48, guiTop+28, true, 0xffff5555);
- Utils.drawStringCentered("enchant, perhaps", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+248+48, guiTop+38, true, 0xffff5555);
- Utils.drawStringCentered("it is on", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+248+48, guiTop+48, true, 0xffff5555);
- Utils.drawStringCentered("another page?", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+248+48, guiTop+58, true, 0xffff5555);
- } else if(removable.isEmpty() && !searchRemovedFromRemovable) {
- Utils.drawStringCentered("No removable", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+248+48, guiTop+28, true, 0xffff5555);
- Utils.drawStringCentered("enchants on", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+248+48, guiTop+38, true, 0xffff5555);
- Utils.drawStringCentered("this page...", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+248+48, guiTop+48, true, 0xffff5555);
- }
- }
- //Available enchants (left)
- GlScissorStack.push(0, guiTop+18, width, guiTop+18+96, scaledResolution);
- for(int i=0; i<7; i++) {
- int index = i + leftScroll.getValue()/16;
-
- if(applicable.size() <= index) break;
- Enchantment ench = applicable.get(index);
-
- int top = guiTop-(leftScroll.getValue()%16)+18+16*i;
- int vOffset = enchanterCurrentEnch != null && enchanterCurrentEnch.enchId.equals(ench.enchId) ? 16 : 0;
- int uOffset = ench.conflicts ? 112 : 0;
- int textOffset = vOffset/16;
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(guiLeft+8, top, 96, 16,
- uOffset/512f, (96+uOffset)/512f, (249+vOffset)/512f, (249+16+vOffset)/512f, GL11.GL_NEAREST);
-
- if(mouseX > guiLeft+8 && mouseX <= guiLeft+8+96 &&
- mouseY > top && mouseY <= top+16) {
- disallowClick = true;
- if(ench.displayLore != null) {
- tooltipToDisplay = ench.displayLore;
- }
- }
-
- String levelStr = ""+ench.xpCost;
- int colour = 0xc8ff8f;
- if(ench.xpCost > playerXpLevel) {
- colour = 0xff5555;
- }
-
- int levelWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(levelStr);
- Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, guiLeft+16-levelWidth/2-1, top+4, 0x2d2102, false);
- Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, guiLeft+16-levelWidth/2+1, top+4, 0x2d2102, false);
- Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, guiLeft+16-levelWidth/2, top+4-1, 0x2d2102, false);
- Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, guiLeft+16-levelWidth/2, top+4+1, 0x2d2102, false);
- Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, guiLeft+16-levelWidth/2, top+4, colour, false);
-
- Minecraft.getMinecraft().fontRendererObj.drawString(ench.enchantName, guiLeft+8+16+2+textOffset, top+4+textOffset, 0xffffffdd, true);
- }
- GlScissorStack.pop(scaledResolution);
-
- //Removable enchants (right)
- GlScissorStack.push(0, guiTop+18, width, guiTop+18+96, scaledResolution);
- for(int i=0; i<7; i++) {
- int index = i + rightScroll.getValue()/16;
-
- if(removable.size() <= index) break;
- Enchantment ench = removable.get(index);
-
- int top = guiTop-(rightScroll.getValue()%16)+18+16*i;
- int vOffset = enchanterCurrentEnch != null && enchanterCurrentEnch.enchId.equals(ench.enchId) ? 16 : 0;
- int textOffset = vOffset/16;
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(guiLeft+248, top, 96, 16,
- 0, 96/512f, (249+vOffset)/512f, (249+16+vOffset)/512f, GL11.GL_NEAREST);
-
- if(mouseX > guiLeft+248 && mouseX <= guiLeft+248+96 &&
- mouseY > top && mouseY <= top+16) {
- disallowClick = true;
- if(ench.displayLore != null) {
- tooltipToDisplay = ench.displayLore;
- }
- }
-
- String levelStr = ""+ench.xpCost;
- if(ench.xpCost < 0) levelStr = "?";
- int colour = 0xc8ff8f;
- if(ench.xpCost > playerXpLevel) {
- colour = 0xff5555;
- }
-
- int levelWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(levelStr);
- Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, guiLeft+256-levelWidth/2-1, top+4, 0x2d2102, false);
- Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, guiLeft+256-levelWidth/2+1, top+4, 0x2d2102, false);
- Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, guiLeft+256-levelWidth/2, top+4-1, 0x2d2102, false);
- Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, guiLeft+256-levelWidth/2, top+4+1, 0x2d2102, false);
- Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, guiLeft+256-levelWidth/2, top+4, colour, false);
-
- Minecraft.getMinecraft().fontRendererObj.drawString(ench.enchantName,
- guiLeft+248+16+2+textOffset, top+4+textOffset, 0xffffffdd, true);
- }
- GlScissorStack.pop(scaledResolution);
-
- //Player Inventory Items
- Minecraft.getMinecraft().fontRendererObj.drawString(Minecraft.getMinecraft().thePlayer.inventory.getDisplayName().getUnformattedText(),
- guiLeft+102, guiTop+Y_SIZE - 96 + 2, 0x404040);
- int inventoryStartIndex = cc.getLowerChestInventory().getSizeInventory();
- GlStateManager.enableDepth();
- for(int i=0; i<36; i++) {
- int itemX = guiLeft+102+18*(i%9);
- int itemY = guiTop+133+18*(i/9);
-
- if(i >= 27) {
- itemY += 4;
- }
-
- GlStateManager.pushMatrix();
- GlStateManager.translate(guiLeft+102-8, guiTop+191-(inventoryStartIndex/9*18+89), 0);
- Slot slot = cc.getSlot(inventoryStartIndex+i);
- chest.drawSlot(slot);
- GlStateManager.popMatrix();
-
- if(mouseX >= itemX && mouseX < itemX+18 &&
- mouseY >= itemY && mouseY < itemY+18) {
- itemHoverX = itemX;
- itemHoverY = itemY;
- hoverLocked = SlotLocking.getInstance().isSlotLocked(slot);
-
- if(slot.getHasStack()) {
- tooltipToDisplay = slot.getStack().getTooltip(Minecraft.getMinecraft().thePlayer,
- Minecraft.getMinecraft().gameSettings.advancedItemTooltips);
- }
- }
- }
-
- //Search bar
- if(currentState == EnchantState.HAS_ITEM) {
- if(searchField.getText().isEmpty() && !searchField.getFocus()) {
- searchField.setSize(90, 14);
- searchField.setPrependText("\u00a77Search...");
- } else {
- if(searchField.getFocus()) {
- int len = Minecraft.getMinecraft().fontRendererObj.getStringWidth(searchField.getTextDisplay())+10;
- searchField.setSize(Math.max(90, len), 14);
- } else {
- searchField.setSize(90, 14);
- }
- searchField.setPrependText("");
- }
- searchField.render(guiLeft+X_SIZE/2-searchField.getWidth()/2, guiTop+83);
- } else if(currentState == EnchantState.ADDING_ENCHANT &&
- enchanterCurrentEnch != null && !enchanterEnchLevels.isEmpty()) {
- int left = guiLeft+X_SIZE/2-56;
- int top = guiTop+83;
-
- int uOffset = enchanterCurrentEnch.conflicts ? 112 : 0;
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(left, top, 112, 16,
- uOffset/512f, (112+uOffset)/512f, 249/512f, (249+16)/512f, GL11.GL_NEAREST);
-
- if(mouseX > left+16 && mouseX <= left+96 &&
- mouseY > top && mouseY <= top+16) {
- disallowClick = true;
- if(enchanterCurrentEnch.displayLore != null) {
- tooltipToDisplay = enchanterCurrentEnch.displayLore;
- }
- }
-
- //Enchant cost
- String levelStr = ""+enchanterCurrentEnch.xpCost;
- if(enchanterCurrentEnch.xpCost < 0) levelStr = "?";
-
- int colour = 0xc8ff8f;
- if(enchanterCurrentEnch.xpCost > playerXpLevel) {
- colour = 0xff5555;
- }
-
- int levelWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(levelStr);
- Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, left+8-levelWidth/2-1, top+4, 0x2d2102, false);
- Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, left+8-levelWidth/2+1, top+4, 0x2d2102, false);
- Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, left+8-levelWidth/2, top+4-1, 0x2d2102, false);
- Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, left+8-levelWidth/2, top+4+1, 0x2d2102, false);
- Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, left+8-levelWidth/2, top+4, colour, false);
-
- //Enchant name
- String name = WordUtils.capitalizeFully(enchanterCurrentEnch.enchId.replace("_", " "));
- if(name.equalsIgnoreCase("Bane of Arthropods")) {
- name = "Bane of Arth.";
- } else if(name.equalsIgnoreCase("Projectile Protection")) {
- name = "Projectile Prot";
- } else if(name.equalsIgnoreCase("Blast Protection")) {
- name = "Blast Prot";
- } else if(name.equalsIgnoreCase("Luck of the Sea")) {
- name = "Luck of Sea";
- }
- Utils.drawStringCentered(name, Minecraft.getMinecraft().fontRendererObj, guiLeft+X_SIZE/2, top+8, true, 0xffffffdd);
-
- if(isChangingEnchLevel) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(left+96, top, 16, 16,
- 96/512f, 112/512f, 265/512f, (265+16)/512f, GL11.GL_NEAREST);
- }
-
- //Enchant level
- levelStr = ""+enchanterCurrentEnch.level;
- if(enchanterCurrentEnch.xpCost < 0) levelStr = "?";
- levelWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(levelStr);
- Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, left+96+8-levelWidth/2-1, top+4, 0x2d2102, false);
- Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, left+96+8-levelWidth/2+1, top+4, 0x2d2102, false);
- Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, left+96+8-levelWidth/2, top+4-1, 0x2d2102, false);
- Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, left+96+8-levelWidth/2, top+4+1, 0x2d2102, false);
- Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, left+96+8-levelWidth/2, top+4, 0xea82ff, false);
-
- //Confirm button
-
- String confirmText = "Apply";
- if(removingEnchantPlayerLevel >= 0) {
- if(removingEnchantPlayerLevel == enchanterCurrentEnch.level) {
- confirmText = "Remove";
- } else if(enchanterCurrentEnch.level > removingEnchantPlayerLevel) {
- confirmText = "Upgrade";
- } else {
- confirmText = "Bad Level";
- }
- }
- if(System.currentTimeMillis() - confirmButtonAnimTime < 500 && !(playerXpLevel < enchanterCurrentEnch.xpCost)) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(guiLeft+X_SIZE/2-1-48, top+18, 48, 14,
- 0, 48/512f, 342/512f, (342+14)/512f, GL11.GL_NEAREST);
- Utils.drawStringCentered(confirmText, Minecraft.getMinecraft().fontRendererObj,
- guiLeft+X_SIZE/2-1-23, top+18+9, false, 0x408040);
- } else {
- Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(guiLeft+X_SIZE/2-1-48, top+18, 48, 14,
- 0, 48/512f, 328/512f, (328+14)/512f, GL11.GL_NEAREST);
- Utils.drawStringCentered(confirmText, Minecraft.getMinecraft().fontRendererObj,
- guiLeft+X_SIZE/2-1-24, top+18+8, false, 0x408040);
-
- if(playerXpLevel < enchanterCurrentEnch.xpCost) {
- Gui.drawRect(guiLeft+X_SIZE/2-1-48, top+18, guiLeft+X_SIZE/2-1, top+18+14, 0x80000000);
- }
- }
-
- //Cancel button
- if(System.currentTimeMillis() - cancelButtonAnimTime < 500) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(guiLeft+X_SIZE/2+1, top+18, 48, 14,
- 0, 48/512f, 342/512f, (342+14)/512f, GL11.GL_NEAREST);
- Utils.drawStringCentered("Cancel", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+X_SIZE/2+1+25, top+18+9, false, 0xa04040);
- } else {
- Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(guiLeft+X_SIZE/2+1, top+18, 48, 14,
- 0, 48/512f, 328/512f, (328+14)/512f, GL11.GL_NEAREST);
- Utils.drawStringCentered("Cancel", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+X_SIZE/2+1+24, top+18+8, false, 0xa04040);
- }
-
- if(mouseY > top+18 && mouseY <= top+18+16) {
- if(mouseX > guiLeft+X_SIZE/2-1-48 && mouseX <= guiLeft+X_SIZE/2-1) {
- disallowClick = true;
- if(enchanterCurrentEnch.displayLore != null) {
- tooltipToDisplay = enchanterCurrentEnch.displayLore;
- }
- } else if(mouseX > guiLeft+X_SIZE/2+1 && mouseX <= guiLeft+X_SIZE/2+1+48) {
- disallowClick = true;
- tooltipToDisplay = Lists.newArrayList("\u00a7cCancel");
- }
- }
-
- //Enchant level switcher
- if(isChangingEnchLevel) {
- tooltipToDisplay = null;
-
- List<Enchantment> before = new ArrayList<>();
- List<Enchantment> after = new ArrayList<>();
-
- for(Enchantment ench : enchanterEnchLevels.values()) {
- if(ench.level < enchanterCurrentEnch.level) {
- before.add(ench);
- } else if(ench.level > enchanterCurrentEnch.level) {
- after.add(ench);
- }
- }
-
- before.sort(Comparator.comparingInt(o -> -o.level));
- after.sort(Comparator.comparingInt(o -> o.level));
-
- int bSize = before.size();
- int aSize = after.size();
- GlStateManager.disableDepth();
- for(int i=0; i<bSize+aSize; i++) {
- Enchantment ench;
- int yIndex;
- if(i < bSize) {
- ench = before.get(i);
- yIndex = -i-1;
- } else {
- ench = after.get(i-bSize);
- yIndex = i-bSize+1;
- }
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
- GlStateManager.color(1, 1, 1, 1);
-
- int type = 0;
- if(i == bSize) {
- type = 2;
- } else if(i == 0) {
- type = 1;
- }
-
- if(mouseX > left+96 && mouseX <= left+96+16 &&
- mouseY > top+16*yIndex && mouseY <= top+16*yIndex+16) {
- tooltipToDisplay = new ArrayList<>(ench.displayLore);
- if(tooltipToDisplay.size() > 2) {
- tooltipToDisplay.remove(tooltipToDisplay.size()-1);
- tooltipToDisplay.remove(tooltipToDisplay.size()-1);
- }
- itemHoverX = -1;
- itemHoverY = -1;
- }
-
- Utils.drawTexturedRect(left+96, top+16*yIndex, 16, 16,
- 16*type/512f, (16+16*type)/512f, 356/512f, (356+16)/512f, GL11.GL_NEAREST);
-
- levelStr = ""+ench.level;
- levelWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(levelStr);
- Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, left+96+8-levelWidth/2-1, top+16*yIndex+4, 0x2d2102, false);
- Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, left+96+8-levelWidth/2+1, top+16*yIndex+4, 0x2d2102, false);
- Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, left+96+8-levelWidth/2, top+16*yIndex+4-1, 0x2d2102, false);
- Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, left+96+8-levelWidth/2, top+16*yIndex+4+1, 0x2d2102, false);
- Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, left+96+8-levelWidth/2, top+16*yIndex+4, 0xea82ff, false);
- }
- GlStateManager.enableDepth();
- }
-
- if(mouseX > left+96 && mouseX <= left+96+16 &&
- mouseY > top && mouseY <= top+16) {
- if(isChangingEnchLevel) {
- tooltipToDisplay = Lists.newArrayList("\u00a7cCancel level change");
- } else {
- tooltipToDisplay = Lists.newArrayList("\u00a7aChange enchant level");
- }
- }
- }
-
- //Item enchant input
- ItemStack itemEnchantInput = cc.getSlot(19).getStack();
- if(itemEnchantInput != null && itemEnchantInput.getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane)) {
- itemEnchantInput = enchantingItem;
- }
- {
- int itemX = guiLeft+174;
- int itemY = guiTop+58;
-
- if(itemEnchantInput == null) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(itemX, itemY, 16, 16,
- 0, 16/512f, 281/512f, (281+16)/512f, GL11.GL_NEAREST);
- } else {
- Utils.drawItemStack(itemEnchantInput, itemX, itemY);
- }
-
- if(mouseX >= itemX && mouseX < itemX+18 &&
- mouseY >= itemY && mouseY < itemY+18) {
- itemHoverX = itemX;
- itemHoverY = itemY;
-
- if(itemEnchantInput != null) {
- tooltipToDisplay = itemEnchantInput.getTooltip(Minecraft.getMinecraft().thePlayer,
- Minecraft.getMinecraft().gameSettings.advancedItemTooltips);
- }
- }
- }
-
- if(!isChangingEnchLevel && itemHoverX >= 0 && itemHoverY >= 0) {
- GlStateManager.disableDepth();
- GlStateManager.colorMask(true, true, true, false);
- Gui.drawRect(itemHoverX, itemHoverY, itemHoverX + 16, itemHoverY + 16,
- hoverLocked ? 0x80ff8080 : 0x80ffffff);
- GlStateManager.colorMask(true, true, true, true);
- GlStateManager.enableDepth();
- }
-
- GlStateManager.translate(0, 0, 300);
-
- //Orb animation
- Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
- GlStateManager.color(1, 1, 1, 1);
- GlStateManager.disableDepth();
- for(ExperienceOrb orb : orbs) {
- int orbX = Math.round(orb.xLast + (orb.x - orb.xLast) * partialTicks);
- int orbY = Math.round(orb.yLast + (orb.y - orb.yLast) * partialTicks);
- GlStateManager.pushMatrix();
- GlStateManager.translate(orbX, orbY, 0);
- GlStateManager.rotate(orb.rotationDeg, 0, 0, 1);
-
- float targetDeltaX = guiLeft+orbTargetX - orb.x;
- float targetDeltaY = guiTop+orbTargetY - orb.y;
- float length = (float)Math.sqrt(targetDeltaX*targetDeltaX + targetDeltaY*targetDeltaY);
- float velSq = orb.xVel*orb.xVel+orb.yVel*orb.yVel;
- float opacity = Math.min(2, Math.max(0.5f, length/16)) * Math.min(2, Math.max(0.5f, velSq/40));
- if(opacity > 1) opacity = 1;
- opacity = (float)Math.sqrt(opacity);
- GlStateManager.color(1, 1, 1, opacity);
-
- Utils.drawTexturedRect(-8, -8, 16, 16,
- ((orb.type%3)*16)/512f, (16+(orb.type%3)*16)/512f, (217+orb.type/3*16)/512f, (217+16+orb.type/3*16)/512f, GL11.GL_NEAREST);
- GlStateManager.popMatrix();
- }
- GlStateManager.enableDepth();
-
- if(stackOnMouse != null) {
- if(disallowClick) {
- Utils.drawItemStack(new ItemStack(Item.getItemFromBlock(Blocks.barrier)), mouseX - 8, mouseY - 8);
- } else {
- Utils.drawItemStack(stackOnMouse, mouseX - 8, mouseY - 8);
- }
- } else if(tooltipToDisplay != null) {
- Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1,
- Minecraft.getMinecraft().fontRendererObj);
- }
- GlStateManager.translate(0, 0, -300);
- }
-
- private void spawnExperienceOrbs(int startX, int startY, int targetX, int targetY, int baseType) {
- orbs.clear();
-
- this.orbTargetX = targetX;
- this.orbTargetY = targetY;
-
- Random rand = new Random();
- for(int i=0; i<EXPERIENCE_ORB_COUNT; i++) {
- ExperienceOrb orb = new ExperienceOrb();
- orb.x = startX;
- orb.y = startY;
- orb.xLast = startX;
- orb.yLast = startY;
- orb.xVel = rand.nextFloat()*20 - 10;
- orb.yVel = rand.nextFloat()*20 - 10;
- orb.type = baseType;
-
- float typeRand = rand.nextFloat();
- if(typeRand < 0.6) {
- orb.type += 0;
- } else if(typeRand < 0.9) {
- orb.type += 1;
- } else {
- orb.type += 2;
- }
- orb.rotationDeg = rand.nextInt(4)*90;
-
- orbs.add(orb);
- }
- }
-
- private void renderEnchantBook(ScaledResolution scaledresolution, float partialTicks) {
- GlStateManager.enableDepth();
-
- GlStateManager.pushMatrix();
- GlStateManager.matrixMode(5889);
- GlStateManager.pushMatrix();
- GlStateManager.loadIdentity();
- GlStateManager.viewport((scaledresolution.getScaledWidth() - 320) / 2 * scaledresolution.getScaleFactor(),
- (scaledresolution.getScaledHeight() - 240) / 2 * scaledresolution.getScaleFactor(),
- 320 * scaledresolution.getScaleFactor(), 240 * scaledresolution.getScaleFactor());
- GlStateManager.translate(0.0F, 0.33F, 0.0F);
- Project.gluPerspective(90.0F, 1.3333334F, 9.0F, 80.0F);
- GlStateManager.matrixMode(5888);
- GlStateManager.loadIdentity();
- RenderHelper.enableStandardItemLighting();
- GlStateManager.translate(0.0F, 3.3F, -16.0F);
- GlStateManager.scale(5, 5, 5);
- GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
- Minecraft.getMinecraft().getTextureManager().bindTexture(ENCHANTMENT_TABLE_BOOK_TEXTURE);
- GlStateManager.rotate(20.0F, 1.0F, 0.0F, 0.0F);
- float bookOpenAngle = this.bookOpenLast + (this.bookOpen - this.bookOpenLast) * partialTicks;
- GlStateManager.translate((1.0F - bookOpenAngle) * 0.2F, (1.0F - bookOpenAngle) * 0.1F, (1.0F - bookOpenAngle) * 0.25F);
- GlStateManager.rotate(-(1.0F - bookOpenAngle) * 90.0F - 90.0F, 0.0F, 1.0F, 0.0F);
- GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F);
- float pageAngle1 = this.pageOpenLast + (this.pageOpen - this.pageOpenLast) * partialTicks + 0.25F;
- float pageAngle2 = this.pageOpenLast + (this.pageOpen - this.pageOpenLast) * partialTicks + 0.75F;
- pageAngle1 = (pageAngle1 - (float) MathHelper.truncateDoubleToInt(pageAngle1)) * 1.6F - 0.3F;
- pageAngle2 = (pageAngle2 - (float)MathHelper.truncateDoubleToInt(pageAngle2)) * 1.6F - 0.3F;
-
- if (pageAngle1 < 0.0F) pageAngle1 = 0.0F;
- if (pageAngle1 > 1.0F) pageAngle1 = 1.0F;
- if (pageAngle2 < 0.0F) pageAngle2 = 0.0F;
- if (pageAngle2 > 1.0F) pageAngle2 = 1.0F;
-
- GlStateManager.enableRescaleNormal();
- MODEL_BOOK.render(null, 0.0F, pageAngle1, pageAngle2, bookOpenAngle, 0.0F, 0.0625F);
- GlStateManager.disableRescaleNormal();
- RenderHelper.disableStandardItemLighting();
- GlStateManager.matrixMode(5889);
- GlStateManager.viewport(0, 0, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight);
- GlStateManager.popMatrix();
- GlStateManager.matrixMode(5888);
- GlStateManager.popMatrix();
- RenderHelper.disableStandardItemLighting();
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
-
- GlStateManager.enableDepth();
- }
-
- public void overrideIsMouseOverSlot(Slot slot, int mouseX, int mouseY, CallbackInfoReturnable<Boolean> cir) {
- if(shouldOverrideFast && currentState != EnchantState.ADDING_ENCHANT) {
- boolean playerInv = slot.inventory == Minecraft.getMinecraft().thePlayer.inventory;
- int slotId = slot.getSlotIndex();
- if(playerInv && slotId < 36) {
- slotId -= 9;
- if(slotId < 0) slotId += 36;
-
- int itemX = guiLeft+102+18*(slotId%9);
- int itemY = guiTop+133+18*(slotId/9);
-
- if(slotId >= 27) {
- itemY += 4;
- }
-
- if(mouseX >= itemX && mouseX < itemX+18 &&
- mouseY >= itemY && mouseY < itemY+18) {
- cir.setReturnValue(true);
- } else {
- cir.setReturnValue(false);
- }
- } else if(slotId == 19) {
- cir.setReturnValue(mouseX >= guiLeft+173 && mouseX < guiLeft+173+18 &&
- mouseY >= guiTop+57 && mouseY < guiTop+57+18);
- }
- }
- }
-
- public boolean mouseInput(int mouseX, int mouseY) {
- if(Mouse.getEventButtonState() && (currentState == EnchantState.HAS_ITEM || currentState == EnchantState.ADDING_ENCHANT)) {
- if(mouseY > guiTop+6 && mouseY < guiTop+6+15) {
- String pageStr = "Page: "+currentPage+"/"+expectedMaxPage;
- int pageStrLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(pageStr);
-
- int click = -1;
- if(mouseX > guiLeft+X_SIZE/2-pageStrLen/2-2-15 && mouseX <= guiLeft+X_SIZE/2-pageStrLen/2-2) {
- click = 17;
- } else if(mouseX > guiLeft+X_SIZE/2+pageStrLen/2+2 && mouseX <= guiLeft+X_SIZE/2+pageStrLen/2+2+15) {
- click = 35;
- }
-
- if(click >= 0) {
- if(currentState == EnchantState.ADDING_ENCHANT) {
- if(Mouse.getEventButtonState()) {
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) return true;
- GuiContainer chest = ((GuiContainer)Minecraft.getMinecraft().currentScreen);
-
- EntityPlayerSP playerIn = Minecraft.getMinecraft().thePlayer;
- short transactionID = playerIn.openContainer.getNextTransactionID(playerIn.inventory);
- ItemStack stack = ((ContainerChest)chest.inventorySlots).getLowerChestInventory().getStackInSlot(48);
- Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C0EPacketClickWindow(
- chest.inventorySlots.windowId, 48, 0, 0, stack, transactionID));
-
- cancelButtonAnimTime = System.currentTimeMillis();
- }
- return true;
- } else {
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) return true;
- GuiContainer chest = ((GuiContainer)Minecraft.getMinecraft().currentScreen);
-
- EntityPlayerSP playerIn = Minecraft.getMinecraft().thePlayer;
- short transactionID = playerIn.openContainer.getNextTransactionID(playerIn.inventory);
- ItemStack stack = ((ContainerChest)chest.inventorySlots).getLowerChestInventory().getStackInSlot(click);
- Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C0EPacketClickWindow(
- chest.inventorySlots.windowId, click, 0, 0, stack, transactionID));
- return true;
- }
- }
- }
- }
-
- if(currentState == EnchantState.HAS_ITEM) {
- if(Mouse.getEventButtonState()) {
- if(mouseX > guiLeft+X_SIZE/2-searchField.getWidth()/2 && mouseX < guiLeft+X_SIZE/2+searchField.getWidth()/2 &&
- mouseY > guiTop+80 && mouseY < guiTop+96) {
- searchField.mouseClicked(mouseX, mouseY, Mouse.getEventButton());
- } else {
- searchField.setFocus(false);
- }
- } else if(Mouse.getEventButton() < 0 && searchField.getFocus() && Mouse.isButtonDown(0)) {
- searchField.mouseClickMove(mouseX, mouseY, 0, 0);
- }
- } else if(currentState == EnchantState.ADDING_ENCHANT && !enchanterEnchLevels.isEmpty()) {
- if(Mouse.getEventButtonState()) {
- int left = guiLeft+X_SIZE/2-56;
- int top = guiTop+83;
-
- Utils.drawTexturedRect(guiLeft+X_SIZE/2-1-48, top+18, 48, 14,
- 0, 48/512f, 328/512f, (328+14)/512f, GL11.GL_NEAREST);
- Utils.drawTexturedRect(guiLeft+X_SIZE/2+1, top+18, 48, 14,
- 0, 48/512f, 328/512f, (328+14)/512f, GL11.GL_NEAREST);
-
- if(!isChangingEnchLevel && mouseX > guiLeft+X_SIZE/2+1 && mouseX <= guiLeft+X_SIZE/2+1+48 &&
- mouseY > top+18 && mouseY <= top+18+14) {
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) return true;
- GuiContainer chest = ((GuiContainer)Minecraft.getMinecraft().currentScreen);
-
- EntityPlayerSP playerIn = Minecraft.getMinecraft().thePlayer;
- short transactionID = playerIn.openContainer.getNextTransactionID(playerIn.inventory);
- ItemStack stack = ((ContainerChest)chest.inventorySlots).getLowerChestInventory().getStackInSlot(48);
- Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C0EPacketClickWindow(
- chest.inventorySlots.windowId, 48, 0, 0, stack, transactionID));
-
- cancelButtonAnimTime = System.currentTimeMillis();
- } else if(!isChangingEnchLevel && enchanterCurrentEnch != null &&
- (mouseX > left+16 && mouseX <= left+96 &&
- mouseY > top && mouseY <= top+16) ||
- (mouseX > guiLeft+X_SIZE/2-1-48 && mouseX <= guiLeft+X_SIZE/2-1 &&
- mouseY > top+18 && mouseY <= top+18+14)) {
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) return true;
- GuiContainer chest = ((GuiContainer)Minecraft.getMinecraft().currentScreen);
-
- EntityPlayerSP playerIn = Minecraft.getMinecraft().thePlayer;
- short transactionID = playerIn.openContainer.getNextTransactionID(playerIn.inventory);
- ItemStack stack = ((ContainerChest)chest.inventorySlots).getLowerChestInventory().getStackInSlot(enchanterCurrentEnch.slotIndex);
- Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C0EPacketClickWindow(
- chest.inventorySlots.windowId,
- enchanterCurrentEnch.slotIndex, 0, 0, stack, transactionID));
-
- int playerXpLevel = Minecraft.getMinecraft().thePlayer.experienceLevel;
- if(playerXpLevel >= enchanterCurrentEnch.xpCost) {
- if(removingEnchantPlayerLevel >= 0 && enchanterCurrentEnch.level == removingEnchantPlayerLevel) {
- spawnExperienceOrbs(guiLeft+X_SIZE/2, guiTop+66, X_SIZE/2, 36, 3);
- } else {
- spawnExperienceOrbs(mouseX, mouseY, X_SIZE/2, 66, 0);
- }
- }
-
- confirmButtonAnimTime = System.currentTimeMillis();
- } else if(mouseX > left+96 && mouseX <= left+96+16) {
- if(!isChangingEnchLevel) {
- if(mouseY > top && mouseY < top+16) {
- isChangingEnchLevel = true;
- return true;
- }
- } else {
- List<Enchantment> before = new ArrayList<>();
- List<Enchantment> after = new ArrayList<>();
-
- for(Enchantment ench : enchanterEnchLevels.values()) {
- if(ench.level < enchanterCurrentEnch.level) {
- before.add(ench);
- } else if(ench.level > enchanterCurrentEnch.level) {
- after.add(ench);
- }
- }
-
- before.sort(Comparator.comparingInt(o -> -o.level));
- after.sort(Comparator.comparingInt(o -> o.level));
-
- int bSize = before.size();
- int aSize = after.size();
- for(int i=0; i<bSize+aSize; i++) {
- Enchantment ench;
- int yIndex;
- if(i < bSize) {
- yIndex = -i-1;
- ench = before.get(i);
- } else {
- yIndex = i-bSize+1;
- ench = after.get(i-bSize);
- }
-
- if(mouseY > top+16*yIndex && mouseY <= top+16*yIndex+16) {
- enchanterCurrentEnch = ench;
- isChangingEnchLevel = false;
- return true;
- }
- }
- }
- }
-
- if(isChangingEnchLevel) {
- isChangingEnchLevel = false;
- return true;
- }
- }
- }
-
- if(!Mouse.getEventButtonState() && Mouse.getEventButton() < 0 && clickedScrollOffset != -1) {
- LerpingInteger lerpingInteger = isClickedScrollLeft ? leftScroll : rightScroll;
- List<Enchantment> enchantsList = isClickedScrollLeft ? applicable : removable;
-
- if(enchantsList.size() > 6) {
- int newOffset = mouseY - clickedScrollOffset;
-
- int newScroll = Math.round(newOffset * (float)((enchantsList.size()-6)*16) / (96-15));
- int max = (enchantsList.size()-6)*16;
-
- if(newScroll > max) newScroll = max;
- if(newScroll < 0) newScroll = 0;
-
- lerpingInteger.setValue(newScroll);
- }
- }
-
- //Config options
- if(Mouse.getEventButtonState()) {
- if(mouseX >= guiLeft+294 && mouseX < guiLeft+294+36 &&
- mouseY >= guiTop+146 && mouseY < guiTop+146+36) {
- int index = (mouseX-(guiLeft+295))/18 + (mouseY-(guiTop+147))/18*2;
-
- int direction = Mouse.getEventButton() == 0 ? 1 : -1;
-
- switch (index) {
- case 0: {
- NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enableTableGUI = false;
- break;
- }
- case 1: {
+ tooltipToDisplay.add(1, EnumChatFormatting.GRAY + "How to display enchants that are");
+ tooltipToDisplay.add(2, EnumChatFormatting.GRAY + "incompatible with your current item,");
+ tooltipToDisplay.add(3, EnumChatFormatting.GRAY + "eg. Smite on a sword with Sharpness");
+ break;*/
+ case 2:
+ Gui.drawRect(guiLeft + 295, guiTop + 147 + 18, guiLeft + 295 + 16, guiTop + 147 + 16 + 18, 0x80ffffff);
+ tooltipToDisplay = createTooltip("Sort enchants...",
+ NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enchantSorting,
+ "By Cost", "Alphabetically"
+ );
+ break;
+ case 3:
+ Gui.drawRect(
+ guiLeft + 295 + 18,
+ guiTop + 147 + 18,
+ guiLeft + 295 + 16 + 18,
+ guiTop + 147 + 16 + 18,
+ 0x80ffffff
+ );
+ tooltipToDisplay = createTooltip("Order enchants...",
+ NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enchantOrdering,
+ "Ascending", "Descending"
+ );
+ break;
+ }
+ }
+
+ //Left scroll bar
+ {
+ int offset;
+ if (applicable.size() <= 6) {
+ offset = 0;
+ } else if (isScrollingLeft && clickedScrollOffset >= 0) {
+ offset = mouseY - clickedScrollOffset;
+ if (offset < 0) offset = 0;
+ if (offset > 96 - 15) offset = 96 - 15;
+ } else {
+ offset = Math.round((96 - 15) * (leftScroll.getValue() / (float) ((applicable.size() - 6) * 16)));
+ }
+ Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(guiLeft + 104, guiTop + 18 + offset, 12, 15,
+ 0, 12 / 512f, 313 / 512f, (313 + 15) / 512f, GL11.GL_NEAREST
+ );
+ }
+ //Right scroll bar
+ {
+ int offset;
+ if (removable.size() <= 6) {
+ offset = 0;
+ } else if (!isScrollingLeft && clickedScrollOffset >= 0) {
+ offset = mouseY - clickedScrollOffset;
+ if (offset < 0) offset = 0;
+ if (offset > 96 - 15) offset = 96 - 15;
+ } else {
+ offset = Math.round((96 - 15) * (rightScroll.getValue() / (float) ((removable.size() - 6) * 16)));
+ }
+ Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(guiLeft + 344, guiTop + 18 + offset, 12, 15,
+ 0, 12 / 512f, 313 / 512f, (313 + 15) / 512f, GL11.GL_NEAREST
+ );
+ }
+
+ //Enchant book model
+ renderEnchantBook(scaledResolution, partialTicks);
+
+ //Can't be enchanted text
+ if (currentState == EnchantState.INVALID_ITEM) {
+ GlStateManager.disableDepth();
+ Utils.drawStringCentered("This item can't", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + X_SIZE / 2, guiTop + 88, true, 0xffff5555
+ );
+ Utils.drawStringCentered("be enchanted", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + X_SIZE / 2, guiTop + 98, true, 0xffff5555
+ );
+ GlStateManager.enableDepth();
+ }
+
+ //Enchant arrow
+ if (arrowAmount.getValue() > 0) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
+ GlStateManager.color(1, 1, 1, 1);
+ float w = 22 * arrowAmount.getValue();
+ if (removingEnchantPlayerLevel < 0) {
+ Utils.drawTexturedRect(guiLeft + 134, guiTop + 58, w, 16,
+ 0, w / 512f, 297 / 512f, (297 + 16) / 512f, GL11.GL_NEAREST
+ );
+ } else {
+ Utils.drawTexturedRect(guiLeft + 230 - w, guiTop + 58, w, 16,
+ (44 - w) / 512f, 44 / 512f, 297 / 512f, (297 + 16) / 512f, GL11.GL_NEAREST
+ );
+ }
+ }
+
+ //Text if no enchants appear
+ if (currentState == EnchantState.HAS_ITEM || currentState == EnchantState.ADDING_ENCHANT) {
+ if (applicable.isEmpty() && removable.isEmpty() && searchRemovedFromApplicable) {
+ Utils.drawStringCentered("Can't find that", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 8 + 48, guiTop + 28, true, 0xffff5555
+ );
+ Utils.drawStringCentered("enchant, perhaps", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 8 + 48, guiTop + 38, true, 0xffff5555
+ );
+ Utils.drawStringCentered("it is on", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 8 + 48, guiTop + 48, true, 0xffff5555
+ );
+ Utils.drawStringCentered("another page?", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 8 + 48, guiTop + 58, true, 0xffff5555
+ );
+ } else if (applicable.isEmpty() && !searchRemovedFromApplicable) {
+ Utils.drawStringCentered("No applicable", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 8 + 48, guiTop + 28, true, 0xffff5555
+ );
+ Utils.drawStringCentered("enchants on", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 8 + 48, guiTop + 38, true, 0xffff5555
+ );
+ Utils.drawStringCentered("this page...", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 8 + 48, guiTop + 48, true, 0xffff5555
+ );
+ }
+ if (applicable.isEmpty() && removable.isEmpty() && searchRemovedFromRemovable) {
+ Utils.drawStringCentered("Can't find that", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 248 + 48, guiTop + 28, true, 0xffff5555
+ );
+ Utils.drawStringCentered("enchant, perhaps", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 248 + 48, guiTop + 38, true, 0xffff5555
+ );
+ Utils.drawStringCentered("it is on", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 248 + 48, guiTop + 48, true, 0xffff5555
+ );
+ Utils.drawStringCentered("another page?", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 248 + 48, guiTop + 58, true, 0xffff5555
+ );
+ } else if (removable.isEmpty() && !searchRemovedFromRemovable) {
+ Utils.drawStringCentered("No removable", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 248 + 48, guiTop + 28, true, 0xffff5555
+ );
+ Utils.drawStringCentered("enchants on", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 248 + 48, guiTop + 38, true, 0xffff5555
+ );
+ Utils.drawStringCentered("this page...", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 248 + 48, guiTop + 48, true, 0xffff5555
+ );
+ }
+ }
+ //Available enchants (left)
+ GlScissorStack.push(0, guiTop + 18, width, guiTop + 18 + 96, scaledResolution);
+ for (int i = 0; i < 7; i++) {
+ int index = i + leftScroll.getValue() / 16;
+
+ if (applicable.size() <= index) break;
+ Enchantment ench = applicable.get(index);
+
+ int top = guiTop - (leftScroll.getValue() % 16) + 18 + 16 * i;
+ int vOffset = enchanterCurrentEnch != null && enchanterCurrentEnch.enchId.equals(ench.enchId) ? 16 : 0;
+ int uOffset = ench.conflicts ? 112 : 0;
+ int textOffset = vOffset / 16;
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(guiLeft + 8, top, 96, 16,
+ uOffset / 512f, (96 + uOffset) / 512f, (249 + vOffset) / 512f, (249 + 16 + vOffset) / 512f, GL11.GL_NEAREST
+ );
+
+ if (mouseX > guiLeft + 8 && mouseX <= guiLeft + 8 + 96 &&
+ mouseY > top && mouseY <= top + 16) {
+ disallowClick = true;
+ if (ench.displayLore != null) {
+ tooltipToDisplay = ench.displayLore;
+ }
+ }
+
+ String levelStr = "" + ench.xpCost;
+ int colour = 0xc8ff8f;
+ if (ench.xpCost > playerXpLevel) {
+ colour = 0xff5555;
+ }
+
+ int levelWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(levelStr);
+ Minecraft.getMinecraft().fontRendererObj.drawString(
+ levelStr,
+ guiLeft + 16 - levelWidth / 2 - 1,
+ top + 4,
+ 0x2d2102,
+ false
+ );
+ Minecraft.getMinecraft().fontRendererObj.drawString(
+ levelStr,
+ guiLeft + 16 - levelWidth / 2 + 1,
+ top + 4,
+ 0x2d2102,
+ false
+ );
+ Minecraft.getMinecraft().fontRendererObj.drawString(
+ levelStr,
+ guiLeft + 16 - levelWidth / 2,
+ top + 4 - 1,
+ 0x2d2102,
+ false
+ );
+ Minecraft.getMinecraft().fontRendererObj.drawString(
+ levelStr,
+ guiLeft + 16 - levelWidth / 2,
+ top + 4 + 1,
+ 0x2d2102,
+ false
+ );
+ Minecraft.getMinecraft().fontRendererObj.drawString(
+ levelStr,
+ guiLeft + 16 - levelWidth / 2,
+ top + 4,
+ colour,
+ false
+ );
+
+ Minecraft.getMinecraft().fontRendererObj.drawString(
+ ench.enchantName,
+ guiLeft + 8 + 16 + 2 + textOffset,
+ top + 4 + textOffset,
+ 0xffffffdd,
+ true
+ );
+ }
+ GlScissorStack.pop(scaledResolution);
+
+ //Removable enchants (right)
+ GlScissorStack.push(0, guiTop + 18, width, guiTop + 18 + 96, scaledResolution);
+ for (int i = 0; i < 7; i++) {
+ int index = i + rightScroll.getValue() / 16;
+
+ if (removable.size() <= index) break;
+ Enchantment ench = removable.get(index);
+
+ int top = guiTop - (rightScroll.getValue() % 16) + 18 + 16 * i;
+ int vOffset = enchanterCurrentEnch != null && enchanterCurrentEnch.enchId.equals(ench.enchId) ? 16 : 0;
+ int textOffset = vOffset / 16;
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(guiLeft + 248, top, 96, 16,
+ 0, 96 / 512f, (249 + vOffset) / 512f, (249 + 16 + vOffset) / 512f, GL11.GL_NEAREST
+ );
+
+ if (mouseX > guiLeft + 248 && mouseX <= guiLeft + 248 + 96 &&
+ mouseY > top && mouseY <= top + 16) {
+ disallowClick = true;
+ if (ench.displayLore != null) {
+ tooltipToDisplay = ench.displayLore;
+ }
+ }
+
+ String levelStr = "" + ench.xpCost;
+ if (ench.xpCost < 0) levelStr = "?";
+ int colour = 0xc8ff8f;
+ if (ench.xpCost > playerXpLevel) {
+ colour = 0xff5555;
+ }
+
+ int levelWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(levelStr);
+ Minecraft.getMinecraft().fontRendererObj.drawString(
+ levelStr,
+ guiLeft + 256 - levelWidth / 2 - 1,
+ top + 4,
+ 0x2d2102,
+ false
+ );
+ Minecraft.getMinecraft().fontRendererObj.drawString(
+ levelStr,
+ guiLeft + 256 - levelWidth / 2 + 1,
+ top + 4,
+ 0x2d2102,
+ false
+ );
+ Minecraft.getMinecraft().fontRendererObj.drawString(
+ levelStr,
+ guiLeft + 256 - levelWidth / 2,
+ top + 4 - 1,
+ 0x2d2102,
+ false
+ );
+ Minecraft.getMinecraft().fontRendererObj.drawString(
+ levelStr,
+ guiLeft + 256 - levelWidth / 2,
+ top + 4 + 1,
+ 0x2d2102,
+ false
+ );
+ Minecraft.getMinecraft().fontRendererObj.drawString(
+ levelStr,
+ guiLeft + 256 - levelWidth / 2,
+ top + 4,
+ colour,
+ false
+ );
+
+ Minecraft.getMinecraft().fontRendererObj.drawString(ench.enchantName,
+ guiLeft + 248 + 16 + 2 + textOffset, top + 4 + textOffset, 0xffffffdd, true
+ );
+ }
+ GlScissorStack.pop(scaledResolution);
+
+ //Player Inventory Items
+ Minecraft.getMinecraft().fontRendererObj.drawString(Minecraft.getMinecraft().thePlayer.inventory
+ .getDisplayName()
+ .getUnformattedText(),
+ guiLeft + 102, guiTop + Y_SIZE - 96 + 2, 0x404040
+ );
+ int inventoryStartIndex = cc.getLowerChestInventory().getSizeInventory();
+ GlStateManager.enableDepth();
+ for (int i = 0; i < 36; i++) {
+ int itemX = guiLeft + 102 + 18 * (i % 9);
+ int itemY = guiTop + 133 + 18 * (i / 9);
+
+ if (i >= 27) {
+ itemY += 4;
+ }
+
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(guiLeft + 102 - 8, guiTop + 191 - (inventoryStartIndex / 9 * 18 + 89), 0);
+ Slot slot = cc.getSlot(inventoryStartIndex + i);
+ chest.drawSlot(slot);
+ GlStateManager.popMatrix();
+
+ if (mouseX >= itemX && mouseX < itemX + 18 &&
+ mouseY >= itemY && mouseY < itemY + 18) {
+ itemHoverX = itemX;
+ itemHoverY = itemY;
+ hoverLocked = SlotLocking.getInstance().isSlotLocked(slot);
+
+ if (slot.getHasStack()) {
+ tooltipToDisplay = slot.getStack().getTooltip(
+ Minecraft.getMinecraft().thePlayer,
+ Minecraft.getMinecraft().gameSettings.advancedItemTooltips
+ );
+ }
+ }
+ }
+
+ //Search bar
+ if (currentState == EnchantState.HAS_ITEM) {
+ if (searchField.getText().isEmpty() && !searchField.getFocus()) {
+ searchField.setSize(90, 14);
+ searchField.setPrependText("\u00a77Search...");
+ } else {
+ if (searchField.getFocus()) {
+ int len = Minecraft.getMinecraft().fontRendererObj.getStringWidth(searchField.getTextDisplay()) + 10;
+ searchField.setSize(Math.max(90, len), 14);
+ } else {
+ searchField.setSize(90, 14);
+ }
+ searchField.setPrependText("");
+ }
+ searchField.render(guiLeft + X_SIZE / 2 - searchField.getWidth() / 2, guiTop + 83);
+ } else if (currentState == EnchantState.ADDING_ENCHANT &&
+ enchanterCurrentEnch != null && !enchanterEnchLevels.isEmpty()) {
+ int left = guiLeft + X_SIZE / 2 - 56;
+ int top = guiTop + 83;
+
+ int uOffset = enchanterCurrentEnch.conflicts ? 112 : 0;
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(left, top, 112, 16,
+ uOffset / 512f, (112 + uOffset) / 512f, 249 / 512f, (249 + 16) / 512f, GL11.GL_NEAREST
+ );
+
+ if (mouseX > left + 16 && mouseX <= left + 96 &&
+ mouseY > top && mouseY <= top + 16) {
+ disallowClick = true;
+ if (enchanterCurrentEnch.displayLore != null) {
+ tooltipToDisplay = enchanterCurrentEnch.displayLore;
+ }
+ }
+
+ //Enchant cost
+ String levelStr = "" + enchanterCurrentEnch.xpCost;
+ if (enchanterCurrentEnch.xpCost < 0) levelStr = "?";
+
+ int colour = 0xc8ff8f;
+ if (enchanterCurrentEnch.xpCost > playerXpLevel) {
+ colour = 0xff5555;
+ }
+
+ int levelWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(levelStr);
+ Minecraft.getMinecraft().fontRendererObj.drawString(
+ levelStr,
+ left + 8 - levelWidth / 2 - 1,
+ top + 4,
+ 0x2d2102,
+ false
+ );
+ Minecraft.getMinecraft().fontRendererObj.drawString(
+ levelStr,
+ left + 8 - levelWidth / 2 + 1,
+ top + 4,
+ 0x2d2102,
+ false
+ );
+ Minecraft.getMinecraft().fontRendererObj.drawString(
+ levelStr,
+ left + 8 - levelWidth / 2,
+ top + 4 - 1,
+ 0x2d2102,
+ false
+ );
+ Minecraft.getMinecraft().fontRendererObj.drawString(
+ levelStr,
+ left + 8 - levelWidth / 2,
+ top + 4 + 1,
+ 0x2d2102,
+ false
+ );
+ Minecraft.getMinecraft().fontRendererObj.drawString(levelStr, left + 8 - levelWidth / 2, top + 4, colour, false);
+
+ //Enchant name
+ String name = WordUtils.capitalizeFully(enchanterCurrentEnch.enchId.replace("_", " "));
+ if (name.equalsIgnoreCase("Bane of Arthropods")) {
+ name = "Bane of Arth.";
+ } else if (name.equalsIgnoreCase("Projectile Protection")) {
+ name = "Projectile Prot";
+ } else if (name.equalsIgnoreCase("Blast Protection")) {
+ name = "Blast Prot";
+ } else if (name.equalsIgnoreCase("Luck of the Sea")) {
+ name = "Luck of Sea";
+ }
+ Utils.drawStringCentered(
+ name,
+ Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + X_SIZE / 2,
+ top + 8,
+ true,
+ 0xffffffdd
+ );
+
+ if (isChangingEnchLevel) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(left + 96, top, 16, 16,
+ 96 / 512f, 112 / 512f, 265 / 512f, (265 + 16) / 512f, GL11.GL_NEAREST
+ );
+ }
+
+ //Enchant level
+ levelStr = "" + enchanterCurrentEnch.level;
+ if (enchanterCurrentEnch.xpCost < 0) levelStr = "?";
+ levelWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(levelStr);
+ Minecraft.getMinecraft().fontRendererObj.drawString(
+ levelStr,
+ left + 96 + 8 - levelWidth / 2 - 1,
+ top + 4,
+ 0x2d2102,
+ false
+ );
+ Minecraft.getMinecraft().fontRendererObj.drawString(
+ levelStr,
+ left + 96 + 8 - levelWidth / 2 + 1,
+ top + 4,
+ 0x2d2102,
+ false
+ );
+ Minecraft.getMinecraft().fontRendererObj.drawString(
+ levelStr,
+ left + 96 + 8 - levelWidth / 2,
+ top + 4 - 1,
+ 0x2d2102,
+ false
+ );
+ Minecraft.getMinecraft().fontRendererObj.drawString(
+ levelStr,
+ left + 96 + 8 - levelWidth / 2,
+ top + 4 + 1,
+ 0x2d2102,
+ false
+ );
+ Minecraft.getMinecraft().fontRendererObj.drawString(
+ levelStr,
+ left + 96 + 8 - levelWidth / 2,
+ top + 4,
+ 0xea82ff,
+ false
+ );
+
+ //Confirm button
+
+ String confirmText = "Apply";
+ if (removingEnchantPlayerLevel >= 0) {
+ if (removingEnchantPlayerLevel == enchanterCurrentEnch.level) {
+ confirmText = "Remove";
+ } else if (enchanterCurrentEnch.level > removingEnchantPlayerLevel) {
+ confirmText = "Upgrade";
+ } else {
+ confirmText = "Bad Level";
+ }
+ }
+ if (System.currentTimeMillis() - confirmButtonAnimTime < 500 && !(playerXpLevel < enchanterCurrentEnch.xpCost)) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(guiLeft + X_SIZE / 2 - 1 - 48, top + 18, 48, 14,
+ 0, 48 / 512f, 342 / 512f, (342 + 14) / 512f, GL11.GL_NEAREST
+ );
+ Utils.drawStringCentered(confirmText, Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + X_SIZE / 2 - 1 - 23, top + 18 + 9, false, 0x408040
+ );
+ } else {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(guiLeft + X_SIZE / 2 - 1 - 48, top + 18, 48, 14,
+ 0, 48 / 512f, 328 / 512f, (328 + 14) / 512f, GL11.GL_NEAREST
+ );
+ Utils.drawStringCentered(confirmText, Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + X_SIZE / 2 - 1 - 24, top + 18 + 8, false, 0x408040
+ );
+
+ if (playerXpLevel < enchanterCurrentEnch.xpCost) {
+ Gui.drawRect(guiLeft + X_SIZE / 2 - 1 - 48, top + 18, guiLeft + X_SIZE / 2 - 1, top + 18 + 14, 0x80000000);
+ }
+ }
+
+ //Cancel button
+ if (System.currentTimeMillis() - cancelButtonAnimTime < 500) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(guiLeft + X_SIZE / 2 + 1, top + 18, 48, 14,
+ 0, 48 / 512f, 342 / 512f, (342 + 14) / 512f, GL11.GL_NEAREST
+ );
+ Utils.drawStringCentered("Cancel", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + X_SIZE / 2 + 1 + 25, top + 18 + 9, false, 0xa04040
+ );
+ } else {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(guiLeft + X_SIZE / 2 + 1, top + 18, 48, 14,
+ 0, 48 / 512f, 328 / 512f, (328 + 14) / 512f, GL11.GL_NEAREST
+ );
+ Utils.drawStringCentered("Cancel", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + X_SIZE / 2 + 1 + 24, top + 18 + 8, false, 0xa04040
+ );
+ }
+
+ if (mouseY > top + 18 && mouseY <= top + 18 + 16) {
+ if (mouseX > guiLeft + X_SIZE / 2 - 1 - 48 && mouseX <= guiLeft + X_SIZE / 2 - 1) {
+ disallowClick = true;
+ if (enchanterCurrentEnch.displayLore != null) {
+ tooltipToDisplay = enchanterCurrentEnch.displayLore;
+ }
+ } else if (mouseX > guiLeft + X_SIZE / 2 + 1 && mouseX <= guiLeft + X_SIZE / 2 + 1 + 48) {
+ disallowClick = true;
+ tooltipToDisplay = Lists.newArrayList("\u00a7cCancel");
+ }
+ }
+
+ //Enchant level switcher
+ if (isChangingEnchLevel) {
+ tooltipToDisplay = null;
+
+ List<Enchantment> before = new ArrayList<>();
+ List<Enchantment> after = new ArrayList<>();
+
+ for (Enchantment ench : enchanterEnchLevels.values()) {
+ if (ench.level < enchanterCurrentEnch.level) {
+ before.add(ench);
+ } else if (ench.level > enchanterCurrentEnch.level) {
+ after.add(ench);
+ }
+ }
+
+ before.sort(Comparator.comparingInt(o -> -o.level));
+ after.sort(Comparator.comparingInt(o -> o.level));
+
+ int bSize = before.size();
+ int aSize = after.size();
+ GlStateManager.disableDepth();
+ for (int i = 0; i < bSize + aSize; i++) {
+ Enchantment ench;
+ int yIndex;
+ if (i < bSize) {
+ ench = before.get(i);
+ yIndex = -i - 1;
+ } else {
+ ench = after.get(i - bSize);
+ yIndex = i - bSize + 1;
+ }
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
+ GlStateManager.color(1, 1, 1, 1);
+
+ int type = 0;
+ if (i == bSize) {
+ type = 2;
+ } else if (i == 0) {
+ type = 1;
+ }
+
+ if (mouseX > left + 96 && mouseX <= left + 96 + 16 &&
+ mouseY > top + 16 * yIndex && mouseY <= top + 16 * yIndex + 16) {
+ tooltipToDisplay = new ArrayList<>(ench.displayLore);
+ if (tooltipToDisplay.size() > 2) {
+ tooltipToDisplay.remove(tooltipToDisplay.size() - 1);
+ tooltipToDisplay.remove(tooltipToDisplay.size() - 1);
+ }
+ itemHoverX = -1;
+ itemHoverY = -1;
+ }
+
+ Utils.drawTexturedRect(left + 96, top + 16 * yIndex, 16, 16,
+ 16 * type / 512f, (16 + 16 * type) / 512f, 356 / 512f, (356 + 16) / 512f, GL11.GL_NEAREST
+ );
+
+ levelStr = "" + ench.level;
+ levelWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(levelStr);
+ Minecraft.getMinecraft().fontRendererObj.drawString(
+ levelStr,
+ left + 96 + 8 - levelWidth / 2 - 1,
+ top + 16 * yIndex + 4,
+ 0x2d2102,
+ false
+ );
+ Minecraft.getMinecraft().fontRendererObj.drawString(
+ levelStr,
+ left + 96 + 8 - levelWidth / 2 + 1,
+ top + 16 * yIndex + 4,
+ 0x2d2102,
+ false
+ );
+ Minecraft.getMinecraft().fontRendererObj.drawString(
+ levelStr,
+ left + 96 + 8 - levelWidth / 2,
+ top + 16 * yIndex + 4 - 1,
+ 0x2d2102,
+ false
+ );
+ Minecraft.getMinecraft().fontRendererObj.drawString(
+ levelStr,
+ left + 96 + 8 - levelWidth / 2,
+ top + 16 * yIndex + 4 + 1,
+ 0x2d2102,
+ false
+ );
+ Minecraft.getMinecraft().fontRendererObj.drawString(
+ levelStr,
+ left + 96 + 8 - levelWidth / 2,
+ top + 16 * yIndex + 4,
+ 0xea82ff,
+ false
+ );
+ }
+ GlStateManager.enableDepth();
+ }
+
+ if (mouseX > left + 96 && mouseX <= left + 96 + 16 &&
+ mouseY > top && mouseY <= top + 16) {
+ if (isChangingEnchLevel) {
+ tooltipToDisplay = Lists.newArrayList("\u00a7cCancel level change");
+ } else {
+ tooltipToDisplay = Lists.newArrayList("\u00a7aChange enchant level");
+ }
+ }
+ }
+
+ //Item enchant input
+ ItemStack itemEnchantInput = cc.getSlot(19).getStack();
+ if (itemEnchantInput != null && itemEnchantInput.getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane)) {
+ itemEnchantInput = enchantingItem;
+ }
+ {
+ int itemX = guiLeft + 174;
+ int itemY = guiTop + 58;
+
+ if (itemEnchantInput == null) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(itemX, itemY, 16, 16,
+ 0, 16 / 512f, 281 / 512f, (281 + 16) / 512f, GL11.GL_NEAREST
+ );
+ } else {
+ Utils.drawItemStack(itemEnchantInput, itemX, itemY);
+ }
+
+ if (mouseX >= itemX && mouseX < itemX + 18 &&
+ mouseY >= itemY && mouseY < itemY + 18) {
+ itemHoverX = itemX;
+ itemHoverY = itemY;
+
+ if (itemEnchantInput != null) {
+ tooltipToDisplay = itemEnchantInput.getTooltip(
+ Minecraft.getMinecraft().thePlayer,
+ Minecraft.getMinecraft().gameSettings.advancedItemTooltips
+ );
+ }
+ }
+ }
+
+ if (!isChangingEnchLevel && itemHoverX >= 0 && itemHoverY >= 0) {
+ GlStateManager.disableDepth();
+ GlStateManager.colorMask(true, true, true, false);
+ Gui.drawRect(itemHoverX, itemHoverY, itemHoverX + 16, itemHoverY + 16,
+ hoverLocked ? 0x80ff8080 : 0x80ffffff
+ );
+ GlStateManager.colorMask(true, true, true, true);
+ GlStateManager.enableDepth();
+ }
+
+ GlStateManager.translate(0, 0, 300);
+
+ //Orb animation
+ Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
+ GlStateManager.color(1, 1, 1, 1);
+ GlStateManager.disableDepth();
+ for (ExperienceOrb orb : orbs) {
+ int orbX = Math.round(orb.xLast + (orb.x - orb.xLast) * partialTicks);
+ int orbY = Math.round(orb.yLast + (orb.y - orb.yLast) * partialTicks);
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(orbX, orbY, 0);
+ GlStateManager.rotate(orb.rotationDeg, 0, 0, 1);
+
+ float targetDeltaX = guiLeft + orbTargetX - orb.x;
+ float targetDeltaY = guiTop + orbTargetY - orb.y;
+ float length = (float) Math.sqrt(targetDeltaX * targetDeltaX + targetDeltaY * targetDeltaY);
+ float velSq = orb.xVel * orb.xVel + orb.yVel * orb.yVel;
+ float opacity = Math.min(2, Math.max(0.5f, length / 16)) * Math.min(2, Math.max(0.5f, velSq / 40));
+ if (opacity > 1) opacity = 1;
+ opacity = (float) Math.sqrt(opacity);
+ GlStateManager.color(1, 1, 1, opacity);
+
+ Utils.drawTexturedRect(
+ -8,
+ -8,
+ 16,
+ 16,
+ ((orb.type % 3) * 16) / 512f,
+ (16 + (orb.type % 3) * 16) / 512f,
+ (217 + orb.type / 3 * 16) / 512f,
+ (217 + 16 + orb.type / 3 * 16) / 512f,
+ GL11.GL_NEAREST
+ );
+ GlStateManager.popMatrix();
+ }
+ GlStateManager.enableDepth();
+
+ if (stackOnMouse != null) {
+ if (disallowClick) {
+ Utils.drawItemStack(new ItemStack(Item.getItemFromBlock(Blocks.barrier)), mouseX - 8, mouseY - 8);
+ } else {
+ Utils.drawItemStack(stackOnMouse, mouseX - 8, mouseY - 8);
+ }
+ } else if (tooltipToDisplay != null) {
+ Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1,
+ Minecraft.getMinecraft().fontRendererObj
+ );
+ }
+ GlStateManager.translate(0, 0, -300);
+ }
+
+ private void spawnExperienceOrbs(int startX, int startY, int targetX, int targetY, int baseType) {
+ orbs.clear();
+
+ this.orbTargetX = targetX;
+ this.orbTargetY = targetY;
+
+ Random rand = new Random();
+ for (int i = 0; i < EXPERIENCE_ORB_COUNT; i++) {
+ ExperienceOrb orb = new ExperienceOrb();
+ orb.x = startX;
+ orb.y = startY;
+ orb.xLast = startX;
+ orb.yLast = startY;
+ orb.xVel = rand.nextFloat() * 20 - 10;
+ orb.yVel = rand.nextFloat() * 20 - 10;
+ orb.type = baseType;
+
+ float typeRand = rand.nextFloat();
+ if (typeRand < 0.6) {
+ orb.type += 0;
+ } else if (typeRand < 0.9) {
+ orb.type += 1;
+ } else {
+ orb.type += 2;
+ }
+ orb.rotationDeg = rand.nextInt(4) * 90;
+
+ orbs.add(orb);
+ }
+ }
+
+ private void renderEnchantBook(ScaledResolution scaledresolution, float partialTicks) {
+ GlStateManager.enableDepth();
+
+ GlStateManager.pushMatrix();
+ GlStateManager.matrixMode(5889);
+ GlStateManager.pushMatrix();
+ GlStateManager.loadIdentity();
+ GlStateManager.viewport((scaledresolution.getScaledWidth() - 320) / 2 * scaledresolution.getScaleFactor(),
+ (scaledresolution.getScaledHeight() - 240) / 2 * scaledresolution.getScaleFactor(),
+ 320 * scaledresolution.getScaleFactor(), 240 * scaledresolution.getScaleFactor()
+ );
+ GlStateManager.translate(0.0F, 0.33F, 0.0F);
+ Project.gluPerspective(90.0F, 1.3333334F, 9.0F, 80.0F);
+ GlStateManager.matrixMode(5888);
+ GlStateManager.loadIdentity();
+ RenderHelper.enableStandardItemLighting();
+ GlStateManager.translate(0.0F, 3.3F, -16.0F);
+ GlStateManager.scale(5, 5, 5);
+ GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(ENCHANTMENT_TABLE_BOOK_TEXTURE);
+ GlStateManager.rotate(20.0F, 1.0F, 0.0F, 0.0F);
+ float bookOpenAngle = this.bookOpenLast + (this.bookOpen - this.bookOpenLast) * partialTicks;
+ GlStateManager.translate(
+ (1.0F - bookOpenAngle) * 0.2F,
+ (1.0F - bookOpenAngle) * 0.1F,
+ (1.0F - bookOpenAngle) * 0.25F
+ );
+ GlStateManager.rotate(-(1.0F - bookOpenAngle) * 90.0F - 90.0F, 0.0F, 1.0F, 0.0F);
+ GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F);
+ float pageAngle1 = this.pageOpenLast + (this.pageOpen - this.pageOpenLast) * partialTicks + 0.25F;
+ float pageAngle2 = this.pageOpenLast + (this.pageOpen - this.pageOpenLast) * partialTicks + 0.75F;
+ pageAngle1 = (pageAngle1 - (float) MathHelper.truncateDoubleToInt(pageAngle1)) * 1.6F - 0.3F;
+ pageAngle2 = (pageAngle2 - (float) MathHelper.truncateDoubleToInt(pageAngle2)) * 1.6F - 0.3F;
+
+ if (pageAngle1 < 0.0F) pageAngle1 = 0.0F;
+ if (pageAngle1 > 1.0F) pageAngle1 = 1.0F;
+ if (pageAngle2 < 0.0F) pageAngle2 = 0.0F;
+ if (pageAngle2 > 1.0F) pageAngle2 = 1.0F;
+
+ GlStateManager.enableRescaleNormal();
+ MODEL_BOOK.render(null, 0.0F, pageAngle1, pageAngle2, bookOpenAngle, 0.0F, 0.0625F);
+ GlStateManager.disableRescaleNormal();
+ RenderHelper.disableStandardItemLighting();
+ GlStateManager.matrixMode(5889);
+ GlStateManager.viewport(0, 0, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight);
+ GlStateManager.popMatrix();
+ GlStateManager.matrixMode(5888);
+ GlStateManager.popMatrix();
+ RenderHelper.disableStandardItemLighting();
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+
+ GlStateManager.enableDepth();
+ }
+
+ public void overrideIsMouseOverSlot(Slot slot, int mouseX, int mouseY, CallbackInfoReturnable<Boolean> cir) {
+ if (shouldOverrideFast && currentState != EnchantState.ADDING_ENCHANT) {
+ boolean playerInv = slot.inventory == Minecraft.getMinecraft().thePlayer.inventory;
+ int slotId = slot.getSlotIndex();
+ if (playerInv && slotId < 36) {
+ slotId -= 9;
+ if (slotId < 0) slotId += 36;
+
+ int itemX = guiLeft + 102 + 18 * (slotId % 9);
+ int itemY = guiTop + 133 + 18 * (slotId / 9);
+
+ if (slotId >= 27) {
+ itemY += 4;
+ }
+
+ if (mouseX >= itemX && mouseX < itemX + 18 &&
+ mouseY >= itemY && mouseY < itemY + 18) {
+ cir.setReturnValue(true);
+ } else {
+ cir.setReturnValue(false);
+ }
+ } else if (slotId == 19) {
+ cir.setReturnValue(mouseX >= guiLeft + 173 && mouseX < guiLeft + 173 + 18 &&
+ mouseY >= guiTop + 57 && mouseY < guiTop + 57 + 18);
+ }
+ }
+ }
+
+ public boolean mouseInput(int mouseX, int mouseY) {
+ if (Mouse.getEventButtonState() &&
+ (currentState == EnchantState.HAS_ITEM || currentState == EnchantState.ADDING_ENCHANT)) {
+ if (mouseY > guiTop + 6 && mouseY < guiTop + 6 + 15) {
+ String pageStr = "Page: " + currentPage + "/" + expectedMaxPage;
+ int pageStrLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(pageStr);
+
+ int click = -1;
+ if (mouseX > guiLeft + X_SIZE / 2 - pageStrLen / 2 - 2 - 15 &&
+ mouseX <= guiLeft + X_SIZE / 2 - pageStrLen / 2 - 2) {
+ click = 17;
+ } else if (mouseX > guiLeft + X_SIZE / 2 + pageStrLen / 2 + 2 &&
+ mouseX <= guiLeft + X_SIZE / 2 + pageStrLen / 2 + 2 + 15) {
+ click = 35;
+ }
+
+ if (click >= 0) {
+ if (currentState == EnchantState.ADDING_ENCHANT) {
+ if (Mouse.getEventButtonState()) {
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) return true;
+ GuiContainer chest = ((GuiContainer) Minecraft.getMinecraft().currentScreen);
+
+ EntityPlayerSP playerIn = Minecraft.getMinecraft().thePlayer;
+ short transactionID = playerIn.openContainer.getNextTransactionID(playerIn.inventory);
+ ItemStack stack = ((ContainerChest) chest.inventorySlots).getLowerChestInventory().getStackInSlot(48);
+ Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C0EPacketClickWindow(
+ chest.inventorySlots.windowId, 48, 0, 0, stack, transactionID));
+
+ cancelButtonAnimTime = System.currentTimeMillis();
+ }
+ } else {
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) return true;
+ GuiContainer chest = ((GuiContainer) Minecraft.getMinecraft().currentScreen);
+
+ EntityPlayerSP playerIn = Minecraft.getMinecraft().thePlayer;
+ short transactionID = playerIn.openContainer.getNextTransactionID(playerIn.inventory);
+ ItemStack stack = ((ContainerChest) chest.inventorySlots).getLowerChestInventory().getStackInSlot(click);
+ Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C0EPacketClickWindow(
+ chest.inventorySlots.windowId, click, 0, 0, stack, transactionID));
+ }
+ return true;
+ }
+ }
+ }
+
+ if (currentState == EnchantState.HAS_ITEM) {
+ if (Mouse.getEventButtonState()) {
+ if (mouseX > guiLeft + X_SIZE / 2 - searchField.getWidth() / 2 &&
+ mouseX < guiLeft + X_SIZE / 2 + searchField.getWidth() / 2 &&
+ mouseY > guiTop + 80 && mouseY < guiTop + 96) {
+ searchField.mouseClicked(mouseX, mouseY, Mouse.getEventButton());
+ } else {
+ searchField.setFocus(false);
+ }
+ } else if (Mouse.getEventButton() < 0 && searchField.getFocus() && Mouse.isButtonDown(0)) {
+ searchField.mouseClickMove(mouseX, mouseY, 0, 0);
+ }
+ } else if (currentState == EnchantState.ADDING_ENCHANT && !enchanterEnchLevels.isEmpty()) {
+ if (Mouse.getEventButtonState()) {
+ int left = guiLeft + X_SIZE / 2 - 56;
+ int top = guiTop + 83;
+
+ Utils.drawTexturedRect(guiLeft + X_SIZE / 2 - 1 - 48, top + 18, 48, 14,
+ 0, 48 / 512f, 328 / 512f, (328 + 14) / 512f, GL11.GL_NEAREST
+ );
+ Utils.drawTexturedRect(guiLeft + X_SIZE / 2 + 1, top + 18, 48, 14,
+ 0, 48 / 512f, 328 / 512f, (328 + 14) / 512f, GL11.GL_NEAREST
+ );
+
+ if (!isChangingEnchLevel && mouseX > guiLeft + X_SIZE / 2 + 1 && mouseX <= guiLeft + X_SIZE / 2 + 1 + 48 &&
+ mouseY > top + 18 && mouseY <= top + 18 + 14) {
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) return true;
+ GuiContainer chest = ((GuiContainer) Minecraft.getMinecraft().currentScreen);
+
+ EntityPlayerSP playerIn = Minecraft.getMinecraft().thePlayer;
+ short transactionID = playerIn.openContainer.getNextTransactionID(playerIn.inventory);
+ ItemStack stack = ((ContainerChest) chest.inventorySlots).getLowerChestInventory().getStackInSlot(48);
+ Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C0EPacketClickWindow(
+ chest.inventorySlots.windowId, 48, 0, 0, stack, transactionID));
+
+ cancelButtonAnimTime = System.currentTimeMillis();
+ } else if (!isChangingEnchLevel && enchanterCurrentEnch != null &&
+ (mouseX > left + 16 && mouseX <= left + 96 &&
+ mouseY > top && mouseY <= top + 16) ||
+ (mouseX > guiLeft + X_SIZE / 2 - 1 - 48 && mouseX <= guiLeft + X_SIZE / 2 - 1 &&
+ mouseY > top + 18 && mouseY <= top + 18 + 14)) {
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) return true;
+ GuiContainer chest = ((GuiContainer) Minecraft.getMinecraft().currentScreen);
+
+ EntityPlayerSP playerIn = Minecraft.getMinecraft().thePlayer;
+ short transactionID = playerIn.openContainer.getNextTransactionID(playerIn.inventory);
+ ItemStack stack = ((ContainerChest) chest.inventorySlots).getLowerChestInventory().getStackInSlot(
+ enchanterCurrentEnch.slotIndex);
+ Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C0EPacketClickWindow(
+ chest.inventorySlots.windowId,
+ enchanterCurrentEnch.slotIndex, 0, 0, stack, transactionID
+ ));
+
+ int playerXpLevel = Minecraft.getMinecraft().thePlayer.experienceLevel;
+ if (playerXpLevel >= enchanterCurrentEnch.xpCost) {
+ if (removingEnchantPlayerLevel >= 0 && enchanterCurrentEnch.level == removingEnchantPlayerLevel) {
+ spawnExperienceOrbs(guiLeft + X_SIZE / 2, guiTop + 66, X_SIZE / 2, 36, 3);
+ } else {
+ spawnExperienceOrbs(mouseX, mouseY, X_SIZE / 2, 66, 0);
+ }
+ }
+
+ confirmButtonAnimTime = System.currentTimeMillis();
+ } else if (mouseX > left + 96 && mouseX <= left + 96 + 16) {
+ if (!isChangingEnchLevel) {
+ if (mouseY > top && mouseY < top + 16) {
+ isChangingEnchLevel = true;
+ return true;
+ }
+ } else {
+ List<Enchantment> before = new ArrayList<>();
+ List<Enchantment> after = new ArrayList<>();
+
+ for (Enchantment ench : enchanterEnchLevels.values()) {
+ if (ench.level < enchanterCurrentEnch.level) {
+ before.add(ench);
+ } else if (ench.level > enchanterCurrentEnch.level) {
+ after.add(ench);
+ }
+ }
+
+ before.sort(Comparator.comparingInt(o -> -o.level));
+ after.sort(Comparator.comparingInt(o -> o.level));
+
+ int bSize = before.size();
+ int aSize = after.size();
+ for (int i = 0; i < bSize + aSize; i++) {
+ Enchantment ench;
+ int yIndex;
+ if (i < bSize) {
+ yIndex = -i - 1;
+ ench = before.get(i);
+ } else {
+ yIndex = i - bSize + 1;
+ ench = after.get(i - bSize);
+ }
+
+ if (mouseY > top + 16 * yIndex && mouseY <= top + 16 * yIndex + 16) {
+ enchanterCurrentEnch = ench;
+ isChangingEnchLevel = false;
+ return true;
+ }
+ }
+ }
+ }
+
+ if (isChangingEnchLevel) {
+ isChangingEnchLevel = false;
+ return true;
+ }
+ }
+ }
+
+ if (!Mouse.getEventButtonState() && Mouse.getEventButton() < 0 && clickedScrollOffset != -1) {
+ LerpingInteger lerpingInteger = isClickedScrollLeft ? leftScroll : rightScroll;
+ List<Enchantment> enchantsList = isClickedScrollLeft ? applicable : removable;
+
+ if (enchantsList.size() > 6) {
+ int newOffset = mouseY - clickedScrollOffset;
+
+ int newScroll = Math.round(newOffset * (float) ((enchantsList.size() - 6) * 16) / (96 - 15));
+ int max = (enchantsList.size() - 6) * 16;
+
+ if (newScroll > max) newScroll = max;
+ if (newScroll < 0) newScroll = 0;
+
+ lerpingInteger.setValue(newScroll);
+ }
+ }
+
+ //Config options
+ if (Mouse.getEventButtonState()) {
+ if (mouseX >= guiLeft + 294 && mouseX < guiLeft + 294 + 36 &&
+ mouseY >= guiTop + 146 && mouseY < guiTop + 146 + 36) {
+ int index = (mouseX - (guiLeft + 295)) / 18 + (mouseY - (guiTop + 147)) / 18 * 2;
+
+ int direction = Mouse.getEventButton() == 0 ? 1 : -1;
+
+ switch (index) {
+ case 0: {
+ NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enableTableGUI = false;
+ break;
+ }
+ /*case 1: {
int val = NotEnoughUpdates.INSTANCE.config.enchantingSolvers.incompatibleEnchants;
val += direction;
if (val < 0) val = 1;
if (val > 1) val = 0;
NotEnoughUpdates.INSTANCE.config.enchantingSolvers.incompatibleEnchants = val;
break;
- }
- case 2: {
- int val = NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enchantSorting;
- val += direction;
- if (val < 0) val = 1;
- if (val > 1) val = 0;
- NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enchantSorting = val;
- break;
- }
- case 3: {
- int val = NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enchantOrdering;
- val += direction;
- if (val < 0) val = 1;
- if (val > 1) val = 0;
- NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enchantOrdering = val;
- break;
- }
- }
- }
- }
-
- if(Mouse.getEventButton() == 0) {
- if(Mouse.getEventButtonState()) {
- if(mouseX > guiLeft+104 && mouseX < guiLeft+104+12) {
- int offset;
- if(applicable.size() <= 6) {
- offset = 0;
- } else {
- offset = Math.round((96-15) * (leftScroll.getValue() / (float)((applicable.size()-6)*16)));
- }
- if(mouseY >= guiTop+18+offset && mouseY < guiTop+18+offset+15) {
- isClickedScrollLeft = true;
- clickedScrollOffset = mouseY - offset;
- }
- } else if(mouseX > guiLeft+344 && mouseX < guiLeft+344+12) {
- int offset;
- if(removable.size() <= 6) {
- offset = 0;
- } else {
- offset = Math.round((96-15) * (rightScroll.getValue() / (float)((removable.size()-6)*16)));
- }
- if(mouseY >= guiTop+18+offset && mouseY < guiTop+18+offset+15) {
- isClickedScrollLeft = false;
- clickedScrollOffset = mouseY - offset;
- }
- }
- } else {
- clickedScrollOffset = -1;
- }
- }
-
- if(mouseY > guiTop+18 && mouseY < guiTop+18+96) {
- if(mouseX > guiLeft+8 && mouseX < guiLeft+8+96) {
- if(Mouse.getEventButton() == 0 && Mouse.getEventButtonState() &&
- Minecraft.getMinecraft().thePlayer.inventory.getItemStack() == null) {
- for(int i=0; i<7; i++) {
- int index = i + leftScroll.getValue() / 16;
- if(applicable.size() <= index) break;
-
- int top = guiTop - (leftScroll.getValue() % 16) + 18 + 16 * i;
- if(mouseX > guiLeft + 8 && mouseX <= guiLeft + 8 + 96 &&
- mouseY > top && mouseY <= top + 16) {
- Enchantment ench = applicable.get(index);
-
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) return true;
- GuiContainer chest = ((GuiContainer)Minecraft.getMinecraft().currentScreen);
-
- if(currentState == EnchantState.HAS_ITEM) {
- EntityPlayerSP playerIn = Minecraft.getMinecraft().thePlayer;
- short transactionID = playerIn.openContainer.getNextTransactionID(playerIn.inventory);
- ItemStack stack = ((ContainerChest)chest.inventorySlots).getLowerChestInventory().getStackInSlot(ench.slotIndex);
- Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C0EPacketClickWindow(
- chest.inventorySlots.windowId,
- ench.slotIndex, 0, 0, stack, transactionID));
- } else if(currentState == EnchantState.ADDING_ENCHANT) {
- EntityPlayerSP playerIn = Minecraft.getMinecraft().thePlayer;
- short transactionID = playerIn.openContainer.getNextTransactionID(playerIn.inventory);
- ItemStack stack = ((ContainerChest)chest.inventorySlots).getLowerChestInventory().getStackInSlot(48);
- Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C0EPacketClickWindow(
- chest.inventorySlots.windowId, 48, 0, 0, stack, transactionID));
-
- cancelButtonAnimTime = System.currentTimeMillis();
- }
-
- return true;
- }
- }
- }
-
- isScrollingLeft = true;
- } else if(mouseX > guiLeft+248 && mouseX < guiLeft+248+96) {
- if(Mouse.getEventButton() == 0 && Mouse.getEventButtonState() &&
- Minecraft.getMinecraft().thePlayer.inventory.getItemStack() == null) {
- for(int i=0; i<7; i++) {
- int index = i + rightScroll.getValue() / 16;
- if(removable.size() <= index) break;
-
- int top = guiTop - (rightScroll.getValue() % 16) + 18 + 16 * i;
- if(mouseX > guiLeft + 248 && mouseX <= guiLeft + 248 + 96 &&
- mouseY > top && mouseY <= top + 16) {
- Enchantment ench = removable.get(index);
-
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) return true;
- GuiContainer chest = ((GuiContainer)Minecraft.getMinecraft().currentScreen);
-
- if(currentState == EnchantState.HAS_ITEM) {
- EntityPlayerSP playerIn = Minecraft.getMinecraft().thePlayer;
- short transactionID = playerIn.openContainer.getNextTransactionID(playerIn.inventory);
- ItemStack stack = ((ContainerChest)chest.inventorySlots).getLowerChestInventory().getStackInSlot(ench.slotIndex);
- Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C0EPacketClickWindow(
- chest.inventorySlots.windowId,
- ench.slotIndex, 0, 0, stack, transactionID));
- } else if(currentState == EnchantState.ADDING_ENCHANT) {
- EntityPlayerSP playerIn = Minecraft.getMinecraft().thePlayer;
- short transactionID = playerIn.openContainer.getNextTransactionID(playerIn.inventory);
- ItemStack stack = ((ContainerChest)chest.inventorySlots).getLowerChestInventory().getStackInSlot(48);
- Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C0EPacketClickWindow(
- chest.inventorySlots.windowId, 48, 0, 0, stack, transactionID));
-
- cancelButtonAnimTime = System.currentTimeMillis();
- }
-
- return true;
- }
- }
- }
- isScrollingLeft = false;
- }
- }
- if(Mouse.getEventDWheel() != 0) {
- int scroll = Mouse.getEventDWheel();
- if(scroll > 0) {
- scroll = -16;
- } else {
- scroll = 16;
- }
-
- LerpingInteger lerpingInteger = isScrollingLeft ? leftScroll : rightScroll;
-
- int elementsCount = isScrollingLeft ? applicable.size() : removable.size();
- int max = (elementsCount-6)*16;
-
- int newTarget = lerpingInteger.getTarget()+scroll;
- if(newTarget > max) newTarget = max;
- if(newTarget < 0) newTarget = 0;
-
- if(newTarget != lerpingInteger.getTarget()) {
- lerpingInteger.resetTimer();
- lerpingInteger.setTarget(newTarget);
- }
- }
-
- if(mouseX > guiLeft+102 && mouseX < guiLeft+102+160) {
- if((mouseY > guiTop+133 && mouseY < guiTop+133+54) || (mouseY > guiTop+133+54+4 && mouseY < guiTop+133+54+4+18)) {
- if(currentState == EnchantState.ADDING_ENCHANT) {
- if(Mouse.getEventButtonState()) {
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) return true;
- GuiContainer chest = ((GuiContainer)Minecraft.getMinecraft().currentScreen);
-
- EntityPlayerSP playerIn = Minecraft.getMinecraft().thePlayer;
- short transactionID = playerIn.openContainer.getNextTransactionID(playerIn.inventory);
- ItemStack stack = ((ContainerChest)chest.inventorySlots).getLowerChestInventory().getStackInSlot(48);
- Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C0EPacketClickWindow(
- chest.inventorySlots.windowId, 48, 0, 0, stack, transactionID));
-
- cancelButtonAnimTime = System.currentTimeMillis();
- }
- return true;
- } else {
- return false;
- }
- }
- }
- if(mouseX >= guiLeft+173 && mouseX < guiLeft+173+18 &&
- mouseY >= guiTop+57 && mouseY < guiTop+57+18) {
- if(currentState == EnchantState.ADDING_ENCHANT) {
- if(Mouse.getEventButtonState()) {
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) return true;
- GuiContainer chest = ((GuiContainer)Minecraft.getMinecraft().currentScreen);
-
- EntityPlayerSP playerIn = Minecraft.getMinecraft().thePlayer;
- short transactionID = playerIn.openContainer.getNextTransactionID(playerIn.inventory);
- ItemStack stack = ((ContainerChest)chest.inventorySlots).getLowerChestInventory().getStackInSlot(48);
- Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C0EPacketClickWindow(
- chest.inventorySlots.windowId, 48, 0, 0, stack, transactionID));
-
- cancelButtonAnimTime = System.currentTimeMillis();
- }
- return true;
- } else {
- return false;
- }
- }
- return true;
- }
-
- public boolean keyboardInput() {
- if(currentState == EnchantState.HAS_ITEM && searchField.getFocus()) {
- if(Keyboard.getEventKeyState()) {
- searchField.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey());
- }
- return true;
- }
-
- return Keyboard.getEventKey() != Keyboard.KEY_ESCAPE &&
- (!NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotLocking ||
- Keyboard.getEventKey() != NotEnoughUpdates.INSTANCE.config.slotLocking.slotLockKey);
- }
+ }*/
+ case 2: {
+ int val = NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enchantSorting;
+ val += direction;
+ if (val < 0) val = 1;
+ if (val > 1) val = 0;
+ NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enchantSorting = val;
+ break;
+ }
+ case 3: {
+ int val = NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enchantOrdering;
+ val += direction;
+ if (val < 0) val = 1;
+ if (val > 1) val = 0;
+ NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enchantOrdering = val;
+ break;
+ }
+ }
+ }
+ }
+
+ if (Mouse.getEventButton() == 0) {
+ if (Mouse.getEventButtonState()) {
+ if (mouseX > guiLeft + 104 && mouseX < guiLeft + 104 + 12) {
+ int offset;
+ if (applicable.size() <= 6) {
+ offset = 0;
+ } else {
+ offset = Math.round((96 - 15) * (leftScroll.getValue() / (float) ((applicable.size() - 6) * 16)));
+ }
+ if (mouseY >= guiTop + 18 + offset && mouseY < guiTop + 18 + offset + 15) {
+ isClickedScrollLeft = true;
+ clickedScrollOffset = mouseY - offset;
+ }
+ } else if (mouseX > guiLeft + 344 && mouseX < guiLeft + 344 + 12) {
+ int offset;
+ if (removable.size() <= 6) {
+ offset = 0;
+ } else {
+ offset = Math.round((96 - 15) * (rightScroll.getValue() / (float) ((removable.size() - 6) * 16)));
+ }
+ if (mouseY >= guiTop + 18 + offset && mouseY < guiTop + 18 + offset + 15) {
+ isClickedScrollLeft = false;
+ clickedScrollOffset = mouseY - offset;
+ }
+ }
+ } else {
+ clickedScrollOffset = -1;
+ }
+ }
+
+ if (mouseY > guiTop + 18 && mouseY < guiTop + 18 + 96) {
+ if (mouseX > guiLeft + 8 && mouseX < guiLeft + 8 + 96) {
+ if (Mouse.getEventButton() == 0 && Mouse.getEventButtonState() &&
+ Minecraft.getMinecraft().thePlayer.inventory.getItemStack() == null) {
+ for (int i = 0; i < 7; i++) {
+ int index = i + leftScroll.getValue() / 16;
+ if (applicable.size() <= index) break;
+
+ int top = guiTop - (leftScroll.getValue() % 16) + 18 + 16 * i;
+ if (mouseX > guiLeft + 8 && mouseX <= guiLeft + 8 + 96 &&
+ mouseY > top && mouseY <= top + 16) {
+ Enchantment ench = applicable.get(index);
+
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) return true;
+ GuiContainer chest = ((GuiContainer) Minecraft.getMinecraft().currentScreen);
+
+ if (currentState == EnchantState.HAS_ITEM) {
+ EntityPlayerSP playerIn = Minecraft.getMinecraft().thePlayer;
+ short transactionID = playerIn.openContainer.getNextTransactionID(playerIn.inventory);
+ ItemStack stack =
+ ((ContainerChest) chest.inventorySlots).getLowerChestInventory().getStackInSlot(ench.slotIndex);
+ Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C0EPacketClickWindow(
+ chest.inventorySlots.windowId,
+ ench.slotIndex, 0, 0, stack, transactionID
+ ));
+ } else if (currentState == EnchantState.ADDING_ENCHANT) {
+ EntityPlayerSP playerIn = Minecraft.getMinecraft().thePlayer;
+ short transactionID = playerIn.openContainer.getNextTransactionID(playerIn.inventory);
+ ItemStack stack = ((ContainerChest) chest.inventorySlots).getLowerChestInventory().getStackInSlot(48);
+ Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C0EPacketClickWindow(
+ chest.inventorySlots.windowId, 48, 0, 0, stack, transactionID));
+
+ cancelButtonAnimTime = System.currentTimeMillis();
+ }
+
+ return true;
+ }
+ }
+ }
+
+ isScrollingLeft = true;
+ } else if (mouseX > guiLeft + 248 && mouseX < guiLeft + 248 + 96) {
+ if (Mouse.getEventButton() == 0 && Mouse.getEventButtonState() &&
+ Minecraft.getMinecraft().thePlayer.inventory.getItemStack() == null) {
+ for (int i = 0; i < 7; i++) {
+ int index = i + rightScroll.getValue() / 16;
+ if (removable.size() <= index) break;
+
+ int top = guiTop - (rightScroll.getValue() % 16) + 18 + 16 * i;
+ if (mouseX > guiLeft + 248 && mouseX <= guiLeft + 248 + 96 &&
+ mouseY > top && mouseY <= top + 16) {
+ Enchantment ench = removable.get(index);
+
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) return true;
+ GuiContainer chest = ((GuiContainer) Minecraft.getMinecraft().currentScreen);
+
+ if (currentState == EnchantState.HAS_ITEM) {
+ EntityPlayerSP playerIn = Minecraft.getMinecraft().thePlayer;
+ short transactionID = playerIn.openContainer.getNextTransactionID(playerIn.inventory);
+ ItemStack stack =
+ ((ContainerChest) chest.inventorySlots).getLowerChestInventory().getStackInSlot(ench.slotIndex);
+ Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C0EPacketClickWindow(
+ chest.inventorySlots.windowId,
+ ench.slotIndex, 0, 0, stack, transactionID
+ ));
+ } else if (currentState == EnchantState.ADDING_ENCHANT) {
+ EntityPlayerSP playerIn = Minecraft.getMinecraft().thePlayer;
+ short transactionID = playerIn.openContainer.getNextTransactionID(playerIn.inventory);
+ ItemStack stack = ((ContainerChest) chest.inventorySlots).getLowerChestInventory().getStackInSlot(48);
+ Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C0EPacketClickWindow(
+ chest.inventorySlots.windowId, 48, 0, 0, stack, transactionID));
+
+ cancelButtonAnimTime = System.currentTimeMillis();
+ }
+
+ return true;
+ }
+ }
+ }
+ isScrollingLeft = false;
+ }
+ }
+ if (Mouse.getEventDWheel() != 0) {
+ int scroll = Mouse.getEventDWheel();
+ if (scroll > 0) {
+ scroll = -16;
+ } else {
+ scroll = 16;
+ }
+
+ LerpingInteger lerpingInteger = isScrollingLeft ? leftScroll : rightScroll;
+
+ int elementsCount = isScrollingLeft ? applicable.size() : removable.size();
+ int max = (elementsCount - 6) * 16;
+
+ int newTarget = lerpingInteger.getTarget() + scroll;
+ if (newTarget > max) newTarget = max;
+ if (newTarget < 0) newTarget = 0;
+
+ if (newTarget != lerpingInteger.getTarget()) {
+ lerpingInteger.resetTimer();
+ lerpingInteger.setTarget(newTarget);
+ }
+ }
+
+ if (mouseX > guiLeft + 102 && mouseX < guiLeft + 102 + 160) {
+ if ((mouseY > guiTop + 133 && mouseY < guiTop + 133 + 54) ||
+ (mouseY > guiTop + 133 + 54 + 4 && mouseY < guiTop + 133 + 54 + 4 + 18)) {
+ if (currentState == EnchantState.ADDING_ENCHANT) {
+ if (Mouse.getEventButtonState()) {
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) return true;
+ GuiContainer chest = ((GuiContainer) Minecraft.getMinecraft().currentScreen);
+
+ EntityPlayerSP playerIn = Minecraft.getMinecraft().thePlayer;
+ short transactionID = playerIn.openContainer.getNextTransactionID(playerIn.inventory);
+ ItemStack stack = ((ContainerChest) chest.inventorySlots).getLowerChestInventory().getStackInSlot(48);
+ Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C0EPacketClickWindow(
+ chest.inventorySlots.windowId, 48, 0, 0, stack, transactionID));
+
+ cancelButtonAnimTime = System.currentTimeMillis();
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+ }
+ if (mouseX >= guiLeft + 173 && mouseX < guiLeft + 173 + 18 &&
+ mouseY >= guiTop + 57 && mouseY < guiTop + 57 + 18) {
+ if (currentState == EnchantState.ADDING_ENCHANT) {
+ if (Mouse.getEventButtonState()) {
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) return true;
+ GuiContainer chest = ((GuiContainer) Minecraft.getMinecraft().currentScreen);
+
+ EntityPlayerSP playerIn = Minecraft.getMinecraft().thePlayer;
+ short transactionID = playerIn.openContainer.getNextTransactionID(playerIn.inventory);
+ ItemStack stack = ((ContainerChest) chest.inventorySlots).getLowerChestInventory().getStackInSlot(48);
+ Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C0EPacketClickWindow(
+ chest.inventorySlots.windowId, 48, 0, 0, stack, transactionID));
+
+ cancelButtonAnimTime = System.currentTimeMillis();
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public boolean keyboardInput() {
+ if (currentState == EnchantState.HAS_ITEM && searchField.getFocus()) {
+ if (Keyboard.getEventKeyState()) {
+ searchField.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey());
+ }
+ return true;
+ }
+ if (Keyboard.getEventKey() == Minecraft.getMinecraft().gameSettings.keyBindScreenshot.getKeyCode()) {
+ return false;
+ }
+
+ return Keyboard.getEventKey() != Keyboard.KEY_ESCAPE &&
+ (!NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotLocking ||
+ Keyboard.getEventKey() != NotEnoughUpdates.INSTANCE.config.slotLocking.slotLockKey);
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java
index 4bbcdbdd..bd4bd680 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java
@@ -5,7 +5,6 @@ import com.google.common.collect.Lists;
import com.google.gson.*;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.core.util.lerp.LerpingInteger;
-import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils;
import io.github.moulberry.notenoughupdates.itemeditor.GuiElementTextField;
import io.github.moulberry.notenoughupdates.options.NEUConfig;
import io.github.moulberry.notenoughupdates.util.Constants;
@@ -15,6 +14,7 @@ import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Keyboard;
@@ -34,459 +34,634 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import static io.github.moulberry.notenoughupdates.util.GuiTextures.button_tex;
+import static io.github.moulberry.notenoughupdates.util.GuiTextures.help;
public class GuiEnchantColour extends GuiScreen {
-
- public static final ResourceLocation custom_ench_colour = new ResourceLocation("notenoughupdates:custom_ench_colour.png");
-
- private static final String sharePrefix = "NEUEC/";
-
- private int guiLeft;
- private int guiTop;
- private final int xSize = 217;
- private int ySize = 0;
- private int ySizeSidebar = 0;
- private int guiTopSidebar;
-
- public static final Splitter splitter = Splitter.on(":").limit(5);
-
- private HashMap<Integer, String> comparators = new HashMap<>();
- private HashMap<Integer, String> modifiers = new HashMap<>();
- private List<GuiElementTextField[]> guiElementTextFields = new ArrayList<>();
-
- private List<String> enchantNamesPretty = null;
- private JsonArray enchantPresets = null;
-
- private LerpingInteger scroll = new LerpingInteger(0, 100);
- private LerpingInteger scrollSideBar = new LerpingInteger(0, 100);
-
- public static int BOLD_MODIFIER = 0b1;
- public static int ITALIC_MODIFIER = 0b10;
- public static int OBFUSCATED_MODIFIER = 0b100;
- public static int UNDERLINE_MODIFIER = 0b1000;
- public static int STRIKETHROUGH_MODIFIER = 0b10000;
- private Gson gson = new Gson();
- private static final Pattern settingPattern = Pattern.compile(".*:[>=<]:[0-9]+:[a-zA-Z0-9]+(:[a-zA-Z0-9])?");
-
- private List<String> getEnchantNamesPretty() {
- if(enchantNamesPretty == null) {
- JsonObject enchantsJson = Constants.ENCHANTS;
- if(!enchantsJson.has("enchants_pretty")) {
- return Lists.newArrayList("ERROR");
- } else {
- JsonArray pretty = enchantsJson.getAsJsonArray("enchants_pretty");
-
- enchantNamesPretty = new ArrayList<>();
- for(int i=0; i<pretty.size(); i++) {
- enchantNamesPretty.add(pretty.get(i).getAsString());
- }
- }
- }
- return enchantNamesPretty;
- }
-
- private List<String> getEnchantColours() {
- return NotEnoughUpdates.INSTANCE.config.hidden.enchantColours;
- }
-
- @Override
- public void drawScreen(int mouseX, int mouseY, float partialTicks) {
- drawDefaultBackground();
-
- List<String> enchantColours = getEnchantColours();
-
- ySize = 53+25*enchantColours.size();
- guiLeft = (width-xSize)/2;
-
-
- if(ySize > height) {
-
- if (scroll.getTarget() > 0) {
- scroll.setTarget(0);
- } else if (scroll.getTarget() < height - ySize) {
- scroll.setTarget(height - ySize);
- }
- scroll.tick();
- guiTop = scroll.getValue();
-
- } else {
- guiTop = (height-ySize)/2;
- scroll.setValue(0);
- scroll.resetTimer();
- }
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(custom_ench_colour);
- Utils.drawTexturedRect(guiLeft, guiTop, xSize, 21, 0, 1, 0, 21/78f, GL11.GL_NEAREST);
- Utils.drawTexturedRect(guiLeft, guiTop+ySize-32, xSize, 32, 0, 1, 46/78f, 1, GL11.GL_NEAREST);
-
- fontRendererObj.drawString("Ench Name", guiLeft+10, guiTop+7, 4210752);
- fontRendererObj.drawString("CMP", guiLeft+86, guiTop+7, 4210752);
- fontRendererObj.drawString("LVL", guiLeft+111, guiTop+7, 4210752);
- fontRendererObj.drawString("COL", guiLeft+136, guiTop+7, 4210752);
- fontRendererObj.drawString("DEL", guiLeft+161, guiTop+7, 4210752);
-
- Utils.drawStringCentered("Add Ench Colour", fontRendererObj, guiLeft+xSize/2+1, guiTop+ySize-20, false, 4210752);
-
- int yIndex = 0;
- for(String str : enchantColours) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(custom_ench_colour);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(guiLeft, guiTop+21+yIndex*25, xSize, 25, 0, 1, 21/78f, 46/78f, GL11.GL_NEAREST);
-
- List<String> colourOps = splitter.splitToList(str);
- String enchantName = getColourOpIndex(colourOps, 0);
- String comparator = getColourOpIndex(colourOps, 1);
- String comparison = getColourOpIndex(colourOps, 2);
- String colourCode = getColourOpIndex(colourOps, 3);
- String modifier = getColourOpIndex(colourOps, 4);
- modifiers.put(yIndex, modifier);
-
- if(colourCode.length() > 1) colourCode = String.valueOf(colourCode.toLowerCase().charAt(0));
- if(comparator.length() > 1) comparator = String.valueOf(comparator.toLowerCase().charAt(0));
-
- Utils.drawStringCentered(comparator, fontRendererObj, guiLeft+96, guiTop+33+25*yIndex, false, 4210752);
-
- if(guiElementTextFields.size() <= yIndex) {
- guiElementTextFields.add(new GuiElementTextField[3]);
- }
- if(guiElementTextFields.get(yIndex)[0] == null) {
- guiElementTextFields.get(yIndex)[0] = new GuiElementTextField(enchantName, GuiElementTextField.SCALE_TEXT);
- guiElementTextFields.get(yIndex)[0].setSize(75, 20);
- }
- if(guiElementTextFields.get(yIndex)[1] == null) {
- guiElementTextFields.get(yIndex)[1] = new GuiElementTextField(comparison,
- GuiElementTextField.SCALE_TEXT|GuiElementTextField.NUM_ONLY|GuiElementTextField.NO_SPACE);
- guiElementTextFields.get(yIndex)[1].setSize(20, 20);
- }
- if(guiElementTextFields.get(yIndex)[2] == null) {
- guiElementTextFields.get(yIndex)[2] = new GuiElementTextField(colourCode, GuiElementTextField.SCALE_TEXT);
- guiElementTextFields.get(yIndex)[2].setSize(20, 20);
- }
- guiElementTextFields.get(yIndex)[0].setText(enchantName);
- guiElementTextFields.get(yIndex)[1].setText(comparison);
- comparators.put(yIndex, comparator);
- guiElementTextFields.get(yIndex)[2].setText(colourCode);
-
- guiElementTextFields.get(yIndex)[0].render(guiLeft+7, guiTop+23+25*yIndex);
- guiElementTextFields.get(yIndex)[1].render(guiLeft+110, guiTop+23+25*yIndex);
- guiElementTextFields.get(yIndex)[2].render(guiLeft+135, guiTop+23+25*yIndex);
-
- int modifierI = getIntModifier(modifier);
- if((modifierI & GuiEnchantColour.BOLD_MODIFIER) != 0) {
- Minecraft.getMinecraft().fontRendererObj.drawString("\u00a7l\u2713", guiLeft+181, guiTop+23+25*yIndex-2, 0xff202020, true);
- }
- if((modifierI & GuiEnchantColour.ITALIC_MODIFIER) != 0) {
- Minecraft.getMinecraft().fontRendererObj.drawString("\u00a7l\u2713", guiLeft+181, guiTop+23+25*yIndex+10, 0xff202020, true);
- }
- if((modifierI & GuiEnchantColour.UNDERLINE_MODIFIER) != 0) {
- Minecraft.getMinecraft().fontRendererObj.drawString("\u00a7l\u2713", guiLeft+196, guiTop+23+25*yIndex-2, 0xff202020, true);
- }
- if((modifierI & GuiEnchantColour.STRIKETHROUGH_MODIFIER) != 0) {
- Minecraft.getMinecraft().fontRendererObj.drawString("\u00a7l\u2713", guiLeft+196, guiTop+23+25*yIndex+10, 0xff202020, true);
- }
-
- yIndex++;
- }
- renderSideBar(mouseX, mouseY, partialTicks);
- }
-
- private void renderSideBar(int mouseX, int mouseY, float partialTicks){
- ySizeSidebar = 24*(2);
-
- if(ySizeSidebar > height) {
-
- if (scrollSideBar.getTarget() > 0) {
- scrollSideBar.setTarget(0);
- } else if (scrollSideBar.getTarget() < height - ySizeSidebar) {
- scrollSideBar.setTarget(height - ySizeSidebar);
- }
-
- scrollSideBar.tick();
- guiTopSidebar = scrollSideBar.getValue();
-
- } else {
- guiTopSidebar = (height-ySizeSidebar)/2;
- scrollSideBar.setValue(0);
- scrollSideBar.resetTimer();
- }
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(custom_ench_colour);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(guiLeft+xSize+3, guiTopSidebar+2, 88, 20, 64/217f, 152/217f, 48/78f, 68/78f, GL11.GL_NEAREST);
- Utils.drawTexturedRect(guiLeft+xSize+3, guiTopSidebar+2+24, 88, 20, 64/217f, 152/217f, 48/78f, 68/78f, GL11.GL_NEAREST);
- Utils.drawTexturedRect(guiLeft+xSize+3, guiTopSidebar+2+24*2, 88, 20, 64/217f, 152/217f, 48/78f, 68/78f, GL11.GL_NEAREST);
- Utils.drawStringCenteredScaledMaxWidth("Load preset", fontRendererObj, guiLeft+xSize+4+44, guiTopSidebar+8, false, 86, 4210752);
- Utils.drawStringCenteredScaledMaxWidth("from Clipboard", fontRendererObj, guiLeft+xSize+4+44, guiTopSidebar+16, false, 86, 4210752);
- Utils.drawStringCenteredScaledMaxWidth("Save preset", fontRendererObj, guiLeft+xSize+4+44, guiTopSidebar+8+24, false, 86, 4210752);
- Utils.drawStringCenteredScaledMaxWidth("to Clipboard", fontRendererObj, guiLeft+xSize+4+44, guiTopSidebar+16+24, false, 86, 4210752);
- Utils.drawStringCenteredScaledMaxWidth("Reset Config", fontRendererObj, guiLeft+xSize+4+44, guiTopSidebar+12+24*2, false, 86, 4210752);
-
- if(!validShareContents()) {
- Gui.drawRect(guiLeft+xSize+3, guiTopSidebar+2, guiLeft+xSize+3+88, guiTopSidebar+2+20, 0x80000000);
- }
- }
-
- @Override
- protected void keyTyped(char typedChar, int keyCode) throws IOException {
- super.keyTyped(typedChar, keyCode);
- for(int yIndex=0; yIndex<guiElementTextFields.size(); yIndex++) {
- for(int i=0; i<3; i++) {
- guiElementTextFields.get(yIndex)[i].keyTyped(typedChar, keyCode);
- if(guiElementTextFields.get(yIndex)[i].getFocus()) {
- int addOffset = 0;
- if(keyCode == Keyboard.KEY_UP) {
- addOffset -= 1;
- } else if(keyCode == Keyboard.KEY_DOWN) {
- addOffset += 1;
- }
-
- NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.remove(yIndex);
- if(yIndex+addOffset < 0) {
- addOffset = -yIndex;
- } else if(yIndex+addOffset > NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.size()) {
- addOffset = NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.size()-yIndex;
- }
- NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.add(yIndex+addOffset,
- getEnchantOpString(guiElementTextFields.get(yIndex), comparators.get(yIndex), modifiers.get(yIndex)));
- if(addOffset != 0) {
- GuiElementTextField[] guiElementTextFieldArray = guiElementTextFields.remove(yIndex);
- guiElementTextFields.add(yIndex+addOffset, guiElementTextFieldArray);
- }
- return;
- }
- }
- }
- }
-
- public String getEnchantOpString(GuiElementTextField[] tfs, String comparator, String modifiers) {
- StringBuilder enchantOp = new StringBuilder();
- enchantOp.append(tfs[0].getText());
- enchantOp.append(":");
- enchantOp.append(comparator);
- enchantOp.append(":");
- enchantOp.append(tfs[1].getText());
- enchantOp.append(":");
- enchantOp.append(tfs[2].getText());
- enchantOp.append(":");
- enchantOp.append(modifiers);
- return enchantOp.toString();
- }
-
- @Override
- public void handleMouseInput() throws IOException {
- super.handleMouseInput();
-
- int dWheel = Mouse.getEventDWheel();
- int mouseX = Mouse.getEventX() * this.width / this.mc.displayWidth;
- if(mouseX > guiLeft && mouseX < guiLeft + xSize) {
- if (dWheel < 0) {
- scroll.setTarget(scroll.getTarget() - 50);
- scroll.resetTimer();
- } else if (dWheel > 0) {
- scroll.setTarget(scroll.getTarget() + 50);
- scroll.resetTimer();
- }
- } else if(mouseX > guiLeft+xSize && mouseX < guiLeft + xSize+ 100) {
- if (dWheel < 0) {
- scrollSideBar.setTarget(scrollSideBar.getTarget() - 50);
- scrollSideBar.resetTimer();
- } else if (dWheel > 0) {
- scrollSideBar.setTarget(scrollSideBar.getTarget() + 50);
- scrollSideBar.resetTimer();
- }
- }
-
- }
-
- public static int getIntModifier(String modifier) {
- try {
- return Integer.parseInt(modifier);
- } catch(NumberFormatException e) {
- return 0;
- }
- }
-
- private boolean validShareContents() {
- try {
- String base64 = (String)Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor);
-
- if(base64.length() <= sharePrefix.length()) return false;
-
- try {
- return new String(Base64.getDecoder().decode(base64)).startsWith(sharePrefix);
- } catch (IllegalArgumentException e){
- return false;
- }
- } catch (HeadlessException | IOException | UnsupportedFlavorException | IllegalStateException e) {
- return false;
- }
- }
-
- @Override
- protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
- super.mouseClicked(mouseX, mouseY, mouseButton);
- for(int yIndex=0; yIndex<guiElementTextFields.size(); yIndex++) {
- for(int i=0; i<3; i++) {
- int x = guiLeft+7;
- if(i == 1) x+=103;
- else if(i == 2) x+=128;
-
- if(mouseX > x && mouseX < x+guiElementTextFields.get(yIndex)[i].getWidth()) {
- if(mouseY > guiTop+23+25*yIndex && mouseY < guiTop+23+25*yIndex+20) {
- guiElementTextFields.get(yIndex)[i].mouseClicked(mouseX, mouseY, mouseButton);
- if(mouseButton == 1) {
- NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.remove(yIndex);
- NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.add(yIndex,
- getEnchantOpString(guiElementTextFields.get(yIndex), comparators.get(yIndex), modifiers.get(yIndex)));
- }
- continue;
- }
- }
- guiElementTextFields.get(yIndex)[i].otherComponentClick();
- }
- comparators.putIfAbsent(yIndex, ">");
- modifiers.putIfAbsent(yIndex, "0");
- if(mouseX >= guiLeft+180 && mouseX <= guiLeft+210 &&
- mouseY >= guiTop+23+25*yIndex && mouseY <= guiTop+23+25*yIndex+20) {
- int modifierI = getIntModifier(modifiers.get(yIndex));
- int selectedModifier = -1;
-
- if(mouseX < guiLeft+195) {
- if(mouseY < guiTop+23+25*yIndex+10) {
- selectedModifier = BOLD_MODIFIER;
- } else {
- selectedModifier = ITALIC_MODIFIER;
- }
- } else {
- if(mouseY < guiTop+23+25*yIndex+10) {
- selectedModifier = UNDERLINE_MODIFIER;
- } else {
- selectedModifier = STRIKETHROUGH_MODIFIER;
- }
- }
-
- if(selectedModifier != -1) {
- int modifierMasked = (modifierI & selectedModifier);
- int modifierMaskedInverted = selectedModifier - modifierMasked;
-
- int modifierInverted = (-1) - selectedModifier;
-
- int finalModifier = (modifierI & modifierInverted) | modifierMaskedInverted;
-
- modifiers.put(yIndex, ""+finalModifier);
-
- NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.remove(yIndex);
- NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.add(yIndex,
- getEnchantOpString(guiElementTextFields.get(yIndex), comparators.get(yIndex), modifiers.get(yIndex)));
- }
- }
- if(mouseY > guiTop+23+25*yIndex && mouseY < guiTop+23+25*yIndex+20) {
- if(mouseX > guiLeft+86 && mouseX < guiLeft+86+20) {
- switch (comparators.get(yIndex)) {
- case ">":
- comparators.put(yIndex, "="); break;
- case "=":
- comparators.put(yIndex, "<"); break;
- default:
- comparators.put(yIndex, ">"); break;
- }
- NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.remove(yIndex);
- NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.add(yIndex,
- getEnchantOpString(guiElementTextFields.get(yIndex), comparators.get(yIndex), modifiers.get(yIndex)));
- } else if(mouseX > guiLeft+160 && mouseX < guiLeft+160+20) {
- NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.remove(yIndex);
- guiElementTextFields.remove(yIndex);
- comparators.remove(yIndex);
- modifiers.remove(yIndex);
- }
- }
- }
- if(mouseX >= guiLeft+57 && mouseX <= guiLeft+xSize-57) {
- if(mouseY >= guiTop+ySize-30 && mouseY <= guiTop+ySize-10) {
- NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.add("[a-zA-Z\\- ]+:>:5:9:0");
- }
- }
- if(mouseX > guiLeft+xSize+3 && mouseX< guiLeft+xSize+3+88){
- if(mouseY > guiTopSidebar+2 && mouseY < guiTopSidebar+20+2){
-
- String base64;
-
- try {
- base64 = (String)Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor);
- } catch (HeadlessException | IOException | UnsupportedFlavorException e) {
- return;
- }
-
- if(base64.length() <= sharePrefix.length()) return;
-
- String jsonString;
- try {
- jsonString = new String(Base64.getDecoder().decode(base64));
- if(!jsonString.startsWith(sharePrefix)) return;
- jsonString = jsonString.substring(sharePrefix.length());
- } catch (IllegalArgumentException e){
- return;
- }
-
- System.out.println(jsonString);
-
- JsonArray presetArray;
- try{
- presetArray = new JsonParser().parse(jsonString).getAsJsonArray();
- } catch (IllegalStateException | JsonParseException e){
- return;
- }
- ArrayList<String> presetList = new ArrayList<>();
-
-
- for (int i = 0; i < presetArray.size(); i++) {
- if (presetArray.get(i).isJsonPrimitive()) {
- String test = presetArray.get(i).getAsString();
- Matcher matcher = settingPattern.matcher(test);
- if(matcher.matches()) {
- presetList.add(presetArray.get(i).getAsString());
- }
- }
- }
- if(presetList.size() != 0) {
- NotEnoughUpdates.INSTANCE.config.hidden.enchantColours = presetList;
- }
-
-
- } else if(mouseY > guiTopSidebar+2+24 && mouseY < guiTopSidebar+20+24+2){
-
- ArrayList<String> result = NotEnoughUpdates.INSTANCE.config.hidden.enchantColours;
- JsonArray jsonArray = new JsonArray();
-
- for (int i = 0; i < result.size(); i++) {
- jsonArray.add(new JsonPrimitive(result.get(i)));
- }
- String base64String = Base64.getEncoder().encodeToString((sharePrefix+jsonArray).getBytes(StandardCharsets.UTF_8));
- Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(base64String), null);
- } else if(mouseY > guiTopSidebar+2+(24*2) && mouseY < guiTopSidebar+20+2+24*2){
- NotEnoughUpdates.INSTANCE.config.hidden.enchantColours = NEUConfig.createDefaultEnchantColours();
- }
- }
- }
-
- public static String getColourOpIndex(List<String> colourOps, int index) {
- if(colourOps.size() > index) {
- return colourOps.get(index);
- } else {
- switch(index) {
- case 0:
- return "[a-zA-Z\\- ]+";
- case 1:
- return ">";
- case 2:
- return "5";
- case 3:
- return "9";
- case 4:
- return "0";
- }
- }
- return null;
- }
+ public static final ResourceLocation custom_ench_colour = new ResourceLocation(
+ "notenoughupdates:custom_ench_colour.png");
+
+ private static final String sharePrefix = "NEUEC/";
+
+ private int guiLeft;
+ private int guiTop;
+ private final int xSize = 217;
+ private int ySize = 0;
+ private int ySizeSidebar = 0;
+ private int guiTopSidebar;
+
+ public static final Splitter splitter = Splitter.on(":").limit(5);
+
+ private final HashMap<Integer, String> comparators = new HashMap<>();
+ private final HashMap<Integer, String> modifiers = new HashMap<>();
+ private final List<GuiElementTextField[]> guiElementTextFields = new ArrayList<>();
+
+ private final LerpingInteger scroll = new LerpingInteger(0, 100);
+ private final LerpingInteger scrollSideBar = new LerpingInteger(0, 100);
+
+ public static int BOLD_MODIFIER = 0b1;
+ public static int ITALIC_MODIFIER = 0b10;
+ public static int OBFUSCATED_MODIFIER = 0b100;
+ public static int UNDERLINE_MODIFIER = 0b1000;
+ public static int STRIKETHROUGH_MODIFIER = 0b10000;
+ private static final Pattern settingPattern = Pattern.compile(".*:[>=<]:[0-9]+:[a-zA-Z0-9]+(:[a-zA-Z0-9]+)?");
+
+ private ItemStack maxedBook;
+ private int maxedBookFound = 0;
+
+ private List<String> getEnchantColours() {
+ return NotEnoughUpdates.INSTANCE.config.hidden.enchantColours;
+ }
+
+ @Override
+ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
+ drawDefaultBackground();
+
+ List<String> enchantColours = getEnchantColours();
+
+ ySize = 53 + 25 * enchantColours.size();
+ guiLeft = (width - xSize) / 2;
+
+ if (ySize > height) {
+
+ if (scroll.getTarget() > 0) {
+ scroll.setTarget(0);
+ } else if (scroll.getTarget() < height - ySize) {
+ scroll.setTarget(height - ySize);
+ }
+ scroll.tick();
+ guiTop = scroll.getValue();
+
+ } else {
+ guiTop = (height - ySize) / 2;
+ scroll.setValue(0);
+ scroll.resetTimer();
+ }
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(custom_ench_colour);
+ Utils.drawTexturedRect(guiLeft, guiTop, xSize, 21, 0, 1, 0, 21 / 78f, GL11.GL_NEAREST);
+ Utils.drawTexturedRect(guiLeft, guiTop + ySize - 32, xSize, 32, 0, 1, 46 / 78f, 1, GL11.GL_NEAREST);
+
+ fontRendererObj.drawString("Ench Name", guiLeft + 10, guiTop + 7, 4210752);
+ fontRendererObj.drawString("CMP", guiLeft + 86, guiTop + 7, 4210752);
+ fontRendererObj.drawString("LVL", guiLeft + 111, guiTop + 7, 4210752);
+ fontRendererObj.drawString("COL", guiLeft + 136, guiTop + 7, 4210752);
+ fontRendererObj.drawString("DEL", guiLeft + 161, guiTop + 7, 4210752);
+
+ Utils.drawStringCentered(
+ "Add Ench Colour",
+ fontRendererObj,
+ guiLeft + xSize / 2 + 1,
+ guiTop + ySize - 20,
+ false,
+ 4210752
+ );
+
+ int yIndex = 0;
+ for (String str : enchantColours) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(custom_ench_colour);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(guiLeft, guiTop + 21 + yIndex * 25, xSize, 25, 0, 1, 21 / 78f, 46 / 78f, GL11.GL_NEAREST);
+
+ List<String> colourOps = splitter.splitToList(str);
+ String enchantName = getColourOpIndex(colourOps, 0);
+ String comparator = getColourOpIndex(colourOps, 1);
+ String comparison = getColourOpIndex(colourOps, 2);
+ String colourCode = getColourOpIndex(colourOps, 3);
+ String modifier = getColourOpIndex(colourOps, 4);
+ modifiers.put(yIndex, modifier);
+
+ if (colourCode.length() > 1) colourCode = String.valueOf(colourCode.toLowerCase().charAt(0));
+ if (comparator.length() > 1) comparator = String.valueOf(comparator.toLowerCase().charAt(0));
+
+ Utils.drawStringCentered(comparator, fontRendererObj, guiLeft + 96, guiTop + 33 + 25 * yIndex, false, 4210752);
+
+ if (guiElementTextFields.size() <= yIndex) {
+ guiElementTextFields.add(new GuiElementTextField[3]);
+ }
+ if (guiElementTextFields.get(yIndex)[0] == null) {
+ guiElementTextFields.get(yIndex)[0] = new GuiElementTextField(enchantName, GuiElementTextField.SCALE_TEXT);
+ guiElementTextFields.get(yIndex)[0].setSize(75, 20);
+ }
+ if (guiElementTextFields.get(yIndex)[1] == null) {
+ guiElementTextFields.get(yIndex)[1] = new GuiElementTextField(
+ comparison,
+ GuiElementTextField.SCALE_TEXT | GuiElementTextField.NUM_ONLY | GuiElementTextField.NO_SPACE
+ );
+ guiElementTextFields.get(yIndex)[1].setSize(20, 20);
+ }
+ if (guiElementTextFields.get(yIndex)[2] == null) {
+ guiElementTextFields.get(yIndex)[2] = new GuiElementTextField(colourCode, GuiElementTextField.SCALE_TEXT);
+ guiElementTextFields.get(yIndex)[2].setSize(20, 20);
+ }
+ guiElementTextFields.get(yIndex)[0].setText(enchantName);
+ guiElementTextFields.get(yIndex)[1].setText(comparison);
+ comparators.put(yIndex, comparator);
+ guiElementTextFields.get(yIndex)[2].setText(colourCode);
+
+ guiElementTextFields.get(yIndex)[0].render(guiLeft + 7, guiTop + 23 + 25 * yIndex);
+ guiElementTextFields.get(yIndex)[1].render(guiLeft + 110, guiTop + 23 + 25 * yIndex);
+ guiElementTextFields.get(yIndex)[2].render(guiLeft + 135, guiTop + 23 + 25 * yIndex);
+
+ int modifierI = getIntModifier(modifier);
+ if ((modifierI & GuiEnchantColour.BOLD_MODIFIER) != 0) {
+ Minecraft.getMinecraft().fontRendererObj.drawString(
+ "\u00a7l\u2713",
+ guiLeft + 181,
+ guiTop + 23 + 25 * yIndex - 2,
+ 0xff202020,
+ true
+ );
+ }
+ if ((modifierI & GuiEnchantColour.ITALIC_MODIFIER) != 0) {
+ Minecraft.getMinecraft().fontRendererObj.drawString(
+ "\u00a7l\u2713",
+ guiLeft + 181,
+ guiTop + 23 + 25 * yIndex + 10,
+ 0xff202020,
+ true
+ );
+ }
+ if ((modifierI & GuiEnchantColour.UNDERLINE_MODIFIER) != 0) {
+ Minecraft.getMinecraft().fontRendererObj.drawString(
+ "\u00a7l\u2713",
+ guiLeft + 196,
+ guiTop + 23 + 25 * yIndex - 2,
+ 0xff202020,
+ true
+ );
+ }
+ if ((modifierI & GuiEnchantColour.STRIKETHROUGH_MODIFIER) != 0) {
+ Minecraft.getMinecraft().fontRendererObj.drawString(
+ "\u00a7l\u2713",
+ guiLeft + 196,
+ guiTop + 23 + 25 * yIndex + 10,
+ 0xff202020,
+ true
+ );
+ }
+
+ yIndex++;
+ }
+ renderSideBar(mouseX, mouseY, partialTicks);
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+ List<String> tooltipToDisplay = null;
+ GlStateManager.color(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(help);
+ Utils.drawTexturedRect(guiLeft + xSize + 3, guiTopSidebar - 18, 16, 16, GL11.GL_NEAREST);
+ if (maxedBookFound == 0) {
+ try {
+ if (NotEnoughUpdates.INSTANCE.manager.jsonToStack(
+ NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("MAXED_ENCHANT_BOOK")).hasDisplayName()) {
+ maxedBook = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("MAXED_ENCHANT_BOOK"));
+ maxedBookFound = 1;
+ } else {
+ maxedBookFound = 2;
+ }
+
+ } catch (Exception ignored) {
+ maxedBookFound = 2;
+ }
+ }
+ if (maxedBookFound == 1) {
+ Utils.drawItemStack(maxedBook, guiLeft + xSize + 3, guiTopSidebar - 34);
+ }
+
+ if (mouseX >= guiLeft + xSize + 3 && mouseX < guiLeft + xSize + 19) {
+ if (mouseY >= guiTopSidebar - 34 && mouseY <= guiTopSidebar - 18 && maxedBookFound == 1) {
+ tooltipToDisplay = maxedBook.getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, fr);
+ tooltipToDisplay = null;
+ }
+ if (mouseY >= guiTopSidebar - 18 && mouseY <= guiTopSidebar - 2) {
+ tooltipToDisplay = Lists.newArrayList(
+ EnumChatFormatting.AQUA + "NEUEC Colouring Guide",
+ EnumChatFormatting.GREEN + "",
+ EnumChatFormatting.GREEN + "How to use the GUI",
+ EnumChatFormatting.YELLOW + "Type the name of the enchant you want to colour in the left box",
+ EnumChatFormatting.YELLOW + "Change the comparison: ",
+ EnumChatFormatting.RED + "> " + EnumChatFormatting.YELLOW + "greater than a level ",
+ EnumChatFormatting.RED + "= " + EnumChatFormatting.YELLOW + "equals the level ",
+ EnumChatFormatting.RED + "< " + EnumChatFormatting.YELLOW + "less than a level",
+ EnumChatFormatting.YELLOW + "Put the level of enchant you want to color in the middle box",
+ EnumChatFormatting.YELLOW + "Put the color code you want to use here",
+ EnumChatFormatting.GREEN + "",
+ EnumChatFormatting.GREEN + "Available colour codes:",
+ Utils.chromaString("z = Chroma"),
+ EnumChatFormatting.DARK_BLUE + "1 = Dark Blue",
+ EnumChatFormatting.DARK_GREEN + "2 = Dark Green",
+ EnumChatFormatting.DARK_AQUA + "3 = Dark Aqua",
+ EnumChatFormatting.DARK_RED + "4 = Dark Red",
+ EnumChatFormatting.DARK_PURPLE + "5 = Dark Purple",
+ EnumChatFormatting.GOLD + "6 = Gold",
+ EnumChatFormatting.GRAY + "7 = Gray",
+ EnumChatFormatting.DARK_GRAY + "8 = Dark Gray",
+ EnumChatFormatting.BLUE + "9 = Blue",
+ EnumChatFormatting.GREEN + "a = Green",
+ EnumChatFormatting.AQUA + "b = Aqua",
+ EnumChatFormatting.RED + "c = Red",
+ EnumChatFormatting.LIGHT_PURPLE + "d = Purple",
+ EnumChatFormatting.YELLOW + "e = Yellow",
+ EnumChatFormatting.WHITE + "f = White",
+ "\u00A7ZZ = SBA Chroma" + EnumChatFormatting.RESET + EnumChatFormatting.GRAY + " (Requires SBA)",
+ "",
+ EnumChatFormatting.GREEN + "Available formatting:",
+ EnumChatFormatting.GRAY + "" + EnumChatFormatting.BOLD + "B = " + EnumChatFormatting.BOLD + "Bold",
+ EnumChatFormatting.GRAY + "" + EnumChatFormatting.STRIKETHROUGH + "S" + EnumChatFormatting.RESET +
+ EnumChatFormatting.GRAY + " = " + EnumChatFormatting.STRIKETHROUGH + "Strikethrough",
+ EnumChatFormatting.GRAY + "" + EnumChatFormatting.UNDERLINE + "U" + EnumChatFormatting.RESET +
+ EnumChatFormatting.GRAY + " = " + EnumChatFormatting.UNDERLINE + "Underline",
+ EnumChatFormatting.GRAY + "" + EnumChatFormatting.ITALIC + "I" + EnumChatFormatting.RESET +
+ EnumChatFormatting.GRAY + " = " + EnumChatFormatting.ITALIC + "Italic"
+ );
+ Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, fr);
+ tooltipToDisplay = null;
+ }
+ }
+
+ }
+
+ private void renderSideBar(int mouseX, int mouseY, float partialTicks) {
+ ySizeSidebar = 24 * (2);
+
+ if (ySizeSidebar > height) {
+
+ if (scrollSideBar.getTarget() > 0) {
+ scrollSideBar.setTarget(0);
+ } else if (scrollSideBar.getTarget() < height - ySizeSidebar) {
+ scrollSideBar.setTarget(height - ySizeSidebar);
+ }
+
+ scrollSideBar.tick();
+ guiTopSidebar = scrollSideBar.getValue();
+
+ } else {
+ guiTopSidebar = (height - ySizeSidebar) / 2;
+ scrollSideBar.setValue(0);
+ scrollSideBar.resetTimer();
+ }
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(custom_ench_colour);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(
+ guiLeft + xSize + 3,
+ guiTopSidebar + 2,
+ 88,
+ 20,
+ 64 / 217f,
+ 152 / 217f,
+ 48 / 78f,
+ 68 / 78f,
+ GL11.GL_NEAREST
+ );
+ Utils.drawTexturedRect(
+ guiLeft + xSize + 3,
+ guiTopSidebar + 2 + 24,
+ 88,
+ 20,
+ 64 / 217f,
+ 152 / 217f,
+ 48 / 78f,
+ 68 / 78f,
+ GL11.GL_NEAREST
+ );
+ Utils.drawTexturedRect(
+ guiLeft + xSize + 3,
+ guiTopSidebar + 2 + 24 * 2,
+ 88,
+ 20,
+ 64 / 217f,
+ 152 / 217f,
+ 48 / 78f,
+ 68 / 78f,
+ GL11.GL_NEAREST
+ );
+ Utils.drawStringCenteredScaledMaxWidth(
+ "Load preset",
+ fontRendererObj,
+ guiLeft + xSize + 4 + 44,
+ guiTopSidebar + 8,
+ false,
+ 86,
+ 4210752
+ );
+ Utils.drawStringCenteredScaledMaxWidth(
+ "from Clipboard",
+ fontRendererObj,
+ guiLeft + xSize + 4 + 44,
+ guiTopSidebar + 16,
+ false,
+ 86,
+ 4210752
+ );
+ Utils.drawStringCenteredScaledMaxWidth(
+ "Save preset",
+ fontRendererObj,
+ guiLeft + xSize + 4 + 44,
+ guiTopSidebar + 8 + 24,
+ false,
+ 86,
+ 4210752
+ );
+ Utils.drawStringCenteredScaledMaxWidth(
+ "to Clipboard",
+ fontRendererObj,
+ guiLeft + xSize + 4 + 44,
+ guiTopSidebar + 16 + 24,
+ false,
+ 86,
+ 4210752
+ );
+ Utils.drawStringCenteredScaledMaxWidth(
+ "Reset Config",
+ fontRendererObj,
+ guiLeft + xSize + 4 + 44,
+ guiTopSidebar + 12 + 24 * 2,
+ false,
+ 86,
+ 4210752
+ );
+
+ if (!validShareContents()) {
+ Gui.drawRect(
+ guiLeft + xSize + 3,
+ guiTopSidebar + 2,
+ guiLeft + xSize + 3 + 88,
+ guiTopSidebar + 2 + 20,
+ 0x80000000
+ );
+ }
+ }
+
+ @Override
+ protected void keyTyped(char typedChar, int keyCode) throws IOException {
+ super.keyTyped(typedChar, keyCode);
+ for (int yIndex = 0; yIndex < guiElementTextFields.size(); yIndex++) {
+ for (int i = 0; i < 3; i++) {
+ guiElementTextFields.get(yIndex)[i].keyTyped(typedChar, keyCode);
+ if (guiElementTextFields.get(yIndex)[i].getFocus()) {
+ int addOffset = 0;
+ if (keyCode == Keyboard.KEY_UP) {
+ addOffset -= 1;
+ } else if (keyCode == Keyboard.KEY_DOWN) {
+ addOffset += 1;
+ }
+
+ NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.remove(yIndex);
+ if (yIndex + addOffset < 0) {
+ addOffset = -yIndex;
+ } else if (yIndex + addOffset > NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.size()) {
+ addOffset = NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.size() - yIndex;
+ }
+ NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.add(
+ yIndex + addOffset,
+ getEnchantOpString(guiElementTextFields.get(yIndex), comparators.get(yIndex), modifiers.get(yIndex))
+ );
+ if (addOffset != 0) {
+ GuiElementTextField[] guiElementTextFieldArray = guiElementTextFields.remove(yIndex);
+ guiElementTextFields.add(yIndex + addOffset, guiElementTextFieldArray);
+ }
+ return;
+ }
+ }
+ }
+ }
+
+ public String getEnchantOpString(GuiElementTextField[] tfs, String comparator, String modifiers) {
+ StringBuilder enchantOp = new StringBuilder();
+ enchantOp.append(tfs[0].getText());
+ enchantOp.append(":");
+ enchantOp.append(comparator);
+ enchantOp.append(":");
+ enchantOp.append(tfs[1].getText());
+ enchantOp.append(":");
+ enchantOp.append(tfs[2].getText());
+ enchantOp.append(":");
+ enchantOp.append(modifiers);
+ return enchantOp.toString();
+ }
+
+ @Override
+ public void handleMouseInput() throws IOException {
+ super.handleMouseInput();
+
+ int dWheel = Mouse.getEventDWheel();
+ int mouseX = Mouse.getEventX() * this.width / this.mc.displayWidth;
+ if (mouseX > guiLeft && mouseX < guiLeft + xSize) {
+ if (dWheel < 0) {
+ scroll.setTarget(scroll.getTarget() - 50);
+ scroll.resetTimer();
+ } else if (dWheel > 0) {
+ scroll.setTarget(scroll.getTarget() + 50);
+ scroll.resetTimer();
+ }
+ } else if (mouseX > guiLeft + xSize && mouseX < guiLeft + xSize + 100) {
+ if (dWheel < 0) {
+ scrollSideBar.setTarget(scrollSideBar.getTarget() - 50);
+ scrollSideBar.resetTimer();
+ } else if (dWheel > 0) {
+ scrollSideBar.setTarget(scrollSideBar.getTarget() + 50);
+ scrollSideBar.resetTimer();
+ }
+ }
+
+ }
+
+ public static int getIntModifier(String modifier) {
+ try {
+ return Integer.parseInt(modifier);
+ } catch (NumberFormatException e) {
+ return 0;
+ }
+ }
+
+ private boolean validShareContents() {
+ try {
+ String base64 = (String) Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor);
+
+ if (base64.length() <= sharePrefix.length()) return false;
+
+ try {
+ return new String(Base64.getDecoder().decode(base64)).startsWith(sharePrefix);
+ } catch (IllegalArgumentException e) {
+ return false;
+ }
+ } catch (HeadlessException | IOException | UnsupportedFlavorException | IllegalStateException e) {
+ return false;
+ }
+ }
+
+ @Override
+ protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
+ super.mouseClicked(mouseX, mouseY, mouseButton);
+ for (int yIndex = 0; yIndex < guiElementTextFields.size(); yIndex++) {
+ for (int i = 0; i < 3; i++) {
+ int x = guiLeft + 7;
+ if (i == 1) x += 103;
+ else if (i == 2) x += 128;
+
+ if (mouseX > x && mouseX < x + guiElementTextFields.get(yIndex)[i].getWidth()) {
+ if (mouseY > guiTop + 23 + 25 * yIndex && mouseY < guiTop + 23 + 25 * yIndex + 20) {
+ guiElementTextFields.get(yIndex)[i].mouseClicked(mouseX, mouseY, mouseButton);
+ if (mouseButton == 1) {
+ NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.remove(yIndex);
+ NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.add(
+ yIndex,
+ getEnchantOpString(guiElementTextFields.get(yIndex), comparators.get(yIndex), modifiers.get(yIndex))
+ );
+ }
+ continue;
+ }
+ }
+ guiElementTextFields.get(yIndex)[i].otherComponentClick();
+ }
+ comparators.putIfAbsent(yIndex, ">");
+ modifiers.putIfAbsent(yIndex, "0");
+ if (mouseX >= guiLeft + 180 && mouseX <= guiLeft + 210 &&
+ mouseY >= guiTop + 23 + 25 * yIndex && mouseY <= guiTop + 23 + 25 * yIndex + 20) {
+ int modifierI = getIntModifier(modifiers.get(yIndex));
+ int selectedModifier = -1;
+
+ if (mouseX < guiLeft + 195) {
+ if (mouseY < guiTop + 23 + 25 * yIndex + 10) {
+ selectedModifier = BOLD_MODIFIER;
+ } else {
+ selectedModifier = ITALIC_MODIFIER;
+ }
+ } else {
+ if (mouseY < guiTop + 23 + 25 * yIndex + 10) {
+ selectedModifier = UNDERLINE_MODIFIER;
+ } else {
+ selectedModifier = STRIKETHROUGH_MODIFIER;
+ }
+ }
+
+ if (selectedModifier != -1) {
+ int modifierMasked = (modifierI & selectedModifier);
+ int modifierMaskedInverted = selectedModifier - modifierMasked;
+
+ int modifierInverted = (-1) - selectedModifier;
+
+ int finalModifier = (modifierI & modifierInverted) | modifierMaskedInverted;
+
+ modifiers.put(yIndex, "" + finalModifier);
+
+ NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.remove(yIndex);
+ NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.add(
+ yIndex,
+ getEnchantOpString(guiElementTextFields.get(yIndex), comparators.get(yIndex), modifiers.get(yIndex))
+ );
+ }
+ }
+ if (mouseY > guiTop + 23 + 25 * yIndex && mouseY < guiTop + 23 + 25 * yIndex + 20) {
+ if (mouseX > guiLeft + 86 && mouseX < guiLeft + 86 + 20) {
+ switch (comparators.get(yIndex)) {
+ case ">":
+ comparators.put(yIndex, "=");
+ break;
+ case "=":
+ comparators.put(yIndex, "<");
+ break;
+ default:
+ comparators.put(yIndex, ">");
+ break;
+ }
+ NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.remove(yIndex);
+ NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.add(
+ yIndex,
+ getEnchantOpString(guiElementTextFields.get(yIndex), comparators.get(yIndex), modifiers.get(yIndex))
+ );
+ } else if (mouseX > guiLeft + 160 && mouseX < guiLeft + 160 + 20) {
+ NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.remove(yIndex);
+ guiElementTextFields.remove(yIndex);
+ comparators.remove(yIndex);
+ modifiers.remove(yIndex);
+ }
+ }
+ }
+ if (mouseX >= guiLeft + 57 && mouseX <= guiLeft + xSize - 57) {
+ if (mouseY >= guiTop + ySize - 30 && mouseY <= guiTop + ySize - 10) {
+ NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.add("[a-zA-Z\\- ]+:>:5:9:0");
+ }
+ }
+ if (mouseX > guiLeft + xSize + 3 && mouseX < guiLeft + xSize + 3 + 88) {
+ if (mouseY > guiTopSidebar + 2 && mouseY < guiTopSidebar + 20 + 2) {
+
+ String base64;
+
+ try {
+ base64 = (String) Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor);
+ } catch (HeadlessException | IOException | UnsupportedFlavorException e) {
+ return;
+ }
+
+ if (base64.length() <= sharePrefix.length()) return;
+
+ String jsonString;
+ try {
+ jsonString = new String(Base64.getDecoder().decode(base64));
+ if (!jsonString.startsWith(sharePrefix)) return;
+ jsonString = jsonString.substring(sharePrefix.length());
+ } catch (IllegalArgumentException e) {
+ return;
+ }
+
+ JsonArray presetArray;
+ try {
+ presetArray = new JsonParser().parse(jsonString).getAsJsonArray();
+ } catch (IllegalStateException | JsonParseException e) {
+ return;
+ }
+ ArrayList<String> presetList = new ArrayList<>();
+
+ for (int i = 0; i < presetArray.size(); i++) {
+ if (presetArray.get(i).isJsonPrimitive()) {
+ String test = presetArray.get(i).getAsString();
+ Matcher matcher = settingPattern.matcher(test);
+ if (matcher.matches()) {
+ presetList.add(presetArray.get(i).getAsString());
+ }
+ }
+ }
+ if (presetList.size() != 0) {
+ NotEnoughUpdates.INSTANCE.config.hidden.enchantColours = presetList;
+ }
+
+ } else if (mouseY > guiTopSidebar + 2 + 24 && mouseY < guiTopSidebar + 20 + 24 + 2) {
+
+ ArrayList<String> result = NotEnoughUpdates.INSTANCE.config.hidden.enchantColours;
+ JsonArray jsonArray = new JsonArray();
+
+ for (String s : result) {
+ jsonArray.add(new JsonPrimitive(s));
+ }
+ String base64String = Base64.getEncoder().encodeToString((sharePrefix +
+ jsonArray).getBytes(StandardCharsets.UTF_8));
+ Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(base64String), null);
+ } else if (mouseY > guiTopSidebar + 2 + (24 * 2) && mouseY < guiTopSidebar + 20 + 2 + 24 * 2) {
+ NotEnoughUpdates.INSTANCE.config.hidden.enchantColours = NEUConfig.createDefaultEnchantColours();
+ }
+ }
+ }
+
+ public static String getColourOpIndex(List<String> colourOps, int index) {
+ if (colourOps.size() > index) {
+ return colourOps.get(index);
+ } else {
+ switch (index) {
+ case 0:
+ return "[a-zA-Z\\- ]+";
+ case 1:
+ return ">";
+ case 2:
+ return "5";
+ case 3:
+ return "9";
+ case 4:
+ return "0";
+ }
+ }
+ return null;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiInvButtonEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiInvButtonEditor.java
index 22a17c9f..7c74c6e2 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiInvButtonEditor.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiInvButtonEditor.java
@@ -1,13 +1,11 @@
package io.github.moulberry.notenoughupdates.miscgui;
import com.google.gson.*;
-import com.google.gson.annotations.Expose;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.core.GlScissorStack;
import io.github.moulberry.notenoughupdates.core.GuiElementTextField;
import io.github.moulberry.notenoughupdates.core.util.lerp.LerpingInteger;
import io.github.moulberry.notenoughupdates.options.NEUConfig;
-import io.github.moulberry.notenoughupdates.util.TexLoc;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
@@ -31,8 +29,8 @@ import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
-import java.util.*;
import java.util.List;
+import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
@@ -40,743 +38,873 @@ import java.util.concurrent.atomic.AtomicInteger;
import static io.github.moulberry.notenoughupdates.miscgui.GuiEnchantColour.custom_ench_colour;
public class GuiInvButtonEditor extends GuiScreen {
-
- private static final ResourceLocation INVENTORY = new ResourceLocation("minecraft:textures/gui/container/inventory.png");
- private static final ResourceLocation EDITOR = new ResourceLocation("notenoughupdates:invbuttons/editor.png");
- private static final ResourceLocation EXTRA_ICONS_JSON = new ResourceLocation("notenoughupdates:invbuttons/extraicons.json");
- private static final ResourceLocation PRESETS_JSON = new ResourceLocation("notenoughupdates:invbuttons/presets.json");
-
- private static final String sharePrefix = "NEUBUTTONS/";
-
- private int xSize = 176;
- private int ySize = 166;
-
- private int guiLeft;
- private int guiTop;
-
- private static final int BACKGROUND_TYPES = 5;
- private static final int ICON_TYPES = 3;
- private int iconTypeIndex = 0;
-
- private int editorXSize = 150;
- private int editorYSize = 204;
- private int editorLeft;
- private int editorTop;
-
- private GuiElementTextField commandTextField = new GuiElementTextField("", editorXSize-14, 16, GuiElementTextField.SCALE_TEXT);
- private GuiElementTextField iconTextField = new GuiElementTextField("", editorXSize-14, 16, GuiElementTextField.SCALE_TEXT);
-
- private static final HashSet<String> prioritisedIcons = new HashSet<>();
- static {
- prioritisedIcons.add("WORKBENCH");
- prioritisedIcons.add("LEATHER_CHESTPLATE");
- prioritisedIcons.add("CHEST");
- prioritisedIcons.add("BONE");
- prioritisedIcons.add("ENDER_CHEST");
- prioritisedIcons.add("GOLD_BARDING");
- prioritisedIcons.add("COMPASS");
- prioritisedIcons.add("GOLD_BLOCK");
- prioritisedIcons.add("EMPTY_MAP");
- prioritisedIcons.add("RAW_FISH");
- prioritisedIcons.add("FISHING_ROD");
- prioritisedIcons.add("EMERALD");
- prioritisedIcons.add("IRON_SWORD");
- prioritisedIcons.add("POTION");
- prioritisedIcons.add("NETHER_STAR");
- prioritisedIcons.add("PAINTING");
- prioritisedIcons.add("COMMAND");
- prioritisedIcons.add("BOOK");
- }
-
- private static HashMap<String, String> extraIcons = null;
-
- private static final HashMap<String, String> skullIcons = new HashMap<>();
- static {
- skullIcons.put("personal bank", "skull:e36e94f6c34a35465fce4a90f2e25976389eb9709a12273574ff70fd4daa6852");
- skullIcons.put("skyblock hub", "skull:d7cc6687423d0570d556ac53e0676cb563bbdd9717cd8269bdebed6f6d4e7bf8");
- skullIcons.put("private island", "skull:c9c8881e42915a9d29bb61a16fb26d059913204d265df5b439b3d792acd56");
- skullIcons.put("castle", "skull:f4559d75464b2e40a518e4de8e6cf3085f0a3ca0b1b7012614c4cd96fed60378");
- skullIcons.put("sirius shack", "skull:7ab83858ebc8ee85c3e54ab13aabfcc1ef2ad446d6a900e471c3f33b78906a5b");
- skullIcons.put("crypts", "skull:25d2f31ba162fe6272e831aed17f53213db6fa1c4cbe4fc827f3963cc98b9");
- skullIcons.put("spiders den", "skull:c754318a3376f470e481dfcd6c83a59aa690ad4b4dd7577fdad1c2ef08d8aee6");
- skullIcons.put("top of the nest", "skull:9d7e3b19ac4f3dee9c5677c135333b9d35a7f568b63d1ef4ada4b068b5a25");
- skullIcons.put("blazing fortress", "skull:c3687e25c632bce8aa61e0d64c24e694c3eea629ea944f4cf30dcfb4fbce071");
- skullIcons.put("blazing fortress magma boss", "skull:38957d5023c937c4c41aa2412d43410bda23cf79a9f6ab36b76fef2d7c429");
- skullIcons.put("the end", "skull:7840b87d52271d2a755dedc82877e0ed3df67dcc42ea479ec146176b02779a5");
- skullIcons.put("the end dragons nest", "skull:a1cd6d2d03f135e7c6b5d6cdae1b3a68743db4eb749faf7341e9fb347aa283b");
- skullIcons.put("the park", "skull:a221f813dacee0fef8c59f76894dbb26415478d9ddfc44c2e708a6d3b7549b");
- skullIcons.put("the park jungle", "skull:79ca3540621c1c79c32bf42438708ff1f5f7d0af9b14a074731107edfeb691c");
- skullIcons.put("the park howling cave", "skull:1832d53997b451635c9cf9004b0f22bb3d99ab5a093942b5b5f6bb4e4de47065");
- skullIcons.put("gold mines", "skull:73bc965d579c3c6039f0a17eb7c2e6faf538c7a5de8e60ec7a719360d0a857a9");
- skullIcons.put("deep caverns", "skull:569a1f114151b4521373f34bc14c2963a5011cdc25a6554c48c708cd96ebfc");
- skullIcons.put("the barn", "skull:4d3a6bd98ac1833c664c4909ff8d2dc62ce887bdcf3cc5b3848651ae5af6b");
- skullIcons.put("mushroom desert", "skull:2116b9d8df346a25edd05f842e7a9345beaf16dca4118abf5a68c75bcaae10");
- skullIcons.put("dungeon hub", "skull:9b56895b9659896ad647f58599238af532d46db9c1b0389b8bbeb70999dab33d");
- skullIcons.put("dwarven mines", "skull:569a1f114151b4521373f34bc14c2963a5011cdc25a6554c48c708cd96ebfc");
- skullIcons.put("hotm heart of the mountain", "skull:86f06eaa3004aeed09b3d5b45d976de584e691c0e9cade133635de93d23b9edb");
- skullIcons.put("bazaar dude", "skull:c232e3820897429157619b0ee099fec0628f602fff12b695de54aef11d923ad7");
- }
-
- private static LinkedHashMap<String, List<NEUConfig.InventoryButton>> presets = null;
-
- public GuiInvButtonEditor() {
- super();
- reloadExtraIcons();
- reloadPresets();
- Keyboard.enableRepeatEvents(true);
- }
-
- private static void reloadExtraIcons() {
- extraIcons = new HashMap<>();
-
- try(BufferedReader reader = new BufferedReader(new InputStreamReader(
- Minecraft.getMinecraft().getResourceManager().getResource(EXTRA_ICONS_JSON).getInputStream(), StandardCharsets.UTF_8))) {
- JsonObject json = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(reader, JsonObject.class);
-
- for(Map.Entry<String, JsonElement> entry : json.entrySet()) {
- if(entry.getValue().isJsonPrimitive()) {
- extraIcons.put(entry.getKey(), "extra:"+entry.getValue().getAsString());
- }
- }
- } catch(Exception e) {
- }
- }
-
- private static void reloadPresets() {
- presets = new LinkedHashMap<>();
-
- try(BufferedReader reader = new BufferedReader(new InputStreamReader(
- Minecraft.getMinecraft().getResourceManager().getResource(PRESETS_JSON).getInputStream(), StandardCharsets.UTF_8))) {
- JsonObject json = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(reader, JsonObject.class);
-
- for(Map.Entry<String, JsonElement> entry : json.entrySet()) {
- if(entry.getValue().isJsonArray()) {
- JsonArray arr = entry.getValue().getAsJsonArray();
- List<NEUConfig.InventoryButton> buttons = new ArrayList<>();
- for(int i=0; i<arr.size(); i++) {
- JsonObject o = arr.get(i).getAsJsonObject();
- NEUConfig.InventoryButton button = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(o, NEUConfig.InventoryButton.class);
- buttons.add(button);
- }
- presets.put(entry.getKey(), buttons);
- }
- }
- } catch(Exception e) {
- }
- }
-
- private static final Comparator<String> prioritisingComparator = (o1, o2) -> {
- boolean c1 = prioritisedIcons.contains(o1);
- boolean c2 = prioritisedIcons.contains(o2);
-
- if(c1 && !c2) return -1;
- if(!c1 && c2) return 1;
-
- return o1.compareTo(o2);
- };
-
- private final List<String> searchedIcons = new ArrayList<>();
-
- private LerpingInteger itemScroll = new LerpingInteger(0, 100);
-
- private NEUConfig.InventoryButton editingButton = null;
-
- private static HashMap<String, ItemStack> skullMap = new HashMap<>();
-
- public static void renderIcon(String icon, int x, int y) {
- if(extraIcons == null) {
- reloadExtraIcons();
- }
-
- if(icon.startsWith("extra:")) {
- String name = icon.substring("extra:".length());
- ResourceLocation resourceLocation = new ResourceLocation("notenoughupdates:invbuttons/extraicons/"+name+".png");
- Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(x, y, 16, 16, GL11.GL_NEAREST);
- } else {
- ItemStack stack = getStack(icon);
-
- float scale = 1;
- if(icon.startsWith("skull:")) {
- scale = 1.2f;
- }
- GlStateManager.pushMatrix();
- GlStateManager.translate(x+8, y+8, 0);
- GlStateManager.scale(scale, scale, 1);
- GlStateManager.translate(-8, -8, 0);
- Utils.drawItemStack(stack, 0, 0);
- GlStateManager.popMatrix();
- }
- }
-
- public static ItemStack getStack(String icon) {
- if(icon.startsWith("extra:")) {
- return null;
- } else if(icon.startsWith("skull:")) {
- String link = icon.substring("skull:".length());
- if(skullMap.containsKey(link)) return skullMap.get(link);
-
- ItemStack render = new ItemStack(Items.skull, 1, 3);
- NBTTagCompound nbt = new NBTTagCompound();
- NBTTagCompound skullOwner = new NBTTagCompound();
- NBTTagCompound properties = new NBTTagCompound();
- NBTTagList textures = new NBTTagList();
- NBTTagCompound textures_0 = new NBTTagCompound();
-
- String uuid = UUID.nameUUIDFromBytes(link.getBytes()).toString();
- skullOwner.setString("Id", uuid);
- skullOwner.setString("Name", uuid);
-
- String display = "{\"textures\":{\"SKIN\":{\"url\":\"http://textures.minecraft.net/texture/"+link+"\"}}}";
- String displayB64 = Base64.getEncoder().encodeToString(display.getBytes());
-
- textures_0.setString("Value", displayB64);
- textures.appendTag(textures_0);
-
- properties.setTag("textures", textures);
- skullOwner.setTag("Properties", properties);
- nbt.setTag("SkullOwner", skullOwner);
- render.setTagCompound(nbt);
-
- skullMap.put(link, render);
- return render;
- } else {
- return NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(icon));
- }
- }
-
- @Override
- public void drawScreen(int mouseX, int mouseY, float partialTicks) {
- super.drawScreen(mouseX, mouseY, partialTicks);
-
- super.drawDefaultBackground();
-
- guiLeft = width/2 - xSize/2;
- guiTop = height/2 - ySize/2;
-
- GlStateManager.enableDepth();
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(INVENTORY);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(guiLeft, guiTop, xSize, ySize, 0, xSize/256f, 0, ySize/256f, GL11.GL_NEAREST);
-
- for(NEUConfig.InventoryButton button : NotEnoughUpdates.INSTANCE.config.hidden.inventoryButtons) {
- int x = guiLeft+button.x;
- int y = guiTop+button.y;
- if(button.anchorRight) {
- x += xSize;
- }
- if(button.anchorBottom) {
- y += ySize;
- }
-
- if(button.isActive()) {
- GlStateManager.color(1, 1, 1, 1f);
- } else {
- GlStateManager.color(1, 1, 1, 0.5f);
- }
-
- 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);
-
- if(button.isActive()) {
- if(button.icon != null && !button.icon.trim().isEmpty()) {
- GlStateManager.enableDepth();
-
- renderIcon(button.icon, x+1, y+1);
- }
- } else {
- fontRendererObj.drawString("+", x+6, y+5, 0xffcccccc);
- }
- }
- Minecraft.getMinecraft().getTextureManager().bindTexture(custom_ench_colour);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(guiLeft-88-2-22, guiTop+2, 88, 20, 64/217f, 152/217f, 48/78f, 68/78f, GL11.GL_NEAREST);
- Utils.drawTexturedRect(guiLeft-88-2-22, guiTop+2+24, 88, 20, 64/217f, 152/217f, 48/78f, 68/78f, GL11.GL_NEAREST);
- Utils.drawStringCenteredScaledMaxWidth("Load preset", fontRendererObj, guiLeft-44-2-22, guiTop+8, false, 86, 4210752);
- Utils.drawStringCenteredScaledMaxWidth("from Clipboard", fontRendererObj, guiLeft-44-2-22, guiTop+16, false, 86, 4210752);
- Utils.drawStringCenteredScaledMaxWidth("Save preset", fontRendererObj, guiLeft-44-2-22, guiTop+8+24, false, 86, 4210752);
- Utils.drawStringCenteredScaledMaxWidth("to Clipboard", fontRendererObj, guiLeft-44-2-22, guiTop+16+24, false, 86, 4210752);
-
- if(!validShareContents()) {
- Gui.drawRect(guiLeft-88-2-22, guiTop+2, guiLeft-2-22, guiTop+2+20, 0x80000000);
- }
-
- GlStateManager.color(1, 1, 1, 1);
-
- if(presets != null) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(EDITOR);
- Utils.drawTexturedRect(guiLeft+xSize+22, guiTop, 80, ySize,
- editorXSize/256f, (editorXSize+80)/256f, 41/256f, (41+ySize)/256f, GL11.GL_NEAREST);
- Utils.drawStringCenteredScaledMaxWidth("\u00a7nPresets", fontRendererObj, guiLeft+xSize+22+40, guiTop+10, false, 70, 0xffa0a0a0);
-
- int index = 0;
- for(String presetName : presets.keySet()) {
- Utils.drawStringCenteredScaledMaxWidth(presetName, fontRendererObj, guiLeft+xSize+22+40, guiTop+25+10*(index++),
- false, 70, 0xff909090);
- }
- }
-
- if(editingButton != null) {
- int x = guiLeft+editingButton.x;
- int y = guiTop+editingButton.y;
- if(editingButton.anchorRight) {
- x += xSize;
- }
- if(editingButton.anchorBottom) {
- y += ySize;
- }
-
- GlStateManager.translate(0, 0, 300);
- editorLeft = x + 8 - editorXSize/2;
- editorTop = y + 18 + 2;
-
- boolean showArrow = true;
- if(editorTop+editorYSize+5 > height) {
- editorTop = height-editorYSize-5;
- showArrow = false;
- }
- if(editorLeft < 5) {
- editorLeft = 5;
- showArrow = false;
- }
- if(editorLeft+editorXSize+5 > width) {
- editorLeft = width-editorXSize-5;
- showArrow = false;
- }
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(EDITOR);
- GlStateManager.color(1, 1, 1, 1f);
- Utils.drawTexturedRect(editorLeft, editorTop, editorXSize, editorYSize, 0, editorXSize/256f, 41/256f, (41+editorYSize)/256f, GL11.GL_NEAREST);
-
- if(showArrow) Utils.drawTexturedRect(x+8-3, y+18, 10, 5, 0, 6/256f, 36/256f, 41/256f, GL11.GL_NEAREST);
-
- fontRendererObj.drawString("Command", editorLeft+7, editorTop+7, 0xffa0a0a0, false);
-
- commandTextField.setSize(editorXSize-14, 16);
- commandTextField.setText(commandTextField.getText().replaceAll("^ +", ""));
- if(commandTextField.getText().startsWith("/")) {
- commandTextField.setPrependText("");
- } else {
- commandTextField.setPrependText("\u00a77/\u00a7r");
- }
- commandTextField.render(editorLeft+7, editorTop+19);
-
- fontRendererObj.drawString("Background", editorLeft+7, editorTop+40, 0xffa0a0a0, false);
-
- for(int i=0; i<BACKGROUND_TYPES; i++) {
- if(i == editingButton.backgroundIndex) {
- Gui.drawRect(editorLeft+7+20*i-1, editorTop+50-1, editorLeft+7+20*i+19, editorTop+50+19, 0xff0000ff);
- }
- Minecraft.getMinecraft().getTextureManager().bindTexture(EDITOR);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(editorLeft+7+20*i, editorTop+50, 18, 18,
- i*18/256f, (i*18+18)/256f, 0/256f, 18/256f, GL11.GL_NEAREST);
- }
-
- fontRendererObj.drawString("Icon Type", editorLeft+7, editorTop+50+24, 0xffa0a0a0, false);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(EDITOR);
- GlStateManager.color(1, 1, 1, 1);
- float uMin = 18/256f;
- float uMax = 36/256f;
- float vMin = 0;
- float vMax = 18/256f;
-
- for(int i=0; i<ICON_TYPES; i++) {
- boolean flip = iconTypeIndex == i;
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(EDITOR);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(editorLeft+7+20*i, editorTop+50+34, 18, 18,
- flip ? uMax : uMin, flip ? uMin : uMax, flip ? vMax : vMin, flip ? vMin : vMax, GL11.GL_NEAREST);
-
- ItemStack stack = null;
- if(i == 0) {
- stack = new ItemStack(Items.diamond_sword);
- } else if(i == 1) {
- stack = getStack("skull:c9c8881e42915a9d29bb61a16fb26d059913204d265df5b439b3d792acd56");
- } else if(i == 2) {
- stack = new ItemStack(Items.lead);
- }
- if(stack != null) Utils.drawItemStack(stack, editorLeft+8+20*i, editorTop+50+35);
- }
-
- fontRendererObj.drawString("Icon Selector", editorLeft+7, editorTop+50+55, 0xffa0a0a0, false);
-
- iconTextField.render(editorLeft+7, editorTop+50+65);
-
- GlStateManager.enableDepth();
-
- itemScroll.tick();
-
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- GlScissorStack.push(0, editorTop+136, width, editorTop+196, scaledResolution);
-
- synchronized(searchedIcons) {
- if(iconTextField.getText().trim().isEmpty() && searchedIcons.isEmpty()) {
- searchedIcons.addAll(NotEnoughUpdates.INSTANCE.manager.getItemInformation().keySet());
- searchedIcons.sort(prioritisingComparator);
- }
-
- int max = (searchedIcons.size()-1)/6*20-40;
- int scroll = itemScroll.getValue();
- if(scroll > max) scroll = max;
-
- int scrollBarHeight = (int)Math.ceil(3f*54f/(searchedIcons.size()-18));
- if(scrollBarHeight < 0) scrollBarHeight = 54;
- if(scrollBarHeight < 2) scrollBarHeight = 2;
- int scrollY = (int)Math.floor(54f*((scroll/20f) / ((searchedIcons.size()-18)/6f)));
- if(scrollY+scrollBarHeight > 54) scrollY = 54-scrollBarHeight;
-
- Gui.drawRect(editorLeft+137, editorTop+139+scrollY, editorLeft+139, editorTop+139+scrollY+scrollBarHeight, 0xff202020);
-
- int endIndex = searchedIcons.size();
- int startIndex = scroll/20*6;
- if(startIndex < 0) startIndex = 0;
- if(endIndex > startIndex+24) endIndex = startIndex+24;
-
- for(int i=startIndex; i<endIndex; i++) {
- String iconS = searchedIcons.get(i);
-
- int iconX = editorLeft+12+((i-startIndex)%6)*20;
- int iconY = editorTop+137+((i-startIndex)/6)*20 - (itemScroll.getValue()%20);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(EDITOR);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(iconX, iconY, 18, 18,
- 18/256f, 36/256f, 0/256f, 18/256f, GL11.GL_NEAREST);
-
- renderIcon(iconS, iconX+1, iconY+1);
- }
- }
-
- GlScissorStack.pop(scaledResolution);
-
- GlStateManager.translate(0, 0, -300);
- }
- }
-
- @Override
- public void handleMouseInput() throws IOException {
- int scroll = Mouse.getEventDWheel();
- if(scroll != 0) {
- scroll = -scroll;
- if(scroll > 1) scroll = 8;
- if(scroll < -1) scroll = -8;
-
- int delta = Math.abs(itemScroll.getTarget() - itemScroll.getValue());
- float acc = delta/20+1;
- scroll *= acc;
-
- int max = (searchedIcons.size()-1)/6*20-40;
- int newTarget = itemScroll.getTarget() + scroll;
-
- if(newTarget > max) newTarget = max;
- if(newTarget < 0) newTarget = 0;
-
- itemScroll.setTarget(newTarget);
- itemScroll.resetTimer();
- }
-
- super.handleMouseInput();
- }
-
- private boolean validShareContents() {
- try {
- String base64 = (String)Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor);
-
- if(base64.length() <= sharePrefix.length()) return false;
-
- try {
- return new String(Base64.getDecoder().decode(base64)).startsWith(sharePrefix);
- } catch (IllegalArgumentException e){
- return false;
- }
- } catch (HeadlessException | IOException | UnsupportedFlavorException | IllegalStateException e) {
- return false;
- }
- }
-
- @Override
- protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
- super.mouseClicked(mouseX, mouseY, mouseButton);
-
- if(editingButton != null) {
- if(mouseX >= editorLeft && mouseX <= editorLeft+editorXSize &&
- mouseY >= editorTop & mouseY <= editorTop + editorYSize) {
- if(mouseX >= editorLeft+7 && mouseX <= editorLeft+7+commandTextField.getWidth() &&
- mouseY >= editorTop+12 && mouseY <= editorTop+12+commandTextField.getHeight()) {
- commandTextField.mouseClicked(mouseX, mouseY, mouseButton);
- iconTextField.unfocus();
- editingButton.command = commandTextField.getText();
- return;
- }
- if(mouseX >= editorLeft+7 && mouseX <= editorLeft+7+iconTextField.getWidth() &&
- mouseY >= editorTop+50+65 && mouseY <= editorTop+50+65+iconTextField.getHeight()) {
- iconTextField.mouseClicked(mouseX, mouseY, mouseButton);
-
- if(mouseButton == 1) {
- search();
- }
-
- commandTextField.unfocus();
- return;
- }
- if(mouseY >= editorTop+50 && mouseY <= editorTop+50+18) {
- for(int i=0; i<BACKGROUND_TYPES; i++) {
- if(mouseX >= editorLeft+7+20*i && mouseX <= editorLeft+7+20*i+18) {
- editingButton.backgroundIndex = i;
- return;
- }
- }
- }
- for(int i=0; i<ICON_TYPES; i++) {
- if(mouseX >= editorLeft+7+20*i && mouseX <= editorLeft+7+20*i+18 &&
- mouseY >= editorTop+50+34 && mouseY <= editorTop+50+34+18) {
- if(iconTypeIndex != i) {
- iconTypeIndex = i;
- search();
- }
- return;
- }
- }
- if(mouseX > editorLeft+8 && mouseX < editorLeft+editorXSize-16 && mouseY > editorTop+136 && mouseY < editorTop+196) {
- synchronized(searchedIcons) {
- int max = (searchedIcons.size()-1)/6*20-40;
- int scroll = itemScroll.getValue();
- if(scroll > max) scroll = max;
-
- int endIndex = searchedIcons.size();
- int startIndex = scroll/20*6;
- if(startIndex < 0) startIndex = 0;
- if(endIndex > startIndex+24) endIndex = startIndex+24;
-
- for(int i=startIndex; i<endIndex; i++) {
- String iconS = searchedIcons.get(i);
-
- int x = editorLeft+12+((i-startIndex)%6)*20;
- int y = editorTop+137+((i-startIndex)/6)*20 - (itemScroll.getValue()%20);
-
- if(mouseX >= x && mouseX <= x+18 &&
- mouseY >= y && mouseY <= y+18) {
- editingButton.icon = iconS;
- return;
- }
- }
- }
- }
- return;
- }
- }
-
- for(NEUConfig.InventoryButton button : NotEnoughUpdates.INSTANCE.config.hidden.inventoryButtons) {
- int x = guiLeft+button.x;
- int y = guiTop+button.y;
- if(button.anchorRight) {
- x += xSize;
- }
- if(button.anchorBottom) {
- y += ySize;
- }
-
- if(mouseX >= x && mouseY >= y &&
- mouseX <= x+18 && mouseY <= y+18) {
- if(editingButton == button) {
- editingButton = null;
- } else {
- editingButton = button;
- commandTextField.setText(editingButton.command);
- }
- return;
- }
- }
-
- if(mouseX > guiLeft-2-88-22 && mouseX< guiLeft-2-22) {
- if (mouseY > guiTop + 2 && mouseY < guiTop + 22) {
-
- String base64;
-
- try {
- base64 = (String) Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor);
- } catch (HeadlessException | IOException | UnsupportedFlavorException e) {
- return;
- }
-
- if(base64.length() <= sharePrefix.length()) return;
-
- String jsonString;
- try {
- jsonString = new String(Base64.getDecoder().decode(base64));
- if(!jsonString.startsWith(sharePrefix)) return;
- jsonString = jsonString.substring(sharePrefix.length());
- } catch (IllegalArgumentException e) {
- return;
-
- }
- JsonArray presetArray;
- try {
- presetArray = new JsonParser().parse(jsonString).getAsJsonArray();
- } catch (IllegalStateException | JsonParseException e) {
- return;
- }
-
-
- List<NEUConfig.InventoryButton> buttons = new ArrayList<>();
- System.out.println(presetArray.size());
- try {
- for (int i = 0; i < presetArray.size(); i++) {
-
-
- JsonElement shittyO = presetArray.get(i);
- JsonElement lessShittyO = new JsonParser().parse(shittyO.getAsString());
- if (lessShittyO.isJsonObject()) {
- JsonObject o = lessShittyO.getAsJsonObject();
- NEUConfig.InventoryButton button = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(o, NEUConfig.InventoryButton.class);
- buttons.add(button);
- }
-
- }
-
- NotEnoughUpdates.INSTANCE.config.hidden.inventoryButtons = buttons;
- return;
- } catch(JsonParseException | ClassCastException | IllegalStateException e){
- return;
- }
-
-
- } else if (mouseY > guiTop + 26 && mouseY < guiTop + 26 + 20) {
-
- List<NEUConfig.InventoryButton> result = NotEnoughUpdates.INSTANCE.config.hidden.inventoryButtons;
- JsonArray jsonArray = new JsonArray();
-
- for (int i = 0; i < result.size(); i++) {
-
- jsonArray.add(new JsonPrimitive(NotEnoughUpdates.INSTANCE.manager.gson.toJson(result.get(i), NEUConfig.InventoryButton.class)));
- }
- String base64String = Base64.getEncoder().encodeToString((sharePrefix+jsonArray).getBytes(StandardCharsets.UTF_8));
- Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(base64String), null);
- return;
- }
- }
-
- if(editingButton == null) {
- int index = 0;
- for(List<NEUConfig.InventoryButton> buttons : presets.values()) {
- if(mouseX >= guiLeft+xSize+22 && mouseX <= guiLeft+xSize+22+80 &&
- mouseY >= guiTop+21+10*index && mouseY <= guiTop+21+10*index+10) {
- NotEnoughUpdates.INSTANCE.config.hidden.inventoryButtons = buttons;
- return;
- }
- index++;
- }
- }
-
- editingButton = null;
- }
-
- @Override
- protected void keyTyped(char typedChar, int keyCode) throws IOException {
- super.keyTyped(typedChar, keyCode);
-
- if(editingButton != null && commandTextField.getFocus()) {
- commandTextField.keyTyped(typedChar, keyCode);
- editingButton.command = commandTextField.getText();
- } else if(editingButton != null && iconTextField.getFocus()) {
- String old = iconTextField.getText().trim();
- iconTextField.keyTyped(typedChar, keyCode);
- String newText = iconTextField.getText().trim();
-
- if(!old.equalsIgnoreCase(newText)) {
- search();
- }
- }
- }
-
- private ExecutorService searchES = Executors.newSingleThreadExecutor();
- private AtomicInteger searchId = new AtomicInteger(0);
-
- public void search() {
- final int thisSearchId = searchId.incrementAndGet();
- final String searchString = iconTextField.getText();
-
- if(iconTypeIndex == 0) {
- if(searchString.trim().isEmpty()) {
- synchronized(searchedIcons) {
- searchedIcons.clear();
-
- List<String> unsorted = new ArrayList<>(NotEnoughUpdates.INSTANCE.manager.getItemInformation().keySet());
- unsorted.sort(prioritisingComparator);
- searchedIcons.addAll(unsorted);
- }
- return;
- }
-
- searchES.submit(() -> {
- if(thisSearchId != searchId.get()) return;
-
- List<String> title = new ArrayList<>(NotEnoughUpdates.INSTANCE.manager.search("title:" + searchString.trim()));
-
- if(thisSearchId != searchId.get()) return;
-
- if(!searchString.trim().contains(" ")) {
- StringBuilder sb = new StringBuilder();
- for(char c : searchString.toCharArray()) {
- sb.append(c).append(" ");
- }
- title.addAll(NotEnoughUpdates.INSTANCE.manager.search("title:" + sb.toString().trim()));
- }
-
- if(thisSearchId != searchId.get()) return;
-
- List<String> desc = new ArrayList<>(NotEnoughUpdates.INSTANCE.manager.search("desc:" + searchString.trim()));
- desc.removeAll(title);
-
- if(thisSearchId != searchId.get()) return;
-
- title.sort(prioritisingComparator);
- desc.sort(prioritisingComparator);
-
- if(thisSearchId != searchId.get()) return;
-
- synchronized(searchedIcons) {
- searchedIcons.clear();
- searchedIcons.addAll(title);
- searchedIcons.addAll(desc);
- }
- });
- } else if(iconTypeIndex == 1) {
- if(searchString.trim().isEmpty()) {
- searchedIcons.clear();
- searchedIcons.addAll(skullIcons.values());
- return;
- }
-
- synchronized(searchedIcons) {
- searchedIcons.clear();
- for(Map.Entry<String, String> entry : skullIcons.entrySet()) {
- if(NotEnoughUpdates.INSTANCE.manager.searchString(entry.getKey(), searchString)) {
- searchedIcons.add(entry.getValue());
- }
- }
- }
- } else if(iconTypeIndex == 2) {
- if(searchString.trim().isEmpty()) {
- searchedIcons.clear();
- searchedIcons.addAll(extraIcons.values());
- return;
- }
-
- synchronized(searchedIcons) {
- searchedIcons.clear();
- for(Map.Entry<String, String> entry : extraIcons.entrySet()) {
- if(NotEnoughUpdates.INSTANCE.manager.searchString(entry.getKey(), searchString)) {
- searchedIcons.add(entry.getValue());
- }
- }
- }
- }
- }
+ private static final ResourceLocation INVENTORY = new ResourceLocation(
+ "minecraft:textures/gui/container/inventory.png");
+ private static final ResourceLocation EDITOR = new ResourceLocation("notenoughupdates:invbuttons/editor.png");
+ private static final ResourceLocation EXTRA_ICONS_JSON = new ResourceLocation(
+ "notenoughupdates:invbuttons/extraicons.json");
+ private static final ResourceLocation PRESETS_JSON = new ResourceLocation("notenoughupdates:invbuttons/presets.json");
+
+ private static final String sharePrefix = "NEUBUTTONS/";
+
+ private final int xSize = 176;
+ private final int ySize = 166;
+
+ private int guiLeft;
+ private int guiTop;
+
+ private static final int BACKGROUND_TYPES = 5;
+ private static final int ICON_TYPES = 3;
+ private int iconTypeIndex = 0;
+
+ private final int editorXSize = 150;
+ private final int editorYSize = 204;
+ private int editorLeft;
+ private int editorTop;
+
+ private final GuiElementTextField commandTextField = new GuiElementTextField(
+ "",
+ editorXSize - 14,
+ 16,
+ GuiElementTextField.SCALE_TEXT
+ );
+ private final GuiElementTextField iconTextField = new GuiElementTextField(
+ "",
+ editorXSize - 14,
+ 16,
+ GuiElementTextField.SCALE_TEXT
+ );
+
+ private static final HashSet<String> prioritisedIcons = new HashSet<String>() {{
+ add("WORKBENCH");
+ add("LEATHER_CHESTPLATE");
+ add("CHEST");
+ add("BONE");
+ add("ENDER_CHEST");
+ add("GOLD_BARDING");
+ add("COMPASS");
+ add("GOLD_BLOCK");
+ add("EMPTY_MAP");
+ add("RAW_FISH");
+ add("FISHING_ROD");
+ add("EMERALD");
+ add("IRON_SWORD");
+ add("POTION");
+ add("NETHER_STAR");
+ add("PAINTING");
+ add("COMMAND");
+ add("BOOK");
+ }};
+
+ private static HashMap<String, String> extraIcons = null;
+
+ private static final HashMap<String, String> skullIcons = new HashMap<String, String>() {{
+ put("personal bank", "skull:e36e94f6c34a35465fce4a90f2e25976389eb9709a12273574ff70fd4daa6852");
+ put("skyblock hub", "skull:d7cc6687423d0570d556ac53e0676cb563bbdd9717cd8269bdebed6f6d4e7bf8");
+ put("private island", "skull:c9c8881e42915a9d29bb61a16fb26d059913204d265df5b439b3d792acd56");
+ put("castle", "skull:f4559d75464b2e40a518e4de8e6cf3085f0a3ca0b1b7012614c4cd96fed60378");
+ put("sirius shack", "skull:7ab83858ebc8ee85c3e54ab13aabfcc1ef2ad446d6a900e471c3f33b78906a5b");
+ put("crypts", "skull:25d2f31ba162fe6272e831aed17f53213db6fa1c4cbe4fc827f3963cc98b9");
+ put("spiders den", "skull:c754318a3376f470e481dfcd6c83a59aa690ad4b4dd7577fdad1c2ef08d8aee6");
+ put("top of the nest", "skull:9d7e3b19ac4f3dee9c5677c135333b9d35a7f568b63d1ef4ada4b068b5a25");
+ put("blazing fortress", "skull:c3687e25c632bce8aa61e0d64c24e694c3eea629ea944f4cf30dcfb4fbce071");
+ put("blazing fortress magma boss", "skull:38957d5023c937c4c41aa2412d43410bda23cf79a9f6ab36b76fef2d7c429");
+ put("the end", "skull:7840b87d52271d2a755dedc82877e0ed3df67dcc42ea479ec146176b02779a5");
+ put("the end dragons nest", "skull:a1cd6d2d03f135e7c6b5d6cdae1b3a68743db4eb749faf7341e9fb347aa283b");
+ put("the park", "skull:a221f813dacee0fef8c59f76894dbb26415478d9ddfc44c2e708a6d3b7549b");
+ put("the park jungle", "skull:79ca3540621c1c79c32bf42438708ff1f5f7d0af9b14a074731107edfeb691c");
+ put("the park howling cave", "skull:1832d53997b451635c9cf9004b0f22bb3d99ab5a093942b5b5f6bb4e4de47065");
+ put("gold mines", "skull:73bc965d579c3c6039f0a17eb7c2e6faf538c7a5de8e60ec7a719360d0a857a9");
+ put("deep caverns", "skull:569a1f114151b4521373f34bc14c2963a5011cdc25a6554c48c708cd96ebfc");
+ put("the barn", "skull:4d3a6bd98ac1833c664c4909ff8d2dc62ce887bdcf3cc5b3848651ae5af6b");
+ put("mushroom desert", "skull:2116b9d8df346a25edd05f842e7a9345beaf16dca4118abf5a68c75bcaae10");
+ put("dungeon hub", "skull:9b56895b9659896ad647f58599238af532d46db9c1b0389b8bbeb70999dab33d");
+ put("dwarven mines", "skull:569a1f114151b4521373f34bc14c2963a5011cdc25a6554c48c708cd96ebfc");
+ put("hotm heart of the mountain", "skull:86f06eaa3004aeed09b3d5b45d976de584e691c0e9cade133635de93d23b9edb");
+ put("bazaar dude", "skull:c232e3820897429157619b0ee099fec0628f602fff12b695de54aef11d923ad7");
+ }};
+
+ private static LinkedHashMap<String, List<NEUConfig.InventoryButton>> presets = null;
+
+ public GuiInvButtonEditor() {
+ super();
+ reloadExtraIcons();
+ reloadPresets();
+ Keyboard.enableRepeatEvents(true);
+ }
+
+ private static void reloadExtraIcons() {
+ extraIcons = new HashMap<>();
+
+ try (
+ BufferedReader reader = new BufferedReader(new InputStreamReader(
+ Minecraft.getMinecraft().getResourceManager().getResource(EXTRA_ICONS_JSON).getInputStream(),
+ StandardCharsets.UTF_8
+ ))
+ ) {
+ JsonObject json = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(reader, JsonObject.class);
+
+ for (Map.Entry<String, JsonElement> entry : json.entrySet()) {
+ if (entry.getValue().isJsonPrimitive()) {
+ extraIcons.put(entry.getKey(), "extra:" + entry.getValue().getAsString());
+ }
+ }
+ } catch (Exception ignored) {
+ }
+ }
+
+ private static void reloadPresets() {
+ presets = new LinkedHashMap<>();
+
+ try (
+ BufferedReader reader = new BufferedReader(new InputStreamReader(
+ Minecraft.getMinecraft().getResourceManager().getResource(PRESETS_JSON).getInputStream(),
+ StandardCharsets.UTF_8
+ ))
+ ) {
+ JsonObject json = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(reader, JsonObject.class);
+
+ for (Map.Entry<String, JsonElement> entry : json.entrySet()) {
+ if (entry.getValue().isJsonArray()) {
+ JsonArray arr = entry.getValue().getAsJsonArray();
+ List<NEUConfig.InventoryButton> buttons = new ArrayList<>();
+ for (int i = 0; i < arr.size(); i++) {
+ JsonObject o = arr.get(i).getAsJsonObject();
+ NEUConfig.InventoryButton button = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(
+ o,
+ NEUConfig.InventoryButton.class
+ );
+ buttons.add(button);
+ }
+ presets.put(entry.getKey(), buttons);
+ }
+ }
+ } catch (Exception ignored) {
+ }
+ }
+
+ private static final Comparator<String> prioritisingComparator = (o1, o2) -> {
+ boolean c1 = prioritisedIcons.contains(o1);
+ boolean c2 = prioritisedIcons.contains(o2);
+
+ if (c1 && !c2) return -1;
+ if (!c1 && c2) return 1;
+
+ return o1.compareTo(o2);
+ };
+
+ private final List<String> searchedIcons = new ArrayList<>();
+
+ private final LerpingInteger itemScroll = new LerpingInteger(0, 100);
+
+ private NEUConfig.InventoryButton editingButton = null;
+
+ private static final HashMap<String, ItemStack> skullMap = new HashMap<>();
+
+ public static void renderIcon(String icon, int x, int y) {
+ if (extraIcons == null) {
+ reloadExtraIcons();
+ }
+
+ if (icon.startsWith("extra:")) {
+ String name = icon.substring("extra:".length());
+ ResourceLocation resourceLocation = new ResourceLocation(
+ "notenoughupdates:invbuttons/extraicons/" + name + ".png");
+ Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(x, y, 16, 16, GL11.GL_NEAREST);
+ } else {
+ ItemStack stack = getStack(icon);
+
+ float scale = 1;
+ if (icon.startsWith("skull:")) {
+ scale = 1.2f;
+ }
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(x + 8, y + 8, 0);
+ GlStateManager.scale(scale, scale, 1);
+ GlStateManager.translate(-8, -8, 0);
+ Utils.drawItemStack(stack, 0, 0);
+ GlStateManager.popMatrix();
+ }
+ }
+
+ public static ItemStack getStack(String icon) {
+ if (icon.startsWith("extra:")) {
+ return null;
+ } else if (icon.startsWith("skull:")) {
+ String link = icon.substring("skull:".length());
+ if (skullMap.containsKey(link)) return skullMap.get(link);
+
+ ItemStack render = new ItemStack(Items.skull, 1, 3);
+ NBTTagCompound nbt = new NBTTagCompound();
+ NBTTagCompound skullOwner = new NBTTagCompound();
+ NBTTagCompound properties = new NBTTagCompound();
+ NBTTagList textures = new NBTTagList();
+ NBTTagCompound textures_0 = new NBTTagCompound();
+
+ String uuid = UUID.nameUUIDFromBytes(link.getBytes()).toString();
+ skullOwner.setString("Id", uuid);
+ skullOwner.setString("Name", uuid);
+
+ String display = "{\"textures\":{\"SKIN\":{\"url\":\"http://textures.minecraft.net/texture/" + link + "\"}}}";
+ String displayB64 = Base64.getEncoder().encodeToString(display.getBytes());
+
+ textures_0.setString("Value", displayB64);
+ textures.appendTag(textures_0);
+
+ properties.setTag("textures", textures);
+ skullOwner.setTag("Properties", properties);
+ nbt.setTag("SkullOwner", skullOwner);
+ render.setTagCompound(nbt);
+
+ skullMap.put(link, render);
+ return render;
+ } else {
+ return NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get(icon));
+ }
+ }
+
+ @Override
+ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
+ super.drawScreen(mouseX, mouseY, partialTicks);
+
+ super.drawDefaultBackground();
+
+ guiLeft = width / 2 - xSize / 2;
+ guiTop = height / 2 - ySize / 2;
+
+ GlStateManager.enableDepth();
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(INVENTORY);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(guiLeft, guiTop, xSize, ySize, 0, xSize / 256f, 0, ySize / 256f, GL11.GL_NEAREST);
+
+ for (NEUConfig.InventoryButton button : NotEnoughUpdates.INSTANCE.config.hidden.inventoryButtons) {
+ int x = guiLeft + button.x;
+ int y = guiTop + button.y;
+ if (button.anchorRight) {
+ x += xSize;
+ }
+ if (button.anchorBottom) {
+ y += ySize;
+ }
+
+ if (button.isActive()) {
+ GlStateManager.color(1, 1, 1, 1f);
+ } else {
+ GlStateManager.color(1, 1, 1, 0.5f);
+ }
+
+ 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
+ );
+
+ if (button.isActive()) {
+ if (button.icon != null && !button.icon.trim().isEmpty()) {
+ GlStateManager.enableDepth();
+
+ renderIcon(button.icon, x + 1, y + 1);
+ }
+ } else {
+ fontRendererObj.drawString("+", x + 6, y + 5, 0xffcccccc);
+ }
+ }
+ Minecraft.getMinecraft().getTextureManager().bindTexture(custom_ench_colour);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(
+ guiLeft - 88 - 2 - 22,
+ guiTop + 2,
+ 88,
+ 20,
+ 64 / 217f,
+ 152 / 217f,
+ 48 / 78f,
+ 68 / 78f,
+ GL11.GL_NEAREST
+ );
+ Utils.drawTexturedRect(
+ guiLeft - 88 - 2 - 22,
+ guiTop + 2 + 24,
+ 88,
+ 20,
+ 64 / 217f,
+ 152 / 217f,
+ 48 / 78f,
+ 68 / 78f,
+ GL11.GL_NEAREST
+ );
+ Utils.drawStringCenteredScaledMaxWidth(
+ "Load preset",
+ fontRendererObj,
+ guiLeft - 44 - 2 - 22,
+ guiTop + 8,
+ false,
+ 86,
+ 4210752
+ );
+ Utils.drawStringCenteredScaledMaxWidth(
+ "from Clipboard",
+ fontRendererObj,
+ guiLeft - 44 - 2 - 22,
+ guiTop + 16,
+ false,
+ 86,
+ 4210752
+ );
+ Utils.drawStringCenteredScaledMaxWidth(
+ "Save preset",
+ fontRendererObj,
+ guiLeft - 44 - 2 - 22,
+ guiTop + 8 + 24,
+ false,
+ 86,
+ 4210752
+ );
+ Utils.drawStringCenteredScaledMaxWidth(
+ "to Clipboard",
+ fontRendererObj,
+ guiLeft - 44 - 2 - 22,
+ guiTop + 16 + 24,
+ false,
+ 86,
+ 4210752
+ );
+
+ if (!validShareContents()) {
+ Gui.drawRect(guiLeft - 88 - 2 - 22, guiTop + 2, guiLeft - 2 - 22, guiTop + 2 + 20, 0x80000000);
+ }
+
+ GlStateManager.color(1, 1, 1, 1);
+
+ if (presets != null) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(EDITOR);
+ Utils.drawTexturedRect(guiLeft + xSize + 22, guiTop, 80, ySize,
+ editorXSize / 256f, (editorXSize + 80) / 256f, 41 / 256f, (41 + ySize) / 256f, GL11.GL_NEAREST
+ );
+ Utils.drawStringCenteredScaledMaxWidth(
+ "\u00a7nPresets",
+ fontRendererObj,
+ guiLeft + xSize + 22 + 40,
+ guiTop + 10,
+ false,
+ 70,
+ 0xffa0a0a0
+ );
+
+ int index = 0;
+ for (String presetName : presets.keySet()) {
+ Utils.drawStringCenteredScaledMaxWidth(
+ presetName,
+ fontRendererObj,
+ guiLeft + xSize + 22 + 40,
+ guiTop + 25 + 10 * (index++),
+ false,
+ 70,
+ 0xff909090
+ );
+ }
+ }
+
+ if (editingButton != null) {
+ int x = guiLeft + editingButton.x;
+ int y = guiTop + editingButton.y;
+ if (editingButton.anchorRight) {
+ x += xSize;
+ }
+ if (editingButton.anchorBottom) {
+ y += ySize;
+ }
+
+ GlStateManager.translate(0, 0, 300);
+ editorLeft = x + 8 - editorXSize / 2;
+ editorTop = y + 18 + 2;
+
+ boolean showArrow = true;
+ if (editorTop + editorYSize + 5 > height) {
+ editorTop = height - editorYSize - 5;
+ showArrow = false;
+ }
+ if (editorLeft < 5) {
+ editorLeft = 5;
+ showArrow = false;
+ }
+ if (editorLeft + editorXSize + 5 > width) {
+ editorLeft = width - editorXSize - 5;
+ showArrow = false;
+ }
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(EDITOR);
+ GlStateManager.color(1, 1, 1, 1f);
+ Utils.drawTexturedRect(
+ editorLeft,
+ editorTop,
+ editorXSize,
+ editorYSize,
+ 0,
+ editorXSize / 256f,
+ 41 / 256f,
+ (41 + editorYSize) / 256f,
+ GL11.GL_NEAREST
+ );
+
+ if (showArrow)
+ Utils.drawTexturedRect(x + 8 - 3, y + 18, 10, 5, 0, 6 / 256f, 36 / 256f, 41 / 256f, GL11.GL_NEAREST);
+
+ fontRendererObj.drawString("Command", editorLeft + 7, editorTop + 7, 0xffa0a0a0, false);
+
+ commandTextField.setSize(editorXSize - 14, 16);
+ commandTextField.setText(commandTextField.getText().replaceAll("^ +", ""));
+ if (commandTextField.getText().startsWith("/")) {
+ commandTextField.setPrependText("");
+ } else {
+ commandTextField.setPrependText("\u00a77/\u00a7r");
+ }
+ commandTextField.render(editorLeft + 7, editorTop + 19);
+
+ fontRendererObj.drawString("Background", editorLeft + 7, editorTop + 40, 0xffa0a0a0, false);
+
+ for (int i = 0; i < BACKGROUND_TYPES; i++) {
+ if (i == editingButton.backgroundIndex) {
+ Gui.drawRect(
+ editorLeft + 7 + 20 * i - 1,
+ editorTop + 50 - 1,
+ editorLeft + 7 + 20 * i + 19,
+ editorTop + 50 + 19,
+ 0xff0000ff
+ );
+ }
+ Minecraft.getMinecraft().getTextureManager().bindTexture(EDITOR);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(editorLeft + 7 + 20 * i, editorTop + 50, 18, 18,
+ i * 18 / 256f, (i * 18 + 18) / 256f, 0 / 256f, 18 / 256f, GL11.GL_NEAREST
+ );
+ }
+
+ fontRendererObj.drawString("Icon Type", editorLeft + 7, editorTop + 50 + 24, 0xffa0a0a0, false);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(EDITOR);
+ GlStateManager.color(1, 1, 1, 1);
+ float uMin = 18 / 256f;
+ float uMax = 36 / 256f;
+ float vMin = 0;
+ float vMax = 18 / 256f;
+
+ for (int i = 0; i < ICON_TYPES; i++) {
+ boolean flip = iconTypeIndex == i;
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(EDITOR);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(editorLeft + 7 + 20 * i, editorTop + 50 + 34, 18, 18,
+ flip ? uMax : uMin, flip ? uMin : uMax, flip ? vMax : vMin, flip ? vMin : vMax, GL11.GL_NEAREST
+ );
+
+ ItemStack stack = null;
+ if (i == 0) {
+ stack = new ItemStack(Items.diamond_sword);
+ } else if (i == 1) {
+ stack = getStack("skull:c9c8881e42915a9d29bb61a16fb26d059913204d265df5b439b3d792acd56");
+ } else if (i == 2) {
+ stack = new ItemStack(Items.lead);
+ }
+ if (stack != null) Utils.drawItemStack(stack, editorLeft + 8 + 20 * i, editorTop + 50 + 35);
+ }
+
+ fontRendererObj.drawString("Icon Selector", editorLeft + 7, editorTop + 50 + 55, 0xffa0a0a0, false);
+
+ iconTextField.render(editorLeft + 7, editorTop + 50 + 65);
+
+ GlStateManager.enableDepth();
+
+ itemScroll.tick();
+
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ GlScissorStack.push(0, editorTop + 136, width, editorTop + 196, scaledResolution);
+
+ synchronized (searchedIcons) {
+ if (iconTextField.getText().trim().isEmpty() && searchedIcons.isEmpty()) {
+ searchedIcons.addAll(NotEnoughUpdates.INSTANCE.manager.getItemInformation().keySet());
+ searchedIcons.sort(prioritisingComparator);
+ }
+
+ int max = (searchedIcons.size() - 1) / 6 * 20 - 40;
+ int scroll = itemScroll.getValue();
+ if (scroll > max) scroll = max;
+
+ int scrollBarHeight = (int) Math.ceil(3f * 54f / (searchedIcons.size() - 18));
+ if (scrollBarHeight < 0) scrollBarHeight = 54;
+ if (scrollBarHeight < 2) scrollBarHeight = 2;
+ int scrollY = (int) Math.floor(54f * ((scroll / 20f) / ((searchedIcons.size() - 18) / 6f)));
+ if (scrollY + scrollBarHeight > 54) scrollY = 54 - scrollBarHeight;
+
+ Gui.drawRect(
+ editorLeft + 137,
+ editorTop + 139 + scrollY,
+ editorLeft + 139,
+ editorTop + 139 + scrollY + scrollBarHeight,
+ 0xff202020
+ );
+
+ int endIndex = searchedIcons.size();
+ int startIndex = scroll / 20 * 6;
+ if (startIndex < 0) startIndex = 0;
+ if (endIndex > startIndex + 24) endIndex = startIndex + 24;
+
+ for (int i = startIndex; i < endIndex; i++) {
+ String iconS = searchedIcons.get(i);
+
+ int iconX = editorLeft + 12 + ((i - startIndex) % 6) * 20;
+ int iconY = editorTop + 137 + ((i - startIndex) / 6) * 20 - (itemScroll.getValue() % 20);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(EDITOR);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(iconX, iconY, 18, 18,
+ 18 / 256f, 36 / 256f, 0 / 256f, 18 / 256f, GL11.GL_NEAREST
+ );
+
+ renderIcon(iconS, iconX + 1, iconY + 1);
+ }
+ }
+
+ GlScissorStack.pop(scaledResolution);
+
+ GlStateManager.translate(0, 0, -300);
+ }
+ }
+
+ @Override
+ public void handleMouseInput() throws IOException {
+ int scroll = Mouse.getEventDWheel();
+ if (scroll != 0) {
+ scroll = -scroll;
+ if (scroll > 1) scroll = 8;
+ if (scroll < -1) scroll = -8;
+
+ int delta = Math.abs(itemScroll.getTarget() - itemScroll.getValue());
+ float acc = delta / 20 + 1;
+ scroll *= acc;
+
+ int max = (searchedIcons.size() - 1) / 6 * 20 - 40;
+ int newTarget = itemScroll.getTarget() + scroll;
+
+ if (newTarget > max) newTarget = max;
+ if (newTarget < 0) newTarget = 0;
+
+ itemScroll.setTarget(newTarget);
+ itemScroll.resetTimer();
+ }
+
+ super.handleMouseInput();
+ }
+
+ private boolean validShareContents() {
+ try {
+ String base64 = (String) Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor);
+
+ if (base64.length() <= sharePrefix.length()) return false;
+
+ try {
+ return new String(Base64.getDecoder().decode(base64)).startsWith(sharePrefix);
+ } catch (IllegalArgumentException e) {
+ return false;
+ }
+ } catch (HeadlessException | IOException | UnsupportedFlavorException | IllegalStateException e) {
+ return false;
+ }
+ }
+
+ @Override
+ protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
+ super.mouseClicked(mouseX, mouseY, mouseButton);
+
+ if (editingButton != null) {
+ if (mouseX >= editorLeft && mouseX <= editorLeft + editorXSize &&
+ mouseY >= editorTop & mouseY <= editorTop + editorYSize) {
+ if (mouseX >= editorLeft + 7 && mouseX <= editorLeft + 7 + commandTextField.getWidth() &&
+ mouseY >= editorTop + 12 && mouseY <= editorTop + 12 + commandTextField.getHeight()) {
+ commandTextField.mouseClicked(mouseX, mouseY, mouseButton);
+ iconTextField.unfocus();
+ editingButton.command = commandTextField.getText();
+ return;
+ }
+ if (mouseX >= editorLeft + 7 && mouseX <= editorLeft + 7 + iconTextField.getWidth() &&
+ mouseY >= editorTop + 50 + 65 && mouseY <= editorTop + 50 + 65 + iconTextField.getHeight()) {
+ iconTextField.mouseClicked(mouseX, mouseY, mouseButton);
+
+ if (mouseButton == 1) {
+ search();
+ }
+
+ commandTextField.unfocus();
+ return;
+ }
+ if (mouseY >= editorTop + 50 && mouseY <= editorTop + 50 + 18) {
+ for (int i = 0; i < BACKGROUND_TYPES; i++) {
+ if (mouseX >= editorLeft + 7 + 20 * i && mouseX <= editorLeft + 7 + 20 * i + 18) {
+ editingButton.backgroundIndex = i;
+ return;
+ }
+ }
+ }
+ for (int i = 0; i < ICON_TYPES; i++) {
+ if (mouseX >= editorLeft + 7 + 20 * i && mouseX <= editorLeft + 7 + 20 * i + 18 &&
+ mouseY >= editorTop + 50 + 34 && mouseY <= editorTop + 50 + 34 + 18) {
+ if (iconTypeIndex != i) {
+ iconTypeIndex = i;
+ search();
+ }
+ return;
+ }
+ }
+ if (mouseX > editorLeft + 8 && mouseX < editorLeft + editorXSize - 16 && mouseY > editorTop + 136 &&
+ mouseY < editorTop + 196) {
+ synchronized (searchedIcons) {
+ int max = (searchedIcons.size() - 1) / 6 * 20 - 40;
+ int scroll = itemScroll.getValue();
+ if (scroll > max) scroll = max;
+
+ int endIndex = searchedIcons.size();
+ int startIndex = scroll / 20 * 6;
+ if (startIndex < 0) startIndex = 0;
+ if (endIndex > startIndex + 24) endIndex = startIndex + 24;
+
+ for (int i = startIndex; i < endIndex; i++) {
+ String iconS = searchedIcons.get(i);
+
+ int x = editorLeft + 12 + ((i - startIndex) % 6) * 20;
+ int y = editorTop + 137 + ((i - startIndex) / 6) * 20 - (itemScroll.getValue() % 20);
+
+ if (mouseX >= x && mouseX <= x + 18 &&
+ mouseY >= y && mouseY <= y + 18) {
+ editingButton.icon = iconS;
+ return;
+ }
+ }
+ }
+ }
+ return;
+ }
+ }
+
+ for (NEUConfig.InventoryButton button : NotEnoughUpdates.INSTANCE.config.hidden.inventoryButtons) {
+ int x = guiLeft + button.x;
+ int y = guiTop + button.y;
+ if (button.anchorRight) {
+ x += xSize;
+ }
+ if (button.anchorBottom) {
+ y += ySize;
+ }
+
+ if (mouseX >= x && mouseY >= y &&
+ mouseX <= x + 18 && mouseY <= y + 18) {
+ if (editingButton == button) {
+ editingButton = null;
+ } else {
+ editingButton = button;
+ commandTextField.setText(editingButton.command);
+ }
+ return;
+ }
+ }
+
+ if (mouseX > guiLeft - 2 - 88 - 22 && mouseX < guiLeft - 2 - 22) {
+ if (mouseY > guiTop + 2 && mouseY < guiTop + 22) {
+
+ String base64;
+
+ try {
+ base64 = (String) Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor);
+ } catch (HeadlessException | IOException | UnsupportedFlavorException e) {
+ return;
+ }
+
+ if (base64.length() <= sharePrefix.length()) return;
+
+ String jsonString;
+ try {
+ jsonString = new String(Base64.getDecoder().decode(base64));
+ if (!jsonString.startsWith(sharePrefix)) return;
+ jsonString = jsonString.substring(sharePrefix.length());
+ } catch (IllegalArgumentException e) {
+ return;
+
+ }
+ JsonArray presetArray;
+ try {
+ presetArray = new JsonParser().parse(jsonString).getAsJsonArray();
+ } catch (IllegalStateException | JsonParseException e) {
+ return;
+ }
+
+ List<NEUConfig.InventoryButton> buttons = new ArrayList<>();
+ System.out.println(presetArray.size());
+ try {
+ for (int i = 0; i < presetArray.size(); i++) {
+
+ JsonElement shittyO = presetArray.get(i);
+ JsonElement lessShittyO = new JsonParser().parse(shittyO.getAsString());
+ if (lessShittyO.isJsonObject()) {
+ JsonObject o = lessShittyO.getAsJsonObject();
+ NEUConfig.InventoryButton button = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(
+ o,
+ NEUConfig.InventoryButton.class
+ );
+ buttons.add(button);
+ }
+
+ }
+
+ NotEnoughUpdates.INSTANCE.config.hidden.inventoryButtons = buttons;
+ return;
+ } catch (JsonParseException | ClassCastException | IllegalStateException e) {
+ return;
+ }
+
+ } else if (mouseY > guiTop + 26 && mouseY < guiTop + 26 + 20) {
+
+ List<NEUConfig.InventoryButton> result = NotEnoughUpdates.INSTANCE.config.hidden.inventoryButtons;
+ JsonArray jsonArray = new JsonArray();
+
+ for (NEUConfig.InventoryButton inventoryButton : result) {
+ jsonArray.add(new JsonPrimitive(NotEnoughUpdates.INSTANCE.manager.gson.toJson(
+ inventoryButton,
+ NEUConfig.InventoryButton.class
+ )));
+ }
+ String base64String = Base64.getEncoder().encodeToString((sharePrefix +
+ jsonArray).getBytes(StandardCharsets.UTF_8));
+ Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(base64String), null);
+ return;
+ }
+ }
+
+ if (editingButton == null) {
+ int index = 0;
+ for (List<NEUConfig.InventoryButton> buttons : presets.values()) {
+ if (mouseX >= guiLeft + xSize + 22 && mouseX <= guiLeft + xSize + 22 + 80 &&
+ mouseY >= guiTop + 21 + 10 * index && mouseY <= guiTop + 21 + 10 * index + 10) {
+ NotEnoughUpdates.INSTANCE.config.hidden.inventoryButtons = buttons;
+ return;
+ }
+ index++;
+ }
+ }
+
+ editingButton = null;
+ }
+
+ @Override
+ protected void keyTyped(char typedChar, int keyCode) throws IOException {
+ super.keyTyped(typedChar, keyCode);
+
+ if (editingButton != null && commandTextField.getFocus()) {
+ commandTextField.keyTyped(typedChar, keyCode);
+ editingButton.command = commandTextField.getText();
+ } else if (editingButton != null && iconTextField.getFocus()) {
+ String old = iconTextField.getText().trim();
+ iconTextField.keyTyped(typedChar, keyCode);
+ String newText = iconTextField.getText().trim();
+
+ if (!old.equalsIgnoreCase(newText)) {
+ search();
+ }
+ }
+ }
+
+ private final ExecutorService searchES = Executors.newSingleThreadExecutor();
+ private final AtomicInteger searchId = new AtomicInteger(0);
+
+ public void search() {
+ final int thisSearchId = searchId.incrementAndGet();
+ final String searchString = iconTextField.getText();
+
+ if (iconTypeIndex == 0) {
+ if (searchString.trim().isEmpty()) {
+ synchronized (searchedIcons) {
+ searchedIcons.clear();
+
+ List<String> unsorted = new ArrayList<>(NotEnoughUpdates.INSTANCE.manager.getItemInformation().keySet());
+ unsorted.sort(prioritisingComparator);
+ searchedIcons.addAll(unsorted);
+ }
+ return;
+ }
+
+ searchES.submit(() -> {
+ if (thisSearchId != searchId.get()) return;
+
+ List<String> title = new ArrayList<>(NotEnoughUpdates.INSTANCE.manager.search("title:" + searchString.trim()));
+
+ if (thisSearchId != searchId.get()) return;
+
+ if (!searchString.trim().contains(" ")) {
+ StringBuilder sb = new StringBuilder();
+ for (char c : searchString.toCharArray()) {
+ sb.append(c).append(" ");
+ }
+ title.addAll(NotEnoughUpdates.INSTANCE.manager.search("title:" + sb.toString().trim()));
+ }
+
+ if (thisSearchId != searchId.get()) return;
+
+ List<String> desc = new ArrayList<>(NotEnoughUpdates.INSTANCE.manager.search("desc:" + searchString.trim()));
+ desc.removeAll(title);
+
+ if (thisSearchId != searchId.get()) return;
+
+ title.sort(prioritisingComparator);
+ desc.sort(prioritisingComparator);
+
+ if (thisSearchId != searchId.get()) return;
+
+ synchronized (searchedIcons) {
+ searchedIcons.clear();
+ searchedIcons.addAll(title);
+ searchedIcons.addAll(desc);
+ }
+ });
+ } else if (iconTypeIndex == 1) {
+ if (searchString.trim().isEmpty()) {
+ searchedIcons.clear();
+ searchedIcons.addAll(skullIcons.values());
+ return;
+ }
+
+ synchronized (searchedIcons) {
+ searchedIcons.clear();
+ for (Map.Entry<String, String> entry : skullIcons.entrySet()) {
+ if (NotEnoughUpdates.INSTANCE.manager.searchString(entry.getKey(), searchString)) {
+ searchedIcons.add(entry.getValue());
+ }
+ }
+ }
+ } else if (iconTypeIndex == 2) {
+ if (searchString.trim().isEmpty()) {
+ searchedIcons.clear();
+ searchedIcons.addAll(extraIcons.values());
+ return;
+ }
+
+ synchronized (searchedIcons) {
+ searchedIcons.clear();
+ for (Map.Entry<String, String> entry : extraIcons.entrySet()) {
+ if (NotEnoughUpdates.INSTANCE.manager.searchString(entry.getKey(), searchString)) {
+ searchedIcons.add(entry.getValue());
+ }
+ }
+ }
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemCustomize.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemCustomize.java
index fb0deaaf..222a0f88 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemCustomize.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemCustomize.java
@@ -10,7 +10,6 @@ import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiScreen;
-import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.resources.model.IBakedModel;
@@ -23,272 +22,282 @@ import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
-import java.awt.*;
-import java.io.*;
-import java.net.URL;
+import java.io.IOException;
import java.util.List;
public class GuiItemCustomize extends GuiScreen {
+ private static final ResourceLocation RESET = new ResourceLocation("notenoughupdates:itemcustomize/reset.png");
+
+ private final ItemStack stack;
+ private final String itemUUID;
+ private final GuiElementTextField textFieldRename = new GuiElementTextField("", 158, 20, GuiElementTextField.COLOUR);
+ private final GuiElementBoolean enchantGlintButton;
+
+ private int renderHeight = 0;
+
+ private final LerpingFloat enchantGlintCustomColourAnimation = new LerpingFloat(0, 200);
+
+ private boolean enchantGlint;
+ private String customGlintColour = null;
+
+ private String customLeatherColour = null;
+ private final boolean supportCustomLeatherColour;
+
+ private GuiElement editor = null;
+
+ public GuiItemCustomize(ItemStack stack, String itemUUID) {
+ this.stack = stack;
+ this.itemUUID = itemUUID;
+
+ IBakedModel model = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getItemModel(stack);
+ boolean stackHasEffect = stack.hasEffect() && !model.isBuiltInRenderer();
+
+ ItemCustomizeManager.ItemData data = ItemCustomizeManager.getDataForItem(stack);
+ if (data != null) {
+ this.enchantGlint = data.overrideEnchantGlint ? data.enchantGlintValue : stackHasEffect;
+ if (data.customName != null) {
+ textFieldRename.setText(data.customName);
+ }
+ this.customGlintColour = data.customGlintColour;
+ this.customLeatherColour = data.customLeatherColour;
+ } else {
+ this.enchantGlint = stackHasEffect;
+ }
+
+ supportCustomLeatherColour = stack.getItem() instanceof ItemArmor &&
+ ((ItemArmor) stack.getItem()).getArmorMaterial() == ItemArmor.ArmorMaterial.LEATHER;
+
+ enchantGlintCustomColourAnimation.setValue(enchantGlint ? 17 : 0);
+ this.enchantGlintButton = new GuiElementBoolean(0, 0, enchantGlint, (bool) -> {
+ enchantGlint = bool;
+ updateData();
+ });
- private static final ResourceLocation RESET = new ResourceLocation("notenoughupdates:itemcustomize/reset.png");
-
- private final ItemStack stack;
- private final String itemUUID;
- private final GuiElementTextField textFieldRename = new GuiElementTextField("", 158, 20, GuiElementTextField.COLOUR);
- private final GuiElementBoolean enchantGlintButton;
-
- private int renderHeight = 0;
-
- private final LerpingFloat enchantGlintCustomColourAnimation = new LerpingFloat(0, 200);
-
- private boolean enchantGlint;
- private String customGlintColour = null;
-
- private String customLeatherColour = null;
- private final boolean supportCustomLeatherColour;
-
- private GuiElement editor = null;
-
- public GuiItemCustomize(ItemStack stack, String itemUUID) {
- this.stack = stack;
- this.itemUUID = itemUUID;
-
- IBakedModel model = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getItemModel(stack);
- boolean stackHasEffect = stack.hasEffect() && !model.isBuiltInRenderer();
-
- ItemCustomizeManager.ItemData data = ItemCustomizeManager.getDataForItem(stack);
- if(data != null) {
- this.enchantGlint = data.overrideEnchantGlint ? data.enchantGlintValue : stackHasEffect;
- if(data.customName != null) {
- textFieldRename.setText(data.customName);
- }
- this.customGlintColour = data.customGlintColour;
- this.customLeatherColour = data.customLeatherColour;
- } else {
- this.enchantGlint = stackHasEffect;
- }
-
- supportCustomLeatherColour = stack.getItem() instanceof ItemArmor && ((ItemArmor) stack.getItem()).getArmorMaterial() == ItemArmor.ArmorMaterial.LEATHER;
-
- enchantGlintCustomColourAnimation.setValue(enchantGlint ? 17 : 0);
- this.enchantGlintButton = new GuiElementBoolean(0, 0, enchantGlint, (bool) -> {
- enchantGlint = bool;
- updateData();
- });
-
- }
-
- @Override
- public void onGuiClosed() {
- updateData();
- }
-
- public String getChromaStrFromLeatherColour() {
- return ChromaColour.special(0, 0xff, ((ItemArmor)stack.getItem()).getColor(stack));
- }
-
- public void updateData() {
- ItemCustomizeManager.ItemData data = new ItemCustomizeManager.ItemData();
-
- IBakedModel model = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getItemModel(stack);
- boolean stackHasEffect = stack.hasEffect() && !model.isBuiltInRenderer();
-
- if(this.enchantGlint != stackHasEffect) {
- data.overrideEnchantGlint = true;
- data.enchantGlintValue = this.enchantGlint;
- }
-
- if(this.customGlintColour != null && !this.customGlintColour.equals(ItemCustomizeManager.DEFAULT_GLINT_COLOR)) {
- data.customGlintColour = this.customGlintColour;
- } else if(model.isBuiltInRenderer() && data.overrideEnchantGlint && data.enchantGlintValue) {
- data.customGlintColour = ItemCustomizeManager.DEFAULT_GLINT_COLOR;
- } else {
- data.customGlintColour = null;
- }
-
- if(supportCustomLeatherColour && this.customLeatherColour != null && !this.customLeatherColour.equals(getChromaStrFromLeatherColour())) {
- data.customLeatherColour = this.customLeatherColour;
- } else {
- data.customLeatherColour = null;
- }
-
- if(!this.textFieldRename.getText().isEmpty()) {
- data.customName = this.textFieldRename.getText();
-
- NBTTagCompound stackTagCompound = stack.getTagCompound();
- if (stackTagCompound != null && stackTagCompound.hasKey("display", 10)) {
- NBTTagCompound nbttagcompound = stackTagCompound.getCompoundTag("display");
-
- if (nbttagcompound.hasKey("Name", 8)) {
- String name = nbttagcompound.getString("Name");
- char[] chars = name.toCharArray();
-
- int i;
- for(i=0; i<chars.length; i+=2) {
- if(chars[i] != '\u00a7'){
- break;
- }
- }
-
- data.customNamePrefix = name.substring(0, i);
- }
- }
- }
-
- ItemCustomizeManager.putItemData(itemUUID, data);
- }
-
- private int getGlintColour() {
- int col = customGlintColour == null ? ChromaColour.specialToChromaRGB(ItemCustomizeManager.DEFAULT_GLINT_COLOR) : ChromaColour.specialToChromaRGB(customGlintColour);
- return 0xff000000 | col;
- }
-
- private int getLeatherColour() {
- if(!supportCustomLeatherColour) return 0xff000000;
-
- int col = customLeatherColour == null ? ((ItemArmor)stack.getItem()).getColor(stack) : ChromaColour.specialToChromaRGB(customLeatherColour);
- return 0xff000000 | col;
- }
-
- @Override
- public void drawScreen(int mouseX, int mouseY, float partialTicks) {
- drawDefaultBackground();
-
- List<String> tooltipToDisplay = null;
-
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
-
- int xCenter = scaledResolution.getScaledWidth()/2;
- int yTopStart = (scaledResolution.getScaledHeight()-renderHeight)/2;
- int yTop = yTopStart;
-
- RenderUtils.drawFloatingRectDark(xCenter-100, yTop-9, 200, renderHeight+11);
-
- RenderUtils.drawFloatingRectDark(xCenter-90, yTop-5, 180, 14);
- Utils.renderShadowedString("\u00a75\u00a7lNEU Item Customizer", xCenter, yTop-1, 180);
-
- yTop += 14;
-
- if(!textFieldRename.getFocus() && textFieldRename.getText().isEmpty()) {
- textFieldRename.setOptions(GuiElementTextField.SCISSOR_TEXT);
- textFieldRename.setPrependText("\u00a77Enter Custom Name...");
- } else {
- textFieldRename.setOptions(GuiElementTextField.COLOUR | GuiElementTextField.SCISSOR_TEXT);
- textFieldRename.setPrependText("");
- }
-
- if(!textFieldRename.getFocus()) {
- textFieldRename.setSize(158, 20);
- } else {
- int textSize = fontRendererObj.getStringWidth(textFieldRename.getTextDisplay())+10;
- textFieldRename.setSize(Math.max(textSize, 158), 20);
- }
-
- textFieldRename.render(xCenter-textFieldRename.getWidth()/2-10, yTop);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(GuiTextures.help);
- GlStateManager.color(1, 1, 1, 1);
- int helpX = xCenter+textFieldRename.getWidth()/2-10;
- Utils.drawTexturedRect(helpX, yTop, 20, 20, GL11.GL_LINEAR);
-
- if(mouseX >= helpX && mouseX <= helpX+20 && mouseY >= yTop && mouseY <= yTop+20) {
- tooltipToDisplay = Lists.newArrayList(
- EnumChatFormatting.AQUA+"Set a custom name for the item",
- EnumChatFormatting.GREEN+"",
- EnumChatFormatting.GREEN+"Type \"&&\" to use colour codes",
- EnumChatFormatting.GREEN+"Type \"**\" for \u272A",
- EnumChatFormatting.GREEN+"",
- EnumChatFormatting.GREEN+"Available colour codes:",
- Utils.chromaString("\u00B6z = Chroma"),
- EnumChatFormatting.DARK_BLUE+"\u00B61 = Dark Blue",
- EnumChatFormatting.DARK_GREEN+"\u00B62 = Dark Green",
- EnumChatFormatting.DARK_AQUA+"\u00B63 = Dark Aqua",
- EnumChatFormatting.DARK_RED+"\u00B64 = Dark Red",
- EnumChatFormatting.DARK_PURPLE+"\u00B65 = Dark Purple",
- EnumChatFormatting.GOLD+"\u00B66 = Gold",
- EnumChatFormatting.GRAY+"\u00B67 = Gray",
- EnumChatFormatting.DARK_GRAY+"\u00B68 = Dark Gray",
- EnumChatFormatting.BLUE+"\u00B69 = Blue",
- EnumChatFormatting.GREEN+"\u00B6a = Green",
- EnumChatFormatting.AQUA+"\u00B6b = Aqua",
- EnumChatFormatting.RED+"\u00B6c = Red",
- EnumChatFormatting.LIGHT_PURPLE+"\u00B6d = Purple",
- EnumChatFormatting.YELLOW+"\u00B6e = Yellow",
- EnumChatFormatting.WHITE+"\u00B6f = White",
- "\u00A7Z\u00B6Z = SBA Chroma"+EnumChatFormatting.RESET+EnumChatFormatting.GRAY+" (Requires SBA)",
- "",
- EnumChatFormatting.GREEN+"Available formatting codes:",
- EnumChatFormatting.GRAY+"\u00B6k = "+EnumChatFormatting.OBFUSCATED+"Obfuscated",
- EnumChatFormatting.GRAY+"\u00B6l = "+EnumChatFormatting.BOLD+"Bold",
- EnumChatFormatting.GRAY+"\u00B6m = "+EnumChatFormatting.STRIKETHROUGH+"Strikethrough",
- EnumChatFormatting.GRAY+"\u00B6n = "+EnumChatFormatting.UNDERLINE+"Underline",
- EnumChatFormatting.GRAY+"\u00B6o = "+EnumChatFormatting.ITALIC+"Italic"
- );
- }
-
- yTop += 25;
-
- RenderUtils.drawFloatingRectDark(xCenter-90, yTop, 180, 110);
- GlStateManager.enableDepth();
- GlStateManager.pushMatrix();
- GlStateManager.translate(xCenter-48, yTop+7, 0);
- GlStateManager.scale(6, 6, 1);
- Utils.drawItemStack(stack, 0, 0);
- GlStateManager.popMatrix();
-
- yTop += 115;
-
- RenderUtils.drawFloatingRectDark(xCenter-90, yTop, 180, 20);
-
- Minecraft.getMinecraft().fontRendererObj.drawString("Enchant Glint",
- xCenter-85, yTop+6, 0xff8040cc);
-
- enchantGlintButton.x = xCenter+90-5-48;
- enchantGlintButton.y = yTop+3;
- enchantGlintButton.render();
-
- yTop += 25;
-
- enchantGlintCustomColourAnimation.tick();
- if(enchantGlintCustomColourAnimation.getValue() > 0) {
- yTop -= 5;
-
- int glintColour = getGlintColour();
-
- GlScissorStack.push(0, yTop, scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), scaledResolution);
- GlStateManager.translate(0, enchantGlintCustomColourAnimation.getValue()-17, 0);
-
- Gui.drawRect(xCenter-90, yTop, xCenter+92, yTop+17, 0x70000000);
- Gui.drawRect(xCenter-90, yTop, xCenter+90, yTop+15, 0xff101016);
- Gui.drawRect(xCenter-89, yTop+1, xCenter+89, yTop+14, 0xff000000 | glintColour);
-
- Utils.renderShadowedString("\u00a7a\u00a7lCustom Glint Colour", xCenter, yTop+4, 180);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(RESET);
- GlStateManager.color(1, 1, 1, 1);
- RenderUtils.drawTexturedRect(xCenter+90-12, yTop+2, 10, 11, GL11.GL_NEAREST);
-
- GlStateManager.translate(0, -enchantGlintCustomColourAnimation.getValue()+17, 0);
- GlScissorStack.pop(scaledResolution);
-
- yTop += enchantGlintCustomColourAnimation.getValue()+3;
- }
-
- if(supportCustomLeatherColour) {
- int leatherColour = getLeatherColour();
-
- Gui.drawRect(xCenter-90, yTop, xCenter+92, yTop+17, 0x70000000);
- Gui.drawRect(xCenter-90, yTop, xCenter+90, yTop+15, 0xff101016);
- Gui.drawRect(xCenter-89, yTop+1, xCenter+89, yTop+14, 0xff000000 | leatherColour);
-
- Utils.renderShadowedString("\u00a7b\u00a7lCustom Leather Colour", xCenter, yTop+4, 180);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(RESET);
- GlStateManager.color(1, 1, 1, 1);
- RenderUtils.drawTexturedRect(xCenter+90-12, yTop+2, 10, 11, GL11.GL_NEAREST);
-
- yTop += 20;
- }
+ }
+
+ @Override
+ public void onGuiClosed() {
+ updateData();
+ }
+
+ public String getChromaStrFromLeatherColour() {
+ return ChromaColour.special(0, 0xff, ((ItemArmor) stack.getItem()).getColor(stack));
+ }
+
+ public void updateData() {
+ ItemCustomizeManager.ItemData data = new ItemCustomizeManager.ItemData();
+
+ IBakedModel model = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getItemModel(stack);
+ boolean stackHasEffect = stack.hasEffect() && !model.isBuiltInRenderer();
+
+ if (this.enchantGlint != stackHasEffect) {
+ data.overrideEnchantGlint = true;
+ data.enchantGlintValue = this.enchantGlint;
+ }
+
+ if (this.customGlintColour != null && !this.customGlintColour.equals(ItemCustomizeManager.DEFAULT_GLINT_COLOR)) {
+ data.customGlintColour = this.customGlintColour;
+ } else if (model.isBuiltInRenderer() && data.overrideEnchantGlint && data.enchantGlintValue) {
+ data.customGlintColour = ItemCustomizeManager.DEFAULT_GLINT_COLOR;
+ } else {
+ data.customGlintColour = null;
+ }
+
+ if (supportCustomLeatherColour && this.customLeatherColour != null && !this.customLeatherColour.equals(
+ getChromaStrFromLeatherColour())) {
+ data.customLeatherColour = this.customLeatherColour;
+ } else {
+ data.customLeatherColour = null;
+ }
+
+ if (!this.textFieldRename.getText().isEmpty()) {
+ data.customName = this.textFieldRename.getText();
+
+ NBTTagCompound stackTagCompound = stack.getTagCompound();
+ if (stackTagCompound != null && stackTagCompound.hasKey("display", 10)) {
+ NBTTagCompound nbttagcompound = stackTagCompound.getCompoundTag("display");
+
+ if (nbttagcompound.hasKey("Name", 8)) {
+ String name = nbttagcompound.getString("Name");
+ char[] chars = name.toCharArray();
+
+ int i;
+ for (i = 0; i < chars.length; i += 2) {
+ if (chars[i] != '\u00a7') {
+ break;
+ }
+ }
+
+ data.customNamePrefix = name.substring(0, i);
+ }
+ }
+ }
+
+ ItemCustomizeManager.putItemData(itemUUID, data);
+ }
+
+ private int getGlintColour() {
+ int col = customGlintColour == null
+ ? ChromaColour.specialToChromaRGB(ItemCustomizeManager.DEFAULT_GLINT_COLOR)
+ : ChromaColour.specialToChromaRGB(customGlintColour);
+ return 0xff000000 | col;
+ }
+
+ private int getLeatherColour() {
+ if (!supportCustomLeatherColour) return 0xff000000;
+
+ int col =
+ customLeatherColour == null ? ((ItemArmor) stack.getItem()).getColor(stack) : ChromaColour.specialToChromaRGB(
+ customLeatherColour);
+ return 0xff000000 | col;
+ }
+
+ @Override
+ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
+ drawDefaultBackground();
+
+ List<String> tooltipToDisplay = null;
+
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+
+ int xCenter = scaledResolution.getScaledWidth() / 2;
+ int yTopStart = (scaledResolution.getScaledHeight() - renderHeight) / 2;
+ int yTop = yTopStart;
+
+ RenderUtils.drawFloatingRectDark(xCenter - 100, yTop - 9, 200, renderHeight + 11);
+
+ RenderUtils.drawFloatingRectDark(xCenter - 90, yTop - 5, 180, 14);
+ Utils.renderShadowedString("\u00a75\u00a7lNEU Item Customizer", xCenter, yTop - 1, 180);
+
+ yTop += 14;
+
+ if (!textFieldRename.getFocus() && textFieldRename.getText().isEmpty()) {
+ textFieldRename.setOptions(GuiElementTextField.SCISSOR_TEXT);
+ textFieldRename.setPrependText("\u00a77Enter Custom Name...");
+ } else {
+ textFieldRename.setOptions(GuiElementTextField.COLOUR | GuiElementTextField.SCISSOR_TEXT);
+ textFieldRename.setPrependText("");
+ }
+
+ if (!textFieldRename.getFocus()) {
+ textFieldRename.setSize(158, 20);
+ } else {
+ int textSize = fontRendererObj.getStringWidth(textFieldRename.getTextDisplay()) + 10;
+ textFieldRename.setSize(Math.max(textSize, 158), 20);
+ }
+
+ textFieldRename.render(xCenter - textFieldRename.getWidth() / 2 - 10, yTop);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(GuiTextures.help);
+ GlStateManager.color(1, 1, 1, 1);
+ int helpX = xCenter + textFieldRename.getWidth() / 2 - 5;
+ Utils.drawTexturedRect(helpX, yTop, 20, 20, GL11.GL_LINEAR);
+
+ if (mouseX >= helpX && mouseX <= helpX + 20 && mouseY >= yTop && mouseY <= yTop + 20) {
+ tooltipToDisplay = Lists.newArrayList(
+ EnumChatFormatting.AQUA + "Set a custom name for the item",
+ EnumChatFormatting.GREEN + "",
+ EnumChatFormatting.GREEN + "Type \"&&\" to use colour codes",
+ EnumChatFormatting.GREEN + "Type \"**\" for \u272A",
+ EnumChatFormatting.GREEN + "",
+ EnumChatFormatting.GREEN + "Available colour codes:",
+ Utils.chromaString("\u00B6z = Chroma"),
+ EnumChatFormatting.DARK_BLUE + "\u00B61 = Dark Blue",
+ EnumChatFormatting.DARK_GREEN + "\u00B62 = Dark Green",
+ EnumChatFormatting.DARK_AQUA + "\u00B63 = Dark Aqua",
+ EnumChatFormatting.DARK_RED + "\u00B64 = Dark Red",
+ EnumChatFormatting.DARK_PURPLE + "\u00B65 = Dark Purple",
+ EnumChatFormatting.GOLD + "\u00B66 = Gold",
+ EnumChatFormatting.GRAY + "\u00B67 = Gray",
+ EnumChatFormatting.DARK_GRAY + "\u00B68 = Dark Gray",
+ EnumChatFormatting.BLUE + "\u00B69 = Blue",
+ EnumChatFormatting.GREEN + "\u00B6a = Green",
+ EnumChatFormatting.AQUA + "\u00B6b = Aqua",
+ EnumChatFormatting.RED + "\u00B6c = Red",
+ EnumChatFormatting.LIGHT_PURPLE + "\u00B6d = Purple",
+ EnumChatFormatting.YELLOW + "\u00B6e = Yellow",
+ EnumChatFormatting.WHITE + "\u00B6f = White",
+ "\u00A7Z\u00B6Z = SBA Chroma" + EnumChatFormatting.RESET + EnumChatFormatting.GRAY + " (Requires SBA)",
+ "",
+ EnumChatFormatting.GREEN + "Available formatting codes:",
+ EnumChatFormatting.GRAY + "\u00B6k = " + EnumChatFormatting.OBFUSCATED + "Obfuscated",
+ EnumChatFormatting.GRAY + "\u00B6l = " + EnumChatFormatting.BOLD + "Bold",
+ EnumChatFormatting.GRAY + "\u00B6m = " + EnumChatFormatting.STRIKETHROUGH + "Strikethrough",
+ EnumChatFormatting.GRAY + "\u00B6n = " + EnumChatFormatting.UNDERLINE + "Underline",
+ EnumChatFormatting.GRAY + "\u00B6o = " + EnumChatFormatting.ITALIC + "Italic"
+ );
+ }
+
+ yTop += 25;
+
+ RenderUtils.drawFloatingRectDark(xCenter - 90, yTop, 180, 110);
+ GlStateManager.enableDepth();
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(xCenter - 48, yTop + 7, 0);
+ GlStateManager.scale(6, 6, 1);
+ Utils.drawItemStack(stack, 0, 0);
+ GlStateManager.popMatrix();
+
+ yTop += 115;
+
+ RenderUtils.drawFloatingRectDark(xCenter - 90, yTop, 180, 20);
+
+ Minecraft.getMinecraft().fontRendererObj.drawString("Enchant Glint",
+ xCenter - 85, yTop + 6, 0xff8040cc
+ );
+
+ enchantGlintButton.x = xCenter + 90 - 5 - 48;
+ enchantGlintButton.y = yTop + 3;
+ enchantGlintButton.render();
+
+ yTop += 25;
+
+ enchantGlintCustomColourAnimation.tick();
+ if (enchantGlintCustomColourAnimation.getValue() > 0) {
+ yTop -= 5;
+
+ int glintColour = getGlintColour();
+
+ GlScissorStack.push(
+ 0,
+ yTop,
+ scaledResolution.getScaledWidth(),
+ scaledResolution.getScaledHeight(),
+ scaledResolution
+ );
+ GlStateManager.translate(0, enchantGlintCustomColourAnimation.getValue() - 17, 0);
+
+ Gui.drawRect(xCenter - 90, yTop, xCenter + 92, yTop + 17, 0x70000000);
+ Gui.drawRect(xCenter - 90, yTop, xCenter + 90, yTop + 15, 0xff101016);
+ Gui.drawRect(xCenter - 89, yTop + 1, xCenter + 89, yTop + 14, 0xff000000 | glintColour);
+
+ Utils.renderShadowedString("\u00a7a\u00a7lCustom Glint Colour", xCenter, yTop + 4, 180);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(RESET);
+ GlStateManager.color(1, 1, 1, 1);
+ RenderUtils.drawTexturedRect(xCenter + 90 - 12, yTop + 2, 10, 11, GL11.GL_NEAREST);
+
+ GlStateManager.translate(0, -enchantGlintCustomColourAnimation.getValue() + 17, 0);
+ GlScissorStack.pop(scaledResolution);
+
+ yTop += enchantGlintCustomColourAnimation.getValue() + 3;
+ }
+
+ if (supportCustomLeatherColour) {
+ int leatherColour = getLeatherColour();
+
+ Gui.drawRect(xCenter - 90, yTop, xCenter + 92, yTop + 17, 0x70000000);
+ Gui.drawRect(xCenter - 90, yTop, xCenter + 90, yTop + 15, 0xff101016);
+ Gui.drawRect(xCenter - 89, yTop + 1, xCenter + 89, yTop + 14, 0xff000000 | leatherColour);
+
+ Utils.renderShadowedString("\u00a7b\u00a7lCustom Leather Colour", xCenter, yTop + 4, 180);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(RESET);
+ GlStateManager.color(1, 1, 1, 1);
+ RenderUtils.drawTexturedRect(xCenter + 90 - 12, yTop + 2, 10, 11, GL11.GL_NEAREST);
+
+ yTop += 20;
+ }
/*if(true) {
yTop += 20;
@@ -314,126 +323,132 @@ public class GuiItemCustomize extends GuiScreen {
}*/
-
- renderHeight = yTop - yTopStart;
-
- if(editor != null) {
- editor.render();
- }
-
- if(tooltipToDisplay != null) {
- Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, fontRendererObj);
- }
-
- super.drawScreen(mouseX, mouseY, partialTicks);
- }
-
- @Override
- public void updateScreen() {
- if(enchantGlint) {
- if(enchantGlintCustomColourAnimation.getTarget() != 17) {
- enchantGlintCustomColourAnimation.setTarget(17);
- enchantGlintCustomColourAnimation.resetTimer();
- }
- } else {
- if(enchantGlintCustomColourAnimation.getTarget() != 0) {
- enchantGlintCustomColourAnimation.setTarget(0);
- enchantGlintCustomColourAnimation.resetTimer();
- }
- }
-
- super.updateScreen();
- }
-
- @Override
- protected void keyTyped(char typedChar, int keyCode) throws IOException {
- Keyboard.enableRepeatEvents(true);
-
- if(textFieldRename.getFocus()) {
- if(keyCode == Keyboard.KEY_ESCAPE) {
- textFieldRename.setFocus(false);
- return;
- } else {
- textFieldRename.keyTyped(typedChar, keyCode);
- }
- }
-
- super.keyTyped(typedChar, keyCode);
- }
-
- @Override
- public void handleKeyboardInput() throws IOException {
- if(editor == null || !editor.keyboardInput()) {
- if(editor != null && Keyboard.getEventKeyState() && Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
- editor = null;
- } else {
- super.handleKeyboardInput();
- }
- }
- }
-
- @Override
- public void handleMouseInput() throws IOException {
- int mouseX = Mouse.getEventX() * this.width / this.mc.displayWidth;
- int mouseY = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
-
- if(editor == null || !editor.mouseInput(mouseX, mouseY)) {
- super.handleMouseInput();
- enchantGlintButton.mouseInput(mouseX, mouseY);
- }
- }
-
- @Override
- protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
- textFieldRename.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
- }
-
- @Override
- protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- int xCenter = scaledResolution.getScaledWidth()/2;
- int yTop = (scaledResolution.getScaledHeight()-renderHeight)/2;
-
- if(mouseX >= xCenter-textFieldRename.getWidth()/2-10 && mouseX <= xCenter+textFieldRename.getWidth()/2-10 &&
- mouseY >= yTop+14 && mouseY <= yTop+14+textFieldRename.getHeight()) {
- textFieldRename.mouseClicked(mouseX, mouseY, mouseButton);
- } else {
- textFieldRename.unfocus();
- }
-
- if(enchantGlint && mouseX >= xCenter-90 && mouseX <= xCenter+90 &&
- mouseY >= yTop+174 && mouseY <= yTop+174+enchantGlintCustomColourAnimation.getValue()) {
- if(mouseX >= xCenter+90-12) {
- editor = null;
- customGlintColour = ItemCustomizeManager.DEFAULT_GLINT_COLOR;
- updateData();
- } else {
- editor = new GuiElementColour(mouseX, mouseY, customGlintColour == null ? ItemCustomizeManager.DEFAULT_GLINT_COLOR : customGlintColour,
- (colour) -> {
- customGlintColour = colour;
- updateData();
- }, () -> editor = null);
- }
- }
-
- float belowEnchGlint = yTop+174+enchantGlintCustomColourAnimation.getValue()+5;
-
- if(supportCustomLeatherColour && mouseX >= xCenter-90 && mouseX <= xCenter+90 &&
- mouseY >= belowEnchGlint &&
- mouseY <= belowEnchGlint+15) {
- if(mouseX >= xCenter+90-12) {
- editor = null;
- customLeatherColour = null;
- updateData();
- } else {
- editor = new GuiElementColour(mouseX, mouseY,
- customLeatherColour == null ? getChromaStrFromLeatherColour() : customLeatherColour,
- (colour) -> {
- customLeatherColour = colour;
- updateData();
- }, () -> editor = null, false, true);
- }
- }
+ renderHeight = yTop - yTopStart;
+
+ if (editor != null) {
+ editor.render();
+ }
+
+ if (tooltipToDisplay != null) {
+ Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, fontRendererObj);
+ }
+
+ super.drawScreen(mouseX, mouseY, partialTicks);
+ }
+
+ @Override
+ public void updateScreen() {
+ if (enchantGlint) {
+ if (enchantGlintCustomColourAnimation.getTarget() != 17) {
+ enchantGlintCustomColourAnimation.setTarget(17);
+ enchantGlintCustomColourAnimation.resetTimer();
+ }
+ } else {
+ if (enchantGlintCustomColourAnimation.getTarget() != 0) {
+ enchantGlintCustomColourAnimation.setTarget(0);
+ enchantGlintCustomColourAnimation.resetTimer();
+ }
+ }
+
+ super.updateScreen();
+ }
+
+ @Override
+ protected void keyTyped(char typedChar, int keyCode) throws IOException {
+ Keyboard.enableRepeatEvents(true);
+
+ if (textFieldRename.getFocus()) {
+ if (keyCode == Keyboard.KEY_ESCAPE) {
+ textFieldRename.setFocus(false);
+ return;
+ } else {
+ textFieldRename.keyTyped(typedChar, keyCode);
+ }
+ }
+
+ super.keyTyped(typedChar, keyCode);
+ }
+
+ @Override
+ public void handleKeyboardInput() throws IOException {
+ if (editor == null || !editor.keyboardInput()) {
+ if (editor != null && Keyboard.getEventKeyState() && Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
+ editor = null;
+ } else {
+ super.handleKeyboardInput();
+ }
+ }
+ }
+
+ @Override
+ public void handleMouseInput() throws IOException {
+ int mouseX = Mouse.getEventX() * this.width / this.mc.displayWidth;
+ int mouseY = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
+
+ if (editor == null || !editor.mouseInput(mouseX, mouseY)) {
+ super.handleMouseInput();
+ enchantGlintButton.mouseInput(mouseX, mouseY);
+ }
+ }
+
+ @Override
+ protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
+ textFieldRename.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
+ }
+
+ @Override
+ protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ int xCenter = scaledResolution.getScaledWidth() / 2;
+ int yTop = (scaledResolution.getScaledHeight() - renderHeight) / 2;
+
+ if (mouseX >= xCenter - textFieldRename.getWidth() / 2 - 10 &&
+ mouseX <= xCenter + textFieldRename.getWidth() / 2 - 10 &&
+ mouseY >= yTop + 14 && mouseY <= yTop + 14 + textFieldRename.getHeight()) {
+ textFieldRename.mouseClicked(mouseX, mouseY, mouseButton);
+ } else {
+ textFieldRename.unfocus();
+ }
+
+ if (enchantGlint && mouseX >= xCenter - 90 && mouseX <= xCenter + 90 &&
+ mouseY >= yTop + 174 && mouseY <= yTop + 174 + enchantGlintCustomColourAnimation.getValue()) {
+ if (mouseX >= xCenter + 90 - 12) {
+ editor = null;
+ customGlintColour = ItemCustomizeManager.DEFAULT_GLINT_COLOR;
+ updateData();
+ } else {
+ editor = new GuiElementColour(
+ mouseX,
+ mouseY,
+ customGlintColour == null ? ItemCustomizeManager.DEFAULT_GLINT_COLOR : customGlintColour,
+ (colour) -> {
+ customGlintColour = colour;
+ updateData();
+ },
+ () -> editor = null
+ );
+ }
+ }
+
+ float belowEnchGlint = yTop + 174 + enchantGlintCustomColourAnimation.getValue() + 5;
+
+ if (supportCustomLeatherColour && mouseX >= xCenter - 90 && mouseX <= xCenter + 90 &&
+ mouseY >= belowEnchGlint &&
+ mouseY <= belowEnchGlint + 15) {
+ if (mouseX >= xCenter + 90 - 12) {
+ editor = null;
+ customLeatherColour = null;
+ updateData();
+ } else {
+ editor = new GuiElementColour(mouseX, mouseY,
+ customLeatherColour == null ? getChromaStrFromLeatherColour() : customLeatherColour,
+ (colour) -> {
+ customLeatherColour = colour;
+ updateData();
+ }, () -> editor = null, false, true
+ );
+ }
+ }
/*if(mouseX >= xCenter-90 && mouseX <= xCenter+90 &&
mouseY >= belowEnchGlint+65 && mouseY <= belowEnchGlint+80) {
@@ -448,6 +463,6 @@ public class GuiItemCustomize extends GuiScreen {
}
}*/
- super.mouseClicked(mouseX, mouseY, mouseButton);
- }
+ super.mouseClicked(mouseX, mouseY, mouseButton);
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemRecipe.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemRecipe.java
index 7caf935f..63a4d6d8 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemRecipe.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemRecipe.java
@@ -1,244 +1,253 @@
package io.github.moulberry.notenoughupdates.miscgui;
-import com.google.gson.JsonObject;
+import com.google.common.collect.ImmutableList;
import io.github.moulberry.notenoughupdates.NEUManager;
-import io.github.moulberry.notenoughupdates.util.TexLoc;
+import io.github.moulberry.notenoughupdates.recipes.NeuRecipe;
+import io.github.moulberry.notenoughupdates.recipes.RecipeSlot;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.client.resources.I18n;
-import net.minecraft.inventory.ContainerWorkbench;
-import net.minecraft.inventory.IInventory;
-import net.minecraft.inventory.Slot;
-import net.minecraft.inventory.SlotCrafting;
+import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
+import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
-import org.lwjgl.util.vector.Vector2f;
-import org.lwjgl.util.vector.Vector3f;
import java.awt.*;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.List;
public class GuiItemRecipe extends GuiScreen {
-
- private static final ResourceLocation resourcePacksTexture = new ResourceLocation("textures/gui/resource_packs.png");
- private static final ResourceLocation craftingTableGuiTextures = new ResourceLocation("textures/gui/container/crafting_table.png");
-
- private List<ItemStack[]> craftMatrices;
- private List<JsonObject> results;
- private int currentIndex = 0;
-
- private String title;
- private NEUManager manager;
-
- public int guiLeft = 0;
- public int guiTop = 0;
- public int xSize = 176;
- public int ySize = 166;
-
- public GuiItemRecipe(String title, List<ItemStack[]> craftMatrices, List<JsonObject> results, NEUManager manager) {
- this.craftMatrices = craftMatrices;
- this.results = results;
- this.manager = manager;
- this.title = title;
- }
-
- private String getCraftText() {
- if(results.get(currentIndex).has("crafttext")) {
- return results.get(currentIndex).get("crafttext").getAsString();
- } else {
- return "";
- }
- }
-
- @Override
- public void drawScreen(int mouseX, int mouseY, float partialTicks) {
- drawDefaultBackground();
-
- if(currentIndex < 0) {
- currentIndex = 0;
- } else if(currentIndex >= craftMatrices.size()) {
- currentIndex = craftMatrices.size()-1;
- }
-
- FontRenderer fontRendererObj = Minecraft.getMinecraft().fontRendererObj;
-
- this.guiLeft = (width - this.xSize) / 2;
- this.guiTop = (height - this.ySize) / 2;
-
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
- Minecraft.getMinecraft().getTextureManager().bindTexture(craftingTableGuiTextures);
- this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, this.xSize, this.ySize);
-
- List<String> tooltipToRender = null;
- for(int index=0; index <= 45; index++) {
- Vector2f pos = getPositionForIndex(index);
- Utils.drawItemStack(getStackForIndex(index), (int)pos.x, (int)pos.y);
-
- if(mouseX > pos.x && mouseX < pos.x+16) {
- if(mouseY > pos.y && mouseY < pos.y+16) {
- ItemStack stack = getStackForIndex(index);
- if(stack != null) {
- tooltipToRender = stack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
- }
- }
- }
- }
-
- if(craftMatrices.size() > 1) {
- int guiX = mouseX - guiLeft;
- int guiY = mouseY - guiTop;
-
- int buttonWidth = 7;
- int buttonHeight = 11;
-
- boolean leftSelected = false;
- boolean rightSelected = false;
-
- if(guiY > + 63 && guiY < + 63 + buttonHeight) {
- if(guiX > + 110 && guiX < 110 + buttonWidth) {
- leftSelected = true;
- } else if(guiX > 147 && guiX < 147 + buttonWidth) {
- rightSelected = true;
- }
- }
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(resourcePacksTexture);
- //Left arrow
- Utils.drawTexturedRect(guiLeft+110, guiTop+63, 7, 11, 34/256f, 48/256f,
- 5/256f + (leftSelected ? 32/256f : 0), 27/256f + (leftSelected ? 32/256f : 0));
- //Right arrow
- Utils.drawTexturedRect(guiLeft+147, guiTop+63, 7, 11, 10/256f, 24/256f,
- 5/256f + (rightSelected ? 32/256f : 0), 27/256f + (rightSelected ? 32/256f : 0));
- GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
-
- String str = (currentIndex+1)+"/"+craftMatrices.size();
- Utils.drawStringCenteredScaledMaxWidth(str, fontRendererObj, guiLeft+132, guiTop+69,
- false, 24, Color.BLACK.getRGB());
- }
-
- Utils.drawStringCenteredScaledMaxWidth(getCraftText(), fontRendererObj, guiLeft+132, guiTop+25,
- false, 75, 4210752);
-
- Utils.drawStringScaledMaxWidth(title, fontRendererObj, guiLeft+28, guiTop+6, title.contains("\u00a7"), xSize-38, 4210752);
-
- if(tooltipToRender != null) {
- Utils.drawHoveringText(tooltipToRender, mouseX, mouseY, width, height, -1, fontRendererObj);
- }
- }
-
- public ItemStack getStackForIndex(int index) {
- if(index == 0) {
- return manager.jsonToStack(results.get(currentIndex));
- } else if(index >= 1 && index <= 9) {
- return craftMatrices.get(currentIndex)[index-1];
- } else {
- return Minecraft.getMinecraft().thePlayer.inventory.getStackInSlot(index-10);
- }
- }
-
- public Vector2f getPositionForIndex(int index) {
- //0 = result
- //1-9 = craft matrix
- //10-18 = hotbar
- //19-45 = player inv
-
- if(index == 0) {
- return new Vector2f(guiLeft+124, guiTop+35);
- } else if(index >= 1 && index <= 9) {
- index -= 1;
- int x = index % 3;
- int y = index / 3;
- return new Vector2f(guiLeft+30 + x*18, guiTop+17 + y * 18);
- } else if(index >= 10 && index <= 18) {
- index -= 10;
- return new Vector2f(guiLeft+8 + index*18, guiTop+142);
- } else if(index >= 19 && index <= 45) {
- index -= 19;
- int x = index % 9;
- int y = index / 9;
- return new Vector2f(guiLeft+8 + x*18, guiTop+84 + y*18);
- }
- return null;
- }
-
- @Override
- public void handleKeyboardInput() throws IOException {
- super.handleKeyboardInput();
-
- if(!Keyboard.getEventKeyState()) return;
-
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- int width = scaledResolution.getScaledWidth();
- int height = scaledResolution.getScaledHeight();
- int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
- int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
-
- int keyPressed = Keyboard.getEventKey() == 0 ? Keyboard.getEventCharacter()+256 : Keyboard.getEventKey();
-
- for(int index=0; index <= 45; index++) {
- Vector2f pos = getPositionForIndex(index);
- if(mouseX > pos.x && mouseX < pos.x+16) {
- if(mouseY > pos.y && mouseY < pos.y+16) {
- ItemStack stack = getStackForIndex(index);
- if(stack != null) {
- if(keyPressed == manager.keybindViewRecipe.getKeyCode()) {
- manager.displayGuiItemRecipe(manager.getInternalNameForItem(stack), "");
- } else if(keyPressed == manager.keybindViewUsages.getKeyCode()) {
- manager.displayGuiItemUsages(manager.getInternalNameForItem(stack));
- }
- }
- return;
- }
- }
- }
- }
-
- @Override
- protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
- super.mouseClicked(mouseX, mouseY, mouseButton);
-
- int guiX = mouseX - guiLeft;
- int guiY = mouseY - guiTop;
-
- int buttonWidth = 7;
- int buttonHeight = 11;
-
- if(guiY > + 63 && guiY < + 63 + buttonHeight) {
- if(guiX > + 110 && guiX < 110 + buttonWidth) {
- currentIndex--;
- Utils.playPressSound();
- return;
- } else if(guiX > 147 && guiX < 147 + buttonWidth) {
- currentIndex++;
- Utils.playPressSound();
- return;
- }
- }
-
- for(int index=0; index <= 45; index++) {
- Vector2f pos = getPositionForIndex(index);
- if(mouseX > pos.x && mouseX < pos.x+16) {
- if(mouseY > pos.y && mouseY < pos.y+16) {
- ItemStack stack = getStackForIndex(index);
- if(stack != null) {
- if(mouseButton == 0) {
- manager.displayGuiItemRecipe(manager.getInternalNameForItem(stack), "");
- } else if(mouseButton == 1) {
- manager.displayGuiItemUsages(manager.getInternalNameForItem(stack));
- }
- }
- return;
- }
- }
- }
- }
-
+ public static final ResourceLocation resourcePacksTexture = new ResourceLocation("textures/gui/resource_packs.png");
+
+ public static final int SLOT_SIZE = 16;
+ public static final int SLOT_SPACING = SLOT_SIZE + 2;
+ public static final int BUTTON_WIDTH = 7;
+ public static final int BUTTON_HEIGHT = 11;
+ public static final int BUTTON_POSITION_Y = 63;
+ public static final int BUTTON_POSITION_LEFT_X = 110;
+ public static final int BUTTON_POSITION_RIGHT_X = 147;
+ public static final int PAGE_STRING_X = 132;
+ public static final int PAGE_STRING_Y = 69;
+ public static final int TITLE_X = 28;
+ public static final int TITLE_Y = 6;
+ public static final int HOTBAR_SLOT_X = 8;
+ public static final int HOTBAR_SLOT_Y = 142;
+ public static final int PLAYER_INVENTORY_X = 8;
+ public static final int PLAYER_INVENTORY_Y = 84;
+
+ private int currentIndex = 0;
+
+ private final String title;
+ private final List<NeuRecipe> craftingRecipes;
+ private final NEUManager manager;
+
+ public int guiLeft = 0;
+ public int guiTop = 0;
+ public int xSize = 176;
+ public int ySize = 166;
+
+ public GuiItemRecipe(String title, List<NeuRecipe> craftingRecipes, NEUManager manager) {
+ this.craftingRecipes = craftingRecipes;
+ this.manager = manager;
+ this.title = title;
+ }
+
+ public NeuRecipe getCurrentRecipe() {
+ currentIndex = MathHelper.clamp_int(currentIndex, 0, craftingRecipes.size());
+ return craftingRecipes.get(currentIndex);
+ }
+
+ public boolean isWithinRect(int x, int y, int topLeftX, int topLeftY, int width, int height) {
+ return topLeftX <= x && x <= topLeftX + width
+ && topLeftY <= y && y <= topLeftY + height;
+ }
+
+ private ImmutableList<RecipeSlot> getAllRenderedSlots() {
+ return ImmutableList.<RecipeSlot>builder()
+ .addAll(getPlayerInventory())
+ .addAll(getCurrentRecipe().getSlots()).build();
+ }
+
+ @Override
+ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
+ drawDefaultBackground();
+ FontRenderer fontRendererObj = Minecraft.getMinecraft().fontRendererObj;
+
+ this.guiLeft = (width - this.xSize) / 2;
+ this.guiTop = (height - this.ySize) / 2;
+
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+
+ NeuRecipe currentRecipe = getCurrentRecipe();
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(currentRecipe.getBackground());
+ this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, this.xSize, this.ySize);
+
+ currentRecipe.drawExtraBackground(this, mouseX, mouseY);
+
+ List<RecipeSlot> slots = getAllRenderedSlots();
+ for (RecipeSlot slot : slots) {
+ Utils.drawItemStack(slot.getItemStack(), slot.getX(this), slot.getY(this));
+ }
+
+ if (craftingRecipes.size() > 1) drawArrows(mouseX, mouseY);
+
+ Utils.drawStringScaledMaxWidth(
+ title,
+ fontRendererObj,
+ guiLeft + TITLE_X,
+ guiTop + TITLE_Y,
+ false,
+ xSize - 38,
+ 0x404040
+ );
+
+ currentRecipe.drawExtraInfo(this, mouseX, mouseY);
+
+ for (RecipeSlot slot : slots) {
+ if (isWithinRect(mouseX, mouseY, slot.getX(this), slot.getY(this), SLOT_SIZE, SLOT_SIZE)) {
+ if (slot.getItemStack() == null) continue;
+ Utils.drawHoveringText(
+ slot.getItemStack().getTooltip(Minecraft.getMinecraft().thePlayer, false),
+ mouseX,
+ mouseY,
+ width,
+ height,
+ -1,
+ fontRendererObj
+ );
+ }
+ }
+ currentRecipe.drawHoverInformation(this, mouseX, mouseY);
+ }
+
+ private void drawArrows(int mouseX, int mouseY) {
+ boolean leftSelected = isWithinRect(
+ mouseX - guiLeft,
+ mouseY - guiTop,
+ BUTTON_POSITION_LEFT_X,
+ BUTTON_POSITION_Y,
+ BUTTON_WIDTH,
+ BUTTON_HEIGHT
+ );
+ boolean rightSelected = isWithinRect(
+ mouseX - guiLeft,
+ mouseY - guiTop,
+ BUTTON_POSITION_RIGHT_X,
+ BUTTON_POSITION_Y,
+ BUTTON_WIDTH,
+ BUTTON_HEIGHT
+ );
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(resourcePacksTexture);
+
+ Utils.drawTexturedRect(guiLeft + BUTTON_POSITION_LEFT_X, guiTop + BUTTON_POSITION_Y, BUTTON_WIDTH, BUTTON_HEIGHT,
+ 34 / 256f, 48 / 256f,
+ leftSelected ? 37 / 256f : 5 / 256f, leftSelected ? 59 / 256f : 27 / 256f
+ );
+ Utils.drawTexturedRect(guiLeft + BUTTON_POSITION_RIGHT_X, guiTop + BUTTON_POSITION_Y, BUTTON_WIDTH, BUTTON_HEIGHT,
+ 10 / 256f, 24 / 256f,
+ rightSelected ? 37 / 256f : 5 / 256f, rightSelected ? 59 / 256f : 27 / 256f
+ );
+ GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
+
+ String selectedPage = (currentIndex + 1) + "/" + craftingRecipes.size();
+
+ Utils.drawStringCenteredScaledMaxWidth(selectedPage, fontRendererObj,
+ guiLeft + PAGE_STRING_X, guiTop + PAGE_STRING_Y, false, 24, Color.BLACK.getRGB()
+ );
+ }
+
+ public List<RecipeSlot> getPlayerInventory() {
+ List<RecipeSlot> slots = new ArrayList<>();
+ ItemStack[] inventory = Minecraft.getMinecraft().thePlayer.inventory.mainInventory;
+ int hotbarSize = InventoryPlayer.getHotbarSize();
+ for (int i = 0; i < inventory.length; i++) {
+ ItemStack item = inventory[i];
+ if (item == null || item.stackSize == 0) continue;
+ int row = i / hotbarSize;
+ int col = i % hotbarSize;
+ if (row == 0)
+ slots.add(new RecipeSlot(HOTBAR_SLOT_X + i * SLOT_SPACING, HOTBAR_SLOT_Y, item));
+ else
+ slots.add(new RecipeSlot(
+ PLAYER_INVENTORY_X + col * SLOT_SPACING,
+ PLAYER_INVENTORY_Y + (row - 1) * SLOT_SPACING,
+ item
+ ));
+ }
+ return slots;
+ }
+
+ @Override
+ public void handleKeyboardInput() throws IOException {
+ super.handleKeyboardInput();
+
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ int width = scaledResolution.getScaledWidth();
+ int height = scaledResolution.getScaledHeight();
+ int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
+ int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
+ int keyPressed = Keyboard.getEventKey() == 0 ? Keyboard.getEventCharacter() + 256 : Keyboard.getEventKey();
+
+ for (RecipeSlot slot : getAllRenderedSlots()) {
+ if (isWithinRect(mouseX, mouseY, slot.getX(this), slot.getY(this), SLOT_SIZE, SLOT_SIZE)) {
+ ItemStack itemStack = slot.getItemStack();
+ if (keyPressed == manager.keybindViewRecipe.getKeyCode()) { // TODO: rework this so it doesnt skip recipe chains
+ manager.displayGuiItemRecipe(manager.getInternalNameForItem(itemStack), "");
+ } else if (keyPressed == manager.keybindViewUsages.getKeyCode()) {
+ manager.displayGuiItemUsages(manager.getInternalNameForItem(itemStack));
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
+ super.mouseClicked(mouseX, mouseY, mouseButton);
+
+ if (isWithinRect(
+ mouseX - guiLeft,
+ mouseY - guiTop,
+ BUTTON_POSITION_LEFT_X,
+ BUTTON_POSITION_Y,
+ BUTTON_WIDTH,
+ BUTTON_HEIGHT
+ )) {
+ currentIndex = currentIndex == 0 ? 0 : currentIndex - 1;
+ Utils.playPressSound();
+ return;
+ }
+
+ if (isWithinRect(
+ mouseX - guiLeft,
+ mouseY - guiTop,
+ BUTTON_POSITION_RIGHT_X,
+ BUTTON_POSITION_Y,
+ BUTTON_WIDTH,
+ BUTTON_HEIGHT
+ )) {
+ currentIndex = currentIndex == craftingRecipes.size() - 1 ? currentIndex : currentIndex + 1;
+ Utils.playPressSound();
+ return;
+ }
+
+ for (RecipeSlot slot : getAllRenderedSlots()) {
+ if (isWithinRect(mouseX, mouseY, slot.getX(this), slot.getY(this), SLOT_SIZE, SLOT_SIZE)) {
+ ItemStack itemStack = slot.getItemStack();
+ if (mouseButton == 0) {
+ manager.displayGuiItemRecipe(manager.getInternalNameForItem(itemStack), "");
+ } else if (mouseButton == 1) {
+ manager.displayGuiItemUsages(manager.getInternalNameForItem(itemStack));
+ }
+ }
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiPriceGraph.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiPriceGraph.java
new file mode 100644
index 00000000..3955b35f
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiPriceGraph.java
@@ -0,0 +1,555 @@
+package io.github.moulberry.notenoughupdates.miscgui;
+
+import com.google.common.reflect.TypeToken;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.util.SpecialColour;
+import io.github.moulberry.notenoughupdates.util.Utils;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.Gui;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.ResourceLocation;
+import org.lwjgl.opengl.GL11;
+
+import java.io.*;
+import java.lang.reflect.Type;
+import java.nio.charset.StandardCharsets;
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+import java.text.SimpleDateFormat;
+import java.time.Instant;
+import java.util.*;
+import java.util.stream.Collectors;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.GZIPOutputStream;
+
+public class GuiPriceGraph extends GuiScreen {
+
+ private static final Gson GSON = new GsonBuilder().create();
+ private static final SimpleDateFormat format = new SimpleDateFormat("dd-MM-yyyy");
+ private final ResourceLocation TEXTURE;
+ private static final int X_SIZE = 364;
+ private static final int Y_SIZE = 215;
+ private Data dataPoints;
+ private float highestValue;
+ private long firstTime;
+ private long lastTime;
+ private Float lowestValue = null;
+ private String itemName;
+ private final String itemId;
+ private int guiLeft;
+ private int guiTop;
+ private ItemStack itemStack = null;
+ private boolean loaded = false;
+ /**
+ * 0 = hour
+ * 1 = day
+ * 2 = week
+ * 3 = all
+ * 4 = custom
+ **/
+ private int mode = NotEnoughUpdates.INSTANCE.config.ahGraph.defaultMode;
+ private long customStart = 0;
+ private long customEnd = 0;
+ private boolean customSelecting = false;
+
+ public GuiPriceGraph(String itemId) {
+ switch (NotEnoughUpdates.INSTANCE.config.ahGraph.graphStyle) {
+ case 1:
+ TEXTURE = new ResourceLocation("notenoughupdates:price_graph_gui/price_information_gui_dark.png");
+ break;
+ case 2:
+ TEXTURE = new ResourceLocation("notenoughupdates:price_graph_gui/price_information_gui_phqdark.png");
+ break;
+ case 3:
+ TEXTURE = new ResourceLocation("notenoughupdates:price_graph_gui/price_information_gui_fsr.png");
+ break;
+ default:
+ TEXTURE = new ResourceLocation("notenoughupdates:price_graph_gui/price_information_gui.png");
+ break;
+ }
+ this.itemId = itemId;
+ if (NotEnoughUpdates.INSTANCE.manager.getItemInformation().containsKey(itemId)) {
+ JsonObject itemInfo = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(itemId);
+ itemName = itemInfo.get("displayname").getAsString();
+ itemStack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(itemInfo);
+ }
+ loadData();
+ }
+
+ @Override
+ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
+ guiLeft = (width - X_SIZE) / 2;
+ guiTop = (height - Y_SIZE) / 2;
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(guiLeft, guiTop, X_SIZE, Y_SIZE,
+ 0, X_SIZE / 512f, 0, Y_SIZE / 512f, GL11.GL_NEAREST
+ );
+ Utils.drawTexturedRect(guiLeft + 245, guiTop + 17, 16, 16,
+ 0, 16 / 512f, (mode == 0 ? 215 : 231) / 512f, (mode == 0 ? 231 : 247) / 512f, GL11.GL_NEAREST
+ );
+ Utils.drawTexturedRect(guiLeft + 263, guiTop + 17, 16, 16,
+ 16 / 512f, 32 / 512f, (mode == 1 ? 215 : 231) / 512f, (mode == 1 ? 231 : 247) / 512f, GL11.GL_NEAREST
+ );
+ Utils.drawTexturedRect(guiLeft + 281, guiTop + 17, 16, 16,
+ 32 / 512f, 48 / 512f, (mode == 2 ? 215 : 231) / 512f, (mode == 2 ? 231 : 247) / 512f, GL11.GL_NEAREST
+ );
+ Utils.drawTexturedRect(guiLeft + 299, guiTop + 17, 16, 16,
+ 48 / 512f, 64 / 512f, (mode == 3 ? 215 : 231) / 512f, (mode == 3 ? 231 : 247) / 512f, GL11.GL_NEAREST
+ );
+
+ if (itemName != null && itemStack != null) {
+ Utils.drawItemStack(itemStack, guiLeft + 16, guiTop + 11);
+ Utils.drawStringScaledMax(itemName, Minecraft.getMinecraft().fontRendererObj, guiLeft + 35, guiTop + 13, false,
+ 0xffffff, 1.77f, 208
+ );
+ }
+
+ if (!loaded)
+ Utils.drawStringCentered("Loading...", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 166, guiTop + 116, false, 0xffffff00
+ );
+ else if (dataPoints == null || dataPoints.get() == null || dataPoints.get().size() <= 1)
+ Utils.drawStringCentered("No data found.", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 166, guiTop + 116, false, 0xffff0000
+ );
+ else {
+
+ int graphColor = SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.ahGraph.graphColor);
+ int graphColor2 = SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.ahGraph.graphColor2);
+ Integer lowestDist = null;
+ Long lowestDistTime = null;
+ HashMap<Integer, Integer> secondLineData = new HashMap<>();
+ for (int i = (dataPoints.isBz() ? 1 : 0); i >= 0; i--) {
+ Utils.drawGradientRect(0, guiLeft + 17, guiTop + 35, guiLeft + 315, guiTop + 198,
+ changeAlpha(i == 0 ? graphColor : graphColor2, 120), changeAlpha(i == 0 ? graphColor : graphColor2, 10)
+ );
+ Integer prevX = null;
+ Integer prevY = null;
+ for (Long time : dataPoints.get().keySet()) {
+ float price = dataPoints.isBz()
+ ? i == 0 ? dataPoints.bz.get(time).b : dataPoints.bz.get(time).s
+ : dataPoints.ah.get(time);
+ int xPos = (int) map(time, firstTime, lastTime, guiLeft + 17, guiLeft + 315);
+ int yPos = (int) map(price, highestValue + 10d, lowestValue - 10d, guiTop + 35, guiTop + 198);
+ if (prevX != null) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedQuad(
+ prevX,
+ prevY,
+ xPos,
+ yPos,
+ xPos,
+ guiTop + 35,
+ prevX,
+ guiTop + 35,
+ 18 / 512f,
+ 19 / 512f,
+ 36 / 512f,
+ 37 / 512f,
+ GL11.GL_NEAREST
+ );
+ if (i == 0) {
+ Utils.drawLine(prevX, prevY + 0.5f, xPos, yPos + 0.5f, 2, graphColor);
+ if (dataPoints.isBz())
+ Utils.drawLine(
+ prevX,
+ secondLineData.get(prevX) + 0.5f,
+ xPos,
+ secondLineData.get(xPos) + 0.5f,
+ 2,
+ graphColor2
+ );
+ }
+ }
+ if (i == 1)
+ secondLineData.put(xPos, yPos);
+ if (mouseX >= guiLeft + 17 && mouseX <= guiLeft + 315 && mouseY >= guiTop + 35 && mouseY <= guiTop + 198) {
+ int dist = Math.abs(mouseX - xPos);
+ if (lowestDist == null || dist < lowestDist) {
+ lowestDist = dist;
+ lowestDistTime = time;
+ }
+ }
+ prevX = xPos;
+ prevY = yPos;
+ }
+ }
+ boolean showDays = lastTime - firstTime > 86400;
+ int prevNum = showDays ? Date.from(Instant.ofEpochSecond(firstTime)).getDate() : Date.from(Instant.ofEpochSecond(
+ firstTime)).getHours();
+ long prevXPos = -100;
+ for (long time = firstTime; time <= lastTime; time += showDays ? 3600 : 60) {
+ int num = showDays
+ ? Date.from(Instant.ofEpochSecond(time)).getDate()
+ : Date.from(Instant.ofEpochSecond(time)).getHours();
+ if (num != prevNum) {
+ int xPos = (int) map(time, firstTime, lastTime, guiLeft + 17, guiLeft + 315);
+ if (Math.abs(prevXPos - xPos) > 30) {
+ Utils.drawStringCentered(String.valueOf(num), Minecraft.getMinecraft().fontRendererObj,
+ xPos, guiTop + 206, false, 0x8b8b8b
+ );
+ prevXPos = xPos;
+ }
+ prevNum = num;
+ }
+ }
+ for (int i = 0; i <= 6; i++) {
+ long price = (long) map(i, 0, 6, highestValue, lowestValue);
+ String formattedPrice = formatPrice(price);
+ Utils.drawStringF(formattedPrice, Minecraft.getMinecraft().fontRendererObj, guiLeft + 320,
+ (float) map(i, 0, 6, guiTop + 35, guiTop + 198)
+ - Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT / 2f,
+ false, 0x8b8b8b
+ );
+ }
+ if (customSelecting) {
+ Utils.drawDottedLine(customStart, guiTop + 36, customStart, guiTop + 197, 2, 10, 0xFFc6c6c6);
+ Utils.drawDottedLine(customEnd, guiTop + 36, customEnd, guiTop + 197, 2, 10, 0xFFc6c6c6);
+ Utils.drawDottedLine(customStart, guiTop + 36, customEnd, guiTop + 36, 2, 10, 0xFFc6c6c6);
+ Utils.drawDottedLine(customStart, guiTop + 197, customEnd, guiTop + 197, 2, 10, 0xFFc6c6c6);
+ }
+ if (lowestDist != null && !customSelecting) {
+ float price = dataPoints.isBz() ? dataPoints.bz.get(lowestDistTime).b : dataPoints.ah.get(lowestDistTime);
+ Float price2 = dataPoints.isBz() ? dataPoints.bz.get(lowestDistTime).s : null;
+ int xPos = (int) map(lowestDistTime, firstTime, lastTime, guiLeft + 17, guiLeft + 315);
+ int yPos = (int) map(price, highestValue + 10d, lowestValue - 10d, guiTop + 35, guiTop + 198);
+ int yPos2 = price2 != null
+ ? (int) map(price2, highestValue + 10d, lowestValue - 10d, guiTop + 35, guiTop + 198)
+ : 0;
+
+ Utils.drawLine(xPos, guiTop + 35, xPos, guiTop + 198, 2, 0x4D8b8b8b);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(xPos - 2.5f, yPos - 2.5f, 5, 5,
+ 0, 5 / 512f, 247 / 512f, 252 / 512f, GL11.GL_NEAREST
+ );
+ if (price2 != null) {
+ Utils.drawTexturedRect(xPos - 2.5f, yPos2 - 2.5f, 5, 5,
+ 0, 5 / 512f, 247 / 512f, 252 / 512f, GL11.GL_NEAREST
+ );
+ }
+
+ Date date = Date.from(Instant.ofEpochSecond(lowestDistTime));
+ SimpleDateFormat displayFormat = new SimpleDateFormat("'§b'd MMMMM yyyy '§eat§b' HH:mm");
+ NumberFormat nf = NumberFormat.getInstance();
+ ArrayList<String> text = new ArrayList<>();
+ text.add(displayFormat.format(date));
+ if (dataPoints.isBz()) {
+ text.add(EnumChatFormatting.YELLOW + "" + EnumChatFormatting.BOLD + "Bazaar Insta-Buy: " +
+ EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + nf.format(price));
+ text.add(EnumChatFormatting.YELLOW + "" + EnumChatFormatting.BOLD + "Bazaar Insta-Sell: " +
+ EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + nf.format(price2));
+ } else {
+ text.add(EnumChatFormatting.YELLOW + "" + EnumChatFormatting.BOLD + "Lowest BIN: " +
+ EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + nf.format(price));
+ }
+ drawHoveringText(text, xPos, yPos);
+ }
+ }
+
+ if (mouseY >= guiTop + 17 && mouseY <= guiTop + 35 && mouseX >= guiLeft + 244 && mouseX <= guiLeft + 316) {
+ int index = (mouseX - guiLeft - 245) / 18;
+ switch (index) {
+ case 0:
+ Gui.drawRect(guiLeft + 245, guiTop + 17, guiLeft + 261, guiTop + 33, 0x80ffffff);
+ drawHoveringText(Collections.singletonList("Show 1 Hour"), mouseX, mouseY);
+ break;
+ case 1:
+ Gui.drawRect(guiLeft + 263, guiTop + 17, guiLeft + 279, guiTop + 33, 0x80ffffff);
+ drawHoveringText(Collections.singletonList("Show 1 Day"), mouseX, mouseY);
+ break;
+ case 2:
+ Gui.drawRect(guiLeft + 281, guiTop + 17, guiLeft + 297, guiTop + 33, 0x80ffffff);
+ drawHoveringText(Collections.singletonList("Show 1 Week"), mouseX, mouseY);
+ break;
+ case 3:
+ Gui.drawRect(guiLeft + 299, guiTop + 17, guiLeft + 315, guiTop + 33, 0x80ffffff);
+ drawHoveringText(Collections.singletonList("Show All"), mouseX, mouseY);
+ break;
+ }
+ }
+ }
+
+ @Override
+ protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
+ super.mouseClicked(mouseX, mouseY, mouseButton);
+ if (mouseY >= guiTop + 17 && mouseY <= guiTop + 35 && mouseX >= guiLeft + 244 && mouseX <= guiLeft + 316) {
+ mode = (mouseX - guiLeft - 245) / 18;
+ loadData();
+ } else if (mouseY >= guiTop + 35 && mouseY <= guiTop + 198 && mouseX >= guiLeft + 17 && mouseX <= guiLeft + 315) {
+ customSelecting = true;
+ customStart = mouseX;
+ customEnd = mouseX;
+ }
+ }
+
+ @Override
+ protected void mouseReleased(int mouseX, int mouseY, int state) {
+ super.mouseReleased(mouseX, mouseY, state);
+ if (customSelecting) {
+ customSelecting = false;
+ customStart = (int) map(customStart, guiLeft + 17, guiLeft + 315, firstTime, lastTime);
+ customEnd = (int) map(mouseX, guiLeft + 17, guiLeft + 315, firstTime, lastTime);
+ if (customStart > customEnd) {
+ long temp = customStart;
+ customStart = customEnd;
+ customEnd = temp;
+ }
+ if (customEnd - customStart != 0) {
+ mode = 4;
+ loadData();
+ }
+ }
+ }
+
+ @Override
+ protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
+ super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
+ if (customSelecting) {
+ customEnd = mouseX < guiLeft + 18 ? guiLeft + 18 : Math.min(mouseX, guiLeft + 314);
+ }
+ }
+
+ private void loadData() {
+ dataPoints = null;
+ loaded = false;
+ new Thread(() -> {
+ File dir = new File("config/notenoughupdates/prices");
+ if (!dir.exists()) {
+ loaded = true;
+ return;
+ }
+ File[] files = dir.listFiles();
+ Data data = new Data();
+ if (files == null) return;
+ for (File file : files) {
+ if (!file.getName().endsWith(".gz")) continue;
+ HashMap<String, Data> data2 = load(file);
+ if (data2 == null || !data2.containsKey(itemId)) continue;
+ if (data2.get(itemId).isBz()) {
+ if (data.bz == null) data.bz = data2.get(itemId).bz;
+ else data.bz.putAll(data2.get(itemId).bz);
+ } else if (data.ah == null) data.ah = data2.get(itemId).ah;
+ else data.ah.putAll(data2.get(itemId).ah);
+ }
+ if (data.get() != null && !data.get().isEmpty()) {
+ if (mode < 3)
+ data = new Data(
+ new TreeMap<>(data.get().entrySet().stream()
+ .filter(e -> e.getKey() > System.currentTimeMillis() / 1000 -
+ (mode == 0 ? 3600 : mode == 1 ? 86400 : 604800))
+ .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))),
+ data.isBz()
+ );
+ else if (mode == 4)
+ data = new Data(
+ new TreeMap<>(data.get().entrySet().stream()
+ .filter(e -> e.getKey() >= customStart && e.getKey() <= customEnd)
+ .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))),
+ data.isBz()
+ );
+ if (data.get() == null || data.get().isEmpty()) {
+ loaded = true;
+ return;
+ }
+ dataPoints = trimData(data);
+ firstTime = dataPoints.get().firstKey();
+ lastTime = dataPoints.get().lastKey();
+ highestValue = 0;
+ lowestValue = null;
+ for (long key : dataPoints.get().keySet()) {
+ float value1 = dataPoints.isBz() ? dataPoints.bz.get(key).b : dataPoints.ah.get(key);
+ Float value2 = dataPoints.isBz() ? dataPoints.bz.get(key).s : null;
+ if (value1 > highestValue) {
+ highestValue = value1;
+ }
+ if (value2 != null && value2 > highestValue) {
+ highestValue = value2;
+ }
+ if (lowestValue == null || value1 < lowestValue) {
+ lowestValue = value1;
+ }
+ if (value2 != null && value2 < lowestValue) {
+ lowestValue = value2;
+ }
+ }
+ }
+ loaded = true;
+ }).start();
+ }
+
+ public static void addToCache(JsonObject items, boolean bazaar) {
+ if (!NotEnoughUpdates.INSTANCE.config.ahGraph.graphEnabled) return;
+ try {
+ File dir = new File("config/notenoughupdates/prices");
+ if (!dir.exists() && !dir.mkdir()) return;
+ File[] files = dir.listFiles();
+ if (files != null)
+ for (File file : files) {
+ if (!file.getName().endsWith(".gz")) continue;
+ if (file.lastModified() <
+ System.currentTimeMillis() - NotEnoughUpdates.INSTANCE.config.ahGraph.dataRetention * 86400000L)
+ file.delete();
+ }
+ Date date = new Date();
+ Long epochSecond = date.toInstant().getEpochSecond();
+ File file = new File(dir, "prices_" + format.format(date) + ".gz");
+ HashMap<String, Data> prices = new HashMap<>();
+ if (file.exists())
+ prices = load(file);
+ if (prices == null) return;
+ for (Map.Entry<String, JsonElement> item : items.entrySet()) {
+ if (prices.containsKey(item.getKey())) {
+ if (bazaar && item.getValue().getAsJsonObject().has("curr_buy") && item.getValue().getAsJsonObject().has(
+ "curr_sell"))
+ prices.get(item.getKey()).bz.put(epochSecond, new BzData(
+ item.getValue().getAsJsonObject().get("curr_buy").getAsFloat(),
+ item.getValue().getAsJsonObject().get("curr_sell").getAsFloat()
+ ));
+ else if (!bazaar)
+ prices.get(item.getKey()).ah.put(epochSecond, item.getValue().getAsInt());
+ } else {
+ TreeMap<Long, Object> mapData = new TreeMap<>();
+ if (bazaar && item.getValue().getAsJsonObject().has("curr_buy") && item.getValue().getAsJsonObject().has(
+ "curr_sell"))
+ mapData.put(epochSecond, new BzData(
+ item.getValue().getAsJsonObject().get("curr_buy").getAsFloat(),
+ item.getValue().getAsJsonObject().get("curr_sell").getAsFloat()
+ ));
+ else if (!bazaar)
+ mapData.put(epochSecond, item.getValue().getAsLong());
+ prices.put(item.getKey(), new Data(mapData, bazaar));
+ }
+ }
+ //noinspection ResultOfMethodCallIgnored
+ file.createNewFile();
+ try (
+ BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
+ new GZIPOutputStream(new FileOutputStream(file)),
+ StandardCharsets.UTF_8
+ ))
+ ) {
+ writer.write(GSON.toJson(prices));
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private Data trimData(Data data) {
+ long first = data.get().firstKey();
+ long last = data.get().lastKey();
+ Data trimmed = new Data();
+ if (data.isBz())
+ trimmed.bz = new TreeMap<>();
+ else
+ trimmed.ah = new TreeMap<>();
+ int zones = NotEnoughUpdates.INSTANCE.config.ahGraph.graphZones;
+ Long[] dataArray = !data.isBz() ? data.ah.keySet().toArray(new Long[0]) : data.bz.keySet().toArray(new Long[0]);
+ int prev = 0;
+ for (int i = 0; i < zones; i++) {
+ long lowest = (long) map(i, 0, zones, first, last);
+ long highest = (long) map(i + 1, 0, zones, first, last);
+ int amount = 0;
+ double sumBuy = 0;
+ double sumSell = 0;
+ for (int l = prev; l < dataArray.length; l++) {
+ if (dataArray[l] >= lowest && dataArray[l] <= highest) {
+ amount++;
+ sumBuy += data.isBz() ? data.bz.get(dataArray[l]).b : data.ah.get(dataArray[l]);
+ if (data.isBz()) sumSell += data.bz.get(dataArray[l]).s;
+ prev = l + 1;
+ } else if (dataArray[l] > highest)
+ break;
+ }
+ if (amount > 0) {
+ if (data.isBz())
+ trimmed.bz.put(lowest, new BzData((float) (sumBuy / amount), (float) (sumSell / amount)));
+ else
+ trimmed.ah.put(lowest, (int) (sumBuy / amount));
+ }
+ }
+ return trimmed;
+ }
+
+ private static HashMap<String, Data> load(File file) {
+ Type type = new TypeToken<HashMap<String, Data>>() {
+ }.getType();
+ if (file.exists()) {
+ try (
+ BufferedReader reader = new BufferedReader(new InputStreamReader(
+ new GZIPInputStream(new FileInputStream(file)),
+ StandardCharsets.UTF_8
+ ))
+ ) {
+ return GSON.fromJson(reader, type);
+ } catch (Exception ignored) {
+ }
+ }
+ return null;
+ }
+
+ private static double map(double x, double in_min, double in_max, double out_min, double out_max) {
+ return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
+ }
+
+ private static String formatPrice(long price) {
+ DecimalFormat df = new DecimalFormat("#.00");
+ if (price >= 1000000000) {
+ return df.format(price / 1000000000f) + "B";
+ } else if (price >= 1000000) {
+ return df.format(price / 1000000f) + "M";
+ } else if (price >= 1000) {
+ return df.format(price / 1000f) + "K";
+ }
+ return String.valueOf(price);
+ }
+
+ private int changeAlpha(int origColor, int alpha) {
+ origColor = origColor & 0x00ffffff; //drop the previous alpha value
+ return (alpha << 24) | origColor; //add the one the user inputted
+ }
+}
+
+class Data {
+ public TreeMap<Long, Integer> ah = null;
+ public TreeMap<Long, BzData> bz = null;
+
+ public Data() {
+ }
+
+ public Data(TreeMap<Long, ?> map, boolean bz) {
+ if (bz)
+ this.bz = (TreeMap<Long, BzData>) map;
+ else
+ this.ah = (TreeMap<Long, Integer>) map;
+ }
+
+ public TreeMap<Long, ?> get() {
+ return !isBz() ? ah : bz;
+ }
+
+ public boolean isBz() {
+ return bz != null && !bz.isEmpty();
+ }
+}
+
+class BzData {
+ float b;
+ float s;
+
+ public BzData(float b, float s) {
+ this.b = b;
+ this.s = s;
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/InventoryStorageSelector.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/InventoryStorageSelector.java
index d24f2572..3932c9d5 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/InventoryStorageSelector.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/InventoryStorageSelector.java
@@ -18,429 +18,479 @@ import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.MouseEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.InputEvent;
-import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
public class InventoryStorageSelector {
-
- private static final InventoryStorageSelector INSTANCE = new InventoryStorageSelector();
-
- private static final ResourceLocation ICONS = new ResourceLocation("notenoughupdates:storage_gui/hotbar_icons.png");
- private static final ResourceLocation STORAGE_PANE_CTM_TEXTURE = new ResourceLocation("notenoughupdates:storage_gui/storage_gui_pane_ctm.png");
-
- public boolean isOverridingSlot = false;
-
- public static InventoryStorageSelector getInstance() {
- return INSTANCE;
- }
-
- public boolean isSlotSelected() {
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.storageGUI.showInvBackpack) {
- isOverridingSlot = false;
- return false;
- }
- if(Minecraft.getMinecraft().currentScreen != null) {
- return false;
- }
- if(Minecraft.getMinecraft().thePlayer == null) {
- isOverridingSlot = false;
- return false;
- }
- if(Minecraft.getMinecraft().thePlayer.inventory.currentItem != 0) {
- isOverridingSlot = false;
- return false;
- }
- return isOverridingSlot;
- }
-
- @SubscribeEvent
- public void onMousePress(MouseEvent event) {
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.storageGUI.showInvBackpack) {
- return;
- }
- if(Minecraft.getMinecraft().currentScreen != null) {
- return;
- }
-
- if(KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.storageGUI.arrowLeftKey)) {
- NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex--;
-
- int max = StorageManager.getInstance().storageConfig.displayToStorageIdMap.size()-1;
- if(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex > max) NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex = max;
- if(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex < 0) NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex = 0;
- } else if(KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.storageGUI.arrowRightKey)) {
- NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex++;
-
- int max = StorageManager.getInstance().storageConfig.displayToStorageIdMap.size()-1;
- if(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex > max) NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex = max;
- if(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex < 0) NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex = 0;
- } else if(KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.storageGUI.arrowDownKey)) {
- sendToPage(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex);
- }
-
- if(isSlotSelected()) {
- int useKeycode = Minecraft.getMinecraft().gameSettings.keyBindUseItem.getKeyCode() + 100;
- int attackKeycode = Minecraft.getMinecraft().gameSettings.keyBindAttack.getKeyCode() + 100;
-
- if(Mouse.getEventButton() == useKeycode || Mouse.getEventButton() == attackKeycode) {
- if(Mouse.getEventButtonState() &&
- Mouse.getEventButton() != NotEnoughUpdates.INSTANCE.config.storageGUI.backpackScrollKey+100) {
- sendToPage(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex);
- }
-
- event.setCanceled(true);
- }
- }
- }
-
- private void sendToPage(int displayId) {
- if(!StorageManager.getInstance().storageConfig.displayToStorageIdMap.containsKey(displayId)) {
- return;
- }
- if(getPage(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex) == null) {
- NotEnoughUpdates.INSTANCE.sendChatMessage("/storage");
- } else {
- int index = StorageManager.getInstance().storageConfig.displayToStorageIdMap.get(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex);
- StorageManager.getInstance().sendToPage(index);
- }
- }
-
- @SubscribeEvent
- public void onKeyPress(InputEvent.KeyInputEvent event) {
- if(Minecraft.getMinecraft().gameSettings.keyBindsHotbar[0].isKeyDown()) {
- isOverridingSlot = false;
- }
- if(Minecraft.getMinecraft().currentScreen != null) {
- return;
- }
-
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.storageGUI.showInvBackpack) {
- return;
- }
-
- if(KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.storageGUI.backpackHotkey)) {
- Minecraft.getMinecraft().thePlayer.inventory.currentItem = 0;
- isOverridingSlot = true;
- } else if(KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.storageGUI.arrowLeftKey)) {
- NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex--;
-
- int max = StorageManager.getInstance().storageConfig.displayToStorageIdMap.size()-1;
- if(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex > max) NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex = max;
- if(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex < 0) NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex = 0;
- } else if(KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.storageGUI.arrowRightKey)) {
- NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex++;
-
- int max = StorageManager.getInstance().storageConfig.displayToStorageIdMap.size()-1;
- if(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex > max) NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex = max;
- if(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex < 0) NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex = 0;
- } else if(KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.storageGUI.arrowDownKey)) {
- sendToPage(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex);
- }
-
- if(isSlotSelected()) {
- KeyBinding attack = Minecraft.getMinecraft().gameSettings.keyBindAttack;
- KeyBinding use = Minecraft.getMinecraft().gameSettings.keyBindUseItem;
-
- if(attack.isPressed() || attack.isKeyDown()) {
- if(attack.getKeyCode() != NotEnoughUpdates.INSTANCE.config.storageGUI.backpackScrollKey) {
- sendToPage(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex);
- }
-
- KeyBinding.setKeyBindState(attack.getKeyCode(), false);
- while(attack.isPressed()){}
- }
-
- if(use.isPressed() || use.isKeyDown()) {
- if(attack.getKeyCode() != NotEnoughUpdates.INSTANCE.config.storageGUI.backpackScrollKey) {
- sendToPage(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex);
- }
-
- KeyBinding.setKeyBindState(use.getKeyCode(), false);
- while(use.isPressed()){}
- }
- }
- }
-
- public int onScroll(int direction, int resultantSlot) {
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.storageGUI.showInvBackpack) {
- return resultantSlot;
- }
- if(Minecraft.getMinecraft().currentScreen != null) {
- return resultantSlot;
- }
-
- int keyCode = NotEnoughUpdates.INSTANCE.config.storageGUI.backpackScrollKey;
- if(isOverridingSlot && KeybindHelper.isKeyDown(keyCode)) {
- NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex -= direction;
- int max = StorageManager.getInstance().storageConfig.displayToStorageIdMap.size()-1;
-
- if(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex > max) NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex = max;
- if(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex < 0) NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex = 0;
- return 0;
- }
-
- boolean allowScroll = NotEnoughUpdates.INSTANCE.config.storageGUI.scrollToBackpack2 == 0 ?
- KeybindHelper.isKeyDown(NotEnoughUpdates.INSTANCE.config.storageGUI.backpackScrollKey) :
- NotEnoughUpdates.INSTANCE.config.storageGUI.scrollToBackpack2 == 1;
-
- if(allowScroll && resultantSlot == 0 && direction == -1 && !isOverridingSlot) {
- isOverridingSlot = true;
- Minecraft.getMinecraft().getItemRenderer().resetEquippedProgress();
- return 0;
- } else if(resultantSlot == 1 && direction == -1 && isOverridingSlot) {
- isOverridingSlot = false;
- Minecraft.getMinecraft().getItemRenderer().resetEquippedProgress();
- return 0;
- } else if(allowScroll && resultantSlot == 8 && direction == 1 && !isOverridingSlot) {
- isOverridingSlot = true;
- Minecraft.getMinecraft().getItemRenderer().resetEquippedProgress();
- return 0;
- }
- return resultantSlot;
- }
-
- private StorageManager.StoragePage getPage(int selectedIndex) {
- if(!StorageManager.getInstance().storageConfig.displayToStorageIdMap.containsKey(selectedIndex)) {
- return null;
- }
- int index = StorageManager.getInstance().storageConfig.displayToStorageIdMap.get(selectedIndex);
- return StorageManager.getInstance().getPage(index, false);
- }
-
- public ItemStack getNamedHeldItemOverride() {
- StorageManager.StoragePage page = getPage(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex);
- if(page != null && page.backpackDisplayStack != null) {
- return page.backpackDisplayStack;
- }
- return new ItemStack(Item.getItemFromBlock(Blocks.chest));
- }
-
- public ItemStack getHeldItemOverride() {
- return getHeldItemOverride(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex);
- }
-
- public ItemStack getHeldItemOverride(int selectedIndex) {
- StorageManager.StoragePage page = getPage(selectedIndex);
- if(page != null) {
- ItemStack stack = page.backpackDisplayStack;
- if(stack == null || stack.getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane)) {
- return new ItemStack(Item.getItemFromBlock(Blocks.ender_chest));
- }
- return stack;
- }
- return new ItemStack(Item.getItemFromBlock(Blocks.chest));
- }
-
- public void render(ScaledResolution scaledResolution, float partialTicks) {
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.storageGUI.showInvBackpack) {
- return;
- }
- if(Minecraft.getMinecraft().currentScreen != null) {
- return;
- }
-
- int max = StorageManager.getInstance().storageConfig.displayToStorageIdMap.size()-1;
- if(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex > max) NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex = max;
- if(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex < 0) NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex = 0;
-
- int width = scaledResolution.getScaledWidth();
- int height = scaledResolution.getScaledHeight();
- FontRenderer fontRendererObj = Minecraft.getMinecraft().fontRendererObj;
- int centerX = width / 2;
-
- int offset = 91 + 10 + 12;
-
- if(NotEnoughUpdates.INSTANCE.config.storageGUI.backpackHotbarSide == 1) {
- offset *= -1;
- }
-
- ItemStack held = getHeldItemOverride();
- int left = centerX - offset - 12;
- int top = scaledResolution.getScaledHeight() - 22;
-
- if(NotEnoughUpdates.INSTANCE.config.storageGUI.showInvBackpackPreview && isSlotSelected()) {
- StorageManager.StoragePage page = getPage(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex);
-
- if(page != null && page.rows > 0) {
- int rows = page.rows;
-
- ResourceLocation storagePreviewTexture = StorageOverlay.STORAGE_PREVIEW_TEXTURES[NotEnoughUpdates.INSTANCE.config.storageGUI.displayStyle];
-
- int startX = centerX - 172/2;
- int startY = height - 80 - (10+18*rows);
-
- GlStateManager.translate(0, 0, 100);
- GL11.glDepthMask(false);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(storagePreviewTexture);
- GlStateManager.color(1, 1, 1,
- NotEnoughUpdates.INSTANCE.config.storageGUI.backpackOpacity/100f);
- Utils.drawTexturedRect(startX, startY, 176, 7, 0, 1, 0, 7/32f, GL11.GL_NEAREST);
- for(int i=0; i<rows; i++) {
- Utils.drawTexturedRect(startX, startY+7+18*i, 176, 18, 0, 1, 7/32f, 25/32f, GL11.GL_NEAREST);
- }
- Utils.drawTexturedRect(startX, startY+7+18*rows, 176, 7, 0, 1, 25/32f, 1, GL11.GL_NEAREST);
-
- GL11.glDepthMask(true);
-
- int[] isPaneCache = new int[rows*9];
- int[] ctmIndexCache = new int[rows*9];
-
- for(int i=0; i<rows*9; i++) {
- ItemStack stack = page.items[i];
- if(stack != null) {
- int itemX = startX+8+18*(i%9);
- int itemY = startY+8+18*(i/9);
-
- int paneType = StorageOverlay.getPaneType(stack, i, isPaneCache);
- if(paneType > 0) {
- GlStateManager.disableAlpha();
- Gui.drawRect(itemX-1, itemY-1, itemX+17, itemY+17, 0x01000000);
- GlStateManager.enableAlpha();
-
- int ctmIndex = StorageOverlay.getCTMIndex(page, i, isPaneCache, ctmIndexCache);
- int startCTMX = (ctmIndex%12)*19;
- int startCTMY = (ctmIndex/12)*19;
-
- ctmIndexCache[i] = ctmIndex;
-
- if(paneType != 17) {
- int rgb = StorageOverlay.getRGBFromPane(paneType-1);
- {
- int a = (rgb >> 24) & 0xFF;
- int r = (rgb >> 16) & 0xFF;
- int g = (rgb >> 8) & 0xFF;
- int b = rgb & 0xFF;
- Minecraft.getMinecraft().getTextureManager().bindTexture(STORAGE_PANE_CTM_TEXTURE);
- GlStateManager.color(r/255f, g/255f, b/255f, a/255f);
- Utils.drawTexturedRect(itemX-1, itemY-1, 18, 18,
- startCTMX/227f, (startCTMX+18)/227f, startCTMY/75f, (startCTMY+18)/75f, GL11.GL_NEAREST);
- }
-
- RenderItem itemRender = Minecraft.getMinecraft().getRenderItem();
- itemRender.renderItemOverlayIntoGUI(Minecraft.getMinecraft().fontRendererObj, stack, itemX, itemY, null);
- GlStateManager.disableLighting();
- }
-
- page.shouldDarkenIfNotSelected[i] = false;
- continue;
- } else {
- int upIndex = i-9;
- int leftIndex = i%9 > 0 ? i-1 : -1;
- int rightIndex = i%9 < 8 ? i+1 : -1;
- int downIndex = i+9;
-
- int[] indexArr = {rightIndex, downIndex, leftIndex, upIndex};
-
- for(int j=0; j<4; j++) {
- int index = indexArr[j];
- int type = index >= 0 && index < isPaneCache.length ? StorageOverlay.getPaneType(page.items[index], index, isPaneCache) : -1;
- if(type > 0) {
- int ctmIndex = StorageOverlay.getCTMIndex(page, index, isPaneCache, ctmIndexCache);
- if(ctmIndex < 0) continue;
-
- boolean renderConnection;
- boolean horizontal = ctmIndex == 1 || ctmIndex == 2 || ctmIndex == 3;
- boolean vertical = ctmIndex == 12 || ctmIndex == 24 || ctmIndex == 36;
- if((i%9 == 0 && index%9 == 0) || (i%9 == 8 && index%9 == 8)) {
- renderConnection = horizontal || vertical;
- } else if(index == leftIndex || index == rightIndex) {
- renderConnection = horizontal;
- } else {
- renderConnection = vertical;
- }
-
- if(renderConnection) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(STORAGE_PANE_CTM_TEXTURE);
- int rgb = StorageOverlay.getRGBFromPane(type-1);
- int a = (rgb >> 24) & 0xFF;
- int r = (rgb >> 16) & 0xFF;
- int g = (rgb >> 8) & 0xFF;
- int b = rgb & 0xFF;
- GlStateManager.color(r/255f, g/255f, b/255f, a/255f);
-
- GlStateManager.pushMatrix();
- GlStateManager.translate(itemX-1+9, itemY-1+9, 10);
- GlStateManager.rotate(j*90, 0, 0, 1);
- GlStateManager.enableAlpha();
- GlStateManager.disableLighting();
-
- boolean horzFlip = false;
- boolean vertFlip = false;
-
- if(index == leftIndex) {
- vertFlip = true;
- } else if(index == downIndex) {
- vertFlip = true;
- }
-
- Utils.drawTexturedRect(0, -9, 8, 18,
- !horzFlip ? 209/227f : 219/227f, horzFlip ? 227/227f : 217/227f,
- !vertFlip ? 57/75f : 75f/75f, vertFlip ? 57/75f : 75f/75f, GL11.GL_NEAREST);
- Utils.drawTexturedRect(8, -9, 10, 18,
- !horzFlip ? 217/227f : 209/227f, horzFlip ? 219/227f : 227/227f,
- !vertFlip ? 57/75f : 75f/75f, vertFlip ? 57/75f : 75f/75f, GL11.GL_NEAREST);
-
- GlStateManager.popMatrix();
- }
- }
- }
- }
-
- GlStateManager.translate(0, 0, 20);
- Utils.drawItemStack(stack, itemX, itemY);
- GlStateManager.translate(0, 0, -20);
- }
- }
-
- String pageTitle;
- if(page.customTitle != null && !page.customTitle.isEmpty()) {
- pageTitle = page.customTitle;
- } else {
- pageTitle = getNamedHeldItemOverride().getDisplayName();
- }
-
- Utils.drawItemStack(held, centerX-8, startY-8);
-
- GlStateManager.translate(0, 0, 100);
- Utils.drawStringCentered(pageTitle, fontRendererObj, centerX, height - 76, true, 0xffff0000);
- int keyCode = NotEnoughUpdates.INSTANCE.config.storageGUI.backpackScrollKey;
- if(KeybindHelper.isKeyValid(keyCode) && !KeybindHelper.isKeyDown(keyCode)) {
- String keyName = KeybindHelper.getKeyName(keyCode);
- Utils.drawStringCentered("["+keyName+"] Scroll Backpacks", fontRendererObj, centerX, startY-10, true, 0xff32CD32);
- }
- GlStateManager.translate(0, 0, -200);
-
- } else if(page == null) {
- Utils.drawStringCentered("Run /storage to enable this feature!", fontRendererObj, centerX, height - 80, true, 0xffff0000);
- } else {
- Utils.drawStringCentered("Right-click to load items", fontRendererObj, centerX, height - 80, true, 0xffff0000);
- }
- }
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(ICONS);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(left + 1, top,
- 22, 22, 0, 22/64f, 0, 22/64f, GL11.GL_NEAREST);
- if(isSlotSelected()) {
- Utils.drawTexturedRect(left, top - 1,
- 24, 22, 0, 24/64f, 22/64f, 44/64f, GL11.GL_NEAREST);
- }
-
- int index = 1;
- if(StorageManager.getInstance().storageConfig.displayToStorageIdMap.containsKey(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex)) {
- int displayIndex = StorageManager.getInstance().storageConfig.displayToStorageIdMap.get(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex);
- if(displayIndex < 9) {
- index = displayIndex+1;
- } else {
- index = displayIndex-8;
- }
- }
-
- Utils.drawItemStackWithText(held, left + 4, top + 3, ""+index);
-
- GlStateManager.enableBlend();
- }
-
+ private static final InventoryStorageSelector INSTANCE = new InventoryStorageSelector();
+
+ private static final ResourceLocation ICONS = new ResourceLocation("notenoughupdates:storage_gui/hotbar_icons.png");
+ private static final ResourceLocation STORAGE_PANE_CTM_TEXTURE = new ResourceLocation(
+ "notenoughupdates:storage_gui/storage_gui_pane_ctm.png");
+
+ public boolean isOverridingSlot = false;
+
+ public static InventoryStorageSelector getInstance() {
+ return INSTANCE;
+ }
+
+ public boolean isSlotSelected() {
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() ||
+ !NotEnoughUpdates.INSTANCE.config.storageGUI.showInvBackpack) {
+ isOverridingSlot = false;
+ return false;
+ }
+ if (Minecraft.getMinecraft().currentScreen != null) {
+ return false;
+ }
+ if (Minecraft.getMinecraft().thePlayer == null) {
+ isOverridingSlot = false;
+ return false;
+ }
+ if (Minecraft.getMinecraft().thePlayer.inventory.currentItem != 0) {
+ isOverridingSlot = false;
+ return false;
+ }
+ return isOverridingSlot;
+ }
+
+ @SubscribeEvent
+ public void onMousePress(MouseEvent event) {
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() ||
+ !NotEnoughUpdates.INSTANCE.config.storageGUI.showInvBackpack) {
+ return;
+ }
+ if (Minecraft.getMinecraft().currentScreen != null) {
+ return;
+ }
+
+ if (KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.storageGUI.arrowLeftKey)) {
+ NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex--;
+
+ int max = StorageManager.getInstance().storageConfig.displayToStorageIdMap.size() - 1;
+ if (NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex > max)
+ NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex = max;
+ if (NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex < 0)
+ NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex = 0;
+ } else if (KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.storageGUI.arrowRightKey)) {
+ NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex++;
+
+ int max = StorageManager.getInstance().storageConfig.displayToStorageIdMap.size() - 1;
+ if (NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex > max)
+ NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex = max;
+ if (NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex < 0)
+ NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex = 0;
+ } else if (KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.storageGUI.arrowDownKey)) {
+ sendToPage(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex);
+ }
+
+ if (isSlotSelected()) {
+ int useKeycode = Minecraft.getMinecraft().gameSettings.keyBindUseItem.getKeyCode() + 100;
+ int attackKeycode = Minecraft.getMinecraft().gameSettings.keyBindAttack.getKeyCode() + 100;
+
+ if (Mouse.getEventButton() == useKeycode || Mouse.getEventButton() == attackKeycode) {
+ if (Mouse.getEventButtonState() &&
+ Mouse.getEventButton() != NotEnoughUpdates.INSTANCE.config.storageGUI.backpackScrollKey + 100) {
+ sendToPage(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex);
+ }
+
+ event.setCanceled(true);
+ }
+ }
+ }
+
+ private void sendToPage(int displayId) {
+ if (!StorageManager.getInstance().storageConfig.displayToStorageIdMap.containsKey(displayId)) {
+ return;
+ }
+ if (getPage(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex) == null) {
+ NotEnoughUpdates.INSTANCE.sendChatMessage("/storage");
+ } else {
+ int index =
+ StorageManager.getInstance().storageConfig.displayToStorageIdMap.get(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex);
+ StorageManager.getInstance().sendToPage(index);
+ }
+ }
+
+ @SubscribeEvent
+ public void onKeyPress(InputEvent.KeyInputEvent event) {
+ if (Minecraft.getMinecraft().gameSettings.keyBindsHotbar[0].isKeyDown()) {
+ isOverridingSlot = false;
+ }
+ if (Minecraft.getMinecraft().currentScreen != null) {
+ return;
+ }
+
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() ||
+ !NotEnoughUpdates.INSTANCE.config.storageGUI.showInvBackpack) {
+ return;
+ }
+
+ if (KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.storageGUI.backpackHotkey)) {
+ Minecraft.getMinecraft().thePlayer.inventory.currentItem = 0;
+ isOverridingSlot = true;
+ } else if (KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.storageGUI.arrowLeftKey)) {
+ NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex--;
+
+ int max = StorageManager.getInstance().storageConfig.displayToStorageIdMap.size() - 1;
+ if (NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex > max)
+ NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex = max;
+ if (NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex < 0)
+ NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex = 0;
+ } else if (KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.storageGUI.arrowRightKey)) {
+ NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex++;
+
+ int max = StorageManager.getInstance().storageConfig.displayToStorageIdMap.size() - 1;
+ if (NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex > max)
+ NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex = max;
+ if (NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex < 0)
+ NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex = 0;
+ } else if (KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.storageGUI.arrowDownKey)) {
+ sendToPage(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex);
+ }
+
+ if (isSlotSelected()) {
+ KeyBinding attack = Minecraft.getMinecraft().gameSettings.keyBindAttack;
+ KeyBinding use = Minecraft.getMinecraft().gameSettings.keyBindUseItem;
+
+ if (attack.isPressed() || attack.isKeyDown()) {
+ if (attack.getKeyCode() != NotEnoughUpdates.INSTANCE.config.storageGUI.backpackScrollKey) {
+ sendToPage(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex);
+ }
+
+ KeyBinding.setKeyBindState(attack.getKeyCode(), false);
+ while (attack.isPressed()) {
+ }
+ }
+
+ if (use.isPressed() || use.isKeyDown()) {
+ if (attack.getKeyCode() != NotEnoughUpdates.INSTANCE.config.storageGUI.backpackScrollKey) {
+ sendToPage(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex);
+ }
+
+ KeyBinding.setKeyBindState(use.getKeyCode(), false);
+ while (use.isPressed()) {
+ }
+ }
+ }
+ }
+
+ public int onScroll(int direction, int resultantSlot) {
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() ||
+ !NotEnoughUpdates.INSTANCE.config.storageGUI.showInvBackpack) {
+ return resultantSlot;
+ }
+ if (Minecraft.getMinecraft().currentScreen != null) {
+ return resultantSlot;
+ }
+
+ int keyCode = NotEnoughUpdates.INSTANCE.config.storageGUI.backpackScrollKey;
+ if (isOverridingSlot && KeybindHelper.isKeyDown(keyCode)) {
+ NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex -= direction;
+ int max = StorageManager.getInstance().storageConfig.displayToStorageIdMap.size() - 1;
+
+ if (NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex > max)
+ NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex = max;
+ if (NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex < 0)
+ NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex = 0;
+ return 0;
+ }
+
+ boolean allowScroll = NotEnoughUpdates.INSTANCE.config.storageGUI.scrollToBackpack2 == 0 ?
+ KeybindHelper.isKeyDown(NotEnoughUpdates.INSTANCE.config.storageGUI.backpackScrollKey) :
+ NotEnoughUpdates.INSTANCE.config.storageGUI.scrollToBackpack2 == 1;
+
+ if (allowScroll && resultantSlot == 0 && direction == -1 && !isOverridingSlot) {
+ isOverridingSlot = true;
+ Minecraft.getMinecraft().getItemRenderer().resetEquippedProgress();
+ return 0;
+ } else if (resultantSlot == 1 && direction == -1 && isOverridingSlot) {
+ isOverridingSlot = false;
+ Minecraft.getMinecraft().getItemRenderer().resetEquippedProgress();
+ return 0;
+ } else if (allowScroll && resultantSlot == 8 && direction == 1 && !isOverridingSlot) {
+ isOverridingSlot = true;
+ Minecraft.getMinecraft().getItemRenderer().resetEquippedProgress();
+ return 0;
+ }
+ return resultantSlot;
+ }
+
+ private StorageManager.StoragePage getPage(int selectedIndex) {
+ if (!StorageManager.getInstance().storageConfig.displayToStorageIdMap.containsKey(selectedIndex)) {
+ return null;
+ }
+ int index = StorageManager.getInstance().storageConfig.displayToStorageIdMap.get(selectedIndex);
+ return StorageManager.getInstance().getPage(index, false);
+ }
+
+ public ItemStack getNamedHeldItemOverride() {
+ StorageManager.StoragePage page = getPage(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex);
+ if (page != null && page.backpackDisplayStack != null) {
+ return page.backpackDisplayStack;
+ }
+ return new ItemStack(Item.getItemFromBlock(Blocks.chest));
+ }
+
+ public ItemStack getHeldItemOverride() {
+ return getHeldItemOverride(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex);
+ }
+
+ public ItemStack getHeldItemOverride(int selectedIndex) {
+ StorageManager.StoragePage page = getPage(selectedIndex);
+ if (page != null) {
+ ItemStack stack = page.backpackDisplayStack;
+ if (stack == null || stack.getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane)) {
+ return new ItemStack(Item.getItemFromBlock(Blocks.ender_chest));
+ }
+ return stack;
+ }
+ return new ItemStack(Item.getItemFromBlock(Blocks.chest));
+ }
+
+ public void render(ScaledResolution scaledResolution, float partialTicks) {
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() ||
+ !NotEnoughUpdates.INSTANCE.config.storageGUI.showInvBackpack) {
+ return;
+ }
+ if (Minecraft.getMinecraft().currentScreen != null) {
+ return;
+ }
+
+ int max = StorageManager.getInstance().storageConfig.displayToStorageIdMap.size() - 1;
+ if (NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex > max)
+ NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex = max;
+ if (NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex < 0)
+ NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex = 0;
+
+ int width = scaledResolution.getScaledWidth();
+ int height = scaledResolution.getScaledHeight();
+ FontRenderer fontRendererObj = Minecraft.getMinecraft().fontRendererObj;
+ int centerX = width / 2;
+
+ int offset = 91 + 10 + 12;
+
+ if (NotEnoughUpdates.INSTANCE.config.storageGUI.backpackHotbarSide == 1) {
+ offset *= -1;
+ }
+
+ ItemStack held = getHeldItemOverride();
+ int left = centerX - offset - 12;
+ int top = scaledResolution.getScaledHeight() - 22;
+
+ if (NotEnoughUpdates.INSTANCE.config.storageGUI.showInvBackpackPreview && isSlotSelected()) {
+ StorageManager.StoragePage page = getPage(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex);
+
+ if (page != null && page.rows > 0) {
+ int rows = page.rows;
+
+ ResourceLocation storagePreviewTexture =
+ StorageOverlay.STORAGE_PREVIEW_TEXTURES[NotEnoughUpdates.INSTANCE.config.storageGUI.displayStyle];
+
+ int startX = centerX - 172 / 2;
+ int startY = height - 80 - (10 + 18 * rows);
+
+ GlStateManager.translate(0, 0, 100);
+ GL11.glDepthMask(false);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(storagePreviewTexture);
+ GlStateManager.color(1, 1, 1,
+ NotEnoughUpdates.INSTANCE.config.storageGUI.backpackOpacity / 100f
+ );
+ Utils.drawTexturedRect(startX, startY, 176, 7, 0, 1, 0, 7 / 32f, GL11.GL_NEAREST);
+ for (int i = 0; i < rows; i++) {
+ Utils.drawTexturedRect(startX, startY + 7 + 18 * i, 176, 18, 0, 1, 7 / 32f, 25 / 32f, GL11.GL_NEAREST);
+ }
+ Utils.drawTexturedRect(startX, startY + 7 + 18 * rows, 176, 7, 0, 1, 25 / 32f, 1, GL11.GL_NEAREST);
+
+ GL11.glDepthMask(true);
+
+ int[] isPaneCache = new int[rows * 9];
+ int[] ctmIndexCache = new int[rows * 9];
+
+ for (int i = 0; i < rows * 9; i++) {
+ ItemStack stack = page.items[i];
+ if (stack != null) {
+ int itemX = startX + 8 + 18 * (i % 9);
+ int itemY = startY + 8 + 18 * (i / 9);
+
+ int paneType = StorageOverlay.getPaneType(stack, i, isPaneCache);
+ if (paneType > 0) {
+ GlStateManager.disableAlpha();
+ Gui.drawRect(itemX - 1, itemY - 1, itemX + 17, itemY + 17, 0x01000000);
+ GlStateManager.enableAlpha();
+
+ int ctmIndex = StorageOverlay.getCTMIndex(page, i, isPaneCache, ctmIndexCache);
+ int startCTMX = (ctmIndex % 12) * 19;
+ int startCTMY = (ctmIndex / 12) * 19;
+
+ ctmIndexCache[i] = ctmIndex;
+
+ if (paneType != 17) {
+ int rgb = StorageOverlay.getRGBFromPane(paneType - 1);
+ {
+ int a = (rgb >> 24) & 0xFF;
+ int r = (rgb >> 16) & 0xFF;
+ int g = (rgb >> 8) & 0xFF;
+ int b = rgb & 0xFF;
+ Minecraft.getMinecraft().getTextureManager().bindTexture(STORAGE_PANE_CTM_TEXTURE);
+ GlStateManager.color(r / 255f, g / 255f, b / 255f, a / 255f);
+ Utils.drawTexturedRect(itemX - 1, itemY - 1, 18, 18,
+ startCTMX / 227f, (startCTMX + 18) / 227f, startCTMY / 75f, (startCTMY + 18) / 75f, GL11.GL_NEAREST
+ );
+ }
+
+ RenderItem itemRender = Minecraft.getMinecraft().getRenderItem();
+ itemRender.renderItemOverlayIntoGUI(
+ Minecraft.getMinecraft().fontRendererObj,
+ stack,
+ itemX,
+ itemY,
+ null
+ );
+ GlStateManager.disableLighting();
+ }
+
+ page.shouldDarkenIfNotSelected[i] = false;
+ continue;
+ } else {
+ int upIndex = i - 9;
+ int leftIndex = i % 9 > 0 ? i - 1 : -1;
+ int rightIndex = i % 9 < 8 ? i + 1 : -1;
+ int downIndex = i + 9;
+
+ int[] indexArr = {rightIndex, downIndex, leftIndex, upIndex};
+
+ for (int j = 0; j < 4; j++) {
+ int index = indexArr[j];
+ int type = index >= 0 && index < isPaneCache.length ? StorageOverlay.getPaneType(
+ page.items[index],
+ index,
+ isPaneCache
+ ) : -1;
+ if (type > 0) {
+ int ctmIndex = StorageOverlay.getCTMIndex(page, index, isPaneCache, ctmIndexCache);
+ if (ctmIndex < 0) continue;
+
+ boolean renderConnection;
+ boolean horizontal = ctmIndex == 1 || ctmIndex == 2 || ctmIndex == 3;
+ boolean vertical = ctmIndex == 12 || ctmIndex == 24 || ctmIndex == 36;
+ if ((i % 9 == 0 && index % 9 == 0) || (i % 9 == 8 && index % 9 == 8)) {
+ renderConnection = horizontal || vertical;
+ } else if (index == leftIndex || index == rightIndex) {
+ renderConnection = horizontal;
+ } else {
+ renderConnection = vertical;
+ }
+
+ if (renderConnection) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(STORAGE_PANE_CTM_TEXTURE);
+ int rgb = StorageOverlay.getRGBFromPane(type - 1);
+ int a = (rgb >> 24) & 0xFF;
+ int r = (rgb >> 16) & 0xFF;
+ int g = (rgb >> 8) & 0xFF;
+ int b = rgb & 0xFF;
+ GlStateManager.color(r / 255f, g / 255f, b / 255f, a / 255f);
+
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(itemX - 1 + 9, itemY - 1 + 9, 10);
+ GlStateManager.rotate(j * 90, 0, 0, 1);
+ GlStateManager.enableAlpha();
+ GlStateManager.disableLighting();
+
+ boolean horzFlip = false;
+ boolean vertFlip = false;
+
+ if (index == leftIndex) {
+ vertFlip = true;
+ } else if (index == downIndex) {
+ vertFlip = true;
+ }
+
+ Utils.drawTexturedRect(0, -9, 8, 18,
+ !horzFlip ? 209 / 227f : 219 / 227f, horzFlip ? 227 / 227f : 217 / 227f,
+ !vertFlip ? 57 / 75f : 75f / 75f, vertFlip ? 57 / 75f : 75f / 75f, GL11.GL_NEAREST
+ );
+ Utils.drawTexturedRect(8, -9, 10, 18,
+ !horzFlip ? 217 / 227f : 209 / 227f, horzFlip ? 219 / 227f : 227 / 227f,
+ !vertFlip ? 57 / 75f : 75f / 75f, vertFlip ? 57 / 75f : 75f / 75f, GL11.GL_NEAREST
+ );
+
+ GlStateManager.popMatrix();
+ }
+ }
+ }
+ }
+
+ GlStateManager.translate(0, 0, 20);
+ Utils.drawItemStack(stack, itemX, itemY);
+ GlStateManager.translate(0, 0, -20);
+ }
+ }
+
+ String pageTitle;
+ if (page.customTitle != null && !page.customTitle.isEmpty()) {
+ pageTitle = page.customTitle;
+ } else {
+ pageTitle = getNamedHeldItemOverride().getDisplayName();
+ }
+
+ Utils.drawItemStack(held, centerX - 8, startY - 8);
+
+ GlStateManager.translate(0, 0, 100);
+ Utils.drawStringCentered(pageTitle, fontRendererObj, centerX, height - 76, true, 0xffff0000);
+ int keyCode = NotEnoughUpdates.INSTANCE.config.storageGUI.backpackScrollKey;
+ if (KeybindHelper.isKeyValid(keyCode) && !KeybindHelper.isKeyDown(keyCode)) {
+ String keyName = KeybindHelper.getKeyName(keyCode);
+ Utils.drawStringCentered(
+ "[" + keyName + "] Scroll Backpacks",
+ fontRendererObj,
+ centerX,
+ startY - 10,
+ true,
+ 0xff32CD32
+ );
+ }
+ GlStateManager.translate(0, 0, -200);
+
+ } else if (page == null) {
+ Utils.drawStringCentered(
+ "Run /storage to enable this feature!",
+ fontRendererObj,
+ centerX,
+ height - 80,
+ true,
+ 0xffff0000
+ );
+ } else {
+ Utils.drawStringCentered("Right-click to load items", fontRendererObj, centerX, height - 80, true, 0xffff0000);
+ }
+ }
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(ICONS);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(left + 1, top,
+ 22, 22, 0, 22 / 64f, 0, 22 / 64f, GL11.GL_NEAREST
+ );
+ if (isSlotSelected()) {
+ Utils.drawTexturedRect(left, top - 1,
+ 24, 22, 0, 24 / 64f, 22 / 64f, 44 / 64f, GL11.GL_NEAREST
+ );
+ }
+
+ int index = 1;
+ if (StorageManager.getInstance().storageConfig.displayToStorageIdMap.containsKey(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex)) {
+ int displayIndex =
+ StorageManager.getInstance().storageConfig.displayToStorageIdMap.get(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex);
+ if (displayIndex < 9) {
+ index = displayIndex + 1;
+ } else {
+ index = displayIndex - 8;
+ }
+ }
+
+ Utils.drawItemStackWithText(held, left + 4, top + 3, "" + index);
+
+ GlStateManager.enableBlend();
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/KatSitterOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/KatSitterOverlay.java
new file mode 100644
index 00000000..107d4db2
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/KatSitterOverlay.java
@@ -0,0 +1,88 @@
+package io.github.moulberry.notenoughupdates.miscgui;
+
+import com.google.gson.JsonObject;
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.util.Utils;
+import io.github.moulberry.notenoughupdates.util.XPInformation;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.gui.inventory.GuiChest;
+import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.init.Blocks;
+import net.minecraft.inventory.ContainerChest;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraftforge.client.event.GuiScreenEvent;
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+
+public class KatSitterOverlay {
+ public KatSitterOverlay() {
+ MinecraftForge.EVENT_BUS.register(this);
+ }
+
+ @SubscribeEvent
+ public void onGuiDrawn(GuiScreenEvent.DrawScreenEvent.Post event) {
+ if (!(event.gui instanceof GuiChest)) return;
+ if (!NotEnoughUpdates.INSTANCE.config.petOverlay.showKatSitting) return;
+ GuiChest gui = (GuiChest) event.gui;
+ ContainerChest container = (ContainerChest) gui.inventorySlots;
+ if (!"Pet Sitter".equals(container.getLowerChestInventory().getDisplayName().getUnformattedText())) return;
+ Slot slot = container.getSlot(13);
+ if (slot == null || !slot.getHasStack() || slot.getStack() == null) return;
+ ItemStack item = slot.getStack();
+ NBTTagCompound tagCompound = item.getTagCompound();
+ if (tagCompound == null || !tagCompound.hasKey("ExtraAttributes", 10)) return;
+ NBTTagCompound extra = tagCompound.getCompoundTag("ExtraAttributes");
+ if (extra == null || !extra.hasKey("id", 8) ||
+ !"PET".equals(extra.getString("id")) || !extra.hasKey("petInfo", 8))
+ return;
+ JsonObject petInfo = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(extra.getString("petInfo"), JsonObject.class);
+ if (petInfo == null || !petInfo.has("exp") || !petInfo.has("tier") || !petInfo.has("type")) return;
+ String petId = petInfo.get("type").getAsString();
+ double xp = petInfo.get("exp").getAsDouble();
+ String rarity = petInfo.get("tier").getAsString();
+ Slot katSlot = container.getSlot(22);
+ String upgradedRarity = nextRarity(rarity);
+ boolean nextRarityPresent = katSlot.getStack() != null && katSlot.getStack().getItem() != Item.getItemFromBlock(
+ Blocks.barrier) && upgradedRarity != null;
+ renderPetInformation(
+ (int) XPInformation.getInstance().getPetLevel(petId, xp, rarity),
+ nextRarityPresent ? (int) XPInformation.getInstance().getPetLevel(petId, xp, upgradedRarity) : null,
+ gui
+ );
+ }
+
+ public void renderPetInformation(int currentLevel, Integer upgradedLevel, GuiChest gui) {
+ FontRenderer font = Minecraft.getMinecraft().fontRendererObj;
+ String currentText = "Current pet level: " + currentLevel;
+ int currentWidth = font.getStringWidth(currentText);
+ String upgradedText = "Upgraded pet level: " + upgradedLevel;
+ int upgradedWidth = font.getStringWidth(upgradedText);
+ int left = gui.guiLeft - 30 - (upgradedLevel == null ? Math.max(upgradedWidth, currentWidth) : currentWidth);
+ GlStateManager.disableLighting();
+ GlStateManager.color(1F, 1F, 1F, 1F);
+ Utils.drawStringScaled(currentText, font, left, gui.guiTop + 25, false, 0xFFD700, 1F);
+ if (upgradedLevel != null)
+ Utils.drawStringScaled(upgradedText, font, left, gui.guiTop + 45, false, 0xFFD700, 1F);
+ }
+
+ public String nextRarity(String currentRarity) {
+ switch (currentRarity.intern()) {
+ case "COMMON":
+ return "UNCOMMON";
+ case "UNCOMMON":
+ return "RARE";
+ case "RARE":
+ return "EPIC";
+ case "EPIC":
+ return "LEGENDARY";
+ case "LEGENDARY":
+ return "MYTHIC";
+ }
+ return null;
+ }
+
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/NEUOverlayPlacements.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/NEUOverlayPlacements.java
index 995ed5e3..f95302ef 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/NEUOverlayPlacements.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/NEUOverlayPlacements.java
@@ -1,7 +1,10 @@
package io.github.moulberry.notenoughupdates.miscgui;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
-import io.github.moulberry.notenoughupdates.mbgui.*;
+import io.github.moulberry.notenoughupdates.mbgui.MBAnchorPoint;
+import io.github.moulberry.notenoughupdates.mbgui.MBDeserializer;
+import io.github.moulberry.notenoughupdates.mbgui.MBGuiElement;
+import io.github.moulberry.notenoughupdates.mbgui.MBGuiGroupFloating;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
@@ -15,205 +18,228 @@ import java.awt.*;
import java.io.IOException;
public class NEUOverlayPlacements extends GuiScreen {
-
- private int clickedX;
- private int clickedY;
- private int clickedAnchorX;
- private int clickedAnchorY;
- private MBGuiElement clickedElement;
- private GuiButton guiButton = new GuiButton(0, 5, 5, "Reset to Default");
-
- private boolean dropdownMenuShown = false;
-
- @Override
- public void drawScreen(int mouseX, int mouseY, float partialTicks) {
- super.drawScreen(mouseX, mouseY, partialTicks);
- drawDefaultBackground();
-
- /*GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
- Minecraft.getMinecraft().getTextureManager().bindTexture(icons);
- GlStateManager.enableBlend();
-
- GlStateManager.tryBlendFuncSeparate(775, 769, 1, 0);
- GlStateManager.enableAlpha();
- this.drawTexturedModalRect(width / 2 - 7, height / 2 - 7, 0, 0, 16, 16);*/
-
- if(mouseX < 300 && mouseY < 300 && clickedElement != null) {
- guiButton.yPosition = height - 5 - guiButton.height;
- } else {
- guiButton.yPosition = 5;
- }
-
- EnumChatFormatting GOLD = EnumChatFormatting.GOLD;
-
- guiButton.drawButton(Minecraft.getMinecraft(), mouseX, mouseY);
-
- NotEnoughUpdates.INSTANCE.overlay.updateGuiGroupSize();
-
- drawRect((width-176)/2, (height-166)/2,
- (width+176)/2, (height+166)/2, new Color(100, 100, 100, 200).getRGB());
- Utils.drawStringCentered(GOLD+"Inventory", Minecraft.getMinecraft().fontRendererObj, width/2f, height/2f, false, 0);
-
- MBGuiGroupFloating mainGroup = NotEnoughUpdates.INSTANCE.overlay.guiGroup;
- mainGroup.render(0, 0);
- GlStateManager.translate(0, 0, 500);
- for(MBGuiElement element : mainGroup.getChildren()) {
- MBAnchorPoint anchorPoint = mainGroup.getChildrenMap().get(element);
- Vector2f position = mainGroup.getChildrenPosition().get(element);
-
- drawRect((int)position.x, (int)position.y,
- (int)position.x+element.getWidth(), (int)position.y+element.getHeight(), new Color(100, 100, 100, 200).getRGB());
-
- switch(anchorPoint.anchorPoint) {
- case TOPLEFT:
- case TOPRIGHT:
- case BOTLEFT:
- case BOTRIGHT:
- drawRect((int)(position.x+element.getWidth()*anchorPoint.anchorPoint.x*0.9f),
- (int)(position.y+element.getHeight()*anchorPoint.anchorPoint.y*0.9f),
- (int)(position.x+element.getWidth()*anchorPoint.anchorPoint.x*0.9f+element.getWidth()*0.1f),
- (int)(position.y+element.getHeight()*anchorPoint.anchorPoint.y*0.9f+element.getHeight()*0.1f),
- new Color(200, 200, 200, 100).getRGB());
- break;
- case TOPMID:
- drawRect((int)position.x, (int)position.y,
- (int)position.x+element.getWidth(), (int)(position.y+element.getHeight()*0.1f),
- new Color(200, 200, 200, 100).getRGB());
- break;
- case MIDLEFT:
- drawRect((int)position.x, (int)position.y,
- (int)(position.x+element.getWidth()*0.1f), (int)position.y+element.getHeight(),
- new Color(200, 200, 200, 100).getRGB());
- break;
- case MIDRIGHT:
- drawRect((int)(position.x+element.getWidth()*0.9f), (int)position.y,
- (int)position.x+element.getWidth(), (int)position.y+element.getHeight(),
- new Color(200, 200, 200, 100).getRGB());
- break;
- case BOTMID:
- drawRect((int)position.x, (int)(position.y+element.getHeight()*0.9f),
- (int)position.x+element.getWidth(), (int)position.y+element.getHeight(),
- new Color(200, 200, 200, 100).getRGB());
- break;
- case MIDMID:
- drawRect((int)(position.x+element.getWidth()*0.45f), (int)(position.y+element.getHeight()*0.45f),
- (int)(position.x+element.getWidth()*0.55f), (int)(position.y+element.getHeight()*0.55f),
- new Color(200, 200, 200, 100).getRGB());
- break;
-
- }
-
- if(anchorPoint.inventoryRelative) {
- Utils.drawStringCentered(GOLD+"Inv-Relative", Minecraft.getMinecraft().fontRendererObj,
- position.x+element.getWidth()*0.5f, position.y+element.getHeight()*0.5f, false, 0);
- }
- }
- GlStateManager.translate(0, 0, -500);
- }
-
- @Override
- protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
- super.mouseClicked(mouseX, mouseY, mouseButton);
-
- if(mouseButton != 0 && mouseButton != 1) return;
-
- MBGuiGroupFloating mainGroup = NotEnoughUpdates.INSTANCE.overlay.guiGroup;
- int index=0;
- for(MBGuiElement element : mainGroup.getChildren()) {
- MBAnchorPoint anchorPoint = mainGroup.getChildrenMap().get(element);
- Vector2f position = mainGroup.getChildrenPosition().get(element);
-
- if(mouseX > position.x && mouseX < position.x + element.getWidth()) {
- if(mouseY > position.y && mouseY < position.y + element.getHeight()) {
- if(mouseButton == 0) {
- clickedElement = element;
- clickedX = mouseX;
- clickedY = mouseY;
- clickedAnchorX = (int)anchorPoint.offset.x;
- clickedAnchorY = (int)anchorPoint.offset.y;
- } else {
- if(Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) {
- anchorPoint.inventoryRelative = !anchorPoint.inventoryRelative;
- } else {
- MBAnchorPoint.AnchorPoint[] vals = MBAnchorPoint.AnchorPoint.values();
- anchorPoint.anchorPoint = vals[(anchorPoint.anchorPoint.ordinal()+1)%vals.length];
-
- mainGroup.recalculate();
-
- anchorPoint.offset.x += position.x - mainGroup.getChildrenPosition().get(element).x;
- anchorPoint.offset.y += position.y - mainGroup.getChildrenPosition().get(element).y;
-
- mainGroup.recalculate();
-
- if(index == 0) {
- NotEnoughUpdates.INSTANCE.config.hidden.overlaySearchBar = anchorPoint.toString();
- } else if(index == 1) {
- NotEnoughUpdates.INSTANCE.config.hidden.overlayQuickCommand = anchorPoint.toString();
- }
- }
- }
- return;
- }
- }
- index++;
- }
-
- if(guiButton.mousePressed(Minecraft.getMinecraft(), mouseX, mouseY)) {
- NotEnoughUpdates.INSTANCE.config.hidden.overlayQuickCommand = "";
- NotEnoughUpdates.INSTANCE.config.hidden.overlaySearchBar = "";
- NotEnoughUpdates.INSTANCE.overlay.resetAnchors(false);
-
- mainGroup.recalculate();
- }
- clickedElement = null;
- }
-
- @Override
- protected void mouseReleased(int mouseX, int mouseY, int state) {
- clickedElement = null;
- }
-
- @Override
- protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
- super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
- if(clickedElement != null) {
- MBGuiGroupFloating mainGroup = NotEnoughUpdates.INSTANCE.overlay.guiGroup;
- MBAnchorPoint anchorPoint = mainGroup.getChildrenMap().get(clickedElement);
-
- if(Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) {
- int dX = mouseX - clickedX;
- int dY = mouseY - clickedY;
- if(Math.abs(dX) > Math.abs(dY)) {
- anchorPoint.offset.x = mouseX - clickedX + clickedAnchorX;
- anchorPoint.offset.y = clickedAnchorY;
- } else {
- anchorPoint.offset.x = clickedAnchorX;
- anchorPoint.offset.y = mouseY - clickedY + clickedAnchorY;
- }
- } else {
- anchorPoint.offset.x = mouseX - clickedX + clickedAnchorX;
- anchorPoint.offset.y = mouseY - clickedY + clickedAnchorY;
- }
-
- int index = 0;
- for(MBGuiElement element : mainGroup.getChildren()) {
- if(element == clickedElement) {
- if(index == 0) {
- NotEnoughUpdates.INSTANCE.config.hidden.overlaySearchBar = anchorPoint.toString();
- } else if(index == 1) {
- NotEnoughUpdates.INSTANCE.config.hidden.overlayQuickCommand = anchorPoint.toString();
- }
- break;
- }
- index++;
- }
- try { MBDeserializer.serializeAndSave(mainGroup, "overlay"); } catch(Exception e) {}
- mainGroup.recalculate();
- }
- }
-
- @Override
- public boolean doesGuiPauseGame() {
- return false;
- }
+ private int clickedX;
+ private int clickedY;
+ private int clickedAnchorX;
+ private int clickedAnchorY;
+ private MBGuiElement clickedElement;
+ private final GuiButton guiButton = new GuiButton(0, 5, 5, "Reset to Default");
+
+ private final boolean dropdownMenuShown = false;
+
+ @Override
+ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
+ super.drawScreen(mouseX, mouseY, partialTicks);
+ drawDefaultBackground();
+
+ /*GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(icons);
+ GlStateManager.enableBlend();
+
+ GlStateManager.tryBlendFuncSeparate(775, 769, 1, 0);
+ GlStateManager.enableAlpha();
+ this.drawTexturedModalRect(width / 2 - 7, height / 2 - 7, 0, 0, 16, 16);*/
+
+ if (mouseX < 300 && mouseY < 300 && clickedElement != null) {
+ guiButton.yPosition = height - 5 - guiButton.height;
+ } else {
+ guiButton.yPosition = 5;
+ }
+
+ EnumChatFormatting GOLD = EnumChatFormatting.GOLD;
+
+ guiButton.drawButton(Minecraft.getMinecraft(), mouseX, mouseY);
+
+ NotEnoughUpdates.INSTANCE.overlay.updateGuiGroupSize();
+
+ drawRect((width - 176) / 2, (height - 166) / 2,
+ (width + 176) / 2, (height + 166) / 2, new Color(100, 100, 100, 200).getRGB()
+ );
+ Utils.drawStringCentered(
+ GOLD + "Inventory",
+ Minecraft.getMinecraft().fontRendererObj,
+ width / 2f,
+ height / 2f,
+ false,
+ 0
+ );
+
+ MBGuiGroupFloating mainGroup = NotEnoughUpdates.INSTANCE.overlay.guiGroup;
+ mainGroup.render(0, 0);
+ GlStateManager.translate(0, 0, 500);
+ for (MBGuiElement element : mainGroup.getChildren()) {
+ MBAnchorPoint anchorPoint = mainGroup.getChildrenMap().get(element);
+ Vector2f position = mainGroup.getChildrenPosition().get(element);
+
+ drawRect(
+ (int) position.x,
+ (int) position.y,
+ (int) position.x + element.getWidth(),
+ (int) position.y + element.getHeight(),
+ new Color(100, 100, 100, 200).getRGB()
+ );
+
+ switch (anchorPoint.anchorPoint) {
+ case TOPLEFT:
+ case TOPRIGHT:
+ case BOTLEFT:
+ case BOTRIGHT:
+ drawRect(
+ (int) (position.x + element.getWidth() * anchorPoint.anchorPoint.x * 0.9f),
+ (int) (position.y + element.getHeight() * anchorPoint.anchorPoint.y * 0.9f),
+ (int) (position.x + element.getWidth() * anchorPoint.anchorPoint.x * 0.9f + element.getWidth() * 0.1f),
+ (int) (position.y + element.getHeight() * anchorPoint.anchorPoint.y * 0.9f + element.getHeight() * 0.1f),
+ new Color(200, 200, 200, 100).getRGB()
+ );
+ break;
+ case TOPMID:
+ drawRect((int) position.x, (int) position.y,
+ (int) position.x + element.getWidth(), (int) (position.y + element.getHeight() * 0.1f),
+ new Color(200, 200, 200, 100).getRGB()
+ );
+ break;
+ case MIDLEFT:
+ drawRect((int) position.x, (int) position.y,
+ (int) (position.x + element.getWidth() * 0.1f), (int) position.y + element.getHeight(),
+ new Color(200, 200, 200, 100).getRGB()
+ );
+ break;
+ case MIDRIGHT:
+ drawRect((int) (position.x + element.getWidth() * 0.9f), (int) position.y,
+ (int) position.x + element.getWidth(), (int) position.y + element.getHeight(),
+ new Color(200, 200, 200, 100).getRGB()
+ );
+ break;
+ case BOTMID:
+ drawRect((int) position.x, (int) (position.y + element.getHeight() * 0.9f),
+ (int) position.x + element.getWidth(), (int) position.y + element.getHeight(),
+ new Color(200, 200, 200, 100).getRGB()
+ );
+ break;
+ case MIDMID:
+ drawRect((int) (position.x + element.getWidth() * 0.45f), (int) (position.y + element.getHeight() * 0.45f),
+ (int) (position.x + element.getWidth() * 0.55f), (int) (position.y + element.getHeight() * 0.55f),
+ new Color(200, 200, 200, 100).getRGB()
+ );
+ break;
+
+ }
+
+ if (anchorPoint.inventoryRelative) {
+ Utils.drawStringCentered(GOLD + "Inv-Relative", Minecraft.getMinecraft().fontRendererObj,
+ position.x + element.getWidth() * 0.5f, position.y + element.getHeight() * 0.5f, false, 0
+ );
+ }
+ }
+ GlStateManager.translate(0, 0, -500);
+ }
+
+ @Override
+ protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
+ super.mouseClicked(mouseX, mouseY, mouseButton);
+
+ if (mouseButton != 0 && mouseButton != 1) return;
+
+ MBGuiGroupFloating mainGroup = NotEnoughUpdates.INSTANCE.overlay.guiGroup;
+ int index = 0;
+ for (MBGuiElement element : mainGroup.getChildren()) {
+ MBAnchorPoint anchorPoint = mainGroup.getChildrenMap().get(element);
+ Vector2f position = mainGroup.getChildrenPosition().get(element);
+
+ if (mouseX > position.x && mouseX < position.x + element.getWidth()) {
+ if (mouseY > position.y && mouseY < position.y + element.getHeight()) {
+ if (mouseButton == 0) {
+ clickedElement = element;
+ clickedX = mouseX;
+ clickedY = mouseY;
+ clickedAnchorX = (int) anchorPoint.offset.x;
+ clickedAnchorY = (int) anchorPoint.offset.y;
+ } else {
+ if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) {
+ anchorPoint.inventoryRelative = !anchorPoint.inventoryRelative;
+ } else {
+ MBAnchorPoint.AnchorPoint[] vals = MBAnchorPoint.AnchorPoint.values();
+ anchorPoint.anchorPoint = vals[(anchorPoint.anchorPoint.ordinal() + 1) % vals.length];
+
+ mainGroup.recalculate();
+
+ anchorPoint.offset.x += position.x - mainGroup.getChildrenPosition().get(element).x;
+ anchorPoint.offset.y += position.y - mainGroup.getChildrenPosition().get(element).y;
+
+ mainGroup.recalculate();
+
+ if (index == 0) {
+ NotEnoughUpdates.INSTANCE.config.hidden.overlaySearchBar = anchorPoint.toString();
+ } else if (index == 1) {
+ NotEnoughUpdates.INSTANCE.config.hidden.overlayQuickCommand = anchorPoint.toString();
+ }
+ }
+ }
+ return;
+ }
+ }
+ index++;
+ }
+
+ if (guiButton.mousePressed(Minecraft.getMinecraft(), mouseX, mouseY)) {
+ NotEnoughUpdates.INSTANCE.config.hidden.overlayQuickCommand = "";
+ NotEnoughUpdates.INSTANCE.config.hidden.overlaySearchBar = "";
+ NotEnoughUpdates.INSTANCE.overlay.resetAnchors(false);
+
+ mainGroup.recalculate();
+ }
+ clickedElement = null;
+ }
+
+ @Override
+ protected void mouseReleased(int mouseX, int mouseY, int state) {
+ clickedElement = null;
+ }
+
+ @Override
+ protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
+ super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
+ if (clickedElement != null) {
+ MBGuiGroupFloating mainGroup = NotEnoughUpdates.INSTANCE.overlay.guiGroup;
+ MBAnchorPoint anchorPoint = mainGroup.getChildrenMap().get(clickedElement);
+
+ if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) {
+ int dX = mouseX - clickedX;
+ int dY = mouseY - clickedY;
+ if (Math.abs(dX) > Math.abs(dY)) {
+ anchorPoint.offset.x = mouseX - clickedX + clickedAnchorX;
+ anchorPoint.offset.y = clickedAnchorY;
+ } else {
+ anchorPoint.offset.x = clickedAnchorX;
+ anchorPoint.offset.y = mouseY - clickedY + clickedAnchorY;
+ }
+ } else {
+ anchorPoint.offset.x = mouseX - clickedX + clickedAnchorX;
+ anchorPoint.offset.y = mouseY - clickedY + clickedAnchorY;
+ }
+
+ int index = 0;
+ for (MBGuiElement element : mainGroup.getChildren()) {
+ if (element == clickedElement) {
+ if (index == 0) {
+ NotEnoughUpdates.INSTANCE.config.hidden.overlaySearchBar = anchorPoint.toString();
+ } else if (index == 1) {
+ NotEnoughUpdates.INSTANCE.config.hidden.overlayQuickCommand = anchorPoint.toString();
+ }
+ break;
+ }
+ index++;
+ }
+ try {
+ MBDeserializer.serializeAndSave(mainGroup, "overlay");
+ } catch (Exception ignored) {
+ }
+ mainGroup.recalculate();
+ }
+ }
+
+ @Override
+ public boolean doesGuiPauseGame() {
+ return false;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java
index 664d684b..bce5bfbd 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java
@@ -29,7 +29,7 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
-
+import net.minecraftforge.client.ClientCommandHandler;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
@@ -38,1950 +38,2287 @@ import org.lwjgl.util.vector.Vector2f;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.awt.*;
-
-import java.util.*;
import java.util.List;
+import java.util.*;
public class StorageOverlay extends GuiElement {
+ private static final int CHEST_TOP_OFFSET = 17;
+ private static final int CHEST_SLOT_SIZE = 18;
+ private static final int CHEST_BOTTOM_OFFSET = 215;
- private static final int CHEST_TOP_OFFSET = 17;
- private static final int CHEST_SLOT_SIZE = 18;
- private static final int CHEST_BOTTOM_OFFSET = 215;
+ private Framebuffer framebuffer = null;
- private Framebuffer framebuffer = null;
+ private final Set<Vector2f> enchantGlintRenderLocations = new HashSet<>();
- private Set<Vector2f> enchantGlintRenderLocations = new HashSet<>();
+ public static final ResourceLocation[] STORAGE_PREVIEW_TEXTURES = new ResourceLocation[4];
+ private static final ResourceLocation[] STORAGE_TEXTURES = new ResourceLocation[4];
+ private static final ResourceLocation STORAGE_ICONS_TEXTURE = new ResourceLocation(
+ "notenoughupdates:storage_gui/storage_icons.png");
+ private static final ResourceLocation STORAGE_PANE_CTM_TEXTURE = new ResourceLocation(
+ "notenoughupdates:storage_gui/storage_gui_pane_ctm.png");
+ private static final ResourceLocation[] LOAD_CIRCLE_SEQ = new ResourceLocation[11];
+ private static final ResourceLocation[] NOT_RICKROLL_SEQ = new ResourceLocation[19];
- public static final ResourceLocation STORAGE_PREVIEW_TEXTURES[] = new ResourceLocation[4];
- private static final ResourceLocation STORAGE_TEXTURES[] = new ResourceLocation[4];
- private static final ResourceLocation STORAGE_ICONS_TEXTURE = new ResourceLocation("notenoughupdates:storage_gui/storage_icons.png");
- private static final ResourceLocation STORAGE_PANE_CTM_TEXTURE = new ResourceLocation("notenoughupdates:storage_gui/storage_gui_pane_ctm.png");
- private static final ResourceLocation[] LOAD_CIRCLE_SEQ = new ResourceLocation[11];
- private static final ResourceLocation[] NOT_RICKROLL_SEQ = new ResourceLocation[19];
- static {
- for(int i=0; i<STORAGE_TEXTURES.length; i++) {
- STORAGE_TEXTURES[i] = new ResourceLocation("notenoughupdates:storage_gui/storage_gui_"+i+".png");
- }
- for(int i=0; i<STORAGE_PREVIEW_TEXTURES.length; i++) {
- STORAGE_PREVIEW_TEXTURES[i] = new ResourceLocation("notenoughupdates:storage_gui/storage_preview_"+i+".png");
- }
+ static {
+ for (int i = 0; i < STORAGE_TEXTURES.length; i++) {
+ STORAGE_TEXTURES[i] = new ResourceLocation("notenoughupdates:storage_gui/storage_gui_" + i + ".png");
+ }
+ for (int i = 0; i < STORAGE_PREVIEW_TEXTURES.length; i++) {
+ STORAGE_PREVIEW_TEXTURES[i] = new ResourceLocation("notenoughupdates:storage_gui/storage_preview_" + i + ".png");
+ }
- for(int i=0; i<NOT_RICKROLL_SEQ.length; i++) {
- NOT_RICKROLL_SEQ[i] = new ResourceLocation("notenoughupdates:storage_gui/we_do_a_little_rolling/"+i+".jpg");
- }
+ for (int i = 0; i < NOT_RICKROLL_SEQ.length; i++) {
+ NOT_RICKROLL_SEQ[i] = new ResourceLocation("notenoughupdates:storage_gui/we_do_a_little_rolling/" + i + ".jpg");
+ }
- LOAD_CIRCLE_SEQ[0] = new ResourceLocation("notenoughupdates:loading_circle_seq/1.png");
- LOAD_CIRCLE_SEQ[1] = new ResourceLocation("notenoughupdates:loading_circle_seq/1.png");
- LOAD_CIRCLE_SEQ[2] = new ResourceLocation("notenoughupdates:loading_circle_seq/2.png");
- for(int i=2; i<=7; i++) {
- LOAD_CIRCLE_SEQ[i+1] = new ResourceLocation("notenoughupdates:loading_circle_seq/"+i+".png");
- }
- LOAD_CIRCLE_SEQ[9] = new ResourceLocation("notenoughupdates:loading_circle_seq/7.png");
- LOAD_CIRCLE_SEQ[10] = new ResourceLocation("notenoughupdates:loading_circle_seq/1.png");
- }
+ LOAD_CIRCLE_SEQ[0] = new ResourceLocation("notenoughupdates:loading_circle_seq/1.png");
+ LOAD_CIRCLE_SEQ[1] = new ResourceLocation("notenoughupdates:loading_circle_seq/1.png");
+ LOAD_CIRCLE_SEQ[2] = new ResourceLocation("notenoughupdates:loading_circle_seq/2.png");
+ for (int i = 2; i <= 7; i++) {
+ LOAD_CIRCLE_SEQ[i + 1] = new ResourceLocation("notenoughupdates:loading_circle_seq/" + i + ".png");
+ }
+ LOAD_CIRCLE_SEQ[9] = new ResourceLocation("notenoughupdates:loading_circle_seq/7.png");
+ LOAD_CIRCLE_SEQ[10] = new ResourceLocation("notenoughupdates:loading_circle_seq/1.png");
+ }
- private static final StorageOverlay INSTANCE = new StorageOverlay();
- public static StorageOverlay getInstance() {
- return INSTANCE;
- }
+ private static final StorageOverlay INSTANCE = new StorageOverlay();
- private GuiElementTextField searchBar = new GuiElementTextField("", 88, 10,
- GuiElementTextField.SCALE_TEXT | GuiElementTextField.DISABLE_BG);
- private GuiElementTextField renameStorageField = new GuiElementTextField("", 100, 13,
- GuiElementTextField.COLOUR);
+ public static StorageOverlay getInstance() {
+ return INSTANCE;
+ }
- private int editingNameId = -1;
-
- private int guiLeft;
- private int guiTop;
-
- private boolean fastRender = false;
-
- private int loadCircleIndex = 0;
- private int rollIndex = 0;
- private int loadCircleRotation = 0;
-
- private long millisAccumIndex = 0;
- private long millisAccumRoll = 0;
- private long millisAccumRotation = 0;
-
- private long lastMillis = 0;
-
- private int scrollVelocity = 0;
- private long lastScroll = 0;
-
- private int[][] isPaneCaches = new int[40][];
- private int[][] ctmIndexCaches = new int[40][];
-
- private int desiredHeightSwitch = -1;
- private int desiredHeightMX = -1;
- private int desiredHeightMY = -1;
-
- private boolean dirty = false;
- private boolean allowTypingInSearchBar = true;
-
- private int scrollGrabOffset = -1;
-
- private LerpingInteger scroll = new LerpingInteger(0, 200);
-
- private int getMaximumScroll() {
- synchronized(StorageManager.getInstance().storageConfig.displayToStorageIdMapRender) {
-
- int maxH = 0;
-
- for(int i=0; i<3; i++) {
- int lastDisplayId = StorageManager.getInstance().storageConfig.displayToStorageIdMapRender.size()-1;
- int coords = (int)Math.ceil(lastDisplayId/3f)*3+1+i;
-
- int h = getPageCoords(coords).y+scroll.getValue()-getStorageViewSize()-14;
-
- if(h > maxH) maxH = h;
- }
-
- return maxH;
- }
- }
-
- public void markDirty() {
- dirty = true;
- }
-
- private void scrollToY(int y) {
- int target = y;
- if(target < 0) target = 0;
-
- int maxY = getMaximumScroll();
- if(target > maxY) target = maxY;
-
- float factor = (scroll.getValue()-target)/(float)(scroll.getValue()-y+1E-5);
-
- scroll.setTarget(target);
- scroll.setTimeToReachTarget(Math.min(200, Math.max(20, (int)(200*factor))));
- scroll.resetTimer();
- }
-
- public void scrollToStorage(int displayId, boolean forceScroll) {
- if(displayId < 0) return;
-
- int y = getPageCoords(displayId).y-17;
- if(y < 3) {
- scrollToY(y + scroll.getValue());
- } else {
- int storageViewSize = getStorageViewSize();
- int y2 = getPageCoords(displayId+3).y-17-storageViewSize;
- if(y2 > 3) {
- if(forceScroll) {
- scrollToY(y + scroll.getValue());
- } else {
- scrollToY(y2+scroll.getValue());
- }
- }
- }
- }
-
- private int getStorageViewSize() {
- return NotEnoughUpdates.INSTANCE.config.storageGUI.storageHeight;
- }
-
- private int getScrollBarHeight() {
- return getStorageViewSize() - 21;
- }
-
- @Override
- public void render() {
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) return;
- GuiChest guiChest = (GuiChest) Minecraft.getMinecraft().currentScreen;
- ContainerChest containerChest = (ContainerChest) guiChest.inventorySlots;
-
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- int width = scaledResolution.getScaledWidth();
- int height = scaledResolution.getScaledHeight();
- int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
- int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
- FontRenderer fontRendererObj = Minecraft.getMinecraft().fontRendererObj;
-
- scroll.tick();
-
- int displayStyle = NotEnoughUpdates.INSTANCE.config.storageGUI.displayStyle;
- ResourceLocation storageTexture = STORAGE_TEXTURES[displayStyle];
- ResourceLocation storagePreviewTexture = STORAGE_PREVIEW_TEXTURES[displayStyle];
- int textColour = 0x404040;
- int searchTextColour = 0xe0e0e0;
- if(displayStyle == 2) {
- textColour = 0x000000;
- searchTextColour = 0xa0a0a0;
- } else if(displayStyle == 3) {
- textColour = 0xFBCC6C;
- } else if(displayStyle == 0) {
- textColour = 0x909090;
- searchTextColour = 0xa0a0a0;
- }
-
- long currentTime = System.currentTimeMillis();
- if(lastMillis > 0) {
- long deltaTime = currentTime - lastMillis;
- millisAccumIndex += deltaTime;
- loadCircleIndex += millisAccumIndex / (1000/15);
- millisAccumIndex %= (1000/15);
-
- millisAccumRotation += deltaTime;
- loadCircleRotation += millisAccumRotation / (1000/107);
- millisAccumRotation %= (1000/107);
-
- millisAccumRoll += deltaTime;
- rollIndex += millisAccumRoll/100;
- millisAccumRoll %= 100;
- }
-
- lastMillis = currentTime;
- loadCircleIndex %= LOAD_CIRCLE_SEQ.length;
- rollIndex %= NOT_RICKROLL_SEQ.length*2;
- loadCircleRotation %= 360;
-
- Color loadCircleColour = Color.getHSBColor(loadCircleRotation/360f, 0.3f, 0.9f);
- ItemStack stackOnMouse = Minecraft.getMinecraft().thePlayer.inventory.getItemStack();
- if(stackOnMouse != null) {
- String stackDisplay = Utils.cleanColour(stackOnMouse.getDisplayName());
- if(stackDisplay.startsWith("Backpack Slot ") || stackDisplay.startsWith("Empty Backpack Slot ") ||
- stackDisplay.startsWith("Ender Chest Page ")) {
- stackOnMouse = null;
- }
- }
-
- List<String> tooltipToDisplay = null;
- int slotPreview = -1;
-
- int storageViewSize = getStorageViewSize();
-
- int sizeX = 540;
- int sizeY = 100+storageViewSize;
- int searchNobX = 18;
-
- int itemHoverX = -1;
- int itemHoverY = -1;
-
- guiLeft = width/2 - (sizeX-searchNobX)/2;
- guiTop = height/2 - sizeY/2;
-
- if(displayStyle == 0) {
- BackgroundBlur.renderBlurredBackground(7, width, height, guiLeft, guiTop, sizeX, storageViewSize);
- BackgroundBlur.renderBlurredBackground(7, width, height, guiLeft+5, guiTop+storageViewSize, sizeX-searchNobX-10, sizeY-storageViewSize-4);
- }
-
- Utils.drawGradientRect(0, 0, width, height, 0xc0101010, 0xd0101010);
-
- GL11.glPushMatrix();
- GlStateManager.translate(guiLeft, guiTop, 0);
-
- boolean hoveringOtherBackpack = false;
-
- //Gui
- Minecraft.getMinecraft().getTextureManager().bindTexture(storageTexture);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(0, 0, sizeX, 10, 0, sizeX/600f, 0, 10/400f, GL11.GL_NEAREST);
- Utils.drawTexturedRect(0, 10, sizeX, storageViewSize-20, 0, sizeX/600f, 10/400f, 94/400f, GL11.GL_NEAREST);
- Utils.drawTexturedRect(0, storageViewSize-10, sizeX, 110, 0, sizeX/600f, 94/400f, 204/400f, GL11.GL_NEAREST);
-
- int maxScroll = getMaximumScroll();
- if(scroll.getValue() > maxScroll) {
- scroll.setValue(maxScroll);
- }
- if(scroll.getValue() < 0) {
- scroll.setValue(0);
- }
-
- //Scroll bar
- int scrollBarY = Math.round(getScrollBarHeight()*scroll.getValue()/(float)maxScroll);
- float uMin = scrollGrabOffset >= 0 ? 12/600f : 0;
- Utils.drawTexturedRect(520, 8+scrollBarY, 12, 15, uMin, uMin+12/600f, 250/400f, 265/400f, GL11.GL_NEAREST);
-
- int currentPage = StorageManager.getInstance().getCurrentPageId();
-
- boolean mouseInsideStorages = mouseY > guiTop+3 && mouseY < guiTop+3+storageViewSize;
-
- //Storages
- boolean doItemRender = true;
- boolean doRenderFramebuffer = false;
- int startY = getPageCoords(0).y;
- if(OpenGlHelper.isFramebufferEnabled()) {
- int h;
- synchronized(StorageManager.getInstance().storageConfig.displayToStorageIdMapRender) {
- int lastDisplayId = StorageManager.getInstance().storageConfig.displayToStorageIdMapRender.size()-1;
- int coords = (int)Math.ceil(lastDisplayId/3f)*3+3;
-
- h = getPageCoords(coords).y+scroll.getValue();
- }
- int w = sizeX;
-
- //Render from framebuffer
- if(framebuffer != null) {
- GlScissorStack.push(0, guiTop+3, width, guiTop+3+storageViewSize, scaledResolution);
- GlStateManager.enableDepth();
- GlStateManager.translate(0, startY, 107.0001f);
- framebuffer.bindFramebufferTexture();
-
- GlStateManager.color(1, 1, 1, 1);
-
- GlStateManager.enableAlpha();
- GlStateManager.alphaFunc(GL11.GL_GREATER, 0F);
- Utils.drawTexturedRect(0, 0, w, h, 0, 1, 1, 0, GL11.GL_NEAREST);
- GlStateManager.alphaFunc(GL11.GL_GREATER, 0.1F);
-
- renderEnchOverlay(enchantGlintRenderLocations);
-
- GlStateManager.translate(0, -startY, -107.0001f);
- GlScissorStack.pop(scaledResolution);
- }
-
- if(dirty || framebuffer == null) {
- dirty = false;
-
- int fw = w*scaledResolution.getScaleFactor();
- int fh = h*scaledResolution.getScaleFactor();
-
- if(framebuffer == null) {
- framebuffer = new Framebuffer(fw, fh, true);
- } else if(framebuffer.framebufferWidth != fw || framebuffer.framebufferHeight != fh) {
- framebuffer.createBindFramebuffer(fw, fh);
- }
- framebuffer.framebufferClear();
- framebuffer.bindFramebuffer(true);
-
- GlStateManager.matrixMode(GL11.GL_PROJECTION);
- GlStateManager.loadIdentity();
- GlStateManager.ortho(0.0D, w, h, 0.0D, 1000.0D, 3000.0D);
- GlStateManager.matrixMode(GL11.GL_MODELVIEW);
-
- GlStateManager.pushMatrix();
- GlStateManager.translate(-guiLeft, -guiTop-startY, 0);
-
- doRenderFramebuffer = true;
- } else {
- doItemRender = false;
- }
- }
-
- if(doItemRender) {
- enchantGlintRenderLocations.clear();
- for(Map.Entry<Integer, Integer> entry : StorageManager.getInstance().storageConfig.displayToStorageIdMapRender.entrySet()) {
- int displayId = entry.getKey();
- int storageId = entry.getValue();
-
- IntPair coords = getPageCoords(displayId);
- int storageX = coords.x;
- int storageY = coords.y;
-
- if(!doRenderFramebuffer) {
- if(coords.y-11 > 3+storageViewSize || coords.y+90 < 3) continue;
- }
-
- StorageManager.StoragePage page = StorageManager.getInstance().getPage(storageId, false);
- if(page != null && page.rows > 0) {
- int rows = page.rows;
-
- isPaneCaches[storageId] = new int[page.rows*9];
- ctmIndexCaches[storageId] = new int[page.rows*9];
- int[] isPaneCache = isPaneCaches[storageId];
- int[] ctmIndexCache = ctmIndexCaches[storageId];
-
- for(int k=0; k<rows*9; k++) {
- ItemStack stack;
-
- if(storageId == currentPage) {
- stack = containerChest.getSlot(k+9).getStack();
- } else {
- stack = page.items[k];
- }
-
- int itemX = storageX+1+18*(k%9);
- int itemY = storageY+1+18*(k/9);
-
- //Render fancy glass
- if(stack != null) {
- int paneType = getPaneType(stack, k, isPaneCache);
- if(paneType > 0) {
- GlStateManager.disableAlpha();
- Gui.drawRect(itemX-1, itemY-1, itemX+17, itemY+17, 0x01000000);
- GlStateManager.enableAlpha();
-
- int ctmIndex = getCTMIndex(page, k, isPaneCache, ctmIndexCache);
- int startCTMX = (ctmIndex%12)*19;
- int startCTMY = (ctmIndex/12)*19;
-
- ctmIndexCache[k] = ctmIndex;
-
- if(paneType != 17) {
- int rgb = getRGBFromPane(paneType-1);
- {
- int a = (rgb >> 24) & 0xFF;
- int r = (rgb >> 16) & 0xFF;
- int g = (rgb >> 8) & 0xFF;
- int b = rgb & 0xFF;
- Minecraft.getMinecraft().getTextureManager().bindTexture(STORAGE_PANE_CTM_TEXTURE);
- GlStateManager.color(r/255f, g/255f, b/255f, a/255f);
- Utils.drawTexturedRect(itemX-1, itemY-1, 18, 18,
- startCTMX/227f, (startCTMX+18)/227f, startCTMY/75f, (startCTMY+18)/75f, GL11.GL_NEAREST);
- }
-
- /*int[] colours = new int[9];
-
- for(int xi=-1; xi<=1; xi++) {
- for(int yi=-1; yi<=1; yi++) {
- List<Integer> indexes = new ArrayList<>();
- List<Integer> coloursList = new ArrayList<>();
- coloursList.add(rgb);
-
- if(xi != 0) {
- indexes.add(k+xi);
- }
- if(yi != 0) {
- indexes.add(k+yi*9);
- }
- if(xi != 0 && yi != 0) {
- indexes.add(k+yi*9+xi);
- }
- for(int index : indexes) {
- if(index >= 0 && index < rows*9) {
- int paneTypeI = getPaneType(page.items[index], index, isPaneCache);
- if(shouldConnect(paneType, paneTypeI)) {
- coloursList.add(getRGBFromPane(paneTypeI-1));
- }
- }
- }
- Vector4f cv = new Vector4f();
- for(int colour : coloursList) {
- float a = (colour >> 24) & 0xFF;
- float r = (colour >> 16) & 0xFF;
- float g = (colour >> 8) & 0xFF;
- float b = colour & 0xFF;
- cv.x += a/coloursList.size();
- cv.y += r/coloursList.size();
- cv.z += g/coloursList.size();
- cv.w += b/coloursList.size();
- }
- int finalCol = (((int)cv.x) << 24) | (((int)cv.y) << 16) | (((int)cv.z) << 8) | ((int)cv.w);
- colours[(xi+1)+(yi+1)*3] = finalCol;
- }
- }
- int[] colours4 = new int[16];
-
- for(int x=0; x<4; x++) {
- for(int y=0; y<4; y++) {
- int ya = y < 2 ? y : y-1;
- int xa = x < 2 ? x : x-1;
- colours4[x+y*4] = colours[xa+ya*3];
- }
- }
-
- GlStateManager.pushMatrix();
- GlStateManager.translate(itemX-1, itemY-1, 0);
- Tessellator tessellator = Tessellator.getInstance();
- WorldRenderer worldrenderer = tessellator.getWorldRenderer();
- worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
- float uMinCTM = startCTMX/227f;
- float uMaxCTM = (startCTMX+18)/227f;
- float vMinCTM = startCTMY/75f;
- float vMaxCTM = (startCTMY+18)/75f;
- for(int xi=-1; xi<=1; xi++) {
- for(int yi = -1; yi <= 1; yi++) {
- float x = xi == -1 ? 0 : xi == 0 ? 1 : 17;
- float y = yi == -1 ? 0 : yi == 0 ? 1 : 17;
- float w = xi == 0 ? 16 : 1;
- float h = yi == 0 ? 16 : 1;
-
- int col1 = colours4[(xi+1)+(yi+1)*4];
- int col2 = colours4[(xi+2)+(yi+1)*4];
- int col3 = colours4[(xi+1)+(yi+2)*4];
- int col4 = colours4[(xi+2)+(yi+2)*4];
-
- worldrenderer
- .pos(x, y+h, 0.0D)
- .tex(uMinCTM + (uMaxCTM - uMinCTM) * x/18f, vMinCTM+(vMaxCTM-vMinCTM)*(y+h)/18f)
- .color((col3 >> 16) & 0xFF, (col3 >> 8) & 0xFF, col3 & 0xFF, (col3 >> 24) & 0xFF).endVertex();
- worldrenderer
- .pos(x+w, y+h, 0.0D)
- .tex(uMinCTM+(uMaxCTM-uMinCTM)*(x+w)/18f, vMinCTM+(vMaxCTM-vMinCTM)*(y+h)/18f)
- .color((col4 >> 16) & 0xFF, (col4 >> 8) & 0xFF, col4 & 0xFF, (col4 >> 24) & 0xFF).endVertex();
- worldrenderer
- .pos(x+w, y, 0.0D)
- .tex(uMinCTM+(uMaxCTM-uMinCTM)*(x+w)/18f, vMinCTM+(vMaxCTM-vMinCTM)*y/18f)
- .color((col2 >> 16) & 0xFF, (col2 >> 8) & 0xFF, col2 & 0xFF, (col2 >> 24) & 0xFF).endVertex();
- worldrenderer
- .pos(x, y, 0.0D)
- .tex(uMinCTM + (uMaxCTM - uMinCTM) * x/18f, vMinCTM+(vMaxCTM-vMinCTM)*y/18f)
- .color((col1 >> 16) & 0xFF, (col1 >> 8) & 0xFF, col1 & 0xFF, (col1 >> 24) & 0xFF).endVertex();
- }
- }
- GlStateManager.disableDepth();
- GlStateManager.color(1, 1, 1, 1);
- GlStateManager.shadeModel(GL11.GL_SMOOTH);
- tessellator.draw();
- GlStateManager.shadeModel(GL11.GL_FLAT);
- GlStateManager.enableDepth();
- GlStateManager.popMatrix();*/
-
- RenderItem itemRender = Minecraft.getMinecraft().getRenderItem();
- itemRender.renderItemOverlayIntoGUI(Minecraft.getMinecraft().fontRendererObj, stack, itemX, itemY, null);
- GlStateManager.disableLighting();
- }
-
- page.shouldDarkenIfNotSelected[k] = false;
- continue;
- }
- }
- page.shouldDarkenIfNotSelected[k] = true;
-
- //Render item
- GlStateManager.translate(0, 0, 20);
- if(doRenderFramebuffer) {
- GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
- GL14.glBlendFuncSeparate(GL11.GL_ONE, GL11.GL_ZERO, GL11.GL_ONE, GL11.GL_ZERO);
-
- if(storageId == currentPage) {
- Utils.hasEffectOverride = true;
- GlStateManager.translate(storageX-7, storageY-17-18, 0);
- guiChest.drawSlot(containerChest.getSlot(k+9));
- GlStateManager.translate(-storageX+7, -storageY+17+18, 0);
- Utils.hasEffectOverride = false;
- } else {
- Utils.drawItemStackWithoutGlint(stack, itemX, itemY);
- }
-
- GL14.glBlendFuncSeparate(770, 771, 1, 0);
-
- if(stack != null && (stack.hasEffect() || stack.getItem() == Items.enchanted_book)) {
- enchantGlintRenderLocations.add(new Vector2f(itemX, itemY-startY));
- }
- } else if(storageId == currentPage) {
- Utils.hasEffectOverride = true;
- GlStateManager.translate(storageX-7, storageY-17-18, 0);
- guiChest.drawSlot(containerChest.getSlot(k+9));
- GlStateManager.translate(-storageX+7, -storageY+17+18, 0);
- Utils.hasEffectOverride = false;
- } else {
- Utils.drawItemStack(stack, itemX, itemY);
- }
- GlStateManager.disableLighting();
- GlStateManager.translate(0, 0, -20);
- }
-
- GlStateManager.disableLighting();
- GlStateManager.enableDepth();
- }
- }
- }
-
- if(OpenGlHelper.isFramebufferEnabled() && doRenderFramebuffer) {
- GlStateManager.popMatrix();
- Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true);
-
- GlStateManager.matrixMode(GL11.GL_PROJECTION);
- GlStateManager.loadIdentity();
- GlStateManager.ortho(0.0D, scaledResolution.getScaledWidth_double(), scaledResolution.getScaledHeight_double(),
- 0.0D, 1000.0D, 3000.0D);
- GlStateManager.matrixMode(GL11.GL_MODELVIEW);
- }
-
- GlScissorStack.push(0, guiTop+3, width, guiTop+3+storageViewSize, scaledResolution);
- for(Map.Entry<Integer, Integer> entry : StorageManager.getInstance().storageConfig.displayToStorageIdMapRender.entrySet()) {
- int displayId = entry.getKey();
- int storageId = entry.getValue();
-
- IntPair coords = getPageCoords(displayId);
- int storageX = coords.x;
- int storageY = coords.y;
-
- if(coords.y-11 > 3+storageViewSize || coords.y+90 < 3) continue;
-
- StorageManager.StoragePage page = StorageManager.getInstance().getPage(storageId, false);
-
- if(editingNameId == storageId) {
- int len = fontRendererObj.getStringWidth(renameStorageField.getTextDisplay())+10;
- renameStorageField.setSize(len, 12);
- renameStorageField.render(storageX, storageY-13);
- } else {
- String pageTitle;
- if(page != null && page.customTitle != null && !page.customTitle.isEmpty()) {
- pageTitle = Utils.chromaStringByColourCode(page.customTitle);
- } else if(entry.getValue() < 9) {
- pageTitle = "Ender Chest Page " + (entry.getValue() + 1);
- } else {
- pageTitle = "Backpack Slot "+(storageId-8);
- }
- int titleLen = fontRendererObj.getStringWidth(pageTitle);
-
- if(mouseX >= guiLeft+storageX && mouseX <= guiLeft+storageX+titleLen+15 &&
- mouseY >= guiTop+storageY-14 && mouseY <= guiTop+storageY+1) {
- pageTitle += " \u270E";
- }
- fontRendererObj.drawString(pageTitle, storageX, storageY-11, textColour);
- }
-
- if(page == null) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(storageTexture);
- GlStateManager.color(1, 1, 1, 1);
- int h = 18*3;
-
- Utils.drawTexturedRect(storageX, storageY, 162, h, 0, 162 / 600f, 265 / 400f, (265+h) / 400f, GL11.GL_NEAREST);
-
- Gui.drawRect(storageX, storageY, storageX + 162, storageY + h, 0x80000000);
-
- if(storageId < 9) {
- Utils.drawStringCenteredScaledMaxWidth("Locked Page", fontRendererObj,
- storageX+81, storageY+h/2, true, 150, 0xd94c00);
- } else {
- Utils.drawStringCenteredScaledMaxWidth("Empty Backpack Slot", fontRendererObj,
- storageX+81, storageY+h/2, true, 150, 0xd94c00);
- }
- } else if(page.rows <= 0) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(storageTexture);
- GlStateManager.color(1, 1, 1, 1);
- int h = 18*3;
-
- Utils.drawTexturedRect(storageX, storageY, 162, h, 0, 162 / 600f, 265 / 400f, (265 + h) / 400f, GL11.GL_NEAREST);
-
- Gui.drawRect(storageX, storageY, storageX + 162, storageY + h, 0x80000000);
-
- Utils.drawStringCenteredScaledMaxWidth("Click to load items", fontRendererObj,
- storageX+81, storageY+h/2, true, 150, 0xffdf00);
- } else {
- int rows = page.rows;
-
- int storageW = 162;
- int storageH = 18*rows;
-
- GlStateManager.enableDepth();
-
- boolean[] shouldLimitBorder = new boolean[rows*9];
- boolean hasCaches = isPaneCaches[storageId] != null && isPaneCaches[storageId].length == rows*9 &&
- ctmIndexCaches[storageId] != null && ctmIndexCaches[storageId].length == rows*9;
-
- //Render item connections
- for(int k=0; k<rows*9; k++) {
- ItemStack stack = page.items[k];
-
- if(stack != null && hasCaches) {
- int itemX = storageX+1+18*(k%9);
- int itemY = storageY+1+18*(k/9);
-
- int[] isPaneCache = isPaneCaches[storageId];
- int[] ctmIndexCache = ctmIndexCaches[storageId];
-
- if(isPaneCache[k] == 17) {
- int ctmIndex = getCTMIndex(page, k, isPaneCache, ctmIndexCache);
- int startCTMX = (ctmIndex%12)*19;
- int startCTMY = (ctmIndex/12)*19;
-
- int rgb = getRGBFromPane(isPaneCache[k]-1);
- int a = (rgb >> 24) & 0xFF;
- int r = (rgb >> 16) & 0xFF;
- int g = (rgb >> 8) & 0xFF;
- int b = rgb & 0xFF;
- Minecraft.getMinecraft().getTextureManager().bindTexture(STORAGE_PANE_CTM_TEXTURE);
- GlStateManager.color(r/255f, g/255f, b/255f, a/255f);
- GlStateManager.translate(0, 0, 110);
- Utils.drawTexturedRect(itemX-1, itemY-1, 18, 18,
- startCTMX/227f, (startCTMX+18)/227f, startCTMY/75f, (startCTMY+18)/75f, GL11.GL_NEAREST);
- GlStateManager.translate(0, 0, -110);
-
- RenderItem itemRender = Minecraft.getMinecraft().getRenderItem();
- itemRender.renderItemOverlayIntoGUI(Minecraft.getMinecraft().fontRendererObj, stack, itemX, itemY, null);
- GlStateManager.enableDepth();
- } else if(isPaneCache[k] < 0) {
- boolean hasConnection = false;
-
- int upIndex = k-9;
- int leftIndex = k%9 > 0 ? k-1 : -1;
- int rightIndex = k%9 < 8 ? k+1 : -1;
- int downIndex = k+9;
-
- int[] indexArr = {rightIndex, downIndex, leftIndex, upIndex};
-
- for(int j=0; j<4; j++) {
- int index = indexArr[j];
- int type = index >= 0 && index < isPaneCache.length ? getPaneType(page.items[index], index, isPaneCache) : -1;
- if(type > 0) {
- int ctmIndex = getCTMIndex(page, index, isPaneCache, ctmIndexCache);
- if(ctmIndex < 0) continue;
-
- boolean renderConnection;
- boolean horizontal = ctmIndex == 1 || ctmIndex == 2 || ctmIndex == 3;
- boolean vertical = ctmIndex == 12 || ctmIndex == 24 || ctmIndex == 36;
- if((k%9 == 0 && index%9 == 0) || (k%9 == 8 && index%9 == 8)) {
- renderConnection = horizontal || vertical;
- } else if(index == leftIndex || index == rightIndex) {
- renderConnection = horizontal;
- } else {
- renderConnection = vertical;
- }
-
- if(renderConnection) {
- shouldLimitBorder[k] = true;
- hasConnection = true;
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(STORAGE_PANE_CTM_TEXTURE);
- int rgb = getRGBFromPane(type-1);
- int a = (rgb >> 24) & 0xFF;
- int r = (rgb >> 16) & 0xFF;
- int g = (rgb >> 8) & 0xFF;
- int b = rgb & 0xFF;
- GlStateManager.color(r/255f, g/255f, b/255f, a/255f);
-
- GlStateManager.pushMatrix();
- GlStateManager.translate(itemX-1+9, itemY-1+9, 10);
- GlStateManager.rotate(j*90, 0, 0, 1);
- GlStateManager.enableAlpha();
- GlStateManager.disableLighting();
-
- boolean horzFlip = false;
- boolean vertFlip = false;
-
- if(index == leftIndex) {
- vertFlip = true;
- } else if(index == downIndex) {
- vertFlip = true;
- }
-
- GlStateManager.enableDepth();
- Utils.drawTexturedRect(0, -9, 8, 18,
- !horzFlip ? 209/227f : 219/227f, horzFlip ? 227/227f : 217/227f,
- !vertFlip ? 57/75f : 75f/75f, vertFlip ? 57/75f : 75f/75f, GL11.GL_NEAREST);
- GlStateManager.translate(0, 0, 120);
- Utils.drawTexturedRect(8, -9, 10, 18,
- !horzFlip ? 217/227f : 209/227f, horzFlip ? 219/227f : 227/227f,
- !vertFlip ? 57/75f : 75f/75f, vertFlip ? 57/75f : 75f/75f, GL11.GL_NEAREST);
- GlStateManager.translate(0, 0, -120);
-
- GlStateManager.popMatrix();
- }
- }
- }
-
- if(hasConnection) {
- page.shouldDarkenIfNotSelected[k] = false;
-
- GlStateManager.disableAlpha();
- GlStateManager.translate(0, 0, 10);
- Gui.drawRect(itemX-1, itemY-1, itemX+17, itemY+17, 0x01000000);
- GlStateManager.translate(0, 0, -10);
- GlStateManager.enableAlpha();
- }
- }
- }
- }
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(storageTexture);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(storageX, storageY, storageW, storageH, 0, 162/600f, 265/400f, (265+storageH)/400f, GL11.GL_NEAREST);
-
- boolean whiteOverlay = false;
-
- for(int k=0; k<rows*9; k++) {
- ItemStack stack = page.items[k];
- int itemX = storageX+1+18*(k%9);
- int itemY = storageY+1+18*(k/9);
-
- if(!searchBar.getText().isEmpty()) {
- if(stack == null || !NotEnoughUpdates.INSTANCE.manager.doesStackMatchSearch(stack, searchBar.getText())) {
- GlStateManager.disableDepth();
- Gui.drawRect(itemX, itemY, itemX+16, itemY+16, 0x80000000);
- GlStateManager.enableDepth();
- }
- }
-
- GlStateManager.disableLighting();
-
- if(mouseInsideStorages && mouseX >= guiLeft+itemX && mouseX < guiLeft+itemX+18 && mouseY >= guiTop+itemY && mouseY < guiTop+itemY+18) {
- boolean allowHover = NotEnoughUpdates.INSTANCE.config.storageGUI.fancyPanes != 1 || !hasCaches || isPaneCaches[storageId][k] <= 0;
-
- if(storageId != StorageManager.getInstance().getCurrentPageId()) {
- hoveringOtherBackpack = true;
- whiteOverlay = stackOnMouse == null;
- } else if(stack == null || allowHover) {
- itemHoverX = itemX;
- itemHoverY = itemY;
- }
-
- if(stack != null && allowHover) {
- tooltipToDisplay = stack.getTooltip(Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().gameSettings.advancedItemTooltips);
- }
- }
- }
-
- GlStateManager.disableDepth();
- if(storageId == currentPage) {
- if(isPaneCaches[storageId] != null && isPaneCaches[storageId].length == rows*9 &&
- ctmIndexCaches[storageId] != null && ctmIndexCaches[storageId].length == rows*9) {
- int[] isPaneCache = isPaneCaches[storageId];
-
- int borderStartY = 0;
- int borderEndY = storageH;
- int borderStartX = 0;
- int borderEndX = storageW;
-
- boolean allChroma = true;
- for(int y=0; y<page.rows; y++) {
- for(int x=0; x<9; x++) {
- int index = x+y*9;
- if(isPaneCache[index] != 17) {
- allChroma = false;
- break;
- }
- }
- }
-
- out:
- for(int y=0; y<page.rows; y++) {
- for(int x=0; x<9; x++) {
- int index = x+y*9;
- if(isPaneCache[index] <= 0 && !shouldLimitBorder[index]) {
- borderStartY = y*18;
- break out;
- }
- }
- }
- out:
- for(int y=page.rows-1; y>=0; y--) {
- for(int x=0; x<9; x++) {
- int index = x+y*9;
- if(isPaneCache[index] <= 0 && !shouldLimitBorder[index]) {
- borderEndY = y*18+18; //Bottom
- break out;
- }
- }
- }
- out:
- for(int x=0; x<9; x++) {
- for(int y=0; y<page.rows; y++) {
- int index = x+y*9;
- if(isPaneCache[index] <= 0 && !shouldLimitBorder[index]) {
- borderStartX = x*18;
- break out;
- }
- }
- }
- out:
- for(int x=8; x>=0; x--) {
- for(int y=0; y<page.rows; y++) {
- int index = x+y*9;
- if(isPaneCache[index] <= 0 && !shouldLimitBorder[index]) {
- borderEndX = x*18+18; //Bottom
- break out;
- }
- }
- }
- int borderColour = ChromaColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedStorageColour);
- Gui.drawRect(storageX+borderStartX+1, storageY+borderStartY, storageX+borderStartX, storageY+borderEndY, borderColour); //Left
- Gui.drawRect(storageX+borderEndX-1, storageY+borderStartY, storageX+borderEndX, storageY+borderEndY, borderColour); //Right
- Gui.drawRect(storageX+borderStartX, storageY+borderStartY, storageX+borderEndX, storageY+borderStartY+1, borderColour); //Top
- Gui.drawRect(storageX+borderStartX, storageY+borderEndY-1, storageX+borderEndX, storageY+borderEndY, borderColour); //Bottom
-
- if(allChroma) {
- ResourceLocation loc;
- if(rollIndex < NOT_RICKROLL_SEQ.length) {
- loc = NOT_RICKROLL_SEQ[rollIndex];
- } else {
- loc = NOT_RICKROLL_SEQ[NOT_RICKROLL_SEQ.length*2-rollIndex-1];
- }
- Minecraft.getMinecraft().getTextureManager().bindTexture(loc);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(storageX, storageY, storageW, storageH, GL11.GL_LINEAR);
- }
- } else {
- int borderColour = ChromaColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedStorageColour);
- Gui.drawRect(storageX+1, storageY, storageX, storageY+storageH, borderColour); //Left
- Gui.drawRect(storageX+storageW-1, storageY, storageX+storageW, storageY+storageH, borderColour); //Right
- Gui.drawRect(storageX, storageY-1, storageX+storageW, storageY, borderColour); //Top
- Gui.drawRect(storageX, storageY+storageH-1, storageX+storageW, storageY+storageH, borderColour); //Bottom
- }
- } else if(currentTime - StorageManager.getInstance().storageOpenSwitchMillis < 1000 &&
- StorageManager.getInstance().desiredStoragePage == storageId &&
- StorageManager.getInstance().getCurrentPageId() != storageId) {
- Gui.drawRect(storageX, storageY, storageX+storageW, storageY+storageH, 0x30000000);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(LOAD_CIRCLE_SEQ[loadCircleIndex]);
- GlStateManager.color(loadCircleColour.getRed()/255f, loadCircleColour.getGreen()/255f,
- loadCircleColour.getBlue()/255f, 1);
-
- GlStateManager.pushMatrix();
- GlStateManager.translate(storageX+storageW/2, storageY+storageH/2, 0);
- GlStateManager.rotate(loadCircleRotation, 0, 0, 1);
- Utils.drawTexturedRect(-10, -10, 20, 20, GL11.GL_LINEAR);
- GlStateManager.popMatrix();
- } else if(whiteOverlay) {
- Gui.drawRect(storageX, storageY, storageX+storageW, storageY+storageH, 0x80ffffff);
- } else {
- if(page.rows <= 0) {
- Gui.drawRect(storageX, storageY, storageX+storageW, storageY+storageH, 0x40000000);
- } else {
- for(int i=0; i<page.rows*9; i++) {
- if(page.items[i] == null || page.shouldDarkenIfNotSelected[i]) {
- int x = storageX+18*(i%9);
- int y = storageY+18*(i/9);
- Gui.drawRect(x, y, x+18, y+18, 0x40000000);
- }
- }
- }
- }
-
- if(StorageManager.getInstance().desiredStoragePage == storageId && StorageManager.getInstance().onStorageMenu) {
- Utils.drawStringCenteredScaledMaxWidth("Please click again to load...", fontRendererObj,
- storageX+81-1, storageY+storageH/2-5, false, 150, 0x111111);
- Utils.drawStringCenteredScaledMaxWidth("Please click again to load...", fontRendererObj,
- storageX+81+1, storageY+storageH/2-5, false, 150, 0x111111);
- Utils.drawStringCenteredScaledMaxWidth("Please click again to load...", fontRendererObj,
- storageX+81, storageY+storageH/2-5-1, false, 150, 0x111111);
- Utils.drawStringCenteredScaledMaxWidth("Please click again to load...", fontRendererObj,
- storageX+81, storageY+storageH/2-5+1, false, 150, 0x111111);
- Utils.drawStringCenteredScaledMaxWidth("Please click again to load...", fontRendererObj,
- storageX+81, storageY+storageH/2-5, false, 150, 0xffdf00);
-
- Utils.drawStringCenteredScaledMaxWidth("Use /neustwhy for more info", fontRendererObj,
- storageX+81-1, storageY+storageH/2+5, false, 150, 0x111111);
- Utils.drawStringCenteredScaledMaxWidth("Use /neustwhy for more info", fontRendererObj,
- storageX+81+1, storageY+storageH/2+5, false, 150, 0x111111);
- Utils.drawStringCenteredScaledMaxWidth("Use /neustwhy for more info", fontRendererObj,
- storageX+81, storageY+storageH/2+5-1, false, 150, 0x111111);
- Utils.drawStringCenteredScaledMaxWidth("Use /neustwhy for more info", fontRendererObj,
- storageX+81, storageY+storageH/2+5+1, false, 150, 0x111111);
- Utils.drawStringCenteredScaledMaxWidth("Use /neustwhy for more info", fontRendererObj,
- storageX+81, storageY+storageH/2+5, false, 150, 0xffdf00);
- }
-
- GlStateManager.enableDepth();
- }
- }
- GlScissorStack.pop(scaledResolution);
-
- if(fastRender){
- fontRendererObj.drawString("Fast render does not work with Storage overlay.", sizeX/2-fontRendererObj.getStringWidth("Fast render does not work with Storage overlay.")/2, -10, 0xFFFF0000);
- }
-
- //Inventory Text
- fontRendererObj.drawString("Inventory", 180, storageViewSize+6, textColour);
- searchBar.setCustomTextColour(searchTextColour);
- searchBar.render(252, storageViewSize+5);
-
- //Player Inventory
- ItemStack[] playerItems = Minecraft.getMinecraft().thePlayer.inventory.mainInventory;
- int inventoryStartIndex = containerChest.getLowerChestInventory().getSizeInventory();
- GlStateManager.enableDepth();
- for(int i=0; i<9; i++) {
- int itemX = 181+18*i;
- int itemY = storageViewSize+76;
-
- GlStateManager.pushMatrix();
- GlStateManager.translate(181-8, storageViewSize+18-(inventoryStartIndex/9*18+31), 0);
- guiChest.drawSlot(containerChest.inventorySlots.get(inventoryStartIndex+i));
- GlStateManager.popMatrix();
-
- if(!searchBar.getText().isEmpty()) {
- if(playerItems[i] == null || !NotEnoughUpdates.INSTANCE.manager.doesStackMatchSearch(playerItems[i], searchBar.getText())) {
- GlStateManager.disableDepth();
- Gui.drawRect(itemX, itemY, itemX+16, itemY+16, 0x80000000);
- GlStateManager.enableDepth();
- }
- }
-
- if(mouseX >= guiLeft+itemX && mouseX < guiLeft+itemX+18 && mouseY >= guiTop+itemY && mouseY < guiTop+itemY+18) {
- itemHoverX = itemX;
- itemHoverY = itemY;
-
- if(playerItems[i] != null) {
- tooltipToDisplay = playerItems[i].getTooltip(Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().gameSettings.advancedItemTooltips);
- }
- }
- }
- for(int i=0; i<27; i++) {
- int itemX = 181+18*(i%9);
- int itemY = storageViewSize+18+18*(i/9);
-
- //Utils.drawItemStack(playerItems[i+9], itemX, itemY);
- GlStateManager.pushMatrix();
- GlStateManager.translate(181-8, storageViewSize+18-(inventoryStartIndex/9*18+31), 0);
- guiChest.drawSlot(containerChest.inventorySlots.get(inventoryStartIndex+9+i));
- GlStateManager.popMatrix();
-
- if(!searchBar.getText().isEmpty()) {
- if(playerItems[i+9] == null || !NotEnoughUpdates.INSTANCE.manager.doesStackMatchSearch(playerItems[i+9], searchBar.getText())) {
- GlStateManager.disableDepth();
- Gui.drawRect(itemX, itemY, itemX+16, itemY+16, 0x80000000);
- GlStateManager.enableDepth();
- }
- }
-
- if(mouseX >= guiLeft+itemX && mouseX < guiLeft+itemX+18 && mouseY >= guiTop+itemY && mouseY < guiTop+itemY+18) {
- itemHoverX = itemX;
- itemHoverY = itemY;
-
- if(playerItems[i+9] != null) {
- tooltipToDisplay = playerItems[i+9].getTooltip(Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().gameSettings.advancedItemTooltips);
- }
- }
- }
-
- //Backpack Selector
- fontRendererObj.drawString("Ender Chest Pages", 9, storageViewSize+12, textColour);
- fontRendererObj.drawString("Storage Pages", 9, storageViewSize+44, textColour);
- if(StorageManager.getInstance().onStorageMenu) {
- for(int i=0; i<9; i++) {
- int itemX = 10+i*18;
- int itemY = storageViewSize+24;
- ItemStack stack = containerChest.getLowerChestInventory().getStackInSlot(i+9);
- Utils.drawItemStack(stack, itemX, itemY);
-
- if(mouseX >= guiLeft+itemX && mouseX < guiLeft+itemX+18 && mouseY >= guiTop+itemY && mouseY < guiTop+itemY+18) {
- itemHoverX = itemX;
- itemHoverY = itemY;
-
- if(stack != null) {
- if(NotEnoughUpdates.INSTANCE.config.storageGUI.enderchestPreview) slotPreview = i;
- tooltipToDisplay = stack.getTooltip(Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().gameSettings.advancedItemTooltips);
- }
- }
- }
- for(int i=0; i<18; i++) {
- int itemX = 10+18*(i%9);
- int itemY = storageViewSize+56+18*(i/9);
- ItemStack stack = containerChest.getLowerChestInventory().getStackInSlot(i+27);
- Utils.drawItemStack(stack, itemX, itemY);
-
- if(mouseX >= guiLeft+itemX && mouseX < guiLeft+itemX+18 && mouseY >= guiTop+itemY && mouseY < guiTop+itemY+18) {
- itemHoverX = itemX;
- itemHoverY = itemY;
-
- if(stack != null) {
- if(NotEnoughUpdates.INSTANCE.config.storageGUI.backpackPreview) slotPreview = i+StorageManager.MAX_ENDER_CHEST_PAGES;
- tooltipToDisplay = stack.getTooltip(Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().gameSettings.advancedItemTooltips);
- }
- }
- }
- } else {
- for(int i=0; i<9; i++) {
- StorageManager.StoragePage page = StorageManager.getInstance().getPage(i, false);
- int itemX = 10+(i%9)*18;
- int itemY = storageViewSize+24+(i/9)*18;
-
- ItemStack stack;
- if(page != null && page.backpackDisplayStack != null) {
- stack = page.backpackDisplayStack;
- } else {
- stack = StorageManager.LOCKED_ENDERCHEST_STACK;
- }
-
- if(stack != null) {
- Utils.drawItemStack(stack, itemX, itemY);
-
- if(mouseX >= guiLeft+itemX && mouseX < guiLeft+itemX+18 && mouseY >= guiTop+itemY && mouseY < guiTop+itemY+18) {
- itemHoverX = itemX;
- itemHoverY = itemY;
- if(NotEnoughUpdates.INSTANCE.config.storageGUI.enderchestPreview) slotPreview = i;
- tooltipToDisplay = stack.getTooltip(Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().gameSettings.advancedItemTooltips);
- }
- }
- }
- for(int i=0; i<18; i++) {
- StorageManager.StoragePage page = StorageManager.getInstance().getPage(i+StorageManager.MAX_ENDER_CHEST_PAGES, false);
- int itemX = 10+(i%9)*18;
- int itemY = storageViewSize+56+(i/9)*18;
-
- ItemStack stack;
- if(page != null && page.backpackDisplayStack != null) {
- stack = page.backpackDisplayStack;
- } else {
- stack = StorageManager.getInstance().getMissingBackpackStack(i);
- }
-
- if(stack != null) {
- Utils.drawItemStack(stack, itemX, itemY);
-
- if(mouseX >= guiLeft+itemX && mouseX < guiLeft+itemX+18 && mouseY >= guiTop+itemY && mouseY < guiTop+itemY+18) {
- itemHoverX = itemX;
- itemHoverY = itemY;
- if(NotEnoughUpdates.INSTANCE.config.storageGUI.backpackPreview) slotPreview = i+StorageManager.MAX_ENDER_CHEST_PAGES;
- tooltipToDisplay = stack.getTooltip(Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().gameSettings.advancedItemTooltips);
-
- if(!StorageManager.getInstance().onStorageMenu) {
- List<String> tooltip = new ArrayList<>();
- for(String line : tooltipToDisplay) {
- tooltip.add(line.replace("Right-click to remove", "Click \"Edit\" to manage"));
- }
- tooltipToDisplay = tooltip;
- }
- }
- }
- }
- }
-
- //Buttons
- Minecraft.getMinecraft().getTextureManager().bindTexture(STORAGE_ICONS_TEXTURE);
- GlStateManager.color(1, 1, 1, 1);
- for(int i=0; i<10; i++) {
- int buttonX = 388+(i%5)*18;
- int buttonY = getStorageViewSize()+35+(i/5)*18;
-
- float minU = (i*16)/256f;
- float maxU = (i*16+16)/256f;
-
- int vIndex = 0;
-
- switch(i) {
- case 2:
- vIndex = NotEnoughUpdates.INSTANCE.config.storageGUI.displayStyle; break;
- case 3:
- vIndex = NotEnoughUpdates.INSTANCE.config.storageGUI.backpackPreview ? 1 : 0; break;
- case 4:
- vIndex = NotEnoughUpdates.INSTANCE.config.storageGUI.enderchestPreview ? 1 : 0; break;
- case 5:
- vIndex = NotEnoughUpdates.INSTANCE.config.storageGUI.masonryMode ? 1 : 0; break;
- case 6:
- vIndex = NotEnoughUpdates.INSTANCE.config.storageGUI.fancyPanes == 2 ? 0 : NotEnoughUpdates.INSTANCE.config.storageGUI.fancyPanes+1; break;
- case 7:
- vIndex = NotEnoughUpdates.INSTANCE.config.storageGUI.searchBarAutofocus ? 1 : 0; break;
- }
-
- Utils.drawTexturedRect(buttonX, buttonY, 16, 16, minU, maxU, (vIndex*16)/256f, (vIndex*16+16)/256f, GL11.GL_NEAREST);
-
- if(mouseX >= guiLeft+buttonX && mouseX < guiLeft+buttonX+18 &&
- mouseY >= guiTop+buttonY && mouseY < guiTop+buttonY+18) {
- switch(i) {
- case 0:
- tooltipToDisplay = createTooltip(
- "Enable GUI",
- 0,
- "On",
- "Off"
- ); break;
- case 1:
- int tooltipStorageHeight = desiredHeightSwitch != -1 ? desiredHeightSwitch :
- NotEnoughUpdates.INSTANCE.config.storageGUI.storageHeight;
- tooltipToDisplay = createTooltip(
- "Storage View Height",
- Math.round((tooltipStorageHeight-104)/52f),
- "Tiny",
- "Small",
- "Medium",
- "Large",
- "Huge"
- );
- if(desiredHeightSwitch != -1) {
- tooltipToDisplay.add("");
- tooltipToDisplay.add(EnumChatFormatting.YELLOW+"* Move mouse to apply changes *");
- }
- break;
- case 2:
- tooltipToDisplay = createTooltip(
- "Overlay Style",
- NotEnoughUpdates.INSTANCE.config.storageGUI.displayStyle,
- "Transparent",
- "Minecraft",
- "Dark",
- "Custom"
- );
- break;
- case 3:
- tooltipToDisplay = createTooltip(
- "Backpack Preview",
- NotEnoughUpdates.INSTANCE.config.storageGUI.backpackPreview ? 0 : 1,
- "On",
- "Off"
- );
- break;
- case 4:
- tooltipToDisplay = createTooltip(
- "Enderchest Preview",
- NotEnoughUpdates.INSTANCE.config.storageGUI.enderchestPreview ? 0 : 1,
- "On",
- "Off"
- );
- break;
- case 5:
- tooltipToDisplay = createTooltip(
- "Compact Vertically",
- NotEnoughUpdates.INSTANCE.config.storageGUI.masonryMode ? 0 : 1,
- "On",
- "Off"
- );
- break;
- case 6:
- tooltipToDisplay = createTooltip(
- "Fancy Glass Panes",
- NotEnoughUpdates.INSTANCE.config.storageGUI.fancyPanes,
- "On",
- "Locked",
- "Off"
- );
- tooltipToDisplay.add(1, "\u00a7eReplace the glass pane textures");
- tooltipToDisplay.add(2, "\u00a7ein your storage containers with");
- tooltipToDisplay.add(3, "\u00a7ea fancy connected texture");
- break;
- case 7:
- tooltipToDisplay = createTooltip(
- "Search Bar Autofocus",
- NotEnoughUpdates.INSTANCE.config.storageGUI.searchBarAutofocus ? 0 : 1,
- "On",
- "Off"
- );
- break;
- }
- }
- }
-
- if(!StorageManager.getInstance().onStorageMenu) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(storageTexture);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(171-36, 41+storageViewSize, 36, 14, 24/600f, 60/600f, 251/400f, 265/400f, GL11.GL_NEAREST);
- }
-
- if(itemHoverX >= 0 && itemHoverY >= 0) {
- GlStateManager.disableDepth();
- GlStateManager.colorMask(true, true, true, false);
- Gui.drawRect(itemHoverX, itemHoverY, itemHoverX + 16, itemHoverY + 16, 0x80ffffff);
- GlStateManager.colorMask(true, true, true, true);
- GlStateManager.enableDepth();
- }
-
- GlStateManager.popMatrix();
- GlStateManager.translate(0, 0, 300);
- allowTypingInSearchBar = false;
- if(stackOnMouse != null) {
- GlStateManager.enableDepth();
- if(hoveringOtherBackpack) {
- Utils.drawItemStack(new ItemStack(Item.getItemFromBlock(Blocks.barrier)), mouseX - 8, mouseY - 8);
- } else {
- Utils.drawItemStack(stackOnMouse, mouseX - 8, mouseY - 8);
- }
- } else if(slotPreview >= 0) {
- StorageManager.StoragePage page = StorageManager.getInstance().getPage(slotPreview, false);
- if(page != null && page.rows > 0) {
- int rows = page.rows;
-
- GlStateManager.translate(0, 0, 100);
- GlStateManager.disableDepth();
- BackgroundBlur.renderBlurredBackground(7, width, height, mouseX+2, mouseY+2, 172, 10+18*rows);
- Utils.drawGradientRect(mouseX+2, mouseY+2, mouseX+174, mouseY+12+18*rows, 0xc0101010, 0xd0101010);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(storagePreviewTexture);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(mouseX, mouseY, 176, 7, 0, 1, 0, 7/32f, GL11.GL_NEAREST);
- for(int i=0; i<rows; i++) {
- Utils.drawTexturedRect(mouseX, mouseY+7+18*i, 176, 18, 0, 1, 7/32f, 25/32f, GL11.GL_NEAREST);
- }
- Utils.drawTexturedRect(mouseX, mouseY+7+18*rows, 176, 7, 0, 1, 25/32f, 1, GL11.GL_NEAREST);
- GlStateManager.enableDepth();
-
- for(int i=0; i<rows*9; i++) {
- ItemStack stack = page.items[i];
- if(stack != null) {
- GlStateManager.enableDepth();
- Utils.drawItemStack(stack, mouseX+8+18*(i%9), mouseY+8+18*(i/9));
- GlStateManager.disableDepth();
- }
- }
- GlStateManager.translate(0, 0, -100);
- } else {
- Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, Minecraft.getMinecraft().fontRendererObj);
- }
- } else if(tooltipToDisplay != null) {
- Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, Minecraft.getMinecraft().fontRendererObj);
- } else {
- allowTypingInSearchBar = true;
- }
- GlStateManager.translate(0, 0, -300);
- }
-
- private static boolean shouldConnect(int paneIndex1, int paneIndex2) {
- if(paneIndex1 == 16 || paneIndex2 == 16) return false;
- if(paneIndex1 < 1 || paneIndex2 < 1) return false;
- if(paneIndex1 == paneIndex2) {
- return true;
- }
- /*if((paneIndex1 == 17) == (paneIndex2 == 17)) {
- return true;
- }*/
- return false;
-
- }
-
- public static int getCTMIndex(StorageManager.StoragePage page, int index, int[] isPaneCache, int[] ctmIndexCache) {
- if(page.items[index] == null) {
- ctmIndexCache[index] = -1;
- return -1;
- }
-
- int paneType = getPaneType(page.items[index], index, isPaneCache);
-
- int upIndex = index-9;
- int leftIndex = index%9 > 0 ? index-1 : -1;
- int rightIndex = index%9 < 8 ? index+1 : -1;
- int downIndex = index+9;
- int upleftIndex = index%9 > 0 ? index-10 : -1;
- int uprightIndex = index%9 < 8 ? index-8 : -1;
- int downleftIndex = index%9 > 0 ? index+8 : -1;
- int downrightIndex = index%9 < 8 ?index+10 : -1;
-
- boolean up = upIndex >= 0 && upIndex < isPaneCache.length && shouldConnect(getPaneType(page.items[upIndex], upIndex, isPaneCache), paneType);
- boolean left = leftIndex >= 0 && leftIndex < isPaneCache.length && shouldConnect(getPaneType(page.items[leftIndex], leftIndex, isPaneCache) , paneType);
- boolean down = downIndex >= 0 && downIndex < isPaneCache.length && shouldConnect(getPaneType(page.items[downIndex], downIndex, isPaneCache) , paneType);
- boolean right = rightIndex >= 0 && rightIndex < isPaneCache.length && shouldConnect(getPaneType(page.items[rightIndex], rightIndex, isPaneCache) , paneType);
- boolean upleft = upleftIndex >= 0 && upleftIndex < isPaneCache.length && shouldConnect(getPaneType(page.items[upleftIndex], upleftIndex, isPaneCache) , paneType);
- boolean upright = uprightIndex >= 0 && uprightIndex < isPaneCache.length && shouldConnect(getPaneType(page.items[uprightIndex], uprightIndex, isPaneCache) , paneType);
- boolean downleft = downleftIndex >= 0 && downleftIndex < isPaneCache.length && shouldConnect(getPaneType(page.items[downleftIndex], downleftIndex, isPaneCache) , paneType);
- boolean downright = downrightIndex >= 0 && downrightIndex < isPaneCache.length && shouldConnect(getPaneType(page.items[downrightIndex], downrightIndex, isPaneCache) , paneType);
-
- int ctmIndex = BetterContainers.getCTMIndex(up, right, down, left, upleft, upright, downright, downleft);
- ctmIndexCache[index] = ctmIndex;
- return ctmIndex;
- }
-
- private static String CHROMA_STR = "230:255:255:0:0";
- public static int getRGBFromPane(int paneType) {
- int rgb = -1;
- EnumChatFormatting formatting = EnumChatFormatting.WHITE;
- switch(paneType) {
- case 0: formatting = EnumChatFormatting.WHITE; break;
- case 1: formatting = EnumChatFormatting.GOLD; break;
- case 2: formatting = EnumChatFormatting.LIGHT_PURPLE; break;
- case 3: formatting = EnumChatFormatting.BLUE; break;
- case 4: formatting = EnumChatFormatting.YELLOW; break;
- case 5: formatting = EnumChatFormatting.GREEN; break;
- case 6: rgb = 0xfff03c96; break;
- case 7: formatting = EnumChatFormatting.DARK_GRAY; break;
- case 8: formatting = EnumChatFormatting.GRAY; break;
- case 9: formatting = EnumChatFormatting.DARK_AQUA; break;
- case 10: formatting = EnumChatFormatting.DARK_PURPLE; break;
- case 11: formatting = EnumChatFormatting.DARK_BLUE; break;
- case 12: rgb = 0xffA0522D; break;
- case 13: formatting = EnumChatFormatting.DARK_GREEN; break;
- case 14: formatting = EnumChatFormatting.DARK_RED; break;
- case 15: rgb = 0x00000000; break;
- case 16: rgb = SpecialColour.specialToChromaRGB(CHROMA_STR); break;
- }
- if(rgb != -1) return rgb;
- return 0xff000000 | Minecraft.getMinecraft().fontRendererObj.getColorCode(formatting.toString().charAt(1));
- }
-
- public static int getPaneType(ItemStack stack, int index, int[] cache) {
- if(cache != null && cache[index] != 0) return cache[index];
-
- if(NotEnoughUpdates.INSTANCE.config.storageGUI.fancyPanes == 2) {
- if(cache != null) cache[index] = -1;
- return -1;
- }
-
- if(stack != null && (stack.getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) || stack.getItem() == Item.getItemFromBlock(Blocks.glass_pane))) {
- String internalName = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack);
- if(internalName != null) {
- if(internalName.startsWith("STAINED_GLASS_PANE")) {
- if(cache != null) cache[index] = stack.getItemDamage()+1;
- return stack.getItemDamage()+1;
- } else if(internalName.startsWith("THIN_GLASS")) {
- if(cache != null) cache[index] = 17;
- return 17;
- }
- }
- }
- if(cache != null) cache[index] = -1;
- return -1;
- }
-
- private List<String> createTooltip(String title, int selectedOption, String... options) {
- String selPrefix = EnumChatFormatting.DARK_AQUA + " \u25b6 ";
- String unselPrefix = EnumChatFormatting.GRAY.toString();
-
- for(int i=0; i<options.length; i++) {
- if(i == selectedOption) {
- options[i] = selPrefix + options[i];
- } else {
- options[i] = unselPrefix + options[i];
- }
- }
-
- List list = Lists.newArrayList(options);
- list.add(0, "");
- list.add(0, EnumChatFormatting.GREEN+title);
- return list;
- }
-
- private static class IntPair {
- int x;
- int y;
-
- public IntPair(int x, int y) {
- this.x = x;
- this.y = y;
- }
- }
-
- public IntPair getPageCoords(int displayId) {
- if(displayId < 0) displayId = 0;
-
- int y;
- if(NotEnoughUpdates.INSTANCE.config.storageGUI.masonryMode) {
- y = -scroll.getValue()+18+108*(displayId/3);
- } else {
- y = -scroll.getValue()+17+104*(displayId/3);
- }
- for(int i=0; i<=displayId-3; i += 3) {
- int maxRows = 1;
- for(int j=i; j<i+3; j++) {
- if(NotEnoughUpdates.INSTANCE.config.storageGUI.masonryMode && displayId%3 != j%3) continue;
-
- if(!StorageManager.getInstance().storageConfig.displayToStorageIdMapRender.containsKey(j)) {
- continue;
- }
- int storageId = StorageManager.getInstance().storageConfig.displayToStorageIdMapRender.get(j);
- StorageManager.StoragePage page = StorageManager.getInstance().getPage(storageId, false);
- if(page == null || page.rows <= 0) {
- maxRows = Math.max(maxRows, 3);
- } else {
- maxRows = Math.max(maxRows, page.rows);
- }
- }
- y -= (5-maxRows)*18;
- }
-
- return new IntPair(8+172*(displayId%3), y);
- }
-
- @Override
- public boolean mouseInput(int mouseX, int mouseY) {
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) return false;
-
- int dWheel = Mouse.getEventDWheel();
- if(!(NotEnoughUpdates.INSTANCE.config.storageGUI.cancelScrollKey != 0 &&
- KeybindHelper.isKeyDown(NotEnoughUpdates.INSTANCE.config.storageGUI.cancelScrollKey)) && dWheel != 0) {
- if(dWheel < 0) {
- dWheel = -1;
- if(scrollVelocity > 0) scrollVelocity = 0;
- }
- if(dWheel > 0) {
- dWheel = 1;
- if(scrollVelocity < 0) scrollVelocity = 0;
- }
-
- long currentTime = System.currentTimeMillis();
- if(currentTime - lastScroll > 200) {
- scrollVelocity = 0;
- } else {
- scrollVelocity = (int)(scrollVelocity / 1.3f);
- }
- lastScroll = currentTime;
-
- scrollVelocity += dWheel*10;
- scrollToY(scroll.getTarget()-scrollVelocity);
-
- return true;
- }
-
- if(Mouse.getEventButtonState()) {
- editingNameId = -1;
- }
-
- if(Mouse.getEventButton() == 0) {
- if(!Mouse.getEventButtonState()) {
- scrollGrabOffset = -1;
- } else if(mouseX >= guiLeft+519 && mouseX <= guiLeft+519+14 &&
- mouseY >= guiTop+8 && mouseY <= guiTop+2+getStorageViewSize()) {
- int scrollMouseY = mouseY - (guiTop+8);
- int scrollBarY = Math.round(getScrollBarHeight()*scroll.getValue()/(float)getMaximumScroll());
-
- if(scrollMouseY >= scrollBarY && scrollMouseY < scrollBarY+12) {
- scrollGrabOffset = scrollMouseY - scrollBarY;
- }
- }
- }
- if(scrollGrabOffset >= 0 && Mouse.getEventButton() == -1 && !Mouse.getEventButtonState()) {
- int scrollMouseY = mouseY - (guiTop+8);
- int scrollBarY = scrollMouseY - scrollGrabOffset;
-
- scrollToY(Math.round(scrollBarY*getMaximumScroll()/(float)getScrollBarHeight()));
- scroll.setTimeToReachTarget(10);
- }
-
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- int width = scaledResolution.getScaledWidth();
- int height = scaledResolution.getScaledHeight();
-
- int storageViewSize = getStorageViewSize();
-
- int sizeX = 540;
- int sizeY = 100+storageViewSize;
- int searchNobX = 18;
-
- guiLeft = width/2 - (sizeX-searchNobX)/2;
- guiTop = height/2 - sizeY/2;
-
- if(Mouse.getEventButtonState() && !StorageManager.getInstance().onStorageMenu) {
- if(mouseX > guiLeft+171-36 && mouseX < guiLeft+171 &&
- mouseY > guiTop+41+storageViewSize && mouseY < guiTop+41+storageViewSize+14) {
- NotEnoughUpdates.INSTANCE.sendChatMessage("/storage");
- searchBar.setFocus(false);
- return true;
- }
- }
-
- if(Mouse.getEventButtonState()) {
- if(mouseX >= guiLeft+252 && mouseX <= guiLeft+252+searchBar.getWidth() &&
- mouseY >= guiTop+storageViewSize+5 && mouseY <= guiTop+storageViewSize+5+searchBar.getHeight()) {
- if(searchBar.getFocus()) {
- searchBar.mouseClicked(mouseX-guiLeft, mouseY-guiTop, Mouse.getEventButton());
- StorageManager.getInstance().searchDisplay(searchBar.getText());
- dirty = true;
- } else {
- searchBar.setFocus(true);
- if(Mouse.getEventButton() == 1) {
- searchBar.setText("");
- StorageManager.getInstance().searchDisplay(searchBar.getText());
- dirty = true;
- }
- }
- } else {
- searchBar.setFocus(false);
- }
- }
-
- if(mouseX > guiLeft+181 && mouseX < guiLeft+181+162 &&
- mouseY > guiTop+storageViewSize+18 && mouseY < guiTop+storageViewSize+94) {
- if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))
- dirty = true;
- return false;
- }
-
- if(mouseY > guiTop+3 && mouseY < guiTop+storageViewSize+3) {
- int currentPage = StorageManager.getInstance().getCurrentPageId();
- for(Map.Entry<Integer, Integer> entry : StorageManager.getInstance().storageConfig.displayToStorageIdMapRender.entrySet()) {
- IntPair pageCoords = getPageCoords(entry.getKey());
-
- if(pageCoords.y > storageViewSize+3 || pageCoords.y+90 < 3) continue;
-
- StorageManager.StoragePage page = StorageManager.getInstance().getPage(entry.getValue(), false);
- int rows = page == null ? 3 : page.rows <= 0 ? 3 : page.rows;
-
- if(page != null) {
- String pageTitle;
- if(page.customTitle != null && !page.customTitle.isEmpty()) {
- pageTitle = page.customTitle;
- } else if(entry.getValue() < 9) {
- pageTitle = "Ender Chest Page " + (entry.getValue() + 1);
- } else {
- pageTitle = "Backpack Slot "+(entry.getValue()-8);
- }
- int titleLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(pageTitle);
-
- if(mouseX >= guiLeft+pageCoords.x && mouseX <= guiLeft+pageCoords.x+titleLen+15 &&
- mouseY >= guiTop+pageCoords.y-14 && mouseY <= guiTop+pageCoords.y+1) {
- if(Mouse.getEventButtonState() && (Mouse.getEventButton() == 0 || Mouse.getEventButton() == 1)) {
- if(editingNameId != entry.getValue()) {
- editingNameId = entry.getValue();
- if(!renameStorageField.getText().equalsIgnoreCase(pageTitle)) {
- renameStorageField.setText(pageTitle);
- }
- }
- if(!renameStorageField.getFocus()) {
- renameStorageField.setFocus(true);
- } else {
- renameStorageField.mouseClicked(mouseX-guiLeft, mouseY-guiTop, Mouse.getEventButton());
- }
- } else if(Mouse.getEventButton() < 0 && Mouse.isButtonDown(0)) {
- renameStorageField.mouseClickMove(mouseX-guiLeft, mouseY-guiTop, 0, 0);
- }
- return true;
- }
- }
-
- if(mouseX > guiLeft+pageCoords.x && mouseX < guiLeft+pageCoords.x+162 &&
- mouseY > guiTop+pageCoords.y && mouseY < guiTop+pageCoords.y+rows*18) {
- if(currentPage >= 0 && entry.getValue() == currentPage) {
- dirty = true;
- return false;
- } else {
- if(Mouse.getEventButtonState() && Mouse.getEventButton() == 0 &&
- Minecraft.getMinecraft().thePlayer.inventory.getItemStack() == null &&
- page != null) {
- scrollToStorage(entry.getKey(), false);
- StorageManager.getInstance().sendToPage(entry.getValue());
- return true;
- }
- }
- }
- }
- }
-
- for(int i=0; i<10; i++) {
- int buttonX = 388+(i%5)*18;
- int buttonY = getStorageViewSize()+35+(i/5)*18;
-
- float minU = (i*16)/256f;
- float maxU = (i*16+16)/256f;
-
- int vIndex = 0;
-
- switch(i) {
- case 2:
- vIndex = NotEnoughUpdates.INSTANCE.config.storageGUI.displayStyle; break;
+ private final GuiElementTextField searchBar = new GuiElementTextField("", 88, 10,
+ GuiElementTextField.SCALE_TEXT | GuiElementTextField.DISABLE_BG
+ );
+ private final GuiElementTextField renameStorageField = new GuiElementTextField("", 100, 13,
+ GuiElementTextField.COLOUR
+ );
+
+ private int editingNameId = -1;
+
+ private int guiLeft;
+ private int guiTop;
+
+ private boolean fastRender = false;
+
+ private int loadCircleIndex = 0;
+ private int rollIndex = 0;
+ private int loadCircleRotation = 0;
+
+ private long millisAccumIndex = 0;
+ private long millisAccumRoll = 0;
+ private long millisAccumRotation = 0;
+
+ private long lastMillis = 0;
+
+ private int scrollVelocity = 0;
+ private long lastScroll = 0;
+
+ private final int[][] isPaneCaches = new int[40][];
+ private final int[][] ctmIndexCaches = new int[40][];
+
+ private int desiredHeightSwitch = -1;
+ private int desiredHeightMX = -1;
+ private int desiredHeightMY = -1;
+
+ private boolean dirty = false;
+ private boolean allowTypingInSearchBar = true;
+
+ private int scrollGrabOffset = -1;
+
+ private final LerpingInteger scroll = new LerpingInteger(0, 200);
+
+ private int getMaximumScroll() {
+ synchronized (StorageManager.getInstance().storageConfig.displayToStorageIdMapRender) {
+
+ int maxH = 0;
+
+ for (int i = 0; i < 3; i++) {
+ int lastDisplayId = StorageManager.getInstance().storageConfig.displayToStorageIdMapRender.size() - 1;
+ int coords = (int) Math.ceil(lastDisplayId / 3f) * 3 + 1 + i;
+
+ int h = getPageCoords(coords).y + scroll.getValue() - getStorageViewSize() - 14;
+
+ if (h > maxH) maxH = h;
+ }
+
+ return maxH;
+ }
+ }
+
+ public void markDirty() {
+ dirty = true;
+ }
+
+ private void scrollToY(int y) {
+ int target = y;
+ if (target < 0) target = 0;
+
+ int maxY = getMaximumScroll();
+ if (target > maxY) target = maxY;
+
+ float factor = (scroll.getValue() - target) / (float) (scroll.getValue() - y + 1E-5);
+
+ scroll.setTarget(target);
+ scroll.setTimeToReachTarget(Math.min(200, Math.max(20, (int) (200 * factor))));
+ scroll.resetTimer();
+ }
+
+ public void scrollToStorage(int displayId, boolean forceScroll) {
+ if (displayId < 0) return;
+
+ int y = getPageCoords(displayId).y - 17;
+ if (y < 3) {
+ scrollToY(y + scroll.getValue());
+ } else {
+ int storageViewSize = getStorageViewSize();
+ int y2 = getPageCoords(displayId + 3).y - 17 - storageViewSize;
+ if (y2 > 3) {
+ if (forceScroll) {
+ scrollToY(y + scroll.getValue());
+ } else {
+ scrollToY(y2 + scroll.getValue());
+ }
+ }
+ }
+ }
+
+ private int getStorageViewSize() {
+ return NotEnoughUpdates.INSTANCE.config.storageGUI.storageHeight;
+ }
+
+ private int getScrollBarHeight() {
+ return getStorageViewSize() - 21;
+ }
+
+ @Override
+ public void render() {
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) return;
+ GuiChest guiChest = (GuiChest) Minecraft.getMinecraft().currentScreen;
+ ContainerChest containerChest = (ContainerChest) guiChest.inventorySlots;
+
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ int width = scaledResolution.getScaledWidth();
+ int height = scaledResolution.getScaledHeight();
+ int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
+ int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
+ FontRenderer fontRendererObj = Minecraft.getMinecraft().fontRendererObj;
+
+ scroll.tick();
+
+ int displayStyle = NotEnoughUpdates.INSTANCE.config.storageGUI.displayStyle;
+ ResourceLocation storageTexture = STORAGE_TEXTURES[displayStyle];
+ ResourceLocation storagePreviewTexture = STORAGE_PREVIEW_TEXTURES[displayStyle];
+ int textColour = 0x404040;
+ int searchTextColour = 0xe0e0e0;
+ if (displayStyle == 2) {
+ textColour = 0x000000;
+ searchTextColour = 0xa0a0a0;
+ } else if (displayStyle == 3) {
+ textColour = 0xFBCC6C;
+ } else if (displayStyle == 0) {
+ textColour = 0x909090;
+ searchTextColour = 0xa0a0a0;
+ }
+
+ long currentTime = System.currentTimeMillis();
+ if (lastMillis > 0) {
+ long deltaTime = currentTime - lastMillis;
+ millisAccumIndex += deltaTime;
+ loadCircleIndex += millisAccumIndex / (1000 / 15);
+ millisAccumIndex %= (1000 / 15);
+
+ millisAccumRotation += deltaTime;
+ loadCircleRotation += millisAccumRotation / (1000 / 107);
+ millisAccumRotation %= (1000 / 107);
+
+ millisAccumRoll += deltaTime;
+ rollIndex += millisAccumRoll / 100;
+ millisAccumRoll %= 100;
+ }
+
+ lastMillis = currentTime;
+ loadCircleIndex %= LOAD_CIRCLE_SEQ.length;
+ rollIndex %= NOT_RICKROLL_SEQ.length * 2;
+ loadCircleRotation %= 360;
+
+ Color loadCircleColour = Color.getHSBColor(loadCircleRotation / 360f, 0.3f, 0.9f);
+ ItemStack stackOnMouse = Minecraft.getMinecraft().thePlayer.inventory.getItemStack();
+ if (stackOnMouse != null) {
+ String stackDisplay = Utils.cleanColour(stackOnMouse.getDisplayName());
+ if (stackDisplay.startsWith("Backpack Slot ") || stackDisplay.startsWith("Empty Backpack Slot ") ||
+ stackDisplay.startsWith("Ender Chest Page ")) {
+ stackOnMouse = null;
+ }
+ }
+
+ List<String> tooltipToDisplay = null;
+ int slotPreview = -1;
+
+ int storageViewSize = getStorageViewSize();
+
+ int sizeX = 540;
+ int sizeY = 100 + storageViewSize;
+ int searchNobX = 18;
+
+ int itemHoverX = -1;
+ int itemHoverY = -1;
+
+ guiLeft = width / 2 - (sizeX - searchNobX) / 2;
+ guiTop = height / 2 - sizeY / 2;
+
+ if (displayStyle == 0) {
+ BackgroundBlur.renderBlurredBackground(7, width, height, guiLeft, guiTop, sizeX, storageViewSize);
+ BackgroundBlur.renderBlurredBackground(
+ 7,
+ width,
+ height,
+ guiLeft + 5,
+ guiTop + storageViewSize,
+ sizeX - searchNobX - 10,
+ sizeY - storageViewSize - 4
+ );
+ }
+
+ Utils.drawGradientRect(0, 0, width, height, 0xc0101010, 0xd0101010);
+
+ GL11.glPushMatrix();
+ GlStateManager.translate(guiLeft, guiTop, 0);
+
+ boolean hoveringOtherBackpack = false;
+
+ //Gui
+ Minecraft.getMinecraft().getTextureManager().bindTexture(storageTexture);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(0, 0, sizeX, 10, 0, sizeX / 600f, 0, 10 / 400f, GL11.GL_NEAREST);
+ Utils.drawTexturedRect(0, 10, sizeX, storageViewSize - 20, 0, sizeX / 600f, 10 / 400f, 94 / 400f, GL11.GL_NEAREST);
+ Utils.drawTexturedRect(
+ 0,
+ storageViewSize - 10,
+ sizeX,
+ 110,
+ 0,
+ sizeX / 600f,
+ 94 / 400f,
+ 204 / 400f,
+ GL11.GL_NEAREST
+ );
+
+ int maxScroll = getMaximumScroll();
+ if (scroll.getValue() > maxScroll) {
+ scroll.setValue(maxScroll);
+ }
+ if (scroll.getValue() < 0) {
+ scroll.setValue(0);
+ }
+
+ //Scroll bar
+ int scrollBarY = Math.round(getScrollBarHeight() * scroll.getValue() / (float) maxScroll);
+ float uMin = scrollGrabOffset >= 0 ? 12 / 600f : 0;
+ Utils.drawTexturedRect(
+ 520,
+ 8 + scrollBarY,
+ 12,
+ 15,
+ uMin,
+ uMin + 12 / 600f,
+ 250 / 400f,
+ 265 / 400f,
+ GL11.GL_NEAREST
+ );
+
+ int currentPage = StorageManager.getInstance().getCurrentPageId();
+
+ boolean mouseInsideStorages = mouseY > guiTop + 3 && mouseY < guiTop + 3 + storageViewSize;
+
+ //Storages
+ boolean doItemRender = true;
+ boolean doRenderFramebuffer = false;
+ int startY = getPageCoords(0).y;
+ if (OpenGlHelper.isFramebufferEnabled()) {
+ int h;
+ synchronized (StorageManager.getInstance().storageConfig.displayToStorageIdMapRender) {
+ int lastDisplayId = StorageManager.getInstance().storageConfig.displayToStorageIdMapRender.size() - 1;
+ int coords = (int) Math.ceil(lastDisplayId / 3f) * 3 + 3;
+
+ h = getPageCoords(coords).y + scroll.getValue();
+ }
+ int w = sizeX;
+
+ //Render from framebuffer
+ if (framebuffer != null) {
+ GlScissorStack.push(0, guiTop + 3, width, guiTop + 3 + storageViewSize, scaledResolution);
+ GlStateManager.enableDepth();
+ GlStateManager.translate(0, startY, 107.0001f);
+ framebuffer.bindFramebufferTexture();
+
+ GlStateManager.color(1, 1, 1, 1);
+
+ GlStateManager.enableAlpha();
+ GlStateManager.alphaFunc(GL11.GL_GREATER, 0F);
+ Utils.drawTexturedRect(0, 0, w, h, 0, 1, 1, 0, GL11.GL_NEAREST);
+ GlStateManager.alphaFunc(GL11.GL_GREATER, 0.1F);
+
+ renderEnchOverlay(enchantGlintRenderLocations);
+
+ GlStateManager.translate(0, -startY, -107.0001f);
+ GlScissorStack.pop(scaledResolution);
+ }
+
+ if (dirty || framebuffer == null) {
+ dirty = false;
+
+ int fw = w * scaledResolution.getScaleFactor();
+ int fh = h * scaledResolution.getScaleFactor();
+
+ if (framebuffer == null) {
+ framebuffer = new Framebuffer(fw, fh, true);
+ } else if (framebuffer.framebufferWidth != fw || framebuffer.framebufferHeight != fh) {
+ framebuffer.createBindFramebuffer(fw, fh);
+ }
+ framebuffer.framebufferClear();
+ framebuffer.bindFramebuffer(true);
+
+ GlStateManager.matrixMode(GL11.GL_PROJECTION);
+ GlStateManager.loadIdentity();
+ GlStateManager.ortho(0.0D, w, h, 0.0D, 1000.0D, 3000.0D);
+ GlStateManager.matrixMode(GL11.GL_MODELVIEW);
+
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(-guiLeft, -guiTop - startY, 0);
+
+ doRenderFramebuffer = true;
+ } else {
+ doItemRender = false;
+ }
+ }
+
+ if (doItemRender) {
+ enchantGlintRenderLocations.clear();
+ for (Map.Entry<Integer, Integer> entry : StorageManager.getInstance().storageConfig.displayToStorageIdMapRender.entrySet()) {
+ int displayId = entry.getKey();
+ int storageId = entry.getValue();
+
+ IntPair coords = getPageCoords(displayId);
+ int storageX = coords.x;
+ int storageY = coords.y;
+
+ if (!doRenderFramebuffer) {
+ if (coords.y - 11 > 3 + storageViewSize || coords.y + 90 < 3) continue;
+ }
+
+ StorageManager.StoragePage page = StorageManager.getInstance().getPage(storageId, false);
+ if (page != null && page.rows > 0) {
+ int rows = page.rows;
+
+ isPaneCaches[storageId] = new int[page.rows * 9];
+ ctmIndexCaches[storageId] = new int[page.rows * 9];
+ int[] isPaneCache = isPaneCaches[storageId];
+ int[] ctmIndexCache = ctmIndexCaches[storageId];
+
+ for (int k = 0; k < rows * 9; k++) {
+ ItemStack stack;
+
+ if (storageId == currentPage) {
+ stack = containerChest.getSlot(k + 9).getStack();
+ } else {
+ stack = page.items[k];
+ }
+
+ int itemX = storageX + 1 + 18 * (k % 9);
+ int itemY = storageY + 1 + 18 * (k / 9);
+
+ //Render fancy glass
+ if (stack != null) {
+ int paneType = getPaneType(stack, k, isPaneCache);
+ if (paneType > 0) {
+ GlStateManager.disableAlpha();
+ Gui.drawRect(itemX - 1, itemY - 1, itemX + 17, itemY + 17, 0x01000000);
+ GlStateManager.enableAlpha();
+
+ int ctmIndex = getCTMIndex(page, k, isPaneCache, ctmIndexCache);
+ int startCTMX = (ctmIndex % 12) * 19;
+ int startCTMY = (ctmIndex / 12) * 19;
+
+ ctmIndexCache[k] = ctmIndex;
+
+ if (paneType != 17) {
+ int rgb = getRGBFromPane(paneType - 1);
+ {
+ int a = (rgb >> 24) & 0xFF;
+ int r = (rgb >> 16) & 0xFF;
+ int g = (rgb >> 8) & 0xFF;
+ int b = rgb & 0xFF;
+ Minecraft.getMinecraft().getTextureManager().bindTexture(STORAGE_PANE_CTM_TEXTURE);
+ GlStateManager.color(r / 255f, g / 255f, b / 255f, a / 255f);
+ Utils.drawTexturedRect(
+ itemX - 1,
+ itemY - 1,
+ 18,
+ 18,
+ startCTMX / 227f,
+ (startCTMX + 18) / 227f,
+ startCTMY / 75f,
+ (startCTMY + 18) / 75f,
+ GL11.GL_NEAREST
+ );
+ }
+
+ /*int[] colours = new int[9];
+
+ for (int xi = -1; xi <= 1; xi++) {
+ for (int yi = -1; yi <= 1; yi++) {
+ List<Integer> indexes = new ArrayList<>();
+ List<Integer> coloursList = new ArrayList<>();
+ coloursList.add(rgb);
+
+ if (xi != 0) {
+ indexes.add(k + xi);
+ }
+ if (yi != 0) {
+ indexes.add(k + yi * 9);
+ }
+ if (xi != 0 && yi != 0) {
+ indexes.add(k + yi * 9 + xi);
+ }
+ for (int index : indexes) {
+ if (index >= 0 && index < rows * 9) {
+ int paneTypeI = getPaneType(page.items[index], index, isPaneCache);
+ if (shouldConnect(paneType, paneTypeI)) {
+ coloursList.add(getRGBFromPane(paneTypeI - 1));
+ }
+ }
+ }
+ Vector4f cv = new Vector4f();
+ for (int colour : coloursList) {
+ float a = (colour >> 24) & 0xFF;
+ float r = (colour >> 16) & 0xFF;
+ float g = (colour >> 8) & 0xFF;
+ float b = colour & 0xFF;
+ cv.x += a / coloursList.size();
+ cv.y += r / coloursList.size();
+ cv.z += g / coloursList.size();
+ cv.w += b / coloursList.size();
+ }
+ int finalCol = (((int) cv.x) << 24) | (((int) cv.y) << 16) | (((int) cv.z) << 8) | ((int) cv.w);
+ colours[(xi + 1) + (yi + 1) * 3] = finalCol;
+ }
+ }
+ int[] colours4 = new int[16];
+
+ for (int x = 0; x < 4; x++) {
+ for (int y = 0; y < 4; y++) {
+ int ya = y < 2 ? y : y - 1;
+ int xa = x < 2 ? x : x - 1;
+ colours4[x + y * 4] = colours[xa + ya * 3];
+ }
+ }
+
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(itemX - 1, itemY - 1, 0);
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+ worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
+ float uMinCTM = startCTMX / 227f;
+ float uMaxCTM = (startCTMX + 18) / 227f;
+ float vMinCTM = startCTMY / 75f;
+ float vMaxCTM = (startCTMY + 18) / 75f;
+ for (int xi = -1; xi <= 1; xi++) {
+ for (int yi = -1; yi <= 1; yi++) {
+ float x = xi == -1 ? 0 : xi == 0 ? 1 : 17;
+ float y = yi == -1 ? 0 : yi == 0 ? 1 : 17;
+ float w = xi == 0 ? 16 : 1;
+ float h = yi == 0 ? 16 : 1;
+
+ int col1 = colours4[(xi + 1) + (yi + 1) * 4];
+ int col2 = colours4[(xi + 2) + (yi + 1) * 4];
+ int col3 = colours4[(xi + 1) + (yi + 2) * 4];
+ int col4 = colours4[(xi + 2) + (yi + 2) * 4];
+
+ worldrenderer
+ .pos(x, y + h, 0.0D)
+ .tex(uMinCTM + (uMaxCTM - uMinCTM) * x / 18f, vMinCTM + (vMaxCTM - vMinCTM) * (y + h) / 18f)
+ .color((col3 >> 16) & 0xFF, (col3 >> 8) & 0xFF, col3 & 0xFF, (col3 >> 24) & 0xFF).endVertex();
+ worldrenderer
+ .pos(x + w, y + h, 0.0D)
+ .tex(
+ uMinCTM + (uMaxCTM - uMinCTM) * (x + w) / 18f,
+ vMinCTM + (vMaxCTM - vMinCTM) * (y + h) / 18f
+ )
+ .color((col4 >> 16) & 0xFF, (col4 >> 8) & 0xFF, col4 & 0xFF, (col4 >> 24) & 0xFF).endVertex();
+ worldrenderer
+ .pos(x + w, y, 0.0D)
+ .tex(uMinCTM + (uMaxCTM - uMinCTM) * (x + w) / 18f, vMinCTM + (vMaxCTM - vMinCTM) * y / 18f)
+ .color((col2 >> 16) & 0xFF, (col2 >> 8) & 0xFF, col2 & 0xFF, (col2 >> 24) & 0xFF).endVertex();
+ worldrenderer
+ .pos(x, y, 0.0D)
+ .tex(uMinCTM + (uMaxCTM - uMinCTM) * x / 18f, vMinCTM + (vMaxCTM - vMinCTM) * y / 18f)
+ .color((col1 >> 16) & 0xFF, (col1 >> 8) & 0xFF, col1 & 0xFF, (col1 >> 24) & 0xFF).endVertex();
+ }
+ }
+ GlStateManager.disableDepth();
+ GlStateManager.color(1, 1, 1, 1);
+ GlStateManager.shadeModel(GL11.GL_SMOOTH);
+ tessellator.draw();
+ GlStateManager.shadeModel(GL11.GL_FLAT);
+ GlStateManager.enableDepth();
+ GlStateManager.popMatrix();*/
+
+ RenderItem itemRender = Minecraft.getMinecraft().getRenderItem();
+ itemRender.renderItemOverlayIntoGUI(
+ Minecraft.getMinecraft().fontRendererObj,
+ stack,
+ itemX,
+ itemY,
+ null
+ );
+ GlStateManager.disableLighting();
+ }
+
+ page.shouldDarkenIfNotSelected[k] = false;
+ continue;
+ }
+ }
+ page.shouldDarkenIfNotSelected[k] = true;
+
+ //Render item
+ GlStateManager.translate(0, 0, 20);
+ if (doRenderFramebuffer) {
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+ GL14.glBlendFuncSeparate(GL11.GL_ONE, GL11.GL_ZERO, GL11.GL_ONE, GL11.GL_ZERO);
+
+ if (storageId == currentPage) {
+ Utils.hasEffectOverride = true;
+ GlStateManager.translate(storageX - 7, storageY - 17 - 18, 0);
+ guiChest.drawSlot(containerChest.getSlot(k + 9));
+ GlStateManager.translate(-storageX + 7, -storageY + 17 + 18, 0);
+ Utils.hasEffectOverride = false;
+ } else {
+ Utils.drawItemStackWithoutGlint(stack, itemX, itemY);
+ }
+
+ GL14.glBlendFuncSeparate(770, 771, 1, 0);
+
+ if (stack != null && (stack.hasEffect() || stack.getItem() == Items.enchanted_book)) {
+ enchantGlintRenderLocations.add(new Vector2f(itemX, itemY - startY));
+ }
+ } else if (storageId == currentPage) {
+ Utils.hasEffectOverride = true;
+ GlStateManager.translate(storageX - 7, storageY - 17 - 18, 0);
+ guiChest.drawSlot(containerChest.getSlot(k + 9));
+ GlStateManager.translate(-storageX + 7, -storageY + 17 + 18, 0);
+ Utils.hasEffectOverride = false;
+ } else {
+ Utils.drawItemStack(stack, itemX, itemY);
+ }
+ GlStateManager.disableLighting();
+ GlStateManager.translate(0, 0, -20);
+ }
+
+ GlStateManager.disableLighting();
+ GlStateManager.enableDepth();
+ }
+ }
+ }
+
+ if (OpenGlHelper.isFramebufferEnabled() && doRenderFramebuffer) {
+ GlStateManager.popMatrix();
+ Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true);
+
+ GlStateManager.matrixMode(GL11.GL_PROJECTION);
+ GlStateManager.loadIdentity();
+ GlStateManager.ortho(0.0D, scaledResolution.getScaledWidth_double(), scaledResolution.getScaledHeight_double(),
+ 0.0D, 1000.0D, 3000.0D
+ );
+ GlStateManager.matrixMode(GL11.GL_MODELVIEW);
+ }
+
+ GlScissorStack.push(0, guiTop + 3, width, guiTop + 3 + storageViewSize, scaledResolution);
+ for (Map.Entry<Integer, Integer> entry : StorageManager.getInstance().storageConfig.displayToStorageIdMapRender.entrySet()) {
+ int displayId = entry.getKey();
+ int storageId = entry.getValue();
+
+ IntPair coords = getPageCoords(displayId);
+ int storageX = coords.x;
+ int storageY = coords.y;
+
+ if (coords.y - 11 > 3 + storageViewSize || coords.y + 90 < 3) continue;
+
+ StorageManager.StoragePage page = StorageManager.getInstance().getPage(storageId, false);
+
+ if (editingNameId == storageId) {
+ int len = fontRendererObj.getStringWidth(renameStorageField.getTextDisplay()) + 10;
+ renameStorageField.setSize(len, 12);
+ renameStorageField.render(storageX, storageY - 13);
+ } else {
+ String pageTitle;
+ if (page != null && page.customTitle != null && !page.customTitle.isEmpty()) {
+ pageTitle = Utils.chromaStringByColourCode(page.customTitle);
+ } else if (entry.getValue() < 9) {
+ pageTitle = "Ender Chest Page " + (entry.getValue() + 1);
+ } else {
+ pageTitle = "Backpack Slot " + (storageId - 8);
+ }
+ int titleLen = fontRendererObj.getStringWidth(pageTitle);
+
+ if (mouseX >= guiLeft + storageX && mouseX <= guiLeft + storageX + titleLen + 15 &&
+ mouseY >= guiTop + storageY - 14 && mouseY <= guiTop + storageY + 1) {
+ pageTitle += " \u270E";
+ }
+ fontRendererObj.drawString(pageTitle, storageX, storageY - 11, textColour);
+ }
+
+ if (page == null) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(storageTexture);
+ GlStateManager.color(1, 1, 1, 1);
+ int h = 18 * 3;
+
+ Utils.drawTexturedRect(
+ storageX,
+ storageY,
+ 162,
+ h,
+ 0,
+ 162 / 600f,
+ 265 / 400f,
+ (265 + h) / 400f,
+ GL11.GL_NEAREST
+ );
+
+ Gui.drawRect(storageX, storageY, storageX + 162, storageY + h, 0x80000000);
+
+ if (storageId < 9) {
+ Utils.drawStringCenteredScaledMaxWidth("Locked Page", fontRendererObj,
+ storageX + 81, storageY + h / 2, true, 150, 0xd94c00
+ );
+ } else {
+ Utils.drawStringCenteredScaledMaxWidth("Empty Backpack Slot", fontRendererObj,
+ storageX + 81, storageY + h / 2, true, 150, 0xd94c00
+ );
+ }
+ } else if (page.rows <= 0) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(storageTexture);
+ GlStateManager.color(1, 1, 1, 1);
+ int h = 18 * 3;
+
+ Utils.drawTexturedRect(
+ storageX,
+ storageY,
+ 162,
+ h,
+ 0,
+ 162 / 600f,
+ 265 / 400f,
+ (265 + h) / 400f,
+ GL11.GL_NEAREST
+ );
+
+ Gui.drawRect(storageX, storageY, storageX + 162, storageY + h, 0x80000000);
+
+ Utils.drawStringCenteredScaledMaxWidth("Click to load items", fontRendererObj,
+ storageX + 81, storageY + h / 2, true, 150, 0xffdf00
+ );
+ } else {
+ int rows = page.rows;
+
+ int storageW = 162;
+ int storageH = 18 * rows;
+
+ GlStateManager.enableDepth();
+
+ boolean[] shouldLimitBorder = new boolean[rows * 9];
+ boolean hasCaches = isPaneCaches[storageId] != null && isPaneCaches[storageId].length == rows * 9 &&
+ ctmIndexCaches[storageId] != null && ctmIndexCaches[storageId].length == rows * 9;
+
+ //Render item connections
+ for (int k = 0; k < rows * 9; k++) {
+ ItemStack stack = page.items[k];
+
+ if (stack != null && hasCaches) {
+ int itemX = storageX + 1 + 18 * (k % 9);
+ int itemY = storageY + 1 + 18 * (k / 9);
+
+ int[] isPaneCache = isPaneCaches[storageId];
+ int[] ctmIndexCache = ctmIndexCaches[storageId];
+
+ if (isPaneCache[k] == 17) {
+ int ctmIndex = getCTMIndex(page, k, isPaneCache, ctmIndexCache);
+ int startCTMX = (ctmIndex % 12) * 19;
+ int startCTMY = (ctmIndex / 12) * 19;
+
+ int rgb = getRGBFromPane(isPaneCache[k] - 1);
+ int a = (rgb >> 24) & 0xFF;
+ int r = (rgb >> 16) & 0xFF;
+ int g = (rgb >> 8) & 0xFF;
+ int b = rgb & 0xFF;
+ Minecraft.getMinecraft().getTextureManager().bindTexture(STORAGE_PANE_CTM_TEXTURE);
+ GlStateManager.color(r / 255f, g / 255f, b / 255f, a / 255f);
+ GlStateManager.translate(0, 0, 110);
+ Utils.drawTexturedRect(itemX - 1, itemY - 1, 18, 18,
+ startCTMX / 227f, (startCTMX + 18) / 227f, startCTMY / 75f, (startCTMY + 18) / 75f, GL11.GL_NEAREST
+ );
+ GlStateManager.translate(0, 0, -110);
+
+ RenderItem itemRender = Minecraft.getMinecraft().getRenderItem();
+ itemRender.renderItemOverlayIntoGUI(Minecraft.getMinecraft().fontRendererObj, stack, itemX, itemY, null);
+ GlStateManager.enableDepth();
+ } else if (isPaneCache[k] < 0) {
+ boolean hasConnection = false;
+
+ int upIndex = k - 9;
+ int leftIndex = k % 9 > 0 ? k - 1 : -1;
+ int rightIndex = k % 9 < 8 ? k + 1 : -1;
+ int downIndex = k + 9;
+
+ int[] indexArr = {rightIndex, downIndex, leftIndex, upIndex};
+
+ for (int j = 0; j < 4; j++) {
+ int index = indexArr[j];
+ int type = index >= 0 && index < isPaneCache.length
+ ? getPaneType(page.items[index], index, isPaneCache)
+ : -1;
+ if (type > 0) {
+ int ctmIndex = getCTMIndex(page, index, isPaneCache, ctmIndexCache);
+ if (ctmIndex < 0) continue;
+
+ boolean renderConnection;
+ boolean horizontal = ctmIndex == 1 || ctmIndex == 2 || ctmIndex == 3;
+ boolean vertical = ctmIndex == 12 || ctmIndex == 24 || ctmIndex == 36;
+ if ((k % 9 == 0 && index % 9 == 0) || (k % 9 == 8 && index % 9 == 8)) {
+ renderConnection = horizontal || vertical;
+ } else if (index == leftIndex || index == rightIndex) {
+ renderConnection = horizontal;
+ } else {
+ renderConnection = vertical;
+ }
+
+ if (renderConnection) {
+ shouldLimitBorder[k] = true;
+ hasConnection = true;
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(STORAGE_PANE_CTM_TEXTURE);
+ int rgb = getRGBFromPane(type - 1);
+ int a = (rgb >> 24) & 0xFF;
+ int r = (rgb >> 16) & 0xFF;
+ int g = (rgb >> 8) & 0xFF;
+ int b = rgb & 0xFF;
+ GlStateManager.color(r / 255f, g / 255f, b / 255f, a / 255f);
+
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(itemX - 1 + 9, itemY - 1 + 9, 10);
+ GlStateManager.rotate(j * 90, 0, 0, 1);
+ GlStateManager.enableAlpha();
+ GlStateManager.disableLighting();
+
+ boolean horzFlip = false;
+ boolean vertFlip = false;
+
+ if (index == leftIndex) {
+ vertFlip = true;
+ } else if (index == downIndex) {
+ vertFlip = true;
+ }
+
+ GlStateManager.enableDepth();
+ Utils.drawTexturedRect(0, -9, 8, 18,
+ !horzFlip ? 209 / 227f : 219 / 227f, horzFlip ? 227 / 227f : 217 / 227f,
+ !vertFlip ? 57 / 75f : 75f / 75f, vertFlip ? 57 / 75f : 75f / 75f, GL11.GL_NEAREST
+ );
+ GlStateManager.translate(0, 0, 120);
+ Utils.drawTexturedRect(8, -9, 10, 18,
+ !horzFlip ? 217 / 227f : 209 / 227f, horzFlip ? 219 / 227f : 227 / 227f,
+ !vertFlip ? 57 / 75f : 75f / 75f, vertFlip ? 57 / 75f : 75f / 75f, GL11.GL_NEAREST
+ );
+ GlStateManager.translate(0, 0, -120);
+
+ GlStateManager.popMatrix();
+ }
+ }
+ }
+
+ if (hasConnection) {
+ page.shouldDarkenIfNotSelected[k] = false;
+
+ GlStateManager.disableAlpha();
+ GlStateManager.translate(0, 0, 10);
+ Gui.drawRect(itemX - 1, itemY - 1, itemX + 17, itemY + 17, 0x01000000);
+ GlStateManager.translate(0, 0, -10);
+ GlStateManager.enableAlpha();
+ }
+ }
+ }
+ }
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(storageTexture);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(
+ storageX,
+ storageY,
+ storageW,
+ storageH,
+ 0,
+ 162 / 600f,
+ 265 / 400f,
+ (265 + storageH) / 400f,
+ GL11.GL_NEAREST
+ );
+
+ boolean whiteOverlay = false;
+
+ for (int k = 0; k < rows * 9; k++) {
+ ItemStack stack = page.items[k];
+ int itemX = storageX + 1 + 18 * (k % 9);
+ int itemY = storageY + 1 + 18 * (k / 9);
+
+ if (!searchBar.getText().isEmpty()) {
+ if (stack == null || !NotEnoughUpdates.INSTANCE.manager.doesStackMatchSearch(stack, searchBar.getText())) {
+ GlStateManager.disableDepth();
+ Gui.drawRect(itemX, itemY, itemX + 16, itemY + 16, 0x80000000);
+ GlStateManager.enableDepth();
+ }
+ }
+
+ GlStateManager.disableLighting();
+
+ if (mouseInsideStorages && mouseX >= guiLeft + itemX && mouseX < guiLeft + itemX + 18 &&
+ mouseY >= guiTop + itemY && mouseY < guiTop + itemY + 18) {
+ boolean allowHover = NotEnoughUpdates.INSTANCE.config.storageGUI.fancyPanes != 1 || !hasCaches ||
+ isPaneCaches[storageId][k] <= 0;
+
+ if (storageId != StorageManager.getInstance().getCurrentPageId()) {
+ hoveringOtherBackpack = true;
+ whiteOverlay = stackOnMouse == null;
+ } else if (stack == null || allowHover) {
+ itemHoverX = itemX;
+ itemHoverY = itemY;
+ }
+
+ if (stack != null && allowHover) {
+ tooltipToDisplay = stack.getTooltip(
+ Minecraft.getMinecraft().thePlayer,
+ Minecraft.getMinecraft().gameSettings.advancedItemTooltips
+ );
+ }
+ }
+ }
+
+ GlStateManager.disableDepth();
+ if (storageId == currentPage) {
+ if (isPaneCaches[storageId] != null && isPaneCaches[storageId].length == rows * 9 &&
+ ctmIndexCaches[storageId] != null && ctmIndexCaches[storageId].length == rows * 9) {
+ int[] isPaneCache = isPaneCaches[storageId];
+
+ int borderStartY = 0;
+ int borderEndY = storageH;
+ int borderStartX = 0;
+ int borderEndX = storageW;
+
+ boolean allChroma = true;
+ for (int y = 0; y < page.rows; y++) {
+ for (int x = 0; x < 9; x++) {
+ int index = x + y * 9;
+ if (isPaneCache[index] != 17) {
+ allChroma = false;
+ break;
+ }
+ }
+ }
+
+ out:
+ for (int y = 0; y < page.rows; y++) {
+ for (int x = 0; x < 9; x++) {
+ int index = x + y * 9;
+ if (isPaneCache[index] <= 0 && !shouldLimitBorder[index]) {
+ borderStartY = y * 18;
+ break out;
+ }
+ }
+ }
+ out:
+ for (int y = page.rows - 1; y >= 0; y--) {
+ for (int x = 0; x < 9; x++) {
+ int index = x + y * 9;
+ if (isPaneCache[index] <= 0 && !shouldLimitBorder[index]) {
+ borderEndY = y * 18 + 18; //Bottom
+ break out;
+ }
+ }
+ }
+ out:
+ for (int x = 0; x < 9; x++) {
+ for (int y = 0; y < page.rows; y++) {
+ int index = x + y * 9;
+ if (isPaneCache[index] <= 0 && !shouldLimitBorder[index]) {
+ borderStartX = x * 18;
+ break out;
+ }
+ }
+ }
+ out:
+ for (int x = 8; x >= 0; x--) {
+ for (int y = 0; y < page.rows; y++) {
+ int index = x + y * 9;
+ if (isPaneCache[index] <= 0 && !shouldLimitBorder[index]) {
+ borderEndX = x * 18 + 18; //Bottom
+ break out;
+ }
+ }
+ }
+ int borderColour =
+ ChromaColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedStorageColour);
+ Gui.drawRect(
+ storageX + borderStartX + 1,
+ storageY + borderStartY,
+ storageX + borderStartX,
+ storageY + borderEndY,
+ borderColour
+ ); //Left
+ Gui.drawRect(
+ storageX + borderEndX - 1,
+ storageY + borderStartY,
+ storageX + borderEndX,
+ storageY + borderEndY,
+ borderColour
+ ); //Right
+ Gui.drawRect(
+ storageX + borderStartX,
+ storageY + borderStartY,
+ storageX + borderEndX,
+ storageY + borderStartY + 1,
+ borderColour
+ ); //Top
+ Gui.drawRect(
+ storageX + borderStartX,
+ storageY + borderEndY - 1,
+ storageX + borderEndX,
+ storageY + borderEndY,
+ borderColour
+ ); //Bottom
+
+ if (allChroma) {
+ ResourceLocation loc;
+ if (rollIndex < NOT_RICKROLL_SEQ.length) {
+ loc = NOT_RICKROLL_SEQ[rollIndex];
+ } else {
+ loc = NOT_RICKROLL_SEQ[NOT_RICKROLL_SEQ.length * 2 - rollIndex - 1];
+ }
+ Minecraft.getMinecraft().getTextureManager().bindTexture(loc);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(storageX, storageY, storageW, storageH, GL11.GL_LINEAR);
+ }
+ } else {
+ int borderColour =
+ ChromaColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedStorageColour);
+ Gui.drawRect(storageX + 1, storageY, storageX, storageY + storageH, borderColour); //Left
+ Gui.drawRect(
+ storageX + storageW - 1,
+ storageY,
+ storageX + storageW,
+ storageY + storageH,
+ borderColour
+ ); //Right
+ Gui.drawRect(storageX, storageY - 1, storageX + storageW, storageY, borderColour); //Top
+ Gui.drawRect(
+ storageX,
+ storageY + storageH - 1,
+ storageX + storageW,
+ storageY + storageH,
+ borderColour
+ ); //Bottom
+ }
+ } else if (currentTime - StorageManager.getInstance().storageOpenSwitchMillis < 1000 &&
+ StorageManager.getInstance().desiredStoragePage == storageId &&
+ StorageManager.getInstance().getCurrentPageId() != storageId) {
+ Gui.drawRect(storageX, storageY, storageX + storageW, storageY + storageH, 0x30000000);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(LOAD_CIRCLE_SEQ[loadCircleIndex]);
+ GlStateManager.color(loadCircleColour.getRed() / 255f, loadCircleColour.getGreen() / 255f,
+ loadCircleColour.getBlue() / 255f, 1
+ );
+
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(storageX + storageW / 2, storageY + storageH / 2, 0);
+ GlStateManager.rotate(loadCircleRotation, 0, 0, 1);
+ Utils.drawTexturedRect(-10, -10, 20, 20, GL11.GL_LINEAR);
+ GlStateManager.popMatrix();
+ } else if (whiteOverlay) {
+ Gui.drawRect(storageX, storageY, storageX + storageW, storageY + storageH, 0x80ffffff);
+ } else {
+ if (page.rows <= 0) {
+ Gui.drawRect(storageX, storageY, storageX + storageW, storageY + storageH, 0x40000000);
+ } else {
+ for (int i = 0; i < page.rows * 9; i++) {
+ if (page.items[i] == null || page.shouldDarkenIfNotSelected[i]) {
+ int x = storageX + 18 * (i % 9);
+ int y = storageY + 18 * (i / 9);
+ Gui.drawRect(x, y, x + 18, y + 18, 0x40000000);
+ }
+ }
+ }
+ }
+
+ if (StorageManager.getInstance().desiredStoragePage == storageId &&
+ StorageManager.getInstance().onStorageMenu) {
+ Utils.drawStringCenteredScaledMaxWidth("Please click again to load...", fontRendererObj,
+ storageX + 81 - 1, storageY + storageH / 2 - 5, false, 150, 0x111111
+ );
+ Utils.drawStringCenteredScaledMaxWidth("Please click again to load...", fontRendererObj,
+ storageX + 81 + 1, storageY + storageH / 2 - 5, false, 150, 0x111111
+ );
+ Utils.drawStringCenteredScaledMaxWidth("Please click again to load...", fontRendererObj,
+ storageX + 81, storageY + storageH / 2 - 5 - 1, false, 150, 0x111111
+ );
+ Utils.drawStringCenteredScaledMaxWidth("Please click again to load...", fontRendererObj,
+ storageX + 81, storageY + storageH / 2 - 5 + 1, false, 150, 0x111111
+ );
+ Utils.drawStringCenteredScaledMaxWidth("Please click again to load...", fontRendererObj,
+ storageX + 81, storageY + storageH / 2 - 5, false, 150, 0xffdf00
+ );
+
+ Utils.drawStringCenteredScaledMaxWidth("Use /neustwhy for more info", fontRendererObj,
+ storageX + 81 - 1, storageY + storageH / 2 + 5, false, 150, 0x111111
+ );
+ Utils.drawStringCenteredScaledMaxWidth("Use /neustwhy for more info", fontRendererObj,
+ storageX + 81 + 1, storageY + storageH / 2 + 5, false, 150, 0x111111
+ );
+ Utils.drawStringCenteredScaledMaxWidth("Use /neustwhy for more info", fontRendererObj,
+ storageX + 81, storageY + storageH / 2 + 5 - 1, false, 150, 0x111111
+ );
+ Utils.drawStringCenteredScaledMaxWidth("Use /neustwhy for more info", fontRendererObj,
+ storageX + 81, storageY + storageH / 2 + 5 + 1, false, 150, 0x111111
+ );
+ Utils.drawStringCenteredScaledMaxWidth("Use /neustwhy for more info", fontRendererObj,
+ storageX + 81, storageY + storageH / 2 + 5, false, 150, 0xffdf00
+ );
+ }
+
+ GlStateManager.enableDepth();
+ }
+ }
+ GlScissorStack.pop(scaledResolution);
+
+ if (fastRender) {
+ fontRendererObj.drawString(
+ "Fast render does not work with Storage overlay.",
+ sizeX / 2 - fontRendererObj.getStringWidth("Fast render does not work with Storage overlay.") / 2,
+ -10,
+ 0xFFFF0000
+ );
+ }
+
+ //Inventory Text
+ fontRendererObj.drawString("Inventory", 180, storageViewSize + 6, textColour);
+ searchBar.setCustomTextColour(searchTextColour);
+ searchBar.render(252, storageViewSize + 5);
+
+ //Player Inventory
+ ItemStack[] playerItems = Minecraft.getMinecraft().thePlayer.inventory.mainInventory;
+ int inventoryStartIndex = containerChest.getLowerChestInventory().getSizeInventory();
+ GlStateManager.enableDepth();
+ for (int i = 0; i < 9; i++) {
+ int itemX = 181 + 18 * i;
+ int itemY = storageViewSize + 76;
+
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(181 - 8, storageViewSize + 18 - (inventoryStartIndex / 9 * 18 + 31), 0);
+ guiChest.drawSlot(containerChest.inventorySlots.get(inventoryStartIndex + i));
+ GlStateManager.popMatrix();
+
+ if (!searchBar.getText().isEmpty()) {
+ if (playerItems[i] == null || !NotEnoughUpdates.INSTANCE.manager.doesStackMatchSearch(
+ playerItems[i],
+ searchBar.getText()
+ )) {
+ GlStateManager.disableDepth();
+ Gui.drawRect(itemX, itemY, itemX + 16, itemY + 16, 0x80000000);
+ GlStateManager.enableDepth();
+ }
+ }
+
+ if (mouseX >= guiLeft + itemX && mouseX < guiLeft + itemX + 18 && mouseY >= guiTop + itemY &&
+ mouseY < guiTop + itemY + 18) {
+ itemHoverX = itemX;
+ itemHoverY = itemY;
+
+ if (playerItems[i] != null) {
+ tooltipToDisplay = playerItems[i].getTooltip(
+ Minecraft.getMinecraft().thePlayer,
+ Minecraft.getMinecraft().gameSettings.advancedItemTooltips
+ );
+ }
+ }
+ }
+ for (int i = 0; i < 27; i++) {
+ int itemX = 181 + 18 * (i % 9);
+ int itemY = storageViewSize + 18 + 18 * (i / 9);
+
+ //Utils.drawItemStack(playerItems[i+9], itemX, itemY);
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(181 - 8, storageViewSize + 18 - (inventoryStartIndex / 9 * 18 + 31), 0);
+ guiChest.drawSlot(containerChest.inventorySlots.get(inventoryStartIndex + 9 + i));
+ GlStateManager.popMatrix();
+
+ if (!searchBar.getText().isEmpty()) {
+ if (playerItems[i + 9] == null || !NotEnoughUpdates.INSTANCE.manager.doesStackMatchSearch(
+ playerItems[i + 9],
+ searchBar.getText()
+ )) {
+ GlStateManager.disableDepth();
+ Gui.drawRect(itemX, itemY, itemX + 16, itemY + 16, 0x80000000);
+ GlStateManager.enableDepth();
+ }
+ }
+
+ if (mouseX >= guiLeft + itemX && mouseX < guiLeft + itemX + 18 && mouseY >= guiTop + itemY &&
+ mouseY < guiTop + itemY + 18) {
+ itemHoverX = itemX;
+ itemHoverY = itemY;
+
+ if (playerItems[i + 9] != null) {
+ tooltipToDisplay = playerItems[i + 9].getTooltip(
+ Minecraft.getMinecraft().thePlayer,
+ Minecraft.getMinecraft().gameSettings.advancedItemTooltips
+ );
+ }
+ }
+ }
+
+ //Backpack Selector
+ fontRendererObj.drawString("Ender Chest Pages", 9, storageViewSize + 12, textColour);
+ fontRendererObj.drawString("Storage Pages", 9, storageViewSize + 44, textColour);
+ if (StorageManager.getInstance().onStorageMenu) {
+ for (int i = 0; i < 9; i++) {
+ int itemX = 10 + i * 18;
+ int itemY = storageViewSize + 24;
+ ItemStack stack = containerChest.getLowerChestInventory().getStackInSlot(i + 9);
+ Utils.drawItemStack(stack, itemX, itemY);
+
+ if (mouseX >= guiLeft + itemX && mouseX < guiLeft + itemX + 18 && mouseY >= guiTop + itemY &&
+ mouseY < guiTop + itemY + 18) {
+ itemHoverX = itemX;
+ itemHoverY = itemY;
+
+ if (stack != null) {
+ if (NotEnoughUpdates.INSTANCE.config.storageGUI.enderchestPreview) slotPreview = i;
+ tooltipToDisplay = stack.getTooltip(
+ Minecraft.getMinecraft().thePlayer,
+ Minecraft.getMinecraft().gameSettings.advancedItemTooltips
+ );
+ }
+ }
+ }
+ for (int i = 0; i < 18; i++) {
+ int itemX = 10 + 18 * (i % 9);
+ int itemY = storageViewSize + 56 + 18 * (i / 9);
+ ItemStack stack = containerChest.getLowerChestInventory().getStackInSlot(i + 27);
+ Utils.drawItemStack(stack, itemX, itemY);
+
+ if (mouseX >= guiLeft + itemX && mouseX < guiLeft + itemX + 18 && mouseY >= guiTop + itemY &&
+ mouseY < guiTop + itemY + 18) {
+ itemHoverX = itemX;
+ itemHoverY = itemY;
+
+ if (stack != null) {
+ if (NotEnoughUpdates.INSTANCE.config.storageGUI.backpackPreview)
+ slotPreview = i + StorageManager.MAX_ENDER_CHEST_PAGES;
+ tooltipToDisplay = stack.getTooltip(
+ Minecraft.getMinecraft().thePlayer,
+ Minecraft.getMinecraft().gameSettings.advancedItemTooltips
+ );
+ }
+ }
+ }
+ } else {
+ for (int i = 0; i < 9; i++) {
+ StorageManager.StoragePage page = StorageManager.getInstance().getPage(i, false);
+ int itemX = 10 + (i % 9) * 18;
+ int itemY = storageViewSize + 24 + (i / 9) * 18;
+
+ ItemStack stack;
+ if (page != null && page.backpackDisplayStack != null) {
+ stack = page.backpackDisplayStack;
+ } else {
+ stack = StorageManager.LOCKED_ENDERCHEST_STACK;
+ }
+
+ if (stack != null) {
+ Utils.drawItemStack(stack, itemX, itemY);
+
+ if (mouseX >= guiLeft + itemX && mouseX < guiLeft + itemX + 18 && mouseY >= guiTop + itemY &&
+ mouseY < guiTop + itemY + 18) {
+ itemHoverX = itemX;
+ itemHoverY = itemY;
+ if (NotEnoughUpdates.INSTANCE.config.storageGUI.enderchestPreview) slotPreview = i;
+ tooltipToDisplay = stack.getTooltip(
+ Minecraft.getMinecraft().thePlayer,
+ Minecraft.getMinecraft().gameSettings.advancedItemTooltips
+ );
+ }
+ }
+ }
+ for (int i = 0; i < 18; i++) {
+ StorageManager.StoragePage page = StorageManager.getInstance().getPage(
+ i + StorageManager.MAX_ENDER_CHEST_PAGES,
+ false
+ );
+ int itemX = 10 + (i % 9) * 18;
+ int itemY = storageViewSize + 56 + (i / 9) * 18;
+
+ ItemStack stack;
+ if (page != null && page.backpackDisplayStack != null) {
+ stack = page.backpackDisplayStack;
+ } else {
+ stack = StorageManager.getInstance().getMissingBackpackStack(i);
+ }
+
+ if (stack != null) {
+ Utils.drawItemStack(stack, itemX, itemY);
+
+ if (mouseX >= guiLeft + itemX && mouseX < guiLeft + itemX + 18 && mouseY >= guiTop + itemY &&
+ mouseY < guiTop + itemY + 18) {
+ itemHoverX = itemX;
+ itemHoverY = itemY;
+ if (NotEnoughUpdates.INSTANCE.config.storageGUI.backpackPreview)
+ slotPreview = i + StorageManager.MAX_ENDER_CHEST_PAGES;
+ tooltipToDisplay = stack.getTooltip(
+ Minecraft.getMinecraft().thePlayer,
+ Minecraft.getMinecraft().gameSettings.advancedItemTooltips
+ );
+
+ if (!StorageManager.getInstance().onStorageMenu) {
+ List<String> tooltip = new ArrayList<>();
+ for (String line : tooltipToDisplay) {
+ tooltip.add(line.replace("Right-click to remove", "Click \"Edit\" to manage"));
+ }
+ tooltipToDisplay = tooltip;
+ }
+ }
+ }
+ }
+ }
+
+ //Buttons
+ Minecraft.getMinecraft().getTextureManager().bindTexture(STORAGE_ICONS_TEXTURE);
+ GlStateManager.color(1, 1, 1, 1);
+ for (int i = 0; i < 10; i++) {
+ int buttonX = 388 + (i % 5) * 18;
+ int buttonY = getStorageViewSize() + 35 + (i / 5) * 18;
+
+ float minU = (i * 16) / 256f;
+ float maxU = (i * 16 + 16) / 256f;
+
+ int vIndex = 0;
+
+ switch (i) {
+ case 2:
+ vIndex = NotEnoughUpdates.INSTANCE.config.storageGUI.displayStyle;
+ break;
+ case 3:
+ vIndex = NotEnoughUpdates.INSTANCE.config.storageGUI.backpackPreview ? 1 : 0;
+ break;
+ case 4:
+ vIndex = NotEnoughUpdates.INSTANCE.config.storageGUI.enderchestPreview ? 1 : 0;
+ break;
+ case 5:
+ vIndex = NotEnoughUpdates.INSTANCE.config.storageGUI.masonryMode ? 1 : 0;
+ break;
+ case 6:
+ vIndex = NotEnoughUpdates.INSTANCE.config.storageGUI.fancyPanes == 2
+ ? 0
+ : NotEnoughUpdates.INSTANCE.config.storageGUI.fancyPanes + 1;
+ break;
+ case 7:
+ vIndex = NotEnoughUpdates.INSTANCE.config.storageGUI.searchBarAutofocus ? 1 : 0;
+ break;
+ case 8:
+ vIndex = NotEnoughUpdates.INSTANCE.config.storageGUI.showEnchantGlint ? 1 : 0;
+ break;
+ }
+
+ Utils.drawTexturedRect(
+ buttonX,
+ buttonY,
+ 16,
+ 16,
+ minU,
+ maxU,
+ (vIndex * 16) / 256f,
+ (vIndex * 16 + 16) / 256f,
+ GL11.GL_NEAREST
+ );
+
+ if (mouseX >= guiLeft + buttonX && mouseX < guiLeft + buttonX + 18 &&
+ mouseY >= guiTop + buttonY && mouseY < guiTop + buttonY + 18) {
+ switch (i) {
+ case 0:
+ tooltipToDisplay = createTooltip(
+ "Enable GUI",
+ 0,
+ "On",
+ "Off"
+ );
+ break;
+ case 1:
+ int tooltipStorageHeight = desiredHeightSwitch != -1 ? desiredHeightSwitch :
+ NotEnoughUpdates.INSTANCE.config.storageGUI.storageHeight;
+ tooltipToDisplay = createTooltip(
+ "Storage View Height",
+ Math.round((tooltipStorageHeight - 104) / 52f),
+ "Tiny",
+ "Small",
+ "Medium",
+ "Large",
+ "Huge"
+ );
+ if (desiredHeightSwitch != -1) {
+ tooltipToDisplay.add("");
+ tooltipToDisplay.add(EnumChatFormatting.YELLOW + "* Move mouse to apply changes *");
+ }
+ break;
+ case 2:
+ tooltipToDisplay = createTooltip(
+ "Overlay Style",
+ NotEnoughUpdates.INSTANCE.config.storageGUI.displayStyle,
+ "Transparent",
+ "Minecraft",
+ "Dark",
+ "Custom"
+ );
+ break;
+ case 3:
+ tooltipToDisplay = createTooltip(
+ "Backpack Preview",
+ NotEnoughUpdates.INSTANCE.config.storageGUI.backpackPreview ? 0 : 1,
+ "On",
+ "Off"
+ );
+ break;
+ case 4:
+ tooltipToDisplay = createTooltip(
+ "Enderchest Preview",
+ NotEnoughUpdates.INSTANCE.config.storageGUI.enderchestPreview ? 0 : 1,
+ "On",
+ "Off"
+ );
+ break;
+ case 5:
+ tooltipToDisplay = createTooltip(
+ "Compact Vertically",
+ NotEnoughUpdates.INSTANCE.config.storageGUI.masonryMode ? 0 : 1,
+ "On",
+ "Off"
+ );
+ break;
+ case 6:
+ tooltipToDisplay = createTooltip(
+ "Fancy Glass Panes",
+ NotEnoughUpdates.INSTANCE.config.storageGUI.fancyPanes,
+ "On",
+ "Locked",
+ "Off"
+ );
+ tooltipToDisplay.add(1, "\u00a7eReplace the glass pane textures");
+ tooltipToDisplay.add(2, "\u00a7ein your storage containers with");
+ tooltipToDisplay.add(3, "\u00a7ea fancy connected texture");
+ break;
+ case 7:
+ tooltipToDisplay = createTooltip(
+ "Search Bar Autofocus",
+ NotEnoughUpdates.INSTANCE.config.storageGUI.searchBarAutofocus ? 0 : 1,
+ "On",
+ "Off"
+ );
+ break;
+ case 8:
+ tooltipToDisplay = createTooltip(
+ "Show Enchant Glint",
+ NotEnoughUpdates.INSTANCE.config.storageGUI.showEnchantGlint ? 0 : 1,
+ "On",
+ "Off"
+ );
+ break;
+ case 9:
+ tooltipToDisplay = createTooltip(
+ "Open Full Settings",
+ 0,
+ "Click To Open"
+ );
+ break;
+ }
+ }
+ }
+
+ if (!StorageManager.getInstance().onStorageMenu) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(storageTexture);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(
+ 171 - 36,
+ 41 + storageViewSize,
+ 36,
+ 14,
+ 24 / 600f,
+ 60 / 600f,
+ 251 / 400f,
+ 265 / 400f,
+ GL11.GL_NEAREST
+ );
+ }
+
+ if (itemHoverX >= 0 && itemHoverY >= 0) {
+ GlStateManager.disableDepth();
+ GlStateManager.colorMask(true, true, true, false);
+ Gui.drawRect(itemHoverX, itemHoverY, itemHoverX + 16, itemHoverY + 16, 0x80ffffff);
+ GlStateManager.colorMask(true, true, true, true);
+ GlStateManager.enableDepth();
+ }
+
+ GlStateManager.popMatrix();
+ GlStateManager.translate(0, 0, 300);
+ allowTypingInSearchBar = false;
+ if (stackOnMouse != null) {
+ GlStateManager.enableDepth();
+ if (hoveringOtherBackpack) {
+ Utils.drawItemStack(new ItemStack(Item.getItemFromBlock(Blocks.barrier)), mouseX - 8, mouseY - 8);
+ } else {
+ Utils.drawItemStack(stackOnMouse, mouseX - 8, mouseY - 8);
+ }
+ } else if (slotPreview >= 0) {
+ StorageManager.StoragePage page = StorageManager.getInstance().getPage(slotPreview, false);
+ if (page != null && page.rows > 0) {
+ int rows = page.rows;
+
+ GlStateManager.translate(0, 0, 100);
+ GlStateManager.disableDepth();
+ BackgroundBlur.renderBlurredBackground(7, width, height, mouseX + 2, mouseY + 2, 172, 10 + 18 * rows);
+ Utils.drawGradientRect(mouseX + 2, mouseY + 2, mouseX + 174, mouseY + 12 + 18 * rows, 0xc0101010, 0xd0101010);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(storagePreviewTexture);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(mouseX, mouseY, 176, 7, 0, 1, 0, 7 / 32f, GL11.GL_NEAREST);
+ for (int i = 0; i < rows; i++) {
+ Utils.drawTexturedRect(mouseX, mouseY + 7 + 18 * i, 176, 18, 0, 1, 7 / 32f, 25 / 32f, GL11.GL_NEAREST);
+ }
+ Utils.drawTexturedRect(mouseX, mouseY + 7 + 18 * rows, 176, 7, 0, 1, 25 / 32f, 1, GL11.GL_NEAREST);
+ GlStateManager.enableDepth();
+
+ for (int i = 0; i < rows * 9; i++) {
+ ItemStack stack = page.items[i];
+ if (stack != null) {
+ GlStateManager.enableDepth();
+ Utils.drawItemStack(stack, mouseX + 8 + 18 * (i % 9), mouseY + 8 + 18 * (i / 9));
+ GlStateManager.disableDepth();
+ }
+ }
+ GlStateManager.translate(0, 0, -100);
+ } else {
+ Utils.drawHoveringText(
+ tooltipToDisplay,
+ mouseX,
+ mouseY,
+ width,
+ height,
+ -1,
+ Minecraft.getMinecraft().fontRendererObj
+ );
+ }
+ } else if (tooltipToDisplay != null) {
+ Utils.drawHoveringText(
+ tooltipToDisplay,
+ mouseX,
+ mouseY,
+ width,
+ height,
+ -1,
+ Minecraft.getMinecraft().fontRendererObj
+ );
+ } else {
+ allowTypingInSearchBar = true;
+ }
+ GlStateManager.translate(0, 0, -300);
+ }
+
+ private static boolean shouldConnect(int paneIndex1, int paneIndex2) {
+ if (paneIndex1 == 16 || paneIndex2 == 16) return false;
+ if (paneIndex1 < 1 || paneIndex2 < 1) return false;
+ return paneIndex1 == paneIndex2;
+
+ }
+
+ public static int getCTMIndex(StorageManager.StoragePage page, int index, int[] isPaneCache, int[] ctmIndexCache) {
+ if (page.items[index] == null) {
+ ctmIndexCache[index] = -1;
+ return -1;
+ }
+
+ int paneType = getPaneType(page.items[index], index, isPaneCache);
+
+ int upIndex = index - 9;
+ int leftIndex = index % 9 > 0 ? index - 1 : -1;
+ int rightIndex = index % 9 < 8 ? index + 1 : -1;
+ int downIndex = index + 9;
+ int upleftIndex = index % 9 > 0 ? index - 10 : -1;
+ int uprightIndex = index % 9 < 8 ? index - 8 : -1;
+ int downleftIndex = index % 9 > 0 ? index + 8 : -1;
+ int downrightIndex = index % 9 < 8 ? index + 10 : -1;
+
+ boolean up = upIndex >= 0 && upIndex < isPaneCache.length && shouldConnect(getPaneType(
+ page.items[upIndex],
+ upIndex,
+ isPaneCache
+ ), paneType);
+ boolean left = leftIndex >= 0 && leftIndex < isPaneCache.length && shouldConnect(getPaneType(
+ page.items[leftIndex],
+ leftIndex,
+ isPaneCache
+ ), paneType);
+ boolean down = downIndex >= 0 && downIndex < isPaneCache.length && shouldConnect(getPaneType(
+ page.items[downIndex],
+ downIndex,
+ isPaneCache
+ ), paneType);
+ boolean right = rightIndex >= 0 && rightIndex < isPaneCache.length && shouldConnect(getPaneType(
+ page.items[rightIndex],
+ rightIndex,
+ isPaneCache
+ ), paneType);
+ boolean upleft = upleftIndex >= 0 && upleftIndex < isPaneCache.length && shouldConnect(getPaneType(
+ page.items[upleftIndex],
+ upleftIndex,
+ isPaneCache
+ ), paneType);
+ boolean upright = uprightIndex >= 0 && uprightIndex < isPaneCache.length && shouldConnect(getPaneType(
+ page.items[uprightIndex],
+ uprightIndex,
+ isPaneCache
+ ), paneType);
+ boolean downleft = downleftIndex >= 0 && downleftIndex < isPaneCache.length && shouldConnect(getPaneType(
+ page.items[downleftIndex],
+ downleftIndex,
+ isPaneCache
+ ), paneType);
+ boolean downright = downrightIndex >= 0 && downrightIndex < isPaneCache.length &&
+ shouldConnect(getPaneType(page.items[downrightIndex], downrightIndex, isPaneCache), paneType);
+
+ int ctmIndex = BetterContainers.getCTMIndex(up, right, down, left, upleft, upright, downright, downleft);
+ ctmIndexCache[index] = ctmIndex;
+ return ctmIndex;
+ }
+
+ private static final String CHROMA_STR = "230:255:255:0:0";
+
+ public static int getRGBFromPane(int paneType) {
+ int rgb = -1;
+ EnumChatFormatting formatting = EnumChatFormatting.WHITE;
+ switch (paneType) {
+ case 0:
+ formatting = EnumChatFormatting.WHITE;
+ break;
+ case 1:
+ formatting = EnumChatFormatting.GOLD;
+ break;
+ case 2:
+ formatting = EnumChatFormatting.LIGHT_PURPLE;
+ break;
+ case 3:
+ formatting = EnumChatFormatting.BLUE;
+ break;
+ case 4:
+ formatting = EnumChatFormatting.YELLOW;
+ break;
+ case 5:
+ formatting = EnumChatFormatting.GREEN;
+ break;
+ case 6:
+ rgb = 0xfff03c96;
+ break;
+ case 7:
+ formatting = EnumChatFormatting.DARK_GRAY;
+ break;
+ case 8:
+ formatting = EnumChatFormatting.GRAY;
+ break;
+ case 9:
+ formatting = EnumChatFormatting.DARK_AQUA;
+ break;
+ case 10:
+ formatting = EnumChatFormatting.DARK_PURPLE;
+ break;
+ case 11:
+ formatting = EnumChatFormatting.DARK_BLUE;
+ break;
+ case 12:
+ rgb = 0xffA0522D;
+ break;
+ case 13:
+ formatting = EnumChatFormatting.DARK_GREEN;
+ break;
+ case 14:
+ formatting = EnumChatFormatting.DARK_RED;
+ break;
+ case 15:
+ rgb = 0x00000000;
+ break;
+ case 16:
+ rgb = SpecialColour.specialToChromaRGB(CHROMA_STR);
+ break;
+ }
+ if (rgb != -1) return rgb;
+ return 0xff000000 | Minecraft.getMinecraft().fontRendererObj.getColorCode(formatting.toString().charAt(1));
+ }
+
+ public static int getPaneType(ItemStack stack, int index, int[] cache) {
+ if (cache != null && cache[index] != 0) return cache[index];
+
+ if (NotEnoughUpdates.INSTANCE.config.storageGUI.fancyPanes == 2) {
+ if (cache != null) cache[index] = -1;
+ return -1;
+ }
+
+ if (stack != null &&
+ (stack.getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) || stack.getItem() == Item.getItemFromBlock(
+ Blocks.glass_pane))) {
+ String internalName = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack);
+ if (internalName != null) {
+ if (internalName.startsWith("STAINED_GLASS_PANE")) {
+ if (cache != null) cache[index] = stack.getItemDamage() + 1;
+ return stack.getItemDamage() + 1;
+ } else if (internalName.startsWith("THIN_GLASS")) {
+ if (cache != null) cache[index] = 17;
+ return 17;
+ }
+ }
+ }
+ if (cache != null) cache[index] = -1;
+ return -1;
+ }
+
+ private List<String> createTooltip(String title, int selectedOption, String... options) {
+ String selPrefix = EnumChatFormatting.DARK_AQUA + " \u25b6 ";
+ String unselPrefix = EnumChatFormatting.GRAY.toString();
+
+ for (int i = 0; i < options.length; i++) {
+ if (i == selectedOption) {
+ options[i] = selPrefix + options[i];
+ } else {
+ options[i] = unselPrefix + options[i];
+ }
+ }
+
+ List<String> list = Lists.newArrayList(options);
+ list.add(0, "");
+ list.add(0, EnumChatFormatting.GREEN + title);
+ return list;
+ }
+
+ private static class IntPair {
+ int x;
+ int y;
+
+ public IntPair(int x, int y) {
+ this.x = x;
+ this.y = y;
+ }
+ }
+
+ public IntPair getPageCoords(int displayId) {
+ if (displayId < 0) displayId = 0;
+
+ int y;
+ if (NotEnoughUpdates.INSTANCE.config.storageGUI.masonryMode) {
+ y = -scroll.getValue() + 18 + 108 * (displayId / 3);
+ } else {
+ y = -scroll.getValue() + 17 + 104 * (displayId / 3);
+ }
+ for (int i = 0; i <= displayId - 3; i += 3) {
+ int maxRows = 1;
+ for (int j = i; j < i + 3; j++) {
+ if (NotEnoughUpdates.INSTANCE.config.storageGUI.masonryMode && displayId % 3 != j % 3) continue;
+
+ if (!StorageManager.getInstance().storageConfig.displayToStorageIdMapRender.containsKey(j)) {
+ continue;
+ }
+ int storageId = StorageManager.getInstance().storageConfig.displayToStorageIdMapRender.get(j);
+ StorageManager.StoragePage page = StorageManager.getInstance().getPage(storageId, false);
+ if (page == null || page.rows <= 0) {
+ maxRows = Math.max(maxRows, 3);
+ } else {
+ maxRows = Math.max(maxRows, page.rows);
+ }
+ }
+ y -= (5 - maxRows) * 18;
+ }
+
+ return new IntPair(8 + 172 * (displayId % 3), y);
+ }
+
+ @Override
+ public boolean mouseInput(int mouseX, int mouseY) {
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) return false;
+
+ int dWheel = Mouse.getEventDWheel();
+ if (!(NotEnoughUpdates.INSTANCE.config.storageGUI.cancelScrollKey != 0 &&
+ KeybindHelper.isKeyDown(NotEnoughUpdates.INSTANCE.config.storageGUI.cancelScrollKey)) && dWheel != 0) {
+ if (dWheel < 0) {
+ dWheel = -1;
+ if (scrollVelocity > 0) scrollVelocity = 0;
+ }
+ if (dWheel > 0) {
+ dWheel = 1;
+ if (scrollVelocity < 0) scrollVelocity = 0;
+ }
+
+ long currentTime = System.currentTimeMillis();
+ if (currentTime - lastScroll > 200) {
+ scrollVelocity = 0;
+ } else {
+ scrollVelocity = (int) (scrollVelocity / 1.3f);
+ }
+ lastScroll = currentTime;
+
+ scrollVelocity += dWheel * 10;
+ scrollToY(scroll.getTarget() - scrollVelocity);
+
+ return true;
+ }
+
+ if (Mouse.getEventButtonState()) {
+ editingNameId = -1;
+ }
+
+ if (Mouse.getEventButton() == 0) {
+ if (!Mouse.getEventButtonState()) {
+ scrollGrabOffset = -1;
+ } else if (mouseX >= guiLeft + 519 && mouseX <= guiLeft + 519 + 14 &&
+ mouseY >= guiTop + 8 && mouseY <= guiTop + 2 + getStorageViewSize()) {
+ int scrollMouseY = mouseY - (guiTop + 8);
+ int scrollBarY = Math.round(getScrollBarHeight() * scroll.getValue() / (float) getMaximumScroll());
+
+ if (scrollMouseY >= scrollBarY && scrollMouseY < scrollBarY + 12) {
+ scrollGrabOffset = scrollMouseY - scrollBarY;
+ }
+ }
+ }
+ if (scrollGrabOffset >= 0 && Mouse.getEventButton() == -1 && !Mouse.getEventButtonState()) {
+ int scrollMouseY = mouseY - (guiTop + 8);
+ int scrollBarY = scrollMouseY - scrollGrabOffset;
+
+ scrollToY(Math.round(scrollBarY * getMaximumScroll() / (float) getScrollBarHeight()));
+ scroll.setTimeToReachTarget(10);
+ }
+
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ int width = scaledResolution.getScaledWidth();
+ int height = scaledResolution.getScaledHeight();
+
+ int storageViewSize = getStorageViewSize();
+
+ int sizeX = 540;
+ int sizeY = 100 + storageViewSize;
+ int searchNobX = 18;
+
+ guiLeft = width / 2 - (sizeX - searchNobX) / 2;
+ guiTop = height / 2 - sizeY / 2;
+
+ if (Mouse.getEventButtonState() && !StorageManager.getInstance().onStorageMenu) {
+ if (mouseX > guiLeft + 171 - 36 && mouseX < guiLeft + 171 &&
+ mouseY > guiTop + 41 + storageViewSize && mouseY < guiTop + 41 + storageViewSize + 14) {
+ NotEnoughUpdates.INSTANCE.sendChatMessage("/storage");
+ searchBar.setFocus(false);
+ return true;
+ }
+ }
+
+ if (Mouse.getEventButtonState()) {
+ if (mouseX >= guiLeft + 252 && mouseX <= guiLeft + 252 + searchBar.getWidth() &&
+ mouseY >= guiTop + storageViewSize + 5 && mouseY <= guiTop + storageViewSize + 5 + searchBar.getHeight()) {
+ if (searchBar.getFocus()) {
+ searchBar.mouseClicked(mouseX - guiLeft, mouseY - guiTop, Mouse.getEventButton());
+ StorageManager.getInstance().searchDisplay(searchBar.getText());
+ dirty = true;
+ } else {
+ searchBar.setFocus(true);
+ if (Mouse.getEventButton() == 1) {
+ searchBar.setText("");
+ StorageManager.getInstance().searchDisplay(searchBar.getText());
+ dirty = true;
+ }
+ }
+ } else {
+ searchBar.setFocus(false);
+ }
+ }
+
+ if (mouseX > guiLeft + 181 && mouseX < guiLeft + 181 + 162 &&
+ mouseY > guiTop + storageViewSize + 18 && mouseY < guiTop + storageViewSize + 94) {
+ if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))
+ dirty = true;
+ return false;
+ }
+
+ if (mouseY > guiTop + 3 && mouseY < guiTop + storageViewSize + 3) {
+ int currentPage = StorageManager.getInstance().getCurrentPageId();
+ for (Map.Entry<Integer, Integer> entry : StorageManager.getInstance().storageConfig.displayToStorageIdMapRender.entrySet()) {
+ IntPair pageCoords = getPageCoords(entry.getKey());
+
+ if (pageCoords.y > storageViewSize + 3 || pageCoords.y + 90 < 3) continue;
+
+ StorageManager.StoragePage page = StorageManager.getInstance().getPage(entry.getValue(), false);
+ int rows = page == null ? 3 : page.rows <= 0 ? 3 : page.rows;
+
+ if (page != null) {
+ String pageTitle;
+ if (page.customTitle != null && !page.customTitle.isEmpty()) {
+ pageTitle = page.customTitle;
+ } else if (entry.getValue() < 9) {
+ pageTitle = "Ender Chest Page " + (entry.getValue() + 1);
+ } else {
+ pageTitle = "Backpack Slot " + (entry.getValue() - 8);
+ }
+ int titleLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(pageTitle);
+
+ if (mouseX >= guiLeft + pageCoords.x && mouseX <= guiLeft + pageCoords.x + titleLen + 15 &&
+ mouseY >= guiTop + pageCoords.y - 14 && mouseY <= guiTop + pageCoords.y + 1) {
+ if (Mouse.getEventButtonState() && (Mouse.getEventButton() == 0 || Mouse.getEventButton() == 1)) {
+ if (editingNameId != entry.getValue()) {
+ editingNameId = entry.getValue();
+ if (!renameStorageField.getText().equalsIgnoreCase(pageTitle)) {
+ renameStorageField.setText(pageTitle);
+ }
+ }
+ if (!renameStorageField.getFocus()) {
+ renameStorageField.setFocus(true);
+ } else {
+ renameStorageField.mouseClicked(mouseX - guiLeft, mouseY - guiTop, Mouse.getEventButton());
+ }
+ } else if (Mouse.getEventButton() < 0 && Mouse.isButtonDown(0)) {
+ renameStorageField.mouseClickMove(mouseX - guiLeft, mouseY - guiTop, 0, 0);
+ }
+ return true;
+ }
+ }
+
+ if (mouseX > guiLeft + pageCoords.x && mouseX < guiLeft + pageCoords.x + 162 &&
+ mouseY > guiTop + pageCoords.y && mouseY < guiTop + pageCoords.y + rows * 18) {
+ if (currentPage >= 0 && entry.getValue() == currentPage) {
+ dirty = true;
+ return false;
+ } else {
+ if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0 &&
+ Minecraft.getMinecraft().thePlayer.inventory.getItemStack() == null &&
+ page != null) {
+ scrollToStorage(entry.getKey(), false);
+ StorageManager.getInstance().sendToPage(entry.getValue());
+ return true;
+ }
+ }
+ }
+ }
+ }
+
+ for (int i = 0; i < 10; i++) {
+ int buttonX = 388 + (i % 5) * 18;
+ int buttonY = getStorageViewSize() + 35 + (i / 5) * 18;
+
+ float minU = (i * 16) / 256f;
+ float maxU = (i * 16 + 16) / 256f;
+
+ int vIndex = 0;
+
+ switch (i) {
+ case 2:
+ vIndex = NotEnoughUpdates.INSTANCE.config.storageGUI.displayStyle;
+ break;
/*case 3:
vIndex = */
- }
-
- Utils.drawTexturedRect(buttonX, buttonY, 16, 16, minU, maxU, (vIndex*16)/256f, (vIndex*16+16)/256f, GL11.GL_NEAREST);
- }
- if(desiredHeightSwitch != -1 && Mouse.getEventButton() == -1 && !Mouse.getEventButtonState()) {
- int delta = Math.abs(desiredHeightMX - mouseX) + Math.abs(desiredHeightMY - mouseY);
- if(delta > 3) {
- NotEnoughUpdates.INSTANCE.config.storageGUI.storageHeight = desiredHeightSwitch;
- desiredHeightSwitch = -1;
- }
- }
- if(Mouse.getEventButtonState() && mouseX >= guiLeft+388 && mouseX < guiLeft+388+90 &&
- mouseY >= guiTop+storageViewSize+35 && mouseY < guiTop+storageViewSize+35+36) {
- int xN = mouseX - (guiLeft+388);
- int yN = mouseY - (guiTop+storageViewSize+35);
-
- int xIndex = xN/18;
- int yIndex = yN/18;
-
- int buttonIndex = xIndex + 5*yIndex;
-
- switch(buttonIndex) {
- case 0:
- NotEnoughUpdates.INSTANCE.config.storageGUI.enableStorageGUI3 = false; break;
- case 1:
- int size = desiredHeightSwitch != -1 ? desiredHeightSwitch : NotEnoughUpdates.INSTANCE.config.storageGUI.storageHeight;
- int sizeIndex = Math.round((size-104)/54f);
- if(Mouse.getEventButton() == 0) {
- sizeIndex--;
- } else {
- sizeIndex++;
- }
- size = sizeIndex*54+104;
- if(size < 104) size = 312;
- if(size > 320) size = 104;
- desiredHeightMX = mouseX;
- desiredHeightMY = mouseY;
- desiredHeightSwitch = size; break;
- case 2:
- int displayStyle = NotEnoughUpdates.INSTANCE.config.storageGUI.displayStyle;
- if(Mouse.getEventButton() == 0) {
- displayStyle++;
- } else {
- displayStyle--;
- }
- if(displayStyle < 0) displayStyle = STORAGE_TEXTURES.length-1;
- if(displayStyle >= STORAGE_TEXTURES.length) displayStyle = 0;
-
- NotEnoughUpdates.INSTANCE.config.storageGUI.displayStyle = displayStyle; break;
- case 3:
- NotEnoughUpdates.INSTANCE.config.storageGUI.backpackPreview =
- !NotEnoughUpdates.INSTANCE.config.storageGUI.backpackPreview; break;
- case 4:
- NotEnoughUpdates.INSTANCE.config.storageGUI.enderchestPreview =
- !NotEnoughUpdates.INSTANCE.config.storageGUI.enderchestPreview; break;
- case 5:
- NotEnoughUpdates.INSTANCE.config.storageGUI.masonryMode =
- !NotEnoughUpdates.INSTANCE.config.storageGUI.masonryMode; break;
- case 6:
- int fancyPanes = NotEnoughUpdates.INSTANCE.config.storageGUI.fancyPanes;
- if(Mouse.getEventButton() == 0) {
- fancyPanes++;
- } else {
- fancyPanes--;
- }
- if(fancyPanes < 0) fancyPanes = 2;
- if(fancyPanes >= 3) fancyPanes = 0;
-
- NotEnoughUpdates.INSTANCE.config.storageGUI.fancyPanes = fancyPanes; break;
- case 7:
- NotEnoughUpdates.INSTANCE.config.storageGUI.searchBarAutofocus =
- !NotEnoughUpdates.INSTANCE.config.storageGUI.searchBarAutofocus; break;
- }
- dirty = true;
- }
-
- if(mouseX >= guiLeft+10 && mouseX <= guiLeft+171 &&
- mouseY >= guiTop+storageViewSize+23 && mouseY <= guiTop+storageViewSize+91) {
- if(StorageManager.getInstance().onStorageMenu) {
- return false;
- } else if(Mouse.getEventButtonState() && Mouse.getEventButton() == 0) {
- for(int i=0; i<9; i++) {
- int storageId = i;
- int displayId = StorageManager.getInstance().getDisplayIdForStorageIdRender(i);
-
- StorageManager.StoragePage page = StorageManager.getInstance().getPage(storageId, false);
- if(page != null) {
- int itemX = 10+(i%9)*18;
- int itemY = storageViewSize+24+(i/9)*18;
-
- if(mouseX >= guiLeft+itemX && mouseX < guiLeft+itemX+18 &&
- mouseY >= guiTop+itemY && mouseY < guiTop+itemY+18) {
- StorageManager.getInstance().sendToPage(storageId);
- scrollToStorage(displayId, true);
- return true;
- }
- }
- }
- for(int i=0; i<18; i++) {
- int storageId = i+StorageManager.MAX_ENDER_CHEST_PAGES;
- int displayId = StorageManager.getInstance().getDisplayIdForStorageIdRender(i);
-
- StorageManager.StoragePage page = StorageManager.getInstance().getPage(storageId, false);
- if(page != null) {
- int itemX = 10+(i%9)*18;
- int itemY = storageViewSize+56+(i/9)*18;
-
- if(mouseX >= guiLeft+itemX && mouseX < guiLeft+itemX+18 &&
- mouseY >= guiTop+itemY && mouseY < guiTop+itemY+18) {
- StorageManager.getInstance().sendToPage(storageId);
- scrollToStorage(displayId, true);
- return true;
- }
- }
- }
- }
- }
-
- return true;
- }
-
- public void overrideIsMouseOverSlot(Slot slot, int mouseX, int mouseY, CallbackInfoReturnable<Boolean> cir) {
- if(StorageManager.getInstance().shouldRenderStorageOverlayFast()) {
- boolean playerInv = slot.inventory == Minecraft.getMinecraft().thePlayer.inventory;
-
- int slotId = slot.getSlotIndex();
- int storageViewSize = getStorageViewSize();
-
- if(playerInv) {
- if(slotId < 9) {
- if(mouseY >= guiTop+storageViewSize+76 && mouseY <= guiTop+storageViewSize+92) {
- int xN = mouseX-(guiLeft+181);
-
- int xClicked = xN/18;
-
- if(xClicked == slotId) {
- cir.setReturnValue(true);
- return;
- }
- }
- } else {
- int xN = mouseX-(guiLeft+181);
- int yN = mouseY-(guiTop+storageViewSize+18);
-
- int xClicked = xN/18;
- int yClicked = yN/18;
-
- if(xClicked >= 0 && xClicked <= 8 &&
- yClicked >= 0 && yClicked <= 2) {
- if(xClicked + yClicked*9 + 9 == slotId) {
- cir.setReturnValue(true);
- return;
- }
- }
- }
- } else {
- if(StorageManager.getInstance().onStorageMenu) {
- if(slotId >= 9 && slotId < 18) {
- if(mouseY >= guiTop+storageViewSize+24 && mouseY < guiTop+storageViewSize+24+18) {
- int xN = mouseX-(guiLeft+10);
-
- int xClicked = xN/18;
-
- if(xClicked == slotId%9) {
- cir.setReturnValue(true);
- return;
- }
- }
- } else if(slotId >= 27 && slotId < 45) {
- int xN = mouseX-(guiLeft+10);
- int yN = mouseY-(guiTop+storageViewSize+56);
-
- int xClicked = xN/18;
- int yClicked = yN/18;
-
- if(xClicked == slotId%9 &&
- yClicked >= 0 && yClicked == slotId/9-3) {
- cir.setReturnValue(true);
- return;
- }
- }
- } else {
- int currentPage = StorageManager.getInstance().getCurrentPageId();
- int displayId = StorageManager.getInstance().getDisplayIdForStorageIdRender(currentPage);
- if(displayId >= 0) {
- IntPair pageCoords = getPageCoords(displayId);
-
- int xN = mouseX-(guiLeft+pageCoords.x);
- int yN = mouseY-(guiTop+pageCoords.y);
-
- int xClicked = xN/18;
- int yClicked = yN/18;
-
- if(xClicked >= 0 && xClicked <= 8 &&
- yClicked >= 0 && yClicked <= 5) {
- if(xClicked + yClicked*9 + 9 == slotId) {
- if(NotEnoughUpdates.INSTANCE.config.storageGUI.fancyPanes == 1 && slot.getHasStack() &&
- getPaneType(slot.getStack(), -1, null) > 0) {
- cir.setReturnValue(false);
- return;
- }
- cir.setReturnValue(true);
- return;
- }
- }
- }
- }
- }
- cir.setReturnValue(false);
- }
- }
-
- public void clearSearch() {
- searchBar.setFocus(false);
- searchBar.setText("");
- StorageManager.getInstance().searchDisplay(searchBar.getText());
- }
-
- @Override
- public boolean keyboardInput() {
- if(Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
- clearSearch();
- return false;
- }
- if(Keyboard.getEventKey() == Minecraft.getMinecraft().gameSettings.keyBindScreenshot.getKeyCode()) {
- return false;
- }
- if(Keyboard.getEventKey() == Minecraft.getMinecraft().gameSettings.keyBindFullscreen.getKeyCode()) {
- return false;
- }
-
- if(Keyboard.getEventKeyState()) {
- if(NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotLocking &&
- KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.slotLocking.slotLockKey) && !searchBar.getFocus()) {
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) return true;
- GuiContainer container = (GuiContainer) Minecraft.getMinecraft().currentScreen;
-
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- int width = scaledResolution.getScaledWidth();
- int height = scaledResolution.getScaledHeight();
- int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
- int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
-
- for(Slot slot : container.inventorySlots.inventorySlots) {
- if(slot != null &&
- slot.inventory == Minecraft.getMinecraft().thePlayer.inventory &&
- container.isMouseOverSlot(slot, mouseX, mouseY)) {
- SlotLocking.getInstance().toggleLock(slot.getSlotIndex());
- return true;
- }
- }
- }
-
- if(editingNameId >= 0) {
- if(Keyboard.getEventKey() == Keyboard.KEY_RETURN) {
- editingNameId = -1;
- return true;
- }
-
- String prevText = renameStorageField.getText();
- renameStorageField.setFocus(true);
- searchBar.setFocus(false);
- renameStorageField.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey());
- if(!prevText.equals(renameStorageField.getText())) {
- StorageManager.StoragePage page = StorageManager.getInstance().getPage(editingNameId, false);
- if(page != null) {
- page.customTitle = renameStorageField.getText();
- }
- }
- } else if(searchBar.getFocus() || (allowTypingInSearchBar && NotEnoughUpdates.INSTANCE.config.storageGUI.searchBarAutofocus)) {
- String prevText = searchBar.getText();
- searchBar.setFocus(true);
- renameStorageField.setFocus(false);
- searchBar.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey());
- if(!prevText.equals(searchBar.getText())) {
- StorageManager.getInstance().searchDisplay(searchBar.getText());
- dirty = true;
- }
- if(NotEnoughUpdates.INSTANCE.config.storageGUI.searchBarAutofocus &&
- searchBar.getText().isEmpty()) {
- searchBar.setFocus(false);
- }
- } else if(Keyboard.getEventKey() == Keyboard.KEY_E) {
- return false;
- }
-
- }
-
- return true;
- }
-
- private static final ResourceLocation RES_ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png");
- private void renderEnchOverlay(Set<Vector2f> locations) {
- float f = (float)(Minecraft.getSystemTime() % 3000L) / 3000.0F / 8.0F;
- float f1 = (float)(Minecraft.getSystemTime() % 4873L) / 4873.0F / 8.0F;
- Minecraft.getMinecraft().getTextureManager().bindTexture(RES_ITEM_GLINT);
-
- GL11.glPushMatrix();
- for(Vector2f loc : locations) {
- GlStateManager.pushMatrix();
- GlStateManager.enableRescaleNormal();
- GlStateManager.enableAlpha();
- GlStateManager.alphaFunc(516, 0.1F);
- GlStateManager.enableBlend();
-
- GlStateManager.disableLighting();
-
- GlStateManager.translate(loc.x, loc.y, 0);
-
- GlStateManager.depthMask(false);
- GlStateManager.depthFunc(GL11.GL_EQUAL);
- GlStateManager.blendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
- GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
- GlStateManager.matrixMode(5890);
- GlStateManager.pushMatrix();
- GlStateManager.scale(8.0F, 8.0F, 8.0F);
- GlStateManager.translate(f, 0.0F, 0.0F);
- GlStateManager.rotate(-50.0F, 0.0F, 0.0F, 1.0F);
-
- GlStateManager.color(0x80/255f, 0x40/255f, 0xCC/255f, 1);
- Utils.drawTexturedRectNoBlend(0, 0, 16, 16, 0, 1/16f, 0, 1/16f, GL11.GL_NEAREST);
-
- GlStateManager.popMatrix();
- GlStateManager.pushMatrix();
- GlStateManager.scale(8.0F, 8.0F, 8.0F);
- GlStateManager.translate(-f1, 0.0F, 0.0F);
- GlStateManager.rotate(10.0F, 0.0F, 0.0F, 1.0F);
-
- GlStateManager.color(0x80/255f, 0x40/255f, 0xCC/255f, 1);
- Utils.drawTexturedRectNoBlend(0, 0, 16, 16, 0, 1/16f, 0, 1/16f, GL11.GL_NEAREST);
-
- GlStateManager.popMatrix();
- GlStateManager.matrixMode(5888);
- GlStateManager.blendFunc(770, 771);
- GlStateManager.depthFunc(515);
- GlStateManager.depthMask(true);
-
- GlStateManager.popMatrix();
- }
- GlStateManager.disableRescaleNormal();
- GL11.glPopMatrix();
-
- GlStateManager.bindTexture(0);
- }
-
- public void fastRenderCheck(){
- if(!OpenGlHelper.isFramebufferEnabled() && NotEnoughUpdates.INSTANCE.config.storageGUI.enableStorageGUI3) {
- this.fastRender = true;
- NEUEventListener.displayNotification(Lists.newArrayList(
- "\u00a74Fast Render Warning",
- "\u00a77Due to the way fast render works, it's not compatible with NEU.",
- "\u00a77Please disable fast render in your options under",
- "\u00a77ESC > Options > Video Settings > Performance > Fast Render",
- "\u00a77This can't be fixed.",
- "\u00a77",
- "\u00a77Press X on your keyboard to close this notifcation"), true, true);
- return;
- }
-
- this.fastRender = false;
- }
+ }
+
+ Utils.drawTexturedRect(
+ buttonX,
+ buttonY,
+ 16,
+ 16,
+ minU,
+ maxU,
+ (vIndex * 16) / 256f,
+ (vIndex * 16 + 16) / 256f,
+ GL11.GL_NEAREST
+ );
+ }
+ if (desiredHeightSwitch != -1 && Mouse.getEventButton() == -1 && !Mouse.getEventButtonState()) {
+ int delta = Math.abs(desiredHeightMX - mouseX) + Math.abs(desiredHeightMY - mouseY);
+ if (delta > 3) {
+ NotEnoughUpdates.INSTANCE.config.storageGUI.storageHeight = desiredHeightSwitch;
+ desiredHeightSwitch = -1;
+ }
+ }
+ if (Mouse.getEventButtonState() && mouseX >= guiLeft + 388 && mouseX < guiLeft + 388 + 90 &&
+ mouseY >= guiTop + storageViewSize + 35 && mouseY < guiTop + storageViewSize + 35 + 36) {
+ int xN = mouseX - (guiLeft + 388);
+ int yN = mouseY - (guiTop + storageViewSize + 35);
+
+ int xIndex = xN / 18;
+ int yIndex = yN / 18;
+
+ int buttonIndex = xIndex + 5 * yIndex;
+
+ switch (buttonIndex) {
+ case 0:
+ NotEnoughUpdates.INSTANCE.config.storageGUI.enableStorageGUI3 = false;
+ break;
+ case 1:
+ int size =
+ desiredHeightSwitch != -1 ? desiredHeightSwitch : NotEnoughUpdates.INSTANCE.config.storageGUI.storageHeight;
+ int sizeIndex = Math.round((size - 104) / 54f);
+ if (Mouse.getEventButton() == 0) {
+ sizeIndex--;
+ } else {
+ sizeIndex++;
+ }
+ size = sizeIndex * 54 + 104;
+ if (size < 104) size = 312;
+ if (size > 320) size = 104;
+ desiredHeightMX = mouseX;
+ desiredHeightMY = mouseY;
+ desiredHeightSwitch = size;
+ break;
+ case 2:
+ int displayStyle = NotEnoughUpdates.INSTANCE.config.storageGUI.displayStyle;
+ if (Mouse.getEventButton() == 0) {
+ displayStyle++;
+ } else {
+ displayStyle--;
+ }
+ if (displayStyle < 0) displayStyle = STORAGE_TEXTURES.length - 1;
+ if (displayStyle >= STORAGE_TEXTURES.length) displayStyle = 0;
+
+ NotEnoughUpdates.INSTANCE.config.storageGUI.displayStyle = displayStyle;
+ break;
+ case 3:
+ NotEnoughUpdates.INSTANCE.config.storageGUI.backpackPreview =
+ !NotEnoughUpdates.INSTANCE.config.storageGUI.backpackPreview;
+ break;
+ case 4:
+ NotEnoughUpdates.INSTANCE.config.storageGUI.enderchestPreview =
+ !NotEnoughUpdates.INSTANCE.config.storageGUI.enderchestPreview;
+ break;
+ case 5:
+ NotEnoughUpdates.INSTANCE.config.storageGUI.masonryMode =
+ !NotEnoughUpdates.INSTANCE.config.storageGUI.masonryMode;
+ break;
+ case 6:
+ int fancyPanes = NotEnoughUpdates.INSTANCE.config.storageGUI.fancyPanes;
+ if (Mouse.getEventButton() == 0) {
+ fancyPanes++;
+ } else {
+ fancyPanes--;
+ }
+ if (fancyPanes < 0) fancyPanes = 2;
+ if (fancyPanes >= 3) fancyPanes = 0;
+
+ NotEnoughUpdates.INSTANCE.config.storageGUI.fancyPanes = fancyPanes;
+ break;
+ case 7:
+ NotEnoughUpdates.INSTANCE.config.storageGUI.searchBarAutofocus =
+ !NotEnoughUpdates.INSTANCE.config.storageGUI.searchBarAutofocus;
+ break;
+ case 8:
+ NotEnoughUpdates.INSTANCE.config.storageGUI.showEnchantGlint =
+ !NotEnoughUpdates.INSTANCE.config.storageGUI.showEnchantGlint;
+ break;
+ case 9:
+ ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/neu storage gui");
+ break;
+ }
+ dirty = true;
+ }
+
+ if (mouseX >= guiLeft + 10 && mouseX <= guiLeft + 171 &&
+ mouseY >= guiTop + storageViewSize + 23 && mouseY <= guiTop + storageViewSize + 91) {
+ if (StorageManager.getInstance().onStorageMenu) {
+ return false;
+ } else if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0) {
+ for (int i = 0; i < 9; i++) {
+ int storageId = i;
+ int displayId = StorageManager.getInstance().getDisplayIdForStorageIdRender(i);
+
+ StorageManager.StoragePage page = StorageManager.getInstance().getPage(storageId, false);
+ if (page != null) {
+ int itemX = 10 + (i % 9) * 18;
+ int itemY = storageViewSize + 24 + (i / 9) * 18;
+
+ if (mouseX >= guiLeft + itemX && mouseX < guiLeft + itemX + 18 &&
+ mouseY >= guiTop + itemY && mouseY < guiTop + itemY + 18) {
+ StorageManager.getInstance().sendToPage(storageId);
+ scrollToStorage(displayId, true);
+ return true;
+ }
+ }
+ }
+ for (int i = 0; i < 18; i++) {
+ int storageId = i + StorageManager.MAX_ENDER_CHEST_PAGES;
+ int displayId = StorageManager.getInstance().getDisplayIdForStorageIdRender(i);
+
+ StorageManager.StoragePage page = StorageManager.getInstance().getPage(storageId, false);
+ if (page != null) {
+ int itemX = 10 + (i % 9) * 18;
+ int itemY = storageViewSize + 56 + (i / 9) * 18;
+
+ if (mouseX >= guiLeft + itemX && mouseX < guiLeft + itemX + 18 &&
+ mouseY >= guiTop + itemY && mouseY < guiTop + itemY + 18) {
+ StorageManager.getInstance().sendToPage(storageId);
+ scrollToStorage(displayId, true);
+ return true;
+ }
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+
+ public void overrideIsMouseOverSlot(Slot slot, int mouseX, int mouseY, CallbackInfoReturnable<Boolean> cir) {
+ if (StorageManager.getInstance().shouldRenderStorageOverlayFast()) {
+ boolean playerInv = slot.inventory == Minecraft.getMinecraft().thePlayer.inventory;
+
+ int slotId = slot.getSlotIndex();
+ int storageViewSize = getStorageViewSize();
+
+ if (playerInv) {
+ if (slotId < 9) {
+ if (mouseY >= guiTop + storageViewSize + 76 && mouseY <= guiTop + storageViewSize + 92) {
+ int xN = mouseX - (guiLeft + 181);
+
+ int xClicked = xN / 18;
+
+ if (xClicked == slotId) {
+ cir.setReturnValue(true);
+ return;
+ }
+ }
+ } else {
+ int xN = mouseX - (guiLeft + 181);
+ int yN = mouseY - (guiTop + storageViewSize + 18);
+
+ int xClicked = xN / 18;
+ int yClicked = yN / 18;
+
+ if (xClicked >= 0 && xClicked <= 8 &&
+ yClicked >= 0 && yClicked <= 2) {
+ if (xClicked + yClicked * 9 + 9 == slotId) {
+ cir.setReturnValue(true);
+ return;
+ }
+ }
+ }
+ } else {
+ if (StorageManager.getInstance().onStorageMenu) {
+ if (slotId >= 9 && slotId < 18) {
+ if (mouseY >= guiTop + storageViewSize + 24 && mouseY < guiTop + storageViewSize + 24 + 18) {
+ int xN = mouseX - (guiLeft + 10);
+
+ int xClicked = xN / 18;
+
+ if (xClicked == slotId % 9) {
+ cir.setReturnValue(true);
+ return;
+ }
+ }
+ } else if (slotId >= 27 && slotId < 45) {
+ int xN = mouseX - (guiLeft + 10);
+ int yN = mouseY - (guiTop + storageViewSize + 56);
+
+ int xClicked = xN / 18;
+ int yClicked = yN / 18;
+
+ if (xClicked == slotId % 9 &&
+ yClicked >= 0 && yClicked == slotId / 9 - 3) {
+ cir.setReturnValue(true);
+ return;
+ }
+ }
+ } else {
+ int currentPage = StorageManager.getInstance().getCurrentPageId();
+ int displayId = StorageManager.getInstance().getDisplayIdForStorageIdRender(currentPage);
+ if (displayId >= 0) {
+ IntPair pageCoords = getPageCoords(displayId);
+
+ int xN = mouseX - (guiLeft + pageCoords.x);
+ int yN = mouseY - (guiTop + pageCoords.y);
+
+ int xClicked = xN / 18;
+ int yClicked = yN / 18;
+
+ if (xClicked >= 0 && xClicked <= 8 &&
+ yClicked >= 0 && yClicked <= 5) {
+ if (xClicked + yClicked * 9 + 9 == slotId) {
+ if (NotEnoughUpdates.INSTANCE.config.storageGUI.fancyPanes == 1 && slot.getHasStack() &&
+ getPaneType(slot.getStack(), -1, null) > 0) {
+ cir.setReturnValue(false);
+ return;
+ }
+ cir.setReturnValue(true);
+ return;
+ }
+ }
+ }
+ }
+ }
+ cir.setReturnValue(false);
+ }
+ }
+
+ public void clearSearch() {
+ searchBar.setFocus(false);
+ searchBar.setText("");
+ StorageManager.getInstance().searchDisplay(searchBar.getText());
+ }
+
+ @Override
+ public boolean keyboardInput() {
+ if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
+ clearSearch();
+ return false;
+ }
+ if (Keyboard.getEventKey() == Minecraft.getMinecraft().gameSettings.keyBindScreenshot.getKeyCode()) {
+ return false;
+ }
+ if (Keyboard.getEventKey() == Minecraft.getMinecraft().gameSettings.keyBindFullscreen.getKeyCode()) {
+ return false;
+ }
+
+ if (Keyboard.getEventKeyState()) {
+ if (NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotLocking &&
+ KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.slotLocking.slotLockKey) && !searchBar.getFocus()) {
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) return true;
+ GuiContainer container = (GuiContainer) Minecraft.getMinecraft().currentScreen;
+
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ int width = scaledResolution.getScaledWidth();
+ int height = scaledResolution.getScaledHeight();
+ int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
+ int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
+
+ for (Slot slot : container.inventorySlots.inventorySlots) {
+ if (slot != null &&
+ slot.inventory == Minecraft.getMinecraft().thePlayer.inventory &&
+ container.isMouseOverSlot(slot, mouseX, mouseY)) {
+ SlotLocking.getInstance().toggleLock(slot.getSlotIndex());
+ return true;
+ }
+ }
+ }
+
+ if (editingNameId >= 0) {
+ if (Keyboard.getEventKey() == Keyboard.KEY_RETURN) {
+ editingNameId = -1;
+ return true;
+ }
+
+ String prevText = renameStorageField.getText();
+ renameStorageField.setFocus(true);
+ searchBar.setFocus(false);
+ renameStorageField.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey());
+ if (!prevText.equals(renameStorageField.getText())) {
+ StorageManager.StoragePage page = StorageManager.getInstance().getPage(editingNameId, false);
+ if (page != null) {
+ page.customTitle = renameStorageField.getText();
+ }
+ }
+ } else if (searchBar.getFocus() ||
+ (allowTypingInSearchBar && NotEnoughUpdates.INSTANCE.config.storageGUI.searchBarAutofocus)) {
+ String prevText = searchBar.getText();
+ searchBar.setFocus(true);
+ renameStorageField.setFocus(false);
+ searchBar.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey());
+ if (!prevText.equals(searchBar.getText())) {
+ StorageManager.getInstance().searchDisplay(searchBar.getText());
+ dirty = true;
+ }
+ if (NotEnoughUpdates.INSTANCE.config.storageGUI.searchBarAutofocus &&
+ searchBar.getText().isEmpty()) {
+ searchBar.setFocus(false);
+ }
+ } else return Keyboard.getEventKey() != Minecraft.getMinecraft().gameSettings.keyBindInventory.getKeyCode();
+
+ }
+
+ return true;
+ }
+
+ private static final ResourceLocation RES_ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png");
+
+ private void renderEnchOverlay(Set<Vector2f> locations) {
+ float f = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F / 8.0F;
+ float f1 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F / 8.0F;
+ if (NotEnoughUpdates.INSTANCE.config.storageGUI.showEnchantGlint) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(RES_ITEM_GLINT);
+ }
+
+ GL11.glPushMatrix();
+ for (Vector2f loc : locations) {
+ GlStateManager.pushMatrix();
+ GlStateManager.enableRescaleNormal();
+ GlStateManager.enableAlpha();
+ GlStateManager.alphaFunc(516, 0.1F);
+ GlStateManager.enableBlend();
+
+ GlStateManager.disableLighting();
+
+ GlStateManager.translate(loc.x, loc.y, 0);
+
+ GlStateManager.depthMask(false);
+ GlStateManager.depthFunc(GL11.GL_EQUAL);
+ GlStateManager.blendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
+ GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
+ GlStateManager.matrixMode(5890);
+ GlStateManager.pushMatrix();
+ GlStateManager.scale(8.0F, 8.0F, 8.0F);
+ GlStateManager.translate(f, 0.0F, 0.0F);
+ GlStateManager.rotate(-50.0F, 0.0F, 0.0F, 1.0F);
+
+ GlStateManager.color(0x80 / 255f, 0x40 / 255f, 0xCC / 255f, 1);
+ Utils.drawTexturedRectNoBlend(0, 0, 16, 16, 0, 1 / 16f, 0, 1 / 16f, GL11.GL_NEAREST);
+
+ GlStateManager.popMatrix();
+ GlStateManager.pushMatrix();
+ GlStateManager.scale(8.0F, 8.0F, 8.0F);
+ GlStateManager.translate(-f1, 0.0F, 0.0F);
+ GlStateManager.rotate(10.0F, 0.0F, 0.0F, 1.0F);
+
+ GlStateManager.color(0x80 / 255f, 0x40 / 255f, 0xCC / 255f, 1);
+ Utils.drawTexturedRectNoBlend(0, 0, 16, 16, 0, 1 / 16f, 0, 1 / 16f, GL11.GL_NEAREST);
+
+ GlStateManager.popMatrix();
+ GlStateManager.matrixMode(5888);
+ GlStateManager.blendFunc(770, 771);
+ GlStateManager.depthFunc(515);
+ GlStateManager.depthMask(true);
+
+ GlStateManager.popMatrix();
+ }
+ GlStateManager.disableRescaleNormal();
+ GL11.glPopMatrix();
+
+ GlStateManager.bindTexture(0);
+ }
+
+ public void fastRenderCheck() {
+ if (!OpenGlHelper.isFramebufferEnabled() && NotEnoughUpdates.INSTANCE.config.storageGUI.enableStorageGUI3) {
+ this.fastRender = true;
+ NEUEventListener.displayNotification(Lists.newArrayList(
+ "\u00a74Fast Render Warning",
+ "\u00a77Due to the way fast render works, it's not compatible with NEU.",
+ "\u00a77Please disable fast render in your options under",
+ "\u00a77ESC > Options > Video Settings > Performance > Fast Render",
+ "\u00a77This can't be fixed.",
+ "\u00a77",
+ "\u00a77Press X on your keyboard to close this notifcation"
+ ), true, true);
+ return;
+ }
+
+ this.fastRender = false;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java
index 0e4fbdea..1ba155d5 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java
@@ -26,1011 +26,1133 @@ import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.io.ByteArrayInputStream;
import java.text.NumberFormat;
-import java.util.*;
import java.util.List;
+import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class TradeWindow {
-
- private static ResourceLocation location = new ResourceLocation("notenoughupdates", "custom_trade.png");
-
- private static final int xSize = 176;
- private static final int ySize = 204;
- private static int guiLeft;
- private static int guiTop;
-
- private static long lastTradeMillis = -1;
-
- private static final long CHANGE_EXCLAM_MILLIS = 5000;
-
- private static Integer[] ourTradeIndexes = new Integer[16];
- private static Integer[] theirTradeIndexes = new Integer[16];
- private static String[] theirTradeOld = new String[16];
- private static Long[] theirTradeChangesMillis = new Long[16];
-
- private static ItemStack lastBackpack;
- private static int lastBackpackX;
- private static int lastBackpackY;
-
-
- public static boolean hypixelTradeWindowActive(String containerName) {
- return containerName != null && containerName.trim().startsWith("You ");
- }
-
- public static boolean tradeWindowActive(String containerName) {
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return false;
- if(!NotEnoughUpdates.INSTANCE.config.tradeMenu.enableCustomTrade) return false;
-
- if(hypixelTradeWindowActive(containerName)) {
- return true;
- }
-
- if(lastTradeMillis != -99) {
- lastTradeMillis = -99;
- ourTradeIndexes = new Integer[16];
- theirTradeIndexes = new Integer[16];
- theirTradeOld = new String[16];
- theirTradeChangesMillis = new Long[16];
- }
-
- return false;
- }
-
- private static void drawStringShadow(String str, float x, float y, int len) {
- for(int xOff=-2; xOff<=2; xOff++) {
- for(int yOff=-2; yOff<=2; yOff++) {
- if(Math.abs(xOff) != Math.abs(yOff)) {
- Utils.drawStringCenteredScaledMaxWidth(Utils.cleanColourNotModifiers(str),
- Minecraft.getMinecraft().fontRendererObj,
- x+xOff/2f, y+yOff/2f, false, len,
- new Color(20, 20, 20, 100/Math.max(Math.abs(xOff), Math.abs(yOff))).getRGB());
- }
- }
- }
-
- Utils.drawStringCenteredScaledMaxWidth(str,
- Minecraft.getMinecraft().fontRendererObj,
- x, y, false, len,
- new Color(64, 64, 64, 255).getRGB());
- }
-
- private static int getPrice(String internalname) {
- int pricePer = NotEnoughUpdates.INSTANCE.manager.auctionManager.getLowestBin(internalname);
- if(pricePer == -1) {
- JsonObject bazaarInfo = NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarInfo(internalname);
- if(bazaarInfo != null && bazaarInfo.has("avg_buy")) {
- pricePer = (int)bazaarInfo.get("avg_buy").getAsFloat();
- }
- }
- if(pricePer == -1) {
- JsonObject info = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfo(internalname);
- if(info != null && !NotEnoughUpdates.INSTANCE.manager.auctionManager.isVanillaItem(internalname) &&
- info.has("price") && info.has("count")) {
- int auctionPricePer = (int)(info.get("price").getAsFloat() / info.get("count").getAsFloat());
-
- pricePer = auctionPricePer;
- }
- }
- return pricePer;
- }
-
- private static int processTopItems(ItemStack stack, Map<Integer, Set<String>> topItems,
- Map<String, ItemStack> topItemsStack, Map<String, Integer> topItemsCount) {
- String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack);
- if(internalname == null) {
- if(stack.getDisplayName().endsWith(" coins")) {
- String clean = Utils.cleanColour(stack.getDisplayName());
-
- int mult = 1;
- StringBuilder sb = new StringBuilder();
- for(int index = 0; index < clean.length(); index++) {
- char c = clean.charAt(index);
- if("0123456789.".indexOf(c) >= 0) {
- sb.append(c);
- } else {
- switch(c) {
- case 'K':
- case 'k':
- mult = 1000; break;
- case 'M':
- case 'm':
- mult = 1000000; break;
- case 'B':
- case 'b':
- mult = 1000000000; break;
- default:
- break;
- }
- break;
- }
- }
- try {
- int coins = (int)(Float.parseFloat(sb.toString())*mult);
-
- topItemsStack.putIfAbsent("TRADE_COINS", stack);
-
- int existingPrice = coins;
- Set<Integer> toRemove = new HashSet<>();
- for(Map.Entry<Integer, Set<String>> entry : topItems.entrySet()) {
- if(entry.getValue().contains("TRADE_COINS")) {
- entry.getValue().remove("TRADE_COINS");
- existingPrice += entry.getKey();
- }
- if(entry.getValue().isEmpty()) toRemove.add(entry.getKey());
- }
- topItems.keySet().removeAll(toRemove);
-
- Set<String> items = topItems.computeIfAbsent(existingPrice, k->new HashSet<>());
- items.add("TRADE_COINS");
-
- return coins;
-
- } catch(Exception ignored) {}
- }
- } else {
- int pricePer = getPrice(internalname);
- if(pricePer > 0) {
- topItemsStack.putIfAbsent(internalname, stack);
-
- int price = pricePer * stack.stackSize;
- int priceInclBackpack = price;
-
- NBTTagCompound tag = stack.getTagCompound();
- if(tag != null && tag.hasKey("ExtraAttributes", 10)) {
- NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
-
- byte[] bytes = null;
- for (String key : ea.getKeySet()) {
- if (key.endsWith("backpack_data") || key.equals("new_year_cake_bag_data")) {
- bytes = ea.getByteArray(key);
- break;
- }
- }
- if(bytes != null) {
- try {
- NBTTagCompound contents_nbt = CompressedStreamTools.readCompressed(new ByteArrayInputStream(bytes));
- NBTTagList items = contents_nbt.getTagList("i", 10);
- for(int k=0; k<items.tagCount(); k++) {
- if(items.getCompoundTagAt(k).getKeySet().size() > 0) {
- NBTTagCompound nbt = items.getCompoundTagAt(k).getCompoundTag("tag");
-
- int id2 = items.getCompoundTagAt(k).getShort("id");
- int count2 = items.getCompoundTagAt(k).getByte("Count");
- int damage2 = items.getCompoundTagAt(k).getShort("Damage");
-
- if(id2 == 141) id2 = 391; //for some reason hypixel thinks carrots have id 141
-
- Item mcItem = Item.getItemById(id2);
- if(mcItem == null) continue;
-
- ItemStack stack2 = new ItemStack(mcItem, count2, damage2);
- stack2.setTagCompound(nbt);
-
- priceInclBackpack += processTopItems(stack2, topItems, topItemsStack, topItemsCount);
- }
- }
- } catch(Exception e) { }
- }
- }
-
- int existingPrice = price;
- Set<Integer> toRemove = new HashSet<>();
- for(Map.Entry<Integer, Set<String>> entry : topItems.entrySet()) {
- if(entry.getValue().contains(internalname)) {
- entry.getValue().remove(internalname);
- existingPrice += entry.getKey();
- }
- if(entry.getValue().isEmpty()) toRemove.add(entry.getKey());
- }
- topItems.keySet().removeAll(toRemove);
-
- Set<String> items = topItems.computeIfAbsent(existingPrice, k->new HashSet<>());
- items.add(internalname);
-
- int count = topItemsCount.computeIfAbsent(internalname, l->0);
- topItemsCount.put(internalname, count+stack.stackSize);
-
- return priceInclBackpack;
- }
- }
- return 0;
- }
-
- private static int getBackpackValue(ItemStack stack) {
- int price = 0;
-
- NBTTagCompound tag = stack.getTagCompound();
- if(tag != null && tag.hasKey("ExtraAttributes", 10)) {
- NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
-
- byte[] bytes = null;
- for (String key : ea.getKeySet()) {
- if (key.endsWith("backpack_data") || key.equals("new_year_cake_bag_data")) {
- bytes = ea.getByteArray(key);
- break;
- }
- }
- if(bytes != null) {
- try {
- NBTTagCompound contents_nbt = CompressedStreamTools.readCompressed(new ByteArrayInputStream(bytes));
- NBTTagList items = contents_nbt.getTagList("i", 10);
- for(int k=0; k<items.tagCount(); k++) {
- if(items.getCompoundTagAt(k).getKeySet().size() > 0) {
- NBTTagCompound nbt = items.getCompoundTagAt(k).getCompoundTag("tag");
- String internalname2 = NotEnoughUpdates.INSTANCE.manager.getInternalnameFromNBT(nbt);
- if(internalname2 != null) {
- int pricePer2 = getPrice(internalname2);
- if(pricePer2 > 0) {
- int count2 = items.getCompoundTagAt(k).getByte("Count");
- price += pricePer2 * count2;
- }
- }
- }
- }
- } catch(Exception e) { }
- }
- }
- return price;
- }
-
- public static void render(int mouseX, int mouseY) {
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) return;
-
- GuiContainer chest = ((GuiContainer)Minecraft.getMinecraft().currentScreen);
- ContainerChest cc = (ContainerChest) chest.inventorySlots;
- String containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText();
-
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
-
- guiLeft = (scaledResolution.getScaledWidth()-xSize)/2;
- guiTop = (scaledResolution.getScaledHeight()-ySize)/2;
-
- List<String> tooltipToDisplay = null;
- ItemStack stackToRender = null;
- int tooltipLen = -1;
-
- //Set index mappings
- //Our slots
- TreeMap<Integer, List<Integer>> ourTradeMap = new TreeMap<>();
- for(int i=0; i<16; i++) {
- ourTradeIndexes[i] = -1;
-
- int x = i % 4;
- int y = i / 4;
- int containerIndex = y*9+x;
-
- ItemStack stack = chest.inventorySlots.getInventory().get(containerIndex);
- if(stack == null) continue;
-
- String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack);
- if(internalname == null) {
- if(stack.getDisplayName().endsWith(" coins")) {
- String clean = Utils.cleanColour(stack.getDisplayName());
-
- int mult = 1;
- StringBuilder sb = new StringBuilder();
- for(int index = 0; index < clean.length(); index++) {
- char c = clean.charAt(index);
- if("0123456789.".indexOf(c) >= 0) {
- sb.append(c);
- } else {
- switch(c) {
- case 'K':
- case 'k':
- mult = 1000; break;
- case 'M':
- case 'm':
- mult = 1000000; break;
- case 'B':
- case 'b':
- mult = 1000000000; break;
- default:
- break;
- }
- break;
- }
- }
- try {
- int coins = (int)(Float.parseFloat(sb.toString())*mult);
-
- List<Integer> list = ourTradeMap.computeIfAbsent(coins, k -> new ArrayList<>());
- list.add(containerIndex);
-
- } catch(Exception ignored) {
- List<Integer> list = ourTradeMap.computeIfAbsent(-1, k -> new ArrayList<>());
- list.add(containerIndex);
- }
- } else {
- List<Integer> list = ourTradeMap.computeIfAbsent(-1, k -> new ArrayList<>());
- list.add(containerIndex);
- }
- } else {
- int price = getPrice(internalname);
- if(price == -1) price = 0;
-
- price += getBackpackValue(stack);
-
- List<Integer> list = ourTradeMap.computeIfAbsent(price, k -> new ArrayList<>());
- list.add(containerIndex);
- }
- }
- long currentTime = System.currentTimeMillis();
- List<String> theirTradeCurrent = new ArrayList<>();
- TreeMap<Integer, List<Integer>> theirTradeMap = new TreeMap<>();
- HashMap<String, Integer> displayCountMap = new HashMap<>();
- for(int i=0; i<16; i++) {
- theirTradeIndexes[i] = -1;
- if(theirTradeChangesMillis[i] == null || currentTime - theirTradeChangesMillis[i] > CHANGE_EXCLAM_MILLIS) {
- theirTradeChangesMillis[i] = -1L;
- }
-
- int x = i % 4;
- int y = i / 4;
- int containerIndex = y*9+x+5;
-
- ItemStack stack = chest.inventorySlots.getInventory().get(containerIndex);
- if(stack == null) continue;
-
- NBTTagCompound tag = stack.getTagCompound();
- String uuid = null;
- if(tag != null && tag.hasKey("ExtraAttributes", 10)) {
- NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
-
- if (ea.hasKey("uuid", 8)) {
- uuid = ea.getString("uuid");
- } else {
- int displayCount = displayCountMap.computeIfAbsent(stack.getDisplayName(), k->0);
- uuid = stack.getDisplayName() + ":" + displayCount;
- displayCountMap.put(stack.getDisplayName(), displayCount+1);
- }
- } else {
- int displayCount = displayCountMap.computeIfAbsent(stack.getDisplayName(), k->0);
- uuid = stack.getDisplayName() + ":" + displayCount;
- displayCountMap.put(stack.getDisplayName(), displayCount+1);
- }
- if(uuid != null) theirTradeCurrent.add(uuid);
-
- String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack);
- if(internalname == null) {
- if(stack.getDisplayName().endsWith(" coins")) {
- String clean = Utils.cleanColour(stack.getDisplayName());
-
- int mult = 1;
- StringBuilder sb = new StringBuilder();
- for(int index = 0; index < clean.length(); index++) {
- char c = clean.charAt(index);
- if("0123456789.".indexOf(c) >= 0) {
- sb.append(c);
- } else {
- switch(c) {
- case 'K':
- case 'k':
- mult = 1000; break;
- case 'M':
- case 'm':
- mult = 1000000; break;
- case 'B':
- case 'b':
- mult = 1000000000; break;
- default:
- break;
- }
- break;
- }
- }
- try {
- int coins = (int)(Float.parseFloat(sb.toString())*mult);
-
- List<Integer> list = theirTradeMap.computeIfAbsent(coins, k -> new ArrayList<>());
- list.add(containerIndex);
-
- } catch(Exception ignored) {
- List<Integer> list = theirTradeMap.computeIfAbsent(-1, k -> new ArrayList<>());
- list.add(containerIndex);
- }
- } else {
- List<Integer> list = theirTradeMap.computeIfAbsent(-1, k -> new ArrayList<>());
- list.add(containerIndex);
- }
- } else {
- JsonObject info = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfo(internalname);
- int price = -1;
- if(info != null && info.has("price") && info.has("count")) {
- int auctionPricePer = (int)(info.get("price").getAsFloat() / info.get("count").getAsFloat());
-
- price = auctionPricePer * stack.stackSize;
- } else {
- JsonObject bazaarInfo = NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarInfo(internalname);
- if(bazaarInfo != null && bazaarInfo.has("avg_buy")) {
- price = (int)bazaarInfo.get("avg_buy").getAsFloat() * stack.stackSize;
- }
- }
-
- price += getBackpackValue(stack);
-
- List<Integer> list = theirTradeMap.computeIfAbsent(price, k -> new ArrayList<>());
- list.add(containerIndex);
- }
- }
- int ourTradeIndex = 0;
- for(Map.Entry<Integer, List<Integer>> entry : ourTradeMap.descendingMap().entrySet()) {
- for(Integer index : entry.getValue()) {
- ourTradeIndexes[ourTradeIndex++] = index;
- }
- }
-
- //Their slots
- int maxMissing = 16-theirTradeCurrent.size();
- int j=0;
- for(int i=0; i<16; i++) {
- while(j <= 15 && (j-i<maxMissing) && theirTradeChangesMillis[j] >= 0) j++;
- j = Math.min(15, j);
-
- String oldUUID = theirTradeOld[i];
- if(oldUUID != null && !theirTradeCurrent.contains(oldUUID)) {
- theirTradeChangesMillis[j] = System.currentTimeMillis();
- }
- j++;
- }
-
- for(int i=0; i<16; i++) {
- theirTradeOld[i] = null;
- }
- int theirTradeIndex = 0;
- displayCountMap.clear();
- j=0;
- for(Map.Entry<Integer, List<Integer>> entry : theirTradeMap.descendingMap().entrySet()) {
- for(Integer index : entry.getValue()) {
- while(j <= 15 && (j-theirTradeIndex<maxMissing) && theirTradeChangesMillis[j] >= 0) j++;
- j = Math.min(15, j);
-
- theirTradeIndexes[j] = index;
-
- ItemStack stack = chest.inventorySlots.getInventory().get(index);
- if(stack == null) continue;
-
- NBTTagCompound tag = stack.getTagCompound();
- String uuid = null;
- if(tag != null && tag.hasKey("ExtraAttributes", 10)) {
- NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
-
- if (ea.hasKey("uuid", 8)) {
- uuid = ea.getString("uuid");
- } else {
- int displayCount = displayCountMap.computeIfAbsent(stack.getDisplayName(), k->0);
- uuid = stack.getDisplayName() + ":" + displayCount;
- displayCountMap.put(stack.getDisplayName(), displayCount+1);
- }
- } else {
- int displayCount = displayCountMap.computeIfAbsent(stack.getDisplayName(), k->0);
- uuid = stack.getDisplayName() + ":" + displayCount;
- displayCountMap.put(stack.getDisplayName(), displayCount+1);
- }
- //System.out.println(uuid);
- theirTradeOld[theirTradeIndex] = uuid;
-
- j++;
- theirTradeIndex++;
- }
- }
-
- GlStateManager.color(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(location);
- Utils.drawTexturedRect(guiLeft, guiTop, xSize, ySize, 0, 176/256f, 0, 204/256f, GL11.GL_NEAREST);
-
- Utils.drawStringF(new ChatComponentTranslation("container.inventory").getUnformattedText(),
- Minecraft.getMinecraft().fontRendererObj, guiLeft+8, guiTop+111, false, 4210752);
- Utils.drawStringF("You", Minecraft.getMinecraft().fontRendererObj, guiLeft+8,
- guiTop+5, false, 4210752);
- String[] split = containerName.split(" ");
- if(split.length >= 1) {
- Utils.drawStringF(split[split.length-1], Minecraft.getMinecraft().fontRendererObj,
- guiLeft+167-Minecraft.getMinecraft().fontRendererObj.getStringWidth(split[split.length-1]),
- guiTop+5, false, 4210752);
- }
-
- int index=0;
- for(ItemStack stack : Minecraft.getMinecraft().thePlayer.inventory.mainInventory) {
- int x = 8+18*(index % 9);
- int y = 104+18*(index / 9);
- if(index < 9) y = 180;
-
- chest.drawSlot(new Slot(Minecraft.getMinecraft().thePlayer.inventory, index, guiLeft+x, guiTop+y));
- //Utils.drawItemStack(stack, guiLeft+x, guiTop+y);
-
- int col = 0x80ffffff;
- if(SlotLocking.getInstance().isSlotIndexLocked(index)) {
- col = 0x80ff8080;
- }
-
- if(mouseX > guiLeft+x-1 && mouseX < guiLeft+x+18) {
- if(mouseY > guiTop+y-1 && mouseY < guiTop+y+18) {
- if(stack != null) stackToRender = stack;
-
- GlStateManager.disableLighting();
- GlStateManager.disableDepth();
- GlStateManager.colorMask(true, true, true, false);
- Utils.drawGradientRect(guiLeft+x, guiTop+y,
- guiLeft+x + 16, guiTop+y + 16, col, col);
- GlStateManager.colorMask(true, true, true, true);
- GlStateManager.enableLighting();
- GlStateManager.enableDepth();
- }
- }
-
- index++;
- }
-
- for(int i=0; i<16; i++) {
- int x = i % 4;
- int y = i / 4;
-
- int containerIndex = ourTradeIndexes[i];
-
- ItemStack stack = null;
- if(containerIndex >= 0) {
- stack = chest.inventorySlots.getInventory().get(containerIndex);
- Utils.drawItemStack(stack, guiLeft+10+x*18, guiTop+15+y*18);
- }
-
- if(mouseX > guiLeft+10+x*18-1 && mouseX < guiLeft+10+x*18+18) {
- if(mouseY > guiTop+15+y*18-1 && mouseY < guiTop+15+y*18+18) {
- if(stack != null) stackToRender = stack;
-
- GlStateManager.disableLighting();
- GlStateManager.disableDepth();
- GlStateManager.colorMask(true, true, true, false);
- Utils.drawGradientRect(guiLeft+10+x*18, guiTop+15+y*18,
- guiLeft+10+x*18 + 16, guiTop+15+y*18 + 16, -2130706433, -2130706433);
- GlStateManager.colorMask(true, true, true, true);
- GlStateManager.enableLighting();
- GlStateManager.enableDepth();
- }
- }
- }
-
- ItemStack bidStack = chest.inventorySlots.getInventory().get(36);
- if(bidStack != null) {
- Utils.drawItemStack(bidStack, guiLeft+10, guiTop+90);
- if(mouseX > guiLeft+10-1 && mouseX < guiLeft+10+18) {
- if(mouseY > guiTop+90-1 && mouseY < guiTop+90+18) {
- tooltipToDisplay = bidStack.getTooltip(Minecraft.getMinecraft().thePlayer,
- Minecraft.getMinecraft().gameSettings.advancedItemTooltips);
- }
- }
- }
-
- ItemStack confirmStack = chest.inventorySlots.getInventory().get(39);
- if(confirmStack != null) {
- String confirmDisplay = confirmStack.getDisplayName();
- if(!confirmDisplay.equals(EnumChatFormatting.GREEN+"Trading!")) {
- if(mouseX > guiLeft+81-51 && mouseX < guiLeft+81) {
- if (mouseY > guiTop+91 && mouseY < guiTop+91+14) {
- tooltipToDisplay = confirmStack.getTooltip(Minecraft.getMinecraft().thePlayer,
- Minecraft.getMinecraft().gameSettings.advancedItemTooltips);
- }
- }
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(location);
- Utils.drawTexturedRect(guiLeft+81-51, guiTop+91, 51, 14,
- 0, 51/256f, ySize/256f, (ySize+14)/256f, GL11.GL_NEAREST);
-
- Pattern pattern = Pattern.compile(EnumChatFormatting.GRAY+"\\("+EnumChatFormatting.YELLOW+"([0-9]+)"+EnumChatFormatting.GRAY+"\\)");
- Matcher matcher = pattern.matcher(confirmDisplay);
-
- if(!confirmDisplay.equals(EnumChatFormatting.YELLOW+"Warning!") &&
- !confirmDisplay.equals(EnumChatFormatting.YELLOW+"Deal!")) {
- lastTradeMillis = -1;
- }
-
- if(matcher.find()) {
- String numS = matcher.group(1);
- int num = Integer.parseInt(numS);
-
- Utils.drawStringCentered(EnumChatFormatting.DARK_RED + "Check " + EnumChatFormatting.BOLD + (char) (9311 + num), Minecraft.getMinecraft().fontRendererObj, guiLeft + 56, guiTop + 99,
- false, 4210752);
- } else if(confirmDisplay.equals(EnumChatFormatting.AQUA+"Gift!")) {
- Utils.drawStringCentered(EnumChatFormatting.GREEN+"Accept", Minecraft.getMinecraft().fontRendererObj, guiLeft+56, guiTop+99,
- true, 4210752);
- } else if(confirmDisplay.equals(EnumChatFormatting.GREEN+"Deal accepted!")) {
- Utils.drawStringCentered(EnumChatFormatting.GREEN+"Accepted", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+56, guiTop+99, true, 4210752);
- } else if(lastTradeMillis > 0) {
- long delta = System.currentTimeMillis() - lastTradeMillis;
- if(delta > 2000) {
- Utils.drawStringCentered(EnumChatFormatting.GREEN+"Accept", Minecraft.getMinecraft().fontRendererObj, guiLeft+56, guiTop+99,
- true, 4210752);
- } else {
- Utils.drawStringCentered(EnumChatFormatting.YELLOW+"Trade "+EnumChatFormatting.BOLD+(char)(9312+(2000-delta)/1000),
- Minecraft.getMinecraft().fontRendererObj, guiLeft+56, guiTop+99,
- true, 4210752);
- }
- } else {
- Utils.drawStringCentered(EnumChatFormatting.YELLOW+"Trade "+EnumChatFormatting.BOLD+(char)(9314), Minecraft.getMinecraft().fontRendererObj, guiLeft+56, guiTop+99,
- true, 4210752);
- }
- }
- }
-
- ItemStack theirConfirmStack = chest.inventorySlots.getInventory().get(41);
- if(theirConfirmStack != null) {
- String confirmDisplay = theirConfirmStack.getDisplayName();
- if(mouseX > guiLeft+95 && mouseX < guiLeft+95+51) {
- if (mouseY > guiTop+91 && mouseY < guiTop+91+14) {
- tooltipToDisplay = theirConfirmStack.getTooltip(Minecraft.getMinecraft().thePlayer,
- Minecraft.getMinecraft().gameSettings.advancedItemTooltips);
- }
- }
-
- GlStateManager.color(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(location);
- Utils.drawTexturedRect(guiLeft+95, guiTop+91, 51, 14,
- 0, 51/256f, ySize/256f, (ySize+14)/256f, GL11.GL_NEAREST);
-
- if(confirmDisplay.equals(EnumChatFormatting.YELLOW+"Pending their confirm")) {
- Utils.drawStringCentered(EnumChatFormatting.YELLOW+"Pending", Minecraft.getMinecraft().fontRendererObj, guiLeft+120, guiTop+99,
- true, 4210752);
- } else if(confirmDisplay.equals(EnumChatFormatting.YELLOW+"Deal timer...")) {
- Utils.drawStringCentered(EnumChatFormatting.YELLOW+"Pending", Minecraft.getMinecraft().fontRendererObj, guiLeft+120, guiTop+99,
- true, 4210752);
- } else if(confirmDisplay.equals(EnumChatFormatting.GREEN+"Other player confirmed!")) {
- Utils.drawStringCentered(EnumChatFormatting.GREEN+"Accepted", Minecraft.getMinecraft().fontRendererObj, guiLeft+120, guiTop+99,
- true, 4210752);
- }
- }
-
- for(int i=0; i<16; i++) {
- int x = i % 4;
- int y = i / 4;
-
- int containerIndex = theirTradeIndexes[i];
-
- ItemStack stack = null;
- if(containerIndex >= 0) {
- stack = chest.inventorySlots.getInventory().get(containerIndex);
- Utils.drawItemStack(stack, guiLeft+96+x*18, guiTop+15+y*18);
- }
-
- if(currentTime % 400 > 200 && theirTradeChangesMillis[i] != null && theirTradeChangesMillis[i] > 0) {
- GlStateManager.translate(0, 0, 200);
- GlStateManager.color(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(location);
- Utils.drawTexturedRect(guiLeft+96+x*18, guiTop+15+y*18, 16, 16,
- 51/256f, 67/256f, 204/256f, 220/256f, GL11.GL_NEAREST);
- GlStateManager.translate(0, 0, -200);
- }
-
- if(mouseX > guiLeft+96+x*18-1 && mouseX < guiLeft+96+x*18+18) {
- if(mouseY > guiTop+15+y*18-1 && mouseY < guiTop+15+y*18+18) {
- if(stack != null) stackToRender = stack;
-
- GlStateManager.disableLighting();
- GlStateManager.disableDepth();
- GlStateManager.colorMask(true, true, true, false);
- Utils.drawGradientRect(guiLeft+96+x*18, guiTop+15+y*18,
- guiLeft+96+x*18 + 16, guiTop+15+y*18 + 16, -2130706433, -2130706433);
- GlStateManager.colorMask(true, true, true, true);
- GlStateManager.enableLighting();
- GlStateManager.enableDepth();
- }
- }
- }
-
- if(NotEnoughUpdates.INSTANCE.config.tradeMenu.customTradePrices) {
- TreeMap<Integer, Set<String>> ourTopItems = new TreeMap<>();
- TreeMap<String, ItemStack> ourTopItemsStack = new TreeMap<>();
- TreeMap<String, Integer> ourTopItemsCount = new TreeMap<>();
- int ourPrice = 0;
- for(int i=0; i<16; i++) {
- int x = i % 4;
- int y = i / 4;
- int containerIndex = y*9+x;
-
- ItemStack stack = chest.inventorySlots.getInventory().get(containerIndex);
- if(stack == null) continue;
-
- ourPrice += processTopItems(stack, ourTopItems, ourTopItemsStack, ourTopItemsCount);
- }
- TreeMap<Integer, Set<String>> theirTopItems = new TreeMap<>();
- TreeMap<String, ItemStack> theirTopItemsStack = new TreeMap<>();
- TreeMap<String, Integer> theirTopItemsCount = new TreeMap<>();
- int theirPrice = 0;
- for(int i=0; i<16; i++) {
- int x = i % 4;
- int y = i / 4;
- int containerIndex = y*9+x+5;
-
- ItemStack stack = chest.inventorySlots.getInventory().get(containerIndex);
- if(stack == null) continue;
-
- theirPrice += processTopItems(stack, theirTopItems, theirTopItemsStack, theirTopItemsCount);
- }
-
- NumberFormat format = NumberFormat.getInstance(Locale.US);
-
- GlStateManager.disableLighting();
- GlStateManager.color(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(location);
- Utils.drawTexturedRect(guiLeft-80-3, guiTop, 80, 106,
- 176/256f, 1, 0, 106/256f, GL11.GL_NEAREST);
- drawStringShadow(EnumChatFormatting.GOLD.toString()+EnumChatFormatting.BOLD+"Total Value",
- guiLeft-40-3, guiTop+11, 72);
- drawStringShadow(EnumChatFormatting.GOLD.toString()+EnumChatFormatting.BOLD+format.format(ourPrice),
- guiLeft-40-3, guiTop+21, 72);
-
- int ourTopIndex = Math.max(0, 3-ourTopItemsStack.size());
- out:
- for(Map.Entry<Integer, Set<String>> entry : ourTopItems.descendingMap().entrySet()) {
- for(String ourTopItemInternal : entry.getValue()) {
- ItemStack stack = ourTopItemsStack.get(ourTopItemInternal);
- if(stack == null) continue;
-
- if(NotEnoughUpdates.INSTANCE.config.tradeMenu.customTradePriceStyle) {
- String countS = "";
- if(ourTopItemsCount.containsKey(ourTopItemInternal)) {
- int count = ourTopItemsCount.get(ourTopItemInternal);
- if(count > 999999) {
- countS = Math.floor(count/10000f)/100f+"m";
- } else if(count > 999) {
- countS = Math.floor(count/10f)/100f+"k";
- } else {
- countS = ""+count;
- }
- }
-
- Utils.drawItemStackWithText(stack, guiLeft-75-3, guiTop+49+18*ourTopIndex, countS);
-
- GlStateManager.disableLighting();
- GlStateManager.disableBlend();
- GlStateManager.color(1, 1, 1, 1);
- drawStringShadow(EnumChatFormatting.GOLD.toString()+EnumChatFormatting.BOLD+format.format(entry.getKey()),
- guiLeft-29-3, guiTop+57+18*ourTopIndex, 52);
- GlStateManager.enableBlend();
- } else {
- drawStringShadow(stack.getDisplayName() + EnumChatFormatting.GRAY+"x"+ourTopItemsCount.get(ourTopItemInternal),
- guiLeft-40-3, guiTop+46+20*ourTopIndex, 72);
- drawStringShadow(EnumChatFormatting.GOLD.toString()+EnumChatFormatting.BOLD+format.format(entry.getKey()),
- guiLeft-40-3, guiTop+56+20*ourTopIndex, 72);
- }
-
- if(++ourTopIndex >= 3) break out;
- }
- }
-
- GlStateManager.color(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(location);
- Utils.drawTexturedRect(guiLeft+xSize+3, guiTop, 80, 106,
- 176/256f, 1, 0, 106/256f, GL11.GL_NEAREST);
- drawStringShadow(EnumChatFormatting.GOLD.toString()+EnumChatFormatting.BOLD+"Total Value",
- guiLeft+xSize+3+40, guiTop+11, 72);
- drawStringShadow(EnumChatFormatting.GOLD.toString()+EnumChatFormatting.BOLD+format.format(theirPrice),
- guiLeft+xSize+3+40, guiTop+21, 72);
-
- int theirTopIndex = Math.max(0, 3-theirTopItemsStack.size());
- out:
- for(Map.Entry<Integer, Set<String>> entry : theirTopItems.descendingMap().entrySet()) {
- for(String theirTopItemInternal : entry.getValue()) {
- ItemStack stack = theirTopItemsStack.get(theirTopItemInternal);
- if(stack == null) continue;
-
- if(NotEnoughUpdates.INSTANCE.config.tradeMenu.customTradePriceStyle) {
- String countS = "";
- if(theirTopItemsCount.containsKey(theirTopItemInternal)) {
- int count = theirTopItemsCount.get(theirTopItemInternal);
- if(count > 999999) {
- countS = Math.floor(count/10000f)/100f+"m";
- } else if(count > 999) {
- countS = Math.floor(count/10f)/100f+"k";
- } else {
- countS = ""+count;
- }
- }
-
- Utils.drawItemStackWithText(stack, guiLeft+xSize+25+3-16, guiTop+49+18*theirTopIndex, countS);
-
- GlStateManager.disableLighting();
- GlStateManager.disableBlend();
- GlStateManager.color(1, 1, 1, 1);
- drawStringShadow(EnumChatFormatting.GOLD.toString()+EnumChatFormatting.BOLD+format.format(entry.getKey()),
- guiLeft+xSize+3+51, guiTop+57+18*theirTopIndex, 52);
- GlStateManager.enableBlend();
- } else {
- drawStringShadow(stack.getDisplayName(),
- guiLeft+xSize+3+40, guiTop+46+20*theirTopIndex, 72);
- drawStringShadow(EnumChatFormatting.GOLD.toString()+EnumChatFormatting.BOLD+format.format(entry.getKey()),
- guiLeft+xSize+3+40, guiTop+56+20*theirTopIndex, 72);
- }
-
- if(++theirTopIndex >= 3) break out;
- }
- }
- }
-
-
- boolean button1 = NotEnoughUpdates.INSTANCE.config.tradeMenu.customTradePriceStyle;
- boolean button2 = NotEnoughUpdates.INSTANCE.config.tradeMenu.customTradePrices;
- boolean button3 = NotEnoughUpdates.INSTANCE.config.tradeMenu.enableCustomTrade;
-
- GlStateManager.color(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(location);
- Utils.drawTexturedRect(guiLeft+xSize+3, guiTop+ySize-19, 17, 17,
- (button3?17:0)/256f, (button3?34:17)/256f, 218/256f, 235/256f, GL11.GL_NEAREST);
- Utils.drawTexturedRect(guiLeft+xSize+3, guiTop+ySize-38, 17, 17,
- (button2?17:0)/256f, (button2?34:17)/256f, 218/256f, 235/256f, GL11.GL_NEAREST);
- Utils.drawTexturedRect(guiLeft+xSize+3, guiTop+ySize-57, 17, 17,
- (button1?17:0)/256f, (button1?34:17)/256f, 218/256f, 235/256f, GL11.GL_NEAREST);
-
- if(mouseX >= guiLeft+xSize+3 && mouseX <= guiLeft+xSize+3+17) {
- if(mouseY >= guiTop+ySize-19 && mouseY <= guiTop+ySize-19+17) {
- tooltipToDisplay = new ArrayList<>();
- tooltipToDisplay.add(EnumChatFormatting.GOLD+"Enable Custom Trade Menu");
- tooltipToDisplay.add(EnumChatFormatting.GRAY+"Use this menu instead of the default trade window");
- tooltipLen = 200;
- } else if(mouseY >= guiTop+ySize-38 && mouseY <= guiTop+ySize-38+17) {
- tooltipToDisplay = new ArrayList<>();
- tooltipToDisplay.add(EnumChatFormatting.GOLD+"Price Information");
- tooltipToDisplay.add(EnumChatFormatting.GRAY+"Show the price of items on both sides");
- tooltipLen = 200;
- } else if(mouseY >= guiTop+ySize-57 && mouseY <= guiTop+ySize-57+17) {
- tooltipToDisplay = new ArrayList<>();
- tooltipToDisplay.add(EnumChatFormatting.GOLD+"Trade Prices Style");
- tooltipToDisplay.add(EnumChatFormatting.GRAY+"Changes the style of the top item prices");
- tooltipLen = 200;
- }
- }
-
- if(stackToRender != null) {
- tooltipToDisplay = stackToRender.getTooltip(Minecraft.getMinecraft().thePlayer,
- Minecraft.getMinecraft().gameSettings.advancedItemTooltips);
- }
-
- if(tooltipToDisplay != null) {
- Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(),
- tooltipLen, Minecraft.getMinecraft().fontRendererObj);
- }
- }
-
- public static void handleMouseInput() {
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) return;
-
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- int width = scaledResolution.getScaledWidth();
- int height = scaledResolution.getScaledHeight();
-
- int mouseX = Mouse.getEventX() * width / Minecraft.getMinecraft().displayWidth;
- int mouseY = height - Mouse.getEventY() * height / Minecraft.getMinecraft().displayHeight - 1;
-
- GuiContainer chest = ((GuiContainer)Minecraft.getMinecraft().currentScreen);
-
- if(Mouse.getEventButtonState() && Mouse.isButtonDown(0)) {
- int index=0;
- for(ItemStack stack : Minecraft.getMinecraft().thePlayer.inventory.mainInventory) {
- if(stack == null) {
- index++;
- continue;
- }
-
- int x = 8+18*(index % 9);
- int y = 104+18*(index / 9);
- if(index < 9) y = 180;
-
- if(mouseX > guiLeft+x && mouseX < guiLeft+x+16) {
- if(mouseY > guiTop+y && mouseY < guiTop+y+16) {
- Slot slot = chest.inventorySlots.getSlotFromInventory(Minecraft.getMinecraft().thePlayer.inventory, index);
- if(!NotEnoughUpdates.INSTANCE.config.slotLocking.lockSlotsInTrade ||
- !SlotLocking.getInstance().isSlotLocked(slot)) {
- Minecraft.getMinecraft().playerController.windowClick(
- chest.inventorySlots.windowId,
- slot.slotNumber, 2, 3, Minecraft.getMinecraft().thePlayer);
- }
- return;
- }
- }
-
- index++;
- }
-
- for(int i=0; i<16; i++) {
- int x = i % 4;
- int y = i / 4;
-
- int containerIndex = ourTradeIndexes[i];
- if(containerIndex < 0) continue;
-
- if(mouseX > guiLeft+10+x*18-1 && mouseX < guiLeft+10+x*18+18) {
- if(mouseY > guiTop+15+y*18-1 && mouseY < guiTop+15+y*18+18) {
- Minecraft.getMinecraft().playerController.windowClick(
- chest.inventorySlots.windowId,
- containerIndex, 2, 3, Minecraft.getMinecraft().thePlayer);
- return;
- }
- }
- }
-
- if(mouseX > guiLeft+10-1 && mouseX < guiLeft+10+18) {
- if(mouseY > guiTop+90-1 && mouseY < guiTop+90+18) {
- Minecraft.getMinecraft().playerController.windowClick(
- chest.inventorySlots.windowId,
- 36, 2, 3, Minecraft.getMinecraft().thePlayer);
- return;
- }
- }
-
- ItemStack confirmStack = chest.inventorySlots.getInventory().get(39);
- if(confirmStack != null) {
- String confirmDisplay = confirmStack.getDisplayName();
- if(!confirmDisplay.equals(EnumChatFormatting.GREEN+"Trading!")) {
- if(mouseX > guiLeft+42 && mouseX < guiLeft+42+40) {
- if (mouseY > guiTop+92 && mouseY < guiTop+92+14) {
- if((confirmDisplay.equals(EnumChatFormatting.YELLOW+"Warning!") ||
- confirmDisplay.equals(EnumChatFormatting.YELLOW+"Deal!")) && lastTradeMillis < 0) {
- lastTradeMillis = System.currentTimeMillis();
- } else if(lastTradeMillis < 0 || System.currentTimeMillis() - lastTradeMillis > 2000) {
- Minecraft.getMinecraft().playerController.windowClick(
- chest.inventorySlots.windowId,
- 39, 2, 3, Minecraft.getMinecraft().thePlayer);
- return;
- }
- }
- }
-
- }
- }
-
- if(mouseX >= guiLeft+xSize+3 && mouseX <= guiLeft+xSize+3+17) {
- if(mouseY >= guiTop+ySize-19 && mouseY <= guiTop+ySize-19+17) {
- NotEnoughUpdates.INSTANCE.config.tradeMenu.enableCustomTrade =
- !NotEnoughUpdates.INSTANCE.config.tradeMenu.enableCustomTrade;
- return;
- } else if(mouseY >= guiTop+ySize-38 && mouseY <= guiTop+ySize-38+17) {
- NotEnoughUpdates.INSTANCE.config.tradeMenu.customTradePrices =
- !NotEnoughUpdates.INSTANCE.config.tradeMenu.customTradePrices;
- return;
- } else if(mouseY >= guiTop+ySize-57 && mouseY <= guiTop+ySize-57+17) {
- NotEnoughUpdates.INSTANCE.config.tradeMenu.customTradePriceStyle =
- !NotEnoughUpdates.INSTANCE.config.tradeMenu.customTradePriceStyle;
- return;
- }
- }
- }
- }
-
- public static boolean keyboardInput() {
- if(NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotLocking &&
- NotEnoughUpdates.INSTANCE.config.slotLocking.lockSlotsInTrade &&
- !Keyboard.isRepeatEvent() &&
- KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.slotLocking.slotLockKey)) {
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- int width = scaledResolution.getScaledWidth();
- int height = scaledResolution.getScaledHeight();
-
- int mouseX = Mouse.getEventX() * width / Minecraft.getMinecraft().displayWidth;
- int mouseY = height - Mouse.getEventY() * height / Minecraft.getMinecraft().displayHeight - 1;
-
- int index=0;
- for(ItemStack stack : Minecraft.getMinecraft().thePlayer.inventory.mainInventory) {
- if(stack == null) {
- index++;
- continue;
- }
-
- int x = 8+18*(index % 9);
- int y = 104+18*(index / 9);
- if(index < 9) y = 180;
-
- if(mouseX > guiLeft+x && mouseX < guiLeft+x+16) {
- if(mouseY > guiTop+y && mouseY < guiTop+y+16) {
- SlotLocking.getInstance().toggleLock(index);
- return true;
- }
- }
-
- index++;
- }
- }
-
- return Keyboard.getEventKey() != Keyboard.KEY_ESCAPE;
- }
-
+ private static final ResourceLocation location = new ResourceLocation("notenoughupdates", "custom_trade.png");
+
+ private static final int xSize = 176;
+ private static final int ySize = 204;
+ private static int guiLeft;
+ private static int guiTop;
+
+ private static long lastTradeMillis = -1;
+
+ private static final long CHANGE_EXCLAM_MILLIS = 5000;
+
+ private static Integer[] ourTradeIndexes = new Integer[16];
+ private static Integer[] theirTradeIndexes = new Integer[16];
+ private static String[] theirTradeOld = new String[16];
+ private static Long[] theirTradeChangesMillis = new Long[16];
+
+ private static ItemStack lastBackpack;
+ private static int lastBackpackX;
+ private static int lastBackpackY;
+
+ public static boolean hypixelTradeWindowActive(String containerName) {
+ return containerName != null && containerName.trim().startsWith("You ");
+ }
+
+ public static boolean tradeWindowActive(String containerName) {
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return false;
+ if (!NotEnoughUpdates.INSTANCE.config.tradeMenu.enableCustomTrade) return false;
+
+ if (hypixelTradeWindowActive(containerName)) {
+ return true;
+ }
+
+ if (lastTradeMillis != -99) {
+ lastTradeMillis = -99;
+ ourTradeIndexes = new Integer[16];
+ theirTradeIndexes = new Integer[16];
+ theirTradeOld = new String[16];
+ theirTradeChangesMillis = new Long[16];
+ }
+
+ return false;
+ }
+
+ private static void drawStringShadow(String str, float x, float y, int len) {
+ for (int xOff = -2; xOff <= 2; xOff++) {
+ for (int yOff = -2; yOff <= 2; yOff++) {
+ if (Math.abs(xOff) != Math.abs(yOff)) {
+ Utils.drawStringCenteredScaledMaxWidth(Utils.cleanColourNotModifiers(str),
+ Minecraft.getMinecraft().fontRendererObj,
+ x + xOff / 2f, y + yOff / 2f, false, len,
+ new Color(20, 20, 20, 100 / Math.max(Math.abs(xOff), Math.abs(yOff))).getRGB()
+ );
+ }
+ }
+ }
+
+ Utils.drawStringCenteredScaledMaxWidth(str,
+ Minecraft.getMinecraft().fontRendererObj,
+ x, y, false, len,
+ new Color(64, 64, 64, 255).getRGB()
+ );
+ }
+
+ private static int getPrice(String internalname) {
+ int pricePer = NotEnoughUpdates.INSTANCE.manager.auctionManager.getLowestBin(internalname);
+ if (pricePer == -1) {
+ JsonObject bazaarInfo = NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarInfo(internalname);
+ if (bazaarInfo != null && bazaarInfo.has("avg_buy")) {
+ pricePer = (int) bazaarInfo.get("avg_buy").getAsFloat();
+ }
+ }
+ if (pricePer == -1) {
+ JsonObject info = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfo(internalname);
+ if (info != null && !NotEnoughUpdates.INSTANCE.manager.auctionManager.isVanillaItem(internalname) &&
+ info.has("price") && info.has("count")) {
+ int auctionPricePer = (int) (info.get("price").getAsFloat() / info.get("count").getAsFloat());
+
+ pricePer = auctionPricePer;
+ }
+ }
+ return pricePer;
+ }
+
+ private static int processTopItems(
+ ItemStack stack, Map<Integer, Set<String>> topItems,
+ Map<String, ItemStack> topItemsStack, Map<String, Integer> topItemsCount
+ ) {
+ String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack);
+ if (internalname == null) {
+ if (stack.getDisplayName().endsWith(" coins")) {
+ String clean = Utils.cleanColour(stack.getDisplayName());
+
+ int mult = 1;
+ StringBuilder sb = new StringBuilder();
+ for (int index = 0; index < clean.length(); index++) {
+ char c = clean.charAt(index);
+ if ("0123456789.".indexOf(c) >= 0) {
+ sb.append(c);
+ } else {
+ switch (c) {
+ case 'K':
+ case 'k':
+ mult = 1000;
+ break;
+ case 'M':
+ case 'm':
+ mult = 1000000;
+ break;
+ case 'B':
+ case 'b':
+ mult = 1000000000;
+ break;
+ default:
+ break;
+ }
+ break;
+ }
+ }
+ try {
+ int coins = (int) (Float.parseFloat(sb.toString()) * mult);
+
+ topItemsStack.putIfAbsent("TRADE_COINS", stack);
+
+ int existingPrice = coins;
+ Set<Integer> toRemove = new HashSet<>();
+ for (Map.Entry<Integer, Set<String>> entry : topItems.entrySet()) {
+ if (entry.getValue().contains("TRADE_COINS")) {
+ entry.getValue().remove("TRADE_COINS");
+ existingPrice += entry.getKey();
+ }
+ if (entry.getValue().isEmpty()) toRemove.add(entry.getKey());
+ }
+ topItems.keySet().removeAll(toRemove);
+
+ Set<String> items = topItems.computeIfAbsent(existingPrice, k -> new HashSet<>());
+ items.add("TRADE_COINS");
+
+ return coins;
+
+ } catch (Exception ignored) {
+ }
+ }
+ } else {
+ int pricePer = getPrice(internalname);
+ if (pricePer > 0) {
+ topItemsStack.putIfAbsent(internalname, stack);
+
+ int price = pricePer * stack.stackSize;
+ int priceInclBackpack = price;
+
+ NBTTagCompound tag = stack.getTagCompound();
+ if (tag != null && tag.hasKey("ExtraAttributes", 10)) {
+ NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
+
+ byte[] bytes = null;
+ for (String key : ea.getKeySet()) {
+ if (key.endsWith("backpack_data") || key.equals("new_year_cake_bag_data")) {
+ bytes = ea.getByteArray(key);
+ break;
+ }
+ }
+ if (bytes != null) {
+ try {
+ NBTTagCompound contents_nbt = CompressedStreamTools.readCompressed(new ByteArrayInputStream(bytes));
+ NBTTagList items = contents_nbt.getTagList("i", 10);
+ for (int k = 0; k < items.tagCount(); k++) {
+ if (items.getCompoundTagAt(k).getKeySet().size() > 0) {
+ NBTTagCompound nbt = items.getCompoundTagAt(k).getCompoundTag("tag");
+
+ int id2 = items.getCompoundTagAt(k).getShort("id");
+ int count2 = items.getCompoundTagAt(k).getByte("Count");
+ int damage2 = items.getCompoundTagAt(k).getShort("Damage");
+
+ if (id2 == 141) id2 = 391; //for some reason hypixel thinks carrots have id 141
+
+ Item mcItem = Item.getItemById(id2);
+ if (mcItem == null) continue;
+
+ ItemStack stack2 = new ItemStack(mcItem, count2, damage2);
+ stack2.setTagCompound(nbt);
+
+ priceInclBackpack += processTopItems(stack2, topItems, topItemsStack, topItemsCount);
+ }
+ }
+ } catch (Exception ignored) {
+ }
+ }
+ }
+
+ int existingPrice = price;
+ Set<Integer> toRemove = new HashSet<>();
+ for (Map.Entry<Integer, Set<String>> entry : topItems.entrySet()) {
+ if (entry.getValue().contains(internalname)) {
+ entry.getValue().remove(internalname);
+ existingPrice += entry.getKey();
+ }
+ if (entry.getValue().isEmpty()) toRemove.add(entry.getKey());
+ }
+ topItems.keySet().removeAll(toRemove);
+
+ Set<String> items = topItems.computeIfAbsent(existingPrice, k -> new HashSet<>());
+ items.add(internalname);
+
+ int count = topItemsCount.computeIfAbsent(internalname, l -> 0);
+ topItemsCount.put(internalname, count + stack.stackSize);
+
+ return priceInclBackpack;
+ }
+ }
+ return 0;
+ }
+
+ private static int getBackpackValue(ItemStack stack) {
+ int price = 0;
+
+ NBTTagCompound tag = stack.getTagCompound();
+ if (tag != null && tag.hasKey("ExtraAttributes", 10)) {
+ NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
+
+ byte[] bytes = null;
+ for (String key : ea.getKeySet()) {
+ if (key.endsWith("backpack_data") || key.equals("new_year_cake_bag_data")) {
+ bytes = ea.getByteArray(key);
+ break;
+ }
+ }
+ if (bytes != null) {
+ try {
+ NBTTagCompound contents_nbt = CompressedStreamTools.readCompressed(new ByteArrayInputStream(bytes));
+ NBTTagList items = contents_nbt.getTagList("i", 10);
+ for (int k = 0; k < items.tagCount(); k++) {
+ if (items.getCompoundTagAt(k).getKeySet().size() > 0) {
+ NBTTagCompound nbt = items.getCompoundTagAt(k).getCompoundTag("tag");
+ String internalname2 = NotEnoughUpdates.INSTANCE.manager.getInternalnameFromNBT(nbt);
+ if (internalname2 != null) {
+ int pricePer2 = getPrice(internalname2);
+ if (pricePer2 > 0) {
+ int count2 = items.getCompoundTagAt(k).getByte("Count");
+ price += pricePer2 * count2;
+ }
+ }
+ }
+ }
+ } catch (Exception ignored) {
+ }
+ }
+ }
+ return price;
+ }
+
+ public static void render(int mouseX, int mouseY) {
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) return;
+
+ GuiContainer chest = ((GuiContainer) Minecraft.getMinecraft().currentScreen);
+ ContainerChest cc = (ContainerChest) chest.inventorySlots;
+ String containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText();
+
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+
+ guiLeft = (scaledResolution.getScaledWidth() - xSize) / 2;
+ guiTop = (scaledResolution.getScaledHeight() - ySize) / 2;
+
+ List<String> tooltipToDisplay = null;
+ ItemStack stackToRender = null;
+ int tooltipLen = -1;
+
+ //Set index mappings
+ //Our slots
+ TreeMap<Integer, List<Integer>> ourTradeMap = new TreeMap<>();
+ for (int i = 0; i < 16; i++) {
+ ourTradeIndexes[i] = -1;
+
+ int x = i % 4;
+ int y = i / 4;
+ int containerIndex = y * 9 + x;
+
+ ItemStack stack = chest.inventorySlots.getInventory().get(containerIndex);
+ if (stack == null) continue;
+
+ String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack);
+ if (internalname == null) {
+ if (stack.getDisplayName().endsWith(" coins")) {
+ String clean = Utils.cleanColour(stack.getDisplayName());
+
+ int mult = 1;
+ StringBuilder sb = new StringBuilder();
+ for (int index = 0; index < clean.length(); index++) {
+ char c = clean.charAt(index);
+ if ("0123456789.".indexOf(c) >= 0) {
+ sb.append(c);
+ } else {
+ switch (c) {
+ case 'K':
+ case 'k':
+ mult = 1000;
+ break;
+ case 'M':
+ case 'm':
+ mult = 1000000;
+ break;
+ case 'B':
+ case 'b':
+ mult = 1000000000;
+ break;
+ default:
+ break;
+ }
+ break;
+ }
+ }
+ try {
+ int coins = (int) (Float.parseFloat(sb.toString()) * mult);
+
+ List<Integer> list = ourTradeMap.computeIfAbsent(coins, k -> new ArrayList<>());
+ list.add(containerIndex);
+
+ } catch (Exception ignored) {
+ List<Integer> list = ourTradeMap.computeIfAbsent(-1, k -> new ArrayList<>());
+ list.add(containerIndex);
+ }
+ } else {
+ List<Integer> list = ourTradeMap.computeIfAbsent(-1, k -> new ArrayList<>());
+ list.add(containerIndex);
+ }
+ } else {
+ int price = getPrice(internalname);
+ if (price == -1) price = 0;
+
+ price += getBackpackValue(stack);
+
+ List<Integer> list = ourTradeMap.computeIfAbsent(price, k -> new ArrayList<>());
+ list.add(containerIndex);
+ }
+ }
+ long currentTime = System.currentTimeMillis();
+ List<String> theirTradeCurrent = new ArrayList<>();
+ TreeMap<Integer, List<Integer>> theirTradeMap = new TreeMap<>();
+ HashMap<String, Integer> displayCountMap = new HashMap<>();
+ for (int i = 0; i < 16; i++) {
+ theirTradeIndexes[i] = -1;
+ if (theirTradeChangesMillis[i] == null || currentTime - theirTradeChangesMillis[i] > CHANGE_EXCLAM_MILLIS) {
+ theirTradeChangesMillis[i] = -1L;
+ }
+
+ int x = i % 4;
+ int y = i / 4;
+ int containerIndex = y * 9 + x + 5;
+
+ ItemStack stack = chest.inventorySlots.getInventory().get(containerIndex);
+ if (stack == null) continue;
+
+ NBTTagCompound tag = stack.getTagCompound();
+ String uuid = null;
+ if (tag != null && tag.hasKey("ExtraAttributes", 10)) {
+ NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
+
+ if (ea.hasKey("uuid", 8)) {
+ uuid = ea.getString("uuid");
+ } else {
+ int displayCount = displayCountMap.computeIfAbsent(stack.getDisplayName(), k -> 0);
+ uuid = stack.getDisplayName() + ":" + displayCount;
+ displayCountMap.put(stack.getDisplayName(), displayCount + 1);
+ }
+ } else {
+ int displayCount = displayCountMap.computeIfAbsent(stack.getDisplayName(), k -> 0);
+ uuid = stack.getDisplayName() + ":" + displayCount;
+ displayCountMap.put(stack.getDisplayName(), displayCount + 1);
+ }
+ if (uuid != null) theirTradeCurrent.add(uuid);
+
+ String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack);
+ if (internalname == null) {
+ if (stack.getDisplayName().endsWith(" coins")) {
+ String clean = Utils.cleanColour(stack.getDisplayName());
+
+ int mult = 1;
+ StringBuilder sb = new StringBuilder();
+ for (int index = 0; index < clean.length(); index++) {
+ char c = clean.charAt(index);
+ if ("0123456789.".indexOf(c) >= 0) {
+ sb.append(c);
+ } else {
+ switch (c) {
+ case 'K':
+ case 'k':
+ mult = 1000;
+ break;
+ case 'M':
+ case 'm':
+ mult = 1000000;
+ break;
+ case 'B':
+ case 'b':
+ mult = 1000000000;
+ break;
+ default:
+ break;
+ }
+ break;
+ }
+ }
+ try {
+ int coins = (int) (Float.parseFloat(sb.toString()) * mult);
+
+ List<Integer> list = theirTradeMap.computeIfAbsent(coins, k -> new ArrayList<>());
+ list.add(containerIndex);
+
+ } catch (Exception ignored) {
+ List<Integer> list = theirTradeMap.computeIfAbsent(-1, k -> new ArrayList<>());
+ list.add(containerIndex);
+ }
+ } else {
+ List<Integer> list = theirTradeMap.computeIfAbsent(-1, k -> new ArrayList<>());
+ list.add(containerIndex);
+ }
+ } else {
+ JsonObject info = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfo(internalname);
+ int price = -1;
+ if (info != null && info.has("price") && info.has("count")) {
+ int auctionPricePer = (int) (info.get("price").getAsFloat() / info.get("count").getAsFloat());
+
+ price = auctionPricePer * stack.stackSize;
+ } else {
+ JsonObject bazaarInfo = NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarInfo(internalname);
+ if (bazaarInfo != null && bazaarInfo.has("avg_buy")) {
+ price = (int) bazaarInfo.get("avg_buy").getAsFloat() * stack.stackSize;
+ }
+ }
+
+ price += getBackpackValue(stack);
+
+ List<Integer> list = theirTradeMap.computeIfAbsent(price, k -> new ArrayList<>());
+ list.add(containerIndex);
+ }
+ }
+ int ourTradeIndex = 0;
+ for (Map.Entry<Integer, List<Integer>> entry : ourTradeMap.descendingMap().entrySet()) {
+ for (Integer index : entry.getValue()) {
+ ourTradeIndexes[ourTradeIndex++] = index;
+ }
+ }
+
+ //Their slots
+ int maxMissing = 16 - theirTradeCurrent.size();
+ int j = 0;
+ for (int i = 0; i < 16; i++) {
+ while (j <= 15 && (j - i < maxMissing) && theirTradeChangesMillis[j] >= 0) j++;
+ j = Math.min(15, j);
+
+ String oldUUID = theirTradeOld[i];
+ if (oldUUID != null && !theirTradeCurrent.contains(oldUUID)) {
+ theirTradeChangesMillis[j] = System.currentTimeMillis();
+ }
+ j++;
+ }
+
+ for (int i = 0; i < 16; i++) {
+ theirTradeOld[i] = null;
+ }
+ int theirTradeIndex = 0;
+ displayCountMap.clear();
+ j = 0;
+ for (Map.Entry<Integer, List<Integer>> entry : theirTradeMap.descendingMap().entrySet()) {
+ for (Integer index : entry.getValue()) {
+ while (j <= 15 && (j - theirTradeIndex < maxMissing) && theirTradeChangesMillis[j] >= 0) j++;
+ j = Math.min(15, j);
+
+ theirTradeIndexes[j] = index;
+
+ ItemStack stack = chest.inventorySlots.getInventory().get(index);
+ if (stack == null) continue;
+
+ NBTTagCompound tag = stack.getTagCompound();
+ String uuid = null;
+ if (tag != null && tag.hasKey("ExtraAttributes", 10)) {
+ NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
+
+ if (ea.hasKey("uuid", 8)) {
+ uuid = ea.getString("uuid");
+ } else {
+ int displayCount = displayCountMap.computeIfAbsent(stack.getDisplayName(), k -> 0);
+ uuid = stack.getDisplayName() + ":" + displayCount;
+ displayCountMap.put(stack.getDisplayName(), displayCount + 1);
+ }
+ } else {
+ int displayCount = displayCountMap.computeIfAbsent(stack.getDisplayName(), k -> 0);
+ uuid = stack.getDisplayName() + ":" + displayCount;
+ displayCountMap.put(stack.getDisplayName(), displayCount + 1);
+ }
+ //System.out.println(uuid);
+ theirTradeOld[theirTradeIndex] = uuid;
+
+ j++;
+ theirTradeIndex++;
+ }
+ }
+
+ GlStateManager.color(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(location);
+ Utils.drawTexturedRect(guiLeft, guiTop, xSize, ySize, 0, 176 / 256f, 0, 204 / 256f, GL11.GL_NEAREST);
+
+ Utils.drawStringF(new ChatComponentTranslation("container.inventory").getUnformattedText(),
+ Minecraft.getMinecraft().fontRendererObj, guiLeft + 8, guiTop + 111, false, 4210752
+ );
+ Utils.drawStringF("You", Minecraft.getMinecraft().fontRendererObj, guiLeft + 8,
+ guiTop + 5, false, 4210752
+ );
+ String[] split = containerName.split(" ");
+ if (split.length >= 1) {
+ Utils.drawStringF(split[split.length - 1], Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 167 - Minecraft.getMinecraft().fontRendererObj.getStringWidth(split[split.length - 1]),
+ guiTop + 5, false, 4210752
+ );
+ }
+
+ int index = 0;
+ for (ItemStack stack : Minecraft.getMinecraft().thePlayer.inventory.mainInventory) {
+ int x = 8 + 18 * (index % 9);
+ int y = 104 + 18 * (index / 9);
+ if (index < 9) y = 180;
+
+ chest.drawSlot(new Slot(Minecraft.getMinecraft().thePlayer.inventory, index, guiLeft + x, guiTop + y));
+ //Utils.drawItemStack(stack, guiLeft+x, guiTop+y);
+
+ int col = 0x80ffffff;
+ if (SlotLocking.getInstance().isSlotIndexLocked(index)) {
+ col = 0x80ff8080;
+ }
+
+ if (mouseX > guiLeft + x - 1 && mouseX < guiLeft + x + 18) {
+ if (mouseY > guiTop + y - 1 && mouseY < guiTop + y + 18) {
+ if (stack != null) stackToRender = stack;
+
+ GlStateManager.disableLighting();
+ GlStateManager.disableDepth();
+ GlStateManager.colorMask(true, true, true, false);
+ Utils.drawGradientRect(guiLeft + x, guiTop + y,
+ guiLeft + x + 16, guiTop + y + 16, col, col
+ );
+ GlStateManager.colorMask(true, true, true, true);
+ GlStateManager.enableLighting();
+ GlStateManager.enableDepth();
+ }
+ }
+
+ index++;
+ }
+
+ for (int i = 0; i < 16; i++) {
+ int x = i % 4;
+ int y = i / 4;
+
+ int containerIndex = ourTradeIndexes[i];
+
+ ItemStack stack = null;
+ if (containerIndex >= 0) {
+ stack = chest.inventorySlots.getInventory().get(containerIndex);
+ Utils.drawItemStack(stack, guiLeft + 10 + x * 18, guiTop + 15 + y * 18);
+ }
+
+ if (mouseX > guiLeft + 10 + x * 18 - 1 && mouseX < guiLeft + 10 + x * 18 + 18) {
+ if (mouseY > guiTop + 15 + y * 18 - 1 && mouseY < guiTop + 15 + y * 18 + 18) {
+ if (stack != null) stackToRender = stack;
+
+ GlStateManager.disableLighting();
+ GlStateManager.disableDepth();
+ GlStateManager.colorMask(true, true, true, false);
+ Utils.drawGradientRect(guiLeft + 10 + x * 18, guiTop + 15 + y * 18,
+ guiLeft + 10 + x * 18 + 16, guiTop + 15 + y * 18 + 16, -2130706433, -2130706433
+ );
+ GlStateManager.colorMask(true, true, true, true);
+ GlStateManager.enableLighting();
+ GlStateManager.enableDepth();
+ }
+ }
+ }
+
+ ItemStack bidStack = chest.inventorySlots.getInventory().get(36);
+ if (bidStack != null) {
+ Utils.drawItemStack(bidStack, guiLeft + 10, guiTop + 90);
+ if (mouseX > guiLeft + 10 - 1 && mouseX < guiLeft + 10 + 18) {
+ if (mouseY > guiTop + 90 - 1 && mouseY < guiTop + 90 + 18) {
+ tooltipToDisplay = bidStack.getTooltip(
+ Minecraft.getMinecraft().thePlayer,
+ Minecraft.getMinecraft().gameSettings.advancedItemTooltips
+ );
+ }
+ }
+ }
+
+ ItemStack confirmStack = chest.inventorySlots.getInventory().get(39);
+ if (confirmStack != null) {
+ String confirmDisplay = confirmStack.getDisplayName();
+ if (!confirmDisplay.equals(EnumChatFormatting.GREEN + "Trading!")) {
+ if (mouseX > guiLeft + 81 - 51 && mouseX < guiLeft + 81) {
+ if (mouseY > guiTop + 91 && mouseY < guiTop + 91 + 14) {
+ tooltipToDisplay = confirmStack.getTooltip(
+ Minecraft.getMinecraft().thePlayer,
+ Minecraft.getMinecraft().gameSettings.advancedItemTooltips
+ );
+ }
+ }
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(location);
+ Utils.drawTexturedRect(guiLeft + 81 - 51, guiTop + 91, 51, 14,
+ 0, 51 / 256f, ySize / 256f, (ySize + 14) / 256f, GL11.GL_NEAREST
+ );
+
+ Pattern pattern = Pattern.compile(
+ EnumChatFormatting.GRAY + "\\(" + EnumChatFormatting.YELLOW + "([0-9]+)" + EnumChatFormatting.GRAY + "\\)");
+ Matcher matcher = pattern.matcher(confirmDisplay);
+
+ if (!confirmDisplay.equals(EnumChatFormatting.YELLOW + "Warning!") &&
+ !confirmDisplay.equals(EnumChatFormatting.YELLOW + "Deal!")) {
+ lastTradeMillis = -1;
+ }
+
+ if (matcher.find()) {
+ String numS = matcher.group(1);
+ int num = Integer.parseInt(numS);
+
+ Utils.drawStringCentered(
+ EnumChatFormatting.DARK_RED + "Check " + EnumChatFormatting.BOLD + (char) (9311 + num),
+ Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 56,
+ guiTop + 99,
+ false,
+ 4210752
+ );
+ } else if (confirmDisplay.equals(EnumChatFormatting.AQUA + "Gift!")) {
+ Utils.drawStringCentered(
+ EnumChatFormatting.GREEN + "Accept",
+ Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 56,
+ guiTop + 99,
+ true,
+ 4210752
+ );
+ } else if (confirmDisplay.equals(EnumChatFormatting.GREEN + "Deal accepted!")) {
+ Utils.drawStringCentered(EnumChatFormatting.GREEN + "Accepted", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 56, guiTop + 99, true, 4210752
+ );
+ } else if (lastTradeMillis > 0) {
+ long delta = System.currentTimeMillis() - lastTradeMillis;
+ if (delta > 2000) {
+ Utils.drawStringCentered(
+ EnumChatFormatting.GREEN + "Accept",
+ Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 56,
+ guiTop + 99,
+ true,
+ 4210752
+ );
+ } else {
+ Utils.drawStringCentered(
+ EnumChatFormatting.YELLOW + "Trade " + EnumChatFormatting.BOLD + (char) (9312 + (2000 - delta) / 1000),
+ Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 56,
+ guiTop + 99,
+ true,
+ 4210752
+ );
+ }
+ } else {
+ Utils.drawStringCentered(
+ EnumChatFormatting.YELLOW + "Trade " + EnumChatFormatting.BOLD + (char) (9314),
+ Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 56,
+ guiTop + 99,
+ true,
+ 4210752
+ );
+ }
+ }
+ }
+
+ ItemStack theirConfirmStack = chest.inventorySlots.getInventory().get(41);
+ if (theirConfirmStack != null) {
+ String confirmDisplay = theirConfirmStack.getDisplayName();
+ if (mouseX > guiLeft + 95 && mouseX < guiLeft + 95 + 51) {
+ if (mouseY > guiTop + 91 && mouseY < guiTop + 91 + 14) {
+ tooltipToDisplay = theirConfirmStack.getTooltip(
+ Minecraft.getMinecraft().thePlayer,
+ Minecraft.getMinecraft().gameSettings.advancedItemTooltips
+ );
+ }
+ }
+
+ GlStateManager.color(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(location);
+ Utils.drawTexturedRect(guiLeft + 95, guiTop + 91, 51, 14,
+ 0, 51 / 256f, ySize / 256f, (ySize + 14) / 256f, GL11.GL_NEAREST
+ );
+
+ if (confirmDisplay.equals(EnumChatFormatting.YELLOW + "Pending their confirm")) {
+ Utils.drawStringCentered(
+ EnumChatFormatting.YELLOW + "Pending",
+ Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 120,
+ guiTop + 99,
+ true,
+ 4210752
+ );
+ } else if (confirmDisplay.equals(EnumChatFormatting.YELLOW + "Deal timer...")) {
+ Utils.drawStringCentered(
+ EnumChatFormatting.YELLOW + "Pending",
+ Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 120,
+ guiTop + 99,
+ true,
+ 4210752
+ );
+ } else if (confirmDisplay.equals(EnumChatFormatting.GREEN + "Other player confirmed!")) {
+ Utils.drawStringCentered(
+ EnumChatFormatting.GREEN + "Accepted",
+ Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 120,
+ guiTop + 99,
+ true,
+ 4210752
+ );
+ }
+ }
+
+ for (int i = 0; i < 16; i++) {
+ int x = i % 4;
+ int y = i / 4;
+
+ int containerIndex = theirTradeIndexes[i];
+
+ ItemStack stack = null;
+ if (containerIndex >= 0) {
+ stack = chest.inventorySlots.getInventory().get(containerIndex);
+ Utils.drawItemStack(stack, guiLeft + 96 + x * 18, guiTop + 15 + y * 18);
+ }
+
+ if (currentTime % 400 > 200 && theirTradeChangesMillis[i] != null && theirTradeChangesMillis[i] > 0) {
+ GlStateManager.translate(0, 0, 200);
+ GlStateManager.color(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(location);
+ Utils.drawTexturedRect(guiLeft + 96 + x * 18, guiTop + 15 + y * 18, 16, 16,
+ 51 / 256f, 67 / 256f, 204 / 256f, 220 / 256f, GL11.GL_NEAREST
+ );
+ GlStateManager.translate(0, 0, -200);
+ }
+
+ if (mouseX > guiLeft + 96 + x * 18 - 1 && mouseX < guiLeft + 96 + x * 18 + 18) {
+ if (mouseY > guiTop + 15 + y * 18 - 1 && mouseY < guiTop + 15 + y * 18 + 18) {
+ if (stack != null) stackToRender = stack;
+
+ GlStateManager.disableLighting();
+ GlStateManager.disableDepth();
+ GlStateManager.colorMask(true, true, true, false);
+ Utils.drawGradientRect(guiLeft + 96 + x * 18, guiTop + 15 + y * 18,
+ guiLeft + 96 + x * 18 + 16, guiTop + 15 + y * 18 + 16, -2130706433, -2130706433
+ );
+ GlStateManager.colorMask(true, true, true, true);
+ GlStateManager.enableLighting();
+ GlStateManager.enableDepth();
+ }
+ }
+ }
+
+ if (NotEnoughUpdates.INSTANCE.config.tradeMenu.customTradePrices) {
+ TreeMap<Integer, Set<String>> ourTopItems = new TreeMap<>();
+ TreeMap<String, ItemStack> ourTopItemsStack = new TreeMap<>();
+ TreeMap<String, Integer> ourTopItemsCount = new TreeMap<>();
+ int ourPrice = 0;
+ for (int i = 0; i < 16; i++) {
+ int x = i % 4;
+ int y = i / 4;
+ int containerIndex = y * 9 + x;
+
+ ItemStack stack = chest.inventorySlots.getInventory().get(containerIndex);
+ if (stack == null) continue;
+
+ ourPrice += processTopItems(stack, ourTopItems, ourTopItemsStack, ourTopItemsCount);
+ }
+ TreeMap<Integer, Set<String>> theirTopItems = new TreeMap<>();
+ TreeMap<String, ItemStack> theirTopItemsStack = new TreeMap<>();
+ TreeMap<String, Integer> theirTopItemsCount = new TreeMap<>();
+ int theirPrice = 0;
+ for (int i = 0; i < 16; i++) {
+ int x = i % 4;
+ int y = i / 4;
+ int containerIndex = y * 9 + x + 5;
+
+ ItemStack stack = chest.inventorySlots.getInventory().get(containerIndex);
+ if (stack == null) continue;
+
+ theirPrice += processTopItems(stack, theirTopItems, theirTopItemsStack, theirTopItemsCount);
+ }
+
+ NumberFormat format = NumberFormat.getInstance(Locale.US);
+
+ GlStateManager.disableLighting();
+ GlStateManager.color(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(location);
+ Utils.drawTexturedRect(guiLeft - 80 - 3, guiTop, 80, 106,
+ 176 / 256f, 1, 0, 106 / 256f, GL11.GL_NEAREST
+ );
+ drawStringShadow(EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + "Total Value",
+ guiLeft - 40 - 3, guiTop + 11, 72
+ );
+ drawStringShadow(EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + format.format(ourPrice),
+ guiLeft - 40 - 3, guiTop + 21, 72
+ );
+
+ int ourTopIndex = Math.max(0, 3 - ourTopItemsStack.size());
+ out:
+ for (Map.Entry<Integer, Set<String>> entry : ourTopItems.descendingMap().entrySet()) {
+ for (String ourTopItemInternal : entry.getValue()) {
+ ItemStack stack = ourTopItemsStack.get(ourTopItemInternal);
+ if (stack == null) continue;
+
+ if (NotEnoughUpdates.INSTANCE.config.tradeMenu.customTradePriceStyle) {
+ String countS = "";
+ if (ourTopItemsCount.containsKey(ourTopItemInternal)) {
+ int count = ourTopItemsCount.get(ourTopItemInternal);
+ if (count > 999999) {
+ countS = Math.floor(count / 10000f) / 100f + "m";
+ } else if (count > 999) {
+ countS = Math.floor(count / 10f) / 100f + "k";
+ } else {
+ countS = "" + count;
+ }
+ }
+
+ Utils.drawItemStackWithText(stack, guiLeft - 75 - 3, guiTop + 49 + 18 * ourTopIndex, countS);
+
+ GlStateManager.disableLighting();
+ GlStateManager.disableBlend();
+ GlStateManager.color(1, 1, 1, 1);
+ drawStringShadow(
+ EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + format.format(entry.getKey()),
+ guiLeft - 29 - 3,
+ guiTop + 57 + 18 * ourTopIndex,
+ 52
+ );
+ GlStateManager.enableBlend();
+ } else {
+ drawStringShadow(
+ stack.getDisplayName() + EnumChatFormatting.GRAY + "x" + ourTopItemsCount.get(ourTopItemInternal),
+ guiLeft - 40 - 3,
+ guiTop + 46 + 20 * ourTopIndex,
+ 72
+ );
+ drawStringShadow(
+ EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + format.format(entry.getKey()),
+ guiLeft - 40 - 3,
+ guiTop + 56 + 20 * ourTopIndex,
+ 72
+ );
+ }
+
+ if (++ourTopIndex >= 3) break out;
+ }
+ }
+
+ GlStateManager.color(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(location);
+ Utils.drawTexturedRect(guiLeft + xSize + 3, guiTop, 80, 106,
+ 176 / 256f, 1, 0, 106 / 256f, GL11.GL_NEAREST
+ );
+ drawStringShadow(EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + "Total Value",
+ guiLeft + xSize + 3 + 40, guiTop + 11, 72
+ );
+ drawStringShadow(EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + format.format(theirPrice),
+ guiLeft + xSize + 3 + 40, guiTop + 21, 72
+ );
+
+ int theirTopIndex = Math.max(0, 3 - theirTopItemsStack.size());
+ out:
+ for (Map.Entry<Integer, Set<String>> entry : theirTopItems.descendingMap().entrySet()) {
+ for (String theirTopItemInternal : entry.getValue()) {
+ ItemStack stack = theirTopItemsStack.get(theirTopItemInternal);
+ if (stack == null) continue;
+
+ if (NotEnoughUpdates.INSTANCE.config.tradeMenu.customTradePriceStyle) {
+ String countS = "";
+ if (theirTopItemsCount.containsKey(theirTopItemInternal)) {
+ int count = theirTopItemsCount.get(theirTopItemInternal);
+ if (count > 999999) {
+ countS = Math.floor(count / 10000f) / 100f + "m";
+ } else if (count > 999) {
+ countS = Math.floor(count / 10f) / 100f + "k";
+ } else {
+ countS = "" + count;
+ }
+ }
+
+ Utils.drawItemStackWithText(stack, guiLeft + xSize + 25 + 3 - 16, guiTop + 49 + 18 * theirTopIndex, countS);
+
+ GlStateManager.disableLighting();
+ GlStateManager.disableBlend();
+ GlStateManager.color(1, 1, 1, 1);
+ drawStringShadow(
+ EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + format.format(entry.getKey()),
+ guiLeft + xSize + 3 + 51,
+ guiTop + 57 + 18 * theirTopIndex,
+ 52
+ );
+ GlStateManager.enableBlend();
+ } else {
+ drawStringShadow(stack.getDisplayName(),
+ guiLeft + xSize + 3 + 40, guiTop + 46 + 20 * theirTopIndex, 72
+ );
+ drawStringShadow(
+ EnumChatFormatting.GOLD.toString() + EnumChatFormatting.BOLD + format.format(entry.getKey()),
+ guiLeft + xSize + 3 + 40,
+ guiTop + 56 + 20 * theirTopIndex,
+ 72
+ );
+ }
+
+ if (++theirTopIndex >= 3) break out;
+ }
+ }
+ }
+
+ boolean button1 = NotEnoughUpdates.INSTANCE.config.tradeMenu.customTradePriceStyle;
+ boolean button2 = NotEnoughUpdates.INSTANCE.config.tradeMenu.customTradePrices;
+ boolean button3 = NotEnoughUpdates.INSTANCE.config.tradeMenu.enableCustomTrade;
+
+ GlStateManager.color(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(location);
+ Utils.drawTexturedRect(guiLeft + xSize + 3, guiTop + ySize - 19, 17, 17,
+ (button3 ? 17 : 0) / 256f, (button3 ? 34 : 17) / 256f, 218 / 256f, 235 / 256f, GL11.GL_NEAREST
+ );
+ Utils.drawTexturedRect(guiLeft + xSize + 3, guiTop + ySize - 38, 17, 17,
+ (button2 ? 17 : 0) / 256f, (button2 ? 34 : 17) / 256f, 218 / 256f, 235 / 256f, GL11.GL_NEAREST
+ );
+ Utils.drawTexturedRect(guiLeft + xSize + 3, guiTop + ySize - 57, 17, 17,
+ (button1 ? 17 : 0) / 256f, (button1 ? 34 : 17) / 256f, 218 / 256f, 235 / 256f, GL11.GL_NEAREST
+ );
+
+ if (mouseX >= guiLeft + xSize + 3 && mouseX <= guiLeft + xSize + 3 + 17) {
+ if (mouseY >= guiTop + ySize - 19 && mouseY <= guiTop + ySize - 19 + 17) {
+ tooltipToDisplay = new ArrayList<String>() {{
+ add(EnumChatFormatting.GOLD + "Enable Custom Trade Menu");
+ add(EnumChatFormatting.GRAY + "Use this menu instead of the default trade window");
+ }};
+ tooltipLen = 200;
+ } else if (mouseY >= guiTop + ySize - 38 && mouseY <= guiTop + ySize - 38 + 17) {
+ tooltipToDisplay = new ArrayList<String>() {{
+ add(EnumChatFormatting.GOLD + "Price Information");
+ add(EnumChatFormatting.GRAY + "Show the price of items on both sides");
+ }};
+ tooltipLen = 200;
+ } else if (mouseY >= guiTop + ySize - 57 && mouseY <= guiTop + ySize - 57 + 17) {
+ tooltipToDisplay = new ArrayList<String>() {{
+ add(EnumChatFormatting.GOLD + "Trade Prices Style");
+ add(EnumChatFormatting.GRAY + "Changes the style of the top item prices");
+ }};
+ tooltipLen = 200;
+ }
+ }
+
+ if (stackToRender != null) {
+ tooltipToDisplay = stackToRender.getTooltip(
+ Minecraft.getMinecraft().thePlayer,
+ Minecraft.getMinecraft().gameSettings.advancedItemTooltips
+ );
+ }
+
+ if (tooltipToDisplay != null) {
+ Utils.drawHoveringText(
+ tooltipToDisplay,
+ mouseX,
+ mouseY,
+ scaledResolution.getScaledWidth(),
+ scaledResolution.getScaledHeight(),
+ tooltipLen,
+ Minecraft.getMinecraft().fontRendererObj
+ );
+ }
+ }
+
+ public static void handleMouseInput() {
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) return;
+
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ int width = scaledResolution.getScaledWidth();
+ int height = scaledResolution.getScaledHeight();
+
+ int mouseX = Mouse.getEventX() * width / Minecraft.getMinecraft().displayWidth;
+ int mouseY = height - Mouse.getEventY() * height / Minecraft.getMinecraft().displayHeight - 1;
+
+ GuiContainer chest = ((GuiContainer) Minecraft.getMinecraft().currentScreen);
+
+ if (Mouse.getEventButtonState() && Mouse.isButtonDown(0)) {
+ int index = 0;
+ for (ItemStack stack : Minecraft.getMinecraft().thePlayer.inventory.mainInventory) {
+ if (stack == null) {
+ index++;
+ continue;
+ }
+
+ int x = 8 + 18 * (index % 9);
+ int y = 104 + 18 * (index / 9);
+ if (index < 9) y = 180;
+
+ if (mouseX > guiLeft + x && mouseX < guiLeft + x + 16) {
+ if (mouseY > guiTop + y && mouseY < guiTop + y + 16) {
+ Slot slot = chest.inventorySlots.getSlotFromInventory(Minecraft.getMinecraft().thePlayer.inventory, index);
+ if (!NotEnoughUpdates.INSTANCE.config.slotLocking.lockSlotsInTrade ||
+ !SlotLocking.getInstance().isSlotLocked(slot)) {
+ Minecraft.getMinecraft().playerController.windowClick(
+ chest.inventorySlots.windowId,
+ slot.slotNumber, 2, 3, Minecraft.getMinecraft().thePlayer
+ );
+ }
+ return;
+ }
+ }
+
+ index++;
+ }
+
+ for (int i = 0; i < 16; i++) {
+ int x = i % 4;
+ int y = i / 4;
+
+ Integer containerIndex = ourTradeIndexes[i];
+ if (containerIndex == null || containerIndex < 0) continue;
+
+ if (mouseX > guiLeft + 10 + x * 18 - 1 && mouseX < guiLeft + 10 + x * 18 + 18) {
+ if (mouseY > guiTop + 15 + y * 18 - 1 && mouseY < guiTop + 15 + y * 18 + 18) {
+ Minecraft.getMinecraft().playerController.windowClick(
+ chest.inventorySlots.windowId,
+ containerIndex, 2, 3, Minecraft.getMinecraft().thePlayer
+ );
+ return;
+ }
+ }
+ }
+
+ if (mouseX > guiLeft + 10 - 1 && mouseX < guiLeft + 10 + 18) {
+ if (mouseY > guiTop + 90 - 1 && mouseY < guiTop + 90 + 18) {
+ Minecraft.getMinecraft().playerController.windowClick(
+ chest.inventorySlots.windowId,
+ 36, 2, 3, Minecraft.getMinecraft().thePlayer
+ );
+ return;
+ }
+ }
+
+ ItemStack confirmStack = chest.inventorySlots.getInventory().get(39);
+ if (confirmStack != null) {
+ String confirmDisplay = confirmStack.getDisplayName();
+ if (!confirmDisplay.equals(EnumChatFormatting.GREEN + "Trading!")) {
+ if (mouseX > guiLeft + 42 && mouseX < guiLeft + 42 + 40) {
+ if (mouseY > guiTop + 92 && mouseY < guiTop + 92 + 14) {
+ if ((confirmDisplay.equals(EnumChatFormatting.YELLOW + "Warning!") ||
+ confirmDisplay.equals(EnumChatFormatting.YELLOW + "Deal!")) && lastTradeMillis < 0) {
+ lastTradeMillis = System.currentTimeMillis();
+ } else if (lastTradeMillis < 0 || System.currentTimeMillis() - lastTradeMillis > 2000) {
+ Minecraft.getMinecraft().playerController.windowClick(
+ chest.inventorySlots.windowId,
+ 39, 2, 3, Minecraft.getMinecraft().thePlayer
+ );
+ return;
+ }
+ }
+ }
+
+ }
+ }
+
+ if (mouseX >= guiLeft + xSize + 3 && mouseX <= guiLeft + xSize + 3 + 17) {
+ if (mouseY >= guiTop + ySize - 19 && mouseY <= guiTop + ySize - 19 + 17) {
+ NotEnoughUpdates.INSTANCE.config.tradeMenu.enableCustomTrade =
+ !NotEnoughUpdates.INSTANCE.config.tradeMenu.enableCustomTrade;
+ return;
+ } else if (mouseY >= guiTop + ySize - 38 && mouseY <= guiTop + ySize - 38 + 17) {
+ NotEnoughUpdates.INSTANCE.config.tradeMenu.customTradePrices =
+ !NotEnoughUpdates.INSTANCE.config.tradeMenu.customTradePrices;
+ return;
+ } else if (mouseY >= guiTop + ySize - 57 && mouseY <= guiTop + ySize - 57 + 17) {
+ NotEnoughUpdates.INSTANCE.config.tradeMenu.customTradePriceStyle =
+ !NotEnoughUpdates.INSTANCE.config.tradeMenu.customTradePriceStyle;
+ return;
+ }
+ }
+ }
+ }
+
+ public static boolean keyboardInput() {
+ if (NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotLocking &&
+ NotEnoughUpdates.INSTANCE.config.slotLocking.lockSlotsInTrade &&
+ !Keyboard.isRepeatEvent() &&
+ KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.slotLocking.slotLockKey)) {
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ int width = scaledResolution.getScaledWidth();
+ int height = scaledResolution.getScaledHeight();
+
+ int mouseX = Mouse.getEventX() * width / Minecraft.getMinecraft().displayWidth;
+ int mouseY = height - Mouse.getEventY() * height / Minecraft.getMinecraft().displayHeight - 1;
+
+ int index = 0;
+ for (ItemStack stack : Minecraft.getMinecraft().thePlayer.inventory.mainInventory) {
+ if (stack == null) {
+ index++;
+ continue;
+ }
+
+ int x = 8 + 18 * (index % 9);
+ int y = 104 + 18 * (index / 9);
+ if (index < 9) y = 180;
+
+ if (mouseX > guiLeft + x && mouseX < guiLeft + x + 16) {
+ if (mouseY > guiTop + y && mouseY < guiTop + y + 16) {
+ SlotLocking.getInstance().toggleLock(index);
+ return true;
+ }
+ }
+
+ index++;
+ }
+ }
+
+ return Keyboard.getEventKey() != Keyboard.KEY_ESCAPE;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/tutorials/NeuConfigTutorial.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/tutorials/NeuConfigTutorial.java
index c4d0115f..938f3f98 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/tutorials/NeuConfigTutorial.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/tutorials/NeuConfigTutorial.java
@@ -1,9 +1,7 @@
package io.github.moulberry.notenoughupdates.miscgui.tutorials;
public class NeuConfigTutorial extends TutorialBase {
-
- static {
- title = "NEU Config Tutorial";
- }
-
+ static {
+ title = "NEU Config Tutorial";
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/tutorials/NeuTutorial.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/tutorials/NeuTutorial.java
index 454c8788..24c6bb7f 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/tutorials/NeuTutorial.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/tutorials/NeuTutorial.java
@@ -1,127 +1,149 @@
package io.github.moulberry.notenoughupdates.miscgui.tutorials;
-import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
-import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
-import org.lwjgl.util.vector.Vector2f;
-
-import java.util.ArrayList;
-import java.util.HashMap;
public class NeuTutorial extends TutorialBase {
+ static {
+ title = "NEU Tutorial";
+ }
- static {
- title = "NEU Tutorial";
- }
-
- @Override
- public void setWorldAndResolution(Minecraft mc, int width, int height) {
- super.setWorldAndResolution(mc, width, height);
- screenshots = new ResourceLocation[18];
- for (int i = 0; i <= 17; i++) {
- screenshots[i] = new ResourceLocation("notenoughupdates:ss_small/ss" + (i + 1) + "-0.jpg");
- }
- }
+ @Override
+ public void setWorldAndResolution(Minecraft mc, int width, int height) {
+ super.setWorldAndResolution(mc, width, height);
+ screenshots = new ResourceLocation[18];
+ for (int i = 0; i <= 17; i++) {
+ screenshots[i] = new ResourceLocation("notenoughupdates:ss_small/ss" + (i + 1) + "-0.jpg");
+ }
+ }
-// static {
-//
-// texts[0].put(new Vector2f(0.73f, 0.60f), Utils.createList(
-// EnumChatFormatting.GOLD+"Itemlist",
-// EnumChatFormatting.GRAY+"Here you will find a list of (most) skyblock items",
-// EnumChatFormatting.GRAY+"The itemlist can be accessed by opening your inventory or most menus while on skyblock"));
-// texts[1].put(new Vector2f(0.73f, 0.16f), Utils.createList(
-// EnumChatFormatting.GOLD+"Itemlist",
-// EnumChatFormatting.GRAY+"These are the page controls for the itemlist",
-// EnumChatFormatting.GRAY+"Clicking these controls will bring you to other pages of the itemlist"));
-// texts[2].put(new Vector2f(0.73f, 1.05f), Utils.createList(
-// EnumChatFormatting.GOLD+"Itemlist",
-// EnumChatFormatting.GRAY+"These are the sorting controls for the itemlist",
-// EnumChatFormatting.GRAY+"The buttons on the left control the ordering of the items",
-// EnumChatFormatting.GRAY+"The buttons on the right can be used to filter a certain type of item"));
-// texts[3].put(new Vector2f(0.39f, 1.04f), Utils.createList(
-// EnumChatFormatting.GOLD+"Itemlist",
-// EnumChatFormatting.GRAY+"This is the search bar for the itemlist",
-// EnumChatFormatting.GRAY+"Double-click the bar to enable inventory search mode",
-// EnumChatFormatting.GRAY+"The button on the left opens up the mod settings",
-// EnumChatFormatting.GRAY+"The button on the right displays this tutorial"));
-// texts[4].put(new Vector2f(0.39f, 0.99f), Utils.createList(
-// EnumChatFormatting.GOLD+"QuickCommands",
-// EnumChatFormatting.GRAY+"These are the QuickCommands",
-// EnumChatFormatting.GRAY+"They let you warp around or access certain menus more easily"));
-// texts[5].put(new Vector2f(0.7f, 0.71f), Utils.createList(
-// EnumChatFormatting.GOLD+"Itemlist",
-// EnumChatFormatting.GRAY+"Hover over an item in the list to display it's lore",
-// EnumChatFormatting.GRAY+"Left clicking some items will display the recipe for that item",
-// EnumChatFormatting.GRAY+"Right clicking some items will display a wiki page for that item",
-// EnumChatFormatting.GRAY+"'F' will favourite an item, putting it to the top of the itemlist"));
-// texts[6].put(new Vector2f(0.17f, 0.21f), Utils.createList(
-// EnumChatFormatting.GOLD+"Collection Log",
-// EnumChatFormatting.GRAY+"This is the collection log. It can be accessed using the /neucl command, or via the QuickCommand",
-// EnumChatFormatting.GRAY+"The collection log keeps track of all items that enter your inventory while you are playing skyblock",
-// EnumChatFormatting.GRAY+"If you are a completionist, this feature is for you"));
-// texts[7].put(new Vector2f(0.05f, 0.13f), Utils.createList(
-// EnumChatFormatting.GOLD+"Collection Log",
-// EnumChatFormatting.GRAY+"Clicking on 'Filter' will change the items that",
-// EnumChatFormatting.GRAY+"appear in the list"));
-// texts[8].put(new Vector2f(0.35f, 0.74f), Utils.createList(
-// EnumChatFormatting.GOLD+"NeuAH",
-// EnumChatFormatting.GRAY+"This is the NEU Auction House (NeuAH)",
-// EnumChatFormatting.GRAY+"This AH can be accessed from anywhere using the /neuah command, or via the QuickCommand",
-// EnumChatFormatting.GRAY+"The items here refresh automatically, so there is no need to close the GUI to see the latest auctions",
-// EnumChatFormatting.GRAY+"Sometimes, you might have to wait until the list is populated with items from the API"));
-// texts[9].put(new Vector2f(0.41f, 0.40f), Utils.createList(
-// EnumChatFormatting.GOLD+"NeuAH",
-// EnumChatFormatting.GRAY+"These tabs control the items that appear in NeuAH",
-// EnumChatFormatting.GRAY+"You can find the main categories on the top of the GUI and subcategories appear on the side of the GUI once a main category is selected"));
-// texts[10].put(new Vector2f(0.57f, 0.38f), Utils.createList(
-// EnumChatFormatting.GOLD+"NeuAH",
-// EnumChatFormatting.GRAY+"Search for items using the search bar at the top",
-// EnumChatFormatting.GRAY+"Boolean operators such as &, | or ! work here."));
-// texts[10].put(new Vector2f(0.40f, 0.72f), Utils.createList(
-// EnumChatFormatting.GOLD+"NeuAH",
-// EnumChatFormatting.GRAY+"This toolbar contains many useful features",
-// EnumChatFormatting.GRAY+"which control the sorting and ordering of",
-// EnumChatFormatting.GRAY+"the auction house, similar to the normal AH"));
-// texts[11].put(new Vector2f(0.55f, 0.72f), Utils.createList(
-// EnumChatFormatting.GOLD+"NeuAH",
-// EnumChatFormatting.GRAY+"Clicking on an item will bring up the auction view",
-// EnumChatFormatting.GRAY+"Here you can viewer the buyer/seller and place bids or make purchases",
-// EnumChatFormatting.GRAY+"Trying to purchase an item will result in a confirmation GUI similar to the normal AH"));
-// texts[12].put(new Vector2f(0.28f, 0.82f), Utils.createList(
-// EnumChatFormatting.GOLD+"Profile Viewer",
-// EnumChatFormatting.GRAY+"Access the profile viewer using /neuprofile (ign) or /pv (ign)",
-// EnumChatFormatting.GRAY+"This is the main page of the profile viewer",
-// EnumChatFormatting.GRAY+"This page contains basic information like stats and skill levels"));
-// texts[12].put(new Vector2f(0.72f, 0.55f), Utils.createList(
-// EnumChatFormatting.GOLD+"Profile Viewer",
-// EnumChatFormatting.GRAY+"Click the button on the left to switch profiles and use the bar on the right to switch players"));
-// texts[13].put(new Vector2f(0.28f, 0.82f), Utils.createList(
-// EnumChatFormatting.GOLD+"Profile Viewer",
-// EnumChatFormatting.GRAY+"This is the extra info page of the profile viewer",
-// EnumChatFormatting.GRAY+"This page contains all the small bits of information about a player that don't fit anywhere else"));
-// texts[14].put(new Vector2f(0.28f, 0.82f), Utils.createList(
-// EnumChatFormatting.GOLD+"Profile Viewer",
-// EnumChatFormatting.GRAY+"This is the inventories page of the profile viewer",
-// EnumChatFormatting.GRAY+"Click on the inventory icons in the top-left or use your keyboard to switch the inventory type",
-// EnumChatFormatting.GRAY+"The bar on the bottom-left searches the current inventory for matching items"));
-// texts[15].put(new Vector2f(0.28f, 0.82f), Utils.createList(
-// EnumChatFormatting.GOLD+"Profile Viewer",
-// EnumChatFormatting.GRAY+"This is the collections page of the profile viewer",
-// EnumChatFormatting.GRAY+"Click on the icons on the left or use the keyboard shortcut to switch collection type"));
-// texts[16].put(new Vector2f(0.28f, 0.82f), Utils.createList(
-// EnumChatFormatting.GOLD+"Profile Viewer",
-// EnumChatFormatting.GRAY+"This is the pets page of the profile viewer",
-// EnumChatFormatting.GRAY+"Click to select the pet on the left",
-// EnumChatFormatting.GRAY+"The selected pet's stats will display on the right"));
-// texts[17].put(new Vector2f(0.27f, 0.40f), Utils.createList(
-// EnumChatFormatting.GOLD+"Overlay",
-// EnumChatFormatting.GRAY+"Rearrange certain GUI elements of the main overlay using /neuoverlay",
-// EnumChatFormatting.GRAY+"If you accidentally move them off screen, use the button in the top left to reset the GUI"));
-// }
-//
-// static {
-// buttons = new ArrayList<>();
-// buttons.add(createNewButton(0.27f, 0.40f, new int[]{1, 2},"TESTSHIT", "neu"));
-// }
+ //static {
+ // texts[0].put(new Vector2f(0.73f, 0.60f), Utils.createList(
+ // EnumChatFormatting.GOLD + "Itemlist",
+ // EnumChatFormatting.GRAY + "Here you will find a list of (most) skyblock items",
+ // EnumChatFormatting.GRAY + "The itemlist can be accessed by opening your inventory or most menus while on skyblock"
+ // ));
+ // texts[1].put(new Vector2f(0.73f, 0.16f), Utils.createList(
+ // EnumChatFormatting.GOLD + "Itemlist",
+ // EnumChatFormatting.GRAY + "These are the page controls for the itemlist",
+ // EnumChatFormatting.GRAY + "Clicking these controls will bring you to other pages of the itemlist"
+ // ));
+ // texts[2].put(new Vector2f(0.73f, 1.05f), Utils.createList(
+ // EnumChatFormatting.GOLD + "Itemlist",
+ // EnumChatFormatting.GRAY + "These are the sorting controls for the itemlist",
+ // EnumChatFormatting.GRAY + "The buttons on the left control the ordering of the items",
+ // EnumChatFormatting.GRAY + "The buttons on the right can be used to filter a certain type of item"
+ // ));
+ // texts[3].put(new Vector2f(0.39f, 1.04f), Utils.createList(
+ // EnumChatFormatting.GOLD + "Itemlist",
+ // EnumChatFormatting.GRAY + "This is the search bar for the itemlist",
+ // EnumChatFormatting.GRAY + "Double-click the bar to enable inventory search mode",
+ // EnumChatFormatting.GRAY + "The button on the left opens up the mod settings",
+ // EnumChatFormatting.GRAY + "The button on the right displays this tutorial"
+ // ));
+ // texts[4].put(new Vector2f(0.39f, 0.99f), Utils.createList(
+ // EnumChatFormatting.GOLD + "QuickCommands",
+ // EnumChatFormatting.GRAY + "These are the QuickCommands",
+ // EnumChatFormatting.GRAY + "They let you warp around or access certain menus more easily"
+ // ));
+ // texts[5].put(new Vector2f(0.7f, 0.71f), Utils.createList(
+ // EnumChatFormatting.GOLD + "Itemlist",
+ // EnumChatFormatting.GRAY + "Hover over an item in the list to display it's lore",
+ // EnumChatFormatting.GRAY + "Left clicking some items will display the recipe for that item",
+ // EnumChatFormatting.GRAY + "Right clicking some items will display a wiki page for that item",
+ // EnumChatFormatting.GRAY + "'F' will favourite an item, putting it to the top of the itemlist"
+ // ));
+ // texts[6].put(new Vector2f(0.17f, 0.21f), Utils.createList(
+ // EnumChatFormatting.GOLD + "Collection Log",
+ // EnumChatFormatting.GRAY +
+ // "This is the collection log. It can be accessed using the /neucl command, or via the QuickCommand",
+ // EnumChatFormatting.GRAY +
+ // "The collection log keeps track of all items that enter your inventory while you are playing skyblock",
+ // EnumChatFormatting.GRAY + "If you are a completionist, this feature is for you"
+ // ));
+ // texts[7].put(new Vector2f(0.05f, 0.13f), Utils.createList(
+ // EnumChatFormatting.GOLD + "Collection Log",
+ // EnumChatFormatting.GRAY + "Clicking on 'Filter' will change the items that",
+ // EnumChatFormatting.GRAY + "appear in the list"
+ // ));
+ // texts[8].put(new Vector2f(0.35f, 0.74f), Utils.createList(
+ // EnumChatFormatting.GOLD + "NeuAH",
+ // EnumChatFormatting.GRAY + "This is the NEU Auction House (NeuAH)",
+ // EnumChatFormatting.GRAY +
+ // "This AH can be accessed from anywhere using the /neuah command, or via the QuickCommand",
+ // EnumChatFormatting.GRAY +
+ // "The items here refresh automatically, so there is no need to close the GUI to see the latest auctions",
+ // EnumChatFormatting.GRAY + "Sometimes, you might have to wait until the list is populated with items from the API"
+ // ));
+ // texts[9].put(new Vector2f(0.41f, 0.40f), Utils.createList(
+ // EnumChatFormatting.GOLD + "NeuAH",
+ // EnumChatFormatting.GRAY + "These tabs control the items that appear in NeuAH",
+ // EnumChatFormatting.GRAY +
+ // "You can find the main categories on the top of the GUI and subcategories appear on the side of the GUI once a main category is selected"
+ // ));
+ // texts[10].put(new Vector2f(0.57f, 0.38f), Utils.createList(
+ // EnumChatFormatting.GOLD + "NeuAH",
+ // EnumChatFormatting.GRAY + "Search for items using the search bar at the top",
+ // EnumChatFormatting.GRAY + "Boolean operators such as &, | or ! work here."
+ // ));
+ // texts[10].put(new Vector2f(0.40f, 0.72f), Utils.createList(
+ // EnumChatFormatting.GOLD + "NeuAH",
+ // EnumChatFormatting.GRAY + "This toolbar contains many useful features",
+ // EnumChatFormatting.GRAY + "which control the sorting and ordering of",
+ // EnumChatFormatting.GRAY + "the auction house, similar to the normal AH"
+ // ));
+ // texts[11].put(new Vector2f(0.55f, 0.72f), Utils.createList(
+ // EnumChatFormatting.GOLD + "NeuAH",
+ // EnumChatFormatting.GRAY + "Clicking on an item will bring up the auction view",
+ // EnumChatFormatting.GRAY + "Here you can viewer the buyer/seller and place bids or make purchases",
+ // EnumChatFormatting.GRAY + "Trying to purchase an item will result in a confirmation GUI similar to the normal AH"
+ // ));
+ // texts[12].put(new Vector2f(0.28f, 0.82f), Utils.createList(
+ // EnumChatFormatting.GOLD + "Profile Viewer",
+ // EnumChatFormatting.GRAY + "Access the profile viewer using /neuprofile (ign) or /pv (ign)",
+ // EnumChatFormatting.GRAY + "This is the main page of the profile viewer",
+ // EnumChatFormatting.GRAY + "This page contains basic information like stats and skill levels"
+ // ));
+ // texts[12].put(new Vector2f(0.72f, 0.55f), Utils.createList(
+ // EnumChatFormatting.GOLD + "Profile Viewer",
+ // EnumChatFormatting.GRAY +
+ // "Click the button on the left to switch profiles and use the bar on the right to switch players"
+ // ));
+ // texts[13].put(new Vector2f(0.28f, 0.82f), Utils.createList(
+ // EnumChatFormatting.GOLD + "Profile Viewer",
+ // EnumChatFormatting.GRAY + "This is the extra info page of the profile viewer",
+ // EnumChatFormatting.GRAY +
+ // "This page contains all the small bits of information about a player that don't fit anywhere else"
+ // ));
+ // texts[14].put(new Vector2f(0.28f, 0.82f), Utils.createList(
+ // EnumChatFormatting.GOLD + "Profile Viewer",
+ // EnumChatFormatting.GRAY + "This is the inventories page of the profile viewer",
+ // EnumChatFormatting.GRAY +
+ // "Click on the inventory icons in the top-left or use your keyboard to switch the inventory type",
+ // EnumChatFormatting.GRAY + "The bar on the bottom-left searches the current inventory for matching items"
+ // ));
+ // texts[15].put(new Vector2f(0.28f, 0.82f), Utils.createList(
+ // EnumChatFormatting.GOLD + "Profile Viewer",
+ // EnumChatFormatting.GRAY + "This is the collections page of the profile viewer",
+ // EnumChatFormatting.GRAY + "Click on the icons on the left or use the keyboard shortcut to switch collection type"
+ // ));
+ // texts[16].put(new Vector2f(0.28f, 0.82f), Utils.createList(
+ // EnumChatFormatting.GOLD + "Profile Viewer",
+ // EnumChatFormatting.GRAY + "This is the pets page of the profile viewer",
+ // EnumChatFormatting.GRAY + "Click to select the pet on the left",
+ // EnumChatFormatting.GRAY + "The selected pet's stats will display on the right"
+ // ));
+ // texts[17].put(new Vector2f(0.27f, 0.40f), Utils.createList(
+ // EnumChatFormatting.GOLD + "Overlay",
+ // EnumChatFormatting.GRAY + "Rearrange certain GUI elements of the main overlay using /neuoverlay",
+ // EnumChatFormatting.GRAY +
+ // "If you accidentally move them off screen, use the button in the top left to reset the GUI"
+ // ));
+ //}
+ //
+ //static {
+ // buttons = new ArrayList<JsonObject>() {{
+ // add(createNewButton(0.27f, 0.40f, new int[]{1, 2}, "TESTSHIT", "neu"));
+ // }};
+ //}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/tutorials/TutorialBase.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/tutorials/TutorialBase.java
index 215f210c..433bb996 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/tutorials/TutorialBase.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/tutorials/TutorialBase.java
@@ -22,298 +22,360 @@ import java.util.List;
import static io.github.moulberry.notenoughupdates.miscgui.GuiEnchantColour.custom_ench_colour;
public class TutorialBase extends GuiScreen {
-
- private int guiLeft = 0;
- private int guiTop = 0;
- private int sizeX = 0;
- private int sizeY = 0;
-
- protected static String title;
-
- private int page = 0;
- private ResourceLocation screenshotBorder = new ResourceLocation("notenoughupdates:ss_border.jpg");
-
- protected ResourceLocation[] screenshots = null;
-
- int scaleFactor = 0;
-
-
-
- @Override
- public void setWorldAndResolution(Minecraft mc, int width, int height) {
- super.setWorldAndResolution(mc, width, height);
- }
-
- @Override
- protected void keyTyped(char typedChar, int keyCode) throws IOException {
- Keyboard.enableRepeatEvents(true);
- super.keyTyped(typedChar, keyCode);
- if(keyCode == Keyboard.KEY_LEFT) {
- page--;
- } else if(keyCode == Keyboard.KEY_RIGHT) {
- page++;
- }
- }
-
- @Override
- public void drawScreen(int mouseX, int mouseY, float partialTicks) {
- super.drawScreen(mouseX, mouseY, partialTicks);
-
- drawDefaultBackground();
-
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- scaleFactor = scaledResolution.getScaleFactor();
-
- sizeX = width/2+40/scaleFactor;
- sizeY = height/2+40/scaleFactor;
- guiLeft = width/4-20/scaleFactor;
- guiTop = height/4-20/scaleFactor;
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(screenshotBorder);
- Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY);
-
- page = Math.max(0, Math.min(17, page));
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(screenshots[page]);
- Utils.drawTexturedRect(guiLeft+20f/scaleFactor, guiTop+20f/scaleFactor, sizeX-40f/scaleFactor, sizeY-40f/scaleFactor);
-
- Utils.drawStringCentered(EnumChatFormatting.GOLD+title+" - Page "+(page+1)+"/"+(texts.size())+" - Use arrow keys", Minecraft.getMinecraft().fontRendererObj,
- width/2, guiTop+8, true, 0);
- if(scaleFactor != 2) Utils.drawStringCentered(EnumChatFormatting.GOLD+"Use GUI Scale normal for better reading experience", Minecraft.getMinecraft().fontRendererObj,
- width/2, guiTop+18, true, 0);
- JsonArray pageTexts = texts.get(page);
- for (int i = 0; i < pageTexts.size(); i++) {
- JsonObject textElement = pageTexts.get(i).getAsJsonObject();
- float oldX = textElement.get("x").getAsFloat();
- float oldY = textElement.get("y").getAsFloat();
-
-// List<String> text = entry.getValue();
- JsonArray textArray = textElement.getAsJsonArray("lines");
- List<String> text = new ArrayList<>();
- for (int j = 0; j < textArray.size(); j++) {
- text.add(textArray.get(j).getAsString());
- }
-
-
- float x = guiLeft+20f/scaleFactor+(sizeX-40f/scaleFactor)*oldX;
- float y = guiTop+20f/scaleFactor+(sizeY-40f/scaleFactor)*oldY;
-
- Utils.drawHoveringText(text, (int)x, (int)y+12, 100000, 100000, 200, Minecraft.getMinecraft().fontRendererObj);
- }
-
- drawButtons();
- }
-
- protected void drawButtons(){
-
- for (int i = 0; i < buttons.size(); i++) {
- JsonObject button = buttons.get(i);
- JsonArray pages = button.get("pages").getAsJsonArray();
- boolean drawButton = false;
- for (int i1 = 0; i1 < pages.size(); i1++) {
- if(pages.get(i1).getAsInt() == page){
- drawButton = true;
- break;
- }
- }
- if(!drawButton){
- continue;
- }
- float x = button.get("x").getAsFloat();
- float y = button.get("y").getAsFloat();
- String text = button.get("text").getAsString();
-// String command = button.get("command").getAsString();
- Minecraft.getMinecraft().getTextureManager().bindTexture(custom_ench_colour);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(guiLeft+20f/scaleFactor+(sizeX-40f/scaleFactor)*x, guiTop+20f/scaleFactor+(sizeY-40f/scaleFactor)*y, 88, 20, 64/217f, 152/217f, 48/78f, 68/78f, GL11.GL_NEAREST);
- Utils.drawStringCenteredScaledMaxWidth(text, fontRendererObj, (guiLeft+20f/scaleFactor+(sizeX-40f/scaleFactor)*x)+44, (guiTop+20f/scaleFactor+(sizeY-40f/scaleFactor)*y)+10, false, 86, 4210752);
-
-
- }
- }
-
- @Override
- protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
- super.mouseClicked(mouseX, mouseY, mouseButton);
- int width= 88;
- int height = 20;
-
- for (int i = 0; i < buttons.size(); i++) {
- JsonObject button = buttons.get(i);
- JsonArray pages = button.get("pages").getAsJsonArray();
- boolean drawButton = false;
- for (int i1 = 0; i1 < pages.size(); i1++) {
- if(pages.get(i1).getAsInt() == page){
- drawButton = true;
- break;
- }
- }
- if(!drawButton){
- continue;
- }
- float x = button.get("x").getAsFloat();
- float y = button.get("y").getAsFloat();
- //String text = button.get("text").getAsString();
- float realX = guiLeft+20f/scaleFactor+(sizeX-40f/scaleFactor)*x;
- float realY = guiTop+20f/scaleFactor+(sizeY-40f/scaleFactor)*y;
- if(mouseX > realX && mouseX < realX+width && mouseY > realY && mouseY < realY+height){
- String command = button.get("command").getAsString();
- NotEnoughUpdates.INSTANCE.openGui = null;
- ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/"+command);
- return;
- }
- }
- }
-
-
-
-
-
- protected static List<JsonArray> texts = new ArrayList<JsonArray>();
-
- protected static List<JsonObject> buttons = new ArrayList<>();
-
- protected static JsonObject createNewButton(float x, float y, int[] pages, String text, String command){
- JsonObject button = new JsonObject();
- JsonArray pagesArray = new JsonArray();
- for (int i = 0; i < pages.length; i++) {
- pagesArray.add(new JsonPrimitive(pages[i]));
- }
- button.add("pages",pagesArray);
- button.add("x", new JsonPrimitive(x));
- button.add("y", new JsonPrimitive(y));
- button.add("text", new JsonPrimitive(text));
- button.add("command", new JsonPrimitive(command));
- return button;
- }
-
- protected static JsonArray createNewTexts(JsonObject... texts){
- JsonArray textArray = new JsonArray();
- for (int i = 0; i < texts.length; i++) {
- textArray.add(texts[i]);
- }
- return textArray;
- }
-
- protected static JsonObject createNewText(float x, float y, String... texts){
- JsonObject tooltip = new JsonObject();
- tooltip.add("x", new JsonPrimitive(x));
- tooltip.add("y", new JsonPrimitive(y));
- JsonArray lines = new JsonArray();
- for (int i = 0; i < texts.length; i++) {
- lines.add(new JsonPrimitive(texts[i]));
- }
- tooltip.add("lines", lines);
- return tooltip;
- }
-
- protected static JsonObject createNewText(float x, float y, List<String> texts){
- JsonObject tooltip = new JsonObject();
- tooltip.add("x", new JsonPrimitive(x));
- tooltip.add("y", new JsonPrimitive(y));
- JsonArray lines = new JsonArray();
- for (int i = 0; i < texts.size(); i++) {
- lines.add(new JsonPrimitive(texts.get(i)));
- }
- tooltip.add("lines", lines);
- return tooltip;
- }
-
-// static {
-// for(int i=0; i<18; i++) {
-// texts[i] = new HashMap<>();
-// }
-// texts[0].put(new Vector2f(0.73f, 0.60f), Utils.createList(
-// EnumChatFormatting.GOLD+"Itemlist",
-// EnumChatFormatting.GRAY+"Here you will find a list of (most) skyblock items",
-// EnumChatFormatting.GRAY+"The itemlist can be accessed by opening your inventory or most menus while on skyblock"));
-// texts[1].put(new Vector2f(0.73f, 0.16f), Utils.createList(
-// EnumChatFormatting.GOLD+"Itemlist",
-// EnumChatFormatting.GRAY+"These are the page controls for the itemlist",
-// EnumChatFormatting.GRAY+"Clicking these controls will bring you to other pages of the itemlist"));
-// texts[2].put(new Vector2f(0.73f, 1.05f), Utils.createList(
-// EnumChatFormatting.GOLD+"Itemlist",
-// EnumChatFormatting.GRAY+"These are the sorting controls for the itemlist",
-// EnumChatFormatting.GRAY+"The buttons on the left control the ordering of the items",
-// EnumChatFormatting.GRAY+"The buttons on the right can be used to filter a certain type of item"));
-// texts[3].put(new Vector2f(0.39f, 1.04f), Utils.createList(
-// EnumChatFormatting.GOLD+"Itemlist",
-// EnumChatFormatting.GRAY+"This is the search bar for the itemlist",
-// EnumChatFormatting.GRAY+"Double-click the bar to enable inventory search mode",
-// EnumChatFormatting.GRAY+"The button on the left opens up the mod settings",
-// EnumChatFormatting.GRAY+"The button on the right displays this tutorial"));
-// texts[4].put(new Vector2f(0.39f, 0.99f), Utils.createList(
-// EnumChatFormatting.GOLD+"QuickCommands",
-// EnumChatFormatting.GRAY+"These are the QuickCommands",
-// EnumChatFormatting.GRAY+"They let you warp around or access certain menus more easily"));
-// texts[5].put(new Vector2f(0.7f, 0.71f), Utils.createList(
-// EnumChatFormatting.GOLD+"Itemlist",
-// EnumChatFormatting.GRAY+"Hover over an item in the list to display it's lore",
-// EnumChatFormatting.GRAY+"Left clicking some items will display the recipe for that item",
-// EnumChatFormatting.GRAY+"Right clicking some items will display a wiki page for that item",
-// EnumChatFormatting.GRAY+"'F' will favourite an item, putting it to the top of the itemlist"));
-// texts[6].put(new Vector2f(0.17f, 0.21f), Utils.createList(
-// EnumChatFormatting.GOLD+"Collection Log",
-// EnumChatFormatting.GRAY+"This is the collection log. It can be accessed using the /neucl command, or via the QuickCommand",
-// EnumChatFormatting.GRAY+"The collection log keeps track of all items that enter your inventory while you are playing skyblock",
-// EnumChatFormatting.GRAY+"If you are a completionist, this feature is for you"));
-// texts[7].put(new Vector2f(0.05f, 0.13f), Utils.createList(
-// EnumChatFormatting.GOLD+"Collection Log",
-// EnumChatFormatting.GRAY+"Clicking on 'Filter' will change the items that",
-// EnumChatFormatting.GRAY+"appear in the list"));
-// texts[8].put(new Vector2f(0.35f, 0.74f), Utils.createList(
-// EnumChatFormatting.GOLD+"NeuAH",
-// EnumChatFormatting.GRAY+"This is the NEU Auction House (NeuAH)",
-// EnumChatFormatting.GRAY+"This AH can be accessed from anywhere using the /neuah command, or via the QuickCommand",
-// EnumChatFormatting.GRAY+"The items here refresh automatically, so there is no need to close the GUI to see the latest auctions",
-// EnumChatFormatting.GRAY+"Sometimes, you might have to wait until the list is populated with items from the API"));
-// texts[9].put(new Vector2f(0.41f, 0.40f), Utils.createList(
-// EnumChatFormatting.GOLD+"NeuAH",
-// EnumChatFormatting.GRAY+"These tabs control the items that appear in NeuAH",
-// EnumChatFormatting.GRAY+"You can find the main categories on the top of the GUI and subcategories appear on the side of the GUI once a main category is selected"));
-// texts[10].put(new Vector2f(0.57f, 0.38f), Utils.createList(
-// EnumChatFormatting.GOLD+"NeuAH",
-// EnumChatFormatting.GRAY+"Search for items using the search bar at the top",
-// EnumChatFormatting.GRAY+"Boolean operators such as &, | or ! work here."));
-// texts[10].put(new Vector2f(0.40f, 0.72f), Utils.createList(
-// EnumChatFormatting.GOLD+"NeuAH",
-// EnumChatFormatting.GRAY+"This toolbar contains many useful features",
-// EnumChatFormatting.GRAY+"which control the sorting and ordering of",
-// EnumChatFormatting.GRAY+"the auction house, similar to the normal AH"));
-// texts[11].put(new Vector2f(0.55f, 0.72f), Utils.createList(
-// EnumChatFormatting.GOLD+"NeuAH",
-// EnumChatFormatting.GRAY+"Clicking on an item will bring up the auction view",
-// EnumChatFormatting.GRAY+"Here you can viewer the buyer/seller and place bids or make purchases",
-// EnumChatFormatting.GRAY+"Trying to purchase an item will result in a confirmation GUI similar to the normal AH"));
-// texts[12].put(new Vector2f(0.28f, 0.82f), Utils.createList(
-// EnumChatFormatting.GOLD+"Profile Viewer",
-// EnumChatFormatting.GRAY+"Access the profile viewer using /neuprofile (ign) or /pv (ign)",
-// EnumChatFormatting.GRAY+"This is the main page of the profile viewer",
-// EnumChatFormatting.GRAY+"This page contains basic information like stats and skill levels"));
-// texts[12].put(new Vector2f(0.72f, 0.55f), Utils.createList(
-// EnumChatFormatting.GOLD+"Profile Viewer",
-// EnumChatFormatting.GRAY+"Click the button on the left to switch profiles and use the bar on the right to switch players"));
-// texts[13].put(new Vector2f(0.28f, 0.82f), Utils.createList(
-// EnumChatFormatting.GOLD+"Profile Viewer",
-// EnumChatFormatting.GRAY+"This is the extra info page of the profile viewer",
-// EnumChatFormatting.GRAY+"This page contains all the small bits of information about a player that don't fit anywhere else"));
-// texts[14].put(new Vector2f(0.28f, 0.82f), Utils.createList(
-// EnumChatFormatting.GOLD+"Profile Viewer",
-// EnumChatFormatting.GRAY+"This is the inventories page of the profile viewer",
-// EnumChatFormatting.GRAY+"Click on the inventory icons in the top-left or use your keyboard to switch the inventory type",
-// EnumChatFormatting.GRAY+"The bar on the bottom-left searches the current inventory for matching items"));
-// texts[15].put(new Vector2f(0.28f, 0.82f), Utils.createList(
-// EnumChatFormatting.GOLD+"Profile Viewer",
-// EnumChatFormatting.GRAY+"This is the collections page of the profile viewer",
-// EnumChatFormatting.GRAY+"Click on the icons on the left or use the keyboard shortcut to switch collection type"));
-// texts[16].put(new Vector2f(0.28f, 0.82f), Utils.createList(
-// EnumChatFormatting.GOLD+"Profile Viewer",
-// EnumChatFormatting.GRAY+"This is the pets page of the profile viewer",
-// EnumChatFormatting.GRAY+"Click to select the pet on the left",
-// EnumChatFormatting.GRAY+"The selected pet's stats will display on the right"));
-// texts[17].put(new Vector2f(0.27f, 0.40f), Utils.createList(
-// EnumChatFormatting.GOLD+"Overlay",
-// EnumChatFormatting.GRAY+"Rearrange certain GUI elements of the main overlay using /neuoverlay",
-// EnumChatFormatting.GRAY+"If you accidentally move them off screen, use the button in the top left to reset the GUI"));
-// }
+ private int guiLeft = 0;
+ private int guiTop = 0;
+ private int sizeX = 0;
+ private int sizeY = 0;
+
+ protected static String title;
+
+ private int page = 0;
+ private final ResourceLocation screenshotBorder = new ResourceLocation("notenoughupdates:ss_border.jpg");
+
+ protected ResourceLocation[] screenshots = null;
+
+ int scaleFactor = 0;
+
+ @Override
+ public void setWorldAndResolution(Minecraft mc, int width, int height) {
+ super.setWorldAndResolution(mc, width, height);
+ }
+
+ @Override
+ protected void keyTyped(char typedChar, int keyCode) throws IOException {
+ Keyboard.enableRepeatEvents(true);
+ super.keyTyped(typedChar, keyCode);
+ if (keyCode == Keyboard.KEY_LEFT) {
+ page--;
+ } else if (keyCode == Keyboard.KEY_RIGHT) {
+ page++;
+ }
+ }
+
+ @Override
+ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
+ super.drawScreen(mouseX, mouseY, partialTicks);
+
+ drawDefaultBackground();
+
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ scaleFactor = scaledResolution.getScaleFactor();
+
+ sizeX = width / 2 + 40 / scaleFactor;
+ sizeY = height / 2 + 40 / scaleFactor;
+ guiLeft = width / 4 - 20 / scaleFactor;
+ guiTop = height / 4 - 20 / scaleFactor;
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(screenshotBorder);
+ Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY);
+
+ page = Math.max(0, Math.min(17, page));
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(screenshots[page]);
+ Utils.drawTexturedRect(
+ guiLeft + 20f / scaleFactor,
+ guiTop + 20f / scaleFactor,
+ sizeX - 40f / scaleFactor,
+ sizeY - 40f / scaleFactor
+ );
+
+ Utils.drawStringCentered(
+ EnumChatFormatting.GOLD + title + " - Page " + (page + 1) + "/" + (texts.size()) + " - Use arrow keys",
+ Minecraft.getMinecraft().fontRendererObj,
+ width / 2,
+ guiTop + 8,
+ true,
+ 0
+ );
+ if (scaleFactor != 2)
+ Utils.drawStringCentered(
+ EnumChatFormatting.GOLD + "Use GUI Scale normal for better reading experience",
+ Minecraft.getMinecraft().fontRendererObj,
+ width / 2,
+ guiTop + 18,
+ true,
+ 0
+ );
+ JsonArray pageTexts = texts.get(page);
+ for (int i = 0; i < pageTexts.size(); i++) {
+ JsonObject textElement = pageTexts.get(i).getAsJsonObject();
+ float oldX = textElement.get("x").getAsFloat();
+ float oldY = textElement.get("y").getAsFloat();
+
+ // List<String> text = entry.getValue();
+ JsonArray textArray = textElement.getAsJsonArray("lines");
+ List<String> text = new ArrayList<>();
+ for (int j = 0; j < textArray.size(); j++) {
+ text.add(textArray.get(j).getAsString());
+ }
+
+ float x = guiLeft + 20f / scaleFactor + (sizeX - 40f / scaleFactor) * oldX;
+ float y = guiTop + 20f / scaleFactor + (sizeY - 40f / scaleFactor) * oldY;
+
+ Utils.drawHoveringText(
+ text,
+ (int) x,
+ (int) y + 12,
+ 100000,
+ 100000,
+ 200,
+ Minecraft.getMinecraft().fontRendererObj
+ );
+ }
+
+ drawButtons();
+ }
+
+ protected void drawButtons() {
+
+ for (JsonObject button : buttons) {
+ JsonArray pages = button.get("pages").getAsJsonArray();
+ boolean drawButton = false;
+ for (int i1 = 0; i1 < pages.size(); i1++) {
+ if (pages.get(i1).getAsInt() == page) {
+ drawButton = true;
+ break;
+ }
+ }
+ if (!drawButton) {
+ continue;
+ }
+ float x = button.get("x").getAsFloat();
+ float y = button.get("y").getAsFloat();
+ String text = button.get("text").getAsString();
+ // String command = button.get("command").getAsString();
+ Minecraft.getMinecraft().getTextureManager().bindTexture(custom_ench_colour);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(
+ guiLeft + 20f / scaleFactor + (sizeX - 40f / scaleFactor) * x,
+ guiTop + 20f / scaleFactor + (sizeY - 40f / scaleFactor) * y,
+ 88,
+ 20,
+ 64 / 217f,
+ 152 / 217f,
+ 48 / 78f,
+ 68 / 78f,
+ GL11.GL_NEAREST
+ );
+ Utils.drawStringCenteredScaledMaxWidth(
+ text,
+ fontRendererObj,
+ (guiLeft + 20f / scaleFactor + (sizeX - 40f / scaleFactor) * x) + 44,
+ (guiTop + 20f / scaleFactor + (sizeY - 40f / scaleFactor) * y) + 10,
+ false,
+ 86,
+ 4210752
+ );
+
+ }
+ }
+
+ @Override
+ protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
+ super.mouseClicked(mouseX, mouseY, mouseButton);
+ int width = 88;
+ int height = 20;
+
+ for (JsonObject button : buttons) {
+ JsonArray pages = button.get("pages").getAsJsonArray();
+ boolean drawButton = false;
+ for (int i1 = 0; i1 < pages.size(); i1++) {
+ if (pages.get(i1).getAsInt() == page) {
+ drawButton = true;
+ break;
+ }
+ }
+ if (!drawButton) {
+ continue;
+ }
+ float x = button.get("x").getAsFloat();
+ float y = button.get("y").getAsFloat();
+ // String text = button.get("text").getAsString();
+ float realX = guiLeft + 20f / scaleFactor + (sizeX - 40f / scaleFactor) * x;
+ float realY = guiTop + 20f / scaleFactor + (sizeY - 40f / scaleFactor) * y;
+ if (mouseX > realX && mouseX < realX + width && mouseY > realY && mouseY < realY + height) {
+ String command = button.get("command").getAsString();
+ NotEnoughUpdates.INSTANCE.openGui = null;
+ ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/" + command);
+ return;
+ }
+ }
+ }
+
+ protected static List<JsonArray> texts = new ArrayList<>();
+
+ protected static List<JsonObject> buttons = new ArrayList<>();
+
+ protected static JsonObject createNewButton(float x, float y, int[] pages, String text, String command) {
+ JsonObject button = new JsonObject();
+ JsonArray pagesArray = new JsonArray();
+ for (int j : pages) {
+ pagesArray.add(new JsonPrimitive(j));
+ }
+ button.add("pages", pagesArray);
+ button.add("x", new JsonPrimitive(x));
+ button.add("y", new JsonPrimitive(y));
+ button.add("text", new JsonPrimitive(text));
+ button.add("command", new JsonPrimitive(command));
+ return button;
+ }
+
+ protected static JsonArray createNewTexts(JsonObject... texts) {
+ JsonArray textArray = new JsonArray();
+ for (JsonObject text : texts) {
+ textArray.add(text);
+ }
+ return textArray;
+ }
+
+ protected static JsonObject createNewText(float x, float y, String... texts) {
+ JsonObject tooltip = new JsonObject();
+ tooltip.add("x", new JsonPrimitive(x));
+ tooltip.add("y", new JsonPrimitive(y));
+ JsonArray lines = new JsonArray();
+ for (String text : texts) {
+ lines.add(new JsonPrimitive(text));
+ }
+ tooltip.add("lines", lines);
+ return tooltip;
+ }
+
+ protected static JsonObject createNewText(float x, float y, List<String> texts) {
+ JsonObject tooltip = new JsonObject();
+ tooltip.add("x", new JsonPrimitive(x));
+ tooltip.add("y", new JsonPrimitive(y));
+ JsonArray lines = new JsonArray();
+ for (String text : texts) {
+ lines.add(new JsonPrimitive(text));
+ }
+ tooltip.add("lines", lines);
+ return tooltip;
+ }
+
+ //static {
+ // for (int i = 0; i < 18; i++) {
+ // texts[i] = new HashMap<>();
+ // }
+ // texts[0].put(new Vector2f(0.73f, 0.60f), Utils.createList(
+ // EnumChatFormatting.GOLD + "Itemlist",
+ // EnumChatFormatting.GRAY + "Here you will find a list of (most) skyblock items",
+ // EnumChatFormatting.GRAY + "The itemlist can be accessed by opening your inventory or most menus while on skyblock"
+ // ));
+ // texts[1].put(new Vector2f(0.73f, 0.16f), Utils.createList(
+ // EnumChatFormatting.GOLD + "Itemlist",
+ // EnumChatFormatting.GRAY + "These are the page controls for the itemlist",
+ // EnumChatFormatting.GRAY + "Clicking these controls will bring you to other pages of the itemlist"
+ // ));
+ // texts[2].put(new Vector2f(0.73f, 1.05f), Utils.createList(
+ // EnumChatFormatting.GOLD + "Itemlist",
+ // EnumChatFormatting.GRAY + "These are the sorting controls for the itemlist",
+ // EnumChatFormatting.GRAY + "The buttons on the left control the ordering of the items",
+ // EnumChatFormatting.GRAY + "The buttons on the right can be used to filter a certain type of item"
+ // ));
+ // texts[3].put(new Vector2f(0.39f, 1.04f), Utils.createList(
+ // EnumChatFormatting.GOLD + "Itemlist",
+ // EnumChatFormatting.GRAY + "This is the search bar for the itemlist",
+ // EnumChatFormatting.GRAY + "Double-click the bar to enable inventory search mode",
+ // EnumChatFormatting.GRAY + "The button on the left opens up the mod settings",
+ // EnumChatFormatting.GRAY + "The button on the right displays this tutorial"
+ // ));
+ // texts[4].put(new Vector2f(0.39f, 0.99f), Utils.createList(
+ // EnumChatFormatting.GOLD + "QuickCommands",
+ // EnumChatFormatting.GRAY + "These are the QuickCommands",
+ // EnumChatFormatting.GRAY + "They let you warp around or access certain menus more easily"
+ // ));
+ // texts[5].put(new Vector2f(0.7f, 0.71f), Utils.createList(
+ // EnumChatFormatting.GOLD + "Itemlist",
+ // EnumChatFormatting.GRAY + "Hover over an item in the list to display it's lore",
+ // EnumChatFormatting.GRAY + "Left clicking some items will display the recipe for that item",
+ // EnumChatFormatting.GRAY + "Right clicking some items will display a wiki page for that item",
+ // EnumChatFormatting.GRAY + "'F' will favourite an item, putting it to the top of the itemlist"
+ // ));
+ // texts[6].put(new Vector2f(0.17f, 0.21f), Utils.createList(
+ // EnumChatFormatting.GOLD + "Collection Log",
+ // EnumChatFormatting.GRAY +
+ // "This is the collection log. It can be accessed using the /neucl command, or via the QuickCommand",
+ // EnumChatFormatting.GRAY +
+ // "The collection log keeps track of all items that enter your inventory while you are playing skyblock",
+ // EnumChatFormatting.GRAY + "If you are a completionist, this feature is for you"
+ // ));
+ // texts[7].put(new Vector2f(0.05f, 0.13f), Utils.createList(
+ // EnumChatFormatting.GOLD + "Collection Log",
+ // EnumChatFormatting.GRAY + "Clicking on 'Filter' will change the items that",
+ // EnumChatFormatting.GRAY + "appear in the list"
+ // ));
+ // texts[8].put(new Vector2f(0.35f, 0.74f), Utils.createList(
+ // EnumChatFormatting.GOLD + "NeuAH",
+ // EnumChatFormatting.GRAY + "This is the NEU Auction House (NeuAH)",
+ // EnumChatFormatting.GRAY +
+ // "This AH can be accessed from anywhere using the /neuah command, or via the QuickCommand",
+ // EnumChatFormatting.GRAY +
+ // "The items here refresh automatically, so there is no need to close the GUI to see the latest auctions",
+ // EnumChatFormatting.GRAY + "Sometimes, you might have to wait until the list is populated with items from the API"
+ // ));
+ // texts[9].put(new Vector2f(0.41f, 0.40f), Utils.createList(
+ // EnumChatFormatting.GOLD + "NeuAH",
+ // EnumChatFormatting.GRAY + "These tabs control the items that appear in NeuAH",
+ // EnumChatFormatting.GRAY +
+ // "You can find the main categories on the top of the GUI and subcategories appear on the side of the GUI once a main category is selected"
+ // ));
+ // texts[10].put(new Vector2f(0.57f, 0.38f), Utils.createList(
+ // EnumChatFormatting.GOLD + "NeuAH",
+ // EnumChatFormatting.GRAY + "Search for items using the search bar at the top",
+ // EnumChatFormatting.GRAY + "Boolean operators such as &, | or ! work here."
+ // ));
+ // texts[10].put(new Vector2f(0.40f, 0.72f), Utils.createList(
+ // EnumChatFormatting.GOLD + "NeuAH",
+ // EnumChatFormatting.GRAY + "This toolbar contains many useful features",
+ // EnumChatFormatting.GRAY + "which control the sorting and ordering of",
+ // EnumChatFormatting.GRAY + "the auction house, similar to the normal AH"
+ // ));
+ // texts[11].put(new Vector2f(0.55f, 0.72f), Utils.createList(
+ // EnumChatFormatting.GOLD + "NeuAH",
+ // EnumChatFormatting.GRAY + "Clicking on an item will bring up the auction view",
+ // EnumChatFormatting.GRAY + "Here you can viewer the buyer/seller and place bids or make purchases",
+ // EnumChatFormatting.GRAY + "Trying to purchase an item will result in a confirmation GUI similar to the normal AH"
+ // ));
+ // texts[12].put(new Vector2f(0.28f, 0.82f), Utils.createList(
+ // EnumChatFormatting.GOLD + "Profile Viewer",
+ // EnumChatFormatting.GRAY + "Access the profile viewer using /neuprofile (ign) or /pv (ign)",
+ // EnumChatFormatting.GRAY + "This is the main page of the profile viewer",
+ // EnumChatFormatting.GRAY + "This page contains basic information like stats and skill levels"
+ // ));
+ // texts[12].put(new Vector2f(0.72f, 0.55f), Utils.createList(
+ // EnumChatFormatting.GOLD + "Profile Viewer",
+ // EnumChatFormatting.GRAY +
+ // "Click the button on the left to switch profiles and use the bar on the right to switch players"
+ // ));
+ // texts[13].put(new Vector2f(0.28f, 0.82f), Utils.createList(
+ // EnumChatFormatting.GOLD + "Profile Viewer",
+ // EnumChatFormatting.GRAY + "This is the extra info page of the profile viewer",
+ // EnumChatFormatting.GRAY +
+ // "This page contains all the small bits of information about a player that don't fit anywhere else"
+ // ));
+ // texts[14].put(new Vector2f(0.28f, 0.82f), Utils.createList(
+ // EnumChatFormatting.GOLD + "Profile Viewer",
+ // EnumChatFormatting.GRAY + "This is the inventories page of the profile viewer",
+ // EnumChatFormatting.GRAY +
+ // "Click on the inventory icons in the top-left or use your keyboard to switch the inventory type",
+ // EnumChatFormatting.GRAY + "The bar on the bottom-left searches the current inventory for matching items"
+ // ));
+ // texts[15].put(new Vector2f(0.28f, 0.82f), Utils.createList(
+ // EnumChatFormatting.GOLD + "Profile Viewer",
+ // EnumChatFormatting.GRAY + "This is the collections page of the profile viewer",
+ // EnumChatFormatting.GRAY + "Click on the icons on the left or use the keyboard shortcut to switch collection type"
+ // ));
+ // texts[16].put(new Vector2f(0.28f, 0.82f), Utils.createList(
+ // EnumChatFormatting.GOLD + "Profile Viewer",
+ // EnumChatFormatting.GRAY + "This is the pets page of the profile viewer",
+ // EnumChatFormatting.GRAY + "Click to select the pet on the left",
+ // EnumChatFormatting.GRAY + "The selected pet's stats will display on the right"
+ // ));
+ // texts[17].put(new Vector2f(0.27f, 0.40f), Utils.createList(
+ // EnumChatFormatting.GOLD + "Overlay",
+ // EnumChatFormatting.GRAY + "Rearrange certain GUI elements of the main overlay using /neuoverlay",
+ // EnumChatFormatting.GRAY +
+ // "If you accidentally move them off screen, use the button in the top left to reset the GUI"
+ // ));
+ //}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinAbstractClientPlayer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinAbstractClientPlayer.java
index 9bf260da..5c81c758 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinAbstractClientPlayer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinAbstractClientPlayer.java
@@ -2,8 +2,6 @@ package io.github.moulberry.notenoughupdates.mixins;
import io.github.moulberry.notenoughupdates.miscfeatures.NPCRetexturing;
import net.minecraft.client.entity.AbstractClientPlayer;
-import net.minecraft.client.network.NetworkPlayerInfo;
-import net.minecraft.client.resources.DefaultPlayerSkin;
import net.minecraft.util.ResourceLocation;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@@ -12,31 +10,29 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(AbstractClientPlayer.class)
public class MixinAbstractClientPlayer {
+ @Inject(method = "hasSkin", at = @At("HEAD"), cancellable = true)
+ public void hasSkin(CallbackInfoReturnable<Boolean> cir) {
+ AbstractClientPlayer $this = (AbstractClientPlayer) (Object) this;
+ if (NPCRetexturing.getInstance().getSkin($this) != null) {
+ cir.setReturnValue(true);
+ }
+ }
- @Inject(method="hasSkin", at=@At("HEAD"), cancellable = true)
- public void hasSkin(CallbackInfoReturnable<Boolean> cir) {
- AbstractClientPlayer $this = (AbstractClientPlayer)(Object)this;
- if(NPCRetexturing.getInstance().getSkin($this) != null) {
- cir.setReturnValue(true);
- }
- }
-
- @Inject(method="getLocationSkin()Lnet/minecraft/util/ResourceLocation;", at=@At("HEAD"), cancellable = true)
- public void getLocationSkin(CallbackInfoReturnable<ResourceLocation> cir) {
- AbstractClientPlayer $this = (AbstractClientPlayer)(Object)this;
- NPCRetexturing.Skin skin = NPCRetexturing.getInstance().getSkin($this);
- if(skin != null) {
- cir.setReturnValue(skin.skinLocation);
- }
- }
-
- @Inject(method="getSkinType", at=@At("HEAD"), cancellable = true)
- public void getSkinType(CallbackInfoReturnable<String> cir) {
- AbstractClientPlayer $this = (AbstractClientPlayer)(Object)this;
- NPCRetexturing.Skin skin = NPCRetexturing.getInstance().getSkin($this);
- if(skin != null) {
- cir.setReturnValue(skin.skinny ? "slim" : "default");
- }
- }
+ @Inject(method = "getLocationSkin()Lnet/minecraft/util/ResourceLocation;", at = @At("HEAD"), cancellable = true)
+ public void getLocationSkin(CallbackInfoReturnable<ResourceLocation> cir) {
+ AbstractClientPlayer $this = (AbstractClientPlayer) (Object) this;
+ NPCRetexturing.Skin skin = NPCRetexturing.getInstance().getSkin($this);
+ if (skin != null) {
+ cir.setReturnValue(skin.skinLocation);
+ }
+ }
+ @Inject(method = "getSkinType", at = @At("HEAD"), cancellable = true)
+ public void getSkinType(CallbackInfoReturnable<String> cir) {
+ AbstractClientPlayer $this = (AbstractClientPlayer) (Object) this;
+ NPCRetexturing.Skin skin = NPCRetexturing.getInstance().getSkin($this);
+ if (skin != null) {
+ cir.setReturnValue(skin.skinny ? "slim" : "default");
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinContainer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinContainer.java
index 58aeb828..80d79712 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinContainer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinContainer.java
@@ -2,22 +2,16 @@ package io.github.moulberry.notenoughupdates.mixins;
import io.github.moulberry.notenoughupdates.miscfeatures.EnchantingSolvers;
import net.minecraft.inventory.Container;
-import net.minecraft.inventory.ContainerChest;
-import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
-import org.lwjgl.input.Keyboard;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(Container.class)
public class MixinContainer {
-
- @Inject(method = "putStacksInSlots", at=@At("RETURN"))
- public void putStacksInSlots(ItemStack[] stacks, CallbackInfo ci) {
- EnchantingSolvers.processInventoryContents(false);
- }
-
+ @Inject(method = "putStacksInSlots", at = @At("RETURN"))
+ public void putStacksInSlots(ItemStack[] stacks, CallbackInfo ci) {
+ EnchantingSolvers.processInventoryContents(false);
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEffectRenderer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEffectRenderer.java
index e4c51618..8d0b291a 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEffectRenderer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEffectRenderer.java
@@ -5,28 +5,24 @@ import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.GlStateManager;
import org.lwjgl.util.vector.Vector3f;
-import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
-import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(EffectRenderer.class)
public class MixinEffectRenderer {
+ @Redirect(method = "renderParticles", at = @At(
+ value = "INVOKE",
+ target = "Lnet/minecraft/client/renderer/GlStateManager;enableBlend()V")
+ )
+ public void renderParticles_enableBlend() {
+ GlStateManager.enableBlend();
- @Redirect(method="renderParticles", at=@At(
- value = "INVOKE",
- target = "Lnet/minecraft/client/renderer/GlStateManager;enableBlend()V")
- )
- public void renderParticles_enableBlend() {
- GlStateManager.enableBlend();
-
- Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
- if(currentPosition != null) {
- EntityFX.interpPosX = currentPosition.x;
- EntityFX.interpPosY = currentPosition.y;
- EntityFX.interpPosZ = currentPosition.z;
- }
- }
-
+ Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
+ if (currentPosition != null) {
+ EntityFX.interpPosX = currentPosition.x;
+ EntityFX.interpPosY = currentPosition.y;
+ EntityFX.interpPosZ = currentPosition.z;
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntity.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntity.java
new file mode 100644
index 00000000..86995647
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntity.java
@@ -0,0 +1,24 @@
+package io.github.moulberry.notenoughupdates.mixins;
+
+import net.minecraft.entity.Entity;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+
+@Mixin(Entity.class)
+public class MixinEntity {
+ // Fix NPE in vanilla code, that we need to work for VillagerTradeRecipe
+ @Inject(method = "getBrightnessForRender", at = @At("HEAD"), cancellable = true)
+ public void onGetBrightnessForRender(float p_getBrightnessForRender_1_, CallbackInfoReturnable<Integer> cir) {
+ if (((Entity) (Object) this).worldObj == null)
+ cir.setReturnValue(-1);
+ }
+
+ // Fix NPE in vanilla code, that we need to work for VillagerTradeRecipe
+ @Inject(method = "getBrightness", at = @At("HEAD"), cancellable = true)
+ public void onGetBrightness(float p_getBrightness_1_, CallbackInfoReturnable<Float> cir) {
+ if (((Entity) (Object) this).worldObj == null)
+ cir.setReturnValue(1.0F);
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityAgeable.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityAgeable.java
new file mode 100644
index 00000000..b8f07b53
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityAgeable.java
@@ -0,0 +1,21 @@
+package io.github.moulberry.notenoughupdates.mixins;
+
+import net.minecraft.entity.EntityAgeable;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+
+@Mixin(EntityAgeable.class)
+public class MixinEntityAgeable {
+ @Shadow
+ protected int growingAge;
+
+ // Fix NPE in vanilla code, that we need to work for VillagerTradeRecipe
+ @Inject(method = "getGrowingAge", cancellable = true, at = @At("HEAD"))
+ public void onGetGrowingAge(CallbackInfoReturnable<Integer> cir) {
+ if (((EntityAgeable) (Object) this).worldObj == null)
+ cir.setReturnValue(growingAge);
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityPlayer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityPlayer.java
index 8757e369..e15d18eb 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityPlayer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityPlayer.java
@@ -1,25 +1,64 @@
package io.github.moulberry.notenoughupdates.mixins;
import io.github.moulberry.notenoughupdates.cosmetics.CapeManager;
+import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EnumPlayerModelParts;
+import net.minecraft.scoreboard.ScorePlayerTeam;
+import net.minecraft.scoreboard.Scoreboard;
+import net.minecraft.util.BlockPos;
+import net.minecraft.world.World;
+import org.spongepowered.asm.lib.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin({EntityPlayer.class})
public abstract class MixinEntityPlayer {
+ @Shadow
+ public abstract boolean interactWith(Entity par1);
+
+ @Inject(method = "isWearing", at = @At("HEAD"), cancellable = true)
+ public void isWearing(EnumPlayerModelParts part, CallbackInfoReturnable<Boolean> cir) {
+ if (part == EnumPlayerModelParts.CAPE) {
+ EntityPlayer $this = (EntityPlayer) (Object) this;
+ String uuid = $this.getUniqueID().toString().replace("-", "");
+ String cape = CapeManager.getInstance().getCape(uuid);
+ if (cape != null && !cape.equalsIgnoreCase("null")) {
+ cir.setReturnValue(false);
+ }
+ }
+ }
+
+ @Redirect(method = "<init>", at = @At(value = "FIELD", target = "Lnet/minecraft/world/World;isRemote:Z", opcode = Opcodes.GETFIELD))
+ public boolean onIsRemote(World instance) {
+ if (instance == null) return true;
+ return instance.isRemote;
+ }
+
+ @Redirect(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getSpawnPoint()Lnet/minecraft/util/BlockPos;"))
+ public BlockPos onGetSpawnPoint(World instance) {
+ if (instance == null)
+ return new BlockPos(0, 0, 0);
+ return instance.getSpawnPoint();
+ }
+
+ @Inject(method = "getWorldScoreboard", at = @At("HEAD"), cancellable = true)
+ public void onGetWorldScoreboard(CallbackInfoReturnable<Scoreboard> cir) {
+ if (((EntityPlayer) (Object) this).worldObj == null) {
+ cir.setReturnValue(null);
+ }
+ }
+
+ @Redirect(method = "getTeam", at = @At(value = "INVOKE", target = "Lnet/minecraft/scoreboard/Scoreboard;getPlayersTeam(Ljava/lang/String;)Lnet/minecraft/scoreboard/ScorePlayerTeam;"))
+ public ScorePlayerTeam onGetTeam(Scoreboard instance, String p_getPlayersTeam_1_) {
+ if (instance == null) {
+ return null;
+ }
+ return instance.getPlayersTeam(p_getPlayersTeam_1_);
+ }
- @Inject(method="isWearing", at=@At("HEAD"), cancellable = true)
- public void isWearing(EnumPlayerModelParts part, CallbackInfoReturnable<Boolean> cir) {
- if(part == EnumPlayerModelParts.CAPE) {
- EntityPlayer $this = (EntityPlayer)(Object)this;
- String uuid = $this.getUniqueID().toString().replace("-", "");
- String cape = CapeManager.getInstance().getCape(uuid);
- if(cape != null && !cape.equalsIgnoreCase("null")) {
- cir.setReturnValue(false);
- }
- }
- }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityPlayerSP.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityPlayerSP.java
index 35ee3a63..573eac22 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityPlayerSP.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityPlayerSP.java
@@ -14,19 +14,17 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(EntityPlayerSP.class)
public class MixinEntityPlayerSP {
+ @Inject(method = "dropOneItem", at = @At("HEAD"), cancellable = true)
+ public void dropOneItem(CallbackInfoReturnable<EntityItem> ci) {
+ if (SBInfo.getInstance().isInDungeon) {
+ return;
+ }
- @Inject(method="dropOneItem", at=@At("HEAD"), cancellable = true)
- public void dropOneItem(CallbackInfoReturnable<EntityItem> ci) {
- if(SBInfo.getInstance().isInDungeon) {
- return;
- }
-
- int slot = Minecraft.getMinecraft().thePlayer.inventory.currentItem;
- if(SlotLocking.getInstance().isSlotIndexLocked(slot) || SlotLocking.getInstance().isSwapedSlotLocked()) {
- ci.cancel();
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED+
- "NotEnoughUpdates has prevented you from dropping that locked item!"));
- }
- }
-
+ int slot = Minecraft.getMinecraft().thePlayer.inventory.currentItem;
+ if (SlotLocking.getInstance().isSlotIndexLocked(slot) || SlotLocking.getInstance().isSwapedSlotLocked()) {
+ ci.cancel();
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED +
+ "NotEnoughUpdates has prevented you from dropping that locked item!"));
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityRenderer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityRenderer.java
index 938e214c..26923726 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityRenderer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityRenderer.java
@@ -2,18 +2,14 @@ package io.github.moulberry.notenoughupdates.mixins;
import io.github.moulberry.notenoughupdates.miscfeatures.CustomItemEffects;
import io.github.moulberry.notenoughupdates.miscfeatures.FancyPortals;
-import io.github.moulberry.notenoughupdates.miscgui.InventoryStorageSelector;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.EntityRenderer;
import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.RenderGlobal;
import net.minecraft.client.settings.GameSettings;
import net.minecraft.entity.Entity;
-import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraftforge.client.ForgeHooksClient;
-import org.lwjgl.util.Display;
import org.lwjgl.util.glu.Project;
import org.lwjgl.util.vector.Vector3f;
import org.spongepowered.asm.lib.Opcodes;
@@ -28,135 +24,138 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(EntityRenderer.class)
public abstract class MixinEntityRenderer {
-
- @Shadow protected abstract float getFOVModifier(float partialTicks, boolean useFOVSetting);
-
- @Shadow private Minecraft mc;
-
- @Shadow private float farPlaneDistance;
-
- @Shadow protected abstract void orientCamera(float partialTicks);
-
- @Inject(method="getFOVModifier", at=@At("RETURN"), cancellable = true)
- public void getFOVModifier_mult(float partialTicks, boolean useFOVSetting, CallbackInfoReturnable<Float> cir) {
- cir.setReturnValue(cir.getReturnValueF() * CustomItemEffects.INSTANCE.getFovMultiplier(partialTicks));
- }
-
- @Redirect(method="updateCameraAndRender", at=@At(
- value="FIELD",
- target="Lnet/minecraft/client/settings/GameSettings;mouseSensitivity:F",
- opcode = Opcodes.GETFIELD
- ))
- public float updateCameraAndRender_mouseSensitivity(GameSettings gameSettings) {
- return gameSettings.mouseSensitivity * CustomItemEffects.INSTANCE.getSensMultiplier();
- }
-
- @Redirect(method="renderWorldPass", at=@At(
- value="INVOKE",
- target = "Lorg/lwjgl/util/glu/Project;gluPerspective(FFFF)V",
- remap = false)
- )
- public void perspective(float f1, float f2, float f3, float f4) {
- if(!FancyPortals.overridePerspective()) {
- Project.gluPerspective(f1, f2, f3, f4);
- }
- }
-
- @Inject(method="updateCameraAndRender", at=@At("RETURN"))
- public void onUpdateCameraAndRender(float partialTicks, long nanoTime, CallbackInfo ci) {
- if(Minecraft.getMinecraft().getRenderViewEntity() == null) return;
-
- if(FancyPortals.shouldRenderWorldOverlay()) {
- GlStateManager.matrixMode(5889);
- GlStateManager.loadIdentity();
- Project.gluPerspective(getFOVModifier(partialTicks, true),
- (float)mc.displayWidth / (float)this.mc.displayHeight, 0.05F,
- farPlaneDistance * MathHelper.SQRT_2);
- GlStateManager.matrixMode(5888);
- GlStateManager.loadIdentity();
- orientCamera(partialTicks);
-
- FancyPortals.onUpdateCameraAndRender(partialTicks, nanoTime);
-
- Minecraft.getMinecraft().entityRenderer.setupOverlayRendering();
- }
- }
-
- @Redirect(method="renderWorldPass", at=@At(
- value="INVOKE",
- target = "Lnet/minecraftforge/client/ForgeHooksClient;dispatchRenderLast(Lnet/minecraft/client/renderer/RenderGlobal;F)V",
- remap = false)
- )
- public void renderWorldPass_dispatchRenderLast(RenderGlobal context, float partialTicks) {
- Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
- if(currentPosition != null) {
- Entity entity = Minecraft.getMinecraft().getRenderViewEntity();
- double d0 = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double)partialTicks;
- double d1 = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double)partialTicks;
- double d2 = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * (double)partialTicks;
-
- GlStateManager.translate(-currentPosition.x + d0, -currentPosition.y + d1, -currentPosition.z + d2);
- ForgeHooksClient.dispatchRenderLast(context, partialTicks);
- GlStateManager.translate(currentPosition.x - d0, currentPosition.y - d1, currentPosition.z - d2);
- } else {
- ForgeHooksClient.dispatchRenderLast(context, partialTicks);
- }
- }
-
- //orientCamera
- @ModifyVariable(method="orientCamera", at=@At(value="STORE"), ordinal = 0)
- public double orientCamera_d0(double d0) {
- Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
- if(currentPosition != null) {
- return currentPosition.x;
- }
- return d0;
- }
-
- @ModifyVariable(method="orientCamera", at=@At(value="STORE"), ordinal = 1)
- public double orientCamera_d1(double d1) {
- Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
- if(currentPosition != null) {
- return currentPosition.y;
- }
- return d1;
- }
-
- @ModifyVariable(method="orientCamera", at=@At(value="STORE"), ordinal = 2)
- public double orientCamera_d2(double d2) {
- Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
- if(currentPosition != null) {
- return currentPosition.z;
- }
- return d2;
- }
-
- //renderWorldPass
- @ModifyVariable(method="renderWorldPass", at=@At(value="STORE"), ordinal = 0)
- public double renderWorldPass_d0(double d0) {
- Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
- if(currentPosition != null) {
- return currentPosition.x;
- }
- return d0;
- }
-
- @ModifyVariable(method="renderWorldPass", at=@At(value="STORE"), ordinal = 1)
- public double renderWorldPass_d1(double d1) {
- Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
- if(currentPosition != null) {
- return currentPosition.y;
- }
- return d1;
- }
-
- @ModifyVariable(method="renderWorldPass", at=@At(value="STORE"), ordinal = 2)
- public double renderWorldPass_d2(double d2) {
- Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
- if(currentPosition != null) {
- return currentPosition.z;
- }
- return d2;
- }
-
+ @Shadow
+ protected abstract float getFOVModifier(float partialTicks, boolean useFOVSetting);
+
+ @Shadow
+ private Minecraft mc;
+
+ @Shadow
+ private float farPlaneDistance;
+
+ @Shadow
+ protected abstract void orientCamera(float partialTicks);
+
+ @Inject(method = "getFOVModifier", at = @At("RETURN"), cancellable = true)
+ public void getFOVModifier_mult(float partialTicks, boolean useFOVSetting, CallbackInfoReturnable<Float> cir) {
+ cir.setReturnValue(cir.getReturnValueF() * CustomItemEffects.INSTANCE.getFovMultiplier(partialTicks));
+ }
+
+ @Redirect(method = "updateCameraAndRender", at = @At(
+ value = "FIELD",
+ target = "Lnet/minecraft/client/settings/GameSettings;mouseSensitivity:F",
+ opcode = Opcodes.GETFIELD
+ ))
+ public float updateCameraAndRender_mouseSensitivity(GameSettings gameSettings) {
+ return gameSettings.mouseSensitivity * CustomItemEffects.INSTANCE.getSensMultiplier();
+ }
+
+ @Redirect(method = "renderWorldPass", at = @At(
+ value = "INVOKE",
+ target = "Lorg/lwjgl/util/glu/Project;gluPerspective(FFFF)V",
+ remap = false)
+ )
+ public void perspective(float f1, float f2, float f3, float f4) {
+ if (!FancyPortals.overridePerspective()) {
+ Project.gluPerspective(f1, f2, f3, f4);
+ }
+ }
+
+ @Inject(method = "updateCameraAndRender", at = @At("RETURN"))
+ public void onUpdateCameraAndRender(float partialTicks, long nanoTime, CallbackInfo ci) {
+ if (Minecraft.getMinecraft().getRenderViewEntity() == null) return;
+
+ if (FancyPortals.shouldRenderWorldOverlay()) {
+ GlStateManager.matrixMode(5889);
+ GlStateManager.loadIdentity();
+ Project.gluPerspective(getFOVModifier(partialTicks, true),
+ (float) mc.displayWidth / (float) this.mc.displayHeight, 0.05F,
+ farPlaneDistance * MathHelper.SQRT_2
+ );
+ GlStateManager.matrixMode(5888);
+ GlStateManager.loadIdentity();
+ orientCamera(partialTicks);
+
+ FancyPortals.onUpdateCameraAndRender(partialTicks, nanoTime);
+
+ Minecraft.getMinecraft().entityRenderer.setupOverlayRendering();
+ }
+ }
+
+ @Redirect(method = "renderWorldPass", at = @At(
+ value = "INVOKE",
+ target = "Lnet/minecraftforge/client/ForgeHooksClient;dispatchRenderLast(Lnet/minecraft/client/renderer/RenderGlobal;F)V",
+ remap = false)
+ )
+ public void renderWorldPass_dispatchRenderLast(RenderGlobal context, float partialTicks) {
+ Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
+ if (currentPosition != null) {
+ Entity entity = Minecraft.getMinecraft().getRenderViewEntity();
+ double d0 = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double) partialTicks;
+ double d1 = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double) partialTicks;
+ double d2 = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * (double) partialTicks;
+
+ GlStateManager.translate(-currentPosition.x + d0, -currentPosition.y + d1, -currentPosition.z + d2);
+ ForgeHooksClient.dispatchRenderLast(context, partialTicks);
+ GlStateManager.translate(currentPosition.x - d0, currentPosition.y - d1, currentPosition.z - d2);
+ } else {
+ ForgeHooksClient.dispatchRenderLast(context, partialTicks);
+ }
+ }
+
+ //orientCamera
+ @ModifyVariable(method = "orientCamera", at = @At(value = "STORE"), ordinal = 0)
+ public double orientCamera_d0(double d0) {
+ Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
+ if (currentPosition != null) {
+ return currentPosition.x;
+ }
+ return d0;
+ }
+
+ @ModifyVariable(method = "orientCamera", at = @At(value = "STORE"), ordinal = 1)
+ public double orientCamera_d1(double d1) {
+ Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
+ if (currentPosition != null) {
+ return currentPosition.y;
+ }
+ return d1;
+ }
+
+ @ModifyVariable(method = "orientCamera", at = @At(value = "STORE"), ordinal = 2)
+ public double orientCamera_d2(double d2) {
+ Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
+ if (currentPosition != null) {
+ return currentPosition.z;
+ }
+ return d2;
+ }
+
+ //renderWorldPass
+ @ModifyVariable(method = "renderWorldPass", at = @At(value = "STORE"), ordinal = 0)
+ public double renderWorldPass_d0(double d0) {
+ Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
+ if (currentPosition != null) {
+ return currentPosition.x;
+ }
+ return d0;
+ }
+
+ @ModifyVariable(method = "renderWorldPass", at = @At(value = "STORE"), ordinal = 1)
+ public double renderWorldPass_d1(double d1) {
+ Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
+ if (currentPosition != null) {
+ return currentPosition.y;
+ }
+ return d1;
+ }
+
+ @ModifyVariable(method = "renderWorldPass", at = @At(value = "STORE"), ordinal = 2)
+ public double renderWorldPass_d2(double d2) {
+ Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
+ if (currentPosition != null) {
+ return currentPosition.z;
+ }
+ return d2;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiChest.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiChest.java
index da704ce3..c0d5627d 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiChest.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiChest.java
@@ -11,31 +11,69 @@ import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin({GuiChest.class})
public class MixinGuiChest {
+ private static final String TARGET = "Lnet/minecraft/client/renderer/texture/TextureManager;" +
+ "bindTexture(Lnet/minecraft/util/ResourceLocation;)V";
- private static final String TARGET = "Lnet/minecraft/client/renderer/texture/TextureManager;" +
- "bindTexture(Lnet/minecraft/util/ResourceLocation;)V";
- @Redirect(method="drawGuiContainerBackgroundLayer", at=@At(value="INVOKE", target=TARGET))
- public void drawGuiContainerBackgroundLayer_bindTexture(TextureManager textureManager, ResourceLocation location) {
- BetterContainers.bindHook(textureManager, location);
- }
+ @Redirect(method = "drawGuiContainerBackgroundLayer", at = @At(value = "INVOKE", target = TARGET))
+ public void drawGuiContainerBackgroundLayer_bindTexture(TextureManager textureManager, ResourceLocation location) {
+ BetterContainers.bindHook(textureManager, location);
+ }
- private static final String TARGET_DRAWSTRING = "Lnet/minecraft/client/gui/FontRenderer;drawString(Ljava/lang/String;III)I";
- @Redirect(method="drawGuiContainerForegroundLayer", at=@At(value="INVOKE", target = TARGET_DRAWSTRING))
- public int drawGuiContainerForegroundLayer_drawString(FontRenderer fontRenderer, String text, int x, int y, int color) {
- return fontRenderer.drawString(text, x, y, BetterContainers.isOverriding() ? BetterContainers.getTextColour() : color);
- }
+ private static final String TARGET_DRAWSTRING =
+ "Lnet/minecraft/client/gui/FontRenderer;drawString(Ljava/lang/String;III)I";
- private static final String TARGET_SBADRAWSTRING = "Lcodes/biscuit/skyblockaddons/asm/hooks/GuiChestHook;" +
- "drawString(Lnet/minecraft/client/gui/FontRenderer;Ljava/lang/String;III)I";
- @Redirect(method="drawGuiContainerForegroundLayer", at=@At(value="INVOKE", target = TARGET_SBADRAWSTRING, remap = false))
- public int drawGuiContainerForegroundLayer_SBA_drawString(FontRenderer fontRenderer, String text, int x, int y, int color) {
- try {
- return (int)Class.forName("codes.biscuit.skyblockaddons.asm.hooks.GuiChestHook")
- .getDeclaredMethod("drawString", FontRenderer.class, String.class, int.class, int.class, int.class)
- .invoke(null, fontRenderer, text, x, y, BetterContainers.isOverriding() ? BetterContainers.getTextColour() : color);
- } catch(Exception e) {}
- return fontRenderer.drawString(text, x, y, BetterContainers.isOverriding() ? BetterContainers.getTextColour() : color);
- }
+ @Redirect(method = "drawGuiContainerForegroundLayer", at = @At(value = "INVOKE", target = TARGET_DRAWSTRING))
+ public int drawGuiContainerForegroundLayer_drawString(
+ FontRenderer fontRenderer,
+ String text,
+ int x,
+ int y,
+ int color
+ ) {
+ return fontRenderer.drawString(
+ text,
+ x,
+ y,
+ BetterContainers.isOverriding() ? BetterContainers.getTextColour() : color
+ );
+ }
+ private static final String TARGET_SBADRAWSTRING = "Lcodes/biscuit/skyblockaddons/asm/hooks/GuiChestHook;" +
+ "drawString(Lnet/minecraft/client/gui/FontRenderer;Ljava/lang/String;III)I";
+ @Redirect(method = "drawGuiContainerForegroundLayer", at = @At(value = "INVOKE", target = TARGET_SBADRAWSTRING, remap = false))
+ public int drawGuiContainerForegroundLayer_SBA_drawString(
+ FontRenderer fontRenderer,
+ String text,
+ int x,
+ int y,
+ int color
+ ) {
+ try {
+ return (int) Class.forName("codes.biscuit.skyblockaddons.asm.hooks.GuiChestHook")
+ .getDeclaredMethod(
+ "drawString",
+ FontRenderer.class,
+ String.class,
+ int.class,
+ int.class,
+ int.class
+ )
+ .invoke(
+ null,
+ fontRenderer,
+ text,
+ x,
+ y,
+ BetterContainers.isOverriding() ? BetterContainers.getTextColour() : color
+ );
+ } catch (Exception ignored) {
+ }
+ return fontRenderer.drawString(
+ text,
+ x,
+ y,
+ BetterContainers.isOverriding() ? BetterContainers.getTextColour() : color
+ );
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java
index db72f903..4d1545b6 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java
@@ -2,8 +2,8 @@ package io.github.moulberry.notenoughupdates.mixins;
import io.github.moulberry.notenoughupdates.NEUEventListener;
import io.github.moulberry.notenoughupdates.NEUOverlay;
-import io.github.moulberry.notenoughupdates.miscfeatures.*;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.miscfeatures.*;
import io.github.moulberry.notenoughupdates.miscgui.GuiCustomEnchant;
import io.github.moulberry.notenoughupdates.miscgui.StorageOverlay;
import io.github.moulberry.notenoughupdates.util.Utils;
@@ -37,256 +37,297 @@ import java.util.concurrent.atomic.AtomicBoolean;
@Mixin(GuiContainer.class)
public abstract class MixinGuiContainer extends GuiScreen {
-
- private static boolean hasProfileViewerStack = false;
- private static final ItemStack profileViewerStack = Utils.createItemStack(Item.getItemFromBlock(Blocks.command_block),
- EnumChatFormatting.GREEN + "Profile Viewer",
- EnumChatFormatting.YELLOW + "Click to open NEU profile viewer!");
-
- @Inject(method="drawSlot", at=@At("RETURN"))
- public void drawSlotRet(Slot slotIn, CallbackInfo ci) {
- SlotLocking.getInstance().drawSlot(slotIn);
- }
-
- @Inject(method="drawSlot", at=@At("HEAD"), cancellable = true)
- public void drawSlot(Slot slot, CallbackInfo ci) {
- if(slot == null) return;
-
- GuiContainer $this = (GuiContainer)(Object)this;
-
- if(!hasProfileViewerStack && $this instanceof GuiChest && slot.getSlotIndex() > 9 && (slot.getSlotIndex() % 9 == 6 || slot.getSlotIndex() % 9 == 7) &&
- BetterContainers.isBlankStack(-1, slot.getStack())) {
- BetterContainers.profileViewerStackIndex = -1;
- hasProfileViewerStack = true;
-
- GuiChest eventGui = (GuiChest) $this;
- ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
- String containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText();
- if(containerName.contains(" Profile") && cc.inventorySlots.size() >= 54) {
- if(cc.inventorySlots.get(22).getStack() != null && cc.inventorySlots.get(22).getStack().getTagCompound() != null){
- NBTTagCompound tag = eventGui.inventorySlots.inventorySlots.get(22).getStack().getTagCompound();
- if(tag.hasKey("SkullOwner") && tag.getCompoundTag("SkullOwner").hasKey("Name")){
- String tagName = tag.getCompoundTag("SkullOwner").getString("Name");
- String displayname = Utils.cleanColour(cc.inventorySlots.get(22).getStack().getDisplayName());
- if(tagName.equals(displayname.substring(displayname.length()-tagName.length()))) {
- ci.cancel();
-
- this.zLevel = 100.0F;
- this.itemRender.zLevel = 100.0F;
-
- GlStateManager.enableDepth();
- this.itemRender.renderItemAndEffectIntoGUI(profileViewerStack, slot.xDisplayPosition, slot.yDisplayPosition);
- this.itemRender.renderItemOverlayIntoGUI(this.fontRendererObj, profileViewerStack,
- slot.xDisplayPosition, slot.yDisplayPosition, "");
-
- this.itemRender.zLevel = 0.0F;
- this.zLevel = 0.0F;
-
- BetterContainers.profileViewerStackIndex = slot.getSlotIndex();
- }
- }
- }
- }
- } else if (slot.getSlotIndex() == 0)
- hasProfileViewerStack = false;
- else if(!($this instanceof GuiChest))
- BetterContainers.profileViewerStackIndex = -1;
-
- if(slot.getStack() == null && NotEnoughUpdates.INSTANCE.overlay.searchMode && NEUEventListener.drawingGuiScreen) {
- GlStateManager.pushMatrix();
- GlStateManager.translate(0, 0, 100 + Minecraft.getMinecraft().getRenderItem().zLevel);
- GlStateManager.depthMask(false);
- Gui.drawRect(slot.xDisplayPosition, slot.yDisplayPosition,
- slot.xDisplayPosition+16, slot.yDisplayPosition+16, NEUOverlay.overlayColourDark);
- GlStateManager.depthMask(true);
- GlStateManager.popMatrix();
- }
-
- ItemStack stack = slot.getStack();
-
- if(stack != null) {
- if(EnchantingSolvers.onStackRender(stack, slot.inventory, slot.getSlotIndex(), slot.xDisplayPosition, slot.yDisplayPosition)) {
- ci.cancel();
- return;
- }
- }
-
- RenderHelper.enableGUIStandardItemLighting();
-
- if(BetterContainers.isOverriding() && !BetterContainers.shouldRenderStack(slot.slotNumber, stack)) {
- ci.cancel();
- }
- }
-
- @Redirect(method="drawScreen", at=@At(
- value = "INVOKE",
- target = "Lnet/minecraft/client/gui/inventory/GuiContainer;renderToolTip(Lnet/minecraft/item/ItemStack;II)V"))
- public void drawScreen_renderTooltip(GuiContainer guiContainer, ItemStack stack, int x, int y) {
- if(theSlot.slotNumber == BetterContainers.profileViewerStackIndex) {
- this.renderToolTip(profileViewerStack, x, y);
- } else {
- this.renderToolTip(stack, x, y);
- }
- }
-
- @Inject(method="drawScreen",
- at=@At(
- value = "INVOKE",
- target = "Lnet/minecraft/client/renderer/GlStateManager;popMatrix()V",
- shift = At.Shift.AFTER
- )
- )
- public void drawScreen_after(int mouseX, int mouseY, float partialTicks, CallbackInfo ci) {
- AuctionSortModeWarning.getInstance().onPostGuiRender();
- }
-
- @Redirect(method="mouseReleased", at=@At(value = "INVOKE", target = "Ljava/util/Set;isEmpty()Z"))
- public boolean mouseReleased_isEmpty(Set<?> set) {
- return set.size() <= 1;
- }
-
- @Inject(method="isMouseOverSlot", at=@At("HEAD"), cancellable = true)
- public void isMouseOverSlot(Slot slotIn, int mouseX, int mouseY, CallbackInfoReturnable<Boolean> cir) {
- StorageOverlay.getInstance().overrideIsMouseOverSlot(slotIn, mouseX, mouseY, cir);
- GuiCustomEnchant.getInstance().overrideIsMouseOverSlot(slotIn, mouseX, mouseY, cir);
- AuctionBINWarning.getInstance().overrideIsMouseOverSlot(slotIn, mouseX, mouseY, cir);
- }
-
- @Redirect(method="drawScreen", at=@At(value="INVOKE", target = "Lnet/minecraft/client/gui/inventory/GuiContainer;drawGradientRect(IIIIII)V"))
- public void drawScreen_drawGradientRect(GuiContainer container, int left, int top, int right, int bottom, int startColor, int endColor) {
- if(startColor == 0x80ffffff && endColor == 0x80ffffff &&
- theSlot != null && SlotLocking.getInstance().isSlotLocked(theSlot)) {
- int col = 0x80ff8080;
- drawGradientRect(left, top, right, bottom, col, col);
- } else {
- drawGradientRect(left, top, right, bottom, startColor, endColor);
- }
- }
-
- @Shadow
- private Slot theSlot;
-
- @Inject(method="drawScreen", at=@At("RETURN"))
- public void drawScreen(CallbackInfo ci) {
- if(theSlot != null && SlotLocking.getInstance().isSlotLocked(theSlot)) {
- SlotLocking.getInstance().setRealSlot(theSlot);
- theSlot = null;
- } else if(theSlot == null){
- SlotLocking.getInstance().setRealSlot(null);
- }
- }
-
- private static final String TARGET_GETSTACK = "Lnet/minecraft/inventory/Slot;getStack()Lnet/minecraft/item/ItemStack;";
- @Redirect(method="drawScreen", at=@At(value="INVOKE", target=TARGET_GETSTACK))
- public ItemStack drawScreen_getStack(Slot slot) {
- if(theSlot != null && theSlot == slot && theSlot.getStack() != null) {
- ItemStack newStack = EnchantingSolvers.overrideStack(theSlot.inventory, theSlot.getSlotIndex(), theSlot.getStack());
- if(newStack != null) {
- return newStack;
- }
- }
- return slot.getStack();
- }
-
- @Redirect(method="drawSlot", at=@At(value="INVOKE", target=TARGET_GETSTACK))
- public ItemStack drawSlot_getStack(Slot slot) {
- GuiContainer $this = (GuiContainer)(Object)this;
-
- ItemStack stack = slot.getStack();
-
- if(stack != null) {
- ItemStack newStack = EnchantingSolvers.overrideStack(slot.inventory, slot.getSlotIndex(), stack);
- if(newStack != null) {
- stack = newStack;
- }
- }
-
- if($this instanceof GuiChest) {
- Container container = ((GuiChest)$this).inventorySlots;
- if(container instanceof ContainerChest) {
- IInventory lower = ((ContainerChest)container).getLowerChestInventory();
- int size = lower.getSizeInventory();
- if(slot.slotNumber >= size) {
- return stack;
- }
- if(System.currentTimeMillis() - BetterContainers.lastRenderMillis < 300 && stack == null) {
- for(int index=0; index<size; index++) {
- if(lower.getStackInSlot(index) != null) {
- BetterContainers.itemCache.put(slot.slotNumber, null);
- return null;
- }
- }
- return BetterContainers.itemCache.get(slot.slotNumber);
- } else {
- BetterContainers.itemCache.put(slot.slotNumber, stack);
- }
- }
- }
- return stack;
- }
-
- private static final String TARGET_CANBEHOVERED = "Lnet/minecraft/inventory/Slot;canBeHovered()Z";
- @Redirect(method="drawScreen", at=@At(value="INVOKE", target=TARGET_CANBEHOVERED))
- public boolean drawScreen_canBeHovered(Slot slot) {
- if(NotEnoughUpdates.INSTANCE.config.improvedSBMenu.hideEmptyPanes &&
- BetterContainers.isOverriding() && BetterContainers.isBlankStack(slot.slotNumber, slot.getStack())) {
- return false;
- }
- return slot.canBeHovered();
- }
-
- @Inject(method="checkHotbarKeys", at=@At(value = "INVOKE", target = "Lnet/minecraft/client/gui/inventory/GuiContainer;handleMouseClick(Lnet/minecraft/inventory/Slot;III)V"), locals = LocalCapture.CAPTURE_FAILSOFT ,cancellable = true)
- public void checkHotbarKeys_Slotlock(int keyCode, CallbackInfoReturnable<Boolean> cir, int i){
- if(SlotLocking.getInstance().isSlotIndexLocked(i)){
- cir.setReturnValue(false);
- }
- }
-
- @Inject(method="handleMouseClick", at=@At(value="HEAD"), cancellable = true)
- public void handleMouseClick(Slot slotIn, int slotId, int clickedButton, int clickType, CallbackInfo ci) {
- GuiContainer $this = (GuiContainer)(Object)this;
-
- if(AuctionBINWarning.getInstance().onMouseClick(slotIn, slotId, clickedButton, clickType)) {
- ci.cancel();
- return;
- }
-
- AtomicBoolean ret = new AtomicBoolean(false);
- SlotLocking.getInstance().onWindowClick(slotIn, slotId, clickedButton, clickType, (tuple) -> {
- ci.cancel();
-
- if(tuple == null) {
- ret.set(true);
- } else {
- int newSlotId = tuple.getLeft();
- int newClickedButton = tuple.getMiddle();
- int newClickedType = tuple.getRight();
-
- ret.set(true);
- $this.mc.playerController.windowClick($this.inventorySlots.windowId, newSlotId, newClickedButton, newClickedType, $this.mc.thePlayer);
- }
- });
- if(ret.get()) return;
-
- if(slotIn != null && slotIn.getStack() != null) {
- if(EnchantingSolvers.onStackClick(slotIn.getStack(), $this.inventorySlots.windowId,
- slotId, clickedButton, clickType)) {
- ci.cancel();
- } else {
- PetInfoOverlay.onStackClick(slotIn.getStack(), $this.inventorySlots.windowId,
- slotId, clickedButton, clickType);
- }
- }
- if(slotIn != null && BetterContainers.isOverriding() && (BetterContainers.isBlankStack(slotIn.slotNumber, slotIn.getStack()) ||
- BetterContainers.isButtonStack(slotIn.slotNumber, slotIn.getStack()))) {
- BetterContainers.clickSlot(slotIn.getSlotIndex());
-
- if(BetterContainers.isBlankStack(slotIn.slotNumber, slotIn.getStack())) {
- $this.mc.playerController.windowClick($this.inventorySlots.windowId, slotId, 2, clickType, $this.mc.thePlayer);
- ci.cancel();
- } else {
- Utils.playPressSound();
- }
- }
- }
+ private static boolean hasProfileViewerStack = false;
+ private static final ItemStack profileViewerStack = Utils.createItemStack(
+ Item.getItemFromBlock(Blocks.command_block),
+ EnumChatFormatting.GREEN + "Profile Viewer",
+ EnumChatFormatting.YELLOW + "Click to open NEU profile viewer!"
+ );
+
+ @Inject(method = "drawSlot", at = @At("RETURN"))
+ public void drawSlotRet(Slot slotIn, CallbackInfo ci) {
+ SlotLocking.getInstance().drawSlot(slotIn);
+ }
+
+ @Inject(method = "drawSlot", at = @At("HEAD"), cancellable = true)
+ public void drawSlot(Slot slot, CallbackInfo ci) {
+ if (slot == null) return;
+
+ GuiContainer $this = (GuiContainer) (Object) this;
+
+ if (!hasProfileViewerStack && $this instanceof GuiChest && slot.getSlotIndex() > 9 &&
+ (slot.getSlotIndex() % 9 == 6 || slot.getSlotIndex() % 9 == 7) &&
+ BetterContainers.isBlankStack(-1, slot.getStack())) {
+ BetterContainers.profileViewerStackIndex = -1;
+ hasProfileViewerStack = true;
+
+ GuiChest eventGui = (GuiChest) $this;
+ ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
+ String containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText();
+ if (containerName.contains(" Profile") && cc.inventorySlots.size() >= 54) {
+ if (cc.inventorySlots.get(22).getStack() != null &&
+ cc.inventorySlots.get(22).getStack().getTagCompound() != null) {
+ NBTTagCompound tag = eventGui.inventorySlots.inventorySlots.get(22).getStack().getTagCompound();
+ if (tag.hasKey("SkullOwner") && tag.getCompoundTag("SkullOwner").hasKey("Name")) {
+ String tagName = tag.getCompoundTag("SkullOwner").getString("Name");
+ String displayname = Utils.cleanColour(cc.inventorySlots.get(22).getStack().getDisplayName());
+ if (tagName.equals(displayname.substring(displayname.length() - tagName.length()))) {
+ ci.cancel();
+
+ this.zLevel = 100.0F;
+ this.itemRender.zLevel = 100.0F;
+
+ GlStateManager.enableDepth();
+ this.itemRender.renderItemAndEffectIntoGUI(
+ profileViewerStack,
+ slot.xDisplayPosition,
+ slot.yDisplayPosition
+ );
+ this.itemRender.renderItemOverlayIntoGUI(this.fontRendererObj, profileViewerStack,
+ slot.xDisplayPosition, slot.yDisplayPosition, ""
+ );
+
+ this.itemRender.zLevel = 0.0F;
+ this.zLevel = 0.0F;
+
+ BetterContainers.profileViewerStackIndex = slot.getSlotIndex();
+ }
+ }
+ }
+ }
+ } else if (slot.getSlotIndex() == 0)
+ hasProfileViewerStack = false;
+ else if (!($this instanceof GuiChest))
+ BetterContainers.profileViewerStackIndex = -1;
+
+ if (slot.getStack() == null && NotEnoughUpdates.INSTANCE.overlay.searchMode && NEUEventListener.drawingGuiScreen) {
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(0, 0, 100 + Minecraft.getMinecraft().getRenderItem().zLevel);
+ GlStateManager.depthMask(false);
+ Gui.drawRect(slot.xDisplayPosition, slot.yDisplayPosition,
+ slot.xDisplayPosition + 16, slot.yDisplayPosition + 16, NEUOverlay.overlayColourDark
+ );
+ GlStateManager.depthMask(true);
+ GlStateManager.popMatrix();
+ }
+
+ ItemStack stack = slot.getStack();
+
+ if (stack != null) {
+ if (EnchantingSolvers.onStackRender(
+ stack,
+ slot.inventory,
+ slot.getSlotIndex(),
+ slot.xDisplayPosition,
+ slot.yDisplayPosition
+ )) {
+ ci.cancel();
+ return;
+ }
+ }
+
+ RenderHelper.enableGUIStandardItemLighting();
+
+ if (BetterContainers.isOverriding() && !BetterContainers.shouldRenderStack(slot.slotNumber, stack)) {
+ ci.cancel();
+ }
+ }
+
+ @Redirect(method = "drawScreen", at = @At(
+ value = "INVOKE",
+ target = "Lnet/minecraft/client/gui/inventory/GuiContainer;renderToolTip(Lnet/minecraft/item/ItemStack;II)V"))
+ public void drawScreen_renderTooltip(GuiContainer guiContainer, ItemStack stack, int x, int y) {
+ if (theSlot.slotNumber == BetterContainers.profileViewerStackIndex) {
+ this.renderToolTip(profileViewerStack, x, y);
+ } else {
+ this.renderToolTip(stack, x, y);
+ }
+ }
+
+ @Inject(method = "drawScreen",
+ at = @At(
+ value = "INVOKE",
+ target = "Lnet/minecraft/client/renderer/GlStateManager;popMatrix()V",
+ shift = At.Shift.AFTER
+ )
+ )
+ public void drawScreen_after(int mouseX, int mouseY, float partialTicks, CallbackInfo ci) {
+ AuctionSortModeWarning.getInstance().onPostGuiRender();
+ }
+
+ @Redirect(method = "mouseReleased", at = @At(value = "INVOKE", target = "Ljava/util/Set;isEmpty()Z"))
+ public boolean mouseReleased_isEmpty(Set<?> set) {
+ return set.size() <= 1;
+ }
+
+ @Inject(method = "isMouseOverSlot", at = @At("HEAD"), cancellable = true)
+ public void isMouseOverSlot(Slot slotIn, int mouseX, int mouseY, CallbackInfoReturnable<Boolean> cir) {
+ StorageOverlay.getInstance().overrideIsMouseOverSlot(slotIn, mouseX, mouseY, cir);
+ GuiCustomEnchant.getInstance().overrideIsMouseOverSlot(slotIn, mouseX, mouseY, cir);
+ AuctionBINWarning.getInstance().overrideIsMouseOverSlot(slotIn, mouseX, mouseY, cir);
+ }
+
+ @Redirect(method = "drawScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/inventory/GuiContainer;drawGradientRect(IIIIII)V"))
+ public void drawScreen_drawGradientRect(
+ GuiContainer container,
+ int left,
+ int top,
+ int right,
+ int bottom,
+ int startColor,
+ int endColor
+ ) {
+ if (startColor == 0x80ffffff && endColor == 0x80ffffff &&
+ theSlot != null && SlotLocking.getInstance().isSlotLocked(theSlot)) {
+ int col = 0x80ff8080;
+ drawGradientRect(left, top, right, bottom, col, col);
+ } else {
+ drawGradientRect(left, top, right, bottom, startColor, endColor);
+ }
+ }
+
+ @Shadow
+ private Slot theSlot;
+
+ @Inject(method = "drawScreen", at = @At("RETURN"))
+ public void drawScreen(CallbackInfo ci) {
+ if (theSlot != null && SlotLocking.getInstance().isSlotLocked(theSlot)) {
+ SlotLocking.getInstance().setRealSlot(theSlot);
+ theSlot = null;
+ } else if (theSlot == null) {
+ SlotLocking.getInstance().setRealSlot(null);
+ }
+ }
+
+ private static final String TARGET_GETSTACK =
+ "Lnet/minecraft/inventory/Slot;getStack()Lnet/minecraft/item/ItemStack;";
+
+ @Redirect(method = "drawScreen", at = @At(value = "INVOKE", target = TARGET_GETSTACK))
+ public ItemStack drawScreen_getStack(Slot slot) {
+ if (theSlot != null && theSlot == slot && theSlot.getStack() != null) {
+ ItemStack newStack = EnchantingSolvers.overrideStack(
+ theSlot.inventory,
+ theSlot.getSlotIndex(),
+ theSlot.getStack()
+ );
+ if (newStack != null) {
+ return newStack;
+ }
+ }
+ return slot.getStack();
+ }
+
+ @Redirect(method = "drawSlot", at = @At(value = "INVOKE", target = TARGET_GETSTACK))
+ public ItemStack drawSlot_getStack(Slot slot) {
+ GuiContainer $this = (GuiContainer) (Object) this;
+
+ ItemStack stack = slot.getStack();
+
+ if (stack != null) {
+ ItemStack newStack = EnchantingSolvers.overrideStack(slot.inventory, slot.getSlotIndex(), stack);
+ if (newStack != null) {
+ stack = newStack;
+ }
+ }
+
+ if ($this instanceof GuiChest) {
+ Container container = $this.inventorySlots;
+ if (container instanceof ContainerChest) {
+ IInventory lower = ((ContainerChest) container).getLowerChestInventory();
+ int size = lower.getSizeInventory();
+ if (slot.slotNumber >= size) {
+ return stack;
+ }
+ if (System.currentTimeMillis() - BetterContainers.lastRenderMillis < 300 && stack == null) {
+ for (int index = 0; index < size; index++) {
+ if (lower.getStackInSlot(index) != null) {
+ BetterContainers.itemCache.put(slot.slotNumber, null);
+ return null;
+ }
+ }
+ return BetterContainers.itemCache.get(slot.slotNumber);
+ } else {
+ BetterContainers.itemCache.put(slot.slotNumber, stack);
+ }
+ }
+ }
+ return stack;
+ }
+
+ private static final String TARGET_CANBEHOVERED = "Lnet/minecraft/inventory/Slot;canBeHovered()Z";
+
+ @Redirect(method = "drawScreen", at = @At(value = "INVOKE", target = TARGET_CANBEHOVERED))
+ public boolean drawScreen_canBeHovered(Slot slot) {
+ if (NotEnoughUpdates.INSTANCE.config.improvedSBMenu.hideEmptyPanes &&
+ BetterContainers.isOverriding() && BetterContainers.isBlankStack(slot.slotNumber, slot.getStack())) {
+ return false;
+ }
+ return slot.canBeHovered();
+ }
+
+ @Inject(method = "checkHotbarKeys", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/inventory/GuiContainer;handleMouseClick(Lnet/minecraft/inventory/Slot;III)V"), locals = LocalCapture.CAPTURE_FAILSOFT, cancellable = true)
+ public void checkHotbarKeys_Slotlock(int keyCode, CallbackInfoReturnable<Boolean> cir, int i) {
+ if (SlotLocking.getInstance().isSlotIndexLocked(i)) {
+ cir.setReturnValue(false);
+ }
+ }
+
+ @Inject(method = "handleMouseClick", at = @At(value = "HEAD"), cancellable = true)
+ public void handleMouseClick(Slot slotIn, int slotId, int clickedButton, int clickType, CallbackInfo ci) {
+ GuiContainer $this = (GuiContainer) (Object) this;
+
+ if (AuctionBINWarning.getInstance().onMouseClick(slotIn, slotId, clickedButton, clickType)) {
+ ci.cancel();
+ return;
+ }
+
+ AtomicBoolean ret = new AtomicBoolean(false);
+ SlotLocking.getInstance().onWindowClick(slotIn, slotId, clickedButton, clickType, (tuple) -> {
+ ci.cancel();
+
+ if (tuple == null) {
+ ret.set(true);
+ } else {
+ int newSlotId = tuple.getLeft();
+ int newClickedButton = tuple.getMiddle();
+ int newClickedType = tuple.getRight();
+
+ ret.set(true);
+ $this.mc.playerController.windowClick(
+ $this.inventorySlots.windowId,
+ newSlotId,
+ newClickedButton,
+ newClickedType,
+ $this.mc.thePlayer
+ );
+ }
+ });
+ if (ret.get()) return;
+
+ if (slotIn != null && slotIn.getStack() != null) {
+ if (EnchantingSolvers.onStackClick(slotIn.getStack(), $this.inventorySlots.windowId,
+ slotId, clickedButton, clickType
+ )) {
+ ci.cancel();
+ } else {
+ PetInfoOverlay.onStackClick(slotIn.getStack(), $this.inventorySlots.windowId,
+ slotId, clickedButton, clickType
+ );
+ }
+ }
+ if (slotIn != null && BetterContainers.isOverriding() && (BetterContainers.isBlankStack(
+ slotIn.slotNumber,
+ slotIn.getStack()
+ ) ||
+ BetterContainers.isButtonStack(slotIn.slotNumber, slotIn.getStack()))) {
+ BetterContainers.clickSlot(slotIn.getSlotIndex());
+
+ if (BetterContainers.isBlankStack(slotIn.slotNumber, slotIn.getStack())) {
+ $this.mc.playerController.windowClick($this.inventorySlots.windowId, slotId, 2, clickType, $this.mc.thePlayer);
+ ci.cancel();
+ } else {
+ Utils.playPressSound();
+ }
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiIngame.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiIngame.java
index 28b14bb2..7f7f25c8 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiIngame.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiIngame.java
@@ -19,37 +19,46 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin({GuiIngame.class})
public class MixinGuiIngame {
+ private static final String TARGET = "Lnet/minecraft/scoreboard/ScorePlayerTeam;" +
+ "formatPlayerName(Lnet/minecraft/scoreboard/Team;Ljava/lang/String;)Ljava/lang/String;";
- private static final String TARGET = "Lnet/minecraft/scoreboard/ScorePlayerTeam;" +
- "formatPlayerName(Lnet/minecraft/scoreboard/Team;Ljava/lang/String;)Ljava/lang/String;";
- @Redirect(method="renderScoreboard", at=@At(value="INVOKE", target=TARGET))
- public String renderScoreboard_formatPlayerName(Team team, String name) {
- if(NotEnoughUpdates.INSTANCE.isOnSkyblock() && NotEnoughUpdates.INSTANCE.config.misc.streamerMode) {
- return StreamerMode.filterScoreboard(ScorePlayerTeam.formatPlayerName(team, name));
- }
- return ScorePlayerTeam.formatPlayerName(team, name);
- }
+ @Redirect(method = "renderScoreboard", at = @At(value = "INVOKE", target = TARGET))
+ public String renderScoreboard_formatPlayerName(Team team, String name) {
+ if (NotEnoughUpdates.INSTANCE.isOnSkyblock() && NotEnoughUpdates.INSTANCE.config.misc.streamerMode) {
+ return StreamerMode.filterScoreboard(ScorePlayerTeam.formatPlayerName(team, name));
+ }
+ return ScorePlayerTeam.formatPlayerName(team, name);
+ }
- @Inject(method="renderTooltip", at=@At("HEAD"))
- protected void renderTooltip(ScaledResolution sr, float partialTicks, CallbackInfo ci) {
- if(Minecraft.getMinecraft().getRenderViewEntity() instanceof EntityPlayer) {
- InventoryStorageSelector.getInstance().render(sr, partialTicks);
- }
- }
+ @Inject(method = "renderTooltip", at = @At("HEAD"))
+ protected void renderTooltip(ScaledResolution sr, float partialTicks, CallbackInfo ci) {
+ if (Minecraft.getMinecraft().getRenderViewEntity() instanceof EntityPlayer) {
+ InventoryStorageSelector.getInstance().render(sr, partialTicks);
+ }
+ }
- @Redirect(method="renderTooltip", at=@At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiIngame;drawTexturedModalRect(IIIIII)V"))
- public void renderTooltooltip_drawTexturedModelRect(GuiIngame guiIngame, int x, int y, int textureX, int textureY, int width, int height) {
- if(!InventoryStorageSelector.getInstance().isSlotSelected() || textureX != 0 || textureY != 22 || width != 24 || height != 22) {
- guiIngame.drawTexturedModalRect(x, y, textureX, textureY, width, height);
- }
- }
+ @Redirect(method = "renderTooltip", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiIngame;drawTexturedModalRect(IIIIII)V"))
+ public void renderTooltooltip_drawTexturedModelRect(
+ GuiIngame guiIngame,
+ int x,
+ int y,
+ int textureX,
+ int textureY,
+ int width,
+ int height
+ ) {
+ if (!InventoryStorageSelector.getInstance().isSlotSelected() || textureX != 0 || textureY != 22 || width != 24 ||
+ height != 22) {
+ guiIngame.drawTexturedModalRect(x, y, textureX, textureY, width, height);
+ }
+ }
- @Redirect(method="updateTick", at=@At(value = "INVOKE", target = "Lnet/minecraft/entity/player/InventoryPlayer;getCurrentItem()Lnet/minecraft/item/ItemStack;"))
- public ItemStack updateTick_getCurrentItem(InventoryPlayer inventory) {
- if(!NotEnoughUpdates.INSTANCE.config.storageGUI.showInvBackpackPreview &&
- InventoryStorageSelector.getInstance().isSlotSelected()) {
- return InventoryStorageSelector.getInstance().getNamedHeldItemOverride();
- }
- return inventory.getCurrentItem();
- }
+ @Redirect(method = "updateTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/InventoryPlayer;getCurrentItem()Lnet/minecraft/item/ItemStack;"))
+ public ItemStack updateTick_getCurrentItem(InventoryPlayer inventory) {
+ if (!NotEnoughUpdates.INSTANCE.config.storageGUI.showInvBackpackPreview &&
+ InventoryStorageSelector.getInstance().isSlotSelected()) {
+ return InventoryStorageSelector.getInstance().getNamedHeldItemOverride();
+ }
+ return inventory.getCurrentItem();
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiInventory.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiInventory.java
index 9a5d739e..25b036ab 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiInventory.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiInventory.java
@@ -10,13 +10,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(GuiInventory.class)
public class MixinGuiInventory {
-
- @Inject(method="drawGuiContainerForegroundLayer", at=@At("HEAD"), cancellable = true)
- protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY, CallbackInfo ci) {
- if(NotEnoughUpdates.INSTANCE.config.inventoryButtons.hideCrafting ||
- NEUEventListener.disableCraftingText) {
- ci.cancel();
- }
- }
-
+ @Inject(method = "drawGuiContainerForegroundLayer", at = @At("HEAD"), cancellable = true)
+ protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY, CallbackInfo ci) {
+ if (NotEnoughUpdates.INSTANCE.config.inventoryButtons.hideCrafting ||
+ NEUEventListener.disableCraftingText) {
+ ci.cancel();
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiScreen.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiScreen.java
index 6b1065ea..eac2b2d5 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiScreen.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiScreen.java
@@ -1,7 +1,6 @@
package io.github.moulberry.notenoughupdates.mixins;
import io.github.moulberry.notenoughupdates.util.SBInfo;
-import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.gui.GuiScreen;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@@ -10,10 +9,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(GuiScreen.class)
public class MixinGuiScreen {
-
- @Inject(method = "sendChatMessage(Ljava/lang/String;Z)V", at=@At("HEAD"))
- public void onSendChatMessage(String message, boolean addToChat, CallbackInfo ci) {
- SBInfo.getInstance().onSendChatMessage(message);
- }
-
+ @Inject(method = "sendChatMessage(Ljava/lang/String;Z)V", at = @At("HEAD"))
+ public void onSendChatMessage(String message, boolean addToChat, CallbackInfo ci) {
+ SBInfo.getInstance().onSendChatMessage(message);
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinInventoryEffectRenderer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinInventoryEffectRenderer.java
index 390896f2..fb5707fe 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinInventoryEffectRenderer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinInventoryEffectRenderer.java
@@ -4,21 +4,17 @@ import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import net.minecraft.client.renderer.InventoryEffectRenderer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
-import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
-
@Mixin({InventoryEffectRenderer.class})
public class MixinInventoryEffectRenderer {
-
- @ModifyVariable(method="updateActivePotionEffects", at=@At(value="STORE"))
- public boolean hasVisibleEffect_updateActivePotionEffects(boolean hasVisibleEffect) {
- if(NotEnoughUpdates.INSTANCE.config.misc.hidePotionEffect &&
- NotEnoughUpdates.INSTANCE.isOnSkyblock()) {
- return false;
- } else {
- return hasVisibleEffect;
- }
- }
-
+ @ModifyVariable(method = "updateActivePotionEffects", at = @At(value = "STORE"))
+ public boolean hasVisibleEffect_updateActivePotionEffects(boolean hasVisibleEffect) {
+ if (NotEnoughUpdates.INSTANCE.config.misc.hidePotionEffect &&
+ NotEnoughUpdates.INSTANCE.isOnSkyblock()) {
+ return false;
+ } else {
+ return hasVisibleEffect;
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinInventoryPlayer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinInventoryPlayer.java
index f60a4839..345b5171 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinInventoryPlayer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinInventoryPlayer.java
@@ -10,21 +10,17 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(InventoryPlayer.class)
public class MixinInventoryPlayer {
+ @Inject(method = "changeCurrentItem", at = @At("RETURN"))
+ public void changeCurrentItemReturn(int direction, CallbackInfo ci) {
+ InventoryPlayer $this = (InventoryPlayer) (Object) this;
- @Inject(method="changeCurrentItem", at=@At("RETURN"))
- public void changeCurrentItemReturn(int direction, CallbackInfo ci) {
- InventoryPlayer $this = (InventoryPlayer)(Object)this;
+ $this.currentItem = InventoryStorageSelector.getInstance().onScroll(direction, $this.currentItem);
+ }
- $this.currentItem = InventoryStorageSelector.getInstance().onScroll(direction, $this.currentItem);
-
-
- }
-
- @Inject(method="changeCurrentItem", at=@At("HEAD"))
- public void changeCurrentItemHead(int direction, CallbackInfo ci) {
- InventoryPlayer $this = (InventoryPlayer)(Object)this;
-
- SlotLocking.getInstance().changedSlot($this.currentItem);
- }
+ @Inject(method = "changeCurrentItem", at = @At("HEAD"))
+ public void changeCurrentItemHead(int direction, CallbackInfo ci) {
+ InventoryPlayer $this = (InventoryPlayer) (Object) this;
+ SlotLocking.getInstance().changedSlot($this.currentItem);
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemCameraTransforms.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemCameraTransforms.java
index 36987677..da2b2e08 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemCameraTransforms.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemCameraTransforms.java
@@ -9,10 +9,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(ItemCameraTransforms.class)
public class MixinItemCameraTransforms {
-
- @Inject(method="applyTransform", at=@At("HEAD"))
- public void applyTransform(ItemCameraTransforms.TransformType type, CallbackInfo ci) {
- CustomSkulls.mostRecentTransformType = type;
- }
-
+ @Inject(method = "applyTransform", at = @At("HEAD"))
+ public void applyTransform(ItemCameraTransforms.TransformType type, CallbackInfo ci) {
+ CustomSkulls.mostRecentTransformType = type;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemRenderer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemRenderer.java
index ab2dff1d..d691b79f 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemRenderer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemRenderer.java
@@ -1,32 +1,23 @@
package io.github.moulberry.notenoughupdates.mixins;
import io.github.moulberry.notenoughupdates.miscgui.InventoryStorageSelector;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
-import org.spongepowered.asm.lib.Opcodes;
-import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
-import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(ItemRenderer.class)
public abstract class MixinItemRenderer {
-
- @Redirect(method="updateEquippedItem", at=@At(
- value = "INVOKE",
- target = "Lnet/minecraft/entity/player/InventoryPlayer;getCurrentItem()Lnet/minecraft/item/ItemStack;"
- ))
- public ItemStack modifyStackToRender(InventoryPlayer player) {
- if(InventoryStorageSelector.getInstance().isSlotSelected()) {
- return InventoryStorageSelector.getInstance().getHeldItemOverride();
- }
- return player.getCurrentItem();
- }
-
+ @Redirect(method = "updateEquippedItem", at = @At(
+ value = "INVOKE",
+ target = "Lnet/minecraft/entity/player/InventoryPlayer;getCurrentItem()Lnet/minecraft/item/ItemStack;"
+ ))
+ public ItemStack modifyStackToRender(InventoryPlayer player) {
+ if (InventoryStorageSelector.getInstance().isSlotSelected()) {
+ return InventoryStorageSelector.getInstance().getHeldItemOverride();
+ }
+ return player.getCurrentItem();
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemStack.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemStack.java
index 52c96c16..25109704 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemStack.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemStack.java
@@ -4,53 +4,47 @@ import io.github.moulberry.notenoughupdates.miscfeatures.ItemCustomizeManager;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.util.EnumChatFormatting;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
@Mixin({ItemStack.class})
public class MixinItemStack {
-
- @Inject(method="hasEffect", at=@At("HEAD"), cancellable = true)
- public void hasEffect(CallbackInfoReturnable<Boolean> cir) {
- if(Utils.getHasEffectOverride()) {
- cir.setReturnValue(false);
- return;
- }
- }
-
- @Shadow
- private NBTTagCompound stackTagCompound;
-
- @Inject(method="getDisplayName",at=@At("HEAD"), cancellable=true)
- public void getDisplayName(CallbackInfoReturnable<String> returnable) {
- try {
- if(stackTagCompound == null || !stackTagCompound.hasKey("ExtraAttributes", 10)) {
- return;
- }
-
- ItemCustomizeManager.ItemData data = ItemCustomizeManager.getDataForItem((ItemStack)(Object)this);
-
- if(data != null && data.customName != null) {
- String customName = data.customName;
- if(customName != null && !customName.equals("")) {
- customName = Utils.chromaStringByColourCode(customName);
-
- if(data.customNamePrefix != null) {
- customName = data.customNamePrefix + customName;
- }
-
- returnable.setReturnValue(customName);
- }
- }
- } catch(Exception e) { }
- }
-
-
+ @Inject(method = "hasEffect", at = @At("HEAD"), cancellable = true)
+ public void hasEffect(CallbackInfoReturnable<Boolean> cir) {
+ if (Utils.getHasEffectOverride()) {
+ cir.setReturnValue(false);
+ return;
+ }
+ }
+
+ @Shadow
+ private NBTTagCompound stackTagCompound;
+
+ @Inject(method = "getDisplayName", at = @At("HEAD"), cancellable = true)
+ public void getDisplayName(CallbackInfoReturnable<String> returnable) {
+ try {
+ if (stackTagCompound == null || !stackTagCompound.hasKey("ExtraAttributes", 10)) {
+ return;
+ }
+
+ ItemCustomizeManager.ItemData data = ItemCustomizeManager.getDataForItem((ItemStack) (Object) this);
+
+ if (data != null && data.customName != null) {
+ String customName = data.customName;
+ if (customName != null && !customName.equals("")) {
+ customName = Utils.chromaStringByColourCode(customName);
+
+ if (data.customNamePrefix != null) {
+ customName = data.customNamePrefix + customName;
+ }
+
+ returnable.setReturnValue(customName);
+ }
+ }
+ } catch (Exception ignored) {
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLayerArmorBase.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLayerArmorBase.java
index c89ce010..a085c5d1 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLayerArmorBase.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLayerArmorBase.java
@@ -15,53 +15,52 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(LayerArmorBase.class)
public abstract class MixinLayerArmorBase<T extends ModelBase> {
+ private static String customEnchGlint = null;
- private static String customEnchGlint = null;
+ @Redirect(method = "renderLayer",
+ at = @At(
+ value = "INVOKE",
+ target = "Lnet/minecraft/item/ItemStack;hasEffect()Z"
+ )
+ )
+ public boolean renderItem_hasEffect(ItemStack stack) {
+ ItemCustomizeManager.ItemData data = ItemCustomizeManager.getDataForItem(stack);
+ if (data != null) {
+ customEnchGlint = data.customGlintColour;
+ if (data.overrideEnchantGlint) {
+ return data.enchantGlintValue;
+ }
+ } else {
+ customEnchGlint = null;
+ }
- @Redirect(method="renderLayer",
- at=@At(
- value = "INVOKE",
- target = "Lnet/minecraft/item/ItemStack;hasEffect()Z"
- )
- )
- public boolean renderItem_hasEffect(ItemStack stack) {
- ItemCustomizeManager.ItemData data = ItemCustomizeManager.getDataForItem(stack);
- if(data != null) {
- customEnchGlint = data.customGlintColour;
- if(data.overrideEnchantGlint) {
- return data.enchantGlintValue;
- }
- } else {
- customEnchGlint = null;
- }
+ return stack.hasEffect();
+ }
- return stack.hasEffect();
- }
+ @Inject(method = "renderGlint", at = @At("HEAD"), cancellable = true)
+ public void renderGlint(
+ EntityLivingBase entitylivingbaseIn, T modelbaseIn, float p_177183_3_, float p_177183_4_,
+ float partialTicks, float p_177183_6_, float p_177183_7_, float p_177183_8_, float scale, CallbackInfo ci
+ ) {
+ float existed = (float) entitylivingbaseIn.ticksExisted + partialTicks;
+ if (ItemCustomizeManager.render3DGlint(customEnchGlint, existed, () ->
+ modelbaseIn.render(entitylivingbaseIn, p_177183_3_, p_177183_4_, p_177183_6_, p_177183_7_, p_177183_8_, scale))) {
+ ci.cancel();
+ }
+ }
- @Inject(method="renderGlint", at=@At("HEAD"), cancellable = true)
- public void renderGlint(EntityLivingBase entitylivingbaseIn, T modelbaseIn, float p_177183_3_, float p_177183_4_,
- float partialTicks, float p_177183_6_, float p_177183_7_, float p_177183_8_, float scale, CallbackInfo ci) {
- float existed = (float)entitylivingbaseIn.ticksExisted + partialTicks;
- if(ItemCustomizeManager.render3DGlint(customEnchGlint, existed, () -> {
- modelbaseIn.render(entitylivingbaseIn, p_177183_3_, p_177183_4_, p_177183_6_, p_177183_7_, p_177183_8_, scale);
- })) {
- ci.cancel();
- }
- }
-
- @Redirect(method="renderLayer",
- at=@At(
- value = "INVOKE",
- target = "Lnet/minecraft/item/ItemArmor;getColor(Lnet/minecraft/item/ItemStack;)I"
- )
- )
- public int renderItem_getColor(ItemArmor item, ItemStack stack) {
- ItemCustomizeManager.ItemData data = ItemCustomizeManager.getDataForItem(stack);
- if(data != null && data.customLeatherColour != null) {
- return ChromaColour.specialToChromaRGB(data.customLeatherColour);
- }
-
- return item.getColor(stack);
- }
+ @Redirect(method = "renderLayer",
+ at = @At(
+ value = "INVOKE",
+ target = "Lnet/minecraft/item/ItemArmor;getColor(Lnet/minecraft/item/ItemStack;)I"
+ )
+ )
+ public int renderItem_getColor(ItemArmor item, ItemStack stack) {
+ ItemCustomizeManager.ItemData data = ItemCustomizeManager.getDataForItem(stack);
+ if (data != null && data.customLeatherColour != null) {
+ return ChromaColour.specialToChromaRGB(data.customLeatherColour);
+ }
+ return item.getColor(stack);
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLayerCustomHead.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLayerCustomHead.java
index 5a780edf..a2785ec7 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLayerCustomHead.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLayerCustomHead.java
@@ -17,55 +17,60 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(LayerCustomHead.class)
public class MixinLayerCustomHead {
+ private static String customGlintColour = null;
- private static String customGlintColour = null;
+ @Inject(method = "doRenderLayer", at = @At("HEAD"))
+ public void doRenderLayer(
+ EntityLivingBase entitylivingbaseIn, float p_177141_2_, float p_177141_3_, float partialTicks,
+ float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale, CallbackInfo ci
+ ) {
+ ItemStack stack = entitylivingbaseIn.getCurrentArmor(3);
- @Inject(method="doRenderLayer", at=@At("HEAD"))
- public void doRenderLayer(EntityLivingBase entitylivingbaseIn, float p_177141_2_, float p_177141_3_, float partialTicks,
- float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale, CallbackInfo ci) {
- ItemStack stack = entitylivingbaseIn.getCurrentArmor(3);
+ ItemCustomizeManager.ItemData data = ItemCustomizeManager.getDataForItem(stack);
+ if (data != null && data.overrideEnchantGlint && data.enchantGlintValue) {
+ customGlintColour = data.customGlintColour;
+ } else {
+ customGlintColour = null;
+ }
+ }
- ItemCustomizeManager.ItemData data = ItemCustomizeManager.getDataForItem(stack);
- if(data != null && data.overrideEnchantGlint && data.enchantGlintValue) {
- customGlintColour = data.customGlintColour;
- } else {
- customGlintColour = null;
- }
- }
+ @Redirect(method = "doRenderLayer",
+ at = @At(
+ value = "INVOKE",
+ target = "Lnet/minecraft/client/renderer/tileentity/TileEntitySkullRenderer;renderSkull(FFFLnet/minecraft/util/EnumFacing;FILcom/mojang/authlib/GameProfile;I)V"
+ )
+ )
+ public void renderItem_renderSkull(
+ TileEntitySkullRenderer tileEntitySkullRenderer, float p_180543_1_, float p_180543_2_,
+ float p_180543_3_, EnumFacing p_180543_4_, float p_180543_5_, int p_180543_6_,
+ GameProfile p_180543_7_, int p_180543_8_
+ ) {
+ GL11.glPushMatrix();
+ tileEntitySkullRenderer.renderSkull(p_180543_1_, p_180543_2_, p_180543_3_, p_180543_4_, p_180543_5_,
+ p_180543_6_, p_180543_7_, p_180543_8_
+ );
+ GL11.glPopMatrix();
- @Redirect(method="doRenderLayer",
- at=@At(
- value = "INVOKE",
- target = "Lnet/minecraft/client/renderer/tileentity/TileEntitySkullRenderer;renderSkull(FFFLnet/minecraft/util/EnumFacing;FILcom/mojang/authlib/GameProfile;I)V"
- )
- )
- public void renderItem_renderSkull(TileEntitySkullRenderer tileEntitySkullRenderer, float p_180543_1_, float p_180543_2_,
- float p_180543_3_, EnumFacing p_180543_4_, float p_180543_5_, int p_180543_6_,
- GameProfile p_180543_7_, int p_180543_8_) {
- GL11.glPushMatrix();
- tileEntitySkullRenderer.renderSkull(p_180543_1_, p_180543_2_, p_180543_3_, p_180543_4_, p_180543_5_,
- p_180543_6_, p_180543_7_, p_180543_8_);
- GL11.glPopMatrix();
+ if (customGlintColour != null) {
+ ItemCustomizeManager.renderEffectHook(customGlintColour, (color) -> {
+ float red = ((color >> 16) & 0xFF) / 255f;
+ float green = ((color >> 8) & 0xFF) / 255f;
+ float blue = (color & 0xFF) / 255f;
+ float alpha = ((color >> 24) & 0xFF) / 255f;
- if(customGlintColour != null) {
- ItemCustomizeManager.renderEffectHook(customGlintColour, (color) -> {
- float red = ((color >> 16) & 0xFF) / 255f;
- float green = ((color >> 8) & 0xFF) / 255f;
- float blue = (color & 0xFF) / 255f;
- float alpha = ((color >> 24) & 0xFF) / 255f;
+ GlStateManager.color(red, green, blue, alpha);
- GlStateManager.color(red, green, blue, alpha);
-
- GlStateManager.scale(1/8f, 1/8f, 1/8f);
- GlStateManager.matrixMode(GL11.GL_MODELVIEW);
- GL11.glPushMatrix();
- ItemCustomizeManager.disableTextureBinding = true;
- tileEntitySkullRenderer.renderSkull(p_180543_1_, p_180543_2_, p_180543_3_, p_180543_4_, p_180543_5_,
- p_180543_6_, p_180543_7_, p_180543_8_);
- ItemCustomizeManager.disableTextureBinding = false;
- GL11.glPopMatrix();
- });
- }
- }
+ GlStateManager.scale(1 / 8f, 1 / 8f, 1 / 8f);
+ GlStateManager.matrixMode(GL11.GL_MODELVIEW);
+ GL11.glPushMatrix();
+ ItemCustomizeManager.disableTextureBinding = true;
+ tileEntitySkullRenderer.renderSkull(p_180543_1_, p_180543_2_, p_180543_3_, p_180543_4_, p_180543_5_,
+ p_180543_6_, p_180543_7_, p_180543_8_
+ );
+ ItemCustomizeManager.disableTextureBinding = false;
+ GL11.glPopMatrix();
+ });
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLoadingScreenRenderer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLoadingScreenRenderer.java
index 3366f569..dbdad65a 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLoadingScreenRenderer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLoadingScreenRenderer.java
@@ -2,21 +2,17 @@ package io.github.moulberry.notenoughupdates.mixins;
import io.github.moulberry.notenoughupdates.miscfeatures.FancyPortals;
import net.minecraft.client.LoadingScreenRenderer;
-import net.minecraft.client.Minecraft;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
-import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(LoadingScreenRenderer.class)
public class MixinLoadingScreenRenderer {
-
- @Inject(method="setLoadingProgress", at=@At(value = "HEAD"), cancellable = true)
- public void setLoadingProgress(int progress, CallbackInfo ci) {
- if(progress < 0 && !FancyPortals.shouldRenderLoadingScreen()) {
- ci.cancel();
- }
- }
-
+ @Inject(method = "setLoadingProgress", at = @At(value = "HEAD"), cancellable = true)
+ public void setLoadingProgress(int progress, CallbackInfo ci) {
+ if (progress < 0 && !FancyPortals.shouldRenderLoadingScreen()) {
+ ci.cancel();
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinMinecraft.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinMinecraft.java
index e2b4a156..b01e9609 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinMinecraft.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinMinecraft.java
@@ -1,47 +1,40 @@
package io.github.moulberry.notenoughupdates.mixins;
-import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.miscfeatures.SlotLocking;
-
import net.minecraft.client.Minecraft;
-import net.minecraft.client.multiplayer.WorldClient;
-import net.minecraft.client.renderer.EntityRenderer;
import org.spongepowered.asm.lib.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
-import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(Minecraft.class)
public class MixinMinecraft {
+ //Commented as they weren't being loaded before
+ /*@Shadow
+ public WorldClient theWorld;
- //Commented as they were'nt being loaded before
-/* @Shadow public WorldClient theWorld;
-
- @Shadow public EntityRenderer entityRenderer;
+ @Shadow
+ public EntityRenderer entityRenderer;
- @Inject(method="shutdownMinecraftApplet", at=@At("HEAD"))
+ @Inject(method = "shutdownMinecraftApplet", at = @At("HEAD"))
public void shutdownMinecraftApplet(CallbackInfo ci) {
NotEnoughUpdates.INSTANCE.saveConfig();
}
- @Inject(method="loadWorld(Lnet/minecraft/client/multiplayer/WorldClient;Ljava/lang/String;)V", at=@At("HEAD"))
+ @Inject(method = "loadWorld(Lnet/minecraft/client/multiplayer/WorldClient;Ljava/lang/String;)V", at = @At("HEAD"))
public void onLoadWorld(WorldClient worldClientIn, String loadingMessage, CallbackInfo ci) {
- if(worldClientIn != theWorld) {
+ if (worldClientIn != theWorld) {
entityRenderer.getMapItemRenderer().clearLoadedMaps();
}
}
- @Redirect(method="loadWorld(Lnet/minecraft/client/multiplayer/WorldClient;Ljava/lang/String;)V",
- at=@At(value = "INVOKE", target = "Ljava/lang/System;gc()V"))
- public void loadWorld_gc() {
- }*/
-
- @Inject(method = "runTick", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/player/InventoryPlayer;currentItem:I", opcode = Opcodes.PUTFIELD))
- public void currentItemMixin(CallbackInfo ci){
- SlotLocking.getInstance().changedSlot(Minecraft.getMinecraft().thePlayer.inventory.currentItem);
- }
+ @Redirect(method = "loadWorld(Lnet/minecraft/client/multiplayer/WorldClient;Ljava/lang/String;)V",
+ at = @At(value = "INVOKE", target = "Ljava/lang/System;gc()V"))
+ public void loadWorld_gc() {}*/
+ @Inject(method = "runTick", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/player/InventoryPlayer;currentItem:I", opcode = Opcodes.PUTFIELD))
+ public void currentItemMixin(CallbackInfo ci) {
+ SlotLocking.getInstance().changedSlot(Minecraft.getMinecraft().thePlayer.inventory.currentItem);
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinMouseHelper.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinMouseHelper.java
index 3d442d58..4d8df949 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinMouseHelper.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinMouseHelper.java
@@ -10,13 +10,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(MouseHelper.class)
public class MixinMouseHelper {
-
- @Inject(method = { "ungrabMouseCursor" }, at = { @At("HEAD") }, cancellable = true)
- public void ungrabMouseCursor(final CallbackInfo ci) {
- if (System.currentTimeMillis() - NEUEventListener.lastGuiClosed < 150L) {
- ci.cancel();
- Mouse.setGrabbed(false);
- }
- }
-
+ @Inject(method = {"ungrabMouseCursor"}, at = {@At("HEAD")}, cancellable = true)
+ public void ungrabMouseCursor(final CallbackInfo ci) {
+ if (System.currentTimeMillis() - NEUEventListener.lastGuiClosed < 150L) {
+ ci.cancel();
+ Mouse.setGrabbed(false);
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinNetHandlerPlayClient.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinNetHandlerPlayClient.java
index 5711f92b..d47dce2c 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinNetHandlerPlayClient.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinNetHandlerPlayClient.java
@@ -1,9 +1,7 @@
package io.github.moulberry.notenoughupdates.mixins;
import io.github.moulberry.notenoughupdates.miscfeatures.*;
-import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.util.SBInfo;
-import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.client.network.NetHandlerPlayClient;
import net.minecraft.entity.player.EntityPlayer;
@@ -19,82 +17,100 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(NetHandlerPlayClient.class)
public class MixinNetHandlerPlayClient {
- private static final String TARGET = "Lnet/minecraft/entity/player/EntityPlayer;" +
- "setPositionAndRotation(DDDFF)V";
- @Redirect(method="handlePlayerPosLook", at=@At(value="INVOKE", target=TARGET))
- public void handlePlayerPosLook_setPositionAndRotation(EntityPlayer player, double x, double y, double z, float yaw, float pitch) {
- if(CustomItemEffects.INSTANCE.aoteTeleportationCurr != null) {
- CustomItemEffects.INSTANCE.aoteTeleportationMillis += Math.max(0, Math.min(300, CustomItemEffects.INSTANCE.tpTime));
- }
- player.setPositionAndRotation(x, y, z, yaw, pitch);
- }
+ private static final String TARGET = "Lnet/minecraft/entity/player/EntityPlayer;" +
+ "setPositionAndRotation(DDDFF)V";
- @Redirect(method="handleParticles", at=@At(
- value = "INVOKE",
- target = "Lnet/minecraft/client/multiplayer/WorldClient;spawnParticle(Lnet/minecraft/util/EnumParticleTypes;ZDDDDDD[I)V"
- ))
- public void handleParticles(WorldClient world, EnumParticleTypes particleTypes, boolean isLongDistance,
- double xCoord, double yCoord, double zCoord,
- double xOffset, double yOffset, double zOffset, int[] params) {
- boolean override = FishingHelper.getInstance().onSpawnParticle(particleTypes, xCoord, yCoord, zCoord, xOffset, yOffset, zOffset);
- if(!override) {
- world.spawnParticle(particleTypes, isLongDistance, xCoord, yCoord, zCoord, xOffset, yOffset, zOffset, params);
- }
- }
+ @Redirect(method = "handlePlayerPosLook", at = @At(value = "INVOKE", target = TARGET))
+ public void handlePlayerPosLook_setPositionAndRotation(
+ EntityPlayer player,
+ double x,
+ double y,
+ double z,
+ float yaw,
+ float pitch
+ ) {
+ if (CustomItemEffects.INSTANCE.aoteTeleportationCurr != null) {
+ CustomItemEffects.INSTANCE.aoteTeleportationMillis += Math.max(
+ 0,
+ Math.min(300, CustomItemEffects.INSTANCE.tpTime)
+ );
+ }
+ player.setPositionAndRotation(x, y, z, yaw, pitch);
+ }
- @Inject(method="handleSpawnMob", at=@At("RETURN"))
- public void handleSpawnMob(S0FPacketSpawnMob packetIn, CallbackInfo ci) {
- //CollectionLogManager.getInstance().onEntityMetadataUpdated(packetIn.getEntityID());
- }
+ @Redirect(method = "handleParticles", at = @At(
+ value = "INVOKE",
+ target = "Lnet/minecraft/client/multiplayer/WorldClient;spawnParticle(Lnet/minecraft/util/EnumParticleTypes;ZDDDDDD[I)V"
+ ))
+ public void handleParticles(
+ WorldClient world, EnumParticleTypes particleTypes, boolean isLongDistance,
+ double xCoord, double yCoord, double zCoord,
+ double xOffset, double yOffset, double zOffset, int[] params
+ ) {
+ boolean override = FishingHelper.getInstance().onSpawnParticle(
+ particleTypes,
+ xCoord,
+ yCoord,
+ zCoord,
+ xOffset,
+ yOffset,
+ zOffset
+ );
+ if (!override) {
+ world.spawnParticle(particleTypes, isLongDistance, xCoord, yCoord, zCoord, xOffset, yOffset, zOffset, params);
+ }
+ }
- @Inject(method="handleSetSlot", at=@At("RETURN"))
- public void handleSetSlot(S2FPacketSetSlot packetIn, CallbackInfo ci) {
- EnchantingSolvers.processInventoryContents(false);
- StorageManager.getInstance().setSlotPacket(packetIn);
- }
+ @Inject(method = "handleSpawnMob", at = @At("RETURN"))
+ public void handleSpawnMob(S0FPacketSpawnMob packetIn, CallbackInfo ci) {
+ //CollectionLogManager.getInstance().onEntityMetadataUpdated(packetIn.getEntityID());
+ }
- @Inject(method="handleOpenWindow", at=@At("RETURN"))
- public void handleOpenWindow(S2DPacketOpenWindow packetIn, CallbackInfo ci) {
- StorageManager.getInstance().openWindowPacket(packetIn);
- }
+ @Inject(method = "handleSetSlot", at = @At("RETURN"))
+ public void handleSetSlot(S2FPacketSetSlot packetIn, CallbackInfo ci) {
+ EnchantingSolvers.processInventoryContents(false);
+ StorageManager.getInstance().setSlotPacket(packetIn);
+ }
- @Inject(method="handleCloseWindow", at=@At("RETURN"))
- public void handleCloseWindow(S2EPacketCloseWindow packetIn, CallbackInfo ci) {
- StorageManager.getInstance().closeWindowPacket(packetIn);
- }
+ @Inject(method = "handleOpenWindow", at = @At("RETURN"))
+ public void handleOpenWindow(S2DPacketOpenWindow packetIn, CallbackInfo ci) {
+ StorageManager.getInstance().openWindowPacket(packetIn);
+ }
- @Inject(method="handleWindowItems", at=@At("RETURN"))
- public void handleOpenWindow(S30PacketWindowItems packetIn, CallbackInfo ci) {
- StorageManager.getInstance().setItemsPacket(packetIn);
- }
+ @Inject(method = "handleCloseWindow", at = @At("RETURN"))
+ public void handleCloseWindow(S2EPacketCloseWindow packetIn, CallbackInfo ci) {
+ StorageManager.getInstance().closeWindowPacket(packetIn);
+ }
- @Inject(method="handleRespawn", at=@At(
- value = "INVOKE",
- target = "Lnet/minecraft/network/PacketThreadUtil;checkThreadAndEnqueue(Lnet/minecraft/network/Packet;Lnet/minecraft/network/INetHandler;Lnet/minecraft/util/IThreadListener;)V",
- shift = At.Shift.AFTER))
- public void handleOpenWindow(S07PacketRespawn packetIn, CallbackInfo ci) {
- FancyPortals.onRespawnPacket(packetIn);
- }
+ @Inject(method = "handleWindowItems", at = @At("RETURN"))
+ public void handleOpenWindow(S30PacketWindowItems packetIn, CallbackInfo ci) {
+ StorageManager.getInstance().setItemsPacket(packetIn);
+ }
- @Inject(method="handleBlockChange", at=@At("HEAD"))
- public void handleBlockChange(S23PacketBlockChange packetIn, CallbackInfo ci) {
- MiningStuff.processBlockChangePacket(packetIn);
- ItemCooldowns.processBlockChangePacket(packetIn);
- }
-
- @Inject(method="addToSendQueue", at=@At("HEAD"))
- public void addToSendQueue(Packet packet, CallbackInfo ci) {
- if(packet instanceof C0EPacketClickWindow) {
- StorageManager.getInstance().clientSendWindowClick((C0EPacketClickWindow)packet);
- }
- }
-
- @Inject(method="handlePlayerListHeaderFooter", at=@At("HEAD"))
- public void handlePlayerListHeaderFooter(S47PacketPlayerListHeaderFooter packetIn, CallbackInfo ci) {
- SBInfo.getInstance().header = packetIn.getHeader().getFormattedText().length() == 0 ? null : packetIn.getHeader();
- SBInfo.getInstance().footer = packetIn.getFooter().getFormattedText().length() == 0 ? null : packetIn.getFooter();
- }
+ @Inject(method = "handleRespawn", at = @At(
+ value = "INVOKE",
+ target = "Lnet/minecraft/network/PacketThreadUtil;checkThreadAndEnqueue(Lnet/minecraft/network/Packet;Lnet/minecraft/network/INetHandler;Lnet/minecraft/util/IThreadListener;)V",
+ shift = At.Shift.AFTER))
+ public void handleOpenWindow(S07PacketRespawn packetIn, CallbackInfo ci) {
+ FancyPortals.onRespawnPacket(packetIn);
+ }
+ @Inject(method = "handleBlockChange", at = @At("HEAD"))
+ public void handleBlockChange(S23PacketBlockChange packetIn, CallbackInfo ci) {
+ MiningStuff.processBlockChangePacket(packetIn);
+ ItemCooldowns.processBlockChangePacket(packetIn);
+ }
+ @Inject(method = "addToSendQueue", at = @At("HEAD"))
+ public void addToSendQueue(Packet packet, CallbackInfo ci) {
+ if (packet instanceof C0EPacketClickWindow) {
+ StorageManager.getInstance().clientSendWindowClick((C0EPacketClickWindow) packet);
+ }
+ }
+ @Inject(method = "handlePlayerListHeaderFooter", at = @At("HEAD"))
+ public void handlePlayerListHeaderFooter(S47PacketPlayerListHeaderFooter packetIn, CallbackInfo ci) {
+ SBInfo.getInstance().header = packetIn.getHeader().getFormattedText().length() == 0 ? null : packetIn.getHeader();
+ SBInfo.getInstance().footer = packetIn.getFooter().getFormattedText().length() == 0 ? null : packetIn.getFooter();
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinPlayerControllerMP.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinPlayerControllerMP.java
index 308dc779..b4481a73 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinPlayerControllerMP.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinPlayerControllerMP.java
@@ -1,29 +1,45 @@
package io.github.moulberry.notenoughupdates.mixins;
-import io.github.moulberry.notenoughupdates.miscfeatures.DwarvenMinesTextures;
-import io.github.moulberry.notenoughupdates.miscfeatures.FairySouls;
+import io.github.moulberry.notenoughupdates.events.OnBlockBreakSoundEffect;
import io.github.moulberry.notenoughupdates.miscfeatures.ItemCooldowns;
-import io.github.moulberry.notenoughupdates.miscfeatures.MiningStuff;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.audio.ISound;
+import net.minecraft.client.audio.SoundHandler;
import net.minecraft.client.multiplayer.PlayerControllerMP;
-import net.minecraft.network.play.client.C07PacketPlayerDigging;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(PlayerControllerMP.class)
public class MixinPlayerControllerMP {
-
- @Inject(method="clickBlock", at=@At("HEAD"), cancellable = true)
- public void clickBlock(BlockPos loc, EnumFacing face, CallbackInfoReturnable<Boolean> cir) {
- ItemCooldowns.blockClicked(loc);
+ @Inject(method = "clickBlock", at = @At("HEAD"), cancellable = true)
+ public void clickBlock(BlockPos loc, EnumFacing face, CallbackInfoReturnable<Boolean> cir) {
+ ItemCooldowns.blockClicked(loc);
/*if(MiningStuff.blockClicked(loc)) {
cir.setReturnValue(false);
((PlayerControllerMP)(Object)this).resetBlockRemoving();
}*/
- }
+ }
+
+ @Redirect(method = "onPlayerDamageBlock", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/audio/SoundHandler;playSound(Lnet/minecraft/client/audio/ISound;)V"))
+ public void onPlayerDamageBlock(
+ SoundHandler instance,
+ ISound p_playSound_1_,
+ BlockPos p_onPlayerDamageBlock_1_,
+ EnumFacing p_onPlayerDamageBlock_2_
+ ) {
+ OnBlockBreakSoundEffect onBlockBreakSoundEffect = new OnBlockBreakSoundEffect(
+ p_playSound_1_,
+ p_onPlayerDamageBlock_1_,
+ Minecraft.getMinecraft().theWorld.getBlockState(p_onPlayerDamageBlock_1_)
+ );
+ if (!onBlockBreakSoundEffect.post()) {
+ instance.playSound(onBlockBreakSoundEffect.getSound());
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRender.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRender.java
index e65b8155..14aad887 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRender.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRender.java
@@ -1,7 +1,7 @@
package io.github.moulberry.notenoughupdates.mixins;
-import io.github.moulberry.notenoughupdates.dungeons.DungeonBlocks;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.dungeons.DungeonBlocks;
import io.github.moulberry.notenoughupdates.util.SpecialColour;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.entity.Entity;
@@ -15,17 +15,17 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(Render.class)
public class MixinRender {
-
- @Inject(method="bindEntityTexture", at=@At("HEAD"), cancellable = true)
- public void bindEntityTexture(Entity entity, CallbackInfoReturnable<Boolean> cir) {
- if(entity instanceof EntityBat && DungeonBlocks.isOverriding()) {
- if(DungeonBlocks.bindModifiedTexture(new ResourceLocation("textures/entity/bat.png"),
- SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.dungeons.dungBatColour))) {
- cir.setReturnValue(true);
- GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR);
- GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
- }
- }
- }
-
+ @Inject(method = "bindEntityTexture", at = @At("HEAD"), cancellable = true)
+ public void bindEntityTexture(Entity entity, CallbackInfoReturnable<Boolean> cir) {
+ if (entity instanceof EntityBat && DungeonBlocks.isOverriding()) {
+ if (DungeonBlocks.bindModifiedTexture(
+ new ResourceLocation("textures/entity/bat.png"),
+ SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.dungeons.dungBatColour)
+ )) {
+ cir.setReturnValue(true);
+ GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR);
+ GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
+ }
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderFish.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderFish.java
index a5e34cd6..9e989311 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderFish.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderFish.java
@@ -18,134 +18,164 @@ import net.minecraft.util.Vec3;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL14;
import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
-import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.awt.*;
@Mixin(RenderFish.class)
public abstract class MixinRenderFish extends Render<EntityFishHook> {
-
- protected MixinRenderFish(RenderManager renderManager) {
- super(renderManager);
- }
-
- @Inject(method = "doRender(Lnet/minecraft/entity/projectile/EntityFishHook;DDDFF)V", at=@At(value = "HEAD"), cancellable = true)
- public void render(EntityFishHook entity, double x, double y, double z, float entityYaw, float partialTicks, CallbackInfo ci) {
- if(NotEnoughUpdates.INSTANCE.config.fishing.hideOtherPlayerAll &&
- entity != null && entity.angler != Minecraft.getMinecraft().thePlayer) {
- ci.cancel();
- return;
- }
-
- if((!NotEnoughUpdates.INSTANCE.config.fishing.enableRodColours &&
- FishingHelper.getInstance().warningState == FishingHelper.PlayerWarningState.NOTHING) || entity == null) return;
-
- String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(entity.angler.getHeldItem());
- if (NotEnoughUpdates.INSTANCE.isOnSkyblock() && internalname != null && entity.angler != null &&
- entity.angler.getHeldItem().getItem().equals(Items.fishing_rod)) {
- if (!internalname.equals("GRAPPLING_HOOK") && !internalname.endsWith("_WHIP")) {
- ci.cancel();
-
- GlStateManager.pushMatrix();
- GlStateManager.translate((float)x, (float)y, (float)z);
- GlStateManager.enableRescaleNormal();
- GlStateManager.scale(0.5F, 0.5F, 0.5F);
- GlStateManager.rotate(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
- GlStateManager.rotate(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
- this.bindEntityTexture(entity);
-
- Tessellator tessellator = Tessellator.getInstance();
- WorldRenderer worldrenderer = tessellator.getWorldRenderer();
- worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_NORMAL);
- worldrenderer.pos(-0.5D, -0.5D, 0.0D).tex(0.0625D, 0.1875D).normal(0.0F, 1.0F, 0.0F).endVertex();
- worldrenderer.pos(0.5D, -0.5D, 0.0D).tex(0.125D, 0.1875D).normal(0.0F, 1.0F, 0.0F).endVertex();
- worldrenderer.pos(0.5D, 0.5D, 0.0D).tex(0.125D, 0.125D).normal(0.0F, 1.0F, 0.0F).endVertex();
- worldrenderer.pos(-0.5D, 0.5D, 0.0D).tex(0.0625D, 0.125D).normal(0.0F, 1.0F, 0.0F).endVertex();
- tessellator.draw();
-
- FishingHelper.getInstance().onRenderBobber(entity);
-
- GlStateManager.disableRescaleNormal();
- GlStateManager.popMatrix();
-
- double playerVecX;
- double playerVecY;
- double playerVecZ;
- double startY;
- if(this.renderManager.options.thirdPersonView == 0 && entity.angler == Minecraft.getMinecraft().thePlayer) {
- float f7 = entity.angler.getSwingProgress(partialTicks);
- float sqrtSinSwing = MathHelper.sin(MathHelper.sqrt_float(f7) * (float)Math.PI);
-
- double decimalFov = (this.renderManager.options.fovSetting / 110.0D);
- Vec3 fppOffset = new Vec3((-decimalFov + (decimalFov / 2.5) - (decimalFov / 8)) + 0.025, -0.045D * (this.renderManager.options.fovSetting / 100.0D), 0.4D);
- fppOffset = fppOffset.rotatePitch(-mathLerp(partialTicks, entity.angler.prevRotationPitch, entity.angler.rotationPitch) * ((float)Math.PI / 180.0F));
- fppOffset = fppOffset.rotateYaw(-mathLerp(partialTicks, entity.angler.prevRotationYaw, entity.angler.rotationYaw) * ((float)Math.PI / 180.0F));
- fppOffset = fppOffset.rotateYaw(sqrtSinSwing * 0.5F);
- fppOffset = fppOffset.rotatePitch(-sqrtSinSwing * 0.7F);
-
- playerVecX = entity.angler.prevPosX + (entity.angler.posX - entity.angler.prevPosX) * (double)partialTicks + fppOffset.xCoord;
- playerVecY = entity.angler.prevPosY + (entity.angler.posY - entity.angler.prevPosY) * (double)partialTicks + fppOffset.yCoord;
- playerVecZ = entity.angler.prevPosZ + (entity.angler.posZ - entity.angler.prevPosZ) * (double)partialTicks + fppOffset.zCoord;
- startY = entity.angler.getEyeHeight();
- } else {
- float angle = (entity.angler.prevRenderYawOffset + (entity.angler.renderYawOffset - entity.angler.prevRenderYawOffset) * partialTicks) * (float)Math.PI / 180.0F;
- double d4 = MathHelper.sin(angle);
- double d6 = MathHelper.cos(angle);
- playerVecX = entity.angler.prevPosX + (entity.angler.posX - entity.angler.prevPosX) * (double)partialTicks - d6 * 0.35D - d4 * 0.8D;
- playerVecY = entity.angler.prevPosY + entity.angler.getEyeHeight() + (entity.angler.posY - entity.angler.prevPosY) * (double)partialTicks - 0.45D;
- playerVecZ = entity.angler.prevPosZ + (entity.angler.posZ - entity.angler.prevPosZ) * (double)partialTicks - d4 * 0.35D + d6 * 0.8D;
- startY = entity.angler.isSneaking() ? -0.1875D : 0.0D;
- }
-
- double d13 = entity.prevPosX + (entity.posX - entity.prevPosX) * (double)partialTicks;
- double d5 = entity.prevPosY + (entity.posY - entity.prevPosY) * (double)partialTicks + 0.25D;
- double d7 = entity.prevPosZ + (entity.posZ - entity.prevPosZ) * (double)partialTicks;
- double d9 = (double)((float)(playerVecX - d13));
- double d11 = (double)((float)(playerVecY - d5)) + startY;
- double d12 = (double)((float)(playerVecZ - d7));
- GlStateManager.disableTexture2D();
- GlStateManager.disableLighting();
- GlStateManager.enableBlend();
- GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
- worldrenderer.begin(3, DefaultVertexFormats.POSITION_COLOR);
-
- String specialColour;
- if (entity.angler.getUniqueID().equals(Minecraft.getMinecraft().thePlayer.getUniqueID())) {
- specialColour = NotEnoughUpdates.INSTANCE.config.fishing.ownRodColour;
- } else {
- specialColour = NotEnoughUpdates.INSTANCE.config.fishing.otherRodColour;
- }
- int colourI = SpecialColour.specialToChromaRGB(specialColour);
-
- for (int l = 0; l <= 16; ++l) {
- if(SpecialColour.getSpeed(specialColour) > 0) { //has chroma
- colourI = SpecialColour.rotateHue(colourI, 10);
- }
- Color colour = new Color(colourI, true);
-
- float f10 = (float)l / 16.0F;
- worldrenderer.pos(x + d9 * (double)f10, y + d11 * (double)(f10 * f10 + f10) * 0.5D + 0.25D, z + d12 * (double)f10)
- .color(colour.getRed(), colour.getGreen(), colour.getBlue(), colour.getAlpha()).endVertex();
- }
-
- tessellator.draw();
- GlStateManager.disableBlend();
- GlStateManager.enableLighting();
- GlStateManager.enableTexture2D();
- }
- }
- }
-
- private static float mathLerp(float var1, float var2, float var3) {
- return var2 + var1 * (var3 - var2);
- }
-
- private static double mathLerp(double var1, double var2, double var3) {
- return var2 + var1 * (var3 - var2);
- }
-
+ protected MixinRenderFish(RenderManager renderManager) {
+ super(renderManager);
+ }
+
+ @Inject(method = "doRender(Lnet/minecraft/entity/projectile/EntityFishHook;DDDFF)V", at = @At(value = "HEAD"), cancellable = true)
+ public void render(
+ EntityFishHook entity,
+ double x,
+ double y,
+ double z,
+ float entityYaw,
+ float partialTicks,
+ CallbackInfo ci
+ ) {
+ if (NotEnoughUpdates.INSTANCE.config.fishing.hideOtherPlayerAll &&
+ entity != null && entity.angler != Minecraft.getMinecraft().thePlayer) {
+ ci.cancel();
+ return;
+ }
+
+ if ((!NotEnoughUpdates.INSTANCE.config.fishing.enableRodColours &&
+ FishingHelper.getInstance().warningState == FishingHelper.PlayerWarningState.NOTHING) || entity == null)
+ return;
+
+ String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(entity.angler.getHeldItem());
+ if (NotEnoughUpdates.INSTANCE.isOnSkyblock() && internalname != null && entity.angler != null &&
+ entity.angler.getHeldItem().getItem().equals(Items.fishing_rod)) {
+ if (!internalname.equals("GRAPPLING_HOOK") && !internalname.endsWith("_WHIP")) {
+ ci.cancel();
+
+ GlStateManager.pushMatrix();
+ GlStateManager.translate((float) x, (float) y, (float) z);
+ GlStateManager.enableRescaleNormal();
+ GlStateManager.scale(0.5F, 0.5F, 0.5F);
+ GlStateManager.rotate(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
+ GlStateManager.rotate(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
+ this.bindEntityTexture(entity);
+
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+ worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_NORMAL);
+ worldrenderer.pos(-0.5D, -0.5D, 0.0D).tex(0.0625D, 0.1875D).normal(0.0F, 1.0F, 0.0F).endVertex();
+ worldrenderer.pos(0.5D, -0.5D, 0.0D).tex(0.125D, 0.1875D).normal(0.0F, 1.0F, 0.0F).endVertex();
+ worldrenderer.pos(0.5D, 0.5D, 0.0D).tex(0.125D, 0.125D).normal(0.0F, 1.0F, 0.0F).endVertex();
+ worldrenderer.pos(-0.5D, 0.5D, 0.0D).tex(0.0625D, 0.125D).normal(0.0F, 1.0F, 0.0F).endVertex();
+ tessellator.draw();
+
+ FishingHelper.getInstance().onRenderBobber(entity);
+
+ GlStateManager.disableRescaleNormal();
+ GlStateManager.popMatrix();
+
+ double playerVecX;
+ double playerVecY;
+ double playerVecZ;
+ double startY;
+ if (this.renderManager.options.thirdPersonView == 0 && entity.angler == Minecraft.getMinecraft().thePlayer) {
+ float f7 = entity.angler.getSwingProgress(partialTicks);
+ float sqrtSinSwing = MathHelper.sin(MathHelper.sqrt_float(f7) * (float) Math.PI);
+
+ double decimalFov = (this.renderManager.options.fovSetting / 110.0D);
+ Vec3 fppOffset = new Vec3(
+ (-decimalFov + (decimalFov / 2.5) - (decimalFov / 8)) + 0.025,
+ -0.045D * (this.renderManager.options.fovSetting / 100.0D),
+ 0.4D
+ );
+ fppOffset = fppOffset.rotatePitch(
+ -mathLerp(partialTicks, entity.angler.prevRotationPitch, entity.angler.rotationPitch) *
+ ((float) Math.PI / 180.0F));
+ fppOffset = fppOffset.rotateYaw(
+ -mathLerp(partialTicks, entity.angler.prevRotationYaw, entity.angler.rotationYaw) *
+ ((float) Math.PI / 180.0F));
+ fppOffset = fppOffset.rotateYaw(sqrtSinSwing * 0.5F);
+ fppOffset = fppOffset.rotatePitch(-sqrtSinSwing * 0.7F);
+
+ playerVecX = entity.angler.prevPosX + (entity.angler.posX - entity.angler.prevPosX) * (double) partialTicks +
+ fppOffset.xCoord;
+ playerVecY = entity.angler.prevPosY + (entity.angler.posY - entity.angler.prevPosY) * (double) partialTicks +
+ fppOffset.yCoord;
+ playerVecZ = entity.angler.prevPosZ + (entity.angler.posZ - entity.angler.prevPosZ) * (double) partialTicks +
+ fppOffset.zCoord;
+ startY = entity.angler.getEyeHeight();
+ } else {
+ float angle = (entity.angler.prevRenderYawOffset +
+ (entity.angler.renderYawOffset - entity.angler.prevRenderYawOffset) * partialTicks) * (float) Math.PI /
+ 180.0F;
+ double d4 = MathHelper.sin(angle);
+ double d6 = MathHelper.cos(angle);
+ playerVecX = entity.angler.prevPosX + (entity.angler.posX - entity.angler.prevPosX) * (double) partialTicks -
+ d6 * 0.35D - d4 * 0.8D;
+ playerVecY = entity.angler.prevPosY + entity.angler.getEyeHeight() +
+ (entity.angler.posY - entity.angler.prevPosY) * (double) partialTicks - 0.45D;
+ playerVecZ = entity.angler.prevPosZ + (entity.angler.posZ - entity.angler.prevPosZ) * (double) partialTicks -
+ d4 * 0.35D + d6 * 0.8D;
+ startY = entity.angler.isSneaking() ? -0.1875D : 0.0D;
+ }
+
+ double d13 = entity.prevPosX + (entity.posX - entity.prevPosX) * (double) partialTicks;
+ double d5 = entity.prevPosY + (entity.posY - entity.prevPosY) * (double) partialTicks + 0.25D;
+ double d7 = entity.prevPosZ + (entity.posZ - entity.prevPosZ) * (double) partialTicks;
+ double d9 = (float) (playerVecX - d13);
+ double d11 = (double) ((float) (playerVecY - d5)) + startY;
+ double d12 = (float) (playerVecZ - d7);
+ GlStateManager.disableTexture2D();
+ GlStateManager.disableLighting();
+ GlStateManager.enableBlend();
+ GL14.glBlendFuncSeparate(
+ GL11.GL_SRC_ALPHA,
+ GL11.GL_ONE_MINUS_SRC_ALPHA,
+ GL11.GL_ONE,
+ GL11.GL_ONE_MINUS_SRC_ALPHA
+ );
+ worldrenderer.begin(3, DefaultVertexFormats.POSITION_COLOR);
+
+ String specialColour;
+ if (entity.angler.getUniqueID().equals(Minecraft.getMinecraft().thePlayer.getUniqueID())) {
+ specialColour = NotEnoughUpdates.INSTANCE.config.fishing.ownRodColour;
+ } else {
+ specialColour = NotEnoughUpdates.INSTANCE.config.fishing.otherRodColour;
+ }
+ int colourI = SpecialColour.specialToChromaRGB(specialColour);
+
+ for (int l = 0; l <= 16; ++l) {
+ if (SpecialColour.getSpeed(specialColour) > 0) { //has chroma
+ colourI = SpecialColour.rotateHue(colourI, 10);
+ }
+ Color colour = new Color(colourI, true);
+
+ float f10 = (float) l / 16.0F;
+ worldrenderer.pos(
+ x + d9 * (double) f10,
+ y + d11 * (double) (f10 * f10 + f10) * 0.5D + 0.25D,
+ z + d12 * (double) f10
+ )
+ .color(colour.getRed(), colour.getGreen(), colour.getBlue(), colour.getAlpha()).endVertex();
+ }
+
+ tessellator.draw();
+ GlStateManager.disableBlend();
+ GlStateManager.enableLighting();
+ GlStateManager.enableTexture2D();
+ }
+ }
+ }
+
+ private static float mathLerp(float var1, float var2, float var3) {
+ return var2 + var1 * (var3 - var2);
+ }
+
+ private static double mathLerp(double var1, double var2, double var3) {
+ return var2 + var1 * (var3 - var2);
+ }
} \ No newline at end of file
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderGlobal.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderGlobal.java
index d992d518..fc3347bf 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderGlobal.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderGlobal.java
@@ -1,7 +1,7 @@
package io.github.moulberry.notenoughupdates.mixins;
-import io.github.moulberry.notenoughupdates.miscfeatures.CustomItemEffects;
import io.github.moulberry.notenoughupdates.cosmetics.CapeManager;
+import io.github.moulberry.notenoughupdates.miscfeatures.CustomItemEffects;
import net.minecraft.client.renderer.RenderGlobal;
import net.minecraft.entity.Entity;
import net.minecraft.util.EnumWorldBlockLayer;
@@ -14,96 +14,96 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(RenderGlobal.class)
public class MixinRenderGlobal {
+ @ModifyVariable(method = "setupTerrain", at = @At(value = "STORE"), ordinal = 4)
+ public double setupTerrain_d0(double d3) {
+ Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
+ if (currentPosition != null) {
+ return currentPosition.x;
+ }
+ return d3;
+ }
- @ModifyVariable(method="setupTerrain", at=@At(value="STORE"), ordinal = 4)
- public double setupTerrain_d0(double d3) {
- Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
- if(currentPosition != null) {
- return currentPosition.x;
- }
- return d3;
- }
-
- @ModifyVariable(method="setupTerrain", at=@At(value="STORE"), ordinal = 5)
- public double setupTerrain_d1(double d4) {
- Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
- if(currentPosition != null) {
- return currentPosition.y;
- }
- return d4;
- }
-
- @ModifyVariable(method="setupTerrain", at=@At(value="STORE"), ordinal = 6)
- public double setupTerrain_d2(double d5) {
- Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
- if(currentPosition != null) {
- return currentPosition.z;
- }
- return d5;
- }
+ @ModifyVariable(method = "setupTerrain", at = @At(value = "STORE"), ordinal = 5)
+ public double setupTerrain_d1(double d4) {
+ Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
+ if (currentPosition != null) {
+ return currentPosition.y;
+ }
+ return d4;
+ }
- //renderEntities
- @ModifyVariable(method="renderEntities", at=@At(value="STORE"), ordinal = 3)
- public double renderEntities_d0(double d3) {
- Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
- if(currentPosition != null) {
- return currentPosition.x;
- }
- return d3;
- }
+ @ModifyVariable(method = "setupTerrain", at = @At(value = "STORE"), ordinal = 6)
+ public double setupTerrain_d2(double d5) {
+ Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
+ if (currentPosition != null) {
+ return currentPosition.z;
+ }
+ return d5;
+ }
- @ModifyVariable(method="renderEntities", at=@At(value="STORE"), ordinal = 4)
- public double renderEntities_d1(double d4) {
- Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
- if(currentPosition != null) {
- return currentPosition.y;
- }
- return d4;
- }
+ //renderEntities
+ @ModifyVariable(method = "renderEntities", at = @At(value = "STORE"), ordinal = 3)
+ public double renderEntities_d0(double d3) {
+ Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
+ if (currentPosition != null) {
+ return currentPosition.x;
+ }
+ return d3;
+ }
- @ModifyVariable(method="renderEntities", at=@At(value="STORE"), ordinal = 5)
- public double renderEntities_d2(double d5) {
- Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
- if(currentPosition != null) {
- return currentPosition.z;
- }
- return d5;
- }
+ @ModifyVariable(method = "renderEntities", at = @At(value = "STORE"), ordinal = 4)
+ public double renderEntities_d1(double d4) {
+ Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
+ if (currentPosition != null) {
+ return currentPosition.y;
+ }
+ return d4;
+ }
- @Inject(method="renderBlockLayer", at=@At("RETURN"))
- public void renderBlockLayer(EnumWorldBlockLayer blockLayerIn, double partialTicks, int pass,
- Entity entityIn, CallbackInfoReturnable<Integer> cir) {
- if(blockLayerIn == EnumWorldBlockLayer.CUTOUT) {
- CapeManager.getInstance().postRenderBlocks();
- }
- }
+ @ModifyVariable(method = "renderEntities", at = @At(value = "STORE"), ordinal = 5)
+ public double renderEntities_d2(double d5) {
+ Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
+ if (currentPosition != null) {
+ return currentPosition.z;
+ }
+ return d5;
+ }
- //drawBlockDamageTexture
- @ModifyVariable(method="drawBlockDamageTexture", at=@At(value="STORE"), ordinal = 0)
- public double drawBlockDamageTexture_d0(double d0) {
- Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
- if(currentPosition != null) {
- return currentPosition.x;
- }
- return d0;
- }
+ @Inject(method = "renderBlockLayer", at = @At("RETURN"))
+ public void renderBlockLayer(
+ EnumWorldBlockLayer blockLayerIn, double partialTicks, int pass,
+ Entity entityIn, CallbackInfoReturnable<Integer> cir
+ ) {
+ if (blockLayerIn == EnumWorldBlockLayer.CUTOUT) {
+ CapeManager.getInstance().postRenderBlocks();
+ }
+ }
- @ModifyVariable(method="drawBlockDamageTexture", at=@At(value="STORE"), ordinal = 1)
- public double drawBlockDamageTexture_d1(double d1) {
- Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
- if(currentPosition != null) {
- return currentPosition.y;
- }
- return d1;
- }
+ //drawBlockDamageTexture
+ @ModifyVariable(method = "drawBlockDamageTexture", at = @At(value = "STORE"), ordinal = 0)
+ public double drawBlockDamageTexture_d0(double d0) {
+ Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
+ if (currentPosition != null) {
+ return currentPosition.x;
+ }
+ return d0;
+ }
- @ModifyVariable(method="drawBlockDamageTexture", at=@At(value="STORE"), ordinal = 2)
- public double drawBlockDamageTexture_d2(double d2) {
- Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
- if(currentPosition != null) {
- return currentPosition.z;
- }
- return d2;
- }
+ @ModifyVariable(method = "drawBlockDamageTexture", at = @At(value = "STORE"), ordinal = 1)
+ public double drawBlockDamageTexture_d1(double d1) {
+ Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
+ if (currentPosition != null) {
+ return currentPosition.y;
+ }
+ return d1;
+ }
+ @ModifyVariable(method = "drawBlockDamageTexture", at = @At(value = "STORE"), ordinal = 2)
+ public double drawBlockDamageTexture_d2(double d2) {
+ Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
+ if (currentPosition != null) {
+ return currentPosition.z;
+ }
+ return d2;
+ }
}
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 db3f9be3..630874ab 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderItem.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderItem.java
@@ -4,8 +4,8 @@ import io.github.moulberry.notenoughupdates.NEUEventListener;
import io.github.moulberry.notenoughupdates.NEUOverlay;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.core.ChromaColour;
-import io.github.moulberry.notenoughupdates.miscfeatures.ItemCustomizeManager;
import io.github.moulberry.notenoughupdates.miscfeatures.ItemCooldowns;
+import io.github.moulberry.notenoughupdates.miscfeatures.ItemCustomizeManager;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
@@ -29,106 +29,105 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin({RenderItem.class})
public abstract class MixinRenderItem {
-
- private static void func_181565_a(WorldRenderer w, int x, int y, float width, int height,
- int r, int g, int b, int a) {
- w.begin(7, DefaultVertexFormats.POSITION_COLOR);
- w.pos((x + 0), (y + 0), 0.0D)
- .color(r, g, b, a).endVertex();
- w.pos((x + 0), (y + height), 0.0D)
- .color(r, g, b, a).endVertex();
- w.pos((x + width), (y + height), 0.0D)
- .color(r, g, b, a).endVertex();
- w.pos((x + width), (y + 0), 0.0D)
- .color(r, g, b, a).endVertex();
- Tessellator.getInstance().draw();
- }
-
- private static String customEnchGlint = null;
-
- @Redirect(method="renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/resources/model/IBakedModel;)V",
- at=@At(
- value = "INVOKE",
- target = "Lnet/minecraft/item/ItemStack;hasEffect()Z"
- )
- )
- public boolean renderItem_hasEffect(ItemStack stack) {
- ItemCustomizeManager.ItemData data = ItemCustomizeManager.getDataForItem(stack);
- if(data != null) {
- customEnchGlint = data.customGlintColour;
- if(data.overrideEnchantGlint) {
- return data.enchantGlintValue;
- }
- } else {
- customEnchGlint = null;
- }
-
- return stack.hasEffect();
- }
-
- @Redirect(method="renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/resources/model/IBakedModel;)V",
- at=@At(
- value = "INVOKE",
- target = "Lnet/minecraft/client/renderer/tileentity/TileEntityItemStackRenderer;renderByItem(Lnet/minecraft/item/ItemStack;)V"
- )
- )
- public void renderItem_renderByItem(TileEntityItemStackRenderer tileEntityItemStackRenderer, ItemStack stack) {
- GL11.glPushMatrix();
- tileEntityItemStackRenderer.renderByItem(stack);
- GL11.glPopMatrix();
-
- ItemCustomizeManager.ItemData data = ItemCustomizeManager.getDataForItem(stack);
- if(data != null) {
- if(data.overrideEnchantGlint && data.enchantGlintValue) {
- ItemCustomizeManager.renderEffectHook(data.customGlintColour, (color) -> {
- float red = ((color >> 16) & 0xFF) / 255f;
- float green = ((color >> 8) & 0xFF) / 255f;
- float blue = (color & 0xFF) / 255f;
- float alpha = ((color >> 24) & 0xFF) / 255f;
-
- GlStateManager.color(red, green, blue, alpha);
-
- GlStateManager.scale(1/8f, 1/8f, 1/8f);
- GlStateManager.matrixMode(GL11.GL_MODELVIEW);
- GL11.glPushMatrix();
- ItemCustomizeManager.disableTextureBinding = true;
- tileEntityItemStackRenderer.renderByItem(stack);
- ItemCustomizeManager.disableTextureBinding = false;
- GL11.glPopMatrix();
-
- });
- }
- }
- }
-
- @Redirect(method="renderQuads",
- at=@At(
- value = "INVOKE",
- target = "Lnet/minecraft/item/Item;getColorFromItemStack(Lnet/minecraft/item/ItemStack;I)I"
- )
- )
- public int renderItem_renderByItem(Item item, ItemStack stack, int renderPass) {
- if(renderPass == 0) {
- ItemCustomizeManager.ItemData data = ItemCustomizeManager.getDataForItem(stack);
- if(data != null && data.customLeatherColour != null) {
- return ChromaColour.specialToChromaRGB(data.customLeatherColour);
- }
- }
-
- return item.getColorFromItemStack(stack, renderPass);
- }
-
- @Inject(method="renderEffect", at=@At("HEAD"), cancellable = true)
- public void renderEffect(IBakedModel model, CallbackInfo ci) {
- if(ItemCustomizeManager.renderEffectHook(customEnchGlint, (color) -> {
- renderModel(model, color);
- })) {
- ci.cancel();
- }
- }
-
- @Shadow
- abstract void renderModel(IBakedModel model, int color);
+ private static void func_181565_a(
+ WorldRenderer w, int x, int y, float width, int height,
+ int r, int g, int b, int a
+ ) {
+ w.begin(7, DefaultVertexFormats.POSITION_COLOR);
+ w.pos((x + 0), (y + 0), 0.0D)
+ .color(r, g, b, a).endVertex();
+ w.pos((x + 0), (y + height), 0.0D)
+ .color(r, g, b, a).endVertex();
+ w.pos((x + width), (y + height), 0.0D)
+ .color(r, g, b, a).endVertex();
+ w.pos((x + width), (y + 0), 0.0D)
+ .color(r, g, b, a).endVertex();
+ Tessellator.getInstance().draw();
+ }
+
+ private static String customEnchGlint = null;
+
+ @Redirect(method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/resources/model/IBakedModel;)V",
+ at = @At(
+ value = "INVOKE",
+ target = "Lnet/minecraft/item/ItemStack;hasEffect()Z"
+ )
+ )
+ public boolean renderItem_hasEffect(ItemStack stack) {
+ ItemCustomizeManager.ItemData data = ItemCustomizeManager.getDataForItem(stack);
+ if (data != null) {
+ customEnchGlint = data.customGlintColour;
+ if (data.overrideEnchantGlint) {
+ return data.enchantGlintValue;
+ }
+ } else {
+ customEnchGlint = null;
+ }
+
+ return stack.hasEffect();
+ }
+
+ @Redirect(method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/resources/model/IBakedModel;)V",
+ at = @At(
+ value = "INVOKE",
+ target = "Lnet/minecraft/client/renderer/tileentity/TileEntityItemStackRenderer;renderByItem(Lnet/minecraft/item/ItemStack;)V"
+ )
+ )
+ public void renderItem_renderByItem(TileEntityItemStackRenderer tileEntityItemStackRenderer, ItemStack stack) {
+ GL11.glPushMatrix();
+ tileEntityItemStackRenderer.renderByItem(stack);
+ GL11.glPopMatrix();
+
+ ItemCustomizeManager.ItemData data = ItemCustomizeManager.getDataForItem(stack);
+ if (data != null) {
+ if (data.overrideEnchantGlint && data.enchantGlintValue) {
+ ItemCustomizeManager.renderEffectHook(data.customGlintColour, (color) -> {
+ float red = ((color >> 16) & 0xFF) / 255f;
+ float green = ((color >> 8) & 0xFF) / 255f;
+ float blue = (color & 0xFF) / 255f;
+ float alpha = ((color >> 24) & 0xFF) / 255f;
+
+ GlStateManager.color(red, green, blue, alpha);
+
+ GlStateManager.scale(1 / 8f, 1 / 8f, 1 / 8f);
+ GlStateManager.matrixMode(GL11.GL_MODELVIEW);
+ GL11.glPushMatrix();
+ ItemCustomizeManager.disableTextureBinding = true;
+ tileEntityItemStackRenderer.renderByItem(stack);
+ ItemCustomizeManager.disableTextureBinding = false;
+ GL11.glPopMatrix();
+
+ });
+ }
+ }
+ }
+
+ @Redirect(method = "renderQuads",
+ at = @At(
+ value = "INVOKE",
+ target = "Lnet/minecraft/item/Item;getColorFromItemStack(Lnet/minecraft/item/ItemStack;I)I"
+ )
+ )
+ public int renderItem_renderByItem(Item item, ItemStack stack, int renderPass) {
+ if (renderPass == 0) {
+ ItemCustomizeManager.ItemData data = ItemCustomizeManager.getDataForItem(stack);
+ if (data != null && data.customLeatherColour != null) {
+ return ChromaColour.specialToChromaRGB(data.customLeatherColour);
+ }
+ }
+
+ return item.getColorFromItemStack(stack, renderPass);
+ }
+
+ @Inject(method = "renderEffect", at = @At("HEAD"), cancellable = true)
+ public void renderEffect(IBakedModel model, CallbackInfo ci) {
+ if (ItemCustomizeManager.renderEffectHook(customEnchGlint, (color) -> renderModel(model, color))) {
+ ci.cancel();
+ }
+ }
+
+ @Shadow
+ abstract void renderModel(IBakedModel model, int color);
/*@Redirect(method="renderEffect",
at=@At(
value = "INVOKE",
@@ -175,105 +174,111 @@ public abstract class MixinRenderItem {
}
}*/
- @Inject(method="renderItemIntoGUI", at=@At("HEAD"))
- public void renderItemHead(ItemStack stack, int x, int y, CallbackInfo ci) {
- if(NotEnoughUpdates.INSTANCE.overlay.searchMode && NEUEventListener.drawingGuiScreen) {
- boolean matches = false;
-
- GuiTextField textField = NotEnoughUpdates.INSTANCE.overlay.getTextField();
-
- if(textField.getText().trim().isEmpty()) {
- matches = true;
- } else if(stack != null) {
- for(String search : textField.getText().split("\\|")) {
- matches |= NotEnoughUpdates.INSTANCE.manager.doesStackMatchSearch(stack, search.trim());
- }
- }
- if(matches) {
- GlStateManager.pushMatrix();
- GlStateManager.translate(0, 0, 100 + Minecraft.getMinecraft().getRenderItem().zLevel);
- GlStateManager.depthMask(false);
- Gui.drawRect(x, y, x+16, y+16, NEUOverlay.overlayColourLight);
- GlStateManager.depthMask(true);
- GlStateManager.popMatrix();
- }
- }
- }
-
- @Inject(method="renderItemIntoGUI", at=@At("RETURN"))
- public void renderItemReturn(ItemStack stack, int x, int y, CallbackInfo ci) {
- if(stack != null && stack.stackSize != 1) return;
- if(NotEnoughUpdates.INSTANCE.overlay.searchMode && NEUEventListener.drawingGuiScreen) {
- boolean matches = false;
-
- GuiTextField textField = NotEnoughUpdates.INSTANCE.overlay.getTextField();
-
- if(textField.getText().trim().isEmpty()) {
- matches = true;
- } else if(stack != null) {
- for(String search : textField.getText().split("\\|")) {
- matches |= NotEnoughUpdates.INSTANCE.manager.doesStackMatchSearch(stack, search.trim());
- }
- }
- if(!matches) {
- GlStateManager.pushMatrix();
- GlStateManager.translate(0, 0, 110 + Minecraft.getMinecraft().getRenderItem().zLevel);
- Gui.drawRect(x, y, x+16, y+16, NEUOverlay.overlayColourDark);
- GlStateManager.popMatrix();
- }
- }
- }
-
- @Inject(method="renderItemOverlayIntoGUI", at=@At("RETURN"))
- public void renderItemOverlayIntoGUI(FontRenderer fr, ItemStack stack, int xPosition, int yPosition, String text, CallbackInfo ci) {
- if(stack != null && stack.stackSize != 1) {
- if(NotEnoughUpdates.INSTANCE.overlay.searchMode && NEUEventListener.drawingGuiScreen) {
- boolean matches = false;
-
- GuiTextField textField = NotEnoughUpdates.INSTANCE.overlay.getTextField();
-
- if(textField.getText().trim().isEmpty()) {
- matches = true;
- } else {
- for(String search : textField.getText().split("\\|")) {
- matches |= NotEnoughUpdates.INSTANCE.manager.doesStackMatchSearch(stack, search.trim());
- }
- }
- if(!matches) {
- GlStateManager.pushMatrix();
- GlStateManager.translate(0, 0, 110 + Minecraft.getMinecraft().getRenderItem().zLevel);
- GlStateManager.disableDepth();
- Gui.drawRect(xPosition, yPosition, xPosition+16, yPosition+16, NEUOverlay.overlayColourDark);
- GlStateManager.enableDepth();
- GlStateManager.popMatrix();
- }
- }
- }
-
- if(stack == null) return;
-
- float damageOverride = ItemCooldowns.getDurabilityOverride(stack);
-
- if(damageOverride >= 0) {
- float barX = 13.0f - damageOverride * 13.0f;
- int col = (int)Math.round(255.0D - damageOverride * 255.0D);
- GlStateManager.disableLighting();
- GlStateManager.disableDepth();
- GlStateManager.disableTexture2D();
- GlStateManager.disableAlpha();
- GlStateManager.disableBlend();
-
- Tessellator tessellator = Tessellator.getInstance();
- WorldRenderer worldrenderer = tessellator.getWorldRenderer();
- func_181565_a(worldrenderer, xPosition + 2, yPosition + 13, 13, 2, 0, 0, 0, 255);
- func_181565_a(worldrenderer, xPosition + 2, yPosition + 13, 12, 1, (255 - col) / 4, 64, 0, 255);
- func_181565_a(worldrenderer, xPosition + 2, yPosition + 13, barX, 1, 255 - col, col, 0, 255);
-
- GlStateManager.enableAlpha();
- GlStateManager.enableTexture2D();
- GlStateManager.enableLighting();
- GlStateManager.enableDepth();
- }
- }
-
+ @Inject(method = "renderItemIntoGUI", at = @At("HEAD"))
+ public void renderItemHead(ItemStack stack, int x, int y, CallbackInfo ci) {
+ if (NotEnoughUpdates.INSTANCE.overlay.searchMode && NEUEventListener.drawingGuiScreen) {
+ boolean matches = false;
+
+ GuiTextField textField = NotEnoughUpdates.INSTANCE.overlay.getTextField();
+
+ if (textField.getText().trim().isEmpty()) {
+ matches = true;
+ } else if (stack != null) {
+ for (String search : textField.getText().split("\\|")) {
+ matches |= NotEnoughUpdates.INSTANCE.manager.doesStackMatchSearch(stack, search.trim());
+ }
+ }
+ if (matches) {
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(0, 0, 100 + Minecraft.getMinecraft().getRenderItem().zLevel);
+ GlStateManager.depthMask(false);
+ Gui.drawRect(x, y, x + 16, y + 16, NEUOverlay.overlayColourLight);
+ GlStateManager.depthMask(true);
+ GlStateManager.popMatrix();
+ }
+ }
+ }
+
+ @Inject(method = "renderItemIntoGUI", at = @At("RETURN"))
+ public void renderItemReturn(ItemStack stack, int x, int y, CallbackInfo ci) {
+ if (stack != null && stack.stackSize != 1) return;
+ if (NotEnoughUpdates.INSTANCE.overlay.searchMode && NEUEventListener.drawingGuiScreen) {
+ boolean matches = false;
+
+ GuiTextField textField = NotEnoughUpdates.INSTANCE.overlay.getTextField();
+
+ if (textField.getText().trim().isEmpty()) {
+ matches = true;
+ } else if (stack != null) {
+ for (String search : textField.getText().split("\\|")) {
+ matches |= NotEnoughUpdates.INSTANCE.manager.doesStackMatchSearch(stack, search.trim());
+ }
+ }
+ if (!matches) {
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(0, 0, 110 + Minecraft.getMinecraft().getRenderItem().zLevel);
+ Gui.drawRect(x, y, x + 16, y + 16, NEUOverlay.overlayColourDark);
+ GlStateManager.popMatrix();
+ }
+ }
+ }
+
+ @Inject(method = "renderItemOverlayIntoGUI", at = @At("RETURN"))
+ public void renderItemOverlayIntoGUI(
+ FontRenderer fr,
+ ItemStack stack,
+ int xPosition,
+ int yPosition,
+ String text,
+ CallbackInfo ci
+ ) {
+ if (stack != null && stack.stackSize != 1) {
+ if (NotEnoughUpdates.INSTANCE.overlay.searchMode && NEUEventListener.drawingGuiScreen) {
+ boolean matches = false;
+
+ GuiTextField textField = NotEnoughUpdates.INSTANCE.overlay.getTextField();
+
+ if (textField.getText().trim().isEmpty()) {
+ matches = true;
+ } else {
+ for (String search : textField.getText().split("\\|")) {
+ matches |= NotEnoughUpdates.INSTANCE.manager.doesStackMatchSearch(stack, search.trim());
+ }
+ }
+ if (!matches) {
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(0, 0, 110 + Minecraft.getMinecraft().getRenderItem().zLevel);
+ GlStateManager.disableDepth();
+ Gui.drawRect(xPosition, yPosition, xPosition + 16, yPosition + 16, NEUOverlay.overlayColourDark);
+ GlStateManager.enableDepth();
+ GlStateManager.popMatrix();
+ }
+ }
+ }
+
+ if (stack == null) return;
+
+ float damageOverride = ItemCooldowns.getDurabilityOverride(stack);
+
+ if (damageOverride >= 0) {
+ float barX = 13.0f - damageOverride * 13.0f;
+ int col = (int) Math.round(255.0D - damageOverride * 255.0D);
+ GlStateManager.disableLighting();
+ GlStateManager.disableDepth();
+ GlStateManager.disableTexture2D();
+ GlStateManager.disableAlpha();
+ GlStateManager.disableBlend();
+
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+ func_181565_a(worldrenderer, xPosition + 2, yPosition + 13, 13, 2, 0, 0, 0, 255);
+ func_181565_a(worldrenderer, xPosition + 2, yPosition + 13, 12, 1, (255 - col) / 4, 64, 0, 255);
+ func_181565_a(worldrenderer, xPosition + 2, yPosition + 13, barX, 1, 255 - col, col, 0, 255);
+
+ GlStateManager.enableAlpha();
+ GlStateManager.enableTexture2D();
+ GlStateManager.enableLighting();
+ GlStateManager.enableDepth();
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderList.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderList.java
index ffaf9ebb..8c1cc247 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderList.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderList.java
@@ -1,7 +1,7 @@
package io.github.moulberry.notenoughupdates.mixins;
import io.github.moulberry.notenoughupdates.dungeons.DungeonBlocks;
-import net.minecraft.client.renderer.*;
+import net.minecraft.client.renderer.RenderList;
import net.minecraft.util.EnumWorldBlockLayer;
import org.lwjgl.opengl.GL11;
import org.spongepowered.asm.mixin.Mixin;
@@ -11,14 +11,13 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin({RenderList.class})
public abstract class MixinRenderList {
+ @Inject(method = "renderChunkLayer", at = @At("HEAD"))
+ public void renderChunkLayer(EnumWorldBlockLayer layer, CallbackInfo ci) {
+ if (DungeonBlocks.textureExists()) {
+ DungeonBlocks.bindTextureIfExists();
- @Inject(method="renderChunkLayer", at=@At("HEAD"))
- public void renderChunkLayer(EnumWorldBlockLayer layer, CallbackInfo ci) {
- if(DungeonBlocks.textureExists()) {
- DungeonBlocks.bindTextureIfExists();
-
- GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR);
- GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
- }
- }
+ GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR);
+ GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRendererLivingEntity.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRendererLivingEntity.java
index 7a1be4de..16c6c99c 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRendererLivingEntity.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRendererLivingEntity.java
@@ -1,16 +1,13 @@
package io.github.moulberry.notenoughupdates.mixins;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
-import io.github.moulberry.notenoughupdates.miscfeatures.CustomItemEffects;
import io.github.moulberry.notenoughupdates.miscfeatures.DamageCommas;
import io.github.moulberry.notenoughupdates.overlays.BonemerangOverlay;
import net.minecraft.client.renderer.entity.RendererLivingEntity;
-import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityArmorStand;
import net.minecraft.util.IChatComponent;
import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
@@ -18,23 +15,24 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(RendererLivingEntity.class)
public abstract class MixinRendererLivingEntity<T extends EntityLivingBase> {
+ @Redirect(method = "renderName", at = @At(value = "INVOKE", target =
+ "Lnet/minecraft/entity/EntityLivingBase;getDisplayName()Lnet/minecraft/util/IChatComponent;"))
+ public IChatComponent renderName_getDisplayName(EntityLivingBase entity) {
+ if (entity instanceof EntityArmorStand) {
+ return DamageCommas.replaceName(entity);
+ } else {
+ return entity.getDisplayName();
+ }
+ }
- @Redirect(method = "renderName", at=@At(value = "INVOKE", target =
- "Lnet/minecraft/entity/EntityLivingBase;getDisplayName()Lnet/minecraft/util/IChatComponent;"))
- public IChatComponent renderName_getDisplayName(EntityLivingBase entity) {
- if(entity instanceof EntityArmorStand) {
- return DamageCommas.replaceName(entity);
- } else {
- return entity.getDisplayName();
- }
- }
-
- @Inject(method="getColorMultiplier", at=@At("HEAD"), cancellable = true)
- public void getColorMultiplier(T entitylivingbaseIn, float lightBrightness,
- float partialTickTime, CallbackInfoReturnable<Integer> cir) {
- if(BonemerangOverlay.INSTANCE.bonemeragedEntities.contains(entitylivingbaseIn) && NotEnoughUpdates.INSTANCE.config.itemOverlays.highlightTargeted) {
- cir.setReturnValue(0x80ff9500);
- }
- }
-
+ @Inject(method = "getColorMultiplier", at = @At("HEAD"), cancellable = true)
+ public void getColorMultiplier(
+ T entitylivingbaseIn, float lightBrightness,
+ float partialTickTime, CallbackInfoReturnable<Integer> cir
+ ) {
+ if (BonemerangOverlay.INSTANCE.bonemeragedEntities.contains(entitylivingbaseIn) &&
+ NotEnoughUpdates.INSTANCE.config.itemOverlays.highlightTargeted) {
+ cir.setReturnValue(0x80ff9500);
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTextureManager.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTextureManager.java
index d96beabb..de6d1537 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTextureManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTextureManager.java
@@ -10,12 +10,10 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(TextureManager.class)
public class MixinTextureManager {
-
- @Inject(method="bindTexture", at=@At("HEAD"), cancellable = true)
- public void bindTexture(ResourceLocation location, CallbackInfo ci) {
- if(ItemCustomizeManager.disableTextureBinding) {
- ci.cancel();
- }
- }
-
+ @Inject(method = "bindTexture", at = @At("HEAD"), cancellable = true)
+ public void bindTexture(ResourceLocation location, CallbackInfo ci) {
+ if (ItemCustomizeManager.disableTextureBinding) {
+ ci.cancel();
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTileEntitySkullRenderer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTileEntitySkullRenderer.java
index 9f13ee41..71750fec 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTileEntitySkullRenderer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTileEntitySkullRenderer.java
@@ -8,17 +8,25 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(TileEntitySkullRenderer.class)
public class MixinTileEntitySkullRenderer {
-
- @Inject(method="renderSkull", at=@At("HEAD"), cancellable = true)
- public void renderSkull(float xOffset, float yOffset, float zOffset, EnumFacing placedDirection,
- float rotationDeg, int skullType, GameProfile skullOwner, int damage, CallbackInfo ci) {
- if(CustomSkulls.getInstance().renderSkull(xOffset, yOffset, zOffset, placedDirection, rotationDeg, skullType, skullOwner, damage)) {
- ci.cancel();
- }
- }
-
+ @Inject(method = "renderSkull", at = @At("HEAD"), cancellable = true)
+ public void renderSkull(
+ float xOffset, float yOffset, float zOffset, EnumFacing placedDirection,
+ float rotationDeg, int skullType, GameProfile skullOwner, int damage, CallbackInfo ci
+ ) {
+ if (CustomSkulls.getInstance().renderSkull(
+ xOffset,
+ yOffset,
+ zOffset,
+ placedDirection,
+ rotationDeg,
+ skullType,
+ skullOwner,
+ damage
+ )) {
+ ci.cancel();
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTileEntitySpecialRenderer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTileEntitySpecialRenderer.java
index e2f7f2e4..f93608b1 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTileEntitySpecialRenderer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTileEntitySpecialRenderer.java
@@ -1,7 +1,7 @@
package io.github.moulberry.notenoughupdates.mixins;
-import io.github.moulberry.notenoughupdates.dungeons.DungeonBlocks;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.dungeons.DungeonBlocks;
import io.github.moulberry.notenoughupdates.util.SpecialColour;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.util.ResourceLocation;
@@ -13,23 +13,26 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin({TileEntitySpecialRenderer.class})
public abstract class MixinTileEntitySpecialRenderer {
-
- @Inject(method="bindTexture", at=@At("HEAD"), cancellable = true)
- public void bindTexture(ResourceLocation location, CallbackInfo info) {
- if(DungeonBlocks.isOverriding()) {
- if(location.getResourcePath().equals("textures/entity/chest/normal.png") ||
- location.getResourcePath().equals("textures/entity/chest/normal_double.png") ||
- location.getResourcePath().equals("textures/entity/chest/trapped.png") ||
- location.getResourcePath().equals("textures/entity/chest/trapped_double.png")) {
- String colour = location.getResourcePath().contains("trapped") ? NotEnoughUpdates.INSTANCE.config.dungeons.dungTrappedChestColour :
- NotEnoughUpdates.INSTANCE.config.dungeons.dungChestColour;
- if(DungeonBlocks.bindModifiedTexture(location,
- SpecialColour.specialToChromaRGB(colour))) {
- info.cancel();
- GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR);
- GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
- }
- }
- }
- }
+ @Inject(method = "bindTexture", at = @At("HEAD"), cancellable = true)
+ public void bindTexture(ResourceLocation location, CallbackInfo info) {
+ if (DungeonBlocks.isOverriding()) {
+ if (location.getResourcePath().equals("textures/entity/chest/normal.png") ||
+ location.getResourcePath().equals("textures/entity/chest/normal_double.png") ||
+ location.getResourcePath().equals("textures/entity/chest/trapped.png") ||
+ location.getResourcePath().equals("textures/entity/chest/trapped_double.png")) {
+ String colour = location.getResourcePath().contains("trapped")
+ ? NotEnoughUpdates.INSTANCE.config.dungeons.dungTrappedChestColour
+ :
+ NotEnoughUpdates.INSTANCE.config.dungeons.dungChestColour;
+ if (DungeonBlocks.bindModifiedTexture(
+ location,
+ SpecialColour.specialToChromaRGB(colour)
+ )) {
+ info.cancel();
+ GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR);
+ GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
+ }
+ }
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinVboRenderList.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinVboRenderList.java
index 42d81781..73cb19d3 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinVboRenderList.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinVboRenderList.java
@@ -11,14 +11,13 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin({VboRenderList.class})
public abstract class MixinVboRenderList {
+ @Inject(method = "renderChunkLayer", at = @At("HEAD"))
+ public void renderChunkLayer(EnumWorldBlockLayer layer, CallbackInfo ci) {
+ if (DungeonBlocks.textureExists()) {
+ DungeonBlocks.bindTextureIfExists();
- @Inject(method="renderChunkLayer", at=@At("HEAD"))
- public void renderChunkLayer(EnumWorldBlockLayer layer, CallbackInfo ci) {
- if(DungeonBlocks.textureExists()) {
- DungeonBlocks.bindTextureIfExists();
-
- GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR);
- GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
- }
- }
+ GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR);
+ GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinWorld.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinWorld.java
index 0df8b30b..86073984 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinWorld.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinWorld.java
@@ -1,9 +1,8 @@
package io.github.moulberry.notenoughupdates.mixins;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.CustomBiomes;
import io.github.moulberry.notenoughupdates.miscfeatures.CustomItemEffects;
-import io.github.moulberry.notenoughupdates.miscfeatures.DwarvenMinesTextures;
-import io.github.moulberry.notenoughupdates.util.SBInfo;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
@@ -15,27 +14,25 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(World.class)
public class MixinWorld {
- @Inject(method="spawnParticle(IZDDDDDD[I)V", at=@At("HEAD"), cancellable = true)
- public void spawnParticle(int particleID, boolean p_175720_2_, double xCood, double yCoord, double zCoord,
- double xOffset, double yOffset, double zOffset, int[] p_175720_15_, CallbackInfo ci) {
- if(NotEnoughUpdates.INSTANCE.config.itemOverlays.disableHyperionParticles &&
- System.currentTimeMillis() - CustomItemEffects.INSTANCE.lastUsedHyperion < 500) {
- if(particleID == 1) {
- ci.cancel();
- }
- }
- }
+ @Inject(method = "spawnParticle(IZDDDDDD[I)V", at = @At("HEAD"), cancellable = true)
+ public void spawnParticle(
+ int particleID, boolean p_175720_2_, double xCood, double yCoord, double zCoord,
+ double xOffset, double yOffset, double zOffset, int[] p_175720_15_, CallbackInfo ci
+ ) {
+ if (NotEnoughUpdates.INSTANCE.config.itemOverlays.disableHyperionParticles &&
+ System.currentTimeMillis() - CustomItemEffects.INSTANCE.lastUsedHyperion < 500) {
+ if (particleID == 1) {
+ ci.cancel();
+ }
+ }
+ }
- @Inject(method="getBiomeGenForCoords", at=@At("HEAD"), cancellable = true)
- public void getBiomeGenForCoords(BlockPos pos, CallbackInfoReturnable<BiomeGenBase> cir) {
- int retexture = DwarvenMinesTextures.retexture(pos);
- if(retexture == 1) {
- cir.setReturnValue(BiomeGenBase.extremeHillsPlus);
- } else if(retexture == 2) {
- cir.setReturnValue(BiomeGenBase.extremeHillsEdge);
- } else if(retexture == 3) {
- cir.setReturnValue(BiomeGenBase.coldBeach);
- }
- }
+ @Inject(method = "getBiomeGenForCoords", at = @At("HEAD"), cancellable = true)
+ public void getBiomeGenForCoords(BlockPos pos, CallbackInfoReturnable<BiomeGenBase> cir) {
+ BiomeGenBase customBiome = CustomBiomes.INSTANCE.getCustomBiome(pos);
+ if (customBiome != null) {
+ cir.setReturnValue(customBiome);
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinWorldClient.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinWorldClient.java
index f8b01883..b20ff8fd 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinWorldClient.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinWorldClient.java
@@ -11,15 +11,13 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(WorldClient.class)
public class MixinWorldClient {
+ @Inject(method = "addEntityToWorld", at = @At("HEAD"))
+ public void addEntityToWorld(int entityID, Entity entityToSpawn, CallbackInfo ci) {
+ FishingHelper.getInstance().addEntity(entityID, entityToSpawn);
+ }
- @Inject(method="addEntityToWorld", at=@At("HEAD"))
- public void addEntityToWorld(int entityID, Entity entityToSpawn, CallbackInfo ci) {
- FishingHelper.getInstance().addEntity(entityID, entityToSpawn);
- }
-
- @Inject(method="removeEntityFromWorld", at=@At("RETURN"))
- public void removeEntityFromWorld(int entityID, CallbackInfoReturnable<Entity> cir) {
- FishingHelper.getInstance().removeEntity(entityID);
- }
-
+ @Inject(method = "removeEntityFromWorld", at = @At("RETURN"))
+ public void removeEntityFromWorld(int entityID, CallbackInfoReturnable<Entity> cir) {
+ FishingHelper.getInstance().removeEntity(entityID);
+ }
}
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 06619ffd..470b0381 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java
@@ -12,6 +12,7 @@ import io.github.moulberry.notenoughupdates.miscgui.GuiEnchantColour;
import io.github.moulberry.notenoughupdates.miscgui.GuiInvButtonEditor;
import io.github.moulberry.notenoughupdates.miscgui.NEUOverlayPlacements;
import io.github.moulberry.notenoughupdates.options.seperateSections.*;
+import io.github.moulberry.notenoughupdates.options.seperateSections.CustomArmour;
import io.github.moulberry.notenoughupdates.overlays.MiningOverlay;
import io.github.moulberry.notenoughupdates.overlays.OverlayManager;
import io.github.moulberry.notenoughupdates.overlays.TextOverlay;
@@ -26,448 +27,562 @@ import java.util.List;
import java.util.Map;
public class NEUConfig extends Config {
-
- private void editOverlay(String activeConfig, TextOverlay overlay, Position position) {
- Vector2f size = overlay.getDummySize();
- int width = (int)size.x;
- int height = (int)size.y;
- Minecraft.getMinecraft().displayGuiScreen(new GuiPositionEditor(position, width, height, () -> {
- overlay.renderDummy();
- OverlayManager.dontRenderOverlay = overlay.getClass();
- }, () -> {
- }, () -> NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper(NEUConfigEditor.editor)
- ));
- }
-
- @Override
- public void executeRunnable(int runnableId) {
- String activeConfigCategory = null;
- if(Minecraft.getMinecraft().currentScreen instanceof GuiScreenElementWrapper) {
- GuiScreenElementWrapper wrapper = (GuiScreenElementWrapper) Minecraft.getMinecraft().currentScreen;
- if(wrapper.element instanceof NEUConfigEditor) {
- activeConfigCategory = ((NEUConfigEditor)wrapper.element).getSelectedCategoryName();
- }
- }
-
- switch (runnableId) {
- case 0:
- ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/neumap");
- return;
- case 1:
- editOverlay(activeConfigCategory, OverlayManager.miningOverlay, mining.overlayPosition);
- return;
- case 2:
- Minecraft.getMinecraft().displayGuiScreen(new GuiPositionEditor(
- NotEnoughUpdates.INSTANCE.config.mining.drillFuelBarPosition,
- NotEnoughUpdates.INSTANCE.config.mining.drillFuelBarWidth, 12, () -> {
- }, () -> {
- }, () -> NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper(NEUConfigEditor.editor)
- ));
- return;
- case 3:
- editOverlay(activeConfigCategory, OverlayManager.farmingOverlay, skillOverlays.farmingPosition);
- return;
- case 4:
- editOverlay(activeConfigCategory, OverlayManager.petInfoOverlay, petOverlay.petInfoPosition);
- return;
- case 5:
- editOverlay(activeConfigCategory, OverlayManager.timersOverlay, miscOverlays.todoPosition);
- return;
- case 6:
- NotEnoughUpdates.INSTANCE.openGui = new NEUOverlayPlacements();
- return;
- case 7:
- NotEnoughUpdates.INSTANCE.openGui = new GuiInvButtonEditor();
- return;
- case 8:
- NotEnoughUpdates.INSTANCE.openGui = new GuiEnchantColour();
- return;
- case 9:
- editOverlay(activeConfigCategory, OverlayManager.bonemerangOverlay, itemOverlays.bonemerangPosition);
- return;
- case 10:
- editOverlay(activeConfigCategory, OverlayManager.crystalHollowOverlay, mining.crystalHollowOverlayPosition);
- }
- }
-
- @Expose
- @Category(
- name = "Misc",
- desc = "Miscellaneous options which don't fit into any other category"
- )
- public Misc misc = new Misc();
-
- @Expose
- @Category(
- name = "Notifications",
- desc = "Notifications"
- )
- public Notifications notifications = new Notifications();
-
- @Expose
- @Category(
- name = "Item List",
- desc = "Item List"
- )
- public Itemlist itemlist = new Itemlist();
-
- @Expose
- @Category(
- name = "Toolbar",
- desc = "Toolbar"
- )
- public Toolbar toolbar = new Toolbar();
-
- @Expose
- @Category(
- name = "Inventory Buttons",
- desc = "Inventory Buttons"
- )
- public InventoryButtons inventoryButtons = new InventoryButtons();
-
-
- @Expose
- @Category(
- name = "Slot Locking",
- desc = "Slot Locking"
- )
- public SlotLocking slotLocking = new SlotLocking();
-
- @Expose
- @Category(
- name = "Tooltip Tweaks",
- desc = "Tooltip Tweaks"
- )
- public TooltipTweaks tooltipTweaks = new TooltipTweaks();
-
- @Expose
- @Category(
- name = "Item Overlays",
- desc = "Item Overlays"
- )
- public ItemOverlays itemOverlays = new ItemOverlays();
-
- @Expose
- @Category(
- name = "Skill Overlays",
- desc = "Skill Overlays"
- )
- public SkillOverlays skillOverlays = new SkillOverlays();
-
- @Expose
- @Category(
- name = "Misc Overlays",
- desc = "Misc Overlays"
- )
- public MiscOverlays miscOverlays = new MiscOverlays();
-
- @Expose
- @Category(
- name = "Storage GUI",
- desc = "Storage GUI"
- )
- public StorageGUI storageGUI = new StorageGUI();
-
- @Expose
- @Category(
- name = "Dungeons",
- desc = "Dungeons"
- )
- public Dungeons dungeons = new Dungeons();
-
-
- @Expose
- @Category(
- name = "Enchanting GUI/Solvers",
- desc = "Enchanting GUI/Solvers"
- )
- public Enchanting enchantingSolvers = new Enchanting();
-
- @Expose
- @Category(
- name = "Mining",
- desc = "Mining"
- )
- public Mining mining = new Mining();
-
-
- @Expose
- @Category(
- name = "Fishing",
- desc = "Fishing"
- )
- public Fishing fishing = new Fishing();
-
- @Expose
- @Category(
- name = "NEU Auction House",
- desc = "NEU Auction House"
- )
- public NeuAuctionHouse neuAuctionHouse = new NeuAuctionHouse();
-
- @Expose
- @Category(
- name = "Improved SB Menus",
- desc = "Improved SB Menus"
- )
- public ImprovedSBMenu improvedSBMenu = new ImprovedSBMenu();
-
- @Expose
- @Category(
- name = "Calendar",
- desc = "Calendar"
- )
- public Calendar calendar = new Calendar();
-
- @Expose
- @Category(
- name = "Trade Menu",
- desc = "Trade Menu"
- )
- public TradeMenu tradeMenu = new TradeMenu();
-
- @Expose
- @Category(
- name = "Pet Overlay",
- desc = "Pet Overlay"
- )
- public PetOverlay petOverlay = new PetOverlay();
-
-
- @Expose
- @Category(
- name = "AH Tweaks",
- desc = "Tweaks for Hypixel's (Not NEU's) Auction House"
- )
- public AHTweaks ahTweaks = new AHTweaks();
-
- @Expose
- @Category(
- name = "Accessory Bag Overlay",
- desc = "Accessory Bag Overlay"
- )
- public AccessoryBag accessoryBag = new AccessoryBag();
-
- @Expose
- @Category(
- name = "Api Key",
- desc = "Api Key"
- )
- public ApiKey apiKey = new ApiKey();
-
- @Expose
- public Hidden hidden = new Hidden();
-
- @Expose
- public DungeonMapConfig dungeonMap = new DungeonMapConfig();
-
- public static class Hidden {
- @Expose
- public HashMap<String, NEUConfig.HiddenProfileSpecific> profileSpecific = new HashMap<>();
- @Expose
- public HashMap<String, NEUConfig.HiddenLocationSpecific> locationSpecific = new HashMap<>();
- @Expose public List<NEUConfig.InventoryButton> inventoryButtons = createDefaultInventoryButtons();
-
- @Expose public boolean enableItemEditing = false;
- @Expose public boolean cacheRenderedItempane = true;
- @Expose public boolean autoupdate = true;
- @Expose public String overlaySearchBar = "";
- @Expose public String overlayQuickCommand = "";
- @Expose public boolean dev = false;
- @Expose public boolean loadedModBefore = false;
- @Expose public String selectedCape = null;
- @Expose public int compareMode = 0;
- @Expose public int sortMode = 0;
- @Expose public ArrayList<Boolean> compareAscending = Lists.newArrayList(true, true, true);
- @Expose public ArrayList<String> favourites = new ArrayList<>();
- @Expose public ArrayList<String> previousAuctionSearches = new ArrayList<>();
- @Expose public ArrayList<String> eventFavourites = new ArrayList<>();
- @Expose public ArrayList<String> quickCommands = createDefaultQuickCommands();
- @Expose public ArrayList<String> enchantColours = createDefaultEnchantColours();
- @Expose public String repoURL = "https://github.com/Moulberry/NotEnoughUpdates-REPO/archive/master.zip";
- @Expose public String repoCommitsURL = "https://api.github.com/repos/Moulberry/NotEnoughUpdates-REPO/commits/master";
-
- @Expose public boolean firstTimeSearchFocus = true;
-
- //These config options were added due to a graphical bug that caused the player to be unable to see the screen
- @Expose public boolean disableBrokenCapes = false;
-
- }
-
- public static ArrayList<String> createDefaultEnchantColours(){
- return Lists.newArrayList(
- "[a-zA-Z\\- ]+:\u003e:9:6:0",
- "[a-zA-Z\\- ]+:\u003e:6:c:0",
- "[a-zA-Z\\- ]+:\u003e:5:5:0",
- "Experience:\u003e:3:5:0",
- "Life Steal:\u003e:3:5:0",
- "Scavenger:\u003e:3:5:0",
- "Looting:\u003e:3:5:0");
- }
-
- private static ArrayList<String> createDefaultQuickCommands() {
- ArrayList<String> arr = new ArrayList<>();
- arr.add("/warp home:Warp Home:eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzljODg4MWU0MjkxNWE5ZDI5YmI2MWExNmZiMjZkMDU5OTEzMjA0ZDI2NWRmNWI0MzliM2Q3OTJhY2Q1NiJ9fX0=");
- arr.add("/warp hub:Warp Hub:eyJ0aW1lc3RhbXAiOjE1NTkyMTU0MTY5MDksInByb2ZpbGVJZCI6IjQxZDNhYmMyZDc0OTQwMGM5MDkwZDU0MzRkMDM4MzFiIiwicHJvZmlsZU5hbWUiOiJNZWdha2xvb24iLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2Q3Y2M2Njg3NDIzZDA1NzBkNTU2YWM1M2UwNjc2Y2I1NjNiYmRkOTcxN2NkODI2OWJkZWJlZDZmNmQ0ZTdiZjgifX19");
- arr.add("/warp dungeon_hub:Dungeon Hub:eyJ0aW1lc3RhbXAiOjE1Nzg0MDk0MTMxNjksInByb2ZpbGVJZCI6IjQxZDNhYmMyZDc0OTQwMGM5MDkwZDU0MzRkMDM4MzFiIiwicHJvZmlsZU5hbWUiOiJNZWdha2xvb24iLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzliNTY4OTViOTY1OTg5NmFkNjQ3ZjU4NTk5MjM4YWY1MzJkNDZkYjljMWIwMzg5YjhiYmViNzA5OTlkYWIzM2QiLCJtZXRhZGF0YSI6eyJtb2RlbCI6InNsaW0ifX19fQ==");
- arr.add("/craft:Crafting Table:CRAFTING_TABLE");
- arr.add("/storage:Storage:CHEST");
- arr.add("/wardrobe:Wardrobe:LEATHER_CHESTPLATE");
- arr.add("/pets:Pets:BONE");
- arr.add("neuah:NEU Auction House:GOLD_BLOCK");
- arr.add("/bz:Bazaar:GOLD_BARDING");
- return arr;
- }
-
- public HiddenProfileSpecific getProfileSpecific() {
- if(SBInfo.getInstance().currentProfile == null) {
- return null;
- }
- return hidden.profileSpecific.computeIfAbsent(SBInfo.getInstance().currentProfile, k-> new HiddenProfileSpecific());
- }
-
- public static class HiddenProfileSpecific {
-
- @Expose public long godPotionDuration = 0L;
- @Expose public long puzzlerCompleted = 0L;
- @Expose public long firstCakeAte = 0L;
- @Expose public long fetchurCompleted = 0L;
- @Expose public long commissionsCompleted = 0L;
- @Expose public long experimentsCompleted = 0L;
- @Expose public long cookieBuffRemaining = 0L;
- @Expose public List<MiningOverlay.ForgeItem> forgeItems = new ArrayList<MiningOverlay.ForgeItem>();
-
- @Expose public int commissionMilestone = 0;
-
- @Expose public HashMap<String, Boolean> automatonParts = new HashMap<String, Boolean>(){{
- put("Electron Transmitter", false);
- put("FTX 3070", false);
- put("Robotron Reflector", false);
- put("Superlite Motor", false);
- put("Control Switch", false);
- put("Synthetic Heart", false);
- }};
-
- @Expose public HashMap<String, Boolean> divanMinesParts = new HashMap<String, Boolean>(){{
- put("Scavenged Lapis Sword", false);
- put("Scavenged Golden Hammer", false);
- put("Scavenged Diamond Axe", false);
- put("Scavenged Emerald Hammer", false);
- }};
-
- @Expose public HashMap<String, Integer> crystals = new HashMap<String, Integer>(){{
- put("Jade", 0);
- put("Amber", 0);
- put("Amethyst", 0);
- put("Sapphire", 0);
- put("Topaz", 0);
- }};
- }
-
- public HiddenLocationSpecific getLocationSpecific() {
- String location = SBInfo.getInstance().getLocation();
- if(location == null || location.isEmpty()) {
- return null;
- }
-
- return getLocationSpecific(location);
- }
-
- public HiddenLocationSpecific getLocationSpecific(String location) {
- return hidden.locationSpecific.computeIfAbsent(location, k-> new HiddenLocationSpecific());
- }
-
- public static class HiddenLocationSpecific {
- @Expose public Map<String, Integer> commissionMaxes = new HashMap<>();
- }
-
- public static List<InventoryButton> createDefaultInventoryButtons() {
- List<InventoryButton> buttons = new ArrayList<>();
- //Below crafting
- buttons.add(new InventoryButton(87, 63, null, true, false, false, 0, ""));
- buttons.add(new InventoryButton(87+21, 63, null, true, false, false, 0, ""));
- buttons.add(new InventoryButton(87+21*2, 63, null, true, false, false, 0, ""));
- buttons.add(new InventoryButton(87+21*3, 63, null, true, false, false, 0, ""));
-
- //Above crafting
- buttons.add(new InventoryButton(87, 5, null, true, false, false, 0, ""));
- buttons.add(new InventoryButton(87+21, 5, null, true, false, false, 0, ""));
- buttons.add(new InventoryButton(87+21*2, 5, null, true, false, false, 0, ""));
- buttons.add(new InventoryButton(87+21*3, 5, null, true, false, false, 0, ""));
-
- //Crafting square
- buttons.add(new InventoryButton(87, 25, null, true, false, false, 0, ""));
- buttons.add(new InventoryButton(87+18, 25, null, true, false, false, 0, ""));
- buttons.add(new InventoryButton(87, 25+18, null, true, false, false, 0, ""));
- buttons.add(new InventoryButton(87+18, 25+18, null, true, false, false, 0, ""));
-
- //Crafting result
- buttons.add(new InventoryButton(143, 35, null, true, false, false, 0, ""));
-
- //Player menu area
- buttons.add(new InventoryButton(60, 8, null, true, false, false, 0, ""));
- buttons.add(new InventoryButton(60, 60, null, true, false, false, 0, ""));
- buttons.add(new InventoryButton(26, 8, null, true, false, false, 0, ""));
- buttons.add(new InventoryButton(26, 60, null, true, false, false, 0, ""));
-
- //Right side
- for(int i=0; i<8; i++) {
- int y = 2+20*i;
- if(y < 80) {
- buttons.add(new InventoryButton(2, 2+20*i, null, false, true, false, 0, ""));
- } else {
- buttons.add(new InventoryButton(2, 2+20*i-166, null, false, true, true, 0, ""));
- }
- }
-
- //Top side
- for(int i=0; i<8; i++) {
- buttons.add(new InventoryButton(4+21*i, -19, null, false, false, false, 0, ""));
- }
-
- //Left side
- for(int i=0; i<8; i++) {
- int y = 2+20*i;
- if(y < 80) {
- buttons.add(new InventoryButton(-19, 2+20*i, null, false, false, false, 0, ""));
- } else {
- buttons.add(new InventoryButton(-19, 2+20*i-166, null, false, false, true, 0, ""));
- }
- }
-
- //Bottom side
- for(int i=0; i<8; i++) {
- buttons.add(new InventoryButton(4+21*i, 2, null, false, false, true, 0, ""));
- }
- return buttons;
- }
-
- public static class InventoryButton {
- @Expose public int x;
- @Expose public int y;
- @Expose public boolean playerInvOnly;
-
- @Expose public boolean anchorRight;
- @Expose public boolean anchorBottom;
-
- @Expose public int backgroundIndex;
- @Expose public String command;
- @Expose public String icon;
-
- public boolean isActive() {
- return command.trim().length() > 0;
- }
-
- public InventoryButton(int x, int y, String icon, boolean playerInvOnly, boolean anchorRight, boolean anchorBottom, int backgroundIndex, String command) {
- this.x = x;
- this.y = y;
- this.icon = icon;
- this.playerInvOnly = playerInvOnly;
- this.anchorRight = anchorRight;
- this.anchorBottom = anchorBottom;
- this.backgroundIndex = backgroundIndex;
- this.command = command;
- }
- }
+ private void editOverlay(String activeConfig, TextOverlay overlay, Position position) {
+ Vector2f size = overlay.getDummySize();
+ int width = (int) size.x;
+ int height = (int) size.y;
+ Minecraft.getMinecraft().displayGuiScreen(new GuiPositionEditor(position, width, height, () -> {
+ overlay.renderDummy();
+ OverlayManager.dontRenderOverlay = overlay.getClass();
+ }, () -> {
+ }, () -> NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper(NEUConfigEditor.editor)));
+ }
+
+ @Override
+ public void executeRunnable(int runnableId) {
+ String activeConfigCategory = null;
+ if (Minecraft.getMinecraft().currentScreen instanceof GuiScreenElementWrapper) {
+ GuiScreenElementWrapper wrapper = (GuiScreenElementWrapper) Minecraft.getMinecraft().currentScreen;
+ if (wrapper.element instanceof NEUConfigEditor) {
+ activeConfigCategory = ((NEUConfigEditor) wrapper.element).getSelectedCategoryName();
+ }
+ }
+
+ switch (runnableId) {
+ case 0:
+ ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/neumap");
+ return;
+ case 1:
+ editOverlay(activeConfigCategory, OverlayManager.miningOverlay, mining.overlayPosition);
+ return;
+ case 2:
+ Minecraft.getMinecraft().displayGuiScreen(new GuiPositionEditor(
+ NotEnoughUpdates.INSTANCE.config.mining.drillFuelBarPosition,
+ NotEnoughUpdates.INSTANCE.config.mining.drillFuelBarWidth, 12, () -> {
+ },
+ () -> {
+ }, () -> NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper(NEUConfigEditor.editor)
+ ));
+ return;
+ case 3:
+ editOverlay(activeConfigCategory, OverlayManager.farmingOverlay, skillOverlays.farmingPosition);
+ return;
+ case 4:
+ editOverlay(activeConfigCategory, OverlayManager.petInfoOverlay, petOverlay.petInfoPosition);
+ return;
+ case 5:
+ editOverlay(activeConfigCategory, OverlayManager.timersOverlay, miscOverlays.todoPosition);
+ return;
+ case 6:
+ NotEnoughUpdates.INSTANCE.openGui = new NEUOverlayPlacements();
+ return;
+ case 7:
+ NotEnoughUpdates.INSTANCE.openGui = new GuiInvButtonEditor();
+ return;
+ case 8:
+ NotEnoughUpdates.INSTANCE.openGui = new GuiEnchantColour();
+ return;
+ case 9:
+ editOverlay(activeConfigCategory, OverlayManager.bonemerangOverlay, itemOverlays.bonemerangPosition);
+ return;
+ case 10:
+ editOverlay(activeConfigCategory, OverlayManager.crystalHollowOverlay, mining.crystalHollowOverlayPosition);
+ return;
+ case 11:
+ editOverlay(activeConfigCategory, OverlayManager.miningSkillOverlay, skillOverlays.miningPosition);
+ return;
+ case 12:
+ ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/dn");
+ return;
+ case 13:
+ ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/pv");
+ return;
+ case 14:
+ editOverlay(activeConfigCategory, OverlayManager.fishingSkillOverlay, skillOverlays.fishingPosition);
+ return;
+ case 16:
+ ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/neusouls clear");
+ return;
+ case 17:
+ ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/neusouls unclear");
+ return;
+ case 18:
+ editOverlay(activeConfigCategory, OverlayManager.slayerOverlay, slayerOverlay.slayerPosition);
+ return;
+ case 19:
+ editOverlay(activeConfigCategory, OverlayManager.combatSkillOverlay, skillOverlays.combatPosition);
+
+ }
+ }
+
+ @Expose
+ @Category(
+ name = "Misc",
+ desc = "Miscellaneous options which don't fit into any other category"
+ )
+ public Misc misc = new Misc();
+
+ @Expose
+ @Category(
+ name = "GUI Locations",
+ desc = "Edit the GUI locations of everything here"
+ )
+ public LocationEdit locationedit = new LocationEdit();
+
+ @Expose
+ @Category(
+ name = "Notifications",
+ desc = "Notifications"
+ )
+ public Notifications notifications = new Notifications();
+
+ @Expose
+ @Category(
+ name = "Item List",
+ desc = "Item List"
+ )
+ public Itemlist itemlist = new Itemlist();
+
+ @Expose
+ @Category(
+ name = "Toolbar",
+ desc = "Toolbar"
+ )
+ public Toolbar toolbar = new Toolbar();
+
+ @Expose
+ @Category(
+ name = "Inventory Buttons",
+ desc = "Inventory Buttons"
+ )
+ public InventoryButtons inventoryButtons = new InventoryButtons();
+
+ @Expose
+ @Category(
+ name = "Slot Locking",
+ desc = "Slot Locking"
+ )
+ public SlotLocking slotLocking = new SlotLocking();
+
+ @Expose
+ @Category(
+ name = "Tooltip Tweaks",
+ desc = "Tooltip Tweaks"
+ )
+ public TooltipTweaks tooltipTweaks = new TooltipTweaks();
+
+ @Expose
+ @Category(
+ name = "Item Overlays",
+ desc = "Item Overlays"
+ )
+ public ItemOverlays itemOverlays = new ItemOverlays();
+
+ @Expose
+ @Category(
+ name = "Skill Overlays",
+ desc = "Skill Overlays"
+ )
+ public SkillOverlays skillOverlays = new SkillOverlays();
+
+ @Expose
+ @Category(
+ name = "Todo Overlay",
+ desc = "Todo Overlay"
+ )
+ public MiscOverlays miscOverlays = new MiscOverlays();
+
+ @Expose
+ @Category(
+ name = "Slayer Overlay",
+ desc = "Slayer Overlay"
+ )
+ public SlayerOverlay slayerOverlay = new SlayerOverlay();
+
+ @Expose
+ @Category(
+ name = "Storage GUI",
+ desc = "Storage GUI"
+ )
+ public StorageGUI storageGUI = new StorageGUI();
+
+ @Expose
+ @Category(
+ name = "Dungeons",
+ desc = "Dungeons"
+ )
+ public Dungeons dungeons = new Dungeons();
+
+ @Expose
+ @Category(
+ name = "Enchanting GUI/Solvers",
+ desc = "Enchanting GUI/Solvers"
+ )
+ public Enchanting enchantingSolvers = new Enchanting();
+
+ @Expose
+ @Category(
+ name = "Mining",
+ desc = "Mining"
+ )
+ public Mining mining = new Mining();
+
+ @Expose
+ @Category(
+ name = "Fishing",
+ desc = "Fishing"
+ )
+ public Fishing fishing = new Fishing();
+
+ @Expose
+ @Category(
+ name = "NEU Auction House",
+ desc = "NEU Auction House"
+ )
+ public NeuAuctionHouse neuAuctionHouse = new NeuAuctionHouse();
+
+ @Expose
+ @Category(
+ name = "Improved SB Menus",
+ desc = "Improved SB Menus"
+ )
+ public ImprovedSBMenu improvedSBMenu = new ImprovedSBMenu();
+
+ @Expose
+ @Category(
+ name = "Custom Armour Hud",
+ desc = "Custom Armour Hud"
+ )
+ public CustomArmour customArmour = new CustomArmour();
+
+ @Expose
+ @Category(
+ name = "Calendar",
+ desc = "Calendar"
+ )
+ public Calendar calendar = new Calendar();
+
+ @Expose
+ @Category(
+ name = "Trade Menu",
+ desc = "Trade Menu"
+ )
+ public TradeMenu tradeMenu = new TradeMenu();
+
+ @Expose
+ @Category(
+ name = "Pet Overlay",
+ desc = "Pet Overlay"
+ )
+ public PetOverlay petOverlay = new PetOverlay();
+
+ @Expose
+ @Category(
+ name = "AH Tweaks",
+ desc = "Tweaks for Hypixel's (Not NEU's) Auction House"
+ )
+ public AHTweaks ahTweaks = new AHTweaks();
+
+ @Expose
+ @Category(
+ name = "AH/BZ Graph",
+ desc = "Graph of auction and bazaar prices"
+ )
+ public AHGraph ahGraph = new AHGraph();
+
+ @Expose
+ @Category(
+ name = "Accessory Bag Overlay",
+ desc = "Accessory Bag Overlay"
+ )
+ public AccessoryBag accessoryBag = new AccessoryBag();
+
+ @Expose
+ @Category(
+ name = "Api Key",
+ desc = "Api Key"
+ )
+ public ApiKey apiKey = new ApiKey();
+
+ @Expose
+ public Hidden hidden = new Hidden();
+
+ @Expose
+ public DungeonMapConfig dungeonMap = new DungeonMapConfig();
+
+ public static class Hidden {
+ @Expose
+ public HashMap<String, NEUConfig.HiddenProfileSpecific> profileSpecific = new HashMap<>();
+ @Expose
+ public HashMap<String, NEUConfig.HiddenLocationSpecific> locationSpecific = new HashMap<>();
+ @Expose
+ public List<NEUConfig.InventoryButton> inventoryButtons = createDefaultInventoryButtons();
+
+ @Expose
+ public boolean enableItemEditing = false;
+ @Expose
+ public boolean cacheRenderedItempane = true;
+ @Expose
+ public boolean autoupdate = true;
+ @Expose
+ public String overlaySearchBar = "";
+ @Expose
+ public String overlayQuickCommand = "";
+ @Expose
+ public boolean dev = false;
+ @Expose
+ public boolean loadedModBefore = false;
+ @Expose
+ public String selectedCape = null;
+ @Expose
+ public int compareMode = 0;
+ @Expose
+ public int sortMode = 0;
+ @Expose
+ public ArrayList<Boolean> compareAscending = Lists.newArrayList(true, true, true);
+ @Expose
+ public ArrayList<String> favourites = new ArrayList<>();
+ @Expose
+ public ArrayList<String> previousAuctionSearches = new ArrayList<>();
+ @Expose
+ public ArrayList<String> eventFavourites = new ArrayList<>();
+ @Expose
+ public ArrayList<String> quickCommands = createDefaultQuickCommands();
+ @Expose
+ public ArrayList<String> enchantColours = createDefaultEnchantColours();
+ @Expose
+ public String repoURL = "https://github.com/Moulberry/NotEnoughUpdates-REPO/archive/master.zip";
+ @Expose
+ public String repoCommitsURL = "https://api.github.com/repos/Moulberry/NotEnoughUpdates-REPO/commits/master";
+
+ @Expose
+ public boolean firstTimeSearchFocus = true;
+
+ //These config options were added due to a graphical bug that caused the player to be unable to see the screen
+ @Expose
+ public boolean disableBrokenCapes = false;
+
+ //Ery wanted to texture himself because its ery
+ @Expose
+ public boolean npcRetextureOnSelf = false;
+
+ }
+
+ public static ArrayList<String> createDefaultEnchantColours() {
+ return Lists.newArrayList(
+ "[a-zA-Z\\- ]+:\u003e:9:6:0",
+ "[a-zA-Z\\- ]+:\u003e:6:c:0",
+ "[a-zA-Z\\- ]+:\u003e:5:5:0",
+ "Experience:\u003e:3:5:0",
+ "Life Steal:\u003e:3:5:0",
+ "Scavenger:\u003e:3:5:0",
+ "Looting:\u003e:3:5:0"
+ );
+ }
+
+ private static ArrayList<String> createDefaultQuickCommands() {
+ return new ArrayList<String>() {{
+ add(
+ "/warp home:Warp Home:eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzljODg4MWU0MjkxNWE5ZDI5YmI2MWExNmZiMjZkMDU5OTEzMjA0ZDI2NWRmNWI0MzliM2Q3OTJhY2Q1NiJ9fX0=");
+ add(
+ "/warp hub:Warp Hub:eyJ0aW1lc3RhbXAiOjE1NTkyMTU0MTY5MDksInByb2ZpbGVJZCI6IjQxZDNhYmMyZDc0OTQwMGM5MDkwZDU0MzRkMDM4MzFiIiwicHJvZmlsZU5hbWUiOiJNZWdha2xvb24iLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2Q3Y2M2Njg3NDIzZDA1NzBkNTU2YWM1M2UwNjc2Y2I1NjNiYmRkOTcxN2NkODI2OWJkZWJlZDZmNmQ0ZTdiZjgifX19");
+ add(
+ "/warp dungeon_hub:Dungeon Hub:eyJ0aW1lc3RhbXAiOjE1Nzg0MDk0MTMxNjksInByb2ZpbGVJZCI6IjQxZDNhYmMyZDc0OTQwMGM5MDkwZDU0MzRkMDM4MzFiIiwicHJvZmlsZU5hbWUiOiJNZWdha2xvb24iLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzliNTY4OTViOTY1OTg5NmFkNjQ3ZjU4NTk5MjM4YWY1MzJkNDZkYjljMWIwMzg5YjhiYmViNzA5OTlkYWIzM2QiLCJtZXRhZGF0YSI6eyJtb2RlbCI6InNsaW0ifX19fQ==");
+ add("/craft:Crafting Table:CRAFTING_TABLE");
+ add("/storage:Storage:CHEST");
+ add("/wardrobe:Wardrobe:LEATHER_CHESTPLATE");
+ add("/pets:Pets:BONE");
+ add("neuah:NEU Auction House:GOLD_BLOCK");
+ add("/bz:Bazaar:GOLD_BARDING");
+ }};
+ }
+
+ public HiddenProfileSpecific getProfileSpecific() {
+ if (SBInfo.getInstance().currentProfile == null) {
+ return null;
+ }
+ return hidden.profileSpecific.computeIfAbsent(
+ SBInfo.getInstance().currentProfile,
+ k -> new HiddenProfileSpecific()
+ );
+ }
+
+ public static class HiddenProfileSpecific {
+
+ @Expose
+ public long godPotionDuration = 0L;
+ @Expose
+ public long puzzlerCompleted = 0L;
+ @Expose
+ public long firstCakeAte = 0L;
+ @Expose
+ public long fetchurCompleted = 0L;
+ @Expose
+ public long commissionsCompleted = 0L;
+ @Expose
+ public long experimentsCompleted = 0L;
+ @Expose
+ public long cookieBuffRemaining = 0L;
+ @Expose
+ public List<MiningOverlay.ForgeItem> forgeItems = new ArrayList<>();
+
+ @Expose
+ public int commissionMilestone = 0;
+
+ @Expose
+ public HashMap<String, Boolean> automatonParts = new HashMap<String, Boolean>() {{
+ put("Electron Transmitter", false);
+ put("FTX 3070", false);
+ put("Robotron Reflector", false);
+ put("Superlite Motor", false);
+ put("Control Switch", false);
+ put("Synthetic Heart", false);
+ }};
+
+ @Expose
+ public HashMap<String, Boolean> divanMinesParts = new HashMap<String, Boolean>() {{
+ put("Scavenged Lapis Sword", false);
+ put("Scavenged Golden Hammer", false);
+ put("Scavenged Diamond Axe", false);
+ put("Scavenged Emerald Hammer", false);
+ }};
+
+ @Expose
+ public HashMap<String, Integer> crystals = new HashMap<String, Integer>() {{
+ put("Jade", 0);
+ put("Amber", 0);
+ put("Amethyst", 0);
+ put("Sapphire", 0);
+ put("Topaz", 0);
+ }};
+ @Expose
+ public long dailyGemstonePowderCompleted = 0L;
+ @Expose
+ public long dailyMithrilPowerCompleted = 0L;
+ }
+
+ public HiddenLocationSpecific getLocationSpecific() {
+ String location = SBInfo.getInstance().getLocation();
+ if (location == null || location.isEmpty()) {
+ return null;
+ }
+
+ return getLocationSpecific(location);
+ }
+
+ public HiddenLocationSpecific getLocationSpecific(String location) {
+ return hidden.locationSpecific.computeIfAbsent(location, k -> new HiddenLocationSpecific());
+ }
+
+ public static class HiddenLocationSpecific {
+ @Expose
+ public Map<String, Integer> commissionMaxes = new HashMap<>();
+ }
+
+ public static List<InventoryButton> createDefaultInventoryButtons() {
+ return new ArrayList<InventoryButton>() {{
+ //Below crafting
+ add(new InventoryButton(87, 63, null, true, false, false, 0, ""));
+ add(new InventoryButton(87 + 21, 63, null, true, false, false, 0, ""));
+ add(new InventoryButton(87 + 21 * 2, 63, null, true, false, false, 0, ""));
+ add(new InventoryButton(87 + 21 * 3, 63, null, true, false, false, 0, ""));
+
+ //Above crafting
+ add(new InventoryButton(87, 5, null, true, false, false, 0, ""));
+ add(new InventoryButton(87 + 21, 5, null, true, false, false, 0, ""));
+ add(new InventoryButton(87 + 21 * 2, 5, null, true, false, false, 0, ""));
+ add(new InventoryButton(87 + 21 * 3, 5, null, true, false, false, 0, ""));
+
+ //Crafting square
+ add(new InventoryButton(87, 25, null, true, false, false, 0, ""));
+ add(new InventoryButton(87 + 18, 25, null, true, false, false, 0, ""));
+ add(new InventoryButton(87, 25 + 18, null, true, false, false, 0, ""));
+ add(new InventoryButton(87 + 18, 25 + 18, null, true, false, false, 0, ""));
+
+ //Crafting result
+ add(new InventoryButton(143, 35, null, true, false, false, 0, ""));
+
+ //Player menu area
+ add(new InventoryButton(60, 8, null, true, false, false, 0, ""));
+ add(new InventoryButton(60, 60, null, true, false, false, 0, ""));
+ add(new InventoryButton(26, 8, null, true, false, false, 0, ""));
+ add(new InventoryButton(26, 60, null, true, false, false, 0, ""));
+
+ //Right side
+ for (int i = 0; i < 8; i++) {
+ int y = 2 + 20 * i;
+ if (y < 80) {
+ add(new InventoryButton(2, 2 + 20 * i, null, false, true, false, 0, ""));
+ } else {
+ add(new InventoryButton(2, 2 + 20 * i - 166, null, false, true, true, 0, ""));
+ }
+ }
+
+ //Top side
+ for (int i = 0; i < 8; i++) {
+ add(new InventoryButton(4 + 21 * i, -19, null, false, false, false, 0, ""));
+ }
+
+ //Left side
+ for (int i = 0; i < 8; i++) {
+ int y = 2 + 20 * i;
+ if (y < 80) {
+ add(new InventoryButton(-19, 2 + 20 * i, null, false, false, false, 0, ""));
+ } else {
+ add(new InventoryButton(-19, 2 + 20 * i - 166, null, false, false, true, 0, ""));
+ }
+ }
+
+ //Bottom side
+ for (int i = 0; i < 8; i++) {
+ add(new InventoryButton(4 + 21 * i, 2, null, false, false, true, 0, ""));
+ }
+ }};
+ }
+
+ public static class InventoryButton {
+ @Expose
+ public int x;
+ @Expose
+ public int y;
+ @Expose
+ public boolean playerInvOnly;
+
+ @Expose
+ public boolean anchorRight;
+ @Expose
+ public boolean anchorBottom;
+
+ @Expose
+ public int backgroundIndex;
+ @Expose
+ public String command;
+ @Expose
+ public String icon;
+
+ public boolean isActive() {
+ return command.trim().length() > 0;
+ }
+
+ public InventoryButton(
+ int x,
+ int y,
+ String icon,
+ boolean playerInvOnly,
+ boolean anchorRight,
+ boolean anchorBottom,
+ int backgroundIndex,
+ String command
+ ) {
+ this.x = x;
+ this.y = y;
+ this.icon = icon;
+ this.playerInvOnly = playerInvOnly;
+ this.anchorRight = anchorRight;
+ this.anchorBottom = anchorBottom;
+ this.backgroundIndex = backgroundIndex;
+ this.command = command;
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java
index 8e5edef1..6681a994 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java
@@ -24,751 +24,812 @@ import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
-import static io.github.moulberry.notenoughupdates.util.GuiTextures.*;
import java.awt.*;
import java.net.URI;
-import java.util.*;
import java.util.List;
+import java.util.*;
-public class NEUConfigEditor extends GuiElement {
+import static io.github.moulberry.notenoughupdates.util.GuiTextures.*;
- public static NEUConfigEditor editor = new NEUConfigEditor(NotEnoughUpdates.INSTANCE.config);
-
- private static final ResourceLocation[] socialsIco = new ResourceLocation[] {
- DISCORD,
- GITHUB,
- TWITTER,
- YOUTUBE,
- PATREON
- };
- private static final String[] socialsLink = new String[] {
- "https://discord.gg/moulberry",
- "https://github.com/Moulberry/NotEnoughUpdates",
- "https://twitter.com/moulberry/",
- "https://www.youtube.com/channel/UCPh-OKmRSS3IQi9p6YppLcw",
- "https://patreon.com/moulberry"
- };
-
- private static final ResourceLocation SEARCH_ICON = new ResourceLocation("notenoughupdates:core/search.png");
-
- private final long openedMillis;
-
- private String selectedCategory = null;
-
- private final LerpingInteger optionsScroll = new LerpingInteger(0, 150);
- private final LerpingInteger categoryScroll = new LerpingInteger(0, 150);
-
- private LinkedHashMap<String, ConfigProcessor.ProcessedCategory> processedConfig;
- private TreeMap<String, Set<ConfigProcessor.ProcessedOption>> searchOptionMap = new TreeMap<>();
- private HashMap<ConfigProcessor.ProcessedOption, ConfigProcessor.ProcessedCategory> categoryForOption = new HashMap<>();
-
- private Set<ConfigProcessor.ProcessedCategory> searchedCategories = null;
- private Map<ConfigProcessor.ProcessedCategory, Set<Integer>> searchedAccordions = null;
- private Set<ConfigProcessor.ProcessedOption> searchedOptions = null;
-
- private LerpingInteger minimumSearchSize = new LerpingInteger(0, 150);
- private GuiElementTextField searchField = new GuiElementTextField("", 0, 20, 0);
-
- public NEUConfigEditor(Config config) {
- this(config, null);
- }
-
- public NEUConfigEditor(Config config, String categoryOpen) {
- this.openedMillis = System.currentTimeMillis();
- this.processedConfig = ConfigProcessor.create(config);
-
- for(ConfigProcessor.ProcessedCategory category : processedConfig.values()) {
- for(ConfigProcessor.ProcessedOption option : category.options.values()) {
- categoryForOption.put(option, category);
-
- String combined = category.name + " " + category.desc + " " + option.name + " " + option.desc;
- combined = combined.replaceAll("[^a-zA-Z_ ]", "").toLowerCase();
- for(String word : combined.split("[ _]")) {
- searchOptionMap.computeIfAbsent(word, k->new HashSet<>()).add(option);
- }
- }
- }
-
- if(categoryOpen != null) {
- for(Map.Entry<String, ConfigProcessor.ProcessedCategory> category : processedConfig.entrySet()) {
- if(category.getValue().name.equalsIgnoreCase(categoryOpen)) {
- selectedCategory = category.getKey();
- break;
- }
- }
- if(selectedCategory == null) {
- for(Map.Entry<String, ConfigProcessor.ProcessedCategory> category : processedConfig.entrySet()) {
- if(category.getValue().name.toLowerCase().startsWith(categoryOpen.toLowerCase())) {
- selectedCategory = category.getKey();
- break;
- }
- }
- }
- if(selectedCategory == null) {
- for(Map.Entry<String, ConfigProcessor.ProcessedCategory> category : processedConfig.entrySet()) {
- if(category.getValue().name.toLowerCase().contains(categoryOpen.toLowerCase())) {
- selectedCategory = category.getKey();
- break;
- }
- }
- }
- }
-
- editor = this;
- }
-
- private LinkedHashMap<String, ConfigProcessor.ProcessedCategory> getCurrentConfigEditing() {
- LinkedHashMap<String, ConfigProcessor.ProcessedCategory> newMap = new LinkedHashMap<>(processedConfig);
- if(searchedCategories != null) newMap.values().retainAll(searchedCategories);
- return newMap;
- }
-
- private LinkedHashMap<String, ConfigProcessor.ProcessedOption> getOptionsInCategory(ConfigProcessor.ProcessedCategory cat) {
- LinkedHashMap<String, ConfigProcessor.ProcessedOption> newMap = new LinkedHashMap<>(cat.options);
-
- if(searchedOptions != null) {
- Set<ConfigProcessor.ProcessedOption> retain = new HashSet<>();
- retain.addAll(searchedOptions);
-
- if(searchedAccordions != null) {
- Set<Integer> visibleAccordions = searchedAccordions.get(cat);
-
- if(visibleAccordions != null && !visibleAccordions.isEmpty()) {
- for(ConfigProcessor.ProcessedOption option : newMap.values()) {
- if(option.editor instanceof GuiOptionEditorAccordion) {
- int accordionId = ((GuiOptionEditorAccordion)option.editor).getAccordionId();
-
- if(visibleAccordions.contains(accordionId)) {
- retain.add(option);
- }
- }
- }
- }
-
- }
-
- newMap.values().retainAll(retain);
- }
- return newMap;
- }
-
- public String getSelectedCategory() {
- return selectedCategory;
- }
-
- public String getSelectedCategoryName() {
- return processedConfig.get(selectedCategory).name;
- }
-
- private void setSelectedCategory(String category) {
- selectedCategory = category;
- optionsScroll.setValue(0);
- }
-
- public void search() {
- String search = searchField.getText().trim().replaceAll("[^a-zA-Z_ ]", "").toLowerCase();
- searchedCategories = null;
- searchedOptions = null;
- searchedAccordions = null;
-
- if(!search.isEmpty()) {
- searchedCategories = new HashSet<>();
- searchedAccordions = new HashMap<>();
-
- for(String word : search.split(" ")) {
- if(word.trim().isEmpty()) continue;
-
- Set<ConfigProcessor.ProcessedOption> options = new HashSet<>();
-
- Map<String, Set<ConfigProcessor.ProcessedOption>> map = NotEnoughUpdates.INSTANCE.manager
- .subMapWithKeysThatAreSuffixes(word, searchOptionMap);
-
- map.values().forEach(options::addAll);
-
- if(!options.isEmpty()) {
- if(searchedOptions == null) {
- searchedOptions = new HashSet<>(options);
- } else {
- searchedOptions.retainAll(options);
- }
- }
- }
-
- if(searchedOptions == null) {
- searchedOptions = new HashSet<>();
- } else {
- for(ConfigProcessor.ProcessedOption option : searchedOptions) {
- ConfigProcessor.ProcessedCategory cat = categoryForOption.get(option);
- if(cat == null) continue;
-
- searchedCategories.add(cat);
- searchedAccordions.computeIfAbsent(cat, k->new HashSet<>()).add(option.accordionId);
- }
- }
- }
- }
-
- public void render() {
- optionsScroll.tick();
- categoryScroll.tick();
-
- List<String> tooltipToDisplay = null;
-
- long currentTime = System.currentTimeMillis();
- long delta = currentTime - openedMillis;
-
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- int width = scaledResolution.getScaledWidth();
- int height = scaledResolution.getScaledHeight();
- int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
- int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
-
- float opacityFactor = LerpUtils.sigmoidZeroOne(delta/500f);
- RenderUtils.drawGradientRect(0, 0, 0, width, height,
- (int)(0x80*opacityFactor) << 24 | 0x101010,
- (int)(0x90*opacityFactor) << 24 | 0x101010);
-
- int xSize = Math.min(scaledResolution.getScaledWidth()-100/scaledResolution.getScaleFactor(), 500);
- int ySize = Math.min(scaledResolution.getScaledHeight()-100/scaledResolution.getScaleFactor(), 400);
-
- int x = (scaledResolution.getScaledWidth() - xSize)/2;
- int y = (scaledResolution.getScaledHeight() - ySize)/2;
-
- int adjScaleFactor = Math.max(2, scaledResolution.getScaleFactor());
-
- int openingXSize = xSize;
- int openingYSize = ySize;
- if(delta < 150) {
- openingXSize = (int)(delta*xSize/150);
- openingYSize = 5;
- } else if(delta < 300) {
- openingYSize = 5 + (int)(delta-150)*(ySize-5)/150;
- }
- RenderUtils.drawFloatingRectDark(
- (scaledResolution.getScaledWidth() - openingXSize)/2,
- (scaledResolution.getScaledHeight() - openingYSize)/2,
- openingXSize, openingYSize);
- GlScissorStack.clear();
- GlScissorStack.push((scaledResolution.getScaledWidth() - openingXSize)/2,
- (scaledResolution.getScaledHeight() - openingYSize)/2,
- (scaledResolution.getScaledWidth() + openingXSize)/2,
- (scaledResolution.getScaledHeight() + openingYSize)/2, scaledResolution);
-
- RenderUtils.drawFloatingRectDark(x+5, y+5, xSize-10, 20, false);
-
- FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
- TextRenderUtils.drawStringCenteredScaledMaxWidth("NotEnoughUpdates by "+EnumChatFormatting.DARK_PURPLE+"Moulberry",
- fr, x+xSize/2, y+15, false, 200, 0xa0a0a0);
-
- RenderUtils.drawFloatingRectDark(x+4, y+49-20,
- 140, ySize-54+20, false);
-
- int innerPadding = 20/adjScaleFactor;
- int innerLeft = x+4+innerPadding;
- int innerRight = x+144-innerPadding;
- int innerTop = y+49+innerPadding;
- int innerBottom = y+ySize-5-innerPadding;
- Gui.drawRect(innerLeft, innerTop, innerLeft+1, innerBottom, 0xff08080E); //Left
- Gui.drawRect(innerLeft+1, innerTop, innerRight, innerTop+1, 0xff08080E); //Top
- Gui.drawRect(innerRight-1, innerTop+1, innerRight, innerBottom, 0xff28282E); //Right
- Gui.drawRect(innerLeft+1, innerBottom-1, innerRight-1, innerBottom, 0xff28282E); //Bottom
- Gui.drawRect(innerLeft+1, innerTop+1, innerRight-1, innerBottom-1, 0x6008080E); //Middle
-
- GlScissorStack.push(0, innerTop+1, scaledResolution.getScaledWidth(),
- innerBottom-1, scaledResolution);
-
- float catBarSize = 1;
- int catY = -categoryScroll.getValue();
-
- LinkedHashMap<String, ConfigProcessor.ProcessedCategory> currentConfigEditing = getCurrentConfigEditing();
- for(Map.Entry<String, ConfigProcessor.ProcessedCategory> entry : currentConfigEditing.entrySet()) {
- String selectedCategory = getSelectedCategory();
- if(selectedCategory == null || !currentConfigEditing.containsKey(selectedCategory)) {
- setSelectedCategory(entry.getKey());
- }
- String catName = entry.getValue().name;
- if(entry.getKey().equals(getSelectedCategory())) {
- catName = EnumChatFormatting.DARK_AQUA.toString() + EnumChatFormatting.UNDERLINE + catName;
- } else {
- catName = EnumChatFormatting.GRAY + catName;
- }
- TextRenderUtils.drawStringCenteredScaledMaxWidth(catName,
- fr, x+75, y+70+catY, false, 100, -1);
- catY += 15;
- if(catY > 0) {
- catBarSize = LerpUtils.clampZeroOne((float)(innerBottom-innerTop-2)/(catY+5+categoryScroll.getValue()));
- }
- }
-
- float catBarStart = categoryScroll.getValue() / (float)(catY + categoryScroll.getValue());
- float catBarEnd = catBarStart+catBarSize;
- if(catBarEnd > 1) {
- catBarEnd = 1;
- if(categoryScroll.getTarget()/(float)(catY + categoryScroll.getValue())+catBarSize < 1) {
- int target = optionsScroll.getTarget();
- categoryScroll.setValue((int)Math.ceil((catY+5+categoryScroll.getValue())-catBarSize*(catY+5+categoryScroll.getValue())));
- categoryScroll.setTarget(target);
- } else {
- categoryScroll.setValue((int)Math.ceil((catY+5+categoryScroll.getValue())-catBarSize*(catY+5+categoryScroll.getValue())));
- }
- }
- int catDist = innerBottom-innerTop-12;
- Gui.drawRect(innerLeft+2, innerTop+5, innerLeft+7, innerBottom-5, 0xff101010);
- Gui.drawRect(innerLeft+3, innerTop+6+(int)(catDist*catBarStart), innerLeft+6,
- innerTop+6+(int)(catDist*catBarEnd), 0xff303030);
-
- GlScissorStack.pop(scaledResolution);
-
- TextRenderUtils.drawStringCenteredScaledMaxWidth("Categories",
- fr, x+75, y+44, false, 120, 0xa368ef);
-
- RenderUtils.drawFloatingRectDark(x+149, y+29, xSize-154, ySize-34, false);
-
- innerLeft = x+149+innerPadding;
- innerRight =x+xSize-5-innerPadding;
- innerBottom = y+ySize-5-innerPadding;
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(SEARCH_ICON);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(innerRight-20, innerTop-(20+innerPadding)/2-9, 18, 18, GL11.GL_NEAREST);
-
- minimumSearchSize.tick();
- boolean shouldShow = !searchField.getText().trim().isEmpty() || searchField.getFocus();
- if(shouldShow && minimumSearchSize.getTarget() < 30) {
- minimumSearchSize.setTarget(30);
- minimumSearchSize.resetTimer();
- } else if(!shouldShow && minimumSearchSize.getTarget() > 0) {
- minimumSearchSize.setTarget(0);
- minimumSearchSize.resetTimer();
- }
-
- int rightStuffLen = 20;
- if(minimumSearchSize.getValue() > 1) {
- int strLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(searchField.getText())+10;
- if(!shouldShow) strLen = 0;
-
- int len = Math.max(strLen, minimumSearchSize.getValue());
- searchField.setSize(len, 18);
- searchField.render(innerRight-25-len, innerTop-(20+innerPadding)/2-9);
-
- rightStuffLen += 5 + len;
- }
-
- if(getSelectedCategory() != null && currentConfigEditing.containsKey(getSelectedCategory())) {
- ConfigProcessor.ProcessedCategory cat = currentConfigEditing.get(getSelectedCategory());
-
- TextRenderUtils.drawStringScaledMaxWidth(cat.desc,
- fr, innerLeft+5, y+40, true, innerRight-innerLeft-rightStuffLen-10, 0xb0b0b0);
- }
-
- Gui.drawRect(innerLeft, innerTop, innerLeft+1, innerBottom, 0xff08080E); //Left
- Gui.drawRect(innerLeft+1, innerTop, innerRight, innerTop+1, 0xff08080E); //Top
- Gui.drawRect(innerRight-1, innerTop+1, innerRight, innerBottom, 0xff303036); //Right
- Gui.drawRect(innerLeft+1, innerBottom-1, innerRight-1, innerBottom, 0xff303036); //Bottom
- Gui.drawRect(innerLeft+1, innerTop+1, innerRight-1, innerBottom-1, 0x6008080E); //Middle
-
- GlScissorStack.push(innerLeft+1, innerTop+1, innerRight-1, innerBottom-1, scaledResolution);
- float barSize = 1;
- int optionY = -optionsScroll.getValue();
- if(getSelectedCategory() != null && currentConfigEditing.containsKey(getSelectedCategory())) {
- ConfigProcessor.ProcessedCategory cat = currentConfigEditing.get(getSelectedCategory());
- int optionWidthDefault = innerRight-innerLeft-20;
- GlStateManager.enableDepth();
- HashMap<Integer, Integer> activeAccordions = new HashMap<>();
- for(ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) {
- int optionWidth = optionWidthDefault;
- if(option.accordionId >= 0) {
- if(!activeAccordions.containsKey(option.accordionId)) {
- continue;
- }
- int accordionDepth = activeAccordions.get(option.accordionId);
- optionWidth = optionWidthDefault - (2*innerPadding)*(accordionDepth+1);
- }
-
- GuiOptionEditor editor = option.editor;
- if(editor == null) {
- continue;
- }
- if(editor instanceof GuiOptionEditorAccordion) {
- GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor;
- if(accordion.getToggled()) {
- int accordionDepth = 0;
- if(option.accordionId >= 0) {
- accordionDepth = activeAccordions.get(option.accordionId)+1;
- }
- activeAccordions.put(accordion.getAccordionId(), accordionDepth);
- }
- }
- int optionHeight = editor.getHeight();
- if(innerTop+5+optionY+optionHeight > innerTop+1 && innerTop+5+optionY < innerBottom-1) {
- editor.render((innerLeft+innerRight-optionWidth)/2-5, innerTop+5+optionY, optionWidth);
- }
- optionY += optionHeight + 5;
- }
- GlStateManager.disableDepth();
- if(optionY > 0) {
- barSize = LerpUtils.clampZeroOne((float)(innerBottom-innerTop-2)/(optionY+5+optionsScroll.getValue()));
- }
- }
-
- GlScissorStack.pop(scaledResolution);
-
- GL11.glDisable(GL11.GL_SCISSOR_TEST);
- if(getSelectedCategory() != null && currentConfigEditing.containsKey(getSelectedCategory())) {
- int optionYOverlay = -optionsScroll.getValue();
- ConfigProcessor.ProcessedCategory cat = currentConfigEditing.get(getSelectedCategory());
- int optionWidthDefault = innerRight-innerLeft-20;
-
- GlStateManager.translate(0, 0, 10);
- GlStateManager.enableDepth();
- HashMap<Integer, Integer> activeAccordions = new HashMap<>();
- for(ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) {
- int optionWidth = optionWidthDefault;
- if(option.accordionId >= 0) {
- if(!activeAccordions.containsKey(option.accordionId)) {
- continue;
- }
- int accordionDepth = activeAccordions.get(option.accordionId);
- optionWidth = optionWidthDefault - (2*innerPadding)*(accordionDepth+1);
- }
-
- GuiOptionEditor editor = option.editor;
- if(editor == null) {
- continue;
- }
- if(editor instanceof GuiOptionEditorAccordion) {
- GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor;
- if(accordion.getToggled()) {
- int accordionDepth = 0;
- if(option.accordionId >= 0) {
- accordionDepth = activeAccordions.get(option.accordionId)+1;
- }
- activeAccordions.put(accordion.getAccordionId(), accordionDepth);
- }
- }
- int optionHeight = editor.getHeight();
- if(innerTop+5+optionYOverlay+optionHeight > innerTop+1 && innerTop+5+optionYOverlay < innerBottom-1) {
- editor.renderOverlay((innerLeft+innerRight-optionWidth)/2-5, innerTop+5+optionYOverlay, optionWidth);
- }
- optionYOverlay += optionHeight + 5;
- }
- GlStateManager.disableDepth();
- GlStateManager.translate(0, 0, -10);
- }
- GL11.glEnable(GL11.GL_SCISSOR_TEST);
-
- float barStart = optionsScroll.getValue() / (float)(optionY + optionsScroll.getValue());
- float barEnd = barStart+barSize;
- if(barEnd > 1) {
- barEnd = 1;
- if(optionsScroll.getTarget()/(float)(optionY + optionsScroll.getValue())+barSize < 1) {
- int target = optionsScroll.getTarget();
- optionsScroll.setValue((int)Math.ceil((optionY+5+optionsScroll.getValue())-barSize*(optionY+5+optionsScroll.getValue())));
- optionsScroll.setTarget(target);
- } else {
- optionsScroll.setValue((int)Math.ceil((optionY+5+optionsScroll.getValue())-barSize*(optionY+5+optionsScroll.getValue())));
- }
- }
- int dist = innerBottom-innerTop-12;
- Gui.drawRect(innerRight-10, innerTop+5, innerRight-5, innerBottom-5, 0xff101010);
- Gui.drawRect(innerRight-9, innerTop+6+(int)(dist*barStart), innerRight-6, innerTop+6+(int)(dist*barEnd), 0xff303030);
-
- for(int socialIndex=0; socialIndex<socialsIco.length; socialIndex++) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(socialsIco[socialIndex]);
- GlStateManager.color(1, 1, 1, 1);
- int socialLeft = x+xSize-23-18*socialIndex;
- RenderUtils.drawTexturedRect(socialLeft, y+7, 16, 16, GL11.GL_LINEAR);
-
- if(mouseX >= socialLeft && mouseX <= socialLeft+16 &&
- mouseY >= y+6 && mouseY <= y+23) {
- tooltipToDisplay = Lists.newArrayList(EnumChatFormatting.YELLOW+"Go to: "+EnumChatFormatting.RESET+socialsLink[socialIndex]);
- }
- }
-
- GlScissorStack.clear();
-
- if(tooltipToDisplay != null) {
- TextRenderUtils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, fr);
- }
-
- GlStateManager.translate(0, 0, -2);
- }
-
- public boolean mouseInput(int mouseX, int mouseY) {
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- int width = scaledResolution.getScaledWidth();
- int height = scaledResolution.getScaledHeight();
-
- int xSize = Math.min(width-100/scaledResolution.getScaleFactor(), 500);
- int ySize = Math.min(height-100/scaledResolution.getScaleFactor(), 400);
-
- int x = (scaledResolution.getScaledWidth() - xSize)/2;
- int y = (scaledResolution.getScaledHeight() - ySize)/2;
-
- int adjScaleFactor = Math.max(2, scaledResolution.getScaleFactor());
-
- int innerPadding = 20/adjScaleFactor;
- int innerTop = y+49+innerPadding;
- int innerBottom = y+ySize-5-innerPadding;
- int innerLeft = x+149+innerPadding;
- int innerRight = x+xSize-5-innerPadding;
-
- if(Mouse.getEventButtonState()) {
- searchField.setFocus(mouseX >= innerRight-20 && mouseX <= innerRight-2 &&
- mouseY >= innerTop-(20+innerPadding)/2-9 && mouseY <= innerTop-(20+innerPadding)/2+9);
-
- if(minimumSearchSize.getValue() > 1) {
- int strLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(searchField.getText())+10;
- int len = Math.max(strLen, minimumSearchSize.getValue());
-
- if(mouseX >= innerRight-25-len && mouseX <= innerRight-25 &&
- mouseY >= innerTop-(20+innerPadding)/2-9 && mouseY <= innerTop-(20+innerPadding)/2+9) {
- String old = searchField.getText();
- searchField.mouseClicked(mouseX, mouseY, Mouse.getEventButton());
-
- if(!searchField.getText().equals(old)) search();
- }
- }
- }
-
- int dWheel = Mouse.getEventDWheel();
- if(mouseY > innerTop && mouseY < innerBottom && dWheel != 0) {
- if(dWheel < 0) {
- dWheel = -1;
- }
- if(dWheel > 0) {
- dWheel = 1;
- }
- if(mouseX < innerLeft) {
- int newTarget = categoryScroll.getTarget() - dWheel*30;
- if(newTarget < 0) {
- newTarget = 0;
- }
-
- float catBarSize = 1;
- int catY = -newTarget;
- for(Map.Entry<String, ConfigProcessor.ProcessedCategory> entry : getCurrentConfigEditing().entrySet()) {
- if(getSelectedCategory() == null) {
- setSelectedCategory(entry.getKey());
- }
-
- catY += 15;
- if(catY > 0) {
- catBarSize = LerpUtils.clampZeroOne((float)(innerBottom-innerTop-2)/(catY+5+newTarget));
- }
- }
-
- int barMax = (int)Math.floor((catY+5+newTarget)-catBarSize*(catY+5+newTarget));
- if(newTarget > barMax) {
- newTarget = barMax;
- }
- categoryScroll.resetTimer();
- categoryScroll.setTarget(newTarget);
- } else {
- int newTarget = optionsScroll.getTarget() - dWheel*30;
- if(newTarget < 0) {
- newTarget = 0;
- }
-
- float barSize = 1;
- int optionY = -newTarget;
- if(getSelectedCategory() != null && getCurrentConfigEditing() != null && getCurrentConfigEditing().containsKey(getSelectedCategory())) {
- ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory());
- HashMap<Integer, Integer> activeAccordions = new HashMap<>();
- for(ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) {
- if(option.accordionId >= 0) {
- if(!activeAccordions.containsKey(option.accordionId)) {
- continue;
- }
- }
-
- GuiOptionEditor editor = option.editor;
- if(editor == null) {
- continue;
- }
- if(editor instanceof GuiOptionEditorAccordion) {
- GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor;
- if(accordion.getToggled()) {
- int accordionDepth = 0;
- if(option.accordionId >= 0) {
- accordionDepth = activeAccordions.get(option.accordionId)+1;
- }
- activeAccordions.put(accordion.getAccordionId(), accordionDepth);
- }
- }
- optionY += editor.getHeight() + 5;
-
- if(optionY > 0) {
- barSize = LerpUtils.clampZeroOne((float)(innerBottom-innerTop-2)/(optionY+5 + newTarget));
- }
- }
- }
-
- int barMax = (int)Math.floor((optionY+5+newTarget)-barSize*(optionY+5+newTarget));
- if(newTarget > barMax) {
- newTarget = barMax;
- }
- optionsScroll.setTimeToReachTarget(Math.min(150, Math.max(10, 5*Math.abs(newTarget - optionsScroll.getValue()))));
- optionsScroll.resetTimer();
- optionsScroll.setTarget(newTarget);
- }
- } else if(Mouse.getEventButtonState() && Mouse.getEventButton() == 0) {
- if(getCurrentConfigEditing() != null) {
- int catY = -categoryScroll.getValue();
- for(Map.Entry<String, ConfigProcessor.ProcessedCategory> entry : getCurrentConfigEditing().entrySet()) {
- if(getSelectedCategory() == null) {
- setSelectedCategory(entry.getKey());
- }
- if(mouseX >= x+5 && mouseX <= x+145 &&
- mouseY >= y+70+catY-7 && mouseY <= y+70+catY+7) {
- setSelectedCategory(entry.getKey());
- return true;
- }
- catY += 15;
- }
- }
-
- for(int socialIndex=0; socialIndex<socialsLink.length; socialIndex++) {
- int socialLeft = x+xSize-23-18*socialIndex;
-
- if(mouseX >= socialLeft && mouseX <= socialLeft+16 &&
- mouseY >= y+6 && mouseY <= y+23) {
- try {
- Desktop.getDesktop().browse(new URI(socialsLink[socialIndex]));
- } catch(Exception ignored) {}
- return true;
- }
- }
- }
-
- int optionY = -optionsScroll.getValue();
- if(getSelectedCategory() != null && getCurrentConfigEditing() != null && getCurrentConfigEditing().containsKey(getSelectedCategory())) {
- int optionWidthDefault = innerRight-innerLeft-20;
- ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory());HashMap<Integer, Integer> activeAccordions = new HashMap<>();
- for(ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) {
- int optionWidth = optionWidthDefault;
- if(option.accordionId >= 0) {
- if(!activeAccordions.containsKey(option.accordionId)) {
- continue;
- }
- int accordionDepth = activeAccordions.get(option.accordionId);
- optionWidth = optionWidthDefault - (2*innerPadding)*(accordionDepth+1);
- }
-
- GuiOptionEditor editor = option.editor;
- if(editor == null) {
- continue;
- }
- if(editor instanceof GuiOptionEditorAccordion) {
- GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor;
- if(accordion.getToggled()) {
- int accordionDepth = 0;
- if(option.accordionId >= 0) {
- accordionDepth = activeAccordions.get(option.accordionId)+1;
- }
- activeAccordions.put(accordion.getAccordionId(), accordionDepth);
- }
- }
- if(editor.mouseInputOverlay((innerLeft+innerRight-optionWidth)/2-5, innerTop+5+optionY, optionWidth, mouseX, mouseY)) {
- return true;
- }
- optionY += editor.getHeight() + 5;
- }
- }
-
- if(mouseX > innerLeft && mouseX < innerRight &&
- mouseY > innerTop && mouseY < innerBottom) {
- optionY = -optionsScroll.getValue();
- if(getSelectedCategory() != null && getCurrentConfigEditing() != null && getCurrentConfigEditing().containsKey(getSelectedCategory())) {
- int optionWidthDefault = innerRight-innerLeft-20;
- ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory());
- HashMap<Integer, Integer> activeAccordions = new HashMap<>();
- for(ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) {
- int optionWidth = optionWidthDefault;
- if(option.accordionId >= 0) {
- if(!activeAccordions.containsKey(option.accordionId)) {
- continue;
- }
- int accordionDepth = activeAccordions.get(option.accordionId);
- optionWidth = optionWidthDefault - (2*innerPadding)*(accordionDepth+1);
- }
-
- GuiOptionEditor editor = option.editor;
- if(editor == null) {
- continue;
- }
- if(editor instanceof GuiOptionEditorAccordion) {
- GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor;
- if(accordion.getToggled()) {
- int accordionDepth = 0;
- if(option.accordionId >= 0) {
- accordionDepth = activeAccordions.get(option.accordionId)+1;
- }
- activeAccordions.put(accordion.getAccordionId(), accordionDepth);
- }
- }
- if(editor.mouseInput((innerLeft+innerRight-optionWidth)/2-5, innerTop+5+optionY, optionWidth, mouseX, mouseY)) {
- return true;
- }
- optionY += editor.getHeight() + 5;
- }
- }
- }
-
- return true;
- }
-
- public boolean keyboardInput() {
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- int width = scaledResolution.getScaledWidth();
-
- int xSize = Math.min(width-100/scaledResolution.getScaleFactor(), 500);
-
- int adjScaleFactor = Math.max(2, scaledResolution.getScaleFactor());
-
- int innerPadding = 20/adjScaleFactor;
- int innerWidth = xSize-154-innerPadding*2;
-
- if(Keyboard.getEventKeyState()) {
- Keyboard.enableRepeatEvents(true);
- String old = searchField.getText();
- searchField.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey());
- searchField.setText(Minecraft.getMinecraft().fontRendererObj.trimStringToWidth(searchField.getText(), innerWidth/2-20));
-
- if(!searchField.getText().equals(old)) search();
- }
-
- if(getSelectedCategory() != null && getCurrentConfigEditing() != null && getCurrentConfigEditing().containsKey(getSelectedCategory())) {
- ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory());
- HashMap<Integer, Integer> activeAccordions = new HashMap<>();
- for(ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) {
- if(option.accordionId >= 0) {
- if(!activeAccordions.containsKey(option.accordionId)) {
- continue;
- }
- }
-
- GuiOptionEditor editor = option.editor;
- if(editor == null) {
- continue;
- }
- if(editor instanceof GuiOptionEditorAccordion) {
- GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor;
- if(accordion.getToggled()) {
- int accordionDepth = 0;
- if(option.accordionId >= 0) {
- accordionDepth = activeAccordions.get(option.accordionId)+1;
- }
- activeAccordions.put(accordion.getAccordionId(), accordionDepth);
- }
- }
- if(editor.keyboardInput()) {
- return true;
- }
- }
- }
-
- return true;
- }
+public class NEUConfigEditor extends GuiElement {
+ public static NEUConfigEditor editor = new NEUConfigEditor(NotEnoughUpdates.INSTANCE.config);
+
+ private static final ResourceLocation[] socialsIco = new ResourceLocation[]{
+ DISCORD,
+ GITHUB,
+ TWITTER,
+ YOUTUBE,
+ PATREON,
+ TWITCH
+ };
+ private static final String[] socialsLink = new String[]{
+ "https://discord.gg/moulberry",
+ "https://github.com/Moulberry/NotEnoughUpdates",
+ "https://twitter.com/moulberry/",
+ "https://www.youtube.com/channel/UCPh-OKmRSS3IQi9p6YppLcw",
+ "https://patreon.com/moulberry",
+ "https://www.twitch.tv/moulberry2"
+ };
+
+ private static final ResourceLocation SEARCH_ICON = new ResourceLocation("notenoughupdates:core/search.png");
+
+ private final long openedMillis;
+
+ private String selectedCategory = null;
+
+ private final LerpingInteger optionsScroll = new LerpingInteger(0, 150);
+ private final LerpingInteger categoryScroll = new LerpingInteger(0, 150);
+
+ private final LinkedHashMap<String, ConfigProcessor.ProcessedCategory> processedConfig;
+ private final TreeMap<String, Set<ConfigProcessor.ProcessedOption>> searchOptionMap = new TreeMap<>();
+ private final HashMap<ConfigProcessor.ProcessedOption, ConfigProcessor.ProcessedCategory> categoryForOption =
+ new HashMap<>();
+
+ private Set<ConfigProcessor.ProcessedCategory> searchedCategories = null;
+ private Map<ConfigProcessor.ProcessedCategory, Set<Integer>> searchedAccordions = null;
+ private Set<ConfigProcessor.ProcessedOption> searchedOptions = null;
+
+ private final LerpingInteger minimumSearchSize = new LerpingInteger(0, 150);
+ private final GuiElementTextField searchField = new GuiElementTextField("", 0, 20, 0);
+
+ public NEUConfigEditor(Config config) {
+ this(config, null);
+ }
+
+ public NEUConfigEditor(Config config, String categoryOpen) {
+ this.openedMillis = System.currentTimeMillis();
+ this.processedConfig = ConfigProcessor.create(config);
+
+ for (ConfigProcessor.ProcessedCategory category : processedConfig.values()) {
+ for (ConfigProcessor.ProcessedOption option : category.options.values()) {
+ categoryForOption.put(option, category);
+
+ String combined = category.name + " " + category.desc + " " + option.name + " " + option.desc;
+ combined = combined.replaceAll("[^a-zA-Z_ ]", "").toLowerCase();
+ for (String word : combined.split("[ _]")) {
+ searchOptionMap.computeIfAbsent(word, k -> new HashSet<>()).add(option);
+ }
+ }
+ }
+
+ if (categoryOpen != null) {
+ for (Map.Entry<String, ConfigProcessor.ProcessedCategory> category : processedConfig.entrySet()) {
+ if (category.getValue().name.equalsIgnoreCase(categoryOpen)) {
+ selectedCategory = category.getKey();
+ break;
+ }
+ }
+ if (selectedCategory == null) {
+ for (Map.Entry<String, ConfigProcessor.ProcessedCategory> category : processedConfig.entrySet()) {
+ if (category.getValue().name.toLowerCase().startsWith(categoryOpen.toLowerCase())) {
+ selectedCategory = category.getKey();
+ break;
+ }
+ }
+ }
+ if (selectedCategory == null) {
+ for (Map.Entry<String, ConfigProcessor.ProcessedCategory> category : processedConfig.entrySet()) {
+ if (category.getValue().name.toLowerCase().contains(categoryOpen.toLowerCase())) {
+ selectedCategory = category.getKey();
+ break;
+ }
+ }
+ }
+ }
+
+ editor = this;
+ }
+
+ private LinkedHashMap<String, ConfigProcessor.ProcessedCategory> getCurrentConfigEditing() {
+ LinkedHashMap<String, ConfigProcessor.ProcessedCategory> newMap = new LinkedHashMap<>(processedConfig);
+ if (searchedCategories != null) newMap.values().retainAll(searchedCategories);
+ return newMap;
+ }
+
+ private LinkedHashMap<String, ConfigProcessor.ProcessedOption> getOptionsInCategory(ConfigProcessor.ProcessedCategory cat) {
+ LinkedHashMap<String, ConfigProcessor.ProcessedOption> newMap = new LinkedHashMap<>(cat.options);
+
+ if (searchedOptions != null) {
+ Set<ConfigProcessor.ProcessedOption> retain = new HashSet<>();
+ retain.addAll(searchedOptions);
+
+ if (searchedAccordions != null) {
+ Set<Integer> visibleAccordions = searchedAccordions.get(cat);
+
+ if (visibleAccordions != null && !visibleAccordions.isEmpty()) {
+ for (ConfigProcessor.ProcessedOption option : newMap.values()) {
+ if (option.editor instanceof GuiOptionEditorAccordion) {
+ int accordionId = ((GuiOptionEditorAccordion) option.editor).getAccordionId();
+
+ if (visibleAccordions.contains(accordionId)) {
+ retain.add(option);
+ }
+ }
+ }
+ }
+
+ }
+
+ newMap.values().retainAll(retain);
+ }
+ return newMap;
+ }
+
+ public String getSelectedCategory() {
+ return selectedCategory;
+ }
+
+ public String getSelectedCategoryName() {
+ return processedConfig.get(selectedCategory).name;
+ }
+
+ private void setSelectedCategory(String category) {
+ selectedCategory = category;
+ optionsScroll.setValue(0);
+ }
+
+ public void search() {
+ String search = searchField.getText().trim().replaceAll("[^a-zA-Z_ ]", "").toLowerCase();
+ searchedCategories = null;
+ searchedOptions = null;
+ searchedAccordions = null;
+
+ if (!search.isEmpty()) {
+ searchedCategories = new HashSet<>();
+ searchedAccordions = new HashMap<>();
+
+ for (String word : search.split(" ")) {
+ if (word.trim().isEmpty()) continue;
+
+ Set<ConfigProcessor.ProcessedOption> options = new HashSet<>();
+
+ Map<String, Set<ConfigProcessor.ProcessedOption>> map = NotEnoughUpdates.INSTANCE.manager
+ .subMapWithKeysThatAreSuffixes(word, searchOptionMap);
+
+ map.values().forEach(options::addAll);
+
+ if (!options.isEmpty()) {
+ if (searchedOptions == null) {
+ searchedOptions = new HashSet<>(options);
+ } else {
+ searchedOptions.retainAll(options);
+ }
+ }
+ }
+
+ if (searchedOptions == null) {
+ searchedOptions = new HashSet<>();
+ } else {
+ for (ConfigProcessor.ProcessedOption option : searchedOptions) {
+ ConfigProcessor.ProcessedCategory cat = categoryForOption.get(option);
+ if (cat == null) continue;
+
+ searchedCategories.add(cat);
+ searchedAccordions.computeIfAbsent(cat, k -> new HashSet<>()).add(option.accordionId);
+ }
+ }
+ }
+ }
+
+ public void render() {
+ optionsScroll.tick();
+ categoryScroll.tick();
+
+ List<String> tooltipToDisplay = null;
+
+ long currentTime = System.currentTimeMillis();
+ long delta = currentTime - openedMillis;
+
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ int width = scaledResolution.getScaledWidth();
+ int height = scaledResolution.getScaledHeight();
+ int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
+ int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
+
+ float opacityFactor = LerpUtils.sigmoidZeroOne(delta / 500f);
+ RenderUtils.drawGradientRect(0, 0, 0, width, height,
+ (int) (0x80 * opacityFactor) << 24 | 0x101010,
+ (int) (0x90 * opacityFactor) << 24 | 0x101010
+ );
+
+ int xSize = Math.min(scaledResolution.getScaledWidth() - 100 / scaledResolution.getScaleFactor(), 500);
+ int ySize = Math.min(scaledResolution.getScaledHeight() - 100 / scaledResolution.getScaleFactor(), 400);
+
+ int x = (scaledResolution.getScaledWidth() - xSize) / 2;
+ int y = (scaledResolution.getScaledHeight() - ySize) / 2;
+
+ int adjScaleFactor = Math.max(2, scaledResolution.getScaleFactor());
+
+ int openingXSize = xSize;
+ int openingYSize = ySize;
+ if (delta < 150) {
+ openingXSize = (int) (delta * xSize / 150);
+ openingYSize = 5;
+ } else if (delta < 300) {
+ openingYSize = 5 + (int) (delta - 150) * (ySize - 5) / 150;
+ }
+ RenderUtils.drawFloatingRectDark(
+ (scaledResolution.getScaledWidth() - openingXSize) / 2,
+ (scaledResolution.getScaledHeight() - openingYSize) / 2,
+ openingXSize, openingYSize
+ );
+ GlScissorStack.clear();
+ GlScissorStack.push((scaledResolution.getScaledWidth() - openingXSize) / 2,
+ (scaledResolution.getScaledHeight() - openingYSize) / 2,
+ (scaledResolution.getScaledWidth() + openingXSize) / 2,
+ (scaledResolution.getScaledHeight() + openingYSize) / 2, scaledResolution
+ );
+
+ RenderUtils.drawFloatingRectDark(x + 5, y + 5, xSize - 10, 20, false);
+
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+ TextRenderUtils.drawStringCenteredScaledMaxWidth(
+ "NotEnoughUpdates by " + EnumChatFormatting.DARK_PURPLE + "Moulberry",
+ fr,
+ x + xSize / 2,
+ y + 15,
+ false,
+ 200,
+ 0xa0a0a0
+ );
+
+ RenderUtils.drawFloatingRectDark(x + 4, y + 49 - 20,
+ 140, ySize - 54 + 20, false
+ );
+
+ int innerPadding = 20 / adjScaleFactor;
+ int innerLeft = x + 4 + innerPadding;
+ int innerRight = x + 144 - innerPadding;
+ int innerTop = y + 49 + innerPadding;
+ int innerBottom = y + ySize - 5 - innerPadding;
+ Gui.drawRect(innerLeft, innerTop, innerLeft + 1, innerBottom, 0xff08080E); //Left
+ Gui.drawRect(innerLeft + 1, innerTop, innerRight, innerTop + 1, 0xff08080E); //Top
+ Gui.drawRect(innerRight - 1, innerTop + 1, innerRight, innerBottom, 0xff28282E); //Right
+ Gui.drawRect(innerLeft + 1, innerBottom - 1, innerRight - 1, innerBottom, 0xff28282E); //Bottom
+ Gui.drawRect(innerLeft + 1, innerTop + 1, innerRight - 1, innerBottom - 1, 0x6008080E); //Middle
+
+ GlScissorStack.push(0, innerTop + 1, scaledResolution.getScaledWidth(),
+ innerBottom - 1, scaledResolution
+ );
+
+ float catBarSize = 1;
+ int catY = -categoryScroll.getValue();
+
+ LinkedHashMap<String, ConfigProcessor.ProcessedCategory> currentConfigEditing = getCurrentConfigEditing();
+ for (Map.Entry<String, ConfigProcessor.ProcessedCategory> entry : currentConfigEditing.entrySet()) {
+ String selectedCategory = getSelectedCategory();
+ if (selectedCategory == null || !currentConfigEditing.containsKey(selectedCategory)) {
+ setSelectedCategory(entry.getKey());
+ }
+ String catName = entry.getValue().name;
+ if (entry.getKey().equals(getSelectedCategory())) {
+ catName = EnumChatFormatting.DARK_AQUA.toString() + EnumChatFormatting.UNDERLINE + catName;
+ } else {
+ catName = EnumChatFormatting.GRAY + catName;
+ }
+ TextRenderUtils.drawStringCenteredScaledMaxWidth(catName,
+ fr, x + 75, y + 70 + catY, false, 100, -1
+ );
+ catY += 15;
+ if (catY > 0) {
+ catBarSize =
+ LerpUtils.clampZeroOne((float) (innerBottom - innerTop - 2) / (catY + 5 + categoryScroll.getValue()));
+ }
+ }
+
+ float catBarStart = categoryScroll.getValue() / (float) (catY + categoryScroll.getValue());
+ float catBarEnd = catBarStart + catBarSize;
+ if (catBarEnd > 1) {
+ catBarEnd = 1;
+ if (categoryScroll.getTarget() / (float) (catY + categoryScroll.getValue()) + catBarSize < 1) {
+ int target = optionsScroll.getTarget();
+ categoryScroll.setValue((int) Math.ceil(
+ (catY + 5 + categoryScroll.getValue()) - catBarSize * (catY + 5 + categoryScroll.getValue())));
+ categoryScroll.setTarget(target);
+ } else {
+ categoryScroll.setValue((int) Math.ceil(
+ (catY + 5 + categoryScroll.getValue()) - catBarSize * (catY + 5 + categoryScroll.getValue())));
+ }
+ }
+ int catDist = innerBottom - innerTop - 12;
+ Gui.drawRect(innerLeft + 2, innerTop + 5, innerLeft + 7, innerBottom - 5, 0xff101010);
+ Gui.drawRect(innerLeft + 3, innerTop + 6 + (int) (catDist * catBarStart), innerLeft + 6,
+ innerTop + 6 + (int) (catDist * catBarEnd), 0xff303030
+ );
+
+ GlScissorStack.pop(scaledResolution);
+
+ TextRenderUtils.drawStringCenteredScaledMaxWidth("Categories",
+ fr, x + 75, y + 44, false, 120, 0xa368ef
+ );
+
+ RenderUtils.drawFloatingRectDark(x + 149, y + 29, xSize - 154, ySize - 34, false);
+
+ innerLeft = x + 149 + innerPadding;
+ innerRight = x + xSize - 5 - innerPadding;
+ innerBottom = y + ySize - 5 - innerPadding;
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(SEARCH_ICON);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(innerRight - 20, innerTop - (20 + innerPadding) / 2 - 9, 18, 18, GL11.GL_NEAREST);
+
+ minimumSearchSize.tick();
+ boolean shouldShow = !searchField.getText().trim().isEmpty() || searchField.getFocus();
+ if (shouldShow && minimumSearchSize.getTarget() < 30) {
+ minimumSearchSize.setTarget(30);
+ minimumSearchSize.resetTimer();
+ } else if (!shouldShow && minimumSearchSize.getTarget() > 0) {
+ minimumSearchSize.setTarget(0);
+ minimumSearchSize.resetTimer();
+ }
+
+ int rightStuffLen = 20;
+ if (minimumSearchSize.getValue() > 1) {
+ int strLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(searchField.getText()) + 10;
+ if (!shouldShow) strLen = 0;
+
+ int len = Math.max(strLen, minimumSearchSize.getValue());
+ searchField.setSize(len, 18);
+ searchField.render(innerRight - 25 - len, innerTop - (20 + innerPadding) / 2 - 9);
+
+ rightStuffLen += 5 + len;
+ }
+
+ if (getSelectedCategory() != null && currentConfigEditing.containsKey(getSelectedCategory())) {
+ ConfigProcessor.ProcessedCategory cat = currentConfigEditing.get(getSelectedCategory());
+
+ TextRenderUtils.drawStringScaledMaxWidth(cat.desc,
+ fr, innerLeft + 5, y + 40, true, innerRight - innerLeft - rightStuffLen - 10, 0xb0b0b0
+ );
+ }
+
+ Gui.drawRect(innerLeft, innerTop, innerLeft + 1, innerBottom, 0xff08080E); //Left
+ Gui.drawRect(innerLeft + 1, innerTop, innerRight, innerTop + 1, 0xff08080E); //Top
+ Gui.drawRect(innerRight - 1, innerTop + 1, innerRight, innerBottom, 0xff303036); //Right
+ Gui.drawRect(innerLeft + 1, innerBottom - 1, innerRight - 1, innerBottom, 0xff303036); //Bottom
+ Gui.drawRect(innerLeft + 1, innerTop + 1, innerRight - 1, innerBottom - 1, 0x6008080E); //Middle
+
+ GlScissorStack.push(innerLeft + 1, innerTop + 1, innerRight - 1, innerBottom - 1, scaledResolution);
+ float barSize = 1;
+ int optionY = -optionsScroll.getValue();
+ if (getSelectedCategory() != null && currentConfigEditing.containsKey(getSelectedCategory())) {
+ ConfigProcessor.ProcessedCategory cat = currentConfigEditing.get(getSelectedCategory());
+ int optionWidthDefault = innerRight - innerLeft - 20;
+ GlStateManager.enableDepth();
+ HashMap<Integer, Integer> activeAccordions = new HashMap<>();
+ for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) {
+ int optionWidth = optionWidthDefault;
+ if (option.accordionId >= 0) {
+ if (!activeAccordions.containsKey(option.accordionId)) {
+ continue;
+ }
+ int accordionDepth = activeAccordions.get(option.accordionId);
+ optionWidth = optionWidthDefault - (2 * innerPadding) * (accordionDepth + 1);
+ }
+
+ GuiOptionEditor editor = option.editor;
+ if (editor == null) {
+ continue;
+ }
+ if (editor instanceof GuiOptionEditorAccordion) {
+ GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor;
+ if (accordion.getToggled()) {
+ int accordionDepth = 0;
+ if (option.accordionId >= 0) {
+ accordionDepth = activeAccordions.get(option.accordionId) + 1;
+ }
+ activeAccordions.put(accordion.getAccordionId(), accordionDepth);
+ }
+ }
+ int optionHeight = editor.getHeight();
+ if (innerTop + 5 + optionY + optionHeight > innerTop + 1 && innerTop + 5 + optionY < innerBottom - 1) {
+ editor.render((innerLeft + innerRight - optionWidth) / 2 - 5, innerTop + 5 + optionY, optionWidth);
+ }
+ optionY += optionHeight + 5;
+ }
+ GlStateManager.disableDepth();
+ if (optionY > 0) {
+ barSize =
+ LerpUtils.clampZeroOne((float) (innerBottom - innerTop - 2) / (optionY + 5 + optionsScroll.getValue()));
+ }
+ }
+
+ GlScissorStack.pop(scaledResolution);
+
+ GL11.glDisable(GL11.GL_SCISSOR_TEST);
+ if (getSelectedCategory() != null && currentConfigEditing.containsKey(getSelectedCategory())) {
+ int optionYOverlay = -optionsScroll.getValue();
+ ConfigProcessor.ProcessedCategory cat = currentConfigEditing.get(getSelectedCategory());
+ int optionWidthDefault = innerRight - innerLeft - 20;
+
+ GlStateManager.translate(0, 0, 10);
+ GlStateManager.enableDepth();
+ HashMap<Integer, Integer> activeAccordions = new HashMap<>();
+ for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) {
+ int optionWidth = optionWidthDefault;
+ if (option.accordionId >= 0) {
+ if (!activeAccordions.containsKey(option.accordionId)) {
+ continue;
+ }
+ int accordionDepth = activeAccordions.get(option.accordionId);
+ optionWidth = optionWidthDefault - (2 * innerPadding) * (accordionDepth + 1);
+ }
+
+ GuiOptionEditor editor = option.editor;
+ if (editor == null) {
+ continue;
+ }
+ if (editor instanceof GuiOptionEditorAccordion) {
+ GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor;
+ if (accordion.getToggled()) {
+ int accordionDepth = 0;
+ if (option.accordionId >= 0) {
+ accordionDepth = activeAccordions.get(option.accordionId) + 1;
+ }
+ activeAccordions.put(accordion.getAccordionId(), accordionDepth);
+ }
+ }
+ int optionHeight = editor.getHeight();
+ if (innerTop + 5 + optionYOverlay + optionHeight > innerTop + 1 &&
+ innerTop + 5 + optionYOverlay < innerBottom - 1) {
+ editor.renderOverlay(
+ (innerLeft + innerRight - optionWidth) / 2 - 5,
+ innerTop + 5 + optionYOverlay,
+ optionWidth
+ );
+ }
+ optionYOverlay += optionHeight + 5;
+ }
+ GlStateManager.disableDepth();
+ GlStateManager.translate(0, 0, -10);
+ }
+ GL11.glEnable(GL11.GL_SCISSOR_TEST);
+
+ float barStart = optionsScroll.getValue() / (float) (optionY + optionsScroll.getValue());
+ float barEnd = barStart + barSize;
+ if (barEnd > 1) {
+ barEnd = 1;
+ if (optionsScroll.getTarget() / (float) (optionY + optionsScroll.getValue()) + barSize < 1) {
+ int target = optionsScroll.getTarget();
+ optionsScroll.setValue((int) Math.ceil(
+ (optionY + 5 + optionsScroll.getValue()) - barSize * (optionY + 5 + optionsScroll.getValue())));
+ optionsScroll.setTarget(target);
+ } else {
+ optionsScroll.setValue((int) Math.ceil(
+ (optionY + 5 + optionsScroll.getValue()) - barSize * (optionY + 5 + optionsScroll.getValue())));
+ }
+ }
+ int dist = innerBottom - innerTop - 12;
+ Gui.drawRect(innerRight - 10, innerTop + 5, innerRight - 5, innerBottom - 5, 0xff101010);
+ Gui.drawRect(
+ innerRight - 9,
+ innerTop + 6 + (int) (dist * barStart),
+ innerRight - 6,
+ innerTop + 6 + (int) (dist * barEnd),
+ 0xff303030
+ );
+
+ for (int socialIndex = 0; socialIndex < socialsIco.length; socialIndex++) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(socialsIco[socialIndex]);
+ GlStateManager.color(1, 1, 1, 1);
+ int socialLeft = x + xSize - 23 - 18 * socialIndex;
+ RenderUtils.drawTexturedRect(socialLeft, y + 7, 16, 16, GL11.GL_LINEAR);
+
+ if (mouseX >= socialLeft && mouseX <= socialLeft + 16 &&
+ mouseY >= y + 6 && mouseY <= y + 23) {
+ tooltipToDisplay = Lists.newArrayList(
+ EnumChatFormatting.YELLOW + "Go to: " + EnumChatFormatting.RESET + socialsLink[socialIndex]);
+ }
+ }
+
+ GlScissorStack.clear();
+
+ if (tooltipToDisplay != null) {
+ TextRenderUtils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, fr);
+ }
+
+ GlStateManager.translate(0, 0, -2);
+ }
+
+ public boolean mouseInput(int mouseX, int mouseY) {
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ int width = scaledResolution.getScaledWidth();
+ int height = scaledResolution.getScaledHeight();
+
+ int xSize = Math.min(width - 100 / scaledResolution.getScaleFactor(), 500);
+ int ySize = Math.min(height - 100 / scaledResolution.getScaleFactor(), 400);
+
+ int x = (scaledResolution.getScaledWidth() - xSize) / 2;
+ int y = (scaledResolution.getScaledHeight() - ySize) / 2;
+
+ int adjScaleFactor = Math.max(2, scaledResolution.getScaleFactor());
+
+ int innerPadding = 20 / adjScaleFactor;
+ int innerTop = y + 49 + innerPadding;
+ int innerBottom = y + ySize - 5 - innerPadding;
+ int innerLeft = x + 149 + innerPadding;
+ int innerRight = x + xSize - 5 - innerPadding;
+
+ if (Mouse.getEventButtonState()) {
+ searchField.setFocus(mouseX >= innerRight - 20 && mouseX <= innerRight - 2 &&
+ mouseY >= innerTop - (20 + innerPadding) / 2 - 9 && mouseY <= innerTop - (20 + innerPadding) / 2 + 9);
+
+ if (minimumSearchSize.getValue() > 1) {
+ int strLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(searchField.getText()) + 10;
+ int len = Math.max(strLen, minimumSearchSize.getValue());
+
+ if (mouseX >= innerRight - 25 - len && mouseX <= innerRight - 25 &&
+ mouseY >= innerTop - (20 + innerPadding) / 2 - 9 && mouseY <= innerTop - (20 + innerPadding) / 2 + 9) {
+ String old = searchField.getText();
+ searchField.mouseClicked(mouseX, mouseY, Mouse.getEventButton());
+
+ if (!searchField.getText().equals(old)) search();
+ }
+ }
+ }
+
+ int dWheel = Mouse.getEventDWheel();
+ if (mouseY > innerTop && mouseY < innerBottom && dWheel != 0) {
+ if (dWheel < 0) {
+ dWheel = -1;
+ }
+ if (dWheel > 0) {
+ dWheel = 1;
+ }
+ if (mouseX < innerLeft) {
+ int newTarget = categoryScroll.getTarget() - dWheel * 30;
+ if (newTarget < 0) {
+ newTarget = 0;
+ }
+
+ float catBarSize = 1;
+ int catY = -newTarget;
+ for (Map.Entry<String, ConfigProcessor.ProcessedCategory> entry : getCurrentConfigEditing().entrySet()) {
+ if (getSelectedCategory() == null) {
+ setSelectedCategory(entry.getKey());
+ }
+
+ catY += 15;
+ if (catY > 0) {
+ catBarSize = LerpUtils.clampZeroOne((float) (innerBottom - innerTop - 2) / (catY + 5 + newTarget));
+ }
+ }
+
+ int barMax = (int) Math.floor((catY + 5 + newTarget) - catBarSize * (catY + 5 + newTarget));
+ if (newTarget > barMax) {
+ newTarget = barMax;
+ }
+ categoryScroll.resetTimer();
+ categoryScroll.setTarget(newTarget);
+ } else {
+ int newTarget = optionsScroll.getTarget() - dWheel * 30;
+ if (newTarget < 0) {
+ newTarget = 0;
+ }
+
+ float barSize = 1;
+ int optionY = -newTarget;
+ if (getSelectedCategory() != null && getCurrentConfigEditing() != null &&
+ getCurrentConfigEditing().containsKey(getSelectedCategory())) {
+ ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory());
+ HashMap<Integer, Integer> activeAccordions = new HashMap<>();
+ for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) {
+ if (option.accordionId >= 0) {
+ if (!activeAccordions.containsKey(option.accordionId)) {
+ continue;
+ }
+ }
+
+ GuiOptionEditor editor = option.editor;
+ if (editor == null) {
+ continue;
+ }
+ if (editor instanceof GuiOptionEditorAccordion) {
+ GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor;
+ if (accordion.getToggled()) {
+ int accordionDepth = 0;
+ if (option.accordionId >= 0) {
+ accordionDepth = activeAccordions.get(option.accordionId) + 1;
+ }
+ activeAccordions.put(accordion.getAccordionId(), accordionDepth);
+ }
+ }
+ optionY += editor.getHeight() + 5;
+
+ if (optionY > 0) {
+ barSize = LerpUtils.clampZeroOne((float) (innerBottom - innerTop - 2) / (optionY + 5 + newTarget));
+ }
+ }
+ }
+
+ int barMax = (int) Math.floor((optionY + 5 + newTarget) - barSize * (optionY + 5 + newTarget));
+ if (newTarget > barMax) {
+ newTarget = barMax;
+ }
+ optionsScroll.setTimeToReachTarget(Math.min(
+ 150,
+ Math.max(10, 5 * Math.abs(newTarget - optionsScroll.getValue()))
+ ));
+ optionsScroll.resetTimer();
+ optionsScroll.setTarget(newTarget);
+ }
+ } else if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0) {
+ if (getCurrentConfigEditing() != null) {
+ int catY = -categoryScroll.getValue();
+ for (Map.Entry<String, ConfigProcessor.ProcessedCategory> entry : getCurrentConfigEditing().entrySet()) {
+ if (getSelectedCategory() == null) {
+ setSelectedCategory(entry.getKey());
+ }
+ if (mouseX >= x + 5 && mouseX <= x + 145 &&
+ mouseY >= y + 70 + catY - 7 && mouseY <= y + 70 + catY + 7) {
+ setSelectedCategory(entry.getKey());
+ return true;
+ }
+ catY += 15;
+ }
+ }
+
+ for (int socialIndex = 0; socialIndex < socialsLink.length; socialIndex++) {
+ int socialLeft = x + xSize - 23 - 18 * socialIndex;
+
+ if (mouseX >= socialLeft && mouseX <= socialLeft + 16 &&
+ mouseY >= y + 6 && mouseY <= y + 23) {
+ try {
+ Desktop.getDesktop().browse(new URI(socialsLink[socialIndex]));
+ } catch (Exception ignored) {
+ }
+ return true;
+ }
+ }
+ }
+
+ int optionY = -optionsScroll.getValue();
+ if (getSelectedCategory() != null && getCurrentConfigEditing() != null &&
+ getCurrentConfigEditing().containsKey(getSelectedCategory())) {
+ int optionWidthDefault = innerRight - innerLeft - 20;
+ ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory());
+ HashMap<Integer, Integer> activeAccordions = new HashMap<>();
+ for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) {
+ int optionWidth = optionWidthDefault;
+ if (option.accordionId >= 0) {
+ if (!activeAccordions.containsKey(option.accordionId)) {
+ continue;
+ }
+ int accordionDepth = activeAccordions.get(option.accordionId);
+ optionWidth = optionWidthDefault - (2 * innerPadding) * (accordionDepth + 1);
+ }
+
+ GuiOptionEditor editor = option.editor;
+ if (editor == null) {
+ continue;
+ }
+ if (editor instanceof GuiOptionEditorAccordion) {
+ GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor;
+ if (accordion.getToggled()) {
+ int accordionDepth = 0;
+ if (option.accordionId >= 0) {
+ accordionDepth = activeAccordions.get(option.accordionId) + 1;
+ }
+ activeAccordions.put(accordion.getAccordionId(), accordionDepth);
+ }
+ }
+ if (editor.mouseInputOverlay(
+ (innerLeft + innerRight - optionWidth) / 2 - 5,
+ innerTop + 5 + optionY,
+ optionWidth,
+ mouseX,
+ mouseY
+ )) {
+ return true;
+ }
+ optionY += editor.getHeight() + 5;
+ }
+ }
+
+ if (mouseX > innerLeft && mouseX < innerRight &&
+ mouseY > innerTop && mouseY < innerBottom) {
+ optionY = -optionsScroll.getValue();
+ if (getSelectedCategory() != null && getCurrentConfigEditing() != null &&
+ getCurrentConfigEditing().containsKey(getSelectedCategory())) {
+ int optionWidthDefault = innerRight - innerLeft - 20;
+ ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory());
+ HashMap<Integer, Integer> activeAccordions = new HashMap<>();
+ for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) {
+ int optionWidth = optionWidthDefault;
+ if (option.accordionId >= 0) {
+ if (!activeAccordions.containsKey(option.accordionId)) {
+ continue;
+ }
+ int accordionDepth = activeAccordions.get(option.accordionId);
+ optionWidth = optionWidthDefault - (2 * innerPadding) * (accordionDepth + 1);
+ }
+
+ GuiOptionEditor editor = option.editor;
+ if (editor == null) {
+ continue;
+ }
+ if (editor instanceof GuiOptionEditorAccordion) {
+ GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor;
+ if (accordion.getToggled()) {
+ int accordionDepth = 0;
+ if (option.accordionId >= 0) {
+ accordionDepth = activeAccordions.get(option.accordionId) + 1;
+ }
+ activeAccordions.put(accordion.getAccordionId(), accordionDepth);
+ }
+ }
+ if (editor.mouseInput(
+ (innerLeft + innerRight - optionWidth) / 2 - 5,
+ innerTop + 5 + optionY,
+ optionWidth,
+ mouseX,
+ mouseY
+ )) {
+ return true;
+ }
+ optionY += editor.getHeight() + 5;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ public boolean keyboardInput() {
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ int width = scaledResolution.getScaledWidth();
+
+ int xSize = Math.min(width - 100 / scaledResolution.getScaleFactor(), 500);
+
+ int adjScaleFactor = Math.max(2, scaledResolution.getScaleFactor());
+
+ int innerPadding = 20 / adjScaleFactor;
+ int innerWidth = xSize - 154 - innerPadding * 2;
+
+ if (Keyboard.getEventKeyState()) {
+ Keyboard.enableRepeatEvents(true);
+ String old = searchField.getText();
+ searchField.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey());
+ searchField.setText(Minecraft.getMinecraft().fontRendererObj.trimStringToWidth(
+ searchField.getText(),
+ innerWidth / 2 - 20
+ ));
+
+ if (!searchField.getText().equals(old)) search();
+ }
+
+ if (getSelectedCategory() != null && getCurrentConfigEditing() != null &&
+ getCurrentConfigEditing().containsKey(getSelectedCategory())) {
+ ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory());
+ HashMap<Integer, Integer> activeAccordions = new HashMap<>();
+ for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) {
+ if (option.accordionId >= 0) {
+ if (!activeAccordions.containsKey(option.accordionId)) {
+ continue;
+ }
+ }
+
+ GuiOptionEditor editor = option.editor;
+ if (editor == null) {
+ continue;
+ }
+ if (editor instanceof GuiOptionEditorAccordion) {
+ GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor;
+ if (accordion.getToggled()) {
+ int accordionDepth = 0;
+ if (option.accordionId >= 0) {
+ accordionDepth = activeAccordions.get(option.accordionId) + 1;
+ }
+ activeAccordions.put(accordion.getAccordionId(), accordionDepth);
+ }
+ }
+ if (editor.keyboardInput()) {
+ return true;
+ }
+ }
+ }
+
+ return true;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/AHGraph.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/AHGraph.java
new file mode 100644
index 00000000..8d3acaf9
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/AHGraph.java
@@ -0,0 +1,83 @@
+package io.github.moulberry.notenoughupdates.options.seperateSections;
+
+import com.google.gson.annotations.Expose;
+import io.github.moulberry.notenoughupdates.core.config.annotations.*;
+import org.lwjgl.input.Keyboard;
+
+public class AHGraph {
+ @Expose
+ @ConfigOption(
+ name = "Enable AH/BZ Price Graph",
+ desc = "Enable or disable the graph. Disabling this will also make it so that no price data is stored."
+ )
+ @ConfigEditorBoolean
+ public boolean graphEnabled = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Keybind",
+ desc = "Key to press to open the graph."
+ )
+ @ConfigEditorKeybind(defaultKey = Keyboard.KEY_P)
+ public int graphKey = Keyboard.KEY_P;
+
+ @Expose
+ @ConfigOption(
+ name = "GUI Style",
+ desc = "Change the style of the graph GUI"
+ )
+ @ConfigEditorDropdown(
+ values = {"Minecraft", "Dark", "PacksHQ Dark", "FSR"}
+ )
+ public int graphStyle = 0;
+
+ @Expose
+ @ConfigOption(
+ name = "Graph Colour",
+ desc = "Set a custom colour for the graph."
+ )
+ @ConfigEditorColour
+ public String graphColor = "0:255:0:255:0";
+
+ @Expose
+ @ConfigOption(
+ name = "Secondary Graph Colour",
+ desc = "Set a custom colour for the second graph line."
+ )
+ @ConfigEditorColour
+ public String graphColor2 = "0:255:255:255:0";
+
+ @Expose
+ @ConfigOption(
+ name = "Default Time",
+ desc = "Change the default time period for the graph."
+ )
+ @ConfigEditorDropdown(
+ values = {"1 Hour", "1 Day", "1 Week", "All Time"}
+ )
+ public int defaultMode = 1;
+
+ @Expose
+ @ConfigOption(
+ name = "Data Retention",
+ desc = "Change the time (in days) that data is kept for.\nLonger retention require more storage."
+ )
+ @ConfigEditorSlider(
+ minValue = 1,
+ maxValue = 30,
+ minStep = 1
+ )
+ public int dataRetention = 7;
+
+ @Expose
+ @ConfigOption(
+ name = "Number of Graph Zones",
+ desc = "Change the number of graph zones.\nHigher numbers will have more detail, but will look way more cramped."
+ )
+ @ConfigEditorSlider(
+ minValue = 50,
+ maxValue = 300,
+ minStep = 1
+ )
+ public int graphZones = 175;
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/AHTweaks.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/AHTweaks.java
index 3e602b08..0d21a96f 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/AHTweaks.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/AHTweaks.java
@@ -4,94 +4,92 @@ import com.google.gson.annotations.Expose;
import io.github.moulberry.notenoughupdates.core.config.annotations.*;
public class AHTweaks {
+ @ConfigOption(
+ name = "Search GUI",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 0)
+ public boolean searchAccordion = false;
- @ConfigOption(
- name = "Search GUI",
- desc = ""
- )
- @ConfigEditorAccordion(id = 0)
- public boolean searchAccordion = false;
+ @Expose
+ @ConfigOption(
+ name = "Enable Search GUI",
+ desc = "Use the advanced search GUI with autocomplete and history instead of the normal sign GUI\n\u00a7eStar Selection Texture: Johnny#4567"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 0)
+ public boolean enableSearchOverlay = true;
- @Expose
- @ConfigOption(
- name = "Enable Search GUI",
- desc = "Use the advanced search GUI with autocomplete and history instead of the normal sign GUI\n\u00a7eStar Selection Texture: Johnny#4567"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 0)
- public boolean enableSearchOverlay = true;
+ @Expose
+ @ConfigOption(
+ name = "Keep Previous Search",
+ desc = "Don't clear the search bar after closing the GUI"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 0)
+ public boolean keepPreviousSearch = false;
- @Expose
- @ConfigOption(
- name = "Keep Previous Search",
- desc = "Don't clear the search bar after closing the GUI"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 0)
- public boolean keepPreviousSearch = false;
+ @Expose
+ @ConfigOption(
+ name = "Past Searches",
+ desc = "Show past searches below the autocomplete box"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 0)
+ public boolean showPastSearches = true;
- @Expose
- @ConfigOption(
- name = "Past Searches",
- desc = "Show past searches below the autocomplete box"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 0)
- public boolean showPastSearches = true;
+ @Expose
+ @ConfigOption(
+ name = "ESC to Full Close",
+ desc = "Make pressing ESCAPE close the search GUI without opening up the AH again\n" +
+ "ENTER can still be used to search"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 0)
+ public boolean escFullClose = true;
- @Expose
- @ConfigOption(
- name = "ESC to Full Close",
- desc = "Make pressing ESCAPE close the search GUI without opening up the AH again\n" +
- "ENTER can still be used to search"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 0)
- public boolean escFullClose = true;
+ @ConfigOption(
+ name = "BIN Warning",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 1)
+ public boolean binWarningAccordion = false;
- @ConfigOption(
- name = "BIN Warning",
- desc = ""
- )
- @ConfigEditorAccordion(id = 1)
- public boolean binWarningAccordion = false;
+ @Expose
+ @ConfigOption(
+ name = "Enable BIN Warning",
+ desc = "Ask for confirmation when BINing an item for below X% of lowestbin"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 1)
+ public boolean enableBINWarning = true;
- @Expose
- @ConfigOption(
- name = "Enable BIN Warning",
- desc = "Ask for confirmation when BINing an item for below X% of lowestbin"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 1)
- public boolean enableBINWarning = true;
+ @Expose
+ @ConfigOption(
+ name = "Warning Threshold",
+ desc = "Threshold for BIN warning\nExample: 10% means warn if sell price is 10% lower than lowestbin"
+ )
+ @ConfigEditorSlider(
+ minValue = 0.0f,
+ maxValue = 100.0f,
+ minStep = 5f
+ )
+ @ConfigAccordionId(id = 1)
+ public float warningThreshold = 10f;
- @Expose
- @ConfigOption(
- name = "Warning Threshold",
- desc = "Threshold for BIN warning\nExample: 10% means warn if sell price is 10% lower than lowestbin"
- )
- @ConfigEditorSlider(
- minValue = 0.0f,
- maxValue = 100.0f,
- minStep = 5f
- )
- @ConfigAccordionId(id = 1)
- public float warningThreshold = 10f;
-
- @ConfigOption(
- name = "Sort Warning",
- desc = ""
- )
- @ConfigEditorAccordion(id = 2)
- public boolean sortWarningAccordion = false;
-
- @Expose
- @ConfigOption(
- name = "Enable Sort Warning",
- desc = "Show the sort mode when the mode is not 'Lowest Price'"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 2)
- public boolean enableSortWarning = true;
+ @ConfigOption(
+ name = "Sort Warning",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 2)
+ public boolean sortWarningAccordion = false;
+ @Expose
+ @ConfigOption(
+ name = "Enable Sort Warning",
+ desc = "Show the sort mode when the mode is not 'Lowest Price'"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 2)
+ public boolean enableSortWarning = true;
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/AccessoryBag.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/AccessoryBag.java
index 57bae5db..9a3d0946 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/AccessoryBag.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/AccessoryBag.java
@@ -5,11 +5,11 @@ import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditor
import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption;
public class AccessoryBag {
- @Expose
- @ConfigOption(
- name = "Enable Accessory Bag Overlay",
- desc = "Show an overlay on the accessory bag screen which gives useful information about your accessories"
- )
- @ConfigEditorBoolean
- public boolean enableOverlay = true;
+ @Expose
+ @ConfigOption(
+ name = "Enable Accessory Bag Overlay",
+ desc = "Show an overlay on the accessory bag screen which gives useful information about your accessories"
+ )
+ @ConfigEditorBoolean
+ public boolean enableOverlay = true;
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ApiKey.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ApiKey.java
index 18786446..0c5e4d2d 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ApiKey.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ApiKey.java
@@ -5,11 +5,11 @@ import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditor
import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption;
public class ApiKey {
- @Expose
- @ConfigOption(
- name = "Api Key",
- desc = "Hypixel api key"
- )
- @ConfigEditorText
- public String apiKey = "";
+ @Expose
+ @ConfigOption(
+ name = "Api Key",
+ desc = "Hypixel api key"
+ )
+ @ConfigEditorText
+ public String apiKey = "";
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Calendar.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Calendar.java
index fea9853a..332f5e8d 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Calendar.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Calendar.java
@@ -6,48 +6,48 @@ import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditor
import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption;
public class Calendar {
- @Expose
- @ConfigOption(
- name = "Event Notifications",
- desc = "Display notifications for skyblock calendar events"
- )
- @ConfigEditorBoolean
- public boolean eventNotifications = true;
+ @Expose
+ @ConfigOption(
+ name = "Event Notifications",
+ desc = "Display notifications for skyblock calendar events"
+ )
+ @ConfigEditorBoolean
+ public boolean eventNotifications = true;
- @Expose
- @ConfigOption(
- name = "Starting Soon Time",
- desc = "Display a notification before events start, time in seconds.\n" +
- "0 = No prior notification"
- )
- @ConfigEditorSlider(
- minValue = 0f,
- maxValue = 600f,
- minStep = 30f
- )
- public int startingSoonTime = 300;
+ @Expose
+ @ConfigOption(
+ name = "Starting Soon Time",
+ desc = "Display a notification before events start, time in seconds.\n" +
+ "0 = No prior notification"
+ )
+ @ConfigEditorSlider(
+ minValue = 0f,
+ maxValue = 600f,
+ minStep = 30f
+ )
+ public int startingSoonTime = 300;
- @Expose
- @ConfigOption(
- name = "Timer In Inventory",
- desc = "Displays the time until the next event at the top of your screen when in inventories"
- )
- @ConfigEditorBoolean
- public boolean showEventTimerInInventory = true;
+ @Expose
+ @ConfigOption(
+ name = "Timer In Inventory",
+ desc = "Displays the time until the next event at the top of your screen when in inventories"
+ )
+ @ConfigEditorBoolean
+ public boolean showEventTimerInInventory = true;
- @Expose
- @ConfigOption(
- name = "Notification Sounds",
- desc = "Play a sound whenever events start"
- )
- @ConfigEditorBoolean
- public boolean eventNotificationSounds = true;
+ @Expose
+ @ConfigOption(
+ name = "Notification Sounds",
+ desc = "Play a sound whenever events start"
+ )
+ @ConfigEditorBoolean
+ public boolean eventNotificationSounds = true;
- @Expose
- @ConfigOption(
- name = "Spooky Night Notification",
- desc = "Send a notification during spooky event when the time reaches 7pm"
- )
- @ConfigEditorBoolean
- public boolean spookyNightNotification = true;
+ @Expose
+ @ConfigOption(
+ name = "Spooky Night Notification",
+ desc = "Send a notification during spooky event when the time reaches 7pm"
+ )
+ @ConfigEditorBoolean
+ public boolean spookyNightNotification = true;
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/CustomArmour.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/CustomArmour.java
new file mode 100644
index 00000000..57a5e1d7
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/CustomArmour.java
@@ -0,0 +1,36 @@
+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.ConfigEditorDropdown;
+import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption;
+
+public class CustomArmour {
+
+ @Expose
+ @ConfigOption(
+ name = "Enable Custom Armour Hud",
+ desc = "Shows an overlay in your inventory showing your 4 extra armour slots"
+ )
+ @ConfigEditorBoolean
+ public boolean enableArmourHud = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Click To Open Wardrobe",
+ desc = "Click on the hud to open /wardrobe"
+ )
+ @ConfigEditorBoolean
+ public boolean sendWardrobeCommand = true;
+
+ @Expose
+ @ConfigOption(
+ name = "GUI Colour",
+ desc = "Change the colour of the GUI"
+ )
+ @ConfigEditorDropdown(
+ values = {"Vanilla", "Grey", "Dark", "Transparent", "FSR"}
+ )
+ public int colourStyle = 0;
+
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/DungeonMapConfig.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/DungeonMapConfig.java
index 367a6eae..b46eafd9 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/DungeonMapConfig.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/DungeonMapConfig.java
@@ -6,137 +6,137 @@ import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditor
import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption;
public class DungeonMapConfig {
- @Expose
- @ConfigOption(
- name = "Border Size",
- desc = "Changes the size of the map border, without changing the size of the contents"
- )
- @ConfigEditorSlider(
- minValue = 0,
- maxValue = 5,
- minStep = 0.25f
- )
- public float dmBorderSize = 1;
-
- @Expose
- @ConfigOption(
- name = "Room Size",
- desc = "Changes the size of rooms. Useful for higher dungeons with larger maps"
- )
- @ConfigEditorSlider(
- minValue = 0,
- maxValue = 5,
- minStep = 0.25f
- )
- public float dmRoomSize = 1;
-
- @Expose
- @ConfigOption(
- name = "Icon Size",
- desc = "Changes the scale of room indicators and player icons"
- )
- @ConfigEditorSlider(
- minValue = 0.5f,
- maxValue = 3f,
- minStep = 0.25f
- )
- public float dmIconScale = 1.0f;
-
- @Expose
- @ConfigOption(
- name = "Border Style",
- desc = "Various custom borders from various talented artists.\nUse 'custom' if your texture pack has a custom border"
- )
- public int dmBorderStyle = 0;
-
- @Expose
- @ConfigOption(
- name = "Show Dungeon Map",
- desc = "Show/hide the NEU dungeon map"
- )
- public boolean dmEnable = true;
-
- @Expose
- @ConfigOption(
- name = "Map Center",
- desc = "Center on rooms, or center on your player"
- )
- public boolean dmCenterPlayer = true;
-
- @Expose
- @ConfigOption(
- name = "Rotate with Player",
- desc = "Rotate the map to face the same direction as your player"
- )
- public boolean dmRotatePlayer = true;
-
- @Expose
- @ConfigOption(
- name = "Orient Checkmarks",
- desc = "Checkmarks will always show vertically, regardless of rotation"
- )
- public boolean dmOrientCheck = true;
-
- @Expose
- @ConfigOption(
- name = "Center Checkmarks",
- desc = "Checkmarks will show closer to the center of rooms"
- )
- public boolean dmCenterCheck = false;
-
- @Expose
- @ConfigOption(
- name = "Player Icon Style",
- desc = "Various player icon styles"
- )
- public int dmPlayerHeads = 0;
-
- @Expose
- @ConfigOption(
- name = "Interpolate Far Players",
- desc = "Will make players far away move smoothly"
- )
- public boolean dmPlayerInterp = true;
-
- @Expose
- @ConfigOption(
- name = "OpenGL Compatibility",
- desc = "Compatiblity options for people with bad computers. ONLY use this if you know what you are doing, otherwise the map will look worse"
- )
- public int dmCompat = 0;
-
- @Expose
- @ConfigOption(
- name = "Background Colour",
- desc = "Colour of the map background. Supports opacity & chroma"
- )
- public String dmBackgroundColour = "00:170:75:75:75";
-
- @Expose
- @ConfigOption(
- name = "Border Colour",
- desc = "Colour of the map border. Supports opacity & chroma. Turn off custom borders to see"
- )
- public String dmBorderColour = "00:0:0:0:0";
-
- @Expose
- @ConfigOption(
- name = "Chroma Border Mode",
- desc = "Applies a hue offset around the map border"
- )
- public boolean dmChromaBorder = false;
-
- @Expose
- @ConfigOption(
- name = "Background Blur Factor",
- desc = "Changes the blur factor behind the map. Set to 0 to disable blur"
- )
- public float dmBackgroundBlur = 0;
-
- @Expose
- @ConfigOption(
- name = "Position",
- desc = "The position of the map"
- )
- public Position dmPosition = new Position(10, 10);
+ @Expose
+ @ConfigOption(
+ name = "Border Size",
+ desc = "Changes the size of the map border, without changing the size of the contents"
+ )
+ @ConfigEditorSlider(
+ minValue = 0,
+ maxValue = 5,
+ minStep = 0.25f
+ )
+ public float dmBorderSize = 1;
+
+ @Expose
+ @ConfigOption(
+ name = "Room Size",
+ desc = "Changes the size of rooms. Useful for higher dungeons with larger maps"
+ )
+ @ConfigEditorSlider(
+ minValue = 0,
+ maxValue = 5,
+ minStep = 0.25f
+ )
+ public float dmRoomSize = 1;
+
+ @Expose
+ @ConfigOption(
+ name = "Icon Size",
+ desc = "Changes the scale of room indicators and player icons"
+ )
+ @ConfigEditorSlider(
+ minValue = 0.5f,
+ maxValue = 3f,
+ minStep = 0.25f
+ )
+ public float dmIconScale = 1.0f;
+
+ @Expose
+ @ConfigOption(
+ name = "Border Style",
+ desc = "Various custom borders from various talented artists.\nUse 'custom' if your texture pack has a custom border"
+ )
+ public int dmBorderStyle = 0;
+
+ @Expose
+ @ConfigOption(
+ name = "Show Dungeon Map",
+ desc = "Show/hide the NEU dungeon map"
+ )
+ public boolean dmEnable = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Map Center",
+ desc = "Center on rooms, or center on your player"
+ )
+ public boolean dmCenterPlayer = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Rotate with Player",
+ desc = "Rotate the map to face the same direction as your player"
+ )
+ public boolean dmRotatePlayer = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Orient Checkmarks",
+ desc = "Checkmarks will always show vertically, regardless of rotation"
+ )
+ public boolean dmOrientCheck = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Center Checkmarks",
+ desc = "Checkmarks will show closer to the center of rooms"
+ )
+ public boolean dmCenterCheck = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Player Icon Style",
+ desc = "Various player icon styles"
+ )
+ public int dmPlayerHeads = 0;
+
+ @Expose
+ @ConfigOption(
+ name = "Interpolate Far Players",
+ desc = "Will make players far away move smoothly"
+ )
+ public boolean dmPlayerInterp = true;
+
+ @Expose
+ @ConfigOption(
+ name = "OpenGL Compatibility",
+ desc = "Compatiblity options for people with bad computers. ONLY use this if you know what you are doing, otherwise the map will look worse"
+ )
+ public int dmCompat = 0;
+
+ @Expose
+ @ConfigOption(
+ name = "Background Colour",
+ desc = "Colour of the map background. Supports opacity & chroma"
+ )
+ public String dmBackgroundColour = "00:170:75:75:75";
+
+ @Expose
+ @ConfigOption(
+ name = "Border Colour",
+ desc = "Colour of the map border. Supports opacity & chroma. Turn off custom borders to see"
+ )
+ public String dmBorderColour = "00:0:0:0:0";
+
+ @Expose
+ @ConfigOption(
+ name = "Chroma Border Mode",
+ desc = "Applies a hue offset around the map border"
+ )
+ public boolean dmChromaBorder = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Background Blur Factor",
+ desc = "Changes the blur factor behind the map. Set to 0 to disable blur"
+ )
+ public float dmBackgroundBlur = 0;
+
+ @Expose
+ @ConfigOption(
+ name = "Position",
+ desc = "The position of the map"
+ )
+ public Position dmPosition = new Position(10, 10);
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Dungeons.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Dungeons.java
index a1b34a6d..ce164c9a 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Dungeons.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Dungeons.java
@@ -2,198 +2,228 @@ package io.github.moulberry.notenoughupdates.options.seperateSections;
import com.google.gson.annotations.Expose;
import io.github.moulberry.notenoughupdates.core.config.annotations.*;
-import org.lwjgl.input.Keyboard;
public class Dungeons {
- @ConfigOption(
- name = "Dungeon Map",
- desc = ""
- )
- @ConfigEditorAccordion(id = 0)
- public boolean dungeonMapAccordion = false;
-
- @Expose
- @ConfigOption(
- name = "Edit Dungeon Map",
- desc = "The NEU dungeon map has it's own editor (/neumap).\n" +
- "Click the button on the left to open it"
- )
- @ConfigEditorButton(
- runnableId = 0,
- buttonText = "Edit"
- )
- @ConfigAccordionId(id = 0)
- public int editDungeonMap = 0;
-
- @Expose
- @ConfigOption(
- name = "Show Own Head As Marker",
- desc = "If you have the \"Head\" icon style selected, don't replace your green marker with a head"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 0)
- public boolean showOwnHeadAsMarker = false;
-
- @ConfigOption(
- name = "Dungeon Profit",
- desc = ""
- )
- @ConfigEditorAccordion(id = 1)
- public boolean dungeonProfitAccordion = false;
-
- @Expose
- @ConfigOption(
- name = "Profit Type",
- desc = "Set the price dataset used for calculating profit"
- )
- @ConfigEditorDropdown(
- values = {"Lowest BIN", "24 AVG Lowest Bin", "Auction AVG"}
- )
- @ConfigAccordionId(id = 1)
- public int profitType = 0;
-
- @Expose
- @ConfigOption(
- name = "Profit Display Location",
- desc = "Set where the profit information is displayed\n" +
- "Overlay = Overlay on right side of inventory\n" +
- "GUI Title = Text displayed next to the inventory title\n" +
- "Lore = Inside the \"Open Reward Chest\" item"
- )
- @ConfigEditorDropdown(
- values = {"Overlay", "GUI Title", "Lore", "Off"}
- )
- @ConfigAccordionId(id = 1)
- public int profitDisplayLoc = 0;
-
-
- @ConfigOption(
- name = "Dungeon Win Overlay",
- desc = ""
- )
- @ConfigEditorAccordion(id = 3)
- public boolean dungeonWinAccordion = false;
-
- @Expose
- @ConfigOption(
- name = "Enable Dungeon Win",
- desc = "Show a fancy win screen and stats when completing a dungeon"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 3)
- public boolean enableDungeonWin = true;
-
- @Expose
- @ConfigOption(
- name = "Dungeon Win Time",
- desc = "Change the amount of time (milliseconds) that the win screen shows for"
- )
- @ConfigEditorSlider(
- minValue = 0,
- maxValue = 20000,
- minStep = 500
- )
- @ConfigAccordionId(id = 3)
- public int dungeonWinMillis = 8000;
-
- @ConfigOption(
- name = "Dungeon Block Overlay",
- desc = ""
- )
- @ConfigEditorAccordion(id = 2)
- public boolean dungeonBlocksAccordion = false;
-
- @Expose
- @ConfigOption(
- name = "Enable Block Overlay",
- desc = "Change the colour of certain blocks / entities while inside dungeons, but keeps the normal texture outside of dungeons"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 2)
- public boolean enableDungBlockOverlay = true;
-
- @Expose
- @ConfigOption(
- name = "Show Overlay Everywhere",
- desc = "Show the dungeon block overlay even when not inside dungeons. Should only be used for testing."
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 2)
- public boolean dungeonBlocksEverywhere = false;
-
- @Expose
- @ConfigOption(
- name = "Slow Update",
- desc = "Updates the colour every second instead of every tick.\n" +
- "\u00A7cWARNING: This will cause all texture animations (eg. flowing water) to update slowly.\n" +
- "This should only be used on low-end machines"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 2)
- public boolean slowDungeonBlocks = false;
-
- @Expose
- @ConfigOption(
- name = "Cracked Bricks",
- desc = "Change the colour of: Cracked Bricks"
- )
- @ConfigEditorColour
- @ConfigAccordionId(id = 2)
- public String dungCrackedColour = "0:255:7:255:217";
-
- @Expose
- @ConfigOption(
- name = "Dispensers",
- desc = "Change the colour of: Dispensers"
- )
- @ConfigEditorColour
- @ConfigAccordionId(id = 2)
- public String dungDispenserColour = "0:255:255:76:0";
-
- @Expose
- @ConfigOption(
- name = "Levers",
- desc = "Change the colour of: Levers"
- )
- @ConfigEditorColour
- @ConfigAccordionId(id = 2)
- public String dungLeverColour = "0:252:24:249:255";
-
- @Expose
- @ConfigOption(
- name = "Tripwire String",
- desc = "Change the colour of: Tripwire String"
- )
- @ConfigEditorColour
- @ConfigAccordionId(id = 2)
- public String dungTripWireColour = "0:255:255:0:0";
-
- @Expose
- @ConfigOption(
- name = "Normal Chests",
- desc = "Change the colour of: Normal Chests"
- )
- @ConfigEditorColour
- @ConfigAccordionId(id = 2)
- public String dungChestColour = "0:255:0:163:36";
-
- @Expose
- @ConfigOption(
- name = "Trapped Chests",
- desc = "Change the colour of: Trapped Chests"
- )
- @ConfigEditorColour
- @ConfigAccordionId(id = 2)
- public String dungTrappedChestColour = "0:255:0:163:36";
-
- @Expose
- @ConfigOption(
- name = "Bats",
- desc = "Change the colour of: Bats"
- )
- @ConfigEditorColour
- @ConfigAccordionId(id = 2)
- public String dungBatColour = "0:255:12:255:0";
-
-
+ @ConfigOption(
+ name = "Dungeon Map",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 0)
+ public boolean dungeonMapAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "\u00A7cWarning",
+ desc = "If you are on Entrance, Floor 1 or Master 1 the map wont work properly"
+ )
+ @ConfigEditorFSR(
+ runnableId = 12,
+ buttonText = ""
+ )
+ @ConfigAccordionId(id = 0)
+ public boolean dungeonF1Warning = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Edit Dungeon Map",
+ desc = "The NEU dungeon map has it's own editor (/neumap).\n" +
+ "Click the button on the left to open it"
+ )
+ @ConfigEditorButton(
+ runnableId = 0,
+ buttonText = "Edit"
+ )
+ @ConfigAccordionId(id = 0)
+ public int editDungeonMap = 0;
+
+ @Expose
+ @ConfigOption(
+ name = "Show Own Head As Marker",
+ desc = "If you have the \"Head\" icon style selected, don't replace your green marker with a head"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 0)
+ public boolean showOwnHeadAsMarker = false;
+
+ @ConfigOption(
+ name = "Dungeon Profit",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 1)
+ public boolean dungeonProfitAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Profit Type",
+ desc = "Set the price dataset used for calculating profit"
+ )
+ @ConfigEditorDropdown(
+ values = {"Lowest BIN", "24 AVG Lowest Bin", "Auction AVG"}
+ )
+ @ConfigAccordionId(id = 1)
+ public int profitType = 0;
+
+ @Expose
+ @ConfigOption(
+ name = "Profit Display Location",
+ desc = "Set where the profit information is displayed\n" +
+ "Overlay = Overlay on right side of inventory\n" +
+ "GUI Title = Text displayed next to the inventory title\n" +
+ "Lore = Inside the \"Open Reward Chest\" item"
+ )
+ @ConfigEditorDropdown(
+ values = {"Overlay", "GUI Title", "Lore", "Off"}
+ )
+ @ConfigAccordionId(id = 1)
+ public int profitDisplayLoc = 0;
+
+ @Expose
+ @ConfigOption(
+ name = "Include Kismet Feather",
+ desc = "Include Kismet Feathers in the Profit Calculation after rerolling"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 1)
+ public boolean useKismetOnDungeonProfit = true;
+
+ @ConfigOption(
+ name = "Dungeon Win Overlay",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 3)
+ public boolean dungeonWinAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Enable Dungeon Win",
+ desc = "Show a fancy win screen and stats when completing a dungeon"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 3)
+ public boolean enableDungeonWin = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Dungeon Win Time",
+ desc = "Change the amount of time (milliseconds) that the win screen shows for"
+ )
+ @ConfigEditorSlider(
+ minValue = 0,
+ maxValue = 20000,
+ minStep = 500
+ )
+ @ConfigAccordionId(id = 3)
+ public int dungeonWinMillis = 8000;
+
+ @ConfigOption(
+ name = "Dungeon Block Overlay",
+ desc = ""
+ )
+
+ @ConfigEditorAccordion(id = 2)
+ public boolean dungeonBlocksAccordion = false;
+ @ConfigOption(
+ name = "\u00A7cWarning",
+ desc = "You need Fast Render and Antialiasing off for these settings to work\n" +
+ "You can find these in your video settings"
+ )
+ @ConfigEditorFSR(
+ runnableId = 12,
+ buttonText = ""
+ )
+ @ConfigAccordionId(id = 2)
+ public boolean dungeonBlockWarning = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Enable Block Overlay",
+ desc = "Change the colour of certain blocks / entities while inside dungeons, but keeps the normal texture outside of dungeons"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 2)
+ public boolean enableDungBlockOverlay = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Show Overlay Everywhere",
+ desc = "Show the dungeon block overlay even when not inside dungeons. Should only be used for testing."
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 2)
+ public boolean dungeonBlocksEverywhere = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Slow Update",
+ desc = "Updates the colour every second instead of every tick.\n" +
+ "\u00A7cWARNING: This will cause all texture animations (eg. flowing water) to update slowly.\n" +
+ "This should only be used on low-end machines"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 2)
+ public boolean slowDungeonBlocks = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Cracked Bricks",
+ desc = "Change the colour of: Cracked Bricks"
+ )
+ @ConfigEditorColour
+ @ConfigAccordionId(id = 2)
+ public String dungCrackedColour = "0:255:7:255:217";
+
+ @Expose
+ @ConfigOption(
+ name = "Dispensers",
+ desc = "Change the colour of: Dispensers"
+ )
+ @ConfigEditorColour
+ @ConfigAccordionId(id = 2)
+ public String dungDispenserColour = "0:255:255:76:0";
+
+ @Expose
+ @ConfigOption(
+ name = "Levers",
+ desc = "Change the colour of: Levers"
+ )
+ @ConfigEditorColour
+ @ConfigAccordionId(id = 2)
+ public String dungLeverColour = "0:252:24:249:255";
+
+ @Expose
+ @ConfigOption(
+ name = "Tripwire String",
+ desc = "Change the colour of: Tripwire String"
+ )
+ @ConfigEditorColour
+ @ConfigAccordionId(id = 2)
+ public String dungTripWireColour = "0:255:255:0:0";
+
+ @Expose
+ @ConfigOption(
+ name = "Normal Chests",
+ desc = "Change the colour of: Normal Chests"
+ )
+ @ConfigEditorColour
+ @ConfigAccordionId(id = 2)
+ public String dungChestColour = "0:255:0:163:36";
+
+ @Expose
+ @ConfigOption(
+ name = "Trapped Chests",
+ desc = "Change the colour of: Trapped Chests"
+ )
+ @ConfigEditorColour
+ @ConfigAccordionId(id = 2)
+ public String dungTrappedChestColour = "0:255:0:163:36";
+
+ @Expose
+ @ConfigOption(
+ name = "Bats",
+ desc = "Change the colour of: Bats"
+ )
+ @ConfigEditorColour
+ @ConfigAccordionId(id = 2)
+ public String dungBatColour = "0:255:12:255:0";
+
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Enchanting.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Enchanting.java
index 9c4156f0..e9add7b4 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Enchanting.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Enchanting.java
@@ -4,169 +4,189 @@ import com.google.gson.annotations.Expose;
import io.github.moulberry.notenoughupdates.core.config.annotations.*;
public class Enchanting {
- @ConfigOption(
- name = "Enchant Table GUI",
- desc = ""
- )
- @ConfigEditorAccordion(id = 1)
- public boolean tableGUIAccordion = false;
-
- @Expose
- @ConfigOption(
- name = "Enable Enchant Table GUI",
- desc = "Show a custom GUI when using the Enchant Table"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 1)
- public boolean enableTableGUI = true;
-
- @Expose
- @ConfigOption(
- name = "Incompatible Enchants",
- desc = "How to display enchants that are incompatible with your current item, eg. Smite on a sword with Sharpness"
- )
- @ConfigEditorDropdown(
- values = {"Highlight", "Hide"}
- )
- @ConfigAccordionId(id = 1)
- public int incompatibleEnchants = 0;
-
- @Expose
- @ConfigOption(
- name = "Enchant Sorting",
- desc = "Change the method of sorting enchants in the GUI"
- )
- @ConfigEditorDropdown(
- values = {"By Cost", "Alphabetical"}
- )
- @ConfigAccordionId(id = 1)
- public int enchantSorting = 0;
-
- @Expose
- @ConfigOption(
- name = "Enchant Ordering",
- desc = "Change the method of ordering used by the sort"
- )
- @ConfigEditorDropdown(
- values = {"Ascending", "Descending"}
- )
- @ConfigAccordionId(id = 1)
- public int enchantOrdering = 0;
-
-
- @ConfigOption(
- name = "Enchanting Solvers",
- desc = ""
- )
- @ConfigEditorAccordion(id = 0)
- public boolean enchantingSolversAccordion = false;
-
-
- @Expose
- @ConfigOption(
- name = "Enable Solvers",
- desc = "Turn on solvers for the experimentation table"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 0)
- public boolean enableEnchantingSolvers = true;
-
- /*@Expose
- @ConfigOption(
- name = "Prevent Misclicks",
- desc = "Prevent accidentally failing the Chronomatron and Ultrasequencer experiments"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 0)
- public boolean preventMisclicks = true;*/
-
- @Expose
- @ConfigOption(
- name = "Hide Tooltips",
- desc = "Hide the tooltip of items in the Chronomatron and Ultrasequencer experiments"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 0)
- public boolean hideTooltips = true;
-
- @Expose
- @ConfigOption(
- name = "Ultrasequencer Numbers",
- desc = "Replace the items in the supersequencer with only numbers"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 0)
- public boolean seqNumbers = false;
-
- @Expose
- @ConfigOption(
- name = "Ultrasequencer Next",
- desc = "Set the colour of the glass pane shown behind the element in the ultrasequencer which is next"
- )
- @ConfigEditorDropdown(
- values = {"None", "White", "Orange", "Light Purple", "Light Blue", "Yellow", "Light Green", "Pink",
- "Gray", "Light Gray", "Cyan", "Dark Purple", "Dark Blue", "Brown", "Dark Green", "Red", "Black"}
- )
- @ConfigAccordionId(id = 0)
- public int seqNext = 6;
-
- @Expose
- @ConfigOption(
- name = "Ultrasequencer Upcoming",
- desc = "Set the colour of the glass pane shown behind the element in the ultrasequencer which is coming after \"next\""
- )
- @ConfigEditorDropdown(
- values = {"None", "White", "Orange", "Light Purple", "Light Blue", "Yellow", "Light Green", "Pink",
- "Gray", "Light Gray", "Cyan", "Dark Purple", "Dark Blue", "Brown", "Dark Green", "Red", "Black"}
- )
- @ConfigAccordionId(id = 0)
- public int seqUpcoming = 5;
-
- @Expose
- @ConfigOption(
- name = "Superpairs Matched",
- desc = "Set the colour of the glass pane shown behind successfully matched pairs"
- )
- @ConfigEditorDropdown(
- values = {"None", "White", "Orange", "Light Purple", "Light Blue", "Yellow", "Light Green", "Pink",
- "Gray", "Light Gray", "Cyan", "Dark Purple", "Dark Blue", "Brown", "Dark Green", "Red", "Black"}
- )
- @ConfigAccordionId(id = 0)
- public int supMatched = 6;
-
- @Expose
- @ConfigOption(
- name = "Superpairs Possible",
- desc = "Set the colour of the glass pane shown behind pairs which can be matched, but have not yet"
- )
- @ConfigEditorDropdown(
- values = {"None", "White", "Orange", "Light Purple", "Light Blue", "Yellow", "Light Green", "Pink",
- "Gray", "Light Gray", "Cyan", "Dark Purple", "Dark Blue", "Brown", "Dark Green", "Red", "Black"}
- )
- @ConfigAccordionId(id = 0)
- public int supPossible = 2;
-
- @Expose
- @ConfigOption(
- name = "Superpairs Unmatched",
- desc = "Set the colour of the glass pane shown behind pairs which have been previously uncovered"
- )
- @ConfigEditorDropdown(
- values = {"None", "White", "Orange", "Light Purple", "Light Blue", "Yellow", "Light Green", "Pink",
- "Gray", "Light Gray", "Cyan", "Dark Purple", "Dark Blue", "Brown", "Dark Green", "Red", "Black"}
- )
- @ConfigAccordionId(id = 0)
- public int supUnmatched = 5;
-
- @Expose
- @ConfigOption(
- name = "Superpairs Powerups",
- desc = "Set the colour of the glass pane shown behind powerups"
- )
- @ConfigEditorDropdown(
- values = {"None", "White", "Orange", "Light Purple", "Light Blue", "Yellow", "Light Green", "Pink",
- "Gray", "Light Gray", "Cyan", "Dark Purple", "Dark Blue", "Brown", "Dark Green", "Red", "Black"}
- )
- @ConfigAccordionId(id = 0)
- public int supPower = 11;
+ @ConfigOption(
+ name = "Enchant Table GUI",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 1)
+ public boolean tableGUIAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Enable Enchant Table GUI",
+ desc = "Show a custom GUI when using the Enchant Table"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 1)
+ public boolean enableTableGUI = true;
+
+ /*@Expose
+ @ConfigOption(
+ name = "Incompatible Enchants",
+ desc = "How to display enchants that are incompatible with your current item, eg. Smite on a sword with Sharpness"
+ )
+ @ConfigEditorDropdown(
+ values = {"Highlight", "Hide"}
+ )
+ @ConfigAccordionId(id = 1)
+ public int incompatibleEnchants = 0;*/
+
+ @Expose
+ @ConfigOption(
+ name = "Enchant Sorting",
+ desc = "Change the method of sorting enchants in the GUI"
+ )
+ @ConfigEditorDropdown(
+ values = {"By Cost", "Alphabetical"}
+ )
+ @ConfigAccordionId(id = 1)
+ public int enchantSorting = 0;
+
+ @Expose
+ @ConfigOption(
+ name = "Enchant Ordering",
+ desc = "Change the method of ordering used by the sort"
+ )
+ @ConfigEditorDropdown(
+ values = {"Ascending", "Descending"}
+ )
+ @ConfigAccordionId(id = 1)
+ public int enchantOrdering = 0;
+
+ @ConfigOption(
+ name = "Enchanting Solvers",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 0)
+ public boolean enchantingSolversAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Enable Solvers",
+ desc = "Turn on solvers for the experimentation table"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 0)
+ public boolean enableEnchantingSolvers = true;
+ //In an email from Donpireso (admin) he says not sending a packet at all isn't bannable
+ //https://cdn.discordapp.com/attachments/823769568933576764/906101631861526559/unknown.png
+ @Expose
+ @ConfigOption(
+ name = "Prevent Misclicks",
+ desc = "Prevent accidentally failing the Chronomatron and Ultrasequencer experiments"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 0)
+ public boolean preventMisclicks1 = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Hide Tooltips",
+ desc = "Hide the tooltip of items in the Chronomatron and Ultrasequencer experiments"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 0)
+ public boolean hideTooltips = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Ultrasequencer Numbers",
+ desc = "Replace the items in the supersequencer with only numbers"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 0)
+ public boolean seqNumbers = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Show Next Click In Chronomatron",
+ desc = "Shows what block you need to click next in Chronomatron"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 0)
+ public boolean showNextClick = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Ultrasequencer Next",
+ desc = "Set the colour of the glass pane shown behind the element in the ultrasequencer which is next"
+ )
+ @ConfigEditorDropdown(
+ values = {
+ "None", "White", "Orange", "Light Purple", "Light Blue", "Yellow", "Light Green", "Pink",
+ "Gray", "Light Gray", "Cyan", "Dark Purple", "Dark Blue", "Brown", "Dark Green", "Red", "Black"
+ }
+ )
+ @ConfigAccordionId(id = 0)
+ public int seqNext = 6;
+
+ @Expose
+ @ConfigOption(
+ name = "Ultrasequencer Upcoming",
+ desc = "Set the colour of the glass pane shown behind the element in the ultrasequencer which is coming after \"next\""
+ )
+ @ConfigEditorDropdown(
+ values = {
+ "None", "White", "Orange", "Light Purple", "Light Blue", "Yellow", "Light Green", "Pink",
+ "Gray", "Light Gray", "Cyan", "Dark Purple", "Dark Blue", "Brown", "Dark Green", "Red", "Black"
+ }
+ )
+ @ConfigAccordionId(id = 0)
+ public int seqUpcoming = 5;
+
+ @Expose
+ @ConfigOption(
+ name = "Superpairs Matched",
+ desc = "Set the colour of the glass pane shown behind successfully matched pairs"
+ )
+ @ConfigEditorDropdown(
+ values = {
+ "None", "White", "Orange", "Light Purple", "Light Blue", "Yellow", "Light Green", "Pink",
+ "Gray", "Light Gray", "Cyan", "Dark Purple", "Dark Blue", "Brown", "Dark Green", "Red", "Black"
+ }
+ )
+ @ConfigAccordionId(id = 0)
+ public int supMatched = 6;
+
+ @Expose
+ @ConfigOption(
+ name = "Superpairs Possible",
+ desc = "Set the colour of the glass pane shown behind pairs which can be matched, but have not yet"
+ )
+ @ConfigEditorDropdown(
+ values = {
+ "None", "White", "Orange", "Light Purple", "Light Blue", "Yellow", "Light Green", "Pink",
+ "Gray", "Light Gray", "Cyan", "Dark Purple", "Dark Blue", "Brown", "Dark Green", "Red", "Black"
+ }
+ )
+ @ConfigAccordionId(id = 0)
+ public int supPossible = 2;
+
+ @Expose
+ @ConfigOption(
+ name = "Superpairs Unmatched",
+ desc = "Set the colour of the glass pane shown behind pairs which have been previously uncovered"
+ )
+ @ConfigEditorDropdown(
+ values = {
+ "None", "White", "Orange", "Light Purple", "Light Blue", "Yellow", "Light Green", "Pink",
+ "Gray", "Light Gray", "Cyan", "Dark Purple", "Dark Blue", "Brown", "Dark Green", "Red", "Black"
+ }
+ )
+ @ConfigAccordionId(id = 0)
+ public int supUnmatched = 5;
+
+ @Expose
+ @ConfigOption(
+ name = "Superpairs Powerups",
+ desc = "Set the colour of the glass pane shown behind powerups"
+ )
+ @ConfigEditorDropdown(
+ values = {
+ "None", "White", "Orange", "Light Purple", "Light Blue", "Yellow", "Light Green", "Pink",
+ "Gray", "Light Gray", "Cyan", "Dark Purple", "Dark Blue", "Brown", "Dark Green", "Red", "Black"
+ }
+ )
+ @ConfigAccordionId(id = 0)
+ public int supPower = 11;
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Fishing.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Fishing.java
index 61fcc559..aa2bacd3 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Fishing.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Fishing.java
@@ -4,204 +4,204 @@ import com.google.gson.annotations.Expose;
import io.github.moulberry.notenoughupdates.core.config.annotations.*;
public class Fishing {
- @Expose
- @ConfigOption(
- name = "Hide Other Players Fishing",
- desc = "Convenience option to easily hide \u00a7lother players'\u00a7r bobbers, rod lines and fishing particles\n" +
- "The advanced options below allow you to set the precise colour, particles, etc."
- )
- @ConfigEditorBoolean
- public boolean hideOtherPlayerAll = false;
-
- @ConfigOption(
- name = "Incoming Fish Warning",
- desc = ""
- )
- @ConfigEditorAccordion(id = 3)
- public boolean incomingFishAccordion = false;
-
- @Expose
- @ConfigOption(
- name = "Fish Warning (R)",
- desc = "Display a red '!' when you need to pull the fish up. The warning takes your ping into account"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 3)
- public boolean incomingFishWarningR = true;
-
- @Expose
- @ConfigOption(
- name = "Fish Warning (Y)",
- desc = "Display a yellow '!' when a fish is approaching your bobber"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 3)
- public boolean incomingFishWarning = true;
-
- @Expose
- @ConfigOption(
- name = "Hooked Sound",
- desc = "Play a high-pitched ding sound when the '!' turns red"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 3)
- public boolean incomingFishHookedSounds = true;
-
- @Expose
- @ConfigOption(
- name = "Approach Sound",
- desc = "Play low-pitched ding sounds while the yellow '!' is visible"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 3)
- public boolean incomingFishIncSounds = false;
-
- @ConfigOption(
- name = "Volumes",
- desc = ""
- )
- @ConfigAccordionId(id = 3)
- @ConfigEditorAccordion(id = 5)
- public boolean incomingFishVolumeAccordion = false;
-
- @Expose
- @ConfigOption(
- name = "Hooked Sound Vol.",
- desc = "Set the volume of the hooked sound"
- )
- @ConfigEditorSlider(
- minValue = 0,
- maxValue = 100,
- minStep = 1
- )
- @ConfigAccordionId(id = 5)
- public float incomingFishHookedSoundsVol = 25;
-
- @Expose
- @ConfigOption(
- name = "Approach Sound Vol.",
- desc = "Set the volume of the approaching sound"
- )
- @ConfigEditorSlider(
- minValue = 0,
- maxValue = 100,
- minStep = 1
- )
- @ConfigAccordionId(id = 5)
- public float incomingFishIncSoundsVol = 10;
-
- @ConfigOption(
- name = "Fishing Particles",
- desc = ""
- )
- @ConfigEditorAccordion(id = 0)
- public boolean particleAccordion = false;
-
- @Expose
- @ConfigOption(
- name = "Enable Custom Particles",
- desc = "Allow you to modify the particles that appear when a fish is incoming for you and other players"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 0)
- public boolean enableCustomParticles = false;
-
- @ConfigOption(
- name = "Your Particles",
- desc = ""
- )
- @ConfigEditorAccordion(id = 1)
- @ConfigAccordionId(id = 0)
- public boolean yourParticlesAccordion = false;
-
- @Expose
- @ConfigOption(
- name = "Particle Type",
- desc = "Change the type of the particle that is spawned\n" +
- "Particle types with (RGB) support custom colours\n" +
- "Set to 'NONE' to disable particles"
- )
- @ConfigEditorDropdown(
- values = {"Default", "None", "Spark (RGB)", "Swirl (RGB)", "Dust (RGB)", "Flame", "Crit", "Magic Crit"}
- )
- @ConfigAccordionId(id = 1)
- public int yourParticleType = 0;
-
- @Expose
- @ConfigOption(
- name = "Custom Colour",
- desc = "Set a custom colour for the particle\n" +
- "Only works for particle types with (RGB)"
- )
- @ConfigEditorColour
- @ConfigAccordionId(id = 1)
- public String yourParticleColour = "0:255:255:255:255";
-
- @ConfigOption(
- name = "Other Players' Particles",
- desc = ""
- )
- @ConfigEditorAccordion(id = 2)
- @ConfigAccordionId(id = 0)
- public boolean otherParticlesAccordion = false;
-
- @Expose
- @ConfigOption(
- name = "Particle Type",
- desc = "Change the type of the particle that is spawned\n" +
- "Particle types with (RGB) support custom colours\n" +
- "Set to 'NONE' to disable particles"
- )
- @ConfigEditorDropdown(
- values = {"Default", "None", "Spark (RGB)", "Swirl (RGB)", "Dust (RGB)", "Flame", "Crit", "Magic Crit"}
- )
- @ConfigAccordionId(id = 2)
- public int otherParticleType = 0;
-
- @Expose
- @ConfigOption(
- name = "Custom Colour",
- desc = "Set a custom colour for the particle\n" +
- "Only works for particle types with (RGB)"
- )
- @ConfigEditorColour
- @ConfigAccordionId(id = 2)
- public String otherParticleColour = "0:255:255:255:255";
-
- @ConfigOption(
- name = "Rod Line Colours",
- desc = ""
- )
- @ConfigEditorAccordion(id = 4)
- public boolean rodAccordion = false;
-
- @Expose
- @ConfigOption(
- name = "Enable Rod Line Colours",
- desc = "Change the colour of your and other players' rod lines\n" +
- "Also fixes the position of the rod line"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 4)
- public boolean enableRodColours = true;
-
- @Expose
- @ConfigOption(
- name = "Own Rod Colour",
- desc = "Change the colour of your own rod lines\n" +
- "You can set the opacity to '0' to HIDE"
- )
- @ConfigEditorColour
- @ConfigAccordionId(id = 4)
- public String ownRodColour = "0:255:0:0:0";
-
- @Expose
- @ConfigOption(
- name = "Other Rod Colour",
- desc = "Change the colour of other players' rod lines\n" +
- "You can set the opacity to '0' to HIDE"
- )
- @ConfigEditorColour
- @ConfigAccordionId(id = 4)
- public String otherRodColour = "0:255:0:0:0";
+ @Expose
+ @ConfigOption(
+ name = "Hide Other Players Fishing",
+ desc = "Convenience option to easily hide \u00a7lother players'\u00a7r bobbers, rod lines and fishing particles\n" +
+ "The advanced options below allow you to set the precise colour, particles, etc."
+ )
+ @ConfigEditorBoolean
+ public boolean hideOtherPlayerAll = false;
+
+ @ConfigOption(
+ name = "Incoming Fish Warning",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 3)
+ public boolean incomingFishAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Enable Fish Warning (R)",
+ desc = "Display a red '!' when you need to pull the fish up. The warning takes your ping into account"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 3)
+ public boolean incomingFishWarningR = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Enable Fish Warning (Y)",
+ desc = "Display a yellow '!' when a fish is approaching your bobber"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 3)
+ public boolean incomingFishWarning = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Enable Hooked Sound",
+ desc = "Play a high-pitched ding sound when the '!' turns red"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 3)
+ public boolean incomingFishHookedSounds = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Enable Approach Sound",
+ desc = "Play low-pitched ding sounds while the yellow '!' is visible"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 3)
+ public boolean incomingFishIncSounds = false;
+
+ @ConfigOption(
+ name = "Volumes",
+ desc = ""
+ )
+ @ConfigAccordionId(id = 3)
+ @ConfigEditorAccordion(id = 5)
+ public boolean incomingFishVolumeAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Hooked Sound Vol.",
+ desc = "Set the volume of the hooked sound"
+ )
+ @ConfigEditorSlider(
+ minValue = 0,
+ maxValue = 100,
+ minStep = 1
+ )
+ @ConfigAccordionId(id = 5)
+ public float incomingFishHookedSoundsVol = 25;
+
+ @Expose
+ @ConfigOption(
+ name = "Approach Sound Vol.",
+ desc = "Set the volume of the approaching sound"
+ )
+ @ConfigEditorSlider(
+ minValue = 0,
+ maxValue = 100,
+ minStep = 1
+ )
+ @ConfigAccordionId(id = 5)
+ public float incomingFishIncSoundsVol = 10;
+
+ @ConfigOption(
+ name = "Fishing Particles",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 0)
+ public boolean particleAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Enable Custom Particles",
+ desc = "Allow you to modify the particles that appear when a fish is incoming for you and other players"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 0)
+ public boolean enableCustomParticles = false;
+
+ @ConfigOption(
+ name = "Your Particles",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 1)
+ @ConfigAccordionId(id = 0)
+ public boolean yourParticlesAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Particle Type",
+ desc = "Change the type of the particle that is spawned\n" +
+ "Particle types with (RGB) support custom colours\n" +
+ "Set to 'NONE' to disable particles"
+ )
+ @ConfigEditorDropdown(
+ values = {"Default", "None", "Spark (RGB)", "Swirl (RGB)", "Dust (RGB)", "Flame", "Crit", "Magic Crit"}
+ )
+ @ConfigAccordionId(id = 1)
+ public int yourParticleType = 0;
+
+ @Expose
+ @ConfigOption(
+ name = "Custom Colour",
+ desc = "Set a custom colour for the particle\n" +
+ "Only works for particle types with (RGB)"
+ )
+ @ConfigEditorColour
+ @ConfigAccordionId(id = 1)
+ public String yourParticleColour = "0:255:255:255:255";
+
+ @ConfigOption(
+ name = "Other Players' Particles",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 2)
+ @ConfigAccordionId(id = 0)
+ public boolean otherParticlesAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Particle Type",
+ desc = "Change the type of the particle that is spawned\n" +
+ "Particle types with (RGB) support custom colours\n" +
+ "Set to 'NONE' to disable particles"
+ )
+ @ConfigEditorDropdown(
+ values = {"Default", "None", "Spark (RGB)", "Swirl (RGB)", "Dust (RGB)", "Flame", "Crit", "Magic Crit"}
+ )
+ @ConfigAccordionId(id = 2)
+ public int otherParticleType = 0;
+
+ @Expose
+ @ConfigOption(
+ name = "Custom Colour",
+ desc = "Set a custom colour for the particle\n" +
+ "Only works for particle types with (RGB)"
+ )
+ @ConfigEditorColour
+ @ConfigAccordionId(id = 2)
+ public String otherParticleColour = "0:255:255:255:255";
+
+ @ConfigOption(
+ name = "Rod Line Colours",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 4)
+ public boolean rodAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Enable Rod Line Colours",
+ desc = "Change the colour of your and other players' rod lines\n" +
+ "Also fixes the position of the rod line"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 4)
+ public boolean enableRodColours = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Own Rod Colour",
+ desc = "Change the colour of your own rod lines\n" +
+ "You can set the opacity to '0' to HIDE"
+ )
+ @ConfigEditorColour
+ @ConfigAccordionId(id = 4)
+ public String ownRodColour = "0:255:0:0:0";
+
+ @Expose
+ @ConfigOption(
+ name = "Other Rod Colour",
+ desc = "Change the colour of other players' rod lines\n" +
+ "You can set the opacity to '0' to HIDE"
+ )
+ @ConfigEditorColour
+ @ConfigAccordionId(id = 4)
+ public String otherRodColour = "0:255:0:0:0";
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ImprovedSBMenu.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ImprovedSBMenu.java
index 6a4cb65c..7d943501 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ImprovedSBMenu.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ImprovedSBMenu.java
@@ -6,41 +6,45 @@ import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditor
import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption;
public class ImprovedSBMenu {
- @Expose
- @ConfigOption(
- name = "Enable Improved SB Menus",
- desc = "Change the way that skyblock menus (eg. /sbmenu) look"
- )
- @ConfigEditorBoolean
- public boolean enableSbMenus = true;
+ @Expose
+ @ConfigOption(
+ name = "Enable Improved SB Menus",
+ desc = "Change the way that skyblock menus (eg. /sbmenu) look"
+ )
+ @ConfigEditorBoolean
+ public boolean enableSbMenus = true;
- @Expose
- @ConfigOption(
- name = "Menu Background Style",
- desc = "Change the style of the background of skyblock menus"
- )
- @ConfigEditorDropdown(
- values = {"Dark 1", "Dark 2", "Transparent", "Light 1", "Light 2", "Light 3",
- "Unused 1", "Unused 2", "Unused 3", "Unused 4"}
- )
- public int backgroundStyle = 0;
+ @Expose
+ @ConfigOption(
+ name = "Menu Background Style",
+ desc = "Change the style of the background of skyblock menus"
+ )
+ @ConfigEditorDropdown(
+ values = {
+ "Dark 1", "Dark 2", "Transparent", "Light 1", "Light 2", "Light 3",
+ "Unused 1", "Unused 2", "Unused 3", "Unused 4"
+ }
+ )
+ public int backgroundStyle = 0;
- @Expose
- @ConfigOption(
- name = "Button Background Style",
- desc = "Change the style of the foreground elements in skyblock menus"
- )
- @ConfigEditorDropdown(
- values = {"Dark 1", "Dark 2", "Transparent", "Light 1", "Light 2", "Light 3",
- "Unused 1", "Unused 2", "Unused 3", "Unused 4"}
- )
- public int buttonStyle = 0;
+ @Expose
+ @ConfigOption(
+ name = "Button Background Style",
+ desc = "Change the style of the foreground elements in skyblock menus"
+ )
+ @ConfigEditorDropdown(
+ values = {
+ "Dark 1", "Dark 2", "Transparent", "Light 1", "Light 2", "Light 3",
+ "Unused 1", "Unused 2", "Unused 3", "Unused 4"
+ }
+ )
+ public int buttonStyle = 0;
- @Expose
- @ConfigOption(
- name = "Hide Empty Tooltips",
- desc = "Hide the tooltips of glass panes with no text"
- )
- @ConfigEditorBoolean
- public boolean hideEmptyPanes = true;
+ @Expose
+ @ConfigOption(
+ name = "Hide Empty Tooltips",
+ desc = "Hide the tooltips of glass panes with no text"
+ )
+ @ConfigEditorBoolean
+ public boolean hideEmptyPanes = true;
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/InventoryButtons.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/InventoryButtons.java
index a4b0616b..9c698b9c 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/InventoryButtons.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/InventoryButtons.java
@@ -7,29 +7,29 @@ import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditor
import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption;
public class InventoryButtons {
- @Expose
- @ConfigOption(
- name = "Open Button Editor",
- desc = "Open button editor GUI (/neubuttons)"
- )
- @ConfigEditorButton(runnableId = 7, buttonText = "Open")
- public boolean openEditorButton = true;
+ @Expose
+ @ConfigOption(
+ name = "Open Button Editor",
+ desc = "Open button editor GUI (/neubuttons)"
+ )
+ @ConfigEditorButton(runnableId = 7, buttonText = "Open")
+ public boolean openEditorButton = true;
- @Expose
- @ConfigOption(
- name = "Always Hide \"Crafting\" Text",
- desc = "Hide crafting text in inventory, even when no button is there"
- )
- @ConfigEditorBoolean
- public boolean hideCrafting = false;
+ @Expose
+ @ConfigOption(
+ name = "Always Hide \"Crafting\" Text",
+ desc = "Hide crafting text in inventory, even when no button is there"
+ )
+ @ConfigEditorBoolean
+ public boolean hideCrafting = false;
- @Expose
- @ConfigOption(
- name = "Button Click Type",
- desc = "Change the click type needed to trigger commands"
- )
- @ConfigEditorDropdown(
- values = {"Mouse Down", "Mouse Up"}
- )
- public int clickType = 0;
+ @Expose
+ @ConfigOption(
+ name = "Button Click Type",
+ desc = "Change the click type needed to trigger commands"
+ )
+ @ConfigEditorDropdown(
+ values = {"Mouse Down", "Mouse Up"}
+ )
+ public int clickType = 0;
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ItemOverlays.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ItemOverlays.java
index 9d0814d5..7d08d038 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ItemOverlays.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ItemOverlays.java
@@ -9,316 +9,348 @@ import java.util.Arrays;
import java.util.List;
public class ItemOverlays {
- @ConfigOption(
- name = "Treecapitator Overlay",
- desc = ""
- )
- @ConfigEditorAccordion(id = 0)
- public boolean treecapAccordion = false;
-
- @Expose
- @ConfigOption(
- name = "Enable Treecap Overlay",
- desc = "Show which blocks will be broken when using a Jungle Axe or Treecapitator"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 0)
- public boolean enableTreecapOverlay = true;
-
- @Expose
- @ConfigOption(
- name = "Show in Item durability",
- desc = "Show the cooldown of the Treecapitator in the item durability"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 0)
- public boolean enableCooldownInItemDurability = true;
-
- @Expose
- @ConfigOption(
- name = "Overlay Colour",
- desc = "Change the colour of the overlay"
- )
- @ConfigEditorColour
- @ConfigAccordionId(id = 0)
- public String treecapOverlayColour = "00:50:64:224:208";
-
- @Expose
- @ConfigOption(
- name = "Enable Monkey Pet Check",
- desc = "Will check using the API to check what pet you're using\nto determine the cooldown based off of if you have a monkey pet."
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 0)
- public boolean enableMonkeyCheck = true;
-
- @ConfigOption(
- name = "Builder's Wand Overlay",
- desc = ""
- )
- @ConfigEditorAccordion(id = 1)
- public boolean wandAccordion = false;
-
- @Expose
- @ConfigOption(
- name = "Enable Wand Overlay",
- desc = "Show which blocks will be placed when using the Builder's Wand"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 1)
- public boolean enableWandOverlay = true;
-
- @Expose
- @ConfigOption(
- name = "Wand Block Count",
- desc = "Shows the total count of a block in your inventory"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 1)
- public boolean wandBlockCount = true;
-
- @Expose
- @ConfigOption(
- name = "Overlay Colour",
- desc = "Change the colour of the ghost block outline"
- )
- @ConfigEditorColour
- @ConfigAccordionId(id = 1)
- public String wandOverlayColour = "00:50:64:224:208";
-
- @ConfigOption(
- name = "Block Zapper Overlay",
- desc = ""
- )
- @ConfigEditorAccordion(id = 6)
- public boolean zapperAccordion = false;
-
- @Expose
- @ConfigOption(
- name = "Enable Zapper Overlay",
- desc = "Show which blocks will be destroyed when using the Block Zapper"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 6)
- public boolean enableZapperOverlay = true;
-
- @Expose
- @ConfigOption(
- name = "Overlay Colour",
- desc = "Change the colour of the ghost block outline"
- )
- @ConfigEditorColour
- @ConfigAccordionId(id = 6)
- public String zapperOverlayColour = "0:102:171:5:0";
-
- @ConfigOption(
- name = "Smooth AOTE/AOTV/Hyp",
- desc = ""
- )
- @ConfigEditorAccordion(id = 2)
- public boolean aoteAccordion = false;
-
- @Expose
- @ConfigOption(
- name = "Enable Smooth AOTE",
- desc = "Teleport smoothly to your destination when using AOTE or AOTV"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 2)
- public boolean enableSmoothAOTE = true;
-
- @Expose
- @ConfigOption(
- name = "Enable Smooth Hyperion",
- desc = "Teleport smoothly to your destination when using Hyperion"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 2)
- public boolean enableSmoothHyperion = true;
-
- @Expose
- @ConfigOption(
- name = "Smooth TP Time",
- desc = "Change the amount of time (milliseconds) taken to teleport"
- )
- @ConfigEditorSlider(
- minValue = 0,
- maxValue = 500,
- minStep = 25
- )
- @ConfigAccordionId(id = 2)
- public int smoothTpMillis = 125;
-
- @Expose
- @ConfigOption(
- name = "Smooth TP Time (Etherwarp)",
- desc = "Teleport smoothly to your destination when using AOTV Etherwarp"
- )
- @ConfigEditorSlider(
- minValue = 0,
- maxValue = 500,
- minStep = 25
- )
- @ConfigAccordionId(id = 2)
- public int smoothTpMillisEtherwarp = 50;
-
- @Expose
- @ConfigOption(
- name = "Disable Hyperion Particles",
- desc = "Remove the explosion effect when using a hyperion"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 2)
- public boolean disableHyperionParticles = true;
-
- @ConfigOption(
- name = "Etherwarp",
- desc = ""
- )
- @ConfigEditorAccordion(id = 7)
- public boolean etherwarpAccordion = false;
-
- @Expose
- @ConfigOption(
- name = "Etherwarp Zoom",
- desc = "Zoom in on targeted blocks with etherwarp, making it easier to adjust at a distance"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 7)
- public boolean etherwarpZoom = true;
-
- @Expose
- @ConfigOption(
- name = "Enable etherwarp helper overlay",
- desc = "Display an overlay which tells you if the etherwarp will fail."
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 7)
- public boolean enableEtherwarpHelperOverlay = true;
-
- @Expose
- @ConfigOption(
- name = "Highlight Colour",
- desc = "Change the colour of the etherwarp target block outline"
- )
- @ConfigEditorColour
- @ConfigAccordionId(id = 7)
- public String etherwarpHighlightColour = "00:70:156:8:96";
-
- @ConfigOption(
- name = "Bonemerang Overlay",
- desc = ""
- )
- @ConfigEditorAccordion(id = 3)
- public boolean bonemerangAccordion = false;
-
- @Expose
- @ConfigOption(
- name = "Enable Bonemerang Overlay",
- desc = "Shows info about the bonemerang while holding it."
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 3)
- public boolean enableBonemerangOverlay = true;
-
- @Expose
- @ConfigOption(
- name = "Highlight Targeted Entities",
- desc = "Highlight entities that will be hit by your bonemerang"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 3)
- public boolean highlightTargeted = true;
-
- @Expose
- @ConfigOption(
- name = "Bonemerang Overlay Position",
- desc = "The position of the Bonemerang overlay."
- )
- @ConfigEditorButton(
- runnableId = 9,
- buttonText = "Edit"
- )
- @ConfigAccordionId(id = 3)
- public Position bonemerangPosition = new Position(-1, -1);
-
- @Expose
- @ConfigOption(
- name = "Bonemerang Overlay Text",
- desc = "\u00a7eDrag text to change the appearance of the overlay\n" +
- "\u00a7rHold a Bonemerang to display the overlay"
- )
- @ConfigEditorDraggableList(
- exampleText = {"\u00a7cBonemerang will break!",
- "\u00a77Targets: \u00a76\u00a7l10"
- }
- )
- @ConfigAccordionId(id = 3)
- public List<Integer> bonemerangOverlayText = new ArrayList<>(Arrays.asList(0, 1));
-
- @Expose
- @ConfigOption(
- name = "Bonemerang Overlay Style",
- desc = "Change the style of the Bonemerang overlay"
- )
- @ConfigEditorDropdown(
- values = {"Background", "No Shadow", "Shadow Only", "Full Shadow"}
- )
- @ConfigAccordionId(id = 3)
- public int bonemerangOverlayStyle = 0;
- @Expose
- @ConfigOption(
- name = "Fast update",
- desc = "Updates the bonemerang overlay faster.\n"+
- "Might cause some lag."
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 3)
- public boolean bonemerangFastUpdate = false;
-
-
-
- @ConfigOption(
- name = "Minion Crystal Radius Overlay",
- desc = ""
- )
- @ConfigEditorAccordion(id = 5)
- public boolean crystalAccordion = false;
-
- @Expose
- @ConfigOption(
- name = "Enable Crystal Overlay",
- desc = "Show a block overlay for the effective radius of minion crystals (farming, mining, etc)."
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 5)
- public boolean enableCrystalOverlay = true;
-
- @Expose
- @ConfigOption(
- name = "Always Show Crystal Overlay",
- desc = "Show the crystal overlay, even when a minion crystal is not being held."
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 5)
- public boolean alwaysShowCrystal = false;
-
-
- @Expose
- @ConfigOption(
- name = "Enable Prismapump Overlay",
- desc = "Show a block overlay for the effected blocks of prismapump's ability."
- )
- @ConfigEditorBoolean
- public boolean enablePrismapumpOverlay = true;
-
-
- @Expose
- @ConfigOption(
- name = "Pickaxe Ability Cooldown",
- desc = "Show the cooldown duration off the pickaxe ability as the durability."
- )
- @ConfigEditorBoolean
- public boolean pickaxeAbility = true;
+ @ConfigOption(
+ name = "Treecapitator Overlay",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 0)
+ public boolean treecapAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Enable Treecap Overlay",
+ desc = "Show which blocks will be broken when using a Jungle Axe or Treecapitator"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 0)
+ public boolean enableTreecapOverlay = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Show in Item durability",
+ desc = "Show the cooldown of the Treecapitator in the item durability"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 0)
+ public boolean enableCooldownInItemDurability = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Overlay Colour",
+ desc = "Change the colour of the overlay"
+ )
+ @ConfigEditorColour
+ @ConfigAccordionId(id = 0)
+ public String treecapOverlayColour = "00:50:64:224:208";
+
+ @Expose
+ @ConfigOption(
+ name = "Enable Monkey Pet Check",
+ desc = "Will check using the API to check what pet you're using\nto determine the cooldown based off of if you have a monkey pet."
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 0)
+ public boolean enableMonkeyCheck = true;
+
+ @ConfigOption(
+ name = "Builder's Wand Overlay",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 1)
+ public boolean wandAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Enable Wand Overlay",
+ desc = "Show which blocks will be placed when using the Builder's Wand"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 1)
+ public boolean enableWandOverlay = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Wand Block Count",
+ desc = "Shows the total count of a block in your inventory"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 1)
+ public boolean wandBlockCount = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Overlay Colour",
+ desc = "Change the colour of the ghost block outline"
+ )
+ @ConfigEditorColour
+ @ConfigAccordionId(id = 1)
+ public String wandOverlayColour = "00:50:64:224:208";
+
+ @ConfigOption(
+ name = "Block Zapper Overlay",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 6)
+ public boolean zapperAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Enable Zapper Overlay",
+ desc = "Show which blocks will be destroyed when using the Block Zapper"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 6)
+ public boolean enableZapperOverlay = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Overlay Colour",
+ desc = "Change the colour of the ghost block outline"
+ )
+ @ConfigEditorColour
+ @ConfigAccordionId(id = 6)
+ public String zapperOverlayColour = "0:102:171:5:0";
+
+ @ConfigOption(
+ name = "Smooth AOTE/AOTV/Hyp",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 2)
+ public boolean aoteAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Enable Smooth AOTE",
+ desc = "Teleport smoothly to your destination when using AOTE or AOTV"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 2)
+ public boolean enableSmoothAOTE = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Enable Smooth Hyperion",
+ desc = "Teleport smoothly to your destination when using Hyperion"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 2)
+ public boolean enableSmoothHyperion = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Smooth TP Time",
+ desc = "Change the amount of time (milliseconds) taken to teleport"
+ )
+ @ConfigEditorSlider(
+ minValue = 0,
+ maxValue = 500,
+ minStep = 25
+ )
+ @ConfigAccordionId(id = 2)
+ public int smoothTpMillis = 125;
+
+ @Expose
+ @ConfigOption(
+ name = "Smooth TP Time (Etherwarp)",
+ desc = "Teleport smoothly to your destination when using AOTV Etherwarp"
+ )
+ @ConfigEditorSlider(
+ minValue = 0,
+ maxValue = 500,
+ minStep = 25
+ )
+ @ConfigAccordionId(id = 2)
+ public int smoothTpMillisEtherwarp = 50;
+
+ @Expose
+ @ConfigOption(
+ name = "Disable Hyperion Particles",
+ desc = "Remove the explosion effect when using a hyperion"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 2)
+ public boolean disableHyperionParticles = true;
+
+ @ConfigOption(
+ name = "Etherwarp",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 7)
+ public boolean etherwarpAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Etherwarp Zoom",
+ desc = "Zoom in on targeted blocks with etherwarp, making it easier to adjust at a distance"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 7)
+ public boolean etherwarpZoom = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Enable etherwarp helper overlay",
+ desc = "Display an overlay which tells you if the etherwarp will fail."
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 7)
+ public boolean enableEtherwarpHelperOverlay = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Enable etherwarp block overlay",
+ desc = "Display an overlay that tells you what block you will TP to."
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 7)
+ public boolean enableEtherwarpBlockOverlay = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Highlight Colour",
+ desc = "Change the colour of the etherwarp target block outline"
+ )
+ @ConfigEditorColour
+ @ConfigAccordionId(id = 7)
+ public String etherwarpHighlightColour = "00:70:156:8:96";
+
+ @ConfigOption(
+ name = "Bonemerang Overlay",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 3)
+ public boolean bonemerangAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Enable Bonemerang Overlay",
+ desc = "Shows info about the bonemerang while holding it."
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 3)
+ public boolean enableBonemerangOverlay = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Highlight Targeted Entities",
+ desc = "Highlight entities that will be hit by your bonemerang"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 3)
+ public boolean highlightTargeted = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Bonemerang Overlay Position",
+ desc = "The position of the Bonemerang overlay."
+ )
+ @ConfigEditorButton(
+ runnableId = 9,
+ buttonText = "Edit"
+ )
+ @ConfigAccordionId(id = 3)
+ public Position bonemerangPosition = new Position(-1, -1);
+
+ @Expose
+ @ConfigOption(
+ name = "Bonemerang Overlay Text",
+ desc = "\u00a7eDrag text to change the appearance of the overlay\n" +
+ "\u00a7rHold a Bonemerang to display the overlay"
+ )
+ @ConfigEditorDraggableList(
+ exampleText = {
+ "\u00a7cBonemerang will break!",
+ "\u00a77Targets: \u00a76\u00a7l10"
+ }
+ )
+ @ConfigAccordionId(id = 3)
+ public List<Integer> bonemerangOverlayText = new ArrayList<>(Arrays.asList(0, 1));
+
+ @Expose
+ @ConfigOption(
+ name = "Bonemerang Overlay Style",
+ desc = "Change the style of the Bonemerang overlay"
+ )
+ @ConfigEditorDropdown(
+ values = {"Background", "No Shadow", "Shadow Only", "Full Shadow"}
+ )
+ @ConfigAccordionId(id = 3)
+ public int bonemerangOverlayStyle = 0;
+ @Expose
+ @ConfigOption(
+ name = "Fast update",
+ desc = "Updates the bonemerang overlay faster.\n" +
+ "Might cause some lag."
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 3)
+ public boolean bonemerangFastUpdate = false;
+
+ @ConfigOption(
+ name = "Minion Crystal Radius Overlay",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 5)
+ public boolean crystalAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Enable Crystal Overlay",
+ desc = "Show a block overlay for the effective radius of minion crystals (farming, mining, etc)."
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 5)
+ public boolean enableCrystalOverlay = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Always Show Crystal Overlay",
+ desc = "Show the crystal overlay, even when a minion crystal is not being held."
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 5)
+ public boolean alwaysShowCrystal = false;
+
+ @ConfigOption(
+ name = "Farming Overlays",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 6)
+ public boolean farmingAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Enable Prismapump Overlay",
+ desc = "Show a block overlay for the effected blocks of prismapump's ability."
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 6)
+ public boolean enablePrismapumpOverlay = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Enable Hoe Of Tilling Overlay",
+ desc = "Show a block overlay for the effected blocks of the hoe of tilling's ability."
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 6)
+ public boolean enableHoeOverlay = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Enable Dirt Wand Overlay",
+ desc = "Show a block overlay for the effected blocks of dirt wand's ability."
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 6)
+ public boolean enableDirtWandOverlay = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Pickaxe Ability Cooldown",
+ desc = "Show the cooldown duration off the pickaxe ability as the durability."
+ )
+ @ConfigEditorBoolean
+ public boolean pickaxeAbility = true;
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Itemlist.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Itemlist.java
index db078353..e1c11f99 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Itemlist.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Itemlist.java
@@ -4,107 +4,107 @@ import com.google.gson.annotations.Expose;
import io.github.moulberry.notenoughupdates.core.config.annotations.*;
public class Itemlist {
- @Expose
- @ConfigOption(
- name = "Show Vanilla Items",
- desc = "Vanilla items are included in the item list"
- )
- @ConfigEditorBoolean
- public boolean showVanillaItems = true;
+ @Expose
+ @ConfigOption(
+ name = "Show Vanilla Items",
+ desc = "Vanilla items are included in the item list"
+ )
+ @ConfigEditorBoolean
+ public boolean showVanillaItems = true;
- @Expose
- @ConfigOption(
- name = "Open Itemlist Arrow",
- desc = "Creates an arrow on the right-side to open the item list when hovered"
- )
- @ConfigEditorBoolean
- public boolean tabOpen = true;
+ @Expose
+ @ConfigOption(
+ name = "Open Itemlist Arrow",
+ desc = "Creates an arrow on the right-side to open the item list when hovered"
+ )
+ @ConfigEditorBoolean
+ public boolean tabOpen = true;
- @Expose
- @ConfigOption(
- name = "Keep Open",
- desc = "Keeps the Itemlist open after the inventory is closed"
- )
- @ConfigEditorBoolean
- public boolean keepopen = false;
+ @Expose
+ @ConfigOption(
+ name = "Keep Open",
+ desc = "Keeps the Itemlist open after the inventory is closed"
+ )
+ @ConfigEditorBoolean
+ public boolean keepopen = false;
- @Expose
- @ConfigOption(
- name = "Item Style",
- desc = "Sets the style of the background behind items"
- )
- @ConfigEditorDropdown(
- values = {"Round", "Square"}
- )
- public int itemStyle = 0;
+ @Expose
+ @ConfigOption(
+ name = "Item Style",
+ desc = "Sets the style of the background behind items"
+ )
+ @ConfigEditorDropdown(
+ values = {"Round", "Square"}
+ )
+ public int itemStyle = 0;
- @Expose
- @ConfigOption(
- name = "Pane Gui Scale",
- desc = "Change the gui scale of the Itemlist"
- )
- @ConfigEditorDropdown(
- values = {"Default", "Small", "Medium", "Large", "Auto"}
- )
- public int paneGuiScale = 0;
+ @Expose
+ @ConfigOption(
+ name = "Pane Gui Scale",
+ desc = "Change the gui scale of the Itemlist"
+ )
+ @ConfigEditorDropdown(
+ values = {"Default", "Small", "Medium", "Large", "Auto"}
+ )
+ public int paneGuiScale = 0;
- @Expose
- @ConfigOption(
- name = "Background Blur",
- desc = "Change the blur amount behind the Itemlist. 0 = off"
- )
- @ConfigEditorSlider(
- minValue = 0,
- maxValue = 20,
- minStep = 1
- )
- public int bgBlurFactor = 5;
+ @Expose
+ @ConfigOption(
+ name = "Background Blur",
+ desc = "Change the blur amount behind the Itemlist. 0 = off"
+ )
+ @ConfigEditorSlider(
+ minValue = 0,
+ maxValue = 20,
+ minStep = 1
+ )
+ public int bgBlurFactor = 5;
- @Expose
- @ConfigOption(
- name = "Pane Width Multiplier",
- desc = "Change the width of the Itemlist"
- )
- @ConfigEditorSlider(
- minValue = 0.5f,
- maxValue = 1.5f,
- minStep = 0.1f
- )
- public float paneWidthMult = 1.0f;
+ @Expose
+ @ConfigOption(
+ name = "Pane Width Multiplier",
+ desc = "Change the width of the Itemlist"
+ )
+ @ConfigEditorSlider(
+ minValue = 0.5f,
+ maxValue = 1.5f,
+ minStep = 0.1f
+ )
+ public float paneWidthMult = 1.0f;
- @Expose
- @ConfigOption(
- name = "Pane Padding",
- desc = "Change the padding around the Itemlist"
- )
- @ConfigEditorSlider(
- minValue = 0f,
- maxValue = 20f,
- minStep = 1f
- )
- public int panePadding = 10;
+ @Expose
+ @ConfigOption(
+ name = "Pane Padding",
+ desc = "Change the padding around the Itemlist"
+ )
+ @ConfigEditorSlider(
+ minValue = 0f,
+ maxValue = 20f,
+ minStep = 1f
+ )
+ public int panePadding = 10;
- @Expose
- @ConfigOption(
- name = "Foreground Colour",
- desc = "Change the colour of foreground elements in the Itemlist"
- )
- @ConfigEditorColour
- public String foregroundColour = "00:255:100:100:100";
+ @Expose
+ @ConfigOption(
+ name = "Foreground Colour",
+ desc = "Change the colour of foreground elements in the Itemlist"
+ )
+ @ConfigEditorColour
+ public String foregroundColour = "00:255:100:100:100";
- @Expose
- @ConfigOption(
- name = "Favourite Colour",
- desc = "Change the colour of favourited elements in the Itemlist"
- )
- @ConfigEditorColour
- public String favouriteColour = "00:255:200:150:50";
+ @Expose
+ @ConfigOption(
+ name = "Favourite Colour",
+ desc = "Change the colour of favourited elements in the Itemlist"
+ )
+ @ConfigEditorColour
+ public String favouriteColour = "00:255:200:150:50";
- @Expose
- @ConfigOption(
- name = "Pane Background Colour",
- desc = "Change the colour of the Itemlist background"
- )
- @ConfigEditorColour
- public String backgroundColour = "15:6:0:0:255";
+ @Expose
+ @ConfigOption(
+ name = "Pane Background Colour",
+ desc = "Change the colour of the Itemlist background"
+ )
+ @ConfigEditorColour
+ public String backgroundColour = "15:6:0:0:255";
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/LocationEdit.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/LocationEdit.java
new file mode 100644
index 00000000..385a3cc1
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/LocationEdit.java
@@ -0,0 +1,187 @@
+package io.github.moulberry.notenoughupdates.options.seperateSections;
+
+import com.google.gson.annotations.Expose;
+import io.github.moulberry.notenoughupdates.core.config.Position;
+import io.github.moulberry.notenoughupdates.core.config.annotations.*;
+
+public class LocationEdit {
+ @Expose
+ @ConfigOption(
+ name = "Edit Dungeon Map",
+ desc = "The NEU dungeon map has it's own editor (/neumap).\n" +
+ "Click the button on the left to open it"
+ )
+ @ConfigEditorButton(
+ runnableId = 0,
+ buttonText = "Edit"
+ )
+ public int editDungeonMap = 0;
+
+ @Expose
+ @ConfigOption(
+ name = "Edit Pet Info Position",
+ desc = "The position of the pet info overlay."
+ )
+ @ConfigEditorButton(
+ runnableId = 4,
+ buttonText = "Edit"
+ )
+ public Position petInfoPosition = new Position(-1, -1);
+
+ @Expose
+ @ConfigOption(
+ name = "Edit Todo Position",
+ desc = "Change the position of the Todo overlay"
+ )
+ @ConfigEditorButton(
+ runnableId = 5,
+ buttonText = "Edit"
+ )
+ @ConfigAccordionId(id = 0)
+ public Position todoPosition = new Position(100, 0);
+
+ @Expose
+ @ConfigOption(
+ name = "Edit Bonemerang Overlay Position",
+ desc = "The position of the Bonemerang overlay."
+ )
+ @ConfigEditorButton(
+ runnableId = 9,
+ buttonText = "Edit"
+ )
+ public Position bonemerangPosition = new Position(-1, -1);
+
+ @Expose
+ @ConfigOption(
+ name = "Edit Slayer Overlay Position",
+ desc = "Change the position of the Slayer overlay"
+ )
+ @ConfigEditorButton(
+ runnableId = 18,
+ buttonText = "Edit"
+ )
+ public Position slayerPosition = new Position(10, 200);
+
+ @ConfigOption(
+ name = "Inventory",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 1)
+ public boolean inventoryAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Edit Toolbar Positions",
+ desc = "Edit the position of the QuickCommands / Search Bar"
+ )
+ @ConfigAccordionId(id = 1)
+ @ConfigEditorButton(runnableId = 6, buttonText = "Edit")
+ public boolean positionButton = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Open Button Editor",
+ desc = "Open button editor GUI (/neubuttons)"
+ )
+ @ConfigAccordionId(id = 1)
+ @ConfigEditorButton(runnableId = 7, buttonText = "Open")
+ public boolean openEditorButton = true;
+
+ @ConfigOption(
+ name = "Mining Overlays",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 2)
+ public boolean miningoverlayAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Edit Dwarven Overlay Position",
+ desc = "Change the position of the Dwarven Mines information Overlay (commisions, powder & forge statuses)"
+ )
+ @ConfigEditorButton(
+ runnableId = 1,
+ buttonText = "Edit"
+ )
+ @ConfigAccordionId(id = 2)
+ public Position overlayPosition = new Position(10, 100);
+
+ @Expose
+ @ConfigOption(
+ name = "Edit Crystal Overlay Position",
+ desc = "Change the position of the Crystal Hollows Overlay."
+ )
+ @ConfigEditorButton(
+ runnableId = 10,
+ buttonText = "Edit"
+ )
+ @ConfigAccordionId(id = 2)
+ public Position crystalHollowOverlayPosition = new Position(200, 0);
+
+ @Expose
+ @ConfigOption(
+ name = "Edit Fuel Bar Position",
+ desc = "Set the position of the drill fuel bar"
+ )
+ @ConfigEditorButton(
+ runnableId = 2,
+ buttonText = "Edit"
+ )
+ @ConfigAccordionId(id = 2)
+ public Position drillFuelBarPosition = new Position(0, -100, true, false);
+
+ @ConfigOption(
+ name = "Skill Overlays",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 3)
+ public boolean skilloverlayAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Edit Farming Overlay Position",
+ desc = "Change the position of the Farming overlay"
+ )
+ @ConfigEditorButton(
+ runnableId = 3,
+ buttonText = "Edit"
+ )
+ @ConfigAccordionId(id = 3)
+ public Position farmingPosition = new Position(10, 200);
+
+ @Expose
+ @ConfigOption(
+ name = "Edit Mining Overlay Position",
+ desc = "Change the position of the Mining overlay"
+ )
+ @ConfigEditorButton(
+ runnableId = 11,
+ buttonText = "Edit"
+ )
+ @ConfigAccordionId(id = 3)
+ public Position miningPosition = new Position(10, 200);
+
+ @Expose
+ @ConfigOption(
+ name = "Edit Fishing Overlay Position",
+ desc = "Change the position of the Fishing overlay"
+ )
+ @ConfigEditorButton(
+ runnableId = 14,
+ buttonText = "Edit"
+ )
+ @ConfigAccordionId(id = 3)
+ public Position fishingPosition = new Position(10, 200);
+
+ @Expose
+ @ConfigOption(
+ name = "Edit Combat Overlay Position",
+ desc = "Change the position of the Combat overlay"
+ )
+ @ConfigEditorButton(
+ runnableId = 19,
+ buttonText = "Edit"
+ )
+ @ConfigAccordionId(id = 3)
+ public Position combatPosition = new Position(10, 200);
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java
index 90c4dc8a..6ebd7f42 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java
@@ -9,504 +9,702 @@ import java.util.Arrays;
import java.util.List;
public class Mining {
- @ConfigOption(
- name = "Waypoints",
- desc = ""
- )
- @ConfigEditorAccordion(id = 0)
- public boolean waypointsAccordion = false;
-
- @Expose
- @ConfigOption(
- name = "Mines Waypoints",
- desc = "Show waypoints in the Dwarven mines to the various locations\n" +
- "Use \"Commissions Only\" to only show active commission locations"
- )
- @ConfigEditorDropdown(
- values = {"Hide", "Commissions Only", "Always"},
- initialIndex = 1
- )
- @ConfigAccordionId(id = 0)
- public int locWaypoints = 1;
-
- @Expose
- @ConfigOption(
- name = "Emissary Waypoints",
- desc = "Show waypoints in the Dwarven mines to emissaries\n" +
- "Use \"Commission End\" to only show after finishing commissions"
- )
- @ConfigEditorDropdown(
- values = {"Hide", "Commission End", "Always"},
- initialIndex = 1
- )
- @ConfigAccordionId(id = 0)
- public int emissaryWaypoints = 1;
-
- @ConfigOption(
- name = "Drill Fuel Bar",
- desc = ""
- )
- @ConfigEditorAccordion(id = 1)
- public boolean drillAccordion = false;
-
- @Expose
- @ConfigOption(
- name = "Drill Fuel Bar",
- desc = "Show a fancy drill fuel bar when holding a drill in mining areas"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 1)
- public boolean drillFuelBar = true;
-
- @Expose
- @ConfigOption(
- name = "Fuel Bar Width",
- desc = "Change the width of the drill fuel bar"
- )
- @ConfigEditorSlider(
- minValue = 50,
- maxValue = 400,
- minStep = 10
- )
- @ConfigAccordionId(id = 1)
- public int drillFuelBarWidth = 200;
-
- @Expose
- @ConfigOption(
- name = "Fuel Bar Position",
- desc = "Set the position of the drill fuel bar"
- )
- @ConfigEditorButton(
- runnableId = 2,
- buttonText = "Edit"
- )
- @ConfigAccordionId(id = 1)
- public Position drillFuelBarPosition = new Position(0, -100, true, false);
-
- @ConfigOption(
- name = "Dwarven Overlay",
- desc = ""
- )
- @ConfigEditorAccordion(id = 2)
- public boolean overlayAccordion = false;
-
- @Expose
- @ConfigOption(
- name = "Dwarven Overlay",
- desc = "Show an Overlay with useful information on the screen while in Dwarven Mines"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 2)
- public boolean dwarvenOverlay = true;
-
- @Expose
- @ConfigOption(
- name = "Dwarven Text",
- desc = "\u00a7eDrag text to change the appearance of the Overlay\n" +
- "\u00a7rGo to the Dwarven Mines to show this Overlay with useful information"
- )
- @ConfigEditorDraggableList(
- exampleText = {"\u00a73Goblin Slayer: \u00a7626.5%\n\u00a73Lucky Raffle: \u00a7c0.0%",
- "\u00a73Mithril Powder: \u00a726,243",
- "\u00a73Gemstone Powder: \u00a7d6,243",
- "\u00a73Forge 1) \u00a79Diamonite\u00a77: \u00a7aReady!",
- "\u00a73Pickaxe CD: \u00a7a78s"}
- )
- @ConfigAccordionId(id = 2)
- public List<Integer> dwarvenText2 = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4));
-
- @Expose
- @ConfigOption(
- name = "Overlay Position",
- desc = "Change the position of the Dwarven Mines information Overlay (commisions, powder & forge statuses)"
- )
- @ConfigEditorButton(
- runnableId = 1,
- buttonText = "Edit"
- )
- @ConfigAccordionId(id = 2)
- public Position overlayPosition = new Position(10, 100);
-
- @Expose
- @ConfigOption(
- name = "Overlay Style",
- desc = "Change the style of the Dwarven Mines information Overlay"
- )
- @ConfigEditorDropdown(
- values = {"Background", "No Shadow", "Shadow", "Full Shadow"}
- )
- @ConfigAccordionId(id = 2)
- public int overlayStyle = 0;
-
- @Expose
- @ConfigOption(
- name = "Show Icons",
- desc = "Show Icons representing the part of the overlay."
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 2)
- public boolean dwarvenOverlayIcons = true;
-
- @Expose
- @ConfigOption(
- name = "Forge Display",
- desc = "Change what gets shown in the Forge Display"
- )
- @ConfigEditorDropdown(
- values = {"Only Done", "Only Working", "Everything Except Locked", "Everything"}
- )
- @ConfigAccordionId(id = 2)
- public int forgeDisplay = 1;
-
- @Expose
- @ConfigOption(
- name = "Forge Location",
- desc = "Change when the forge display gets shown"
- )
- @ConfigEditorDropdown(
- values = {"Dwarven Mines+Crystal Hollows", "Everywhere except dungeons", "Everywhere"}
- )
- @ConfigAccordionId(id = 2)
- public int forgeDisplayEnabledLocations = 0;
-
-
- @ConfigOption(
- name = "Metal Detector Solver",
- desc = ""
- )
- @ConfigEditorAccordion(id = 3)
- public boolean metalDetectorSolverAccordion = false;
-
- @Expose
- @ConfigOption(
- name = "Enable Waypoints",
- desc = "Enabled the metal detector solver for Mines of Divan, to use this stand still to calculate possible blocks and then if required stand" +
- " still on another block."
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 3)
- public boolean metalDetectorEnabled = true;
-
- @Expose
- @ConfigOption(
- name = "Show Possible Blocks",
- desc = "Show waypoints on possible locations when NEU isn't sure about what block the treasure is."
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 3)
- public boolean metalDetectorShowPossible = false;
-
- @ConfigOption(
- name = "Crystal Hollows Overlay",
- desc = ""
- )
- @ConfigEditorAccordion(id = 4)
- public boolean crystalHollowOverlayAccordion = false;
-
- @Expose
- @ConfigOption(
- name = "Enable Overlay",
- desc = "Enables the Crystal Hollows Overlay."
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 4)
- public boolean crystalHollowOverlay = true;
-
- @Expose
- @ConfigOption(
- name = "Overlay Position",
- desc = "Change the position of the Crystal Hollows Overlay."
- )
- @ConfigEditorButton(
- runnableId = 10,
- buttonText = "Edit"
- )
- @ConfigAccordionId(id = 4)
- public Position crystalHollowOverlayPosition = new Position(200, 0);
-
- @Expose
- @ConfigOption(
- name = "Options",
- desc = "Drag text to change the appearance of the overlay!\n" +
- "Click add to add extra things!"
- )
- @ConfigEditorDraggableList(
- exampleText = {
- "\u00a73Amber Crystal: \u00a7aPlaced\n" +
- "\u00a73Sapphire Crystal: \u00a7eCollected\n" +
- "\u00a73Jade Crystal: \u00a7eMissing\n" +
- "\u00a73Amethyst Crystal: \u00a7cMissing\n" +
- "\u00a73Topaz Crystal: \u00a7cMissing\n",
- "\u00a73Crystals: \u00a7a4/5",
- "\u00a73Crystals: \u00a7a80%",
- "\u00a73Electron Transmitter: \u00a7aDone\n" +
- "\u00a73Robotron Reflector: \u00a7eIn Storage\n" +
- "\u00a73Superlite Motor: \u00a7eIn Inventory\n" +
- "\u00a73Synthetic Hearth: \u00a7cMissing\n" +
- "\u00a73Control Switch: \u00a7cMissing\n" +
- "\u00a73FTX 3070: \u00a7cMissing",
- "\u00a73Electron Transmitter: \u00a7a3\n" +
- "\u00a73Robotron Reflector: \u00a7e2\n" +
- "\u00a73Superlite Motor: \u00a7e1\n" +
- "\u00a73Synthetic Hearth: \u00a7c0\n" +
- "\u00a73Control Switch: \u00a7c0\n" +
- "\u00a73FTX 3070: \u00a7c0",
- "\u00a73Automaton parts: \u00a7a5/6",
- "\u00a73Automaton parts: \u00a7a83%",
- "\u00a73Scavenged Lapis Sword: \u00a7aDone\n" +
- "\u00a73Scavenged Golden Hammer: \u00a7eIn Storage\n" +
- "\u00a73Scavenged Diamond Axe: \u00a7eIn Inventory\n" +
- "\u00a73Scavenged Emerald Hammer: \u00a7cMissing\n",
- "\u00a73Scavenged Lapis Sword: \u00a7a3\n" +
- "\u00a73Scavenged Golden Hammer: \u00a7e2\n" +
- "\u00a73Scavenged Diamond Axe: \u00a7e1\n" +
- "\u00a73Scavenged Emerald Hammer: \u00a7c0\n",
- "\u00a73Mines of Divan parts: \u00a7a3/4",
- "\u00a73Mines of Divan parts: \u00a7a75%"
- }
- )
- @ConfigAccordionId(id = 4)
- public List<Integer> crystalHollowText = new ArrayList<>(Arrays.asList(0, 3, 7));
-
- @Expose
- @ConfigOption(
- name = "Style",
- desc = "Change the style of the Crystal Hollows Overlay."
- )
- @ConfigEditorDropdown(
- values = {"Background", "No Shadow", "Shadow", "Full Shadow"}
- )
- @ConfigAccordionId(id = 4)
- public int crystalHollowOverlayStyle = 0;
-
-
- @Expose
- @ConfigOption(
- name = "Show Icons",
- desc = "Show icons in the Overlay that represent the part."
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 4)
- public boolean crystalHollowIcons = true;
-
-
- @Expose
- @ConfigOption(
- name = "Hide Done",
- desc = "Don't show parts you've given to the NPC."
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 4)
- public boolean crystalHollowHideDone = false;
-
- @ConfigOption(
- name = "Locations",
- desc = ""
- )
- @ConfigEditorAccordion(id = 5)
- @ConfigAccordionId(id = 4)
- public boolean crystalHollowLocationAccordion = false;
-
- @Expose
- @ConfigOption(
- name = "Show Automaton",
- desc = "Change where to show Automaton parts."
- )
- @ConfigEditorDropdown(
- values = {"Crystal Hollows", "Precursor Remnants", "Lost Precursor City"}
- )
- @ConfigAccordionId(id = 5)
- public int crystalHollowAutomatonLocation = 2;
-
- @Expose
- @ConfigOption(
- name = "Show Divan",
- desc = "Change where to show Mines of Divan parts."
- )
- @ConfigEditorDropdown(
- values = {"Crystal Hollows", "Mithril Deposits", "Mines of Divan"}
- )
- @ConfigAccordionId(id = 5)
- public int crystalHollowDivanLocation = 2;
-
- @Expose
- @ConfigOption(
- name = "Show Crystal",
- desc = "Change where to show Collected Crystals."
- )
- @ConfigEditorDropdown(
- values = {"Crystal Hollows", "When No Other Overlays"}
- )
- @ConfigAccordionId(id = 5)
- public int crystalHollowCrystalLocation = 1;
-
- @ConfigOption(
- name = "Colours",
- desc = ""
- )
- @ConfigEditorAccordion(id = 6)
- @ConfigAccordionId(id = 4)
- public boolean crystalHollowColourAccordion = false;
-
- @Expose
- @ConfigOption(
- name = "Main Color",
- desc = "Change the main color of the overlay."
-
- )
- @ConfigEditorDropdown(
- values = {"Black", "Dark Blue", "Dark Green", "Dark Aqua", "Dark Red", "Dark Purple", "Gold", "Gray", "Dark Gray", "Blue", "Green", "Aqua", "Red", "Light Purple", "Yellow", "White"}
- )
- @ConfigAccordionId(id = 6)
- public int crystalHollowPartColor = 3;
-
- @Expose
- @ConfigOption(
- name = "Done Color",
- desc = "Change the colour when the part is given to the NPC."
-
- )
- @ConfigEditorDropdown(
- values = {"Black", "Dark Blue", "Dark Green", "Dark Aqua", "Dark Red", "Dark Purple", "Gold", "Gray", "Dark Gray", "Blue", "Green", "Aqua", "Red", "Light Purple", "Yellow", "White"}
- )
-
- @ConfigAccordionId(id = 6)
- public int crystalHollowDoneColor = 10;
-
- @Expose
- @ConfigOption(
- name = "In Inventory Color",
- desc = "Change the colour when the part is in the inventory."
- )
- @ConfigEditorDropdown(
- values = {"Black", "Dark Blue", "Dark Green", "Dark Aqua", "Dark Red", "Dark Purple", "Gold", "Gray", "Dark Gray", "Blue", "Green", "Aqua", "Red", "Light Purple", "Yellow", "White"}
- )
- @ConfigAccordionId(id = 6)
- public int crystalHollowInventoryColor = 14;
-
- @Expose
- @ConfigOption(
- name = "In Storage Color",
- desc = "Change the colour when the part is in the storage."
- )
- @ConfigEditorDropdown(
- values = {"Black", "Dark Blue", "Dark Green", "Dark Aqua", "Dark Red", "Dark Purple", "Gold", "Gray", "Dark Gray", "Blue", "Green", "Aqua", "Red", "Light Purple", "Yellow", "White"}
- )
- @ConfigAccordionId(id = 6)
- public int crystalHollowStorageColor = 14;
-
- @Expose
- @ConfigOption(
- name = "Missing Color",
- desc = "Change the colour when the part is missing."
- )
- @ConfigEditorDropdown(
- values = {"Black", "Dark Blue", "Dark Green", "Dark Aqua", "Dark Red", "Dark Purple", "Gold", "Gray", "Dark Gray", "Blue", "Green", "Aqua", "Red", "Light Purple", "Yellow", "White"}
- )
- @ConfigAccordionId(id = 6)
- public int crystalHollowMissingColor = 12;
-
- @Expose
- @ConfigOption(
- name = "Placed Color",
- desc = "Change the colour when the crystal is placed."
- )
- @ConfigEditorDropdown(
- values = {"Black", "Dark Blue", "Dark Green", "Dark Aqua", "Dark Red", "Dark Purple", "Gold", "Gray", "Dark Gray", "Blue", "Green", "Aqua", "Red", "Light Purple", "Yellow", "White"}
- )
- @ConfigAccordionId(id = 6)
- public int crystalHollowPlacedColor = 10;
-
- @Expose
- @ConfigOption(
- name = "Collected Color",
- desc = "Change the colour when the crystal is collected"
- )
- @ConfigEditorDropdown(
- values = {"Black", "Dark Blue", "Dark Green", "Dark Aqua", "Dark Red", "Dark Purple", "Gold", "Gray", "Dark Gray", "Blue", "Green", "Aqua", "Red", "Light Purple", "Yellow", "White"}
- )
- @ConfigAccordionId(id = 6)
- public int crystalHollowCollectedColor = 14;
-
- @Expose
- @ConfigOption(
- name = "All Color",
- desc = "Change the colour when you have 2/3-all of the parts collected in the count overlay."
- )
- @ConfigEditorDropdown(
- values = {"Black", "Dark Blue", "Dark Green", "Dark Aqua", "Dark Red", "Dark Purple", "Gold", "Gray", "Dark Gray", "Blue", "Green", "Aqua", "Red", "Light Purple", "Yellow", "White"}
- )
- @ConfigAccordionId(id = 6)
- public int crystalHollowAllColor = 10;
-
- @Expose
- @ConfigOption(
- name = "1/3 Color",
- desc = "Change the colour when you have 1/3-2/3 of the parts collected in the count overlay."
- )
- @ConfigEditorDropdown(
- values = {"Black", "Dark Blue", "Dark Green", "Dark Aqua", "Dark Red", "Dark Purple", "Gold", "Gray", "Dark Gray", "Blue", "Green", "Aqua", "Red", "Light Purple", "Yellow", "White"}
- )
- @ConfigAccordionId(id = 6)
- public int crystalHollowMiddleColor = 14;
-
- @Expose
- @ConfigOption(
- name = "0 Color",
- desc = "Change the colour when you have 0-1/3 of the parts collected in the count overlay."
- )
- @ConfigEditorDropdown(
- values = {"Black", "Dark Blue", "Dark Green", "Dark Aqua", "Dark Red", "Dark Purple", "Gold", "Gray", "Dark Gray", "Blue", "Green", "Aqua", "Red", "Light Purple", "Yellow", "White"}
- )
- @ConfigAccordionId(id = 6)
- public int crystalHollowNoneColor = 12;
-
- @Expose
- @ConfigOption(
- name = "Puzzler Solver",
- desc = "Show the correct block to mine for the puzzler puzzle in Dwarven Mines"
- )
- @ConfigEditorBoolean
- public boolean puzzlerSolver = true;
-
- @Expose
- @ConfigOption(
- name = "Titanium Alert",
- desc = "Show an alert whenever titanium appears nearby"
- )
- @ConfigEditorBoolean
- public boolean titaniumAlert = true;
-
- @Expose
- @ConfigOption(
- name = "Titanium must touch air",
- desc = "Only show an alert if the Titanium touches air. (kinda sus)"
- )
- @ConfigEditorBoolean
- public boolean titaniumAlertMustBeVisible = false;
-
-
- @Expose
- @ConfigOption(
- name = "Dwarven Mines Textures",
- desc = "Allows texture packs to retexture blocks in the Dwarven Mines. If you don't have a texturepack that does this, you should leave this off"
- )
- @ConfigEditorBoolean
- public boolean dwarvenTextures = false;
-
- /*@Expose
- @ConfigOption(
- name = "Don't Mine Stone",
- desc = "Prevent mining stone blocks in mining areas"
- )
- @ConfigEditorBoolean
- public boolean dontMineStone = true;
-
- @Expose
- @ConfigOption(
- name = "Reveal Mist Creepers",
- desc = "Make the creepers in the Dwarven Mines mist visible"
- )
- @ConfigEditorBoolean
- public boolean revealMistCreepers = true;*/
+ @ConfigOption(
+ name = "Waypoints",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 0)
+ public boolean waypointsAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Mines Waypoints",
+ desc = "Show waypoints in the Dwarven mines to the various locations\n" +
+ "Use \"Commissions Only\" to only show active commission locations"
+ )
+ @ConfigEditorDropdown(
+ values = {"Hide", "Commissions Only", "Always"},
+ initialIndex = 1
+ )
+ @ConfigAccordionId(id = 0)
+ public int locWaypoints = 1;
+
+ @Expose
+ @ConfigOption(
+ name = "Hide waypoints when at Location",
+ desc = "Hides the Commission Waypoints if you are already at the location of the waypoint.\n" +
+ "Only active if Waypoints are set to \"Commissions Only\""
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 0)
+ public boolean hideWaypointIfAtLocation = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Emissary Waypoints",
+ desc = "Show waypoints in the Dwarven mines to emissaries\n" +
+ "Use \"Commission End\" to only show after finishing commissions"
+ )
+ @ConfigEditorDropdown(
+ values = {"Hide", "Commission End", "Always"},
+ initialIndex = 1
+ )
+ @ConfigAccordionId(id = 0)
+ public int emissaryWaypoints = 1;
+
+ @ConfigOption(
+ name = "Drill Fuel Bar",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 1)
+ public boolean drillAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Drill Fuel Bar",
+ desc = "Show a fancy drill fuel bar when holding a drill in mining areas"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 1)
+ public boolean drillFuelBar = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Fuel Bar Width",
+ desc = "Change the width of the drill fuel bar"
+ )
+ @ConfigEditorSlider(
+ minValue = 50,
+ maxValue = 400,
+ minStep = 10
+ )
+ @ConfigAccordionId(id = 1)
+ public int drillFuelBarWidth = 200;
+
+ @Expose
+ @ConfigOption(
+ name = "Edit Fuel Bar Position",
+ desc = "Set the position of the drill fuel bar"
+ )
+ @ConfigEditorButton(
+ runnableId = 2,
+ buttonText = "Edit"
+ )
+ @ConfigAccordionId(id = 1)
+ public Position drillFuelBarPosition = new Position(0, -100, true, false);
+
+ @ConfigOption(
+ name = "Dwarven Overlay",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 2)
+ public boolean overlayAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Enable Dwarven Overlay",
+ desc = "Show an Overlay with useful information on the screen while in Dwarven Mines"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 2)
+ public boolean dwarvenOverlay = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Dwarven Text",
+ desc = "\u00a7eDrag text to change the appearance of the Overlay\n" +
+ "\u00a7rGo to the Dwarven Mines to show this Overlay with useful information"
+ )
+ @ConfigEditorDraggableList(
+ exampleText = {
+ "\u00a73Goblin Slayer: \u00a7626.5%\n\u00a73Lucky Raffle: \u00a7c0.0%",
+ "\u00a73Mithril Powder: \u00a726,243",
+ "\u00a73Gemstone Powder: \u00a7d6,243",
+ "\u00a73Forge 1) \u00a79Diamonite\u00a77: \u00a7aReady!",
+ "\u00a73Pickaxe CD: \u00a7a78s"
+ }
+ )
+ @ConfigAccordionId(id = 2)
+ public List<Integer> dwarvenText2 = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4));
+
+ @Expose
+ @ConfigOption(
+ name = "Edit Dwarven Overlay Position",
+ desc = "Change the position of the Dwarven Mines information Overlay (commisions, powder & forge statuses)"
+ )
+ @ConfigEditorButton(
+ runnableId = 1,
+ buttonText = "Edit"
+ )
+ @ConfigAccordionId(id = 2)
+ public Position overlayPosition = new Position(10, 100);
+
+ @Expose
+ @ConfigOption(
+ name = "Overlay Style",
+ desc = "Change the style of the Dwarven Mines information Overlay"
+ )
+ @ConfigEditorDropdown(
+ values = {"Background", "No Shadow", "Shadow", "Full Shadow"}
+ )
+ @ConfigAccordionId(id = 2)
+ public int overlayStyle = 0;
+
+ @Expose
+ @ConfigOption(
+ name = "Show Icons",
+ desc = "Show Icons representing the part of the overlay."
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 2)
+ public boolean dwarvenOverlayIcons = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Forge Display",
+ desc = "Change what gets shown in the Forge Display"
+ )
+ @ConfigEditorDropdown(
+ values = {"Only Done", "Only Working", "Everything Except Locked", "Everything"}
+ )
+ @ConfigAccordionId(id = 2)
+ public int forgeDisplay = 1;
+
+ @Expose
+ @ConfigOption(
+ name = "Forge Location",
+ desc = "Change when the forge display gets shown"
+ )
+ @ConfigEditorDropdown(
+ values = {"Dwarven Mines+Crystal Hollows", "Everywhere except dungeons", "Everywhere"}
+ )
+ @ConfigAccordionId(id = 2)
+ public int forgeDisplayEnabledLocations = 0;
+
+ @ConfigOption(
+ name = "Metal Detector Solver",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 3)
+ public boolean metalDetectorSolverAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Enable Waypoints",
+ desc =
+ "Enabled the metal detector solver for Mines of Divan, to use this stand still to calculate possible blocks and then if required stand" +
+ " still on another block."
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 3)
+ public boolean metalDetectorEnabled = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Show Possible Blocks",
+ desc = "Show waypoints on possible locations when NEU isn't sure about what block the treasure is."
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 3)
+ public boolean metalDetectorShowPossible = false;
+
+ @ConfigOption(
+ name = "Crystal Hollows Overlay",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 4)
+ public boolean crystalHollowOverlayAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Enable Crystal Overlay",
+ desc = "Enables the Crystal Hollows Overlay."
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 4)
+ public boolean crystalHollowOverlay = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Edit Crystal Overlay Position",
+ desc = "Change the position of the Crystal Hollows Overlay."
+ )
+ @ConfigEditorButton(
+ runnableId = 10,
+ buttonText = "Edit"
+ )
+ @ConfigAccordionId(id = 4)
+ public Position crystalHollowOverlayPosition = new Position(200, 0);
+
+ @Expose
+ @ConfigOption(
+ name = "Options",
+ desc = "Drag text to change the appearance of the overlay!\n" +
+ "Click add to add extra things!"
+ )
+ @ConfigEditorDraggableList(
+ exampleText = {
+ "\u00a73Amber Crystal: \u00a7aPlaced\n" +
+ "\u00a73Sapphire Crystal: \u00a7eCollected\n" +
+ "\u00a73Jade Crystal: \u00a7eMissing\n" +
+ "\u00a73Amethyst Crystal: \u00a7cMissing\n" +
+ "\u00a73Topaz Crystal: \u00a7cMissing\n",
+ "\u00a73Crystals: \u00a7a4/5",
+ "\u00a73Crystals: \u00a7a80%",
+ "\u00a73Electron Transmitter: \u00a7aDone\n" +
+ "\u00a73Robotron Reflector: \u00a7eIn Storage\n" +
+ "\u00a73Superlite Motor: \u00a7eIn Inventory\n" +
+ "\u00a73Synthetic Hearth: \u00a7cMissing\n" +
+ "\u00a73Control Switch: \u00a7cMissing\n" +
+ "\u00a73FTX 3070: \u00a7cMissing",
+ "\u00a73Electron Transmitter: \u00a7a3\n" +
+ "\u00a73Robotron Reflector: \u00a7e2\n" +
+ "\u00a73Superlite Motor: \u00a7e1\n" +
+ "\u00a73Synthetic Hearth: \u00a7c0\n" +
+ "\u00a73Control Switch: \u00a7c0\n" +
+ "\u00a73FTX 3070: \u00a7c0",
+ "\u00a73Automaton parts: \u00a7a5/6",
+ "\u00a73Automaton parts: \u00a7a83%",
+ "\u00a73Scavenged Lapis Sword: \u00a7aDone\n" +
+ "\u00a73Scavenged Golden Hammer: \u00a7eIn Storage\n" +
+ "\u00a73Scavenged Diamond Axe: \u00a7eIn Inventory\n" +
+ "\u00a73Scavenged Emerald Hammer: \u00a7cMissing\n",
+ "\u00a73Scavenged Lapis Sword: \u00a7a3\n" +
+ "\u00a73Scavenged Golden Hammer: \u00a7e2\n" +
+ "\u00a73Scavenged Diamond Axe: \u00a7e1\n" +
+ "\u00a73Scavenged Emerald Hammer: \u00a7c0\n",
+ "\u00a73Mines of Divan parts: \u00a7a3/4",
+ "\u00a73Mines of Divan parts: \u00a7a75%"
+ }
+ )
+ @ConfigAccordionId(id = 4)
+ public List<Integer> crystalHollowText = new ArrayList<>(Arrays.asList(0, 3, 7));
+
+ @Expose
+ @ConfigOption(
+ name = "Style",
+ desc = "Change the style of the Crystal Hollows Overlay."
+ )
+ @ConfigEditorDropdown(
+ values = {"Background", "No Shadow", "Shadow", "Full Shadow"}
+ )
+ @ConfigAccordionId(id = 4)
+ public int crystalHollowOverlayStyle = 0;
+
+ @Expose
+ @ConfigOption(
+ name = "Show Icons",
+ desc = "Show icons in the Overlay that represent the part."
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 4)
+ public boolean crystalHollowIcons = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Hide Done",
+ desc = "Don't show parts you've given to the NPC."
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 4)
+ public boolean crystalHollowHideDone = false;
+
+ @ConfigOption(
+ name = "Locations",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 5)
+ @ConfigAccordionId(id = 4)
+ public boolean crystalHollowLocationAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Show Automaton",
+ desc = "Change where to show Automaton parts."
+ )
+ @ConfigEditorDropdown(
+ values = {"Crystal Hollows", "Precursor Remnants", "Lost Precursor City"}
+ )
+ @ConfigAccordionId(id = 5)
+ public int crystalHollowAutomatonLocation = 2;
+
+ @Expose
+ @ConfigOption(
+ name = "Show Divan",
+ desc = "Change where to show Mines of Divan parts."
+ )
+ @ConfigEditorDropdown(
+ values = {"Crystal Hollows", "Mithril Deposits", "Mines of Divan"}
+ )
+ @ConfigAccordionId(id = 5)
+ public int crystalHollowDivanLocation = 2;
+
+ @Expose
+ @ConfigOption(
+ name = "Show Crystal",
+ desc = "Change where to show Collected Crystals."
+ )
+ @ConfigEditorDropdown(
+ values = {"Crystal Hollows", "When No Other Overlays"}
+ )
+ @ConfigAccordionId(id = 5)
+ public int crystalHollowCrystalLocation = 1;
+
+ @ConfigOption(
+ name = "Colours",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 6)
+ @ConfigAccordionId(id = 4)
+ public boolean crystalHollowColourAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Main Color",
+ desc = "Change the main color of the overlay."
+
+ )
+ @ConfigEditorDropdown(
+ values = {
+ "Black",
+ "Dark Blue",
+ "Dark Green",
+ "Dark Aqua",
+ "Dark Red",
+ "Dark Purple",
+ "Gold",
+ "Gray",
+ "Dark Gray",
+ "Blue",
+ "Green",
+ "Aqua",
+ "Red",
+ "Light Purple",
+ "Yellow",
+ "White"
+ }
+ )
+ @ConfigAccordionId(id = 6)
+ public int crystalHollowPartColor = 3;
+
+ @Expose
+ @ConfigOption(
+ name = "Done Color",
+ desc = "Change the colour when the part is given to the NPC."
+
+ )
+ @ConfigEditorDropdown(
+ values = {
+ "Black",
+ "Dark Blue",
+ "Dark Green",
+ "Dark Aqua",
+ "Dark Red",
+ "Dark Purple",
+ "Gold",
+ "Gray",
+ "Dark Gray",
+ "Blue",
+ "Green",
+ "Aqua",
+ "Red",
+ "Light Purple",
+ "Yellow",
+ "White"
+ }
+ )
+
+ @ConfigAccordionId(id = 6)
+ public int crystalHollowDoneColor = 10;
+
+ @Expose
+ @ConfigOption(
+ name = "In Inventory Color",
+ desc = "Change the colour when the part is in the inventory."
+ )
+ @ConfigEditorDropdown(
+ values = {
+ "Black",
+ "Dark Blue",
+ "Dark Green",
+ "Dark Aqua",
+ "Dark Red",
+ "Dark Purple",
+ "Gold",
+ "Gray",
+ "Dark Gray",
+ "Blue",
+ "Green",
+ "Aqua",
+ "Red",
+ "Light Purple",
+ "Yellow",
+ "White"
+ }
+ )
+ @ConfigAccordionId(id = 6)
+ public int crystalHollowInventoryColor = 14;
+
+ @Expose
+ @ConfigOption(
+ name = "In Storage Color",
+ desc = "Change the colour when the part is in the storage."
+ )
+ @ConfigEditorDropdown(
+ values = {
+ "Black",
+ "Dark Blue",
+ "Dark Green",
+ "Dark Aqua",
+ "Dark Red",
+ "Dark Purple",
+ "Gold",
+ "Gray",
+ "Dark Gray",
+ "Blue",
+ "Green",
+ "Aqua",
+ "Red",
+ "Light Purple",
+ "Yellow",
+ "White"
+ }
+ )
+ @ConfigAccordionId(id = 6)
+ public int crystalHollowStorageColor = 14;
+
+ @Expose
+ @ConfigOption(
+ name = "Missing Color",
+ desc = "Change the colour when the part is missing."
+ )
+ @ConfigEditorDropdown(
+ values = {
+ "Black",
+ "Dark Blue",
+ "Dark Green",
+ "Dark Aqua",
+ "Dark Red",
+ "Dark Purple",
+ "Gold",
+ "Gray",
+ "Dark Gray",
+ "Blue",
+ "Green",
+ "Aqua",
+ "Red",
+ "Light Purple",
+ "Yellow",
+ "White"
+ }
+ )
+ @ConfigAccordionId(id = 6)
+ public int crystalHollowMissingColor = 12;
+
+ @Expose
+ @ConfigOption(
+ name = "Placed Color",
+ desc = "Change the colour when the crystal is placed."
+ )
+ @ConfigEditorDropdown(
+ values = {
+ "Black",
+ "Dark Blue",
+ "Dark Green",
+ "Dark Aqua",
+ "Dark Red",
+ "Dark Purple",
+ "Gold",
+ "Gray",
+ "Dark Gray",
+ "Blue",
+ "Green",
+ "Aqua",
+ "Red",
+ "Light Purple",
+ "Yellow",
+ "White"
+ }
+ )
+ @ConfigAccordionId(id = 6)
+ public int crystalHollowPlacedColor = 10;
+
+ @Expose
+ @ConfigOption(
+ name = "Collected Color",
+ desc = "Change the colour when the crystal is collected"
+ )
+ @ConfigEditorDropdown(
+ values = {
+ "Black",
+ "Dark Blue",
+ "Dark Green",
+ "Dark Aqua",
+ "Dark Red",
+ "Dark Purple",
+ "Gold",
+ "Gray",
+ "Dark Gray",
+ "Blue",
+ "Green",
+ "Aqua",
+ "Red",
+ "Light Purple",
+ "Yellow",
+ "White"
+ }
+ )
+ @ConfigAccordionId(id = 6)
+ public int crystalHollowCollectedColor = 14;
+
+ @Expose
+ @ConfigOption(
+ name = "All Color",
+ desc = "Change the colour when you have 2/3-all of the parts collected in the count overlay."
+ )
+ @ConfigEditorDropdown(
+ values = {
+ "Black",
+ "Dark Blue",
+ "Dark Green",
+ "Dark Aqua",
+ "Dark Red",
+ "Dark Purple",
+ "Gold",
+ "Gray",
+ "Dark Gray",
+ "Blue",
+ "Green",
+ "Aqua",
+ "Red",
+ "Light Purple",
+ "Yellow",
+ "White"
+ }
+ )
+ @ConfigAccordionId(id = 6)
+ public int crystalHollowAllColor = 10;
+
+ @Expose
+ @ConfigOption(
+ name = "1/3 Color",
+ desc = "Change the colour when you have 1/3-2/3 of the parts collected in the count overlay."
+ )
+ @ConfigEditorDropdown(
+ values = {
+ "Black",
+ "Dark Blue",
+ "Dark Green",
+ "Dark Aqua",
+ "Dark Red",
+ "Dark Purple",
+ "Gold",
+ "Gray",
+ "Dark Gray",
+ "Blue",
+ "Green",
+ "Aqua",
+ "Red",
+ "Light Purple",
+ "Yellow",
+ "White"
+ }
+ )
+ @ConfigAccordionId(id = 6)
+ public int crystalHollowMiddleColor = 14;
+
+ @Expose
+ @ConfigOption(
+ name = "0 Color",
+ desc = "Change the colour when you have 0-1/3 of the parts collected in the count overlay."
+ )
+ @ConfigEditorDropdown(
+ values = {
+ "Black",
+ "Dark Blue",
+ "Dark Green",
+ "Dark Aqua",
+ "Dark Red",
+ "Dark Purple",
+ "Gold",
+ "Gray",
+ "Dark Gray",
+ "Blue",
+ "Green",
+ "Aqua",
+ "Red",
+ "Light Purple",
+ "Yellow",
+ "White"
+ }
+ )
+ @ConfigAccordionId(id = 6)
+ public int crystalHollowNoneColor = 12;
+
+ @Expose
+ @ConfigOption(
+ name = "Puzzler Solver",
+ desc = "Show the correct block to mine for the puzzler puzzle in Dwarven Mines"
+ )
+ @ConfigEditorBoolean
+ public boolean puzzlerSolver = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Titanium Alert",
+ desc = "Show an alert whenever titanium appears nearby"
+ )
+ @ConfigEditorBoolean
+ public boolean titaniumAlert = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Titanium must touch air",
+ desc = "Only show an alert if the Titanium touches air. (kinda sus)"
+ )
+ @ConfigEditorBoolean
+ public boolean titaniumAlertMustBeVisible = false;
+
+ @ConfigOption(
+ name = "Custom Textures",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 7)
+ public boolean texturesAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Dwarven Mines Textures",
+ desc = "Allows texture packs to retexture blocks in the Dwarven Mines. If you don't have a texture pack that does this, you should leave this off"
+ )
+ @ConfigAccordionId(id = 7)
+ @ConfigEditorBoolean
+ public boolean dwarvenTextures = false;
+ @Expose
+ @ConfigOption(
+ name = "Crystal Hollows Textures",
+ desc = "Allows texture packs to retexture blocks in the Crystal Hollows. If you don't have a texture pack that does this, you should leave this off"
+ )
+ @ConfigAccordionId(id = 7)
+ @ConfigEditorBoolean
+ public boolean crystalHollowTextures = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Replace Gemstone sounds",
+ desc = "Replace the break sounds of crystals in the Crystal Hollows. Requires a texture pack with this feature"
+ )
+ @ConfigAccordionId(id = 7)
+ @ConfigEditorBoolean
+ public boolean gemstoneSounds = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Replace Mithril sounds",
+ desc = "Replace the break sounds of mithril and titanium in the Dwarven mines. Requires a texture pack with this feature"
+ )
+ @ConfigAccordionId(id = 7)
+ @ConfigEditorBoolean
+ public boolean mithrilSounds = false;
+
}
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 b38e7fd5..01a4576d 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
@@ -4,89 +4,141 @@ import com.google.gson.annotations.Expose;
import io.github.moulberry.notenoughupdates.core.config.annotations.*;
public class Misc {
- @Expose
- @ConfigOption(
- name = "Only Show on Skyblock",
- desc = "The item list and some other GUI elements will only show on skyblock"
- )
- @ConfigEditorBoolean
- public boolean onlyShowOnSkyblock = true;
-
- @Expose
- @ConfigOption(
- name = "Hide Potion Effects",
- desc = "Hide the potion effects inside your inventory while on skyblock"
- )
- @ConfigEditorBoolean
- public boolean hidePotionEffect = true;
-
-
-
- @Expose
- @ConfigOption(
- name = "Streamer Mode",
- desc = "Randomize lobby names in the scoreboard and chat messages to help prevent stream sniping"
- )
- @ConfigEditorBoolean
- public boolean streamerMode = false;
-
- @Expose
- @ConfigOption(
- name = "GUI Click Sounds",
- desc = "Play click sounds in various NEU-related GUIs when pressing buttons"
- )
- @ConfigEditorBoolean
- public boolean guiButtonClicks = true;
-
-
- @Expose
- @ConfigOption(
- name = "Replace Chat Social Options",
- desc = "Replace Hypixel's chat social options with NEU's profile viewer."
- )
- @ConfigEditorBoolean
- public boolean replaceSocialOptions = true;
-
-
-
- @Expose
- @ConfigOption(
- name = "Damage Indicator Style",
- desc = "Change the style of Skyblock damage indicators to be easier to read"
- )
- @ConfigEditorDropdown(
- values = {"Off", "Commas", "Shortened"}
- )
- public int damageIndicatorStyle = 1;
-
- @Expose
- @ConfigOption(
- name = "Edit Enchant Colours",
- desc = "Change the colours of certain skyblock enchants"
- )
- @ConfigEditorButton(runnableId = 8, buttonText = "Open")
- public boolean editEnchantColoursButton = true;
-
- @Expose
- @ConfigOption(
- name = "Chroma Text Speed",
- desc = "Change the speed of chroma text for items names (/neucustomize) and enchant colours (/neuec) with the chroma colour code (&z)"
- )
- @ConfigEditorSlider(
- minValue = 10,
- maxValue = 500,
- minStep = 10
- )
- public int chromaSpeed = 100;
-
- @Expose
- @ConfigOption(
- name = "Disable Skull retexturing",
- desc = "Disables the skull retexturing."
- )
- @ConfigEditorBoolean
- public boolean disableSkullRetexturing = false;
-
-
+ @Expose
+ @ConfigOption(
+ name = "Only Show on Skyblock",
+ desc = "The item list and some other GUI elements will only show on skyblock"
+ )
+ @ConfigEditorBoolean
+ public boolean onlyShowOnSkyblock = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Hide Potion Effects",
+ desc = "Hide the potion effects inside your inventory while on skyblock"
+ )
+ @ConfigEditorBoolean
+ public boolean hidePotionEffect = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Streamer Mode",
+ desc = "Randomize lobby names in the scoreboard and chat messages to help prevent stream sniping"
+ )
+ @ConfigEditorBoolean
+ public boolean streamerMode = false;
+
+ @ConfigOption(
+ name = "Fairy Soul Waypoints",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 0)
+ public boolean fariySoulAccordion = false;
+ @Expose
+ @ConfigOption(
+ name = "Fairy Souls Finder",
+ desc = "Shows waypoints to fairy souls (/neusouls)"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 0)
+ public boolean fariySoul = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Clear Fairy Souls",
+ desc = "Clears waypoints to fairy souls (/neusouls clear)"
+ )
+ @ConfigEditorButton(
+ runnableId = 16,
+ buttonText = "Clear"
+ )
+ @ConfigAccordionId(id = 0)
+ public boolean fariySoulClear = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Unclear Fairy Souls",
+ desc = "Shows all waypoints to fairy souls (/neusouls unclear)"
+ )
+ @ConfigEditorButton(
+ runnableId = 17,
+ buttonText = "Unclear"
+ )
+ @ConfigAccordionId(id = 0)
+ public boolean fariySoulUnclear = false;
+
+ @Expose
+ @ConfigOption(
+ name = "GUI Click Sounds",
+ desc = "Play click sounds in various NEU-related GUIs when pressing buttons"
+ )
+ @ConfigEditorBoolean
+ public boolean guiButtonClicks = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Replace Chat Social Options",
+ desc = "Replace Hypixel's chat social options with NEU's profile viewer or with /ah"
+ )
+ @ConfigEditorDropdown(
+ values = {"Off", "/pv", "/ah"}
+ )
+ public int replaceSocialOptions1 = 1;
+
+ @Expose
+ @ConfigOption(
+ name = "Damage Indicator Style",
+ desc = "Change the style of Skyblock damage indicators to be easier to read\n" +
+ "\u00A7cSome old animations mods break this feature"
+ )
+ @ConfigEditorDropdown(
+ values = {"Off", "Commas", "Shortened"}
+ )
+ public int damageIndicatorStyle = 1;
+
+ @Expose
+ @ConfigOption(
+ name = "Profile Viewer",
+ desc = "Brings up the profile viewer (/pv)\n" +
+ "Shows stats and networth of players"
+ )
+ @ConfigEditorButton(runnableId = 13, buttonText = "Open")
+ public boolean openPV = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Edit Enchant Colours",
+ desc = "Change the colours of certain skyblock enchants (/neuec)"
+ )
+ @ConfigEditorButton(runnableId = 8, buttonText = "Open")
+ public boolean editEnchantColoursButton = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Chroma Text Speed",
+ desc = "Change the speed of chroma text for items names (/neucustomize) and enchant colours (/neuec) with the chroma colour code (&z)"
+ )
+ @ConfigEditorSlider(
+ minValue = 10,
+ maxValue = 500,
+ minStep = 10
+ )
+ public int chromaSpeed = 100;
+
+ @Expose
+ @ConfigOption(
+ name = "Disable Skull retexturing",
+ desc = "Disables the skull retexturing."
+ )
+ @ConfigEditorBoolean
+ public boolean disableSkullRetexturing = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Disable NPC retexturing",
+ desc = "Disables the NPC retexturing."
+ )
+ @ConfigEditorBoolean
+ public boolean disableNPCRetexturing = false;
} \ No newline at end of file
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MiscOverlays.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MiscOverlays.java
index 0209b097..849f5823 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MiscOverlays.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MiscOverlays.java
@@ -1,256 +1,381 @@
-package io.github.moulberry.notenoughupdates.options.seperateSections;
-
-import com.google.gson.annotations.Expose;
-import io.github.moulberry.notenoughupdates.core.config.Position;
-import io.github.moulberry.notenoughupdates.core.config.annotations.*;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-public class MiscOverlays {
- @ConfigOption(
- name = "Todo Overlay",
- desc = ""
- )
- @ConfigEditorAccordion(id = 0)
- public boolean todoAccordion = true;
-
- @Expose
- @ConfigOption(
- name = "Enable Todo Overlay",
- desc = "Show an overlay that reminds you to do important tasks"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 0)
- public boolean todoOverlay2 = false;
-
- @Expose
- @ConfigOption(
- name = "Todo Text",
- desc = "\u00a7eDrag text to change the appearance of the overlay\n" +
- "\u00a7rIf you want to see the time until something is available, click \"Add\" and then the respective timer"
- )
- @ConfigEditorDraggableList(
- exampleText = {
- "\u00a73Cakes: \u00a7e1d21h",
- "\u00a73Cookie Buff: \u00a7e2d23h",
- "\u00a73Godpot: \u00a7e19h",
- "\u00a73Puzzler: \u00a7e13h",
- "\u00a73Fetchur: \u00a7e3h38m",
- "\u00a73Commissions: \u00a7e3h38m",
- "\u00a73Experiments: \u00a7e3h38m"}
- )
- @ConfigAccordionId(id = 0)
- public List<Integer> todoText2 = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4, 5, 6));
-
- @ConfigOption(
- name = "Show Only If Soon",
- desc = ""
- )
- @ConfigAccordionId(id = 0)
- @ConfigEditorAccordion(id = 1)
- public boolean TodoAccordion = false;
-
- @Expose
- @ConfigOption(
- name = "Experimentation Display",
- desc = "Change the way the experimentation timer displays\n" +
- "Only when ready, When very Soon, When soon, When kinda soon or always."
- )
- @ConfigAccordionId(id =1)
- @ConfigEditorDropdown(
- values = {"Only when ready", "When very Soon", "When soon", "When Kinda Soon", "Always"}
- )
- public int experimentationDisplay = 0;
-
-
- @Expose
- @ConfigOption(
- name = "Puzzler Reset Display",
- desc = "Change the way the puzzler reset timer displays\n" +
- "Only when ready, When very Soon, When soon, When kinda soon or always."
- )
- @ConfigAccordionId(id =1)
- @ConfigEditorDropdown(
- values = {"Only when ready", "When very Soon", "When soon", "When Kinda Soon", "Always"}
- )
- public int puzzlerDisplay = 0;
-
- @Expose
- @ConfigOption(
- name = "Fetchur Reset Display",
- desc = "Change the way the fetchur reset timer displays\n" +
- "Only when ready, When very Soon, When soon, When kinda soon or always."
- )
- @ConfigAccordionId(id =1)
- @ConfigEditorDropdown(
- values = {"Only when ready", "When very Soon", "When soon", "When Kinda Soon", "Always"}
- )
- public int fetchurDisplay = 0;
-
- @Expose
- @ConfigOption(
- name = "Commission timer Display",
- desc = "Change the way the Commission timer displays\n" +
- "Only when ready, When very Soon, When soon, When kinda soon or always."
- )
- @ConfigAccordionId(id =1)
- @ConfigEditorDropdown(
- values = {"Only when ready", "When very Soon", "When soon", "When Kinda Soon", "Always"}
- )
- public int commissionDisplay = 0;
-
- @Expose
- @ConfigOption(
- name = "Cake Buff Display",
- desc = "Change the way the cake buff timer displays\n" +
- "Only when ready, When very Soon, When soon, When kinda soon or always."
- )
- @ConfigAccordionId(id =1)
- @ConfigEditorDropdown(
- values = {"Only when ready", "When very Soon", "When soon", "When Kinda Soon", "Always"}
- )
- public int cakesDisplay = 0;
-
- @Expose
- @ConfigOption(
- name = "Cookie Buff Display",
- desc = "Change the way the cookie buff displays\n" +
- "Only when ready, When very Soon, When soon, When kinda soon or always."
- )
- @ConfigAccordionId(id =1)
- @ConfigEditorDropdown(
- values = {"Only when ready", "When very Soon", "When soon", "When Kinda Soon", "Always"}
- )
- public int cookieBuffDisplay = 0;
-
- @Expose
- @ConfigOption(
- name = "God Pot Display",
- desc = "Change the way the god pot displays\n" +
- "Only when ready, When very Soon, When soon, When kinda soon or always."
- )
- @ConfigAccordionId(id =1)
- @ConfigEditorDropdown(
- values = {"Only when ready", "When very Soon", "When soon", "When Kinda Soon", "Always"}
- )
- public int godpotDisplay = 0;
-
- @ConfigOption(
- name = "Colours",
- desc = ""
- )
-
- @ConfigEditorAccordion(id = 2)
- @ConfigAccordionId(id = 0)
- public boolean TodoColourAccordion = false;
-
- @Expose
- @ConfigOption(
- name = "Ready colour",
- desc = "Change the colour of when the timer is ready"
-
- )
- @ConfigEditorDropdown(
- values = {"Black", "Dark Blue", "Dark Green", "Dark Aqua", "Dark Red", "Dark Purple", "Gold", "Gray", "Dark Gray", "Blue", "Green", "Aqua", "Red", "Light Purple", "Yellow", "White"}
- )
- @ConfigAccordionId(id = 2)
- public int readyColour = 10;
-
- @Expose
- @ConfigOption(
- name = "Gone colour",
- desc = "Change the colour of when the timer is gone"
-
- )
- @ConfigEditorDropdown(
- values = {"Black", "Dark Blue", "Dark Green", "Dark Aqua", "Dark Red", "Dark Purple", "Gold", "Gray", "Dark Gray", "Blue", "Green", "Aqua", "Red", "Light Purple", "Yellow", "White"}
- )
- @ConfigAccordionId(id = 2)
- public int goneColour = 12;
-
- @Expose
- @ConfigOption(
- name = "Very soon colour",
- desc = "Change the colour of when the timer is almost ready/gone"
-
- )
- @ConfigEditorDropdown(
- values = {"Black", "Dark Blue", "Dark Green", "Dark Aqua", "Dark Red", "Dark Purple", "Gold", "Gray", "Dark Gray", "Blue", "Green", "Aqua", "Red", "Light Purple", "Yellow", "White"}
- )
- @ConfigAccordionId(id = 2)
- public int verySoonColour = 11;
-
- @Expose
- @ConfigOption(
- name = "Soon Colour",
- desc = "Change the colour of when the timer is soon ready/gone"
-
- )
- @ConfigEditorDropdown(
- values = {"Black", "Dark Blue", "Dark Green", "Dark Aqua", "Dark Red", "Dark Purple", "Gold", "Gray", "Dark Gray", "Blue", "Green", "Aqua", "Red", "Light Purple", "Yellow", "White"}
- )
- @ConfigAccordionId(id = 2)
- public int soonColour = 9;
-
- @Expose
- @ConfigOption(
- name = "Kinda Soon Colour",
- desc = "Change the colour of when the timer is kinda soon ready/gone"
-
- )
- @ConfigEditorDropdown(
- values = {"Black", "Dark Blue", "Dark Green", "Dark Aqua", "Dark Red", "Dark Purple", "Gold", "Gray", "Dark Gray", "Blue", "Green", "Aqua", "Red", "Light Purple", "Yellow", "White"}
- )
- @ConfigAccordionId(id = 2)
- public int kindaSoonColour = 1;
-
-
- @Expose
- @ConfigOption(
- name = "Default Colour",
- desc = "Change the default colour of the timers"
-
- )
-
- @ConfigEditorDropdown(
- values = {"Black", "Dark Blue", "Dark Green", "Dark Aqua", "Dark Red", "Dark Purple", "Gold", "Gray", "Dark Gray", "Blue", "Green", "Aqua", "Red", "Light Purple", "Yellow", "White"}
- )
- @ConfigAccordionId(id = 2)
- public int defaultColour = 15;
-
-
- @Expose
- @ConfigOption(
- name = "Todo Position",
- desc = "Change the position of the Todo overlay"
- )
- @ConfigEditorButton(
- runnableId = 5,
- buttonText = "Edit"
- )
- @ConfigAccordionId(id = 0)
- public Position todoPosition = new Position(100, 0);
-
-
- @Expose
- @ConfigOption(
- name = "Todo Style",
- desc = "Change the style of the todo overlay"
- )
- @ConfigEditorDropdown(
- values = {"Background", "No Shadow", "Shadow", "Full Shadow"}
- )
- @ConfigAccordionId(id = 0)
- public int todoStyle = 0;
-
- @Expose
- @ConfigOption(
- name = "Todo Icons",
- desc = "Add little item icons next to the lines in the todo overlay"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 0)
- public boolean todoIcons = true;
-}
+package io.github.moulberry.notenoughupdates.options.seperateSections;
+
+import com.google.gson.annotations.Expose;
+import io.github.moulberry.notenoughupdates.core.config.Position;
+import io.github.moulberry.notenoughupdates.core.config.annotations.*;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class MiscOverlays {
+ @ConfigOption(
+ name = "Todo Overlay",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 0)
+ public boolean todoAccordion = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Enable Todo Overlay",
+ desc = "Show an overlay that reminds you to do important tasks"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 0)
+ public boolean todoOverlay2 = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Todo Text",
+ desc = "\u00a7eDrag text to change the appearance of the overlay\n" +
+ "\u00a7rIf you want to see the time until something is available, click \"Add\" and then the respective timer"
+ )
+ @ConfigEditorDraggableList(
+ exampleText = {
+ "\u00a73Cakes: \u00a7e1d21h",
+ "\u00a73Cookie Buff: \u00a7e2d23h",
+ "\u00a73Godpot: \u00a7e19h",
+ "\u00a73Puzzler: \u00a7e13h",
+ "\u00a73Fetchur: \u00a7e3h38m",
+ "\u00a73Commissions: \u00a7e3h38m",
+ "\u00a73Experiments: \u00a7e3h38m",
+ "\u00a73Daily Mithril Powder: \u00a7e3h38m",
+ "\u00a73Daily Gemstone Powder: \u00a7e3h38m",
+ }
+ )
+ @ConfigAccordionId(id = 0)
+ public List<Integer> todoText2 = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8));
+
+ @ConfigOption(
+ name = "Show Only If Soon",
+ desc = ""
+ )
+ @ConfigAccordionId(id = 0)
+ @ConfigEditorAccordion(id = 1)
+ public boolean TodoAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Experimentation Display",
+ desc = "Change the way the experimentation timer displays\n" +
+ "Only when ready, When very Soon, When soon, When kinda soon or always."
+ )
+ @ConfigAccordionId(id = 1)
+ @ConfigEditorDropdown(
+ values = {"Only when ready", "When very Soon", "When soon", "When Kinda Soon", "Always"}
+ )
+ public int experimentationDisplay = 0;
+
+ @Expose
+ @ConfigOption(
+ name = "Puzzler Reset Display",
+ desc = "Change the way the puzzler reset timer displays\n" +
+ "Only when ready, When very Soon, When soon, When kinda soon or always."
+ )
+ @ConfigAccordionId(id = 1)
+ @ConfigEditorDropdown(
+ values = {"Only when ready", "When very Soon", "When soon", "When Kinda Soon", "Always"}
+ )
+ public int puzzlerDisplay = 0;
+
+ @Expose
+ @ConfigOption(
+ name = "Fetchur Reset Display",
+ desc = "Change the way the fetchur reset timer displays\n" +
+ "Only when ready, When very Soon, When soon, When kinda soon or always."
+ )
+ @ConfigAccordionId(id = 1)
+ @ConfigEditorDropdown(
+ values = {"Only when ready", "When very Soon", "When soon", "When Kinda Soon", "Always"}
+ )
+ public int fetchurDisplay = 0;
+
+ @Expose
+ @ConfigOption(
+ name = "Commission timer Display",
+ desc = "Change the way the Commission timer displays\n" +
+ "Only when ready, When very Soon, When soon, When kinda soon or always."
+ )
+ @ConfigAccordionId(id = 1)
+ @ConfigEditorDropdown(
+ values = {"Only when ready", "When very Soon", "When soon", "When Kinda Soon", "Always"}
+ )
+ public int commissionDisplay = 0;
+
+ @Expose
+ @ConfigOption(
+ name = "Cake Buff Display",
+ desc = "Change the way the cake buff timer displays\n" +
+ "Only when ready, When very Soon, When soon, When kinda soon or always."
+ )
+ @ConfigAccordionId(id = 1)
+ @ConfigEditorDropdown(
+ values = {"Only when ready", "When very Soon", "When soon", "When Kinda Soon", "Always"}
+ )
+ public int cakesDisplay = 0;
+
+ @Expose
+ @ConfigOption(
+ name = "Cookie Buff Display",
+ desc = "Change the way the cookie buff displays\n" +
+ "Only when ready, When very Soon, When soon, When kinda soon or always."
+ )
+ @ConfigAccordionId(id = 1)
+ @ConfigEditorDropdown(
+ values = {"Only when ready", "When very Soon", "When soon", "When Kinda Soon", "Always"}
+ )
+ public int cookieBuffDisplay = 0;
+
+ @Expose
+ @ConfigOption(
+ name = "God Pot Display",
+ desc = "Change the way the god pot displays\n" +
+ "Only when ready, When very Soon, When soon, When kinda soon or always."
+ )
+ @ConfigAccordionId(id = 1)
+ @ConfigEditorDropdown(
+ values = {"Only when ready", "When very Soon", "When soon", "When Kinda Soon", "Always"}
+ )
+ public int godpotDisplay = 0;
+
+ @Expose
+ @ConfigOption(
+ name = "Daily Mithril Powder Display",
+ desc = "Change the way the daily mithril powder displays\n" +
+ "Only when ready, When very Soon, When soon, When kinda soon or always."
+ )
+ @ConfigAccordionId(id = 1)
+ @ConfigEditorDropdown(
+ values = {"Only when ready", "When very Soon", "When soon", "When Kinda Soon", "Always"}
+ )
+ public int dailyMithrilPowderDisplay = 0;
+
+ @Expose
+ @ConfigOption(
+ name = "Daily Gemstone Powder Display",
+ desc = "Change the way the daily gemstone powder displays\n" +
+ "Only when ready, When very Soon, When soon, When kinda soon or always."
+ )
+ @ConfigAccordionId(id = 1)
+ @ConfigEditorDropdown(
+ values = {"Only when ready", "When very Soon", "When soon", "When Kinda Soon", "Always"}
+ )
+ public int dailyGemstonePowderDisplay = 0;
+
+ @ConfigOption(
+ name = "Colours",
+ desc = ""
+ )
+
+ @ConfigEditorAccordion(id = 2)
+ @ConfigAccordionId(id = 0)
+ public boolean TodoColourAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Ready colour",
+ desc = "Change the colour of when the timer is ready"
+
+ )
+ @ConfigEditorDropdown(
+ values = {
+ "Black",
+ "Dark Blue",
+ "Dark Green",
+ "Dark Aqua",
+ "Dark Red",
+ "Dark Purple",
+ "Gold",
+ "Gray",
+ "Dark Gray",
+ "Blue",
+ "Green",
+ "Aqua",
+ "Red",
+ "Light Purple",
+ "Yellow",
+ "White"
+ }
+ )
+ @ConfigAccordionId(id = 2)
+ public int readyColour = 10;
+
+ @Expose
+ @ConfigOption(
+ name = "Gone colour",
+ desc = "Change the colour of when the timer is gone"
+
+ )
+ @ConfigEditorDropdown(
+ values = {
+ "Black",
+ "Dark Blue",
+ "Dark Green",
+ "Dark Aqua",
+ "Dark Red",
+ "Dark Purple",
+ "Gold",
+ "Gray",
+ "Dark Gray",
+ "Blue",
+ "Green",
+ "Aqua",
+ "Red",
+ "Light Purple",
+ "Yellow",
+ "White"
+ }
+ )
+ @ConfigAccordionId(id = 2)
+ public int goneColour = 12;
+
+ @Expose
+ @ConfigOption(
+ name = "Very soon colour",
+ desc = "Change the colour of when the timer is almost ready/gone"
+
+ )
+ @ConfigEditorDropdown(
+ values = {
+ "Black",
+ "Dark Blue",
+ "Dark Green",
+ "Dark Aqua",
+ "Dark Red",
+ "Dark Purple",
+ "Gold",
+ "Gray",
+ "Dark Gray",
+ "Blue",
+ "Green",
+ "Aqua",
+ "Red",
+ "Light Purple",
+ "Yellow",
+ "White"
+ }
+ )
+ @ConfigAccordionId(id = 2)
+ public int verySoonColour = 11;
+
+ @Expose
+ @ConfigOption(
+ name = "Soon Colour",
+ desc = "Change the colour of when the timer is soon ready/gone"
+
+ )
+ @ConfigEditorDropdown(
+ values = {
+ "Black",
+ "Dark Blue",
+ "Dark Green",
+ "Dark Aqua",
+ "Dark Red",
+ "Dark Purple",
+ "Gold",
+ "Gray",
+ "Dark Gray",
+ "Blue",
+ "Green",
+ "Aqua",
+ "Red",
+ "Light Purple",
+ "Yellow",
+ "White"
+ }
+ )
+ @ConfigAccordionId(id = 2)
+ public int soonColour = 9;
+
+ @Expose
+ @ConfigOption(
+ name = "Kinda Soon Colour",
+ desc = "Change the colour of when the timer is kinda soon ready/gone"
+
+ )
+ @ConfigEditorDropdown(
+ values = {
+ "Black",
+ "Dark Blue",
+ "Dark Green",
+ "Dark Aqua",
+ "Dark Red",
+ "Dark Purple",
+ "Gold",
+ "Gray",
+ "Dark Gray",
+ "Blue",
+ "Green",
+ "Aqua",
+ "Red",
+ "Light Purple",
+ "Yellow",
+ "White"
+ }
+ )
+ @ConfigAccordionId(id = 2)
+ public int kindaSoonColour = 1;
+
+ @Expose
+ @ConfigOption(
+ name = "Default Colour",
+ desc = "Change the default colour of the timers"
+
+ )
+
+ @ConfigEditorDropdown(
+ values = {
+ "Black",
+ "Dark Blue",
+ "Dark Green",
+ "Dark Aqua",
+ "Dark Red",
+ "Dark Purple",
+ "Gold",
+ "Gray",
+ "Dark Gray",
+ "Blue",
+ "Green",
+ "Aqua",
+ "Red",
+ "Light Purple",
+ "Yellow",
+ "White"
+ }
+ )
+ @ConfigAccordionId(id = 2)
+ public int defaultColour = 15;
+
+ @Expose
+ @ConfigOption(
+ name = "Edit Todo Overlay Position",
+ desc = "Change the position of the Todo overlay"
+ )
+ @ConfigEditorButton(
+ runnableId = 5,
+ buttonText = "Edit"
+ )
+ @ConfigAccordionId(id = 0)
+ public Position todoPosition = new Position(100, 0);
+
+ @Expose
+ @ConfigOption(
+ name = "Todo Style",
+ desc = "Change the style of the todo overlay"
+ )
+ @ConfigEditorDropdown(
+ values = {"Background", "No Shadow", "Shadow", "Full Shadow"}
+ )
+ @ConfigAccordionId(id = 0)
+ public int todoStyle = 0;
+
+ @Expose
+ @ConfigOption(
+ name = "Todo Icons",
+ desc = "Add little item icons next to the lines in the todo overlay"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 0)
+ public boolean todoIcons = true;
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/NeuAuctionHouse.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/NeuAuctionHouse.java
index d410d996..82b0f22a 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/NeuAuctionHouse.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/NeuAuctionHouse.java
@@ -6,40 +6,40 @@ import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditor
import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption;
public class NeuAuctionHouse {
- @Expose
- @ConfigOption(
- name = "Enable NeuAH",
- desc = "Turn on the NEU Auction House. \u00A7cWARNING: May negatively impact performance on low-end machines"
- )
- @ConfigEditorBoolean
- public boolean enableNeuAuctionHouse = false;
+ @Expose
+ @ConfigOption(
+ name = "Enable NeuAH",
+ desc = "Turn on the NEU Auction House. \u00A7cWARNING: May negatively impact performance on low-end machines"
+ )
+ @ConfigEditorBoolean
+ public boolean enableNeuAuctionHouse = false;
- @Expose
- @ConfigOption(
- name = "Disable AH Scroll",
- desc = "Disable scrolling using the scroll wheel inside NeuAH.\n" +
- "This should be used if you want to be able to scroll through tooltips"
- )
- @ConfigEditorBoolean
- public boolean disableAhScroll = false;
+ @Expose
+ @ConfigOption(
+ name = "Disable AH Scroll",
+ desc = "Disable scrolling using the scroll wheel inside NeuAH.\n" +
+ "This should be used if you want to be able to scroll through tooltips"
+ )
+ @ConfigEditorBoolean
+ public boolean disableAhScroll = false;
- @Expose
- @ConfigOption(
- name = "AH Notification (Mins)",
- desc = "Change the amount of time (in minutes) before the \"Ending Soon\" notification for an auction you have bid on"
- )
- @ConfigEditorSlider(
- minValue = 1f,
- maxValue = 10f,
- minStep = 1f
- )
- public int ahNotification = 5;
+ @Expose
+ @ConfigOption(
+ name = "AH Notification (Mins)",
+ desc = "Change the amount of time (in minutes) before the \"Ending Soon\" notification for an auction you have bid on"
+ )
+ @ConfigEditorSlider(
+ minValue = 1f,
+ maxValue = 10f,
+ minStep = 1f
+ )
+ public int ahNotification = 5;
- @Expose
- @ConfigOption(
- name = "Price Filtering in NEU AH",
- desc = "The ability to filter the price of items and their respective average BIN values"
- )
- @ConfigEditorBoolean
- public boolean priceFiltering = false;
+ @Expose
+ @ConfigOption(
+ name = "Price Filtering in NEU AH",
+ desc = "The ability to filter the price of items and their respective average BIN values"
+ )
+ @ConfigEditorBoolean
+ public boolean priceFiltering = false;
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Notifications.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Notifications.java
index b6c12077..9fae1d01 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Notifications.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Notifications.java
@@ -5,28 +5,28 @@ import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditor
import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption;
public class Notifications {
- @Expose
- @ConfigOption(
- name = "Update Messages",
- desc = "Give a notification in chat whenever a new version of NEU is released"
- )
- @ConfigEditorBoolean
- public boolean showUpdateMsg = true;
+ @Expose
+ @ConfigOption(
+ name = "Update Messages",
+ desc = "Give a notification in chat whenever a new version of NEU is released"
+ )
+ @ConfigEditorBoolean
+ public boolean showUpdateMsg = true;
- @Expose
- @ConfigOption(
- name = "RAM Warning",
- desc = "Warning when game starts with lots of RAM allocated\n"+
- "\u00a7cBefore disabling this, please seriously read the message. If you complain about FPS issues without listening to the warning, that's your fault."
- )
- @ConfigEditorBoolean
- public boolean doRamNotif = true;
+ @Expose
+ @ConfigOption(
+ name = "RAM Warning",
+ desc = "Warning when game starts with lots of RAM allocated\n" +
+ "\u00a7cBefore disabling this, please seriously read the message. If you complain about FPS issues without listening to the warning, that's your fault."
+ )
+ @ConfigEditorBoolean
+ public boolean doRamNotif = true;
- /*@Expose
- @ConfigOption(
- name = "Wrong Pet",
- desc = "Gives a notification in chat whenever you're using a pet that doesnt match the same xp you're gathering."
- )
- @ConfigEditorBoolean
- public boolean showWrongPetMsg = false;*/
+ /*@Expose
+ @ConfigOption(
+ name = "Wrong Pet",
+ desc = "Gives a notification in chat whenever you're using a pet that doesnt match the same xp you're gathering."
+ )
+ @ConfigEditorBoolean
+ public boolean showWrongPetMsg = false;*/
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/PetOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/PetOverlay.java
index f37280fa..f0d0c22c 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/PetOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/PetOverlay.java
@@ -9,66 +9,110 @@ import java.util.Arrays;
import java.util.List;
public class PetOverlay {
- @Expose
- @ConfigOption(
- name = "Enable Pet Info Overlay",
- desc = "Shows current active pet and pet exp on screen."
- )
- @ConfigEditorBoolean
- public boolean enablePetInfo = false;
+ @Expose
+ @ConfigOption(
+ name = "Enable Pet Info Overlay",
+ desc = "Shows current active pet and pet exp on screen."
+ )
+ @ConfigEditorBoolean
+ public boolean enablePetInfo = false;
- @Expose
- @ConfigOption(
- name = "Pet Info Position",
- desc = "The position of the pet info."
- )
- @ConfigEditorButton(
- runnableId = 4,
- buttonText = "Edit"
- )
- public Position petInfoPosition = new Position(-1, -1);
+ @Expose
+ @ConfigOption(
+ name = "Edit Pet Info Position",
+ desc = "The position of the pet info."
+ )
+ @ConfigEditorButton(
+ runnableId = 4,
+ buttonText = "Edit"
+ )
+ public Position petInfoPosition = new Position(-1, -1);
- @Expose
- @ConfigOption(
- name = "Pet Overlay Text",
- desc = "\u00a7eDrag text to change the appearance of the overlay\n" +
- "\u00a7rEquip a pet to show the overlay"
- )
- @ConfigEditorDraggableList(
- exampleText = {"\u00a7a[Lvl 37] \u00a7fRock",
- "\u00a7b2,312.9/2,700\u00a7e (85.7%)",
- "\u00a7b2.3k/2.7k\u00a7e (85.7%)",
- "\u00a7bXP/h: \u00a7e27,209",
- "\u00a7bTotal XP: \u00a7e30,597.9",
- "\u00a7bHeld Item: \u00a7fMining Exp Boost",
- "\u00a7bUntil L38: \u00a7e5m13s",
- "\u00a7bUntil L100: \u00a7e2d13h"}
- )
- public List<Integer> petOverlayText = new ArrayList<>(Arrays.asList(0, 2, 3, 6, 4));
+ @Expose
+ @ConfigOption(
+ name = "Pet Overlay Text",
+ desc = "\u00a7eDrag text to change the appearance of the overlay\n" +
+ "\u00a7rEquip a pet to show the overlay"
+ )
+ @ConfigEditorDraggableList(
+ exampleText = {
+ "\u00a7a[Lvl 37] \u00a7fRock",
+ "\u00a7b2,312.9/2,700\u00a7e (85.7%)",
+ "\u00a7b2.3k/2.7k\u00a7e (85.7%)",
+ "\u00a7bXP/h: \u00a7e27,209",
+ "\u00a7bTotal XP: \u00a7e30,597.9",
+ "\u00a7bHeld Item: \u00a7fMining Exp Boost",
+ "\u00a7bUntil L38: \u00a7e5m13s",
+ "\u00a7bUntil L100: \u00a7e2d13h"
+ }
+ )
+ public List<Integer> petOverlayText = new ArrayList<>(Arrays.asList(0, 2, 3, 6, 4));
- @Expose
- @ConfigOption(
- name = "Pet Overlay Icon",
- desc = "Show the icon of the pet you have equiped in the overlay"
- )
- @ConfigEditorBoolean
- public boolean petOverlayIcon = true;
+ @Expose
+ @ConfigOption(
+ name = "Pet Overlay Icon",
+ desc = "Show the icon of the pet you have equiped in the overlay"
+ )
+ @ConfigEditorBoolean
+ public boolean petOverlayIcon = true;
- @Expose
- @ConfigOption(
- name = "Pet Info Overlay Style",
- desc = "Change the style of the Pet Info overlay"
- )
- @ConfigEditorDropdown(
- values = {"Background", "No Shadow", "Shadow Only", "Full Shadow"}
- )
- public int petInfoOverlayStyle = 0;
+ @Expose
+ @ConfigOption(
+ name = "Pet Info Overlay Style",
+ desc = "Change the style of the Pet Info overlay"
+ )
+ @ConfigEditorDropdown(
+ values = {"Background", "No Shadow", "Shadow Only", "Full Shadow"}
+ )
+ public int petInfoOverlayStyle = 0;
- @Expose
- @ConfigOption(
- name = "Show Last Pet",
- desc = "Show 2 pets on the overlay\nUseful if training two pets at once with autopet"
- )
- @ConfigEditorBoolean
- public boolean dualPets = false;
+ @Expose
+ @ConfigOption(
+ name = "Show Last Pet",
+ desc = "Show 2 pets on the overlay\nUseful if training two pets at once with autopet"
+ )
+ @ConfigEditorBoolean
+ public boolean dualPets = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Pet Inventory Display",
+ desc = "Shows an overlay in your inventory showing your current pet"
+ )
+ @ConfigEditorBoolean
+ public boolean petInvDisplay = false;
+
+ @Expose
+ @ConfigOption(
+ name = "GUI Colour",
+ desc = "Change the colour of the GUI"
+ )
+ @ConfigEditorDropdown(
+ values = {"Vanilla", "Grey", "Dark", "Transparent", "FSR"}
+ )
+ public int colourStyle = 0;
+
+ @Expose
+ @ConfigOption(
+ name = "Click To Open Pets",
+ desc = "Click on the hud to open /pets"
+ )
+ @ConfigEditorBoolean
+ public boolean sendPetsCommand = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Hide Pet Inventory Tooltip",
+ desc = "Hides the tooltip of your active in your inventory"
+ )
+ @ConfigEditorBoolean
+ public boolean hidePetTooltip = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Show upgraded Pet Level",
+ desc = "Show the estimated pet level after an upgrade at Kats"
+ )
+ @ConfigEditorBoolean
+ public boolean showKatSitting = true;
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SkillOverlays.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SkillOverlays.java
index ba83fc0c..71b41329 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SkillOverlays.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SkillOverlays.java
@@ -3,56 +3,315 @@ package io.github.moulberry.notenoughupdates.options.seperateSections;
import com.google.gson.annotations.Expose;
import io.github.moulberry.notenoughupdates.core.config.Position;
import io.github.moulberry.notenoughupdates.core.config.annotations.*;
+import org.lwjgl.input.Keyboard;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class SkillOverlays {
- @Expose
- @ConfigOption(
- name = "Enable Farming Overlay",
- desc = "Show an overlay while farming with useful information"
- )
- @ConfigEditorBoolean
- public boolean farmingOverlay = true;
-
- @Expose
- @ConfigOption(
- name = "Farming Text",
- desc = "\u00a7eDrag text to change the appearance of the overlay\n" +
- "\u00a7rHold a mathematical hoe or use an axe while gaining farming xp to show the overlay"
- )
- @ConfigEditorDraggableList(
- exampleText = {"\u00a7bCounter: \u00a7e37,547,860",
- "\u00a7bCrops/m: \u00a7e38.29",
- "\u00a7bFarm: \u00a7e12\u00a77 [\u00a7e|||||||||||||||||\u00a78||||||||\u00a77] \u00a7e67%",
- "\u00a7bCurrent XP: \u00a7e6,734",
- "\u00a7bRemaining XP: \u00a7e3,265",
- "\u00a7bXP/h: \u00a7e238,129",
- "\u00a7bYaw: \u00a7e68.25\u00a7l\u1D52",
- "\u00a7bETA: 13h12m"}
- )
- public List<Integer> farmingText = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4, 5, 7, 6));
-
- @Expose
- @ConfigOption(
- name = "Farming Position",
- desc = "Change the position of the Farming overlay"
- )
- @ConfigEditorButton(
- runnableId = 3,
- buttonText = "Edit"
- )
- public Position farmingPosition = new Position(10, 200);
-
- @Expose
- @ConfigOption(
- name = "Farming Style",
- desc = "Change the style of the Farming overlay"
- )
- @ConfigEditorDropdown(
- values = {"Background", "No Shadow", "Shadow", "Full Shadow"}
- )
- public int farmingStyle = 0;
+ @ConfigOption(
+ name = "Skill Overlay info",
+ desc =
+ "The skill trackers need you to have an \u00A72api key\u00A77 set (if you don't have one set do \u00A72/api new\u00A77)\n" +
+ "For the overlays to show you need a \u00A7bmathematical hoe\u00A77 or an axe with \u00A7bcultivating\u00A77 " +
+ "enchant for farming, a pickaxe with \u00A7bcompact\u00A77 for mining or a rod with \u00A7bexpertise\u00A77"
+ )
+ @ConfigEditorFSR(
+ runnableId = 12,
+ buttonText = ""
+ )
+ public boolean skillInfo = false;
+ @ConfigOption(
+ name = "Farming",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 0)
+ public boolean farmingAccordion = false;
+ @Expose
+ @ConfigOption(
+ name = "Enable Farming Overlay",
+ desc = "Show an overlay while farming with useful information"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 0)
+ public boolean farmingOverlay = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Farming Text",
+ desc = "\u00a7eDrag text to change the appearance of the overlay\n" +
+ "\u00a7rHold a mathematical hoe or use an axe with cultivating enchantment while gaining farming xp to show the overlay"
+ )
+ @ConfigEditorDraggableList(
+ exampleText = {
+ "\u00a7bCounter: \u00a7e37,547,860",
+ "\u00a7bCrops/m: \u00a7e38.29",
+ "\u00a7bFarm: \u00a7e12\u00a77 [\u00a7e|||||||||||||||||\u00a78||||||||\u00a77] \u00a7e67%",
+ "\u00a7bCurrent XP: \u00a7e6,734",
+ "\u00a7bRemaining XP: \u00a7e3,265",
+ "\u00a7bXP/h: \u00a7e238,129",
+ "\u00a7bYaw: \u00a7e68.25\u00a7l\u1D52",
+ "\u00a7bETA: \u00a7e13h12m",
+ "\u00a7bPitch: \u00a7e69.42\u00a7l\u1D52",
+ "\u00a7bCultivating: \u00a7e10,137,945/20,000,000",
+ "\u00a7bCoins/m \u00a7e57,432"
+ }
+ )
+ @ConfigAccordionId(id = 0)
+ public List<Integer> farmingText = new ArrayList<>(Arrays.asList(0, 9, 10, 1, 2, 3, 4, 5, 7, 6));
+
+ @Expose
+ @ConfigOption(
+ name = "Use BZ Price For Coins/m",
+ desc = "Uses the bazzar price instead of NPC price for coins/m"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 0)
+ public boolean useBZPrice = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Edit Farming Overlay Position",
+ desc = "Change the position of the Farming overlay"
+ )
+ @ConfigEditorButton(
+ runnableId = 3,
+ buttonText = "Edit"
+ )
+ @ConfigAccordionId(id = 0)
+ public Position farmingPosition = new Position(10, 200);
+
+ @Expose
+ @ConfigOption(
+ name = "Farming Style",
+ desc = "Change the style of the Farming overlay"
+ )
+ @ConfigEditorDropdown(
+ values = {"Background", "No Shadow", "Shadow", "Full Shadow"}
+ )
+ @ConfigAccordionId(id = 0)
+ public int farmingStyle = 0;
+ @ConfigOption(
+ name = "Mining",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 1)
+ public boolean miningAccordion = false;
+ @Expose
+ @ConfigOption(
+ name = "Enable Mining Overlay",
+ desc = "Show an overlay while Mining with useful information"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 1)
+ public boolean miningSkillOverlay = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Mining Text",
+ desc = "\u00a7eDrag text to change the appearance of the overlay\n" +
+ "\u00a7rHold a pickaxe with compact while gaining mining xp to show the overlay"
+ )
+ @ConfigEditorDraggableList(
+ exampleText = {
+ "\u00a7bCompact: \u00a7e547,860",
+ "\u00a7bBlocks/m: \u00a7e38.29",
+ "\u00a7bMine: \u00a7e12\u00a77 [\u00a7e|||||||||||||||||\u00a78||||||||\u00a77] \u00a7e67%",
+ "\u00a7bCurrent XP: \u00a7e6,734",
+ "\u00a7bRemaining XP: \u00a7e3,265",
+ "\u00a7bXP/h: \u00a7e238,129",
+ "\u00a7bYaw: \u00a7e68.25\u00a7l\u1D52",
+ "\u00a7bETA: \u00a7e13h12m",
+ "\u00a7bCompact Progress: \u00a7e137,945/150,000"
+ }
+ )
+ @ConfigAccordionId(id = 1)
+ public List<Integer> miningText = new ArrayList<>(Arrays.asList(0, 8, 1, 2, 3, 4, 5, 7));
+
+ @Expose
+ @ConfigOption(
+ name = "Edit Mining Overlay Position",
+ desc = "Change the position of the Mining overlay"
+ )
+ @ConfigEditorButton(
+ runnableId = 11,
+ buttonText = "Edit"
+ )
+ @ConfigAccordionId(id = 1)
+ public Position miningPosition = new Position(10, 200);
+
+ @Expose
+ @ConfigOption(
+ name = "Mining Style",
+ desc = "Change the style of the Mining overlay"
+ )
+ @ConfigEditorDropdown(
+ values = {"Background", "No Shadow", "Shadow", "Full Shadow"}
+ )
+ @ConfigAccordionId(id = 1)
+ public int miningStyle = 0;
+
+ @ConfigOption(
+ name = "Fishing",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 3)
+ public boolean fishingAccordion = false;
+ @Expose
+ @ConfigOption(
+ name = "Enable Fishing Overlay",
+ desc = "Show an overlay while Fishing with useful information"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 3)
+ public boolean FishingSkillOverlay = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Fishing Text",
+ desc = "\u00a7eDrag text to change the appearance of the overlay\n" +
+ "\u00a7rHold a fishing rod with expertise enchantment while gaining fishing xp to show the overlay"
+ )
+ @ConfigEditorDraggableList(
+ exampleText = {
+ "\u00a7bExpertise: \u00a7e7,945/10,000",
+ //"\u00a7bCatches/m: \u00a7e38.29",
+ "\u00a7bFishing: \u00a7e12\u00a77 [\u00a7e|||||||||||||||||\u00a78||||||||\u00a77] \u00a7e67%",
+ "\u00a7bCurrent XP: \u00a7e6,734",
+ "\u00a7bRemaining XP: \u00a7e3,265",
+ "\u00a7bXP/h: \u00a7e238,129",
+ //"\u00a7bYaw: \u00a7e68.25\u00a7l\u1D52",
+ "\u00a7bETA: \u00a7e13h12m",
+ //"\u00a7bExpertise Progress: \u00a7e7,945/10,000",
+ "\u00a7bTimer: \u00a7e1m15s"
+ }
+ )
+ @ConfigAccordionId(id = 3)
+ public List<Integer> fishingText = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4, 5, 6));
+
+ @Expose
+ @ConfigOption(
+ name = "Edit Fishing Overlay Position",
+ desc = "Change the position of the Fishing overlay"
+ )
+ @ConfigEditorButton(
+ runnableId = 14,
+ buttonText = "Edit"
+ )
+ @ConfigAccordionId(id = 3)
+ public Position fishingPosition = new Position(10, 200);
+
+ @Expose
+ @ConfigOption(
+ name = "Fishing Style",
+ desc = "Change the style of the Fishing overlay"
+ )
+ @ConfigEditorDropdown(
+ values = {"Background", "No Shadow", "Shadow", "Full Shadow"}
+ )
+ @ConfigAccordionId(id = 3)
+ public int fishingStyle = 0;
+
+ @Expose
+ @ConfigOption(
+ name = "Toggle Fishing timer",
+ desc = "Start or stop the timer on the fishing overlay\n" +
+ "Also can plays a ding customizable below"
+ )
+ @ConfigEditorKeybind(defaultKey = Keyboard.KEY_END)
+ @ConfigAccordionId(id = 3)
+ public int fishKey = Keyboard.KEY_END;
+
+ @Expose
+ @ConfigOption(
+ name = "Fishing Timer Alert",
+ desc = "Change the amount of time (seconds) until the timer dings"
+ )
+ @ConfigEditorSlider(
+ minValue = 0,
+ maxValue = 600,
+ minStep = 20
+ )
+ @ConfigAccordionId(id = 3)
+ public int customFishTimer = 300;
+
+ @ConfigOption(
+ name = "Combat",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 4)
+ public boolean combatAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "\u00A7cWarning",
+ desc = "The combat display will only show if you have a Book of Stats on the item you are using"
+ )
+ @ConfigEditorFSR(
+ runnableId = 12,
+ buttonText = ""
+ )
+ @ConfigAccordionId(id = 4)
+ public boolean combatInfo = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Enable Combat Overlay",
+ desc = "Show an overlay while Combat with useful information"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 4)
+ public boolean combatSkillOverlay = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Combat Text",
+ desc = "\u00a7eDrag text to change the appearance of the overlay\n" +
+ "\u00a7rHold an item with Book of Stats to show the display"
+ )
+ @ConfigEditorDraggableList(
+ exampleText = {
+ "\u00a7bKills: \u00a7e547,860",
+ "\u00a7bCombat: \u00a7e12\u00a77 [\u00a7e|||||||||||||||||\u00a78||||||||\u00a77] \u00a7e67%",
+ "\u00a7bCurrent XP: \u00a7e6,734",
+ "\u00a7bRemaining XP: \u00a7e3,265",
+ "\u00a7bXP/h: \u00a7e238,129",
+ "\u00a7bETA: \u00a7e13h12m"
+ }
+ )
+ @ConfigAccordionId(id = 4)
+ public List<Integer> combatText = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4, 5));
+
+ @Expose
+ @ConfigOption(
+ name = "Edit Combat Overlay Position",
+ desc = "Change the position of the Combat overlay"
+ )
+ @ConfigEditorButton(
+ runnableId = 19,
+ buttonText = "Edit"
+ )
+ @ConfigAccordionId(id = 4)
+ public Position combatPosition = new Position(10, 200);
+
+ @Expose
+ @ConfigOption(
+ name = "Combat Style",
+ desc = "Change the style of the Combat overlay"
+ )
+ @ConfigEditorDropdown(
+ values = {"Background", "No Shadow", "Shadow", "Full Shadow"}
+ )
+ @ConfigAccordionId(id = 4)
+ public int combatStyle = 0;
+
+ @Expose
+ @ConfigOption(
+ name = "Always show combat overlay",
+ desc = "Shows combat overlay even if you dont have Book of Stats"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 4)
+ public boolean alwaysShowCombatOverlay = false;
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SlayerOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SlayerOverlay.java
new file mode 100644
index 00000000..220b992b
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SlayerOverlay.java
@@ -0,0 +1,76 @@
+package io.github.moulberry.notenoughupdates.options.seperateSections;
+
+import com.google.gson.annotations.Expose;
+import io.github.moulberry.notenoughupdates.core.config.Position;
+import io.github.moulberry.notenoughupdates.core.config.annotations.*;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class SlayerOverlay {
+ @Expose
+ @ConfigOption(
+ name = "\u00A7cWarning",
+ desc = "You may have to do 2 bosses before everything shows"
+ )
+ @ConfigEditorFSR(
+ runnableId = 12
+ )
+ public boolean slayerWarning = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Enable Slayer Overlay",
+ desc = "Toggles the slayer overlay"
+ )
+ @ConfigEditorBoolean
+ public boolean slayerOverlay = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Only show when relevant",
+ desc = "Only shows the overlay when you are in an area where your current Slayer can be completed"
+ )
+ @ConfigEditorBoolean
+ public boolean onlyShowWhenRelevant = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Slayer Text",
+ desc = "\u00a7eDrag text to change the appearance of the overlay"
+ )
+ @ConfigEditorDraggableList(
+ exampleText = {
+ "\u00a7eSlayer: \u00a74Sven",
+ "\u00a7eRNG Meter: \u00a75100%",
+ "\u00a7eLvl: \u00a7d7",
+ "\u00a7eKill time: \u00a7c1:30",
+ "\u00a7eXP: \u00a7d75,450/100,000",
+ "\u00a7eBosses till next Lvl: \u00a7d17",
+ "\u00a7eAverage kill time: \u00a7c3:20"
+ }
+ )
+ public List<Integer> slayerText = new ArrayList<>(Arrays.asList(0, 1, 4, 5, 3, 6));
+
+ @Expose
+ @ConfigOption(
+ name = "Edit Slayer Overlay Position",
+ desc = "Change the position of the Slayer overlay"
+ )
+ @ConfigEditorButton(
+ runnableId = 18,
+ buttonText = "Edit"
+ )
+ public Position slayerPosition = new Position(10, 200);
+
+ @Expose
+ @ConfigOption(
+ name = "Slayer Style",
+ desc = "Change the style of the Slayer overlay"
+ )
+ @ConfigEditorDropdown(
+ values = {"Background", "No Shadow", "Shadow", "Full Shadow"}
+ )
+ public int slayerStyle = 0;
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SlotLocking.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SlotLocking.java
index df8df020..f9d1eef1 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SlotLocking.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SlotLocking.java
@@ -1,55 +1,62 @@
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.ConfigEditorKeybind;
-import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorSlider;
-import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption;
+import io.github.moulberry.notenoughupdates.core.config.annotations.*;
import org.lwjgl.input.Keyboard;
public class SlotLocking {
- @Expose
- @ConfigOption(
- name = "Enable Slot Locking",
- desc = "Allows you to lock slots and create slot bindings"
- )
- @ConfigEditorBoolean
- public boolean enableSlotLocking = false;
+ @Expose
+ @ConfigOption(
+ name = "\u00A7cWarning",
+ desc = "Make sure you have SBA's locked slots off before you turn NEU's on"
+ )
+ @ConfigEditorFSR(
+ runnableId = 12
+ )
+ public boolean slotLockWarning = false;
- @Expose
- @ConfigOption(
- name = "Enable Slot Binding",
- desc = "Allows you to create slot bindings\nNote: \"Enable Slot Locking\" must be on"
- )
- @ConfigEditorBoolean
- public boolean enableSlotBinding = true;
+ @Expose
+ @ConfigOption(
+ name = "Enable Slot Locking",
+ desc = "Allows you to lock slots and create slot bindings"
+ )
+ @ConfigEditorBoolean
+ public boolean enableSlotLocking = false;
- @Expose
- @ConfigOption(
- name = "Don't Drop Bound Slots",
- desc = "Slot bindings also act as locked slots (prevents dropping / moving in inventory)"
- )
- @ConfigEditorBoolean
- public boolean bindingAlsoLocks = false;
+ @Expose
+ @ConfigOption(
+ name = "Enable Slot Binding",
+ desc = "Allows you to create slot bindings\nNote: \"Enable Slot Locking\" must be on"
+ )
+ @ConfigEditorBoolean
+ public boolean enableSlotBinding = true;
- @Expose
- @ConfigOption(
- name = "Slot Lock Key",
- desc = "Click this key to LOCK a slot\n" +
- "Hold this key and drag to BIND a slot"
- )
- @ConfigEditorKeybind(defaultKey = Keyboard.KEY_L)
- public int slotLockKey = Keyboard.KEY_L;
+ @Expose
+ @ConfigOption(
+ name = "Don't Drop Bound Slots",
+ desc = "Slot bindings also act as locked slots (prevents dropping / moving in inventory)"
+ )
+ @ConfigEditorBoolean
+ public boolean bindingAlsoLocks = false;
- @Expose
- @ConfigOption(
- name = "Lock Slots in Trade",
- desc = "Prevents trading locked items in the custom trade windows"
- )
- @ConfigEditorBoolean
- public boolean lockSlotsInTrade = true;
+ @Expose
+ @ConfigOption(
+ name = "Slot Lock Key",
+ desc = "Click this key to LOCK a slot\n" +
+ "Hold this key and drag to BIND a slot"
+ )
+ @ConfigEditorKeybind(defaultKey = Keyboard.KEY_L)
+ public int slotLockKey = Keyboard.KEY_L;
+
+ @Expose
+ @ConfigOption(
+ name = "Lock Slots in Trade",
+ desc = "Prevents trading locked items in the custom trade windows"
+ )
+ @ConfigEditorBoolean
+ public boolean lockSlotsInTrade = true;
- @Expose
+ @Expose
/*@ConfigOption(
name = "Item Swap drop delay",
desc = "Set the delay between swapping to another item and being able to drop it.\n"+
@@ -60,25 +67,25 @@ public class SlotLocking {
maxValue = 500,
minStep = 5
)*/
- public int slotLockSwapDelay = 100;
+ public int slotLockSwapDelay = 100;
- @Expose
- @ConfigOption(
- name = "Slot Lock Sound",
- desc = "Play a ding when locking/unlocking slots"
- )
- @ConfigEditorBoolean
- public boolean slotLockSound = true;
+ @Expose
+ @ConfigOption(
+ name = "Slot Lock Sound",
+ desc = "Play a ding when locking/unlocking slots"
+ )
+ @ConfigEditorBoolean
+ public boolean slotLockSound = true;
- @Expose
- @ConfigOption(
- name = "Slot Lock Sound Vol.",
- desc = "Set the volume of the ding sound"
- )
- @ConfigEditorSlider(
- minValue = 0,
- maxValue = 100,
- minStep = 1
- )
- public float slotLockSoundVol = 20;
+ @Expose
+ @ConfigOption(
+ name = "Slot Lock Sound Vol.",
+ desc = "Set the volume of the ding sound"
+ )
+ @ConfigEditorSlider(
+ minValue = 0,
+ maxValue = 100,
+ minStep = 1
+ )
+ public float slotLockSoundVol = 20;
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/StorageGUI.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/StorageGUI.java
index 114183d3..a2d50409 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/StorageGUI.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/StorageGUI.java
@@ -5,238 +5,256 @@ import io.github.moulberry.notenoughupdates.core.config.annotations.*;
import org.lwjgl.input.Keyboard;
public class StorageGUI {
- @ConfigOption(
- name = "Storage Overlay",
- desc = ""
- )
- @ConfigEditorAccordion(id = 1)
- public boolean storageOverlayAccordion = false;
-
- @Expose
- public int selectedIndex = 0;
-
- @Expose
- @ConfigOption(
- name = "Enable Storage GUI",
- desc = "Show a custom storage overlay when accessing /storage. " +
- "Makes switching between pages much easier and also allows for searching through all storages"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 1)
- public boolean enableStorageGUI3 = true;
-
- @Expose
- @ConfigOption(
- name = "Storage Height",
- desc = "Change the height of the storage preview section. Increasing this allows more storages to be seen at once"
- )
- @ConfigEditorSlider(
- minValue = 104,
- maxValue = 312,
- minStep = 26
- )
- @ConfigAccordionId(id = 1)
- public int storageHeight = 208;
-
- @Expose
- @ConfigOption(
- name = "Storage Style",
- desc = "Change the visual style of the overlay"
- )
- @ConfigEditorDropdown(
- values = {"Transparent", "Minecraft", "Dark", "Custom"}
- )
- @ConfigAccordionId(id = 1)
- public int displayStyle = 0;
-
- @Expose
- @ConfigOption(
- name = "Enderchest Preview",
- desc = "Preview Enderchest pages when hovering over the selector on the left side"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 1)
- public boolean enderchestPreview = true;
-
- @Expose
- @ConfigOption(
- name = "Backpack Preview",
- desc = "Preview Backpacks when hovering over the selector on the left side"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 1)
- public boolean backpackPreview = true;
-
- @Expose
- @ConfigOption(
- name = "Compact Vertically",
- desc = "Remove the space between backpacks when there is a size discrepancy"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 1)
- public boolean masonryMode = false;
-
- @Expose
- @ConfigOption(
- name = "Fancy Glass Panes",
- desc = "Replace the glass pane textures in your storage containers with a fancy connected texture"
- )
- @ConfigEditorDropdown(
- values = {"On", "Locked", "Off"}
- )
- @ConfigAccordionId(id = 1)
- public int fancyPanes = 0;
-
- @Expose
- @ConfigOption(
- name = "Search Bar Autofocus",
- desc = "Automatically focus the search bar when pressing keys"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 1)
- public boolean searchBarAutofocus = true;
-
- @Expose
- @ConfigOption(
- name = "Selected Storage Colour",
- desc = "Change the colour used to draw the selected backpack border"
- )
- @ConfigEditorColour
- @ConfigAccordionId(id = 1)
- public String selectedStorageColour = "0:255:255:223:0";
-
- @Expose
- @ConfigOption(
- name = "Scrollable Tooltips",
- desc = "Support for scrolling tooltips for users with small monitors\n" +
- "This will prevent the menu from scrolling while holding the key, allowing you to scroll tooltips"
- )
- @ConfigEditorKeybind(defaultKey = 0)
- @ConfigAccordionId(id = 1)
- public int cancelScrollKey = 0;
-
-
- @ConfigOption(
- name = "Inventory Backpacks",
- desc = ""
- )
- @ConfigEditorAccordion(id = 0)
- public boolean inventorySlotAccordion = false;
-
- @Expose
- @ConfigOption(
- name = "Inventory Backpacks",
- desc = "Add a \"10th slot\" to your inventory which allows you to quickly access your backpacks"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 0)
- public boolean showInvBackpack = false;
-
- //public boolean showInvBackpack = false;
- @Expose
- @ConfigOption(
- name = "Scroll to Backpack",
- desc = "Allow scrolling to the backpack using the mouse wheel.\n" +
- "\"Scroll (Key)\" = Allow scrolling to 10th slot only while 'Backpack Scroll Key' (default: SHIFT) is pressed"
- )
- @ConfigEditorDropdown(
- values = {"Scroll (Key)", "Scroll (Always)", "Don't Scroll"}
- )
- @ConfigAccordionId(id = 0)
- public int scrollToBackpack2 = 0;
-
- @Expose
- @ConfigOption(
- name = "Backpack Side",
- desc = "Set which side of the hotbar the backpack slot shows"
- )
- @ConfigEditorDropdown(
- values = {"Left", "Right"}
- )
- @ConfigAccordionId(id = 0)
- public int backpackHotbarSide = 0;
-
- @Expose
- @ConfigOption(
- name = "Backpack Peeking",
- desc = "When the backpack is selected, show it's contents on your screen"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 0)
- public boolean showInvBackpackPreview = true;
-
- @Expose
- @ConfigOption(
- name = "Backpack Opacity%",
- desc = "Change the opacity of the backpack preview background"
- )
- @ConfigEditorSlider(
- minValue = 0,
- maxValue = 100,
- minStep = 5
- )
- @ConfigAccordionId(id = 0)
- public int backpackOpacity = 50;
-
- @Expose
- @ConfigOption(
- name = "Backpack Scroll Key",
- desc = "Change the key which needs to be pressed in order to allow backpacks to be scrolled between"
- )
- @ConfigEditorKeybind(defaultKey = Keyboard.KEY_LSHIFT)
- @ConfigAccordionId(id = 0)
- public int backpackScrollKey = Keyboard.KEY_LSHIFT;
-
- @Expose
- @ConfigOption(
- name = "Backpack Hotkey",
- desc = "Hotkey to quickly switch to the backpack slot"
- )
- @ConfigEditorKeybind(defaultKey = Keyboard.KEY_GRAVE)
- @ConfigAccordionId(id = 0)
- public int backpackHotkey = Keyboard.KEY_GRAVE;
-
- @Expose
- @ConfigOption(
- name = "Arrow Key Backpacks",
- desc = "Use arrow keys [LEFT],[RIGHT] to move between backpacks and [DOWN] to navigate backpack even when the slot is not selected. Keys are customizable below"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 0)
- public boolean arrowKeyBackpacks = false;
-
- @ConfigOption(
- name = "Arrow Key Backpack Keybinds",
- desc = ""
- )
- @ConfigEditorAccordion(id = 2)
- @ConfigAccordionId(id = 0)
- public boolean backpackArrowAccordion = false;
-
- @Expose
- @ConfigOption(
- name = "Backpack Left",
- desc = "Select the backpack to the left"
- )
- @ConfigEditorKeybind(defaultKey = Keyboard.KEY_LEFT)
- @ConfigAccordionId(id = 2)
- public int arrowLeftKey = Keyboard.KEY_LEFT;
-
- @Expose
- @ConfigOption(
- name = "Backpack Right",
- desc = "Select the backpack to the right"
- )
- @ConfigEditorKeybind(defaultKey = Keyboard.KEY_RIGHT)
- @ConfigAccordionId(id = 2)
- public int arrowRightKey = Keyboard.KEY_RIGHT;
-
- @Expose
- @ConfigOption(
- name = "Backpack Open",
- desc = "Open the selected backpack"
- )
- @ConfigEditorKeybind(defaultKey = Keyboard.KEY_DOWN)
- @ConfigAccordionId(id = 2)
- public int arrowDownKey = Keyboard.KEY_DOWN;
+ @ConfigOption(
+ name = "Storage Overlay",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 1)
+ public boolean storageOverlayAccordion = false;
+
+ @Expose
+ public int selectedIndex = 0;
+ @ConfigOption(
+ name = "\u00A7cWarning",
+ desc = "You need Fast Render and Antialiasing off for these settings to work\n" +
+ "You can find these in your video settings"
+ )
+ @ConfigEditorFSR(
+ runnableId = 12,
+ buttonText = ""
+ )
+ @ConfigAccordionId(id = 1)
+ public boolean storageGUIWarning = false;
+ @Expose
+ @ConfigOption(
+ name = "Enable Storage GUI",
+ desc = "Show a custom storage overlay when accessing /storage. " +
+ "Makes switching between pages much easier and also allows for searching through all storages"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 1)
+ public boolean enableStorageGUI3 = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Storage Height",
+ desc = "Change the height of the storage preview section. Increasing this allows more storages to be seen at once"
+ )
+ @ConfigEditorSlider(
+ minValue = 104,
+ maxValue = 312,
+ minStep = 26
+ )
+ @ConfigAccordionId(id = 1)
+ public int storageHeight = 208;
+
+ @Expose
+ @ConfigOption(
+ name = "Storage Style",
+ desc = "Change the visual style of the overlay"
+ )
+ @ConfigEditorDropdown(
+ values = {"Transparent", "Minecraft", "Dark", "Custom"}
+ )
+ @ConfigAccordionId(id = 1)
+ public int displayStyle = 0;
+
+ @Expose
+ @ConfigOption(
+ name = "Enderchest Preview",
+ desc = "Preview Enderchest pages when hovering over the selector on the left side"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 1)
+ public boolean enderchestPreview = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Backpack Preview",
+ desc = "Preview Backpacks when hovering over the selector on the left side"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 1)
+ public boolean backpackPreview = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Compact Vertically",
+ desc = "Remove the space between backpacks when there is a size discrepancy"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 1)
+ public boolean masonryMode = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Fancy Glass Panes",
+ desc = "Replace the glass pane textures in your storage containers with a fancy connected texture"
+ )
+ @ConfigEditorDropdown(
+ values = {"On", "Locked", "Off"}
+ )
+ @ConfigAccordionId(id = 1)
+ public int fancyPanes = 0;
+
+ @Expose
+ @ConfigOption(
+ name = "Search Bar Autofocus",
+ desc = "Automatically focus the search bar when pressing keys"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 1)
+ public boolean searchBarAutofocus = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Show Enchant Glint",
+ desc = "Toggle enchant glint in storage GUI"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 1)
+ public boolean showEnchantGlint = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Selected Storage Colour",
+ desc = "Change the colour used to draw the selected backpack border"
+ )
+ @ConfigEditorColour
+ @ConfigAccordionId(id = 1)
+ public String selectedStorageColour = "0:255:255:223:0";
+
+ @Expose
+ @ConfigOption(
+ name = "Scrollable Tooltips",
+ desc = "Support for scrolling tooltips for users with small monitors\n" +
+ "This will prevent the menu from scrolling while holding the key, allowing you to scroll tooltips"
+ )
+ @ConfigEditorKeybind(defaultKey = 0)
+ @ConfigAccordionId(id = 1)
+ public int cancelScrollKey = 0;
+
+ @ConfigOption(
+ name = "Inventory Backpacks",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 0)
+ public boolean inventorySlotAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Inventory Backpacks",
+ desc = "Add a \"10th slot\" to your inventory which allows you to quickly access your backpacks"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 0)
+ public boolean showInvBackpack = false;
+
+ //public boolean showInvBackpack = false;
+ @Expose
+ @ConfigOption(
+ name = "Scroll to Backpack",
+ desc = "Allow scrolling to the backpack using the mouse wheel.\n" +
+ "\"Scroll (Key)\" = Allow scrolling to 10th slot only while 'Backpack Scroll Key' (default: SHIFT) is pressed"
+ )
+ @ConfigEditorDropdown(
+ values = {"Scroll (Key)", "Scroll (Always)", "Don't Scroll"}
+ )
+ @ConfigAccordionId(id = 0)
+ public int scrollToBackpack2 = 0;
+
+ @Expose
+ @ConfigOption(
+ name = "Backpack Side",
+ desc = "Set which side of the hotbar the backpack slot shows"
+ )
+ @ConfigEditorDropdown(
+ values = {"Left", "Right"}
+ )
+ @ConfigAccordionId(id = 0)
+ public int backpackHotbarSide = 0;
+
+ @Expose
+ @ConfigOption(
+ name = "Backpack Peeking",
+ desc = "When the backpack is selected, show it's contents on your screen"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 0)
+ public boolean showInvBackpackPreview = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Backpack Opacity%",
+ desc = "Change the opacity of the backpack preview background"
+ )
+ @ConfigEditorSlider(
+ minValue = 0,
+ maxValue = 100,
+ minStep = 5
+ )
+ @ConfigAccordionId(id = 0)
+ public int backpackOpacity = 50;
+
+ @Expose
+ @ConfigOption(
+ name = "Backpack Scroll Key",
+ desc = "Change the key which needs to be pressed in order to allow backpacks to be scrolled between"
+ )
+ @ConfigEditorKeybind(defaultKey = Keyboard.KEY_LSHIFT)
+ @ConfigAccordionId(id = 0)
+ public int backpackScrollKey = Keyboard.KEY_LSHIFT;
+
+ @Expose
+ @ConfigOption(
+ name = "Backpack Hotkey",
+ desc = "Hotkey to quickly switch to the backpack slot"
+ )
+ @ConfigEditorKeybind(defaultKey = Keyboard.KEY_GRAVE)
+ @ConfigAccordionId(id = 0)
+ public int backpackHotkey = Keyboard.KEY_GRAVE;
+
+ @Expose
+ @ConfigOption(
+ name = "Arrow Key Backpacks",
+ desc = "Use arrow keys [LEFT],[RIGHT] to move between backpacks and [DOWN] to navigate backpack even when the slot is not selected. Keys are customizable below"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 0)
+ public boolean arrowKeyBackpacks = false;
+
+ @ConfigOption(
+ name = "Arrow Key Backpack Keybinds",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 2)
+ @ConfigAccordionId(id = 0)
+ public boolean backpackArrowAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Backpack Left",
+ desc = "Select the backpack to the left"
+ )
+ @ConfigEditorKeybind(defaultKey = Keyboard.KEY_LEFT)
+ @ConfigAccordionId(id = 2)
+ public int arrowLeftKey = Keyboard.KEY_LEFT;
+
+ @Expose
+ @ConfigOption(
+ name = "Backpack Right",
+ desc = "Select the backpack to the right"
+ )
+ @ConfigEditorKeybind(defaultKey = Keyboard.KEY_RIGHT)
+ @ConfigAccordionId(id = 2)
+ public int arrowRightKey = Keyboard.KEY_RIGHT;
+
+ @Expose
+ @ConfigOption(
+ name = "Backpack Open",
+ desc = "Open the selected backpack"
+ )
+ @ConfigEditorKeybind(defaultKey = Keyboard.KEY_DOWN)
+ @ConfigAccordionId(id = 2)
+ public int arrowDownKey = Keyboard.KEY_DOWN;
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Toolbar.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Toolbar.java
index 51092bbe..39674459 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Toolbar.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Toolbar.java
@@ -4,91 +4,98 @@ import com.google.gson.annotations.Expose;
import io.github.moulberry.notenoughupdates.core.config.annotations.*;
public class Toolbar {
- @Expose
- @ConfigOption(
- name = "Edit Toolbar Positions",
- desc = "Edit the position of the QuickCommands / Search Bar"
- )
- @ConfigEditorButton(runnableId = 6, buttonText = "Edit")
- public boolean positionButton = true;
+ @Expose
+ @ConfigOption(
+ name = "Edit Toolbar Positions",
+ desc = "Edit the position of the QuickCommands / Search Bar"
+ )
+ @ConfigEditorButton(runnableId = 6, buttonText = "Edit")
+ public boolean positionButton = true;
+ @ConfigOption(
+ name = "Search Bar",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 0)
+ public boolean searchBarAccordion = false;
+ @Expose
+ @ConfigOption(
+ name = "Show Search Bar",
+ desc = "Show Itemlist search bar in the NEU toolbar"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 0)
+ public boolean searchBar = true;
- @ConfigOption(
- name = "Search Bar",
- desc = ""
- )
- @ConfigEditorAccordion(id = 0)
- public boolean searchBarAccordion = false;
+ @Expose
+ @ConfigOption(
+ name = "Show a quick settings button",
+ desc = "Show quick settings button in the NEU toolbar"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 0)
+ public boolean enableSettingsButton = true;
- @Expose
- @ConfigOption(
- name = "Show Search Bar",
- desc = "Show Itemlist search bar in the NEU toolbar"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 0)
- public boolean searchBar = true;
+ @Expose
+ @ConfigOption(
+ name = "Show a help settings button",
+ desc = "Show quick settings button in the NEU toolbar"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 0)
+ public boolean enableHelpButton = true;
- @Expose
- @ConfigOption(
- name = "Show a quick settings button",
- desc = "Show quick settings button in the NEU toolbar"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 0)
- public boolean enableSettingsButton = true;
+ @Expose
+ @ConfigOption(
+ name = "Search Bar Width",
+ desc = "Change the width of the search bar"
+ )
+ @ConfigEditorSlider(
+ minValue = 50f,
+ maxValue = 300f,
+ minStep = 10f
+ )
+ @ConfigAccordionId(id = 0)
+ public int searchBarWidth = 200;
- @Expose
- @ConfigOption(
- name = "Show a help settings button",
- desc = "Show quick settings button in the NEU toolbar"
- )
- @ConfigEditorBoolean
- @ConfigAccordionId(id = 0)
- public boolean enableHelpButton = true;
+ @Expose
+ @ConfigOption(
+ name = "Search Bar Height",
+ desc = "Change the height of the search bar"
+ )
+ @ConfigEditorSlider(
+ minValue = 15f,
+ maxValue = 50f,
+ minStep = 1f
+ )
+ @ConfigAccordionId(id = 0)
+ public int searchBarHeight = 40;
- @Expose
- @ConfigOption(
- name = "Search Bar Width",
- desc = "Change the width of the search bar"
- )
- @ConfigEditorSlider(
- minValue = 50f,
- maxValue = 300f,
- minStep = 10f
- )
- @ConfigAccordionId(id = 0)
- public int searchBarWidth = 200;
+ @Expose
+ @ConfigOption(
+ name = "Auto turnoff search mode",
+ desc = "Turns off the inventory search mode after 2 minutes"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 0)
+ public boolean autoTurnOffSearchMode = true;
- @Expose
- @ConfigOption(
- name = "Search Bar Height",
- desc = "Change the height of the search bar"
- )
- @ConfigEditorSlider(
- minValue = 15f,
- maxValue = 50f,
- minStep = 1f
- )
- @ConfigAccordionId(id = 0)
- public int searchBarHeight = 40;
+ @Expose
+ @ConfigOption(
+ name = "Show Quick Commands",
+ desc = "Show QuickCommands\u2122 in the NEU toolbar"
+ )
+ @ConfigEditorBoolean
+ public boolean quickCommands = false;
- @Expose
- @ConfigOption(
- name = "Show Quick Commands",
- desc = "Show QuickCommands\u2122 in the NEU toolbar"
- )
- @ConfigEditorBoolean
- public boolean quickCommands = false;
-
- @Expose
- @ConfigOption(
- name = "Quick Commands Click Type",
- desc = "Change the click type needed to trigger quick commands"
- )
- @ConfigEditorDropdown(
- values = {"Mouse Up", "Mouse Down"}
- )
- public int quickCommandsClickType = 0;
+ @Expose
+ @ConfigOption(
+ name = "Quick Commands Click Type",
+ desc = "Change the click type needed to trigger quick commands"
+ )
+ @ConfigEditorDropdown(
+ values = {"Mouse Up", "Mouse Down"}
+ )
+ public int quickCommandsClickType = 0;
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TooltipTweaks.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TooltipTweaks.java
index c6266393..52d2a5d1 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TooltipTweaks.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TooltipTweaks.java
@@ -9,117 +9,134 @@ import java.util.Arrays;
import java.util.List;
public class TooltipTweaks {
- @ConfigOption(
- name = "Tooltip Price Information",
- desc = ""
- )
- @ConfigEditorAccordion(id = 0)
- public boolean priceInfoAccordion = false;
-
- @Expose
- @ConfigOption(
- name = "Price Info (Auc)",
- desc = "\u00a7rSelect what price information you would like to see on auctionable item tooltips\n" +
- "\u00a7eDrag text to rearrange"
- )
- @ConfigEditorDraggableList(
- exampleText = {"\u00a7eLowest BIN",
- "\u00a7eAH Price",
- "\u00a7eAH Sales",
- "\u00a7eRaw Craft Cost",
- "\u00a7eAVG Lowest BIN",
- "\u00a7eDungeon Costs"}
- )
- @ConfigAccordionId(id = 0)
- public List<Integer> priceInfoAuc = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 5));
-
- @Expose
- @ConfigOption(
- name = "Price Info (Baz)",
- desc = "\u00a7rSelect what price information you would like to see on bazaar item tooltips\n" +
- "\u00a7eDrag text to rearrange"
- )
- @ConfigEditorDraggableList(
- exampleText = {"\u00a7eBuy", "\u00a7eSell", "\u00a7eBuy (Insta)", "\u00a7eSell (Insta)", "\u00a7eRaw Craft Cost"}
- )
- @ConfigAccordionId(id = 0)
- public List<Integer> priceInfoBaz = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4));
-
- @Expose
- @ConfigOption(
- name = "Price Info (Inv)",
- desc = "Show price information for items in your inventory"
- )
- @ConfigEditorBoolean
- public boolean showPriceInfoInvItem = true;
-
- @Expose
- @ConfigOption(
- name = "Price Info (AH)",
- desc = "Show price information for auctioned items"
- )
- @ConfigEditorBoolean
- public boolean showPriceInfoAucItem = true;
-
- @Expose
- @ConfigOption(
- name = "Price info keybind",
- desc = "Only show price info if holding a key."
- )
- @ConfigEditorBoolean
- public boolean disablePriceKey = false;
-
- @Expose
- @ConfigOption(
- name = "Show Price info Keybind",
- desc = "Hold this key to show a price info tooltip"
- )
- @ConfigEditorKeybind(defaultKey = Keyboard.KEY_NONE)
- public int disablePriceKeyKeybind = Keyboard.KEY_NONE;
-
-
-
- @Expose
- @ConfigOption(
- name = "Show reforge stats",
- desc = "Show statistics a reforge stone will apply."
- )
- @ConfigEditorBoolean
- public boolean showReforgeStats = true;
-
- @Expose
- @ConfigOption(
- name = "Missing Enchant List",
- desc = "Show which enchants are missing on an item when pressing LSHIFT"
- )
- @ConfigEditorBoolean
- public boolean missingEnchantList = true;
-
- @Expose
- @ConfigOption(
- name = "Expand Pet Exp Requirement",
- desc = "Show which the full amount of pet xp required"
- )
- @ConfigEditorBoolean
- public boolean petExtendExp = false;
-
- @Expose
- @ConfigOption(
- name = "Tooltip Border Colours",
- desc = "Make the borders of tooltips match the rarity of the item (NEU Tooltips Only)"
- )
- @ConfigEditorBoolean
- public boolean tooltipBorderColours = true;
-
- @Expose
- @ConfigOption(
- name = "Tooltip Border Opacity",
- desc = "Change the opacity of the rarity highlight (NEU Tooltips Only)"
- )
- @ConfigEditorSlider(
- minValue = 0f,
- maxValue = 255f,
- minStep = 1f
- )
- public int tooltipBorderOpacity = 200;
+ @ConfigOption(
+ name = "Tooltip Price Information",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 0)
+ public boolean priceInfoAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Price Info (Auc)",
+ desc = "\u00a7rSelect what price information you would like to see on auctionable item tooltips\n" +
+ "\u00a7eDrag text to rearrange"
+ )
+ @ConfigEditorDraggableList(
+ exampleText = {
+ "\u00a7eLowest BIN",
+ "\u00a7eAH Price",
+ "\u00a7eAH Sales",
+ "\u00a7eRaw Craft Cost",
+ "\u00a7eAVG Lowest BIN",
+ "\u00a7eDungeon Costs"
+ }
+ )
+ @ConfigAccordionId(id = 0)
+ public List<Integer> priceInfoAuc = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 5));
+
+ @Expose
+ @ConfigOption(
+ name = "Price Info (Baz)",
+ desc = "\u00a7rSelect what price information you would like to see on bazaar item tooltips\n" +
+ "\u00a7eDrag text to rearrange"
+ )
+ @ConfigEditorDraggableList(
+ exampleText = {"\u00a7eBuy", "\u00a7eSell", "\u00a7eBuy (Insta)", "\u00a7eSell (Insta)", "\u00a7eRaw Craft Cost"}
+ )
+ @ConfigAccordionId(id = 0)
+ public List<Integer> priceInfoBaz = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4));
+
+ @Expose
+ @ConfigOption(
+ name = "Use Short Number Format",
+ desc = "Use Short Numbers (5.1m) instead of 5,130,302"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 0)
+ public boolean shortNumberFormatPrices = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Price Info (Inv)",
+ desc = "Show price information for items in your inventory"
+ )
+ @ConfigEditorBoolean
+ public boolean showPriceInfoInvItem = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Price Info (AH)",
+ desc = "Show price information for auctioned items"
+ )
+ @ConfigEditorBoolean
+ public boolean showPriceInfoAucItem = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Price info keybind",
+ desc = "Only show price info if holding a key."
+ )
+ @ConfigEditorBoolean
+ public boolean disablePriceKey = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Show Price info Keybind",
+ desc = "Hold this key to show a price info tooltip"
+ )
+ @ConfigEditorKeybind(defaultKey = Keyboard.KEY_NONE)
+ public int disablePriceKeyKeybind = Keyboard.KEY_NONE;
+
+ @Expose
+ @ConfigOption(
+ name = "Show reforge stats",
+ desc = "Show statistics a reforge stone will apply."
+ )
+ @ConfigEditorBoolean
+ public boolean showReforgeStats = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Hide default reforge stats",
+ desc = "Hides the reforge stats only for Legendary items that Hypixel adds to the Reforge stones"
+ )
+ @ConfigEditorBoolean
+ public boolean hideDefaultReforgeStats = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Missing Enchant List",
+ desc = "Show which enchants are missing on an item when pressing LSHIFT"
+ )
+ @ConfigEditorBoolean
+ public boolean missingEnchantList = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Expand Pet Exp Requirement",
+ desc = "Show which the full amount of pet xp required"
+ )
+ @ConfigEditorBoolean
+ public boolean petExtendExp = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Tooltip Border Colours",
+ desc = "Make the borders of tooltips match the rarity of the item (NEU Tooltips Only)"
+ )
+ @ConfigEditorBoolean
+ public boolean tooltipBorderColours = true;
+
+ @Expose
+ @ConfigOption(
+ name = "Tooltip Border Opacity",
+ desc = "Change the opacity of the rarity highlight (NEU Tooltips Only)"
+ )
+ @ConfigEditorSlider(
+ minValue = 0f,
+ maxValue = 255f,
+ minStep = 1f
+ )
+ public int tooltipBorderOpacity = 200;
} \ No newline at end of file
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TradeMenu.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TradeMenu.java
index 930316be..cb0c5dd1 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TradeMenu.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TradeMenu.java
@@ -5,23 +5,22 @@ import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditor
import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption;
public class TradeMenu {
- @Expose
- @ConfigOption(
- name = "Enable Custom Trade Menu",
- desc = "When trading with other players in skyblock, display a special GUI designed to prevent scamming"
- )
- @ConfigEditorBoolean
- public boolean enableCustomTrade = true;
+ @Expose
+ @ConfigOption(
+ name = "Enable Custom Trade Menu",
+ desc = "When trading with other players in skyblock, display a special GUI designed to prevent scamming"
+ )
+ @ConfigEditorBoolean
+ public boolean enableCustomTrade = true;
+ @Expose
+ @ConfigOption(
+ name = "Price Information",
+ desc = "Show the price of items in the trade window on both sides"
+ )
+ @ConfigEditorBoolean
+ public boolean customTradePrices = true;
- @Expose
- @ConfigOption(
- name = "Price Information",
- desc = "Show the price of items in the trade window on both sides"
- )
- @ConfigEditorBoolean
- public boolean customTradePrices = true;
-
- @Expose
- public boolean customTradePriceStyle = true;
+ @Expose
+ public boolean customTradePriceStyle = true;
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java
index 016e638b..7281eecf 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java
@@ -30,526 +30,593 @@ import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
public class AuctionSearchOverlay {
+ private static final ResourceLocation SEARCH_OVERLAY_TEXTURE = new ResourceLocation(
+ "notenoughupdates:auc_search/ah_search_overlay.png");
+ private static final ResourceLocation SEARCH_OVERLAY_TEXTURE_TAB_COMPLETED = new ResourceLocation(
+ "notenoughupdates:auc_search/ah_search_overlay_tab_completed.png");
+ private static final ResourceLocation STAR = new ResourceLocation("notenoughupdates:auc_search/star.png");
+ private static final ResourceLocation STAR_BOARD = new ResourceLocation("notenoughupdates:auc_search/star_board.png");
+
+ private static final GuiElementTextField textField = new GuiElementTextField("", 200, 20, 0);
+ private static boolean searchFieldClicked = false;
+ private static String searchString = "";
+ private static String searchStringExtra = "";
+ private static final Splitter SPACE_SPLITTER = Splitter.on(" ").omitEmptyStrings().trimResults();
+ private static boolean tabCompleted = false;
+ private static int tabCompletionIndex = -1;
- private static final ResourceLocation SEARCH_OVERLAY_TEXTURE = new ResourceLocation("notenoughupdates:auc_search/ah_search_overlay.png");
- private static final ResourceLocation SEARCH_OVERLAY_TEXTURE_TAB_COMPLETED = new ResourceLocation("notenoughupdates:auc_search/ah_search_overlay_tab_completed.png");
- private static final ResourceLocation STAR = new ResourceLocation("notenoughupdates:auc_search/star.png");
- private static final ResourceLocation STAR_BOARD = new ResourceLocation("notenoughupdates:auc_search/star_board.png");
-
- private static GuiElementTextField textField = new GuiElementTextField("", 200, 20, 0);
- private static boolean searchFieldClicked = false;
- private static String searchString = "";
- private static String searchStringExtra = "";
- private static Splitter SPACE_SPLITTER = Splitter.on(" ").omitEmptyStrings().trimResults();
- private static boolean tabCompleted = false;
- private static int tabCompletionIndex = -1;
-
- private static int selectedStars = 0;
- private static boolean atLeast = true;
-
- private static final int AUTOCOMPLETE_HEIGHT = 118;
-
- private static final Set<String> autocompletedItems = new LinkedHashSet<>();
-
- private static final Comparator<String> salesComparator = (o1, o2) -> {
- JsonObject auctionInfo1 = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfo(o1);
- JsonObject auctionInfo2 = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfo(o2);
-
- boolean auc1Invalid = auctionInfo1 == null || !auctionInfo1.has("sales");
- boolean auc2Invalid = auctionInfo2 == null || !auctionInfo2.has("sales");
-
- if(auc1Invalid && auc2Invalid) return o1.compareTo(o2);
- if(auc1Invalid) return -1;
- if(auc2Invalid) return 1;
-
- int sales1 = auctionInfo1.get("sales").getAsInt();
- int sales2 = auctionInfo2.get("sales").getAsInt();
-
- if(sales1 == sales2) return o1.compareTo(o2);
- if(sales1 > sales2) return -1;
- return 1;
- };
-
- public static boolean shouldReplace() {
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return false;
- if(!NotEnoughUpdates.INSTANCE.config.ahTweaks.enableSearchOverlay) return false;
-
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiEditSign)) {
- if(!NotEnoughUpdates.INSTANCE.config.ahTweaks.keepPreviousSearch) searchString = "";
- return false;
- }
-
- String lastContainer = SBInfo.getInstance().lastOpenContainerName;
-
- if(lastContainer == null) return false;
- if(!lastContainer.equals("Auctions Browser") && !lastContainer.startsWith("Auctions: ")) return false;
-
- TileEntitySign tes = ((GuiEditSign)Minecraft.getMinecraft().currentScreen).tileSign;
-
- if(tes == null) return false;
- if(tes.getPos().getY() != 0) return false;
- if(!tes.signText[2].getUnformattedText().equals("^^^^^^^^^^^^^^^")) return false;
- if(!tes.signText[3].getUnformattedText().equals("Enter query")) return false;
-
- return true;
- }
-
- public static void render() {
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- int width = scaledResolution.getScaledWidth();
- int height = scaledResolution.getScaledHeight();
- int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
- int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
-
- Utils.drawGradientRect(0, 0, width, height, -1072689136, -804253680);
-
- int h = NotEnoughUpdates.INSTANCE.config.ahTweaks.showPastSearches ? 219 : 145;
-
- int topY = height/4;
- if(scaledResolution.getScaleFactor() >= 4) {
- topY = height/2 - h/2 + 5;
- }
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(SEARCH_OVERLAY_TEXTURE);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(width/2-100, topY-1, 203, h, 0, 203/512f, 0, h/256f, GL11.GL_NEAREST);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(STAR_BOARD);
- Utils.drawTexturedRect(width/2+105, topY+27, 55, 13, GL11.GL_NEAREST);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(STAR);
- GlStateManager.color(1, 1, 1, 1);
- int stars = atLeast && selectedStars > 0 ? 5 : selectedStars;
- for(int i=0; i<stars; i++) {
- if(i >= selectedStars) {
- GlStateManager.color(1, 1, 1, 0.3f);
- }
- Utils.drawTexturedRect(width/2+108+10*i, topY+29, 9, 10, GL11.GL_NEAREST);
- }
-
- Gui.drawRect(width/2+106, topY+42, width/2+115, topY+51, 0xffffffff);
- Gui.drawRect(width/2+107, topY+43, width/2+114, topY+50, 0xff000000);
- if(atLeast) Gui.drawRect(width/2+108, topY+44, width/2+113, topY+49, 0xffffffff);
- Minecraft.getMinecraft().fontRendererObj.drawString("At Least?", width/2+117, topY+43, 0xffffff);
-
- Minecraft.getMinecraft().fontRendererObj.drawString("Enter Query:", width/2-100, topY-10, 0xdddddd, true);
-
- textField.setFocus(true);
- textField.setText(searchString);
- textField.setSize(149, 20);
- textField.setCustomBorderColour(0xffffff);
- textField.render(width/2-100+1, topY+1);
-
- if(textField.getText().trim().isEmpty()) autocompletedItems.clear();
-
- //Gui.drawRect(width/2-101, height/4+25, width/2+101, height/4+25+ AUTOCOMPLETE_HEIGHT, 0xffffffff);
- //Gui.drawRect(width/2-100, height/4+25+1, width/2+100, height/4+25-1+ AUTOCOMPLETE_HEIGHT, 0xff000000);
-
- List<String> tooltipToDisplay = null;
-
- int num = 0;
- synchronized(autocompletedItems) {
- String[] autoCompletedItemsArray = autocompletedItems.toArray(new String[0]);
- for (int i = 0; i < autocompletedItems.size(); i++) {
- String str = autoCompletedItemsArray[i];
- JsonObject obj = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(str);
- if (obj != null) {
- ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(obj);
- //Gui.drawRect(width/2-96, height/4+30+num*22, width/2+96, height/4+30+num*22+20, 0xff505050);
- if (i == tabCompletionIndex) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(SEARCH_OVERLAY_TEXTURE_TAB_COMPLETED);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(width / 2 - 96 + 1, topY + 30 + num * 22 + 1, 193, 21, 0 / 512f, 193 / 512f, 0, 21 / 256f, GL11.GL_NEAREST);
- } else {
- Minecraft.getMinecraft().getTextureManager().bindTexture(SEARCH_OVERLAY_TEXTURE);
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(width / 2 - 96 + 1, topY + 30 + num * 22 + 1, 193, 21, 214 / 512f, 407 / 512f, 0, 21 / 256f, GL11.GL_NEAREST);
-
- }
- String itemName = Utils.trimIgnoreColour(stack.getDisplayName().replaceAll("\\[.+]", ""));
- if (itemName.contains("Enchanted Book") && str.contains(";")) {
- String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stack.getTagCompound());
- itemName = lore[0].trim();
- }
-
- Minecraft.getMinecraft().fontRendererObj.drawString(Minecraft.getMinecraft().fontRendererObj.trimStringToWidth(itemName, 165),
- width / 2 - 74, topY + 35 + num * 22 + 1, 0xdddddd, true);
-
- GlStateManager.enableDepth();
- Utils.drawItemStack(stack, width/2-94+2, topY+32+num*22+1);
-
- if(mouseX > width/2-96 && mouseX < width/2+96 && mouseY > topY+30+num*22 && mouseY < topY+30+num*22+20) {
- tooltipToDisplay = stack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
- }
-
- if(++num >= 5) break;
- }
- }
- }
-
- if(NotEnoughUpdates.INSTANCE.config.ahTweaks.showPastSearches) {
- Minecraft.getMinecraft().fontRendererObj.drawString("Past Searches:", width/2-100, topY+25+ AUTOCOMPLETE_HEIGHT +5, 0xdddddd, true);
-
- for(int i=0; i<5; i++) {
- if(i >= NotEnoughUpdates.INSTANCE.config.hidden.previousAuctionSearches.size()) break;
-
- String s = NotEnoughUpdates.INSTANCE.config.hidden.previousAuctionSearches.get(i);
- Minecraft.getMinecraft().fontRendererObj.drawString(s, width/2-95+1, topY+45+ AUTOCOMPLETE_HEIGHT +i*10+2, 0xdddddd, true);
- }
-
- if(tooltipToDisplay != null) {
- Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, Minecraft.getMinecraft().fontRendererObj);
- }
- }
-
- }
-
- public static void close() {
- if(NotEnoughUpdates.INSTANCE.config.ahTweaks.keepPreviousSearch) {
- search();
- } else {
- synchronized(autocompletedItems) {
- autocompletedItems.clear();
- }
- }
-
-
- TileEntitySign tes = ((GuiEditSign)Minecraft.getMinecraft().currentScreen).tileSign;
-
- String search = searchString.trim();
- if(searchStringExtra != null && !searchStringExtra.isEmpty()) {
- search += " " + searchStringExtra.trim();
- }
- if(search.length() <= 15) {
- tes.signText[0] = new ChatComponentText(search.substring(0, Math.min(search.length(), 15)));
- } else {
- List<String> words = SPACE_SPLITTER.splitToList(search);
-
- StringBuilder line0 = new StringBuilder();
- StringBuilder line1 = new StringBuilder();
-
- int currentLine = 0;
- for(String word : words) {
- if(currentLine == 0) {
- if(line0.length() + word.length() > 15) {
- currentLine++;
- } else {
- line0.append(word);
- if(line0.length() >= 15) {
- currentLine++;
- continue;
- } else {
- line0.append(" ");
- }
- }
- }
- if(currentLine == 1) {
- if(line1.length() + word.length() > 15) {
- line1.append(word, 0, 15 - line1.length());
- break;
- } else {
- line1.append(word);
- if(line1.length() >= 15) {
- break;
- } else {
- line1.append(" ");
- }
- }
- }
- if(line1.length() >= 15) break;
- }
-
- tes.signText[0] = new ChatComponentText(line0.toString().trim());
- tes.signText[1] = new ChatComponentText(line1.toString().trim());
- }
-
- if(!searchString.trim().isEmpty()) {
- List<String> previousAuctionSearches = NotEnoughUpdates.INSTANCE.config.hidden.previousAuctionSearches;
- previousAuctionSearches.remove(searchString);
- previousAuctionSearches.remove(searchString);
- previousAuctionSearches.add(0, searchString);
- while(previousAuctionSearches.size() > 5) {
- previousAuctionSearches.remove(previousAuctionSearches.size()-1);
- }
- }
-
- Minecraft.getMinecraft().displayGuiScreen(null);
-
- if (Minecraft.getMinecraft().currentScreen == null) {
- Minecraft.getMinecraft().setIngameFocus();
- }
- }
-
- private static ExecutorService searchES = Executors.newSingleThreadExecutor();
- private static AtomicInteger searchId = new AtomicInteger(0);
-
- private static String getItemIdAtIndex(int i) {
- if (!autocompletedItems.isEmpty()) {
- if ((i > autocompletedItems.size() - 1) || i < 0 || i > 4) {
- return "";
- }
- String searchString = autocompletedItems.toArray()[i].toString();
- JsonObject repoObject = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(searchString);
- String displayname = repoObject.get("displayname").getAsString();
- if (displayname.contains("Enchanted Book")) {
- String lore = repoObject.get("lore").getAsJsonArray().get(0).getAsString();
- String name = lore.substring(0, lore.lastIndexOf(" "));
- return Utils.cleanColour(name);
- } else {
- return Utils.cleanColour(displayname);
- }
- } else {
- return null;
- }
- }
-
- public static void search() {
- final int thisSearchId = searchId.incrementAndGet();
-
- searchES.submit(() -> {
- if (thisSearchId != searchId.get()) return;
-
- List<String> title = new ArrayList<>(NotEnoughUpdates.INSTANCE.manager.search("title:" + searchString.trim()));
-
- if (thisSearchId != searchId.get()) return;
-
- if(!searchString.trim().contains(" ")) {
- StringBuilder sb = new StringBuilder();
- for(char c : searchString.toCharArray()) {
- sb.append(c).append(" ");
- }
- title.addAll(NotEnoughUpdates.INSTANCE.manager.search("title:"+sb.toString().trim()));
- }
-
- if(thisSearchId != searchId.get()) return;
-
- List<String> desc = new ArrayList<>(NotEnoughUpdates.INSTANCE.manager.search("desc:"+searchString.trim()));
- desc.removeAll(title);
-
- if(thisSearchId != searchId.get()) return;
-
- Set<String> auctionableItems = NotEnoughUpdates.INSTANCE.manager.auctionManager.getLowestBinKeySet();
- auctionableItems.addAll(NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfoKeySet());
-
- if(!auctionableItems.isEmpty()) {
- title.retainAll(auctionableItems);
- desc.retainAll(auctionableItems);
-
- title.sort(salesComparator);
- desc.sort(salesComparator);
- } else {
- Set<String> bazaarItems = NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarKeySet();
-
- title.removeAll(bazaarItems);
- desc.removeAll(bazaarItems);
- }
-
- if(thisSearchId != searchId.get()) return;
-
- synchronized(autocompletedItems) {
- autocompletedItems.clear();
- autocompletedItems.addAll(title);
- autocompletedItems.addAll(desc);
- }
- });
- }
-
- public static void keyEvent() {
- if(Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
- searchStringExtra = "";
- close();
- if(NotEnoughUpdates.INSTANCE.config.ahTweaks.escFullClose) {
- Minecraft.getMinecraft().thePlayer.sendQueue.addToSendQueue(new C0DPacketCloseWindow(Minecraft.getMinecraft().thePlayer.openContainer.windowId));
- }
- } else if(Keyboard.getEventKey() == Keyboard.KEY_RETURN) {
- searchStringExtra = "";
- close();
- } else if(Keyboard.getEventKey() == Keyboard.KEY_TAB) {
- //autocomplete to first item in the list
- tabCompleted = true;
- String id = getItemIdAtIndex(0);
- if (id == null) {
- tabCompleted = false;
- textField.setFocus(true);
- textField.setText(searchString);
- } else {
- tabCompletionIndex = 0;
- searchString = id;
- }
- } else if(Keyboard.getEventKeyState()) {
- if (tabCompleted) {
- String id;
- switch (Keyboard.getEventKey()) {
- case Keyboard.KEY_DOWN:
- id = getItemIdAtIndex(tabCompletionIndex + 1);
- if (id == null) {
- textField.setFocus(true);
- textField.setText(searchString);
- tabCompleted = false;
- tabCompletionIndex = -1;
- } else if (id.equals("")) {
- //At the end of the autocompletion List, do nothing
- return;
- } else {
- searchString = id;
- tabCompletionIndex += 1;
- return;
- }
- break;
- case Keyboard.KEY_UP:
- id = getItemIdAtIndex(tabCompletionIndex - 1);
- if (id == null) {
- textField.setFocus(true);
- textField.setText(searchString);
- tabCompleted = false;
- tabCompletionIndex = -1;
- } else if (id.equals("")) {
- //At the end of the autocompletion List, do nothing
- return;
- } else {
- searchString = id;
- tabCompletionIndex -= 1;
- return;
- }
- break;
- default:
- tabCompletionIndex = -1;
- tabCompleted = false;
- }
- }
- textField.setFocus(true);
- textField.setText(searchString);
- textField.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey());
- searchString = textField.getText();
-
- search();
- }
- }
-
- public static void mouseEvent() {
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- int width = scaledResolution.getScaledWidth();
- int height = scaledResolution.getScaledHeight();
- int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
- int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
-
- int h = NotEnoughUpdates.INSTANCE.config.ahTweaks.showPastSearches ? 219 : 145;
-
- int topY = height/4;
- if(scaledResolution.getScaleFactor() >= 4) {
- topY = height/2 - h/2 + 5;
- }
-
- if(Mouse.getEventButtonState() && mouseX > width/2+105 && mouseX < width/2+105+55 &&
- mouseY > topY+27 && mouseY < topY+40) {
- int starClicked = 5;
- for(int i=1; i<=5; i++) {
- if(mouseX < width/2+108+10*i) {
- starClicked = i;
- break;
- }
- }
- if(selectedStars == starClicked) {
- selectedStars = 0;
- } else {
- selectedStars = starClicked;
- }
- return;
- }
-
- if(Mouse.getEventButtonState() && mouseX >= width/2+106 && mouseX <= width/2+116 &&
- mouseY >= topY+42 && mouseY <= topY+50) {
- atLeast = !atLeast;
- return;
- }
-
- if(!Mouse.getEventButtonState() && Mouse.getEventButton() == -1 && searchFieldClicked) {
- textField.mouseClickMove(mouseX-2, topY+10, 0, 0);
- }
-
- if(Mouse.getEventButton() != -1) {
- searchFieldClicked = false;
- }
-
- if(Mouse.getEventButtonState()) {
- if(mouseY > topY && mouseY < topY+20) {
- if(mouseX > width/2-100) {
- if(mouseX < width/2+49) {
- searchFieldClicked = true;
- textField.mouseClicked(mouseX-2, mouseY, Mouse.getEventButton());
-
- if(Mouse.getEventButton() == 1) {
- searchString = "";
- synchronized(autocompletedItems) {
- autocompletedItems.clear();
- }
- }
- } else if(mouseX < width/2+75) {
- searchStringExtra = "";
- close();
- } else if(mouseX < width/2+100) {
- searchStringExtra = "";
- close();
- Minecraft.getMinecraft().thePlayer.sendQueue.addToSendQueue(new C0DPacketCloseWindow(Minecraft.getMinecraft().thePlayer.openContainer.windowId));
- NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper(new NEUConfigEditor(
- NotEnoughUpdates.INSTANCE.config, "AH Search GUI"));
- }
- }
- } else if(Mouse.getEventButton() == 0) {
- int num = 0;
- synchronized(autocompletedItems) {
- for(String str : autocompletedItems) {
- JsonObject obj = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(str);
- if(obj != null) {
- ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(obj);
- if(mouseX >= width/2-96 && mouseX <= width/2+96 && mouseY >= topY+30+num*22 && mouseY <= topY+30+num*22+20) {
- searchString = Utils.cleanColour(stack.getDisplayName().replaceAll("\\[.+]", "")).trim();
- if(searchString.contains("Enchanted Book") && str.contains(";")) {
- String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stack.getTagCompound());
- String[] split = Utils.cleanColour(lore[0]).trim().split(" ");
- split[split.length-1] = "";
-
- searchString = StringUtils.join(split, " ").trim();
- }
-
- JsonObject essenceCosts = Constants.ESSENCECOSTS;
- searchStringExtra = "";
- if(essenceCosts != null && essenceCosts.has(str) && selectedStars > 0) {
- for(int i=0; i<selectedStars; i++) {
- searchStringExtra += "\u272A";
- }
- if(selectedStars < 5 && !atLeast) {
- searchStringExtra += " ";
- searchStringExtra += stack.getItem().getItemStackDisplayName(stack).substring(0, 1);
- }
- }
-
- close();
- return;
- }
-
- if(++num >= 5) break;
- }
- }
- }
-
- if(NotEnoughUpdates.INSTANCE.config.ahTweaks.showPastSearches) {
- for(int i=0; i<5; i++) {
- if(i >= NotEnoughUpdates.INSTANCE.config.hidden.previousAuctionSearches.size()) break;
-
- String s = NotEnoughUpdates.INSTANCE.config.hidden.previousAuctionSearches.get(i);
- if(mouseX >= width/2-95 && mouseX <= width/2+95 && mouseY >= topY+45+AUTOCOMPLETE_HEIGHT+i*10 && mouseY <= topY+45+AUTOCOMPLETE_HEIGHT+i*10+10) {
- searchString = s;
- searchStringExtra = "";
- close();
- return;
- }
- }
- }
- }
- }
-
-
- }
+ private static int selectedStars = 0;
+ private static boolean atLeast = true;
+ private static final int AUTOCOMPLETE_HEIGHT = 118;
+
+ private static final Set<String> autocompletedItems = new LinkedHashSet<>();
+
+ private static final Comparator<String> salesComparator = (o1, o2) -> {
+ JsonObject auctionInfo1 = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfo(o1);
+ JsonObject auctionInfo2 = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfo(o2);
+
+ boolean auc1Invalid = auctionInfo1 == null || !auctionInfo1.has("sales");
+ boolean auc2Invalid = auctionInfo2 == null || !auctionInfo2.has("sales");
+
+ if (auc1Invalid && auc2Invalid) return o1.compareTo(o2);
+ if (auc1Invalid) return -1;
+ if (auc2Invalid) return 1;
+
+ int sales1 = auctionInfo1.get("sales").getAsInt();
+ int sales2 = auctionInfo2.get("sales").getAsInt();
+
+ if (sales1 == sales2) return o1.compareTo(o2);
+ if (sales1 > sales2) return -1;
+ return 1;
+ };
+
+ public static boolean shouldReplace() {
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return false;
+ if (!NotEnoughUpdates.INSTANCE.config.ahTweaks.enableSearchOverlay) return false;
+
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiEditSign)) {
+ if (!NotEnoughUpdates.INSTANCE.config.ahTweaks.keepPreviousSearch) searchString = "";
+ return false;
+ }
+
+ String lastContainer = SBInfo.getInstance().lastOpenContainerName;
+
+ if (lastContainer == null) return false;
+ if (!lastContainer.equals("Auctions Browser") && !lastContainer.startsWith("Auctions: ")) return false;
+
+ TileEntitySign tes = ((GuiEditSign) Minecraft.getMinecraft().currentScreen).tileSign;
+
+ if (tes == null) return false;
+ if (tes.getPos().getY() != 0) return false;
+ if (!tes.signText[2].getUnformattedText().equals("^^^^^^^^^^^^^^^")) return false;
+ return tes.signText[3].getUnformattedText().equals("Enter query");
+ }
+
+ public static void render() {
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ int width = scaledResolution.getScaledWidth();
+ int height = scaledResolution.getScaledHeight();
+ int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
+ int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
+
+ Utils.drawGradientRect(0, 0, width, height, -1072689136, -804253680);
+
+ int h = NotEnoughUpdates.INSTANCE.config.ahTweaks.showPastSearches ? 219 : 145;
+
+ int topY = height / 4;
+ if (scaledResolution.getScaleFactor() >= 4) {
+ topY = height / 2 - h / 2 + 5;
+ }
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(SEARCH_OVERLAY_TEXTURE);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(width / 2 - 100, topY - 1, 203, h, 0, 203 / 512f, 0, h / 256f, GL11.GL_NEAREST);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(STAR_BOARD);
+ Utils.drawTexturedRect(width / 2 + 105, topY + 27, 55, 13, GL11.GL_NEAREST);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(STAR);
+ GlStateManager.color(1, 1, 1, 1);
+ int stars = atLeast && selectedStars > 0 ? 5 : selectedStars;
+ for (int i = 0; i < stars; i++) {
+ if (i >= selectedStars) {
+ GlStateManager.color(1, 1, 1, 0.3f);
+ }
+ Utils.drawTexturedRect(width / 2 + 108 + 10 * i, topY + 29, 9, 10, GL11.GL_NEAREST);
+ }
+
+ Gui.drawRect(width / 2 + 106, topY + 42, width / 2 + 115, topY + 51, 0xffffffff);
+ Gui.drawRect(width / 2 + 107, topY + 43, width / 2 + 114, topY + 50, 0xff000000);
+ if (atLeast) Gui.drawRect(width / 2 + 108, topY + 44, width / 2 + 113, topY + 49, 0xffffffff);
+ Minecraft.getMinecraft().fontRendererObj.drawString("At Least?", width / 2 + 117, topY + 43, 0xffffff);
+
+ Minecraft.getMinecraft().fontRendererObj.drawString("Enter Query:", width / 2 - 100, topY - 10, 0xdddddd, true);
+
+ textField.setFocus(true);
+ textField.setText(searchString);
+ textField.setSize(149, 20);
+ textField.setCustomBorderColour(0xffffff);
+ textField.render(width / 2 - 100 + 1, topY + 1);
+
+ if (textField.getText().trim().isEmpty()) autocompletedItems.clear();
+
+ //Gui.drawRect(width/2-101, height/4+25, width/2+101, height/4+25+ AUTOCOMPLETE_HEIGHT, 0xffffffff);
+ //Gui.drawRect(width/2-100, height/4+25+1, width/2+100, height/4+25-1+ AUTOCOMPLETE_HEIGHT, 0xff000000);
+
+ List<String> tooltipToDisplay = null;
+
+ int num = 0;
+ synchronized (autocompletedItems) {
+ String[] autoCompletedItemsArray = autocompletedItems.toArray(new String[0]);
+ for (int i = 0; i < autoCompletedItemsArray.length; i++) {
+ String str = autoCompletedItemsArray[i];
+ JsonObject obj = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(str);
+ if (obj != null) {
+ ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(obj);
+ //Gui.drawRect(width/2-96, height/4+30+num*22, width/2+96, height/4+30+num*22+20, 0xff505050);
+ if (i == tabCompletionIndex) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(SEARCH_OVERLAY_TEXTURE_TAB_COMPLETED);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(
+ width / 2 - 96 + 1,
+ topY + 30 + num * 22 + 1,
+ 193,
+ 21,
+ 0 / 512f,
+ 193 / 512f,
+ 0,
+ 21 / 256f,
+ GL11.GL_NEAREST
+ );
+ } else {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(SEARCH_OVERLAY_TEXTURE);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(
+ width / 2 - 96 + 1,
+ topY + 30 + num * 22 + 1,
+ 193,
+ 21,
+ 214 / 512f,
+ 407 / 512f,
+ 0,
+ 21 / 256f,
+ GL11.GL_NEAREST
+ );
+
+ }
+ String itemName = Utils.trimIgnoreColour(stack.getDisplayName().replaceAll("\\[.+]", ""));
+ if (itemName.contains("Enchanted Book") && str.contains(";")) {
+ String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stack.getTagCompound());
+ itemName = lore[0].trim();
+ }
+
+ Minecraft.getMinecraft().fontRendererObj.drawString(Minecraft.getMinecraft().fontRendererObj.trimStringToWidth(
+ itemName,
+ 165
+ ),
+ width / 2 - 74, topY + 35 + num * 22 + 1, 0xdddddd, true
+ );
+
+ GlStateManager.enableDepth();
+ Utils.drawItemStack(stack, width / 2 - 94 + 2, topY + 32 + num * 22 + 1);
+
+ if (mouseX > width / 2 - 96 && mouseX < width / 2 + 96 && mouseY > topY + 30 + num * 22 &&
+ mouseY < topY + 30 + num * 22 + 20) {
+ tooltipToDisplay = stack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ }
+
+ if (++num >= 5) break;
+ }
+ }
+ }
+
+ if (NotEnoughUpdates.INSTANCE.config.ahTweaks.showPastSearches) {
+ Minecraft.getMinecraft().fontRendererObj.drawString(
+ "Past Searches:",
+ width / 2 - 100,
+ topY + 25 + AUTOCOMPLETE_HEIGHT + 5,
+ 0xdddddd,
+ true
+ );
+
+ for (int i = 0; i < 5; i++) {
+ if (i >= NotEnoughUpdates.INSTANCE.config.hidden.previousAuctionSearches.size()) break;
+
+ String s = NotEnoughUpdates.INSTANCE.config.hidden.previousAuctionSearches.get(i);
+ Minecraft.getMinecraft().fontRendererObj.drawString(
+ s,
+ width / 2 - 95 + 1,
+ topY + 45 + AUTOCOMPLETE_HEIGHT + i * 10 + 2,
+ 0xdddddd,
+ true
+ );
+ }
+
+ if (tooltipToDisplay != null) {
+ Utils.drawHoveringText(
+ tooltipToDisplay,
+ mouseX,
+ mouseY,
+ width,
+ height,
+ -1,
+ Minecraft.getMinecraft().fontRendererObj
+ );
+ }
+ }
+
+ }
+
+ private static final ExecutorService searchES = Executors.newSingleThreadExecutor();
+ private static final AtomicInteger searchId = new AtomicInteger(0);
+
+ private static String getItemIdAtIndex(int i) {
+ if (!autocompletedItems.isEmpty()) {
+ if ((i > autocompletedItems.size() - 1) || i < 0 || i > 4) {
+ return "";
+ }
+ String searchString = autocompletedItems.toArray()[i].toString();
+ JsonObject repoObject = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(searchString);
+ String displayname = repoObject.get("displayname").getAsString();
+ if (displayname.contains("Enchanted Book")) {
+ String lore = repoObject.get("lore").getAsJsonArray().get(0).getAsString();
+ String name = lore.substring(0, lore.lastIndexOf(" "));
+ return Utils.cleanColour(name);
+ } else {
+ return Utils.cleanColour(displayname);
+ }
+ } else {
+ return null;
+ }
+ }
+
+ public static void close() {
+ if (tabCompleted) {
+ tabCompletionIndex = -1;
+ tabCompleted = false;
+ }
+ if (NotEnoughUpdates.INSTANCE.config.ahTweaks.keepPreviousSearch) {
+ search();
+ } else {
+ synchronized (autocompletedItems) {
+ autocompletedItems.clear();
+ }
+ }
+
+ TileEntitySign tes = ((GuiEditSign) Minecraft.getMinecraft().currentScreen).tileSign;
+
+ String search = searchString.trim();
+ if (searchStringExtra != null && !searchStringExtra.isEmpty()) {
+ search += " " + searchStringExtra.trim();
+ }
+ if (search.length() <= 15) {
+ tes.signText[0] = new ChatComponentText(search.substring(0, Math.min(search.length(), 15)));
+ } else {
+ List<String> words = SPACE_SPLITTER.splitToList(search);
+
+ StringBuilder line0 = new StringBuilder();
+ StringBuilder line1 = new StringBuilder();
+
+ int currentLine = 0;
+ for (String word : words) {
+ if (currentLine == 0) {
+ if (line0.length() + word.length() > 15) {
+ currentLine++;
+ } else {
+ line0.append(word);
+ if (line0.length() >= 15) {
+ currentLine++;
+ continue;
+ } else {
+ line0.append(" ");
+ }
+ }
+ }
+ if (currentLine == 1) {
+ if (line1.length() + word.length() > 15) {
+ line1.append(word, 0, 15 - line1.length());
+ break;
+ } else {
+ line1.append(word);
+ if (line1.length() >= 15) {
+ break;
+ } else {
+ line1.append(" ");
+ }
+ }
+ }
+ if (line1.length() >= 15) break;
+ }
+
+ tes.signText[0] = new ChatComponentText(line0.toString().trim());
+ tes.signText[1] = new ChatComponentText(line1.toString().trim());
+ }
+
+ if (!searchString.trim().isEmpty()) {
+ List<String> previousAuctionSearches = NotEnoughUpdates.INSTANCE.config.hidden.previousAuctionSearches;
+ previousAuctionSearches.remove(searchString);
+ previousAuctionSearches.remove(searchString);
+ previousAuctionSearches.add(0, searchString);
+ while (previousAuctionSearches.size() > 5) {
+ previousAuctionSearches.remove(previousAuctionSearches.size() - 1);
+ }
+ }
+
+ Minecraft.getMinecraft().displayGuiScreen(null);
+
+ if (Minecraft.getMinecraft().currentScreen == null) {
+ Minecraft.getMinecraft().setIngameFocus();
+ }
+ }
+
+ private static boolean updateTabCompletedSearch(int key) {
+ String id;
+ if (key == Keyboard.KEY_DOWN || key == Keyboard.KEY_TAB) {
+ id = getItemIdAtIndex(tabCompletionIndex + 1);
+ if (id == null) {
+ textField.setFocus(true);
+ textField.setText(searchString);
+ tabCompleted = false;
+ tabCompletionIndex = -1;
+ return true;
+ } else if (id.equals("")) {
+ tabCompletionIndex = 0;
+ return true;
+ } else {
+ searchString = id;
+ tabCompletionIndex += 1;
+ return true;
+ }
+ } else if (key == Keyboard.KEY_UP) {
+ id = getItemIdAtIndex(tabCompletionIndex - 1);
+ if (id == null) {
+ textField.setFocus(true);
+ textField.setText(searchString);
+ tabCompleted = false;
+ tabCompletionIndex = -1;
+ return true;
+ } else if (id.equals("")) {
+ if (autocompletedItems.size() > 4) tabCompletionIndex = 4;
+ else tabCompletionIndex = autocompletedItems.size() - 1;
+ tabCompletionIndex = autocompletedItems.size() - 1;
+ return true;
+ } else {
+ searchString = id;
+ tabCompletionIndex -= 1;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static void search() {
+ final int thisSearchId = searchId.incrementAndGet();
+
+ searchES.submit(() -> {
+ if (thisSearchId != searchId.get()) return;
+
+ List<String> title = new ArrayList<>(NotEnoughUpdates.INSTANCE.manager.search("title:" + searchString.trim()));
+
+ if (thisSearchId != searchId.get()) return;
+
+ if (!searchString.trim().contains(" ")) {
+ StringBuilder sb = new StringBuilder();
+ for (char c : searchString.toCharArray()) {
+ sb.append(c).append(" ");
+ }
+ title.addAll(NotEnoughUpdates.INSTANCE.manager.search("title:" + sb.toString().trim()));
+ }
+
+ if (thisSearchId != searchId.get()) return;
+
+ List<String> desc = new ArrayList<>(NotEnoughUpdates.INSTANCE.manager.search("desc:" + searchString.trim()));
+ desc.removeAll(title);
+
+ if (thisSearchId != searchId.get()) return;
+
+ Set<String> auctionableItems = NotEnoughUpdates.INSTANCE.manager.auctionManager.getLowestBinKeySet();
+ auctionableItems.addAll(NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfoKeySet());
+
+ if (!auctionableItems.isEmpty()) {
+ title.retainAll(auctionableItems);
+ desc.retainAll(auctionableItems);
+
+ title.sort(salesComparator);
+ desc.sort(salesComparator);
+ } else {
+ Set<String> bazaarItems = NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarKeySet();
+
+ title.removeAll(bazaarItems);
+ desc.removeAll(bazaarItems);
+ }
+
+ if (thisSearchId != searchId.get()) return;
+
+ synchronized (autocompletedItems) {
+ autocompletedItems.clear();
+ autocompletedItems.addAll(title);
+ autocompletedItems.addAll(desc);
+ }
+ });
+ }
+
+ public static void keyEvent() {
+ boolean ignoreKey = false;
+
+ if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
+ searchStringExtra = "";
+ close();
+ if (NotEnoughUpdates.INSTANCE.config.ahTweaks.escFullClose) {
+ Minecraft.getMinecraft().thePlayer.sendQueue.addToSendQueue(new C0DPacketCloseWindow(Minecraft.getMinecraft().thePlayer.openContainer.windowId));
+ }
+ return;
+ } else if (Keyboard.getEventKey() == Keyboard.KEY_RETURN) {
+ searchStringExtra = "";
+ close();
+ return;
+ } else if (Keyboard.getEventKey() == Keyboard.KEY_TAB) {
+ //autocomplete to first item in the list
+ if (!tabCompleted) {
+ tabCompleted = true;
+ ignoreKey = true;
+ String id = getItemIdAtIndex(0);
+ if (id == null) {
+ tabCompleted = false;
+ textField.setFocus(true);
+ textField.setText(searchString);
+ } else {
+ tabCompletionIndex = 0;
+ searchString = id;
+ }
+ }
+ }
+
+ if (Keyboard.getEventKeyState()) {
+ if (tabCompleted) {
+ if (!ignoreKey) {
+ boolean success = updateTabCompletedSearch(Keyboard.getEventKey());
+ if (success) return;
+ textField.setFocus(true);
+ textField.setText(searchString);
+ tabCompleted = false;
+ tabCompletionIndex = -1;
+ } else return;
+
+ }
+ textField.setFocus(true);
+ textField.setText(searchString);
+ textField.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey());
+ searchString = textField.getText();
+
+ search();
+ }
+ }
+
+ public static void mouseEvent() {
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ int width = scaledResolution.getScaledWidth();
+ int height = scaledResolution.getScaledHeight();
+ int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
+ int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
+
+ int h = NotEnoughUpdates.INSTANCE.config.ahTweaks.showPastSearches ? 219 : 145;
+
+ int topY = height / 4;
+ if (scaledResolution.getScaleFactor() >= 4) {
+ topY = height / 2 - h / 2 + 5;
+ }
+
+ if (Mouse.getEventButtonState() && mouseX > width / 2 + 105 && mouseX < width / 2 + 105 + 55 &&
+ mouseY > topY + 27 && mouseY < topY + 40) {
+ int starClicked = 5;
+ for (int i = 1; i <= 5; i++) {
+ if (mouseX < width / 2 + 108 + 10 * i) {
+ starClicked = i;
+ break;
+ }
+ }
+ if (selectedStars == starClicked) {
+ selectedStars = 0;
+ } else {
+ selectedStars = starClicked;
+ }
+ return;
+ }
+
+ if (Mouse.getEventButtonState() && mouseX >= width / 2 + 106 && mouseX <= width / 2 + 116 &&
+ mouseY >= topY + 42 && mouseY <= topY + 50) {
+ atLeast = !atLeast;
+ return;
+ }
+
+ if (!Mouse.getEventButtonState() && Mouse.getEventButton() == -1 && searchFieldClicked) {
+ textField.mouseClickMove(mouseX - 2, topY + 10, 0, 0);
+ }
+
+ if (Mouse.getEventButton() != -1) {
+ searchFieldClicked = false;
+ }
+
+ if (Mouse.getEventButtonState()) {
+ if (mouseY > topY && mouseY < topY + 20) {
+ if (mouseX > width / 2 - 100) {
+ if (mouseX < width / 2 + 49) {
+ searchFieldClicked = true;
+ textField.mouseClicked(mouseX - 2, mouseY, Mouse.getEventButton());
+
+ if (Mouse.getEventButton() == 1) {
+ searchString = "";
+ synchronized (autocompletedItems) {
+ autocompletedItems.clear();
+ }
+ }
+ } else if (mouseX < width / 2 + 75) {
+ searchStringExtra = "";
+ close();
+ } else if (mouseX < width / 2 + 100) {
+ searchStringExtra = "";
+ close();
+ Minecraft.getMinecraft().thePlayer.sendQueue.addToSendQueue(new C0DPacketCloseWindow(Minecraft.getMinecraft().thePlayer.openContainer.windowId));
+ NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper(new NEUConfigEditor(
+ NotEnoughUpdates.INSTANCE.config, "AH Search GUI"));
+ }
+ }
+ } else if (Mouse.getEventButton() == 0) {
+ int num = 0;
+ synchronized (autocompletedItems) {
+ for (String str : autocompletedItems) {
+ JsonObject obj = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(str);
+ if (obj != null) {
+ ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(obj);
+ if (mouseX >= width / 2 - 96 && mouseX <= width / 2 + 96 && mouseY >= topY + 30 + num * 22 &&
+ mouseY <= topY + 30 + num * 22 + 20) {
+ searchString = Utils.cleanColour(stack.getDisplayName().replaceAll("\\[.+]", "")).trim();
+ if (searchString.contains("Enchanted Book") && str.contains(";")) {
+ String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stack.getTagCompound());
+ String[] split = Utils.cleanColour(lore[0]).trim().split(" ");
+ split[split.length - 1] = "";
+
+ searchString = StringUtils.join(split, " ").trim();
+ }
+
+ JsonObject essenceCosts = Constants.ESSENCECOSTS;
+ searchStringExtra = "";
+ if (essenceCosts != null && essenceCosts.has(str) && selectedStars > 0) {
+ for (int i = 0; i < selectedStars; i++) {
+ searchStringExtra += "\u272A";
+ }
+ if (selectedStars < 5 && !atLeast) {
+ searchStringExtra += " ";
+ searchStringExtra += stack.getItem().getItemStackDisplayName(stack).substring(0, 1);
+ }
+ }
+
+ close();
+ return;
+ }
+
+ if (++num >= 5) break;
+ }
+ }
+ }
+
+ if (NotEnoughUpdates.INSTANCE.config.ahTweaks.showPastSearches) {
+ for (int i = 0; i < 5; i++) {
+ if (i >= NotEnoughUpdates.INSTANCE.config.hidden.previousAuctionSearches.size()) break;
+
+ String s = NotEnoughUpdates.INSTANCE.config.hidden.previousAuctionSearches.get(i);
+ if (mouseX >= width / 2 - 95 && mouseX <= width / 2 + 95 &&
+ mouseY >= topY + 45 + AUTOCOMPLETE_HEIGHT + i * 10 &&
+ mouseY <= topY + 45 + AUTOCOMPLETE_HEIGHT + i * 10 + 10) {
+ searchString = s;
+ searchStringExtra = "";
+ close();
+ return;
+ }
+ }
+ }
+ }
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/BonemerangOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/BonemerangOverlay.java
index 80bc9855..aa8a15ce 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/BonemerangOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/BonemerangOverlay.java
@@ -17,95 +17,105 @@ import org.lwjgl.util.vector.Vector3f;
import java.util.*;
import java.util.function.Supplier;
-import static net.minecraft.util.EnumChatFormatting.DARK_AQUA;
-
public class BonemerangOverlay extends TextOverlay {
- public BonemerangOverlay(Position position, Supplier<List<String>> dummyStrings, Supplier<TextOverlayStyle> styleSupplier) {
- super(position, dummyStrings, styleSupplier);
- INSTANCE = this;
- }
-
- public static BonemerangOverlay INSTANCE;
-
- public final Set<EntityLivingBase> bonemeragedEntities = new HashSet<>();
-
- @Override
- public void updateFrequent() {
- if(NotEnoughUpdates.INSTANCE.config.itemOverlays.bonemerangFastUpdate){
- updateOverlay();
- }
- }
-
- @Override
- public void update() {
- if(!NotEnoughUpdates.INSTANCE.config.itemOverlays.bonemerangFastUpdate){
- updateOverlay();
- }
- }
-
- private void updateOverlay(){
- if(!NotEnoughUpdates.INSTANCE.config.itemOverlays.enableBonemerangOverlay && NotEnoughUpdates.INSTANCE.config.itemOverlays.highlightTargeted){
- overlayStrings = null;
- return;
- }
- overlayStrings = new ArrayList<>();
-
-
- bonemeragedEntities.clear();
- if(Minecraft.getMinecraft().thePlayer == null) return;
- if(Minecraft.getMinecraft().theWorld == null) return;
-
- ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem();
-
- String internal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held);
-
- if(internal != null && internal.equals("BONE_BOOMERANG")) {
- HashMap<Integer, String> map = new HashMap<>();
-
- EntityPlayerSP p = Minecraft.getMinecraft().thePlayer;
- float stepSize = 0.15f;
- float bonemerangDistance = 15;
-
- Vector3f position = new Vector3f((float)p.posX, (float)p.posY + p.getEyeHeight(), (float)p.posZ);
- Vec3 look = p.getLook(0);
-
- Vector3f step = new Vector3f((float)look.xCoord, (float)look.yCoord, (float)look.zCoord);
- step.scale(stepSize / step.length());
-
- for(int i=0; i<Math.floor(bonemerangDistance/stepSize)-2; i++) {
- AxisAlignedBB bb = new AxisAlignedBB(position.x - 0.75f, position.y - 0.1, position.z - 0.75f,
- position.x + 0.75f, position.y + 0.25, position.z + 0.75);
-
- BlockPos blockPos = new BlockPos(position.x, position.y, position.z);
-
- if(!Minecraft.getMinecraft().theWorld.isAirBlock(blockPos) &&
- Minecraft.getMinecraft().theWorld.getBlockState(blockPos).getBlock().isFullCube()) {
- map.put(0, EnumChatFormatting.RED + "Bonemerang will break!");
- break;
- }
-
- List<Entity> entities = Minecraft.getMinecraft().theWorld.getEntitiesWithinAABBExcludingEntity(Minecraft.getMinecraft().thePlayer, bb);
- for (Entity entity : entities) {
- if (entity instanceof EntityLivingBase && !(entity instanceof EntityArmorStand) && !entity.isInvisible()) {
- if (!bonemeragedEntities.contains(entity)) {
- bonemeragedEntities.add((EntityLivingBase) entity);
- }
- }
- }
-
- position.translate(step.x, step.y, step.z);
- }
- if(NotEnoughUpdates.INSTANCE.config.itemOverlays.enableBonemerangOverlay) {
- map.put(1, EnumChatFormatting.GRAY + "Targets: " + EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + bonemeragedEntities.size());
- for (int index : NotEnoughUpdates.INSTANCE.config.itemOverlays.bonemerangOverlayText) {
- if (map.containsKey(index)) {
- overlayStrings.add(map.get(index));
- }
- }
- }
-
- }
-
- if(overlayStrings.isEmpty()) overlayStrings = null;
- }
+ public BonemerangOverlay(
+ Position position,
+ Supplier<List<String>> dummyStrings,
+ Supplier<TextOverlayStyle> styleSupplier
+ ) {
+ super(position, dummyStrings, styleSupplier);
+ INSTANCE = this;
+ }
+
+ public static BonemerangOverlay INSTANCE;
+
+ public final Set<EntityLivingBase> bonemeragedEntities = new HashSet<>();
+
+ @Override
+ public void updateFrequent() {
+ if (NotEnoughUpdates.INSTANCE.config.itemOverlays.bonemerangFastUpdate) {
+ updateOverlay();
+ }
+ }
+
+ @Override
+ public void update() {
+ if (!NotEnoughUpdates.INSTANCE.config.itemOverlays.bonemerangFastUpdate) {
+ updateOverlay();
+ }
+ }
+
+ private void updateOverlay() {
+ if (!NotEnoughUpdates.INSTANCE.config.itemOverlays.enableBonemerangOverlay &&
+ NotEnoughUpdates.INSTANCE.config.itemOverlays.highlightTargeted) {
+ overlayStrings = null;
+ return;
+ }
+ overlayStrings = new ArrayList<>();
+
+ bonemeragedEntities.clear();
+ if (Minecraft.getMinecraft().thePlayer == null) return;
+ if (Minecraft.getMinecraft().theWorld == null) return;
+
+ ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem();
+
+ String internal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held);
+
+ if (internal != null && internal.equals("BONE_BOOMERANG")) {
+ HashMap<Integer, String> map = new HashMap<>();
+
+ EntityPlayerSP p = Minecraft.getMinecraft().thePlayer;
+ float stepSize = 0.15f;
+ float bonemerangDistance = 15;
+
+ Vector3f position = new Vector3f((float) p.posX, (float) p.posY + p.getEyeHeight(), (float) p.posZ);
+ Vec3 look = p.getLook(0);
+
+ Vector3f step = new Vector3f((float) look.xCoord, (float) look.yCoord, (float) look.zCoord);
+ step.scale(stepSize / step.length());
+
+ for (int i = 0; i < Math.floor(bonemerangDistance / stepSize) - 2; i++) {
+ AxisAlignedBB bb = new AxisAlignedBB(position.x - 0.75f, position.y - 0.1, position.z - 0.75f,
+ position.x + 0.75f, position.y + 0.25, position.z + 0.75
+ );
+
+ BlockPos blockPos = new BlockPos(position.x, position.y, position.z);
+
+ if (!Minecraft.getMinecraft().theWorld.isAirBlock(blockPos) &&
+ Minecraft.getMinecraft().theWorld.getBlockState(blockPos).getBlock().isFullCube()) {
+ map.put(0, EnumChatFormatting.RED + "Bonemerang will break!");
+ break;
+ }
+
+ List<Entity> entities = Minecraft.getMinecraft().theWorld.getEntitiesWithinAABBExcludingEntity(
+ Minecraft.getMinecraft().thePlayer,
+ bb
+ );
+ for (Entity entity : entities) {
+ if (entity instanceof EntityLivingBase && !(entity instanceof EntityArmorStand) && !entity.isInvisible()) {
+ if (!bonemeragedEntities.contains(entity)) {
+ bonemeragedEntities.add((EntityLivingBase) entity);
+ }
+ }
+ }
+
+ position.translate(step.x, step.y, step.z);
+ }
+ if (NotEnoughUpdates.INSTANCE.config.itemOverlays.enableBonemerangOverlay) {
+ map.put(
+ 1,
+ EnumChatFormatting.GRAY + "Targets: " + EnumChatFormatting.GOLD + EnumChatFormatting.BOLD +
+ bonemeragedEntities.size()
+ );
+ for (int index : NotEnoughUpdates.INSTANCE.config.itemOverlays.bonemerangOverlayText) {
+ if (map.containsKey(index)) {
+ overlayStrings.add(map.get(index));
+ }
+ }
+ }
+
+ }
+
+ if (overlayStrings.isEmpty()) overlayStrings = null;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/CombatSkillOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/CombatSkillOverlay.java
new file mode 100644
index 00000000..6d46dfd6
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/CombatSkillOverlay.java
@@ -0,0 +1,258 @@
+package io.github.moulberry.notenoughupdates.overlays;
+
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.core.config.Position;
+import io.github.moulberry.notenoughupdates.core.util.lerp.LerpUtils;
+import io.github.moulberry.notenoughupdates.util.Utils;
+import io.github.moulberry.notenoughupdates.util.XPInformation;
+import net.minecraft.client.Minecraft;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.EnumChatFormatting;
+
+import java.text.NumberFormat;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.function.Supplier;
+
+public class CombatSkillOverlay
+ extends TextOverlay { //Im sure there is a much better way to do this besides making another class ¯\_(ツ)_/¯
+ private long lastUpdate = -1;
+ private int killLast = -1;
+ private int kill = -1;
+ private final LinkedList<Integer> killQueue = new LinkedList<>();
+
+ private XPInformation.SkillInfo skillInfo = null;
+ private XPInformation.SkillInfo skillInfoLast = null;
+
+ private float lastTotalXp = -1;
+ private boolean isKilling = false;
+ private final LinkedList<Float> xpGainQueue = new LinkedList<>();
+ private float xpGainHourLast = -1;
+ private float xpGainHour = -1;
+
+ private int xpGainTimer = 0;
+
+ private final String skillType = "Combat";
+
+ public CombatSkillOverlay(
+ Position position,
+ Supplier<List<String>> dummyStrings,
+ Supplier<TextOverlayStyle> styleSupplier
+ ) {
+ super(position, dummyStrings, styleSupplier);
+ }
+
+ private float interp(float now, float last) {
+ float interp = now;
+ if (last >= 0 && last != now) {
+ float factor = (System.currentTimeMillis() - lastUpdate) / 1000f;
+ factor = LerpUtils.clampZeroOne(factor);
+ interp = last + (now - last) * factor;
+ }
+ return interp;
+ }
+
+ @Override
+ public void update() {
+ if (!NotEnoughUpdates.INSTANCE.config.skillOverlays.combatSkillOverlay) {
+ kill = -1;
+ overlayStrings = null;
+ return;
+ }
+
+ lastUpdate = System.currentTimeMillis();
+ killLast = kill;
+ xpGainHourLast = xpGainHour;
+ kill = -1;
+
+ if (Minecraft.getMinecraft().thePlayer == null) return;
+
+ ItemStack stack = Minecraft.getMinecraft().thePlayer.getHeldItem();
+ if (stack != null && stack.hasTagCompound()) {
+ NBTTagCompound tag = stack.getTagCompound();
+
+ if (tag.hasKey("ExtraAttributes", 10)) {
+ NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
+
+ if (ea.hasKey("stats_book", 99)) {
+ kill = ea.getInteger("stats_book");
+ killQueue.add(0, kill);
+ }
+ }
+ }
+
+ String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack);
+
+ skillInfoLast = skillInfo;
+ skillInfo = XPInformation.getInstance().getSkillInfo(skillType);
+ if (skillInfo != null) {
+ float totalXp = skillInfo.totalXp;
+
+ if (lastTotalXp > 0) {
+ float delta = totalXp - lastTotalXp;
+
+ if (delta > 0 && delta < 1000) {
+ xpGainTimer = 3;
+
+ xpGainQueue.add(0, delta);
+ while (xpGainQueue.size() > 30) {
+ xpGainQueue.removeLast();
+ }
+
+ float totalGain = 0;
+ for (float f : xpGainQueue) totalGain += f;
+
+ xpGainHour = totalGain * (60 * 60) / xpGainQueue.size();
+
+ isKilling = true;
+ } else if (xpGainTimer > 0) {
+ xpGainTimer--;
+
+ xpGainQueue.add(0, 0f);
+ while (xpGainQueue.size() > 30) {
+ xpGainQueue.removeLast();
+ }
+
+ float totalGain = 0;
+ for (float f : xpGainQueue) totalGain += f;
+
+ xpGainHour = totalGain * (60 * 60) / xpGainQueue.size();
+
+ isKilling = true;
+ } else if (delta <= 0) {
+ isKilling = false;
+ }
+ }
+
+ lastTotalXp = totalXp;
+ }
+
+ while (killQueue.size() >= 4) {
+ killQueue.removeLast();
+ }
+
+ if (kill != -1) {
+ overlayStrings = new ArrayList<>();
+ } else {
+ overlayStrings = null;
+ }
+
+ }
+
+ @Override
+ public void updateFrequent() {
+ super.updateFrequent();
+
+ if (kill < 0 && !NotEnoughUpdates.INSTANCE.config.skillOverlays.alwaysShowCombatOverlay) {
+ overlayStrings = null;
+ } else {
+ HashMap<Integer, String> lineMap = new HashMap<>();
+
+ overlayStrings = new ArrayList<>();
+
+ NumberFormat format = NumberFormat.getIntegerInstance();
+
+ if (kill >= 0) {
+ int counterInterp = (int) interp(kill, killLast);
+
+ lineMap.put(0, EnumChatFormatting.AQUA + "Kills: " + EnumChatFormatting.YELLOW + format.format(counterInterp));
+ }
+
+ float xpInterp = xpGainHour;
+ if (xpGainHourLast == xpGainHour && xpGainHour <= 0) {
+ lineMap.put(4, EnumChatFormatting.AQUA + "XP/h: " + EnumChatFormatting.YELLOW + "N/A");
+ } else {
+ xpInterp = interp(xpGainHour, xpGainHourLast);
+
+ lineMap.put(4, EnumChatFormatting.AQUA + "XP/h: " + EnumChatFormatting.YELLOW +
+ format.format(xpInterp) + (isKilling ? "" : EnumChatFormatting.RED + " (PAUSED)"));
+ }
+
+ if (skillInfo != null && skillInfo.level < 60) {
+ StringBuilder levelStr = new StringBuilder(EnumChatFormatting.AQUA + "Combat" + ": ");
+
+ levelStr.append(EnumChatFormatting.YELLOW)
+ .append(skillInfo.level)
+ .append(EnumChatFormatting.GRAY)
+ .append(" [");
+
+ float progress = skillInfo.currentXp / skillInfo.currentXpMax;
+ if (skillInfoLast != null && skillInfo.currentXpMax == skillInfoLast.currentXpMax) {
+ progress = interp(progress, skillInfoLast.currentXp / skillInfoLast.currentXpMax);
+ }
+
+ float lines = 25;
+ for (int i = 0; i < lines; i++) {
+ if (i / lines < progress) {
+ levelStr.append(EnumChatFormatting.YELLOW);
+ } else {
+ levelStr.append(EnumChatFormatting.DARK_GRAY);
+ }
+ levelStr.append('|');
+ }
+
+ levelStr.append(EnumChatFormatting.GRAY)
+ .append("] ")
+ .append(EnumChatFormatting.YELLOW)
+ .append((int) (progress * 100))
+ .append("%");
+
+ int current = (int) skillInfo.currentXp;
+ if (skillInfoLast != null && skillInfo.currentXpMax == skillInfoLast.currentXpMax) {
+ current = (int) interp(current, skillInfoLast.currentXp);
+ }
+
+ int remaining = (int) (skillInfo.currentXpMax - skillInfo.currentXp);
+ if (skillInfoLast != null && skillInfo.currentXpMax == skillInfoLast.currentXpMax) {
+ remaining = (int) interp(remaining, (int) (skillInfoLast.currentXpMax - skillInfoLast.currentXp));
+ }
+
+ lineMap.put(1, levelStr.toString());
+ lineMap.put(2, EnumChatFormatting.AQUA + "Current XP: " + EnumChatFormatting.YELLOW + format.format(current));
+ if (remaining < 0) {
+ lineMap.put(3, EnumChatFormatting.AQUA + "Remaining XP: " + EnumChatFormatting.YELLOW + "MAXED!");
+ lineMap.put(5, EnumChatFormatting.AQUA + "ETA: " + EnumChatFormatting.YELLOW + "MAXED!");
+ } else {
+ lineMap.put(
+ 3,
+ EnumChatFormatting.AQUA + "Remaining XP: " + EnumChatFormatting.YELLOW + format.format(remaining)
+ );
+ if (xpGainHour < 1000) {
+ lineMap.put(5, EnumChatFormatting.AQUA + "ETA: " + EnumChatFormatting.YELLOW + "N/A");
+ } else {
+ lineMap.put(
+ 5,
+ EnumChatFormatting.AQUA + "ETA: " + EnumChatFormatting.YELLOW +
+ Utils.prettyTime((long) (remaining) * 1000 * 60 * 60 / (long) xpInterp)
+ );
+ }
+ }
+
+ }
+
+ if (skillInfo != null && skillInfo.level == 60) {
+ int current = (int) skillInfo.currentXp;
+ if (skillInfoLast != null && skillInfo.currentXpMax == skillInfoLast.currentXpMax) {
+ current = (int) interp(current, skillInfoLast.currentXp);
+ }
+
+ lineMap.put(
+ 1,
+ EnumChatFormatting.AQUA + "Combat: " + EnumChatFormatting.YELLOW + "60 " + EnumChatFormatting.RED + "(Maxed)"
+ );
+ lineMap.put(2, EnumChatFormatting.AQUA + "Current XP: " + EnumChatFormatting.YELLOW + format.format(current));
+
+ }
+
+ for (int strIndex : NotEnoughUpdates.INSTANCE.config.skillOverlays.combatText) {
+ if (lineMap.get(strIndex) != null) {
+ overlayStrings.add(lineMap.get(strIndex));
+ }
+ }
+ if (overlayStrings != null && overlayStrings.isEmpty()) overlayStrings = null;
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/CraftingOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/CraftingOverlay.java
deleted file mode 100644
index eb4749db..00000000
--- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/CraftingOverlay.java
+++ /dev/null
@@ -1,118 +0,0 @@
-package io.github.moulberry.notenoughupdates.overlays;
-
-import com.google.gson.JsonObject;
-import io.github.moulberry.notenoughupdates.NEUManager;
-import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
-import io.github.moulberry.notenoughupdates.util.Utils;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.FontRenderer;
-import net.minecraft.client.gui.Gui;
-import net.minecraft.client.gui.inventory.GuiChest;
-import net.minecraft.inventory.ContainerChest;
-import net.minecraft.inventory.Slot;
-import net.minecraft.item.ItemStack;
-import org.lwjgl.input.Keyboard;
-import org.lwjgl.input.Mouse;
-
-import java.util.List;
-
-public class CraftingOverlay {
- private static ItemStack[] items = new ItemStack[9];
- private static final NEUManager manager = NotEnoughUpdates.INSTANCE.manager;
- public static boolean shouldRender = false;
- private static String text = null;
-
-
- public static void render() {
- if (shouldRender) {
- ContainerChest container = (ContainerChest) Minecraft.getMinecraft().thePlayer.openContainer;
- GuiChest gc = (GuiChest) Minecraft.getMinecraft().currentScreen;
- FontRenderer ft = Minecraft.getMinecraft().fontRendererObj;
- int width = Utils.peekGuiScale().getScaledWidth();
- int height = Utils.peekGuiScale().getScaledHeight();
- int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
- int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
- List<String> tooltip = null;
- for (int i = 0; i < 9; i++) {
- if (items[i] != null) {
- int slotIndex = (int) (10 + 9 * Math.floor(i / 3f) + (i % 3));
- Slot slot = container.inventorySlots.get(slotIndex);
- int x = slot.xDisplayPosition + gc.guiLeft;
- int y = slot.yDisplayPosition + gc.guiTop;
- if (!slot.getHasStack() || !manager.getInternalNameForItem(items[i]).equals(manager.getInternalNameForItem(slot.getStack())) ||
- slot.getStack().stackSize < items[i].stackSize)
- Gui.drawRect(x, y, x + 16, y + 16, 0x64ff0000);
- if (!slot.getHasStack())
- Utils.drawItemStack(items[i], x, y);
- if (!slot.getHasStack() && mouseX >= x && mouseX < x + 16 && mouseY >= y && mouseY < y + 16)
- tooltip = items[i].getTooltip(Minecraft.getMinecraft().thePlayer, false);
- }
- }
- if (text != null)
- ft.drawStringWithShadow(text,
- Utils.peekGuiScale().getScaledWidth() / 2f - ft.getStringWidth(text) / 2f,
- gc.guiTop - 15f, 0x808080);
- if (tooltip != null)
- Utils.drawHoveringText(tooltip, mouseX, mouseY, width, height, -1, ft);
- }
- }
-
- public static void updateItem(JsonObject item) {
- items = new ItemStack[9];
- text = null;
- String[] x = {"1", "2", "3"};
- String[] y = {"A", "B", "C"};
- for (int i = 0; i < 9; i++) {
- String name = y[i / 3] + x[i % 3];
- String itemS = item.getAsJsonObject("recipe").get(name).getAsString();
- if (itemS != null && !itemS.equals("")) {
- int count = 1;
- if (itemS.split(":").length == 2) {
- count = Integer.parseInt(itemS.split(":")[1]);
- itemS = itemS.split(":")[0];
- }
- JsonObject craft = manager.getItemInformation().get(itemS);
- if (craft != null) {
- ItemStack stack = manager.jsonToStack(craft);
- stack.stackSize = count;
- items[i] = stack;
- }
- }
- }
- if (item.has("crafttext")) {
- text = item.get("crafttext").getAsString();
- }
- shouldRender = true;
- }
-
- public static void keyInput() {
- if (!Keyboard.getEventKeyState() || Keyboard.getEventKey() != Keyboard.KEY_U && Keyboard.getEventKey() != Keyboard.KEY_R)
- return;
- int width = Utils.peekGuiScale().getScaledWidth();
- int height = Utils.peekGuiScale().getScaledHeight();
- int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
- int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
- ContainerChest container = (ContainerChest) Minecraft.getMinecraft().thePlayer.openContainer;
- GuiChest gc = (GuiChest) Minecraft.getMinecraft().currentScreen;
- for (int i = 0; i < 9; i++) {
- if (items[i] != null) {
- int slotIndex = (int) (10 + 9 * Math.floor(i / 3f) + (i % 3));
- Slot slot = container.inventorySlots.get(slotIndex);
- int x = slot.xDisplayPosition + gc.guiLeft;
- int y = slot.yDisplayPosition + gc.guiTop;
- if (mouseX >= x && mouseX < x + 16 && mouseY >= y && mouseY < y + 16) {
- if (!slot.getHasStack()) {
- String internalName = manager.getInternalNameForItem(items[i]);
- if (Keyboard.getEventKey() == Keyboard.KEY_U && internalName != null) {
- manager.displayGuiItemUsages(internalName);
- } else if (Keyboard.getEventKey() == Keyboard.KEY_R && internalName != null && manager.getItemInformation().containsKey(internalName)) {
- JsonObject item = manager.getItemInformation().get(internalName);
- manager.showRecipe(item);
- }
- }
- break;
- }
- }
- }
- }
-}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/CrystalHollowOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/CrystalHollowOverlay.java
index f3dfa242..529f132a 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/CrystalHollowOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/CrystalHollowOverlay.java
@@ -13,391 +13,509 @@ import net.minecraft.util.EnumChatFormatting;
import org.lwjgl.util.vector.Vector2f;
import java.text.DecimalFormat;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import java.util.function.Supplier;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class CrystalHollowOverlay extends TextOverlay {
- private static final Minecraft mc = Minecraft.getMinecraft();
- private final StorageManager storageManager = StorageManager.getInstance();
- private final Pattern notFoundPattern = Pattern.compile("\\[NPC] Keeper of \\w+: Talk to me when you have found a (?<item>[a-z-A-Z ]+)!");
- private final Pattern foundPattern = Pattern.compile("\\[NPC] Keeper of \\w+: Excellent! You have returned the (?<item>[a-z-A-Z ]+) to its rightful place!");
- private final Pattern resetPattern = Pattern.compile("\\[NPC] Keeper of \\w+: (You found all of the items! Behold\\.\\.\\. the Jade Crystal!)");
- private final Pattern alreadyFoundPattern = Pattern.compile("\\[NPC] Keeper of \\w+: You have already restored this Dwarf's (?<item>[a-z-A-Z ]+)!");
- private final Pattern givePattern = Pattern.compile("\\[NPC] Professor Robot: Thanks for bringing me the (?<part>[a-zA-Z0-9 ]+)! Bring me (\\d+|one) more components? to fix the giant!");
- private final Pattern notFinalPattern = Pattern.compile("\\[NPC] Professor Robot: That's not the final component! Bring me a (?<part>[a-zA-Z0-9 ]+) to gain access to Automaton Prime's storage container!");
- private final Pattern obtainCrystalPattern = Pattern.compile(" +(?<crystal>[a-zA-Z]+) Crystal");
- private final Pattern crystalNotPlacedPattern = Pattern.compile(".*: You haven't placed the (?<crystal>[a-zA-Z]+) Crystal yet!");
- private final Pattern crystalPlacedPattern = Pattern.compile(".*: You have already placed the (?<crystal>[a-zA-Z]+) Crystal!");
- private final Pattern crystalPlacePattern = Pattern.compile("✦ You placed the (?<crystal>[a-zA-Z]+) Crystal!");
- private final Pattern crystalReclaimPattern = Pattern.compile("✦ You reclaimed the (?<crystal>[a-zA-Z]+) Crystal!");
+ private static final Minecraft mc = Minecraft.getMinecraft();
+ private final StorageManager storageManager = StorageManager.getInstance();
+ private final Pattern notFoundPattern = Pattern.compile(
+ "\\[NPC] Keeper of \\w+: Talk to me when you have found a (?<item>[a-z-A-Z ]+)!");
+ private final Pattern foundPattern = Pattern.compile(
+ "\\[NPC] Keeper of \\w+: Excellent! You have returned the (?<item>[a-z-A-Z ]+) to its rightful place!");
+ private final Pattern resetPattern = Pattern.compile(
+ "\\[NPC] Keeper of \\w+: (You found all of the items! Behold\\.\\.\\. the Jade Crystal!)");
+ private final Pattern alreadyFoundPattern = Pattern.compile(
+ "\\[NPC] Keeper of \\w+: You have already restored this Dwarf's (?<item>[a-z-A-Z ]+)!");
+ private final Pattern givePattern = Pattern.compile(
+ "\\[NPC] Professor Robot: Thanks for bringing me the (?<part>[a-zA-Z0-9 ]+)! Bring me (\\d+|one) more components? to fix the giant!");
+ private final Pattern notFinalPattern = Pattern.compile(
+ "\\[NPC] Professor Robot: That's not the final component! Bring me a (?<part>[a-zA-Z0-9 ]+) to gain access to Automaton Prime's storage container!");
+ private final Pattern obtainCrystalPattern = Pattern.compile(" +(?<crystal>[a-zA-Z]+) Crystal");
+ private final Pattern crystalNotPlacedPattern = Pattern.compile(
+ ".*: You haven't placed the (?<crystal>[a-zA-Z]+) Crystal yet!");
+ private final Pattern crystalPlacedPattern = Pattern.compile(
+ ".*: You have already placed the (?<crystal>[a-zA-Z]+) Crystal!");
+ private final Pattern crystalPlacePattern = Pattern.compile("✦ You placed the (?<crystal>[a-zA-Z]+) Crystal!");
+ private final Pattern crystalReclaimPattern = Pattern.compile("✦ You reclaimed the (?<crystal>[a-zA-Z]+) Crystal!");
- public CrystalHollowOverlay(Position position, Supplier<List<String>> dummyStrings, Supplier<TextOverlayStyle> styleSupplier) {
- super(position, dummyStrings, styleSupplier);
- }
+ public CrystalHollowOverlay(
+ Position position,
+ Supplier<List<String>> dummyStrings,
+ Supplier<TextOverlayStyle> styleSupplier
+ ) {
+ super(position, dummyStrings, styleSupplier);
+ }
- @Override
- public void update() {
- overlayStrings = null;
- if (!NotEnoughUpdates.INSTANCE.config.mining.crystalHollowOverlay || SBInfo.getInstance().getLocation() == null ||
- !SBInfo.getInstance().getLocation().equals("crystal_hollows"))
- return;
+ @Override
+ public void update() {
+ overlayStrings = null;
+ if (!NotEnoughUpdates.INSTANCE.config.mining.crystalHollowOverlay || SBInfo.getInstance().getLocation() == null ||
+ !SBInfo.getInstance().getLocation().equals("crystal_hollows"))
+ return;
- NEUConfig.HiddenProfileSpecific hidden = NotEnoughUpdates.INSTANCE.config.getProfileSpecific();
- if (hidden == null) return;
- overlayStrings = new ArrayList<>();
- HashMap<String, Integer> inventoryData = new HashMap<>();
- for (String key : hidden.automatonParts.keySet())
- inventoryData.put(key, 0);
- for (String key : hidden.divanMinesParts.keySet())
- inventoryData.put(key, 0);
- HashMap<String, Integer> storageData = new HashMap<>(inventoryData);
- for (ItemStack item : mc.thePlayer.inventory.mainInventory)
- if (item != null) {
- String name = Utils.cleanColour(item.getDisplayName());
- if (inventoryData.containsKey(name))
- inventoryData.put(name, inventoryData.get(name) + item.stackSize);
- }
- for (Map.Entry<Integer, Integer> entry : storageManager.storageConfig.displayToStorageIdMap.entrySet()) {
- int storageId = entry.getValue();
- StorageManager.StoragePage page = storageManager.getPage(storageId, false);
- if (page != null && page.rows > 0)
- for (ItemStack item : page.items)
- if (item != null) {
- String name = Utils.cleanColour(item.getDisplayName());
- if (storageData.containsKey(name))
- storageData.put(name, storageData.get(name) + item.stackSize);
- }
- }
+ NEUConfig.HiddenProfileSpecific hidden = NotEnoughUpdates.INSTANCE.config.getProfileSpecific();
+ if (hidden == null) return;
+ overlayStrings = new ArrayList<>();
+ HashMap<String, Integer> inventoryData = new HashMap<>();
+ for (String key : hidden.automatonParts.keySet())
+ inventoryData.put(key, 0);
+ for (String key : hidden.divanMinesParts.keySet())
+ inventoryData.put(key, 0);
+ HashMap<String, Integer> storageData = new HashMap<>(inventoryData);
+ for (ItemStack item : mc.thePlayer.inventory.mainInventory)
+ if (item != null) {
+ String name = Utils.cleanColour(item.getDisplayName());
+ if (inventoryData.containsKey(name))
+ inventoryData.put(name, inventoryData.get(name) + item.stackSize);
+ }
+ for (Map.Entry<Integer, Integer> entry : storageManager.storageConfig.displayToStorageIdMap.entrySet()) {
+ int storageId = entry.getValue();
+ StorageManager.StoragePage page = storageManager.getPage(storageId, false);
+ if (page != null && page.rows > 0)
+ for (ItemStack item : page.items)
+ if (item != null) {
+ String name = Utils.cleanColour(item.getDisplayName());
+ if (storageData.containsKey(name))
+ storageData.put(name, storageData.get(name) + item.stackSize);
+ }
+ }
- for (int i : NotEnoughUpdates.INSTANCE.config.mining.crystalHollowText) {
- switch (i) {
- case 0:
- if (crystalCheck()) {
- for (String part : hidden.crystals.keySet()) {
- switch (hidden.crystals.get(part)) {
- case 2:
- if (!NotEnoughUpdates.INSTANCE.config.mining.crystalHollowHideDone)
- overlayStrings.add(EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + part + ": " +
- EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPlacedColor] + "Placed");
- break;
- case 1:
- overlayStrings.add(EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + part + ": " +
- EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowCollectedColor] + "Collected");
- break;
- case 0:
- overlayStrings.add(EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + part + ": " +
- EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowMissingColor] + "Missing");
- break;
- }
- }
- }
- break;
- case 1:
- if (crystalCheck()) {
- int count = getCountCrystal(hidden.crystals);
- float percent = (float) count / hidden.crystals.size() * 100;
- overlayStrings.add(EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + "Crystals: " + getColor(percent)
- + count + "/" + hidden.crystals.size());
- }
- break;
- case 2:
- if (crystalCheck()) {
- int count = getCountCrystal(hidden.crystals);
- float percent = (float) count / hidden.crystals.size() * 100;
- DecimalFormat df = new DecimalFormat("#.#");
- overlayStrings.add(EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + "Crystals: " + getColor(percent) +
- df.format(percent) + "%");
- }
- break;
- case 3:
- if (automatonCheck())
- renderParts(hidden.automatonParts, inventoryData, storageData);
- break;
- case 4:
- if (automatonCheck())
- renderPartsNumbers(hidden.automatonParts, inventoryData, storageData);
- break;
- case 5:
- if (automatonCheck())
- renderCount("Automaton parts", hidden.automatonParts, inventoryData, storageData);
- break;
- case 6:
- if (automatonCheck())
- renderPercent("Automaton parts", hidden.automatonParts, inventoryData, storageData);
- break;
- case 7:
- if (divanCheck())
- renderParts(hidden.divanMinesParts, inventoryData, storageData);
- break;
- case 8:
- if (divanCheck())
- renderPartsNumbers(hidden.divanMinesParts, inventoryData, storageData);
- break;
- case 9:
- if (divanCheck())
- renderCount("Mines of Divan parts", hidden.divanMinesParts, inventoryData, storageData);
- break;
- case 10:
- if (divanCheck())
- renderPercent("Mines of Divan parts", hidden.divanMinesParts, inventoryData, storageData);
- break;
- }
- }
- }
+ for (int i : NotEnoughUpdates.INSTANCE.config.mining.crystalHollowText) {
+ switch (i) {
+ case 0:
+ if (crystalCheck()) {
+ for (String part : hidden.crystals.keySet()) {
+ switch (hidden.crystals.get(part)) {
+ case 2:
+ if (!NotEnoughUpdates.INSTANCE.config.mining.crystalHollowHideDone)
+ overlayStrings.add(
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] +
+ part + ": " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPlacedColor] +
+ "Placed");
+ break;
+ case 1:
+ overlayStrings.add(
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + part +
+ ": " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowCollectedColor] +
+ "Collected");
+ break;
+ case 0:
+ overlayStrings.add(
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + part +
+ ": " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowMissingColor] +
+ "Missing");
+ break;
+ }
+ }
+ }
+ break;
+ case 1:
+ if (crystalCheck()) {
+ int count = getCountCrystal(hidden.crystals);
+ float percent = (float) count / hidden.crystals.size() * 100;
+ overlayStrings.add(
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] +
+ "Crystals: " + getColor(percent)
+ + count + "/" + hidden.crystals.size());
+ }
+ break;
+ case 2:
+ if (crystalCheck()) {
+ int count = getCountCrystal(hidden.crystals);
+ float percent = (float) count / hidden.crystals.size() * 100;
+ DecimalFormat df = new DecimalFormat("#.#");
+ overlayStrings.add(
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] +
+ "Crystals: " + getColor(percent) +
+ df.format(percent) + "%");
+ }
+ break;
+ case 3:
+ if (automatonCheck())
+ renderParts(hidden.automatonParts, inventoryData, storageData);
+ break;
+ case 4:
+ if (automatonCheck())
+ renderPartsNumbers(hidden.automatonParts, inventoryData, storageData);
+ break;
+ case 5:
+ if (automatonCheck())
+ renderCount("Automaton parts", hidden.automatonParts, inventoryData, storageData);
+ break;
+ case 6:
+ if (automatonCheck())
+ renderPercent("Automaton parts", hidden.automatonParts, inventoryData, storageData);
+ break;
+ case 7:
+ if (divanCheck())
+ renderParts(hidden.divanMinesParts, inventoryData, storageData);
+ break;
+ case 8:
+ if (divanCheck())
+ renderPartsNumbers(hidden.divanMinesParts, inventoryData, storageData);
+ break;
+ case 9:
+ if (divanCheck())
+ renderCount("Mines of Divan parts", hidden.divanMinesParts, inventoryData, storageData);
+ break;
+ case 10:
+ if (divanCheck())
+ renderPercent("Mines of Divan parts", hidden.divanMinesParts, inventoryData, storageData);
+ break;
+ }
+ }
+ }
- private void renderParts(HashMap<String, Boolean> parts, HashMap<String, Integer> inventoryData, HashMap<String, Integer> storageData) {
- for (String part : parts.keySet()) {
- if (parts.get(part) && !NotEnoughUpdates.INSTANCE.config.mining.crystalHollowHideDone)
- overlayStrings.add(EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + part + ": " +
- EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowDoneColor] + "Done");
- else if (inventoryData.get(part) >= 1)
- overlayStrings.add(EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + part + ": " +
- EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowInventoryColor] + "In Inventory");
- else if (storageData.get(part) >= 1)
- overlayStrings.add(EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + part + ": " +
- EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowStorageColor] + "In Storage");
- else
- overlayStrings.add(EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + part + ": " +
- EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowMissingColor] + "Missing");
- }
- }
+ private void renderParts(
+ HashMap<String, Boolean> parts,
+ HashMap<String, Integer> inventoryData,
+ HashMap<String, Integer> storageData
+ ) {
+ for (String part : parts.keySet()) {
+ if (parts.get(part) && !NotEnoughUpdates.INSTANCE.config.mining.crystalHollowHideDone)
+ overlayStrings.add(
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + part + ": " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowDoneColor] + "Done");
+ else if (inventoryData.get(part) >= 1)
+ overlayStrings.add(
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + part + ": " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowInventoryColor] +
+ "In Inventory");
+ else if (storageData.get(part) >= 1)
+ overlayStrings.add(
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + part + ": " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowStorageColor] +
+ "In Storage");
+ else
+ overlayStrings.add(
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + part + ": " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowMissingColor] + "Missing");
+ }
+ }
- private void renderPartsNumbers(HashMap<String, Boolean> parts, HashMap<String, Integer> inventoryData, HashMap<String, Integer> storageData) {
- for (String part : parts.keySet()) {
- if (parts.get(part))
- overlayStrings.add(EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + part + ": " +
- EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowDoneColor] + (inventoryData.get(part) + storageData.get(part)));
- else if (inventoryData.get(part) >= 1)
- overlayStrings.add(EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + part + ": " +
- EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowInventoryColor] + (inventoryData.get(part) + storageData.get(part)));
- else if (storageData.get(part) >= 1)
- overlayStrings.add(EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + part + ": " +
- EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowStorageColor] + (inventoryData.get(part) + storageData.get(part)));
- else
- overlayStrings.add(EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + part + ": " +
- EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowMissingColor] + (inventoryData.get(part) + storageData.get(part)));
- }
- }
+ private void renderPartsNumbers(
+ HashMap<String, Boolean> parts,
+ HashMap<String, Integer> inventoryData,
+ HashMap<String, Integer> storageData
+ ) {
+ for (String part : parts.keySet()) {
+ if (parts.get(part))
+ overlayStrings.add(
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + part + ": " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowDoneColor] +
+ (inventoryData.get(part) + storageData.get(part)));
+ else if (inventoryData.get(part) >= 1)
+ overlayStrings.add(
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + part + ": " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowInventoryColor] +
+ (inventoryData.get(part) + storageData.get(part)));
+ else if (storageData.get(part) >= 1)
+ overlayStrings.add(
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + part + ": " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowStorageColor] +
+ (inventoryData.get(part) + storageData.get(part)));
+ else
+ overlayStrings.add(
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + part + ": " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowMissingColor] +
+ (inventoryData.get(part) + storageData.get(part)));
+ }
+ }
- private void renderCount(String text, HashMap<String, Boolean> parts, HashMap<String, Integer> inventoryData, HashMap<String, Integer> storageData) {
- int count = getCount(parts, inventoryData, storageData);
- float percent = (float) count / parts.size() * 100;
- overlayStrings.add(EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + text + ": " + getColor(percent) + count
- + "/" + parts.size());
- }
+ private void renderCount(
+ String text,
+ HashMap<String, Boolean> parts,
+ HashMap<String, Integer> inventoryData,
+ HashMap<String, Integer> storageData
+ ) {
+ int count = getCount(parts, inventoryData, storageData);
+ float percent = (float) count / parts.size() * 100;
+ overlayStrings.add(
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + text + ": " +
+ getColor(percent) + count
+ + "/" + parts.size());
+ }
- private void renderPercent(String text, HashMap<String, Boolean> parts, HashMap<String, Integer> inventoryData, HashMap<String, Integer> storageData) {
- int count = getCount(parts, inventoryData, storageData);
- float percent = (float) count / parts.size() * 100;
- DecimalFormat df = new DecimalFormat("#.#");
- overlayStrings.add(EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + text + ": " + getColor(percent) +
- df.format(percent) + "%");
- }
+ private void renderPercent(
+ String text,
+ HashMap<String, Boolean> parts,
+ HashMap<String, Integer> inventoryData,
+ HashMap<String, Integer> storageData
+ ) {
+ int count = getCount(parts, inventoryData, storageData);
+ float percent = (float) count / parts.size() * 100;
+ DecimalFormat df = new DecimalFormat("#.#");
+ overlayStrings.add(
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowPartColor] + text + ": " +
+ getColor(percent) +
+ df.format(percent) + "%");
+ }
- private EnumChatFormatting getColor(float percent) {
- if (percent >= 66)
- return EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowAllColor];
- else if (percent >= 33)
- return EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowMiddleColor];
- else
- return EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowNoneColor];
- }
+ private EnumChatFormatting getColor(float percent) {
+ if (percent >= 66)
+ return EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowAllColor];
+ else if (percent >= 33)
+ return EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowMiddleColor];
+ else
+ return EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.mining.crystalHollowNoneColor];
+ }
- private int getCount(HashMap<String, Boolean> parts, HashMap<String, Integer> inventoryData, HashMap<String, Integer> storageData) {
- int count = 0;
- for (String part : parts.keySet())
- if (parts.get(part) || inventoryData.get(part) > 0 || storageData.get(part) > 0)
- count++;
- return count;
- }
+ private int getCount(
+ HashMap<String, Boolean> parts,
+ HashMap<String, Integer> inventoryData,
+ HashMap<String, Integer> storageData
+ ) {
+ int count = 0;
+ for (String part : parts.keySet())
+ if (parts.get(part) || inventoryData.get(part) > 0 || storageData.get(part) > 0)
+ count++;
+ return count;
+ }
- private int getCountCrystal(HashMap<String, Integer> parts) {
- int count = 0;
- for (String part : parts.keySet())
- if (parts.get(part) > 0)
- count++;
- return count;
- }
+ private int getCountCrystal(HashMap<String, Integer> parts) {
+ int count = 0;
+ for (String part : parts.keySet())
+ if (parts.get(part) > 0)
+ count++;
+ return count;
+ }
- private boolean automatonCheck() {
- return NotEnoughUpdates.INSTANCE.config.mining.crystalHollowAutomatonLocation == 0 ||
- NotEnoughUpdates.INSTANCE.config.mining.crystalHollowAutomatonLocation == 1 &&
- SBInfo.getInstance().location.equals("Precursor Remnants") ||
- NotEnoughUpdates.INSTANCE.config.mining.crystalHollowAutomatonLocation >= 1 &&
- SBInfo.getInstance().location.equals("Lost Precursor City");
- }
+ private boolean automatonCheck() {
+ return NotEnoughUpdates.INSTANCE.config.mining.crystalHollowAutomatonLocation == 0 ||
+ NotEnoughUpdates.INSTANCE.config.mining.crystalHollowAutomatonLocation == 1 &&
+ SBInfo.getInstance().location.equals("Precursor Remnants") ||
+ NotEnoughUpdates.INSTANCE.config.mining.crystalHollowAutomatonLocation >= 1 &&
+ SBInfo.getInstance().location.equals("Lost Precursor City");
+ }
- private boolean divanCheck() {
- return NotEnoughUpdates.INSTANCE.config.mining.crystalHollowDivanLocation == 0 ||
- NotEnoughUpdates.INSTANCE.config.mining.crystalHollowDivanLocation == 1 &&
- SBInfo.getInstance().location.equals("Mithril Deposits") ||
- NotEnoughUpdates.INSTANCE.config.mining.crystalHollowDivanLocation >= 1 &&
- SBInfo.getInstance().location.equals("Mines of Divan");
- }
+ private boolean divanCheck() {
+ return NotEnoughUpdates.INSTANCE.config.mining.crystalHollowDivanLocation == 0 ||
+ NotEnoughUpdates.INSTANCE.config.mining.crystalHollowDivanLocation == 1 &&
+ SBInfo.getInstance().location.equals("Mithril Deposits") ||
+ NotEnoughUpdates.INSTANCE.config.mining.crystalHollowDivanLocation >= 1 &&
+ SBInfo.getInstance().location.equals("Mines of Divan");
+ }
- private boolean crystalCheck() {
- return NotEnoughUpdates.INSTANCE.config.mining.crystalHollowCrystalLocation == 0 || !divanCheck() && !automatonCheck();
- }
+ private boolean crystalCheck() {
+ return NotEnoughUpdates.INSTANCE.config.mining.crystalHollowCrystalLocation == 0 ||
+ !divanCheck() && !automatonCheck();
+ }
- public void message(String message) {
- NEUConfig.HiddenProfileSpecific hidden = NotEnoughUpdates.INSTANCE.config.getProfileSpecific();
- if (hidden == null) return;
+ public void message(String message) {
+ NEUConfig.HiddenProfileSpecific hidden = NotEnoughUpdates.INSTANCE.config.getProfileSpecific();
+ if (hidden == null) return;
- Matcher crystalNotPlacedMatcher = crystalNotPlacedPattern.matcher(message);
- Matcher crystalPlacedMatcher = crystalPlacedPattern.matcher(message);
- Matcher crystalPlaceMatcher = crystalPlacePattern.matcher(message);
- Matcher crystalReclaimMatcher = crystalReclaimPattern.matcher(message);
- if (message.equals(" You've earned a Crystal Loot Bundle!"))
- hidden.crystals.replaceAll((k, v) -> 0);
- if (crystalNotPlacedMatcher.matches() && hidden.crystals.containsKey(crystalNotPlacedMatcher.group("crystal"))) {
- hidden.crystals.put(crystalNotPlacedMatcher.group("crystal"), 1);
- resetCrystal(hidden, crystalNotPlacedMatcher.group("crystal"));
- } else if (crystalPlacedMatcher.matches() && hidden.crystals.containsKey(crystalPlacedMatcher.group("crystal"))) {
- hidden.crystals.put(crystalPlacedMatcher.group("crystal"), 2);
- resetCrystal(hidden, crystalPlacedMatcher.group("crystal"));
- } else if (crystalPlaceMatcher.matches() && hidden.crystals.containsKey(crystalPlaceMatcher.group("crystal")))
- hidden.crystals.put(crystalPlaceMatcher.group("crystal"), 2);
- else if (crystalReclaimMatcher.matches() && hidden.crystals.containsKey(crystalReclaimMatcher.group("crystal")))
- hidden.crystals.put(crystalReclaimMatcher.group("crystal"), 1);
- else if (message.startsWith("[NPC] Keeper of ")) {
- Matcher foundMatcher = foundPattern.matcher(message);
- Matcher alreadyFoundMatcher = alreadyFoundPattern.matcher(message);
- Matcher notFoundMatcher = notFoundPattern.matcher(message);
- Matcher resetMatcher = resetPattern.matcher(message);
- if (foundMatcher.matches() && hidden.divanMinesParts.containsKey(foundMatcher.group("item")))
- hidden.divanMinesParts.put(foundMatcher.group("item"), true);
- else if (notFoundMatcher.matches() && hidden.divanMinesParts.containsKey(notFoundMatcher.group("item")))
- hidden.divanMinesParts.put(notFoundMatcher.group("item"), false);
- else if (resetMatcher.matches())
- hidden.divanMinesParts.replaceAll((k, v) -> false);
- else if (alreadyFoundMatcher.matches() && hidden.divanMinesParts.containsKey(alreadyFoundMatcher.group("item")))
- hidden.divanMinesParts.put(alreadyFoundMatcher.group("item"), true);
- } else if (message.startsWith(" ")) {
- Matcher crystalMatcher = obtainCrystalPattern.matcher(message);
- if (crystalMatcher.matches() && hidden.crystals.containsKey(crystalMatcher.group("crystal")))
- hidden.crystals.put(crystalMatcher.group("crystal"), 1);
- else {
- String item = message.replace(" ", "");
- if (hidden.automatonParts.containsKey(item))
- hidden.automatonParts.put(item, false);
- }
- } else if (message.startsWith("[NPC] Professor Robot: ")) {
- switch (message) {
- case "[NPC] Professor Robot: That's not one of the components I need! Bring me one of the missing components:":
- hidden.automatonParts.replaceAll((k, v) -> true);
- break;
- case "[NPC] Professor Robot: You've brought me all of the components!":
- hidden.automatonParts.replaceAll((k, v) -> false);
- break;
- default:
- Matcher giveMatcher = givePattern.matcher(message);
- Matcher notFinalMatcher = notFinalPattern.matcher(message);
- if (giveMatcher.matches()) {
- String item = giveMatcher.group("part");
- if (hidden.automatonParts.containsKey(item)) {
- hidden.automatonParts.put(item, true);
- }
- } else if (notFinalMatcher.matches()) {
- String item = notFinalMatcher.group("part");
- if (hidden.automatonParts.containsKey(item)) {
- hidden.automatonParts.replaceAll((k, v) -> true);
- hidden.automatonParts.put(item, false);
- }
- }
- break;
- }
- }
- }
+ Matcher crystalNotPlacedMatcher = crystalNotPlacedPattern.matcher(message);
+ Matcher crystalPlacedMatcher = crystalPlacedPattern.matcher(message);
+ Matcher crystalPlaceMatcher = crystalPlacePattern.matcher(message);
+ Matcher crystalReclaimMatcher = crystalReclaimPattern.matcher(message);
+ if (message.equals(" You've earned a Crystal Loot Bundle!"))
+ hidden.crystals.replaceAll((k, v) -> 0);
+ if (crystalNotPlacedMatcher.matches() && hidden.crystals.containsKey(crystalNotPlacedMatcher.group("crystal"))) {
+ hidden.crystals.put(crystalNotPlacedMatcher.group("crystal"), 1);
+ resetCrystal(hidden, crystalNotPlacedMatcher.group("crystal"));
+ } else if (crystalPlacedMatcher.matches() && hidden.crystals.containsKey(crystalPlacedMatcher.group("crystal"))) {
+ hidden.crystals.put(crystalPlacedMatcher.group("crystal"), 2);
+ resetCrystal(hidden, crystalPlacedMatcher.group("crystal"));
+ } else if (crystalPlaceMatcher.matches() && hidden.crystals.containsKey(crystalPlaceMatcher.group("crystal")))
+ hidden.crystals.put(crystalPlaceMatcher.group("crystal"), 2);
+ else if (crystalReclaimMatcher.matches() && hidden.crystals.containsKey(crystalReclaimMatcher.group("crystal")))
+ hidden.crystals.put(crystalReclaimMatcher.group("crystal"), 1);
+ else if (message.startsWith("[NPC] Keeper of ")) {
+ Matcher foundMatcher = foundPattern.matcher(message);
+ Matcher alreadyFoundMatcher = alreadyFoundPattern.matcher(message);
+ Matcher notFoundMatcher = notFoundPattern.matcher(message);
+ Matcher resetMatcher = resetPattern.matcher(message);
+ if (foundMatcher.matches() && hidden.divanMinesParts.containsKey(foundMatcher.group("item")))
+ hidden.divanMinesParts.put(foundMatcher.group("item"), true);
+ else if (notFoundMatcher.matches() && hidden.divanMinesParts.containsKey(notFoundMatcher.group("item")))
+ hidden.divanMinesParts.put(notFoundMatcher.group("item"), false);
+ else if (resetMatcher.matches())
+ hidden.divanMinesParts.replaceAll((k, v) -> false);
+ else if (alreadyFoundMatcher.matches() && hidden.divanMinesParts.containsKey(alreadyFoundMatcher.group("item")))
+ hidden.divanMinesParts.put(alreadyFoundMatcher.group("item"), true);
+ } else if (message.startsWith(" ")) {
+ Matcher crystalMatcher = obtainCrystalPattern.matcher(message);
+ if (crystalMatcher.matches() && hidden.crystals.containsKey(crystalMatcher.group("crystal")))
+ hidden.crystals.put(crystalMatcher.group("crystal"), 1);
+ else {
+ String item = message.replace(" ", "");
+ if (hidden.automatonParts.containsKey(item))
+ hidden.automatonParts.put(item, false);
+ }
+ } else if (message.startsWith("[NPC] Professor Robot: ")) {
+ switch (message) {
+ case "[NPC] Professor Robot: That's not one of the components I need! Bring me one of the missing components:":
+ hidden.automatonParts.replaceAll((k, v) -> true);
+ break;
+ case "[NPC] Professor Robot: You've brought me all of the components!":
+ hidden.automatonParts.replaceAll((k, v) -> false);
+ break;
+ default:
+ Matcher giveMatcher = givePattern.matcher(message);
+ Matcher notFinalMatcher = notFinalPattern.matcher(message);
+ if (giveMatcher.matches()) {
+ String item = giveMatcher.group("part");
+ if (hidden.automatonParts.containsKey(item)) {
+ hidden.automatonParts.put(item, true);
+ }
+ } else if (notFinalMatcher.matches()) {
+ String item = notFinalMatcher.group("part");
+ if (hidden.automatonParts.containsKey(item)) {
+ hidden.automatonParts.replaceAll((k, v) -> true);
+ hidden.automatonParts.put(item, false);
+ }
+ }
+ break;
+ }
+ }
+ }
- private void resetCrystal(NEUConfig.HiddenProfileSpecific hidden, String crystal) {
- switch (crystal) {
- case "Sapphire":
- hidden.automatonParts.replaceAll((k, v) -> false);
- break;
- case "Jade":
- hidden.divanMinesParts.replaceAll((k, v) -> false);
- break;
- }
- }
+ private void resetCrystal(NEUConfig.HiddenProfileSpecific hidden, String crystal) {
+ switch (crystal) {
+ case "Sapphire":
+ hidden.automatonParts.replaceAll((k, v) -> false);
+ break;
+ case "Jade":
+ hidden.divanMinesParts.replaceAll((k, v) -> false);
+ break;
+ }
+ }
- @Override
- protected void renderLine(String line, Vector2f position, boolean dummy) {
- if (!NotEnoughUpdates.INSTANCE.config.mining.crystalHollowIcons) return;
- GlStateManager.enableDepth();
+ @Override
+ protected void renderLine(String line, Vector2f position, boolean dummy) {
+ if (!NotEnoughUpdates.INSTANCE.config.mining.crystalHollowIcons) return;
+ GlStateManager.enableDepth();
- ItemStack icon = null;
- String cleaned = Utils.cleanColour(line);
- String beforeColon = cleaned.split(":")[0];
- switch (beforeColon) {
- case "Scavenged Lapis Sword":
- icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("DWARVEN_LAPIS_SWORD"));
- break;
- case "Scavenged Golden Hammer":
- icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("DWARVEN_GOLD_HAMMER"));
- break;
- case "Scavenged Diamond Axe":
- icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("DWARVEN_DIAMOND_AXE"));
- break;
- case "Scavenged Emerald Hammer":
- icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("DWARVEN_EMERALD_HAMMER"));
- break;
- case "Electron Transmitter":
- icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("ELECTRON_TRANSMITTER"));
- break;
- case "FTX 3070":
- icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("FTX_3070"));
- break;
- case "Robotron Reflector":
- icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("ROBOTRON_REFLECTOR"));
- break;
- case "Superlite Motor":
- icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("SUPERLITE_MOTOR"));
- break;
- case "Control Switch":
- icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("CONTROL_SWITCH"));
- break;
- case "Synthetic Heart":
- icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("SYNTHETIC_HEART"));
- break;
- case "Amber":
- icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("PERFECT_AMBER_GEM"));
- break;
- case "Sapphire":
- icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("PERFECT_SAPPHIRE_GEM"));
- break;
- case "Jade":
- icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("PERFECT_JADE_GEM"));
- break;
- case "Amethyst":
- icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("PERFECT_AMETHYST_GEM"));
- break;
- case "Topaz":
- icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("PERFECT_TOPAZ_GEM"));
- break;
- }
+ ItemStack icon = null;
+ String cleaned = Utils.cleanColour(line);
+ String beforeColon = cleaned.split(":")[0];
+ if (crystallHollowsIcons == null) {
+ setupCrystallHollowsIcons();
+ }
+ if (crystallHollowsIcons.containsKey(beforeColon)) {
+ icon = crystallHollowsIcons.get(beforeColon);
+ }
+ if (icon != null) {
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(position.x, position.y, 0);
+ GlStateManager.scale(0.5f, 0.5f, 1f);
+ Utils.drawItemStack(icon, 0, 0);
+ GlStateManager.popMatrix();
- if (icon != null) {
- GlStateManager.pushMatrix();
- GlStateManager.translate(position.x, position.y, 0);
- GlStateManager.scale(0.5f, 0.5f, 1f);
- Utils.drawItemStack(icon, 0, 0);
- GlStateManager.popMatrix();
+ position.x += 12;
+ }
- position.x += 12;
- }
+ super.renderLine(line, position, dummy);
+ }
- super.renderLine(line, position, dummy);
- }
+ private static Map<String, ItemStack> crystallHollowsIcons;
- @Override
- protected Vector2f getSize(List<String> strings) {
- if (NotEnoughUpdates.INSTANCE.config.mining.crystalHollowIcons)
- return super.getSize(strings).translate(12, 0);
- return super.getSize(strings);
- }
+ private static void setupCrystallHollowsIcons() {
+ crystallHollowsIcons = new HashMap<String, ItemStack>() {{
+ put(
+ "Scavenged Lapis Sword",
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("DWARVEN_LAPIS_SWORD"))
+ );
+ put(
+ "Scavenged Golden Hammer",
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("DWARVEN_GOLD_HAMMER"))
+ );
+ put(
+ "Scavenged Diamond Axe",
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("DWARVEN_DIAMOND_AXE"))
+ );
+ put(
+ "Scavenged Emerald Hammer",
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("DWARVEN_EMERALD_HAMMER"))
+ );
+ put(
+ "Electron Transmitter",
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("ELECTRON_TRANSMITTER"))
+ );
+ put(
+ "FTX 3070",
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("FTX_3070"))
+ );
+ put(
+ "Robotron Reflector",
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("ROBOTRON_REFLECTOR"))
+ );
+ put(
+ "Superlite Motor",
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("SUPERLITE_MOTOR"))
+ );
+ put(
+ "Control Switch",
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("CONTROL_SWITCH"))
+ );
+ put(
+ "Synthetic Heart",
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("SYNTHETIC_HEART"))
+ );
+ put(
+ "Amber",
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("PERFECT_AMBER_GEM"))
+ );
+ put(
+ "Sapphire",
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("PERFECT_SAPPHIRE_GEM"))
+ );
+ put(
+ "Jade",
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("PERFECT_JADE_GEM"))
+ );
+ put(
+ "Amethyst",
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("PERFECT_AMETHYST_GEM"))
+ );
+ put(
+ "Topaz",
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("PERFECT_TOPAZ_GEM"))
+ );
+ }};
+ }
+
+ @Override
+ protected Vector2f getSize(List<String> strings) {
+ if (NotEnoughUpdates.INSTANCE.config.mining.crystalHollowIcons)
+ return super.getSize(strings).translate(12, 0);
+ return super.getSize(strings);
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/FarmingOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/FarmingOverlay.java
index e6310022..f2c7e396 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/FarmingOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/FarmingOverlay.java
@@ -1,5 +1,6 @@
package io.github.moulberry.notenoughupdates.overlays;
+import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.core.config.Position;
import io.github.moulberry.notenoughupdates.core.util.lerp.LerpUtils;
@@ -9,7 +10,6 @@ import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
-import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import java.text.NumberFormat;
import java.util.ArrayList;
@@ -19,257 +19,508 @@ import java.util.List;
import java.util.function.Supplier;
public class FarmingOverlay extends TextOverlay {
-
- private long lastUpdate = -1;
- private int counterLast = -1;
- private int counter = -1;
- private float cropsPerSecondLast = 0;
- private float cropsPerSecond = 0;
- private LinkedList<Integer> counterQueue = new LinkedList<>();
-
- private XPInformation.SkillInfo skillInfo = null;
- private XPInformation.SkillInfo skillInfoLast = null;
-
- private float lastTotalXp = -1;
- private boolean isFarming = false;
- private LinkedList<Float> xpGainQueue = new LinkedList<>();
- private float xpGainHourLast = -1;
- private float xpGainHour = -1;
-
- private int xpGainTimer = 0;
-
- private String skillType = "Farming";
-
- public FarmingOverlay(Position position, Supplier<List<String>> dummyStrings, Supplier<TextOverlayStyle> styleSupplier) {
- super(position, dummyStrings, styleSupplier);
- }
-
- private float interp(float now, float last) {
- float interp = now;
- if(last >= 0 && last != now) {
- float factor = (System.currentTimeMillis()-lastUpdate)/1000f;
- factor = LerpUtils.clampZeroOne(factor);
- interp = last + (now - last) * factor;
- }
- return interp;
- }
-
- @Override
- public void update() {
- if(!NotEnoughUpdates.INSTANCE.config.skillOverlays.farmingOverlay) {
- counter = -1;
- overlayStrings = null;
- return;
- }
-
- lastUpdate = System.currentTimeMillis();
- counterLast = counter;
- xpGainHourLast = xpGainHour;
- counter = -1;
-
- if(Minecraft.getMinecraft().thePlayer == null) return;
-
- ItemStack stack = Minecraft.getMinecraft().thePlayer.getHeldItem();
- if(stack != null && stack.hasTagCompound()) {
- NBTTagCompound tag = stack.getTagCompound();
-
- if(tag.hasKey("ExtraAttributes", 10)) {
- NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
-
- if(ea.hasKey("mined_crops", 99)) {
- counter = ea.getInteger("mined_crops");
- counterQueue.add(0, counter);
- } else if(ea.hasKey("farmed_cultivating", 99)) {
- counter = ea.getInteger("farmed_cultivating");
- counterQueue.add(0, counter);
- }
- }
- }
- String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack);
- if(internalname != null && internalname.startsWith("THEORETICAL_HOE_WARTS")) {
- skillType = "Alchemy";
- } else {
- skillType = "Farming";
- }
-
- skillInfoLast = skillInfo;
- skillInfo = XPInformation.getInstance().getSkillInfo(skillType);
- if(skillInfo != null) {
- float totalXp = skillInfo.totalXp;
-
- if(lastTotalXp > 0) {
- float delta = totalXp - lastTotalXp;
-
- if(delta > 0 && delta < 1000) {
- xpGainTimer = 3;
-
- xpGainQueue.add(0, delta);
- while(xpGainQueue.size() > 30) {
- xpGainQueue.removeLast();
- }
-
- float totalGain = 0;
- for(float f : xpGainQueue) totalGain += f;
-
- xpGainHour = totalGain * (60 * 60) / xpGainQueue.size();
-
- isFarming = true;
- } else if(xpGainTimer > 0) {
- xpGainTimer--;
-
- xpGainQueue.add(0, 0f);
- while(xpGainQueue.size() > 30) {
- xpGainQueue.removeLast();
- }
-
- float totalGain = 0;
- for(float f : xpGainQueue) totalGain += f;
-
- xpGainHour = totalGain * (60 * 60) / xpGainQueue.size();
-
- isFarming = true;
- } else if(delta <= 0) {
- isFarming = false;
- }
- }
-
- lastTotalXp = totalXp;
- }
-
- while(counterQueue.size() >= 4) {
- counterQueue.removeLast();
- }
-
- if(counterQueue.isEmpty()) {
- cropsPerSecond = -1;
- cropsPerSecondLast = 0;
- } else {
- cropsPerSecondLast = cropsPerSecond;
- int last = counterQueue.getLast();
- int first = counterQueue.getFirst();
-
- cropsPerSecond = (first - last)/3f;
- }
-
- if(counter != -1) {
- overlayStrings = new ArrayList<>();
- } else {
- overlayStrings = null;
- }
-
- }
-
- @Override
- public void updateFrequent() {
- super.updateFrequent();
-
- if(counter < 0) {
- overlayStrings = null;
- } else {
- HashMap<Integer, String> lineMap = new HashMap<>();
-
- overlayStrings = new ArrayList<>();
-
- NumberFormat format = NumberFormat.getIntegerInstance();
-
- if(counter >= 0) {
- int counterInterp = (int)interp(counter, counterLast);
-
- lineMap.put(0, EnumChatFormatting.AQUA+"Counter: "+EnumChatFormatting.YELLOW+format.format(counterInterp));
- }
-
- if(counter >= 0) {
- if(cropsPerSecondLast == cropsPerSecond && cropsPerSecond <= 0) {
- lineMap.put(1, EnumChatFormatting.AQUA+"Crops/m: "+EnumChatFormatting.YELLOW+"N/A");
- } else {
- float cpsInterp = interp(cropsPerSecond, cropsPerSecondLast);
-
- lineMap.put(1, EnumChatFormatting.AQUA+"Crops/m: "+EnumChatFormatting.YELLOW+
- String.format("%.2f", cpsInterp*60));
- }
- }
-
- float xpInterp = xpGainHour;
- if(xpGainHourLast == xpGainHour && xpGainHour <= 0) {
- lineMap.put(5, EnumChatFormatting.AQUA+"XP/h: "+EnumChatFormatting.YELLOW+"N/A");
- } else {
- xpInterp = interp(xpGainHour, xpGainHourLast);
-
- lineMap.put(5, EnumChatFormatting.AQUA+"XP/h: "+EnumChatFormatting.YELLOW+
- format.format(xpInterp)+(isFarming ? "" : EnumChatFormatting.RED + " (PAUSED)"));
- }
-
- if(skillInfo != null) {
- StringBuilder levelStr = new StringBuilder(EnumChatFormatting.AQUA + skillType.substring(0, 4) + ": ");
-
- levelStr.append(EnumChatFormatting.YELLOW)
- .append(skillInfo.level)
- .append(EnumChatFormatting.GRAY)
- .append(" [");
-
- float progress = skillInfo.currentXp / skillInfo.currentXpMax;
- if(skillInfoLast != null && skillInfo.currentXpMax == skillInfoLast.currentXpMax) {
- progress = interp(progress, skillInfoLast.currentXp / skillInfoLast.currentXpMax);
- }
-
- float lines = 25;
- for(int i=0; i<lines; i++) {
- if(i/lines < progress) {
- levelStr.append(EnumChatFormatting.YELLOW);
- } else {
- levelStr.append(EnumChatFormatting.DARK_GRAY);
- }
- levelStr.append('|');
- }
-
- levelStr.append(EnumChatFormatting.GRAY)
- .append("] ")
- .append(EnumChatFormatting.YELLOW)
- .append((int)(progress*100))
- .append("%");
-
- int current = (int)skillInfo.currentXp;
- if(skillInfoLast != null && skillInfo.currentXpMax == skillInfoLast.currentXpMax) {
- current = (int)interp(current, skillInfoLast.currentXp);
- }
-
- int remaining = (int)(skillInfo.currentXpMax - skillInfo.currentXp);
- if(skillInfoLast != null && skillInfo.currentXpMax == skillInfoLast.currentXpMax) {
- remaining = (int)interp(remaining, (int)(skillInfoLast.currentXpMax - skillInfoLast.currentXp));
- }
-
- lineMap.put(2, levelStr.toString());
- lineMap.put(3, EnumChatFormatting.AQUA+"Current XP: " + EnumChatFormatting.YELLOW+ format.format(current));
- if(remaining < 0) {
- lineMap.put(4, EnumChatFormatting.AQUA+"Remaining XP: " + EnumChatFormatting.YELLOW+ "MAXED!");
- lineMap.put(7, EnumChatFormatting.AQUA+"ETA: "+EnumChatFormatting.YELLOW+ "MAXED!");
- } else {
- lineMap.put(4, EnumChatFormatting.AQUA+"Remaining XP: " + EnumChatFormatting.YELLOW+ format.format(remaining));
- if(xpGainHour < 1000) {
- lineMap.put(7, EnumChatFormatting.AQUA+"ETA: "+EnumChatFormatting.YELLOW+ "N/A");
- } else {
- lineMap.put(7, EnumChatFormatting.AQUA+"ETA: "+EnumChatFormatting.YELLOW+ Utils.prettyTime((long)(remaining)*1000*60*60/(long)xpInterp));
- }
- }
-
- }
-
- float yaw = Minecraft.getMinecraft().thePlayer.rotationYawHead;
- yaw %= 360;
- if(yaw < 0) yaw += 360;
- if(yaw > 180) yaw -= 360;
-
- lineMap.put(6, EnumChatFormatting.AQUA+"Yaw: "+EnumChatFormatting.YELLOW+
- String.format("%.2f", yaw)+EnumChatFormatting.BOLD+"\u1D52");
-
- for(int strIndex : NotEnoughUpdates.INSTANCE.config.skillOverlays.farmingText) {
- if(lineMap.get(strIndex) != null) {
- overlayStrings.add(lineMap.get(strIndex));
- }
- }
- if(overlayStrings != null && overlayStrings.isEmpty()) overlayStrings = null;
- }
- }
-
-
+ private long lastUpdate = -1;
+ private int counterLast = -1;
+ private int counter = -1;
+ private int cultivatingLast = -1;
+ private int cultivating = -1;
+ private int cultivatingTier = -1;
+ private String cultivatingTierAmount = "1";
+ private int Farming = -1;
+ private int Alch = -1;
+ private int Foraging = -1;
+ private double Coins = -1;
+ private float cropsPerSecondLast = 0;
+ private float cropsPerSecond = 0;
+ private final LinkedList<Integer> counterQueue = new LinkedList<>();
+
+ private XPInformation.SkillInfo skillInfo = null;
+ private XPInformation.SkillInfo skillInfoLast = null;
+
+ private float lastTotalXp = -1;
+ private boolean isFarming = false;
+ private final LinkedList<Float> xpGainQueue = new LinkedList<>();
+ private float xpGainHourLast = -1;
+ private float xpGainHour = -1;
+
+ private int xpGainTimer = 0;
+
+ private String skillType = "Farming";
+
+ public FarmingOverlay(
+ Position position,
+ Supplier<List<String>> dummyStrings,
+ Supplier<TextOverlayStyle> styleSupplier
+ ) {
+ super(position, dummyStrings, styleSupplier);
+ }
+
+ private float interp(float now, float last) {
+ float interp = now;
+ if (last >= 0 && last != now) {
+ float factor = (System.currentTimeMillis() - lastUpdate) / 1000f;
+ factor = LerpUtils.clampZeroOne(factor);
+ interp = last + (now - last) * factor;
+ }
+ return interp;
+ }
+
+ @Override
+ public void update() {
+ if (!NotEnoughUpdates.INSTANCE.config.skillOverlays.farmingOverlay) {
+ counter = -1;
+ overlayStrings = null;
+ return;
+ }
+
+ lastUpdate = System.currentTimeMillis();
+ counterLast = counter;
+ cultivatingLast = cultivating;
+ xpGainHourLast = xpGainHour;
+ counter = -1;
+
+ if (Minecraft.getMinecraft().thePlayer == null) return;
+
+ ItemStack stack = Minecraft.getMinecraft().thePlayer.getHeldItem();
+ if (stack != null && stack.hasTagCompound()) {
+ NBTTagCompound tag = stack.getTagCompound();
+
+ if (tag.hasKey("ExtraAttributes", 10)) {
+ NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
+
+ if (ea.hasKey("mined_crops", 99)) {
+ counter = ea.getInteger("mined_crops");
+ cultivating = ea.getInteger("farmed_cultivating");
+ counterQueue.add(0, counter);
+ } else if (ea.hasKey("farmed_cultivating", 99)) {
+ counter = ea.getInteger("farmed_cultivating");
+ cultivating = ea.getInteger("farmed_cultivating");
+ counterQueue.add(0, counter);
+ }
+ }
+ }
+
+ if (cultivating < 1000) {
+ cultivatingTier = 1;
+ } else if (cultivating < 5000) {
+ cultivatingTier = 2;
+ } else if (cultivating < 25000) {
+ cultivatingTier = 3;
+ } else if (cultivating < 100000) {
+ cultivatingTier = 4;
+ } else if (cultivating < 300000) {
+ cultivatingTier = 5;
+ } else if (cultivating < 1500000) {
+ cultivatingTier = 6;
+ } else if (cultivating < 5000000) {
+ cultivatingTier = 7;
+ } else if (cultivating < 20000000) {
+ cultivatingTier = 8;
+ } else if (cultivating < 100000000) {
+ cultivatingTier = 9;
+ } else if (cultivating > 100000000) {
+ cultivatingTier = 10;
+ }
+
+ switch (cultivatingTier) {
+ case 1:
+ cultivatingTierAmount = "1,000";
+ break;
+ case 2:
+ cultivatingTierAmount = "5,000";
+ break;
+ case 3:
+ cultivatingTierAmount = "25,000";
+ break;
+ case 4:
+ cultivatingTierAmount = "100,000";
+ break;
+ case 5:
+ cultivatingTierAmount = "300,000";
+ break;
+ case 6:
+ cultivatingTierAmount = "1,500,000";
+ break;
+ case 7:
+ cultivatingTierAmount = "5,000,000";
+ break;
+ case 8:
+ cultivatingTierAmount = "20,000,000";
+ break;
+ case 9:
+ cultivatingTierAmount = "100,000,000";
+ break;
+ case 10:
+ cultivatingTierAmount = "Maxed";
+ break;
+ }
+
+ String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack);
+ if (internalname != null && internalname.startsWith("THEORETICAL_HOE_WARTS")) {
+ skillType = "Alchemy";
+ Farming = 0;
+ Alch = 1;
+ Foraging = 0;
+ } else if (internalname != null && internalname.startsWith("TREECAPITATOR_AXE") ||
+ (internalname != null && internalname.startsWith("JUNGLE_AXE"))) {
+ skillType = "Foraging";
+ Farming = 0;
+ Alch = 0;
+ Foraging = 1;
+ } else {
+ skillType = "Farming";
+ Farming = 1;
+ Alch = 0;
+ Foraging = 0;
+ }
+
+ if (!NotEnoughUpdates.INSTANCE.config.skillOverlays.useBZPrice || internalname != null && (internalname.equals(
+ "TREECAPITATOR_AXE"))
+ || internalname != null && (internalname.equals("JUNGLE_AXE"))) {
+ if (internalname != null && internalname.startsWith("THEORETICAL_HOE_WARTS") ||
+ (internalname != null && internalname.equals("COCO_CHOPPER"))) {
+ Coins = 3;
+ } else if (internalname != null && internalname.startsWith("THEORETICAL_HOE_POTATO") ||
+ (internalname != null && internalname.startsWith("THEORETICAL_HOE_CARROT"))
+ || (internalname != null && internalname.equals("CACTUS_KNIFE")) ||
+ (internalname != null && internalname.startsWith("THEORETICAL_HOE_WHEAT"))) {
+ Coins = 1;
+ } else if (internalname != null && internalname.startsWith("THEORETICAL_HOE_CANE") ||
+ (internalname != null && internalname.equals("TREECAPITATOR_AXE"))
+ || (internalname != null && internalname.equals("JUNGLE_AXE"))) {
+ Coins = 2;
+ } else if ((internalname != null && internalname.equals("PUMPKIN_DICER")) ||
+ (internalname != null && internalname.equals("FUNGI_CUTTER"))) {
+ Coins = 4;
+ } else if ((internalname != null && internalname.equals("MELON_DICER"))) {
+ Coins = 0.5;
+ } else {
+ Coins = 0;
+ }
+ }
+ if (NotEnoughUpdates.INSTANCE.config.skillOverlays.useBZPrice) {
+ if (internalname != null && internalname.startsWith("THEORETICAL_HOE_WARTS")) {
+ JsonObject crop = NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarInfo("ENCHANTED_NETHER_STALK");
+ if (crop != null) {
+ if (crop.has("curr_sell")) {
+ Coins = crop.get("curr_sell").getAsFloat() / 160;
+ }
+ }
+ } else if (internalname != null && internalname.startsWith("THEORETICAL_HOE_POTATO")) {
+ JsonObject crop = NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarInfo("ENCHANTED_POTATO");
+ if (crop != null) {
+ if (crop.has("curr_sell")) {
+ Coins = crop.get("curr_sell").getAsFloat() / 160;
+ }
+ }
+ } else if (internalname != null && internalname.startsWith("THEORETICAL_HOE_CARROT")) {
+ JsonObject crop = NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarInfo("ENCHANTED_CARROT");
+ if (crop != null) {
+ if (crop.has("curr_sell")) {
+ Coins = crop.get("curr_sell").getAsFloat() / 160;
+ }
+ }
+ } else if (internalname != null && internalname.startsWith("THEORETICAL_HOE_CANE")) {
+ JsonObject crop = NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarInfo("ENCHANTED_SUGAR");
+ if (crop != null) {
+ if (crop.has("curr_sell")) {
+ Coins = crop.get("curr_sell").getAsFloat() / 160;
+ }
+ }
+ } else if (internalname != null && internalname.startsWith("PUMPKIN_DICER")) {
+ JsonObject crop = NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarInfo("ENCHANTED_PUMPKIN");
+ if (crop != null) {
+ if (crop.has("curr_sell")) {
+ Coins = crop.get("curr_sell").getAsFloat() / 160;
+ }
+ }
+ } else if (internalname != null && internalname.startsWith("FUNGI_CUTTER")) {
+ JsonObject red = NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarInfo("ENCHANTED_RED_MUSHROOM");
+ JsonObject brown = NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarInfo("ENCHANTED_BROWN_MUSHROOM");
+ if (red != null && brown != null) {
+ if (red.has("curr_sell") && (brown.has("curr_sell"))) {
+ double crop = (red.get("curr_sell").getAsFloat() + red.get("curr_sell").getAsFloat()) / 2;
+ Coins = crop / 160;
+ }
+ }
+ } else if (internalname != null && internalname.startsWith("MELON_DICER")) {
+ JsonObject crop = NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarInfo("ENCHANTED_MELON");
+ if (crop != null) {
+ if (crop.has("curr_sell")) {
+ Coins = crop.get("curr_sell").getAsFloat() / 160;
+ }
+ }
+ } else if (internalname != null && internalname.startsWith("THEORETICAL_HOE_WHEAT")) {
+ JsonObject crop = NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarInfo("ENCHANTED_HAY_BLOCK");
+ if (crop != null) {
+ if (crop.has("curr_sell")) {
+ Coins = crop.get("curr_sell").getAsFloat() / 1296;
+ }
+ }
+ } else if (internalname != null && internalname.startsWith("CACTUS_KNIFE")) {
+ JsonObject crop = NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarInfo("ENCHANTED_CACTUS_GREEN");
+ if (crop != null) {
+ if (crop.has("curr_sell")) {
+ Coins = crop.get("curr_sell").getAsFloat() / 160;
+ }
+ }
+ }
+ }
+
+ skillInfoLast = skillInfo;
+ skillInfo = XPInformation.getInstance().getSkillInfo(skillType);
+ if (skillInfo != null) {
+ float totalXp = skillInfo.totalXp;
+
+ if (lastTotalXp > 0) {
+ float delta = totalXp - lastTotalXp;
+
+ if (delta > 0 && delta < 1000) {
+ xpGainTimer = 3;
+
+ xpGainQueue.add(0, delta);
+ while (xpGainQueue.size() > 30) {
+ xpGainQueue.removeLast();
+ }
+
+ float totalGain = 0;
+ for (float f : xpGainQueue) totalGain += f;
+
+ xpGainHour = totalGain * (60 * 60) / xpGainQueue.size();
+
+ isFarming = true;
+ } else if (xpGainTimer > 0) {
+ xpGainTimer--;
+
+ xpGainQueue.add(0, 0f);
+ while (xpGainQueue.size() > 30) {
+ xpGainQueue.removeLast();
+ }
+
+ float totalGain = 0;
+ for (float f : xpGainQueue) totalGain += f;
+
+ xpGainHour = totalGain * (60 * 60) / xpGainQueue.size();
+
+ isFarming = true;
+ } else if (delta <= 0) {
+ isFarming = false;
+ }
+ }
+
+ lastTotalXp = totalXp;
+ }
+
+ while (counterQueue.size() >= 4) {
+ counterQueue.removeLast();
+ }
+
+ if (counterQueue.isEmpty()) {
+ cropsPerSecond = -1;
+ cropsPerSecondLast = 0;
+ } else {
+ cropsPerSecondLast = cropsPerSecond;
+ int last = counterQueue.getLast();
+ int first = counterQueue.getFirst();
+
+ cropsPerSecond = (first - last) / 3f;
+ }
+
+ if (counter != -1) {
+ overlayStrings = new ArrayList<>();
+ } else {
+ overlayStrings = null;
+ }
+
+ }
+
+ @Override
+ public void updateFrequent() {
+ super.updateFrequent();
+
+ if (counter < 0) {
+ overlayStrings = null;
+ } else {
+ HashMap<Integer, String> lineMap = new HashMap<>();
+
+ overlayStrings = new ArrayList<>();
+
+ NumberFormat format = NumberFormat.getIntegerInstance();
+
+ if (counter >= 0 && cultivating != counter) {
+ int counterInterp = (int) interp(counter, counterLast);
+
+ lineMap.put(
+ 0,
+ EnumChatFormatting.AQUA + "Counter: " + EnumChatFormatting.YELLOW + format.format(counterInterp)
+ );
+ }
+
+ if (counter >= 0) {
+ if (cropsPerSecondLast == cropsPerSecond && cropsPerSecond <= 0) {
+ lineMap.put(
+ 1,
+ EnumChatFormatting.AQUA + (Foraging == 1 ? "Logs/m: " : "Crops/m: ") + EnumChatFormatting.YELLOW + "N/A"
+ );
+ } else {
+ float cpsInterp = interp(cropsPerSecond, cropsPerSecondLast);
+
+ lineMap.put(
+ 1,
+ EnumChatFormatting.AQUA + (Foraging == 1 ? "Logs/m: " : "Crops/m: ") + EnumChatFormatting.YELLOW +
+ String.format("%,.2f", cpsInterp * 60)
+ );
+ }
+ }
+
+ if (counter >= 0 && Coins > 0) {
+ if (cropsPerSecondLast == cropsPerSecond && cropsPerSecond <= 0) {
+ lineMap.put(10, EnumChatFormatting.AQUA + "Coins/m: " + EnumChatFormatting.YELLOW + "N/A");
+ } else {
+ float cpsInterp = interp(cropsPerSecond, cropsPerSecondLast);
+
+ lineMap.put(10, EnumChatFormatting.AQUA + "Coins/m: " + EnumChatFormatting.YELLOW +
+ String.format("%,.2f", (cpsInterp * 60) * Coins));
+ }
+ }
+
+ if (cultivatingTier <= 9 && cultivating > 0) {
+ int counterInterp = (int) interp(cultivating, cultivatingLast);
+ lineMap.put(
+ 9,
+ EnumChatFormatting.AQUA + "Cultivating: " + EnumChatFormatting.YELLOW + format.format(counterInterp) + "/" +
+ cultivatingTierAmount
+ );
+ }
+ if (cultivatingTier == 10) {
+ int counterInterp = (int) interp(cultivating, cultivatingLast);
+ lineMap.put(
+ 9,
+ EnumChatFormatting.AQUA + "Cultivating: " + EnumChatFormatting.YELLOW + format.format(counterInterp)
+ );
+ }
+
+ float xpInterp = xpGainHour;
+ if (xpGainHourLast == xpGainHour && xpGainHour <= 0) {
+ lineMap.put(5, EnumChatFormatting.AQUA + "XP/h: " + EnumChatFormatting.YELLOW + "N/A");
+ } else {
+ xpInterp = interp(xpGainHour, xpGainHourLast);
+
+ lineMap.put(5, EnumChatFormatting.AQUA + "XP/h: " + EnumChatFormatting.YELLOW +
+ format.format(xpInterp) + (isFarming ? "" : EnumChatFormatting.RED + " (PAUSED)"));
+ }
+
+ if (skillInfo != null && skillInfo.level < 60) {
+ StringBuilder levelStr = new StringBuilder(EnumChatFormatting.AQUA + skillType + ": ");
+
+ levelStr.append(EnumChatFormatting.YELLOW)
+ .append(skillInfo.level)
+ .append(EnumChatFormatting.GRAY)
+ .append(" [");
+
+ float progress = skillInfo.currentXp / skillInfo.currentXpMax;
+ if (skillInfoLast != null && skillInfo.currentXpMax == skillInfoLast.currentXpMax) {
+ progress = interp(progress, skillInfoLast.currentXp / skillInfoLast.currentXpMax);
+ }
+
+ float lines = 25;
+ for (int i = 0; i < lines; i++) {
+ if (i / lines < progress) {
+ levelStr.append(EnumChatFormatting.YELLOW);
+ } else {
+ levelStr.append(EnumChatFormatting.DARK_GRAY);
+ }
+ levelStr.append('|');
+ }
+
+ levelStr.append(EnumChatFormatting.GRAY)
+ .append("] ")
+ .append(EnumChatFormatting.YELLOW)
+ .append((int) (progress * 100))
+ .append("%");
+
+ int current = (int) skillInfo.currentXp;
+ if (skillInfoLast != null && skillInfo.currentXpMax == skillInfoLast.currentXpMax) {
+ current = (int) interp(current, skillInfoLast.currentXp);
+ }
+
+ int remaining = (int) (skillInfo.currentXpMax - skillInfo.currentXp);
+ if (skillInfoLast != null && skillInfo.currentXpMax == skillInfoLast.currentXpMax) {
+ remaining = (int) interp(remaining, (int) (skillInfoLast.currentXpMax - skillInfoLast.currentXp));
+ }
+
+ lineMap.put(2, levelStr.toString());
+ lineMap.put(3, EnumChatFormatting.AQUA + "Current XP: " + EnumChatFormatting.YELLOW + format.format(current));
+ if (remaining < 0) {
+ lineMap.put(4, EnumChatFormatting.AQUA + "Remaining XP: " + EnumChatFormatting.YELLOW + "MAXED!");
+ lineMap.put(7, EnumChatFormatting.AQUA + "ETA: " + EnumChatFormatting.YELLOW + "MAXED!");
+ } else {
+ lineMap.put(
+ 4,
+ EnumChatFormatting.AQUA + "Remaining XP: " + EnumChatFormatting.YELLOW + format.format(remaining)
+ );
+ if (xpGainHour < 1000) {
+ lineMap.put(7, EnumChatFormatting.AQUA + "ETA: " + EnumChatFormatting.YELLOW + "N/A");
+ } else {
+ lineMap.put(
+ 7,
+ EnumChatFormatting.AQUA + "ETA: " + EnumChatFormatting.YELLOW +
+ Utils.prettyTime((long) (remaining) * 1000 * 60 * 60 / (long) xpInterp)
+ );
+ }
+ }
+
+ }
+
+ if (skillInfo != null && skillInfo.level == 60 || Alch == 1 && skillInfo != null && skillInfo.level == 50) {
+ int current = (int) skillInfo.currentXp;
+ if (skillInfoLast != null && skillInfo.currentXpMax == skillInfoLast.currentXpMax) {
+ current = (int) interp(current, skillInfoLast.currentXp);
+ }
+
+ if (Alch == 0) {
+ lineMap.put(
+ 2,
+ EnumChatFormatting.AQUA + "Farming: " + EnumChatFormatting.YELLOW + "60 " + EnumChatFormatting.RED +
+ "(Maxed)"
+ );
+ } else if (Foraging == 1) {
+ lineMap.put(
+ 2,
+ EnumChatFormatting.AQUA + "Foraging: " + EnumChatFormatting.YELLOW + "50 " + EnumChatFormatting.RED +
+ "(Maxed)"
+ );
+ } else {
+ lineMap.put(
+ 2,
+ EnumChatFormatting.AQUA + "Alch: " + EnumChatFormatting.YELLOW + "50 " + EnumChatFormatting.RED + "(Maxed)"
+ );
+ }
+ lineMap.put(3, EnumChatFormatting.AQUA + "Current XP: " + EnumChatFormatting.YELLOW + format.format(current));
+
+ }
+
+ float yaw = Minecraft.getMinecraft().thePlayer.rotationYawHead;
+ float pitch = Minecraft.getMinecraft().thePlayer.rotationPitch;
+ yaw %= 360;
+ if (yaw < 0) yaw += 360;
+ if (yaw > 180) yaw -= 360;
+ pitch %= 360;
+ if (pitch < 0) pitch += 360;
+ if (pitch > 180) pitch -= 360;
+
+ lineMap.put(6, EnumChatFormatting.AQUA + "Yaw: " + EnumChatFormatting.YELLOW +
+ String.format("%.2f", yaw) + EnumChatFormatting.BOLD + "\u1D52");
+
+ lineMap.put(8, EnumChatFormatting.AQUA + "Pitch: " + EnumChatFormatting.YELLOW +
+ String.format("%.2f", pitch) + EnumChatFormatting.BOLD + "\u1D52");
+
+ for (int strIndex : NotEnoughUpdates.INSTANCE.config.skillOverlays.farmingText) {
+ if (lineMap.get(strIndex) != null) {
+ overlayStrings.add(lineMap.get(strIndex));
+ }
+ }
+ if (overlayStrings != null && overlayStrings.isEmpty()) overlayStrings = null;
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/FishingSkillOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/FishingSkillOverlay.java
new file mode 100644
index 00000000..6f7b21d8
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/FishingSkillOverlay.java
@@ -0,0 +1,405 @@
+package io.github.moulberry.notenoughupdates.overlays;
+
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.core.config.KeybindHelper;
+import io.github.moulberry.notenoughupdates.core.config.Position;
+import io.github.moulberry.notenoughupdates.core.util.lerp.LerpUtils;
+import io.github.moulberry.notenoughupdates.util.Utils;
+import io.github.moulberry.notenoughupdates.util.XPInformation;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.audio.ISound;
+import net.minecraft.client.audio.PositionedSound;
+import net.minecraft.client.audio.SoundCategory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.ResourceLocation;
+
+import java.text.NumberFormat;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.function.Supplier;
+
+public class FishingSkillOverlay
+ extends TextOverlay { //Im sure there is a much better way to do this besides making another class ¯\_(ツ)_/¯
+
+ private long lastUpdate = -1;
+ private long timer = -1;
+ private int expertiseLast = -1;
+ private int expertise = -1;
+ private int expertiseTier = -1;
+ private String expertiseTierAmount = "1";
+ private float fishedPerSecondLast = 0;
+ private float fishedPerSecond = 0;
+ private final LinkedList<Integer> expertiseQueue = new LinkedList<>();
+
+ private XPInformation.SkillInfo skillInfo = null;
+ private XPInformation.SkillInfo skillInfoLast = null;
+
+ private float lastTotalXp = -1;
+ private boolean isFishing = false;
+ private final LinkedList<Float> xpGainQueue = new LinkedList<>();
+ private float xpGainHourLast = -1;
+ private float xpGainHour = -1;
+
+ private int xpGainTimer = 0;
+
+ private final String skillType = "Fishing";
+
+ public FishingSkillOverlay(
+ Position position,
+ Supplier<List<String>> dummyStrings,
+ Supplier<TextOverlayStyle> styleSupplier
+ ) {
+ super(position, dummyStrings, styleSupplier);
+ }
+
+ private float interp(float now, float last) {
+ float interp = now;
+ if (last >= 0 && last != now) {
+ float factor = (System.currentTimeMillis() - lastUpdate) / 1000f;
+ factor = LerpUtils.clampZeroOne(factor);
+ interp = last + (now - last) * factor;
+ }
+ return interp;
+ }
+
+ @Override
+ public void update() {
+ if (!NotEnoughUpdates.INSTANCE.config.skillOverlays.FishingSkillOverlay) {
+ expertise = -1;
+ overlayStrings = null;
+ return;
+ }
+
+ lastUpdate = System.currentTimeMillis();
+ expertiseLast = expertise;
+ xpGainHourLast = xpGainHour;
+ expertise = -1;
+
+ if (Minecraft.getMinecraft().thePlayer == null) return;
+
+ ItemStack stack = Minecraft.getMinecraft().thePlayer.getHeldItem();
+ if (stack != null && stack.hasTagCompound()) {
+ NBTTagCompound tag = stack.getTagCompound();
+
+ if (tag.hasKey("ExtraAttributes", 10)) {
+ NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
+
+ if (ea.hasKey("expertise_kills", 99)) {
+ expertise = ea.getInteger("expertise_kills");
+ expertiseQueue.add(0, expertise);
+ }
+ }
+ }
+
+ if (expertise < 50) {
+ expertiseTier = 1;
+ } else if (expertise < 100) {
+ expertiseTier = 2;
+ } else if (expertise < 250) {
+ expertiseTier = 3;
+ } else if (expertise < 500) {
+ expertiseTier = 4;
+ } else if (expertise < 1000) {
+ expertiseTier = 5;
+ } else if (expertise < 2500) {
+ expertiseTier = 6;
+ } else if (expertise < 5500) {
+ expertiseTier = 7;
+ } else if (expertise < 10000) {
+ expertiseTier = 8;
+ } else if (expertise < 15000) {
+ expertiseTier = 9;
+ } else if (expertise > 15000) {
+ expertiseTier = 10;
+ }
+
+ switch (expertiseTier) {
+ case 1:
+ expertiseTierAmount = "50";
+ break;
+ case 2:
+ expertiseTierAmount = "100";
+ break;
+ case 3:
+ expertiseTierAmount = "250";
+ break;
+ case 4:
+ expertiseTierAmount = "500";
+ break;
+ case 5:
+ expertiseTierAmount = "1,000";
+ break;
+ case 6:
+ expertiseTierAmount = "2,500";
+ break;
+ case 7:
+ expertiseTierAmount = "5,500";
+ break;
+ case 8:
+ expertiseTierAmount = "10,000";
+ break;
+ case 9:
+ expertiseTierAmount = "15,000";
+ break;
+ case 10:
+ expertiseTierAmount = "Maxed";
+ break;
+ }
+
+ String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack);
+
+ skillInfoLast = skillInfo;
+ skillInfo = XPInformation.getInstance().getSkillInfo(skillType);
+ if (skillInfo != null) {
+ float totalXp = skillInfo.totalXp;
+
+ if (lastTotalXp > 0) {
+ float delta = totalXp - lastTotalXp;
+
+ if (delta > 0 && delta < 1000) {
+ xpGainTimer = 3;
+
+ xpGainQueue.add(0, delta);
+ while (xpGainQueue.size() > 30) {
+ xpGainQueue.removeLast();
+ }
+
+ float totalGain = 0;
+ for (float f : xpGainQueue) totalGain += f;
+
+ xpGainHour = totalGain * (60 * 60) / xpGainQueue.size();
+
+ isFishing = true;
+ } else if (xpGainTimer > 0) {
+ xpGainTimer--;
+
+ xpGainQueue.add(0, 0f);
+ while (xpGainQueue.size() > 30) {
+ xpGainQueue.removeLast();
+ }
+
+ float totalGain = 0;
+ for (float f : xpGainQueue) totalGain += f;
+
+ xpGainHour = totalGain * (60 * 60) / xpGainQueue.size();
+
+ isFishing = true;
+ } else if (delta <= 0) {
+ isFishing = false;
+ }
+ }
+
+ lastTotalXp = totalXp;
+ }
+
+ while (expertiseQueue.size() >= 4) {
+ expertiseQueue.removeLast();
+ }
+
+ if (expertiseQueue.isEmpty()) {
+ fishedPerSecond = -1;
+ fishedPerSecondLast = 0;
+ } else {
+ fishedPerSecondLast = fishedPerSecond;
+ int last = expertiseQueue.getLast();
+ int first = expertiseQueue.getFirst();
+
+ fishedPerSecond = (first - last) / 3f;
+ }
+
+ if (expertise != -1) {
+ overlayStrings = new ArrayList<>();
+ } else {
+ overlayStrings = null;
+ }
+
+ }
+
+ @Override
+ public void updateFrequent() {
+ super.updateFrequent();
+
+ if (expertise < 0) {
+ overlayStrings = null;
+ } else {
+ HashMap<Integer, String> lineMap = new HashMap<>();
+
+ overlayStrings = new ArrayList<>();
+
+ NumberFormat format = NumberFormat.getIntegerInstance();
+
+ /*if(expertise >= 0) {
+ int counterInterp = (int)interp(expertise, expertiseLast);
+
+ lineMap.put(0, EnumChatFormatting.AQUA+"Expertise Kills: "+EnumChatFormatting.YELLOW+format.format(counterInterp));
+ }*/
+
+
+ /*if(expertise >= 0) {
+ if(fishedPerSecondLast == fishedPerSecond && fishedPerSecond <= 0) {
+ lineMap.put(7, EnumChatFormatting.AQUA+"Catches/m: "+EnumChatFormatting.YELLOW + "N/A");
+ } else {
+ //float cpsInterp = interp(fishedPerSecond, fishedPerSecondLast);
+
+ lineMap.put(7, EnumChatFormatting.AQUA+"Catches/m: "+EnumChatFormatting.YELLOW +
+ fishedPerSecond);
+ //String.format("%.2f", cpsInterp*60));
+ }
+ }*/
+
+ if (expertiseTier <= 9) {
+ int counterInterp = (int) interp(expertise, expertiseLast);
+ lineMap.put(
+ 0,
+ EnumChatFormatting.AQUA + "Expertise: " + EnumChatFormatting.YELLOW + format.format(counterInterp) + "/" +
+ expertiseTierAmount
+ );
+ }
+ if (expertiseTier == 10) {
+ int counterInterp = (int) interp(expertise, expertiseLast);
+ lineMap.put(
+ 0,
+ EnumChatFormatting.AQUA + "Expertise: " + EnumChatFormatting.YELLOW + format.format(counterInterp) + " " +
+ EnumChatFormatting.RED + expertiseTierAmount
+ );
+ }
+
+ float xpInterp = xpGainHour;
+ if (xpGainHourLast == xpGainHour && xpGainHour <= 0) {
+ lineMap.put(4, EnumChatFormatting.AQUA + "XP/h: " + EnumChatFormatting.YELLOW + "N/A");
+ } else {
+ xpInterp = interp(xpGainHour, xpGainHourLast);
+
+ lineMap.put(4, EnumChatFormatting.AQUA + "XP/h: " + EnumChatFormatting.YELLOW +
+ format.format(xpInterp) + (isFishing ? "" : EnumChatFormatting.RED + " (PAUSED)"));
+ }
+
+ if (skillInfo != null && skillInfo.level < 50) {
+ StringBuilder levelStr = new StringBuilder(EnumChatFormatting.AQUA + skillType + ": ");
+
+ levelStr.append(EnumChatFormatting.YELLOW)
+ .append(skillInfo.level)
+ .append(EnumChatFormatting.GRAY)
+ .append(" [");
+
+ float progress = skillInfo.currentXp / skillInfo.currentXpMax;
+ if (skillInfoLast != null && skillInfo.currentXpMax == skillInfoLast.currentXpMax) {
+ progress = interp(progress, skillInfoLast.currentXp / skillInfoLast.currentXpMax);
+ }
+
+ float lines = 25;
+ for (int i = 0; i < lines; i++) {
+ if (i / lines < progress) {
+ levelStr.append(EnumChatFormatting.YELLOW);
+ } else {
+ levelStr.append(EnumChatFormatting.DARK_GRAY);
+ }
+ levelStr.append('|');
+ }
+
+ levelStr.append(EnumChatFormatting.GRAY)
+ .append("] ")
+ .append(EnumChatFormatting.YELLOW)
+ .append((int) (progress * 100))
+ .append("%");
+
+ int current = (int) skillInfo.currentXp;
+ if (skillInfoLast != null && skillInfo.currentXpMax == skillInfoLast.currentXpMax) {
+ current = (int) interp(current, skillInfoLast.currentXp);
+ }
+
+ int remaining = (int) (skillInfo.currentXpMax - skillInfo.currentXp);
+ if (skillInfoLast != null && skillInfo.currentXpMax == skillInfoLast.currentXpMax) {
+ remaining = (int) interp(remaining, (int) (skillInfoLast.currentXpMax - skillInfoLast.currentXp));
+ }
+
+ lineMap.put(1, levelStr.toString());
+ lineMap.put(2, EnumChatFormatting.AQUA + "Current XP: " + EnumChatFormatting.YELLOW + format.format(current));
+ if (remaining < 0) {
+ lineMap.put(3, EnumChatFormatting.AQUA + "Remaining XP: " + EnumChatFormatting.YELLOW + "MAXED!");
+ lineMap.put(5, EnumChatFormatting.AQUA + "ETA: " + EnumChatFormatting.YELLOW + "MAXED!");
+ } else {
+ lineMap.put(
+ 3,
+ EnumChatFormatting.AQUA + "Remaining XP: " + EnumChatFormatting.YELLOW + format.format(remaining)
+ );
+ if (xpGainHour < 1000) {
+ lineMap.put(5, EnumChatFormatting.AQUA + "ETA: " + EnumChatFormatting.YELLOW + "N/A");
+ } else {
+ lineMap.put(
+ 5,
+ EnumChatFormatting.AQUA + "ETA: " + EnumChatFormatting.YELLOW +
+ Utils.prettyTime((long) (remaining) * 1000 * 60 * 60 / (long) xpInterp)
+ );
+ }
+ }
+
+ }
+
+ if (skillInfo != null && skillInfo.level == 50) {
+ int current = (int) skillInfo.currentXp;
+ if (skillInfoLast != null && skillInfo.currentXpMax == skillInfoLast.currentXpMax) {
+ current = (int) interp(current, skillInfoLast.currentXp);
+ }
+
+ lineMap.put(
+ 1,
+ EnumChatFormatting.AQUA + "Fishing: " + EnumChatFormatting.YELLOW + "50 " + EnumChatFormatting.RED + "(Maxed)"
+ );
+ lineMap.put(2, EnumChatFormatting.AQUA + "Current XP: " + EnumChatFormatting.YELLOW + format.format(current));
+
+ }
+
+ /*float yaw = Minecraft.getMinecraft().thePlayer.rotationYawHead;
+ yaw %= 360;
+ if(yaw < 0) yaw += 360;
+ if(yaw > 180) yaw -= 360;
+
+ lineMap.put(6, EnumChatFormatting.AQUA+"Yaw: "+EnumChatFormatting.YELLOW+
+ String.format("%.2f", yaw)+EnumChatFormatting.BOLD+"\u1D52");*/
+ int key = NotEnoughUpdates.INSTANCE.config.skillOverlays.fishKey;
+
+ ISound sound = new PositionedSound(new ResourceLocation("random.orb")) {{
+ volume = 50;
+ repeat = false;
+ repeatDelay = 0;
+ attenuationType = ISound.AttenuationType.NONE;
+ }};
+
+ int funnyCustomTimer = 1000 * NotEnoughUpdates.INSTANCE.config.skillOverlays.customFishTimer;
+ if (KeybindHelper.isKeyPressed(key) && timer != 0 && System.currentTimeMillis() - timer > 1000) {
+ timer = 0;
+ } else if (KeybindHelper.isKeyPressed(key) && timer == 0) {
+ timer = System.currentTimeMillis();
+ }
+ if (timer >= 1) {
+ lineMap.put(
+ 6,
+ EnumChatFormatting.AQUA + "Timer: " + EnumChatFormatting.YELLOW +
+ Utils.prettyTime(System.currentTimeMillis() - (timer))
+ );
+ }
+ if (timer <= 0) {
+ lineMap.put(6, EnumChatFormatting.AQUA + "Timer: " + EnumChatFormatting.RED + "(Stopped)");
+ }
+ if (System.currentTimeMillis() - timer > funnyCustomTimer &&
+ System.currentTimeMillis() - timer < (funnyCustomTimer + 100) && funnyCustomTimer != 0) {
+ float oldLevel = Minecraft.getMinecraft().gameSettings.getSoundLevel(SoundCategory.PLAYERS);
+ Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.PLAYERS, 1);
+ Minecraft.getMinecraft().getSoundHandler().playSound(sound);
+ Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.PLAYERS, oldLevel);
+ }
+
+ for (int strIndex : NotEnoughUpdates.INSTANCE.config.skillOverlays.fishingText) {
+ if (lineMap.get(strIndex) != null) {
+ overlayStrings.add(lineMap.get(strIndex));
+ }
+ }
+ if (overlayStrings != null && overlayStrings.isEmpty()) overlayStrings = null;
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBar.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBar.java
index 25148ba3..fa2db8b5 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBar.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBar.java
@@ -2,7 +2,6 @@ package io.github.moulberry.notenoughupdates.overlays;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.core.config.Position;
-import io.github.moulberry.notenoughupdates.options.NEUConfig;
import io.github.moulberry.notenoughupdates.util.SBInfo;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
@@ -18,153 +17,169 @@ import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL14;
import java.awt.*;
-import java.util.Random;
public class FuelBar {
-
- public static final ResourceLocation FUEL_BAR = new ResourceLocation("notenoughupdates:fuel_bar.png");
-
- private float fuelAmount = -1;
- private String fuelString = "";
-
- @SubscribeEvent
- public void onTick(TickEvent.ClientTickEvent event) {
- fuelAmount = -1;
-
- if(SBInfo.getInstance().getLocation() == null) return;
- if(!(SBInfo.getInstance().getLocation().startsWith("mining_")||SBInfo.getInstance().getLocation().equals("crystal_hollows"))) return;
-
- if(Minecraft.getMinecraft().thePlayer == null) return;
- if(!NotEnoughUpdates.INSTANCE.config.mining.drillFuelBar) return;
-
- ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem();
- if(held != null) {
- String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held);
- if(internalname != null && (internalname.contains("_DRILL_") || internalname.equals("DIVAN_DRILL"))) {
- String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(held.getTagCompound());
- for(String line : lore) {
- try {
- if(line.startsWith("\u00A77Fuel: ")) {
- String[] split = Utils.cleanColour(line).split("/");
- if(split.length == 2) {
- String fuelS = split[0].split(" ")[1];
- int fuel = Integer.parseInt(fuelS.replace(",","").trim());
-
- String maxFuelS = split[1].trim();
- int mult = 1;
- if(maxFuelS.endsWith("k")) {
- mult = 1000;
- }
- int maxFuel = Integer.parseInt(maxFuelS.replace("k", "").trim())*mult;
- fuelAmount = fuel/(float)maxFuel;
- if(fuelAmount > 1) {
- fuelAmount = 1;
- }
- fuelString = line;
-
- break;
- }
- }
- } catch(Exception ignored) {}
- }
- }
- }
- }
-
- @SubscribeEvent
- public void onRenderScreen(RenderGameOverlayEvent.Post event) {
- if(fuelAmount < 0) return;
- if(!NotEnoughUpdates.INSTANCE.config.mining.drillFuelBar) return;
- if(event.type == RenderGameOverlayEvent.ElementType.ALL) {
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
-
- Position position = NotEnoughUpdates.INSTANCE.config.mining.drillFuelBarPosition;
- int x = position.getAbsX(scaledResolution, NotEnoughUpdates.INSTANCE.config.mining.drillFuelBarWidth);
- int y = position.getAbsY(scaledResolution, 12);
- x -= NotEnoughUpdates.INSTANCE.config.mining.drillFuelBarWidth/2;
- renderBar(x, y+4, NotEnoughUpdates.INSTANCE.config.mining.drillFuelBarWidth, fuelAmount);
-
- String str = fuelString.replace("\u00A77", EnumChatFormatting.DARK_GREEN.toString()) +
- EnumChatFormatting.GOLD + String.format(" (%d%%)", (int)(fuelAmount*100));
-
- GlStateManager.enableBlend();
- GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
- GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
-
- String clean = Utils.cleanColourNotModifiers(str);
- for(int xO=-2; xO<=2; xO++) {
- for(int yO=-2; yO<=2; yO++) {
- if(Math.abs(xO) != Math.abs(yO)) {
- Minecraft.getMinecraft().fontRendererObj.drawString(clean,
- x+2+xO/2f, y+yO/2f,
- new Color(0, 0, 0, 200/Math.max(Math.abs(xO), Math.abs(yO))).getRGB(), false);
- }
- }
- }
- Minecraft.getMinecraft().fontRendererObj.drawString(str,
- x+2, y, 0xffffff, false);
- }
- }
-
- private void renderBarCap(float x, float y, boolean left, float rCapSize, float completion) {
- float size = left ? 10 : rCapSize;
- int startTexX = left ? 0 : (170 + 11-(int)Math.ceil(rCapSize));
-
- if(completion < 1) {
- Utils.drawTexturedRect(x, y, size, 5,
- startTexX/181f, 1, 0/10f, 5/10f, GL11.GL_NEAREST);
- }
- if(completion > 0) {
- Utils.drawTexturedRect(x, y, size*completion, 5,
- startTexX/181f, (startTexX+size*completion)/181f, 5/10f, 10/10f, GL11.GL_NEAREST);
- }
- }
-
- private void renderBarNotch(float x, float y, int id, float completion) {
- id = id % 16;
-
- int startTexX = 10 + id*10;
-
- if(completion < 1) {
- Utils.drawTexturedRect(x, y, 10, 5,
- startTexX/181f, (startTexX+10)/181f, 0/10f, 5/10f, GL11.GL_NEAREST);
- }
- if(completion > 0) {
- Utils.drawTexturedRect(x, y, 10*completion, 5,
- startTexX/181f, (startTexX+10*completion)/181f, 5/10f, 10/10f, GL11.GL_NEAREST);
- }
-
- }
-
- private void renderBar(float x, float y, float xSize, float completed) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(FUEL_BAR);
-
- GlStateManager.pushMatrix();
- GlStateManager.translate(x, y, 0);
- xSize = xSize/1.5f;
- GlStateManager.scale(1.5f, 1.5f, 1);
-
- Color c = Color.getHSBColor(148/360f*completed-20/360f, 0.9f, 1-0.5f*completed);
- GlStateManager.color(c.getRed()/255f, c.getGreen()/255f, c.getBlue()/255f, 1);
-
- float offsetCompleteX = xSize*completed;
- for(int xOffset = 0; xOffset < xSize; xOffset += 10) {
- float notchCompl = 1;
- if(xOffset > offsetCompleteX) {
- notchCompl = 0;
- } else if(xOffset+10 > offsetCompleteX) {
- notchCompl = (offsetCompleteX-xOffset)/10f;
- }
- if(xOffset == 0) {
- renderBarCap(0, 0, true, 0, notchCompl);
- } else if(xOffset + 11 > xSize) {
- renderBarCap(xOffset, 0, false, xSize-xOffset, notchCompl);
- } else {
- renderBarNotch(xOffset, 0, xOffset/10, notchCompl);
- }
- }
-
- GlStateManager.popMatrix();
- }
-
+ public static final ResourceLocation FUEL_BAR = new ResourceLocation("notenoughupdates:fuel_bar.png");
+
+ private float fuelAmount = -1;
+ private String fuelString = "";
+
+ @SubscribeEvent
+ public void onTick(TickEvent.ClientTickEvent event) {
+ fuelAmount = -1;
+
+ if (SBInfo.getInstance().getLocation() == null) return;
+ if (!(SBInfo.getInstance().getLocation().startsWith("mining_") || SBInfo.getInstance().getLocation().equals(
+ "crystal_hollows")))
+ return;
+
+ if (Minecraft.getMinecraft().thePlayer == null) return;
+ if (!NotEnoughUpdates.INSTANCE.config.mining.drillFuelBar) return;
+
+ ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem();
+ if (held != null) {
+ String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held);
+ if (internalname != null && (internalname.contains("_DRILL_") || internalname.equals("DIVAN_DRILL"))) {
+ String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(held.getTagCompound());
+ for (String line : lore) {
+ try {
+ if (line.startsWith("\u00A77Fuel: ")) {
+ String[] split = Utils.cleanColour(line).split("/");
+ if (split.length == 2) {
+ String fuelS = split[0].split(" ")[1];
+ int fuel = Integer.parseInt(fuelS.replace(",", "").trim());
+
+ String maxFuelS = split[1].trim();
+ int mult = 1;
+ if (maxFuelS.endsWith("k")) {
+ mult = 1000;
+ }
+ int maxFuel = Integer.parseInt(maxFuelS.replace("k", "").trim()) * mult;
+ fuelAmount = fuel / (float) maxFuel;
+ if (fuelAmount > 1) {
+ fuelAmount = 1;
+ }
+ fuelString = line;
+
+ break;
+ }
+ }
+ } catch (Exception ignored) {
+ }
+ }
+ }
+ }
+ }
+
+ @SubscribeEvent
+ public void onRenderScreen(RenderGameOverlayEvent.Post event) {
+ if (fuelAmount < 0) return;
+ if (!NotEnoughUpdates.INSTANCE.config.mining.drillFuelBar) return;
+ if (event.type == RenderGameOverlayEvent.ElementType.ALL) {
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+
+ Position position = NotEnoughUpdates.INSTANCE.config.mining.drillFuelBarPosition;
+ int x = position.getAbsX(scaledResolution, NotEnoughUpdates.INSTANCE.config.mining.drillFuelBarWidth);
+ int y = position.getAbsY(scaledResolution, 12);
+ x -= NotEnoughUpdates.INSTANCE.config.mining.drillFuelBarWidth / 2;
+ renderBar(x, y + 4, NotEnoughUpdates.INSTANCE.config.mining.drillFuelBarWidth, fuelAmount);
+
+ String str = fuelString.replace("\u00A77", EnumChatFormatting.DARK_GREEN.toString()) +
+ EnumChatFormatting.GOLD + String.format(" (%d%%)", (int) (fuelAmount * 100));
+
+ GlStateManager.enableBlend();
+ GL14.glBlendFuncSeparate(
+ GL11.GL_SRC_ALPHA,
+ GL11.GL_ONE_MINUS_SRC_ALPHA,
+ GL11.GL_ONE,
+ GL11.GL_ONE_MINUS_SRC_ALPHA
+ );
+ GlStateManager.tryBlendFuncSeparate(
+ GL11.GL_SRC_ALPHA,
+ GL11.GL_ONE_MINUS_SRC_ALPHA,
+ GL11.GL_ONE,
+ GL11.GL_ONE_MINUS_SRC_ALPHA
+ );
+
+ String clean = Utils.cleanColourNotModifiers(str);
+ for (int xO = -2; xO <= 2; xO++) {
+ for (int yO = -2; yO <= 2; yO++) {
+ if (Math.abs(xO) != Math.abs(yO)) {
+ Minecraft.getMinecraft().fontRendererObj.drawString(clean,
+ x + 2 + xO / 2f, y + yO / 2f,
+ new Color(0, 0, 0, 200 / Math.max(Math.abs(xO), Math.abs(yO))).getRGB(), false
+ );
+ }
+ }
+ }
+ Minecraft.getMinecraft().fontRendererObj.drawString(str,
+ x + 2, y, 0xffffff, false
+ );
+ }
+ }
+
+ private void renderBarCap(float x, float y, boolean left, float rCapSize, float completion) {
+ float size = left ? 10 : rCapSize;
+ int startTexX = left ? 0 : (170 + 11 - (int) Math.ceil(rCapSize));
+
+ if (completion < 1) {
+ Utils.drawTexturedRect(x, y, size, 5,
+ startTexX / 181f, 1, 0 / 10f, 5 / 10f, GL11.GL_NEAREST
+ );
+ }
+ if (completion > 0) {
+ Utils.drawTexturedRect(x, y, size * completion, 5,
+ startTexX / 181f, (startTexX + size * completion) / 181f, 5 / 10f, 10 / 10f, GL11.GL_NEAREST
+ );
+ }
+ }
+
+ private void renderBarNotch(float x, float y, int id, float completion) {
+ id = id % 16;
+
+ int startTexX = 10 + id * 10;
+
+ if (completion < 1) {
+ Utils.drawTexturedRect(x, y, 10, 5,
+ startTexX / 181f, (startTexX + 10) / 181f, 0 / 10f, 5 / 10f, GL11.GL_NEAREST
+ );
+ }
+ if (completion > 0) {
+ Utils.drawTexturedRect(x, y, 10 * completion, 5,
+ startTexX / 181f, (startTexX + 10 * completion) / 181f, 5 / 10f, 10 / 10f, GL11.GL_NEAREST
+ );
+ }
+
+ }
+
+ private void renderBar(float x, float y, float xSize, float completed) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(FUEL_BAR);
+
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(x, y, 0);
+ xSize = xSize / 1.5f;
+ GlStateManager.scale(1.5f, 1.5f, 1);
+
+ Color c = Color.getHSBColor(148 / 360f * completed - 20 / 360f, 0.9f, 1 - 0.5f * completed);
+ GlStateManager.color(c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f, 1);
+
+ float offsetCompleteX = xSize * completed;
+ for (int xOffset = 0; xOffset < xSize; xOffset += 10) {
+ float notchCompl = 1;
+ if (xOffset > offsetCompleteX) {
+ notchCompl = 0;
+ } else if (xOffset + 10 > offsetCompleteX) {
+ notchCompl = (offsetCompleteX - xOffset) / 10f;
+ }
+ if (xOffset == 0) {
+ renderBarCap(0, 0, true, 0, notchCompl);
+ } else if (xOffset + 11 > xSize) {
+ renderBarCap(xOffset, 0, false, xSize - xOffset, notchCompl);
+ } else {
+ renderBarNotch(xOffset, 0, xOffset / 10, notchCompl);
+ }
+ }
+
+ GlStateManager.popMatrix();
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java
index 0943f120..bfbe367f 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java
@@ -34,169 +34,180 @@ import java.util.regex.Pattern;
import static net.minecraft.util.EnumChatFormatting.*;
public class MiningOverlay extends TextOverlay {
+ public MiningOverlay(
+ Position position,
+ Supplier<List<String>> dummyStrings,
+ Supplier<TextOverlayStyle> styleSupplier
+ ) {
+ super(position, dummyStrings, styleSupplier);
+ }
+
+ private static final Pattern NUMBER_PATTERN = Pattern.compile("(?<number>\\d*,?\\d+)(?: |$)");
+ public static Map<String, Float> commissionProgress = new LinkedHashMap<>();
+
+ @Override
+ public void updateFrequent() {
+ if (Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
+ GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
+ ContainerChest container = (ContainerChest) chest.inventorySlots;
+ IInventory lower = container.getLowerChestInventory();
+ String containerName = lower.getDisplayName().getUnformattedText();
+
+ if (containerName.equals("Commissions") && lower.getSizeInventory() >= 27) {
+ UpdateCommissions(lower);
+ } else if (containerName.equals("Forge") && lower.getSizeInventory() >= 36) {
+ updateForge(lower);
+ }
+ }
+ }
+
+ private void updateForge(IInventory lower) {
+ NEUConfig.HiddenProfileSpecific hidden = NotEnoughUpdates.INSTANCE.config.getProfileSpecific();
+ if (hidden == null) {
+ return;
+ }
+
+ itemLoop:
+ for (int i = 0; i < 5; i++) {
+ ItemStack stack = lower.getStackInSlot(i + 11);
+ if (stack != null) {
+ String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stack.getTagCompound());
+
+ for (String line : lore) {
+ Matcher matcher = timeRemainingForge.matcher(line);
+ if (stack.getDisplayName().matches("\\xA7cSlot #([1-5])")) {
+ ForgeItem newForgeItem = new ForgeItem(i, 1, false);
+ replaceForgeOrAdd(newForgeItem, hidden.forgeItems, true);
+ //empty Slot
+ } else if (stack.getDisplayName().matches("\\xA7aSlot #([1-5])")) {
+ ForgeItem newForgeItem = new ForgeItem(i, 0, false);
+ replaceForgeOrAdd(newForgeItem, hidden.forgeItems, true);
+ } else if (matcher.matches()) {
+ String timeremainingString = matcher.group(1);
+
+ long duration = 0;
+
+ if (matcher.group("Completed") != null && !matcher.group("Completed").equals("")) {
+ ForgeItem newForgeItem = new ForgeItem(Utils.cleanColour(stack.getDisplayName()), 0, i, false);
+ replaceForgeOrAdd(newForgeItem, hidden.forgeItems, true);
+ } else {
+
+ try {
+ if (matcher.group("days") != null && !matcher.group("days").equals("")) {
+ duration = duration + (long) Integer.parseInt(matcher.group("days")) * 24 * 60 * 60 * 1000;
+ }
+ if (matcher.group("hours") != null && !matcher.group("hours").equals("")) {
+ duration = duration + (long) Integer.parseInt(matcher.group("hours")) * 60 * 60 * 1000;
+ }
+ if (matcher.group("minutes") != null && !matcher.group("minutes").equals("")) {
+ duration = duration + (long) Integer.parseInt(matcher.group("minutes")) * 60 * 1000;
+ }
+ if (matcher.group("seconds") != null && !matcher.group("seconds").equals("")) {
+ duration = duration + (long) Integer.parseInt(matcher.group("seconds")) * 1000;
+ }
+ } catch (Exception ignored) {
+ }
+ if (duration > 0) {
+ ForgeItem newForgeItem = new ForgeItem(
+ Utils.cleanColour(stack.getDisplayName()),
+ System.currentTimeMillis() + duration,
+ i,
+ false
+ );
+ replaceForgeOrAdd(newForgeItem, hidden.forgeItems, true);
+ }
+ }
+
+ continue itemLoop;
+ }
+ }
+
+ //Locked Slot
+ }
+ }
+ }
+
+ private void UpdateCommissions(IInventory lower) {
+ // Get the location (type) of the currently shown commissions
+ ItemStack commTypeStack = lower.getStackInSlot(27);
+ if (commTypeStack == null || !commTypeStack.hasTagCompound()) {
+ return;
+ }
+
+ String name = Utils.cleanColour(commTypeStack.getDisplayName()).trim();
+ if (!name.equals("Switch Type")) {
+ return;
+ }
+
+ String commLocation = null;
+ String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(commTypeStack.getTagCompound());
+ for (String line : lore) {
+ if (line == null) {
+ continue;
+ }
+ String cleanLine = Utils.cleanColour(line).trim();
+ if (cleanLine.equals("Dwarven Mines")) {
+ commLocation = "mining_3";
+ } else if (cleanLine.equals("Crystal Hollows")) {
+ commLocation = "crystal_hollows";
+ } else {
+ continue;
+ }
+ break;
+ }
+ if (commLocation == null) {
+ return;
+ }
+
+ // Now get the commission info
+ for (int i = 9; i < 18; i++) {
+ ItemStack stack = lower.getStackInSlot(i);
+ if (stack != null && stack.hasTagCompound()) {
+ lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stack.getTagCompound());
+ String commName = null;
+ int numberValue = -1;
+ for (String line : lore) {
+ if (commName != null) {
+ String clean = Utils.cleanColour(line).trim();
+ if (clean.isEmpty()) {
+ break;
+ } else {
+ Matcher matcher = NUMBER_PATTERN.matcher(clean);
+ if (matcher.find()) {
+ try {
+ numberValue = Integer.parseInt(matcher.group("number").replace(",", ""));
+ } catch (NumberFormatException ignored) {
+ }
+ }
+ }
+ }
+ if (line.startsWith("\u00a77\u00a79")) {
+ String textAfter = line.substring(4);
+ if (!textAfter.contains("\u00a7") && !textAfter.equals("Rewards") && !textAfter.equals("Progress")) {
+ commName = textAfter;
+ }
+ }
+ }
+
+ NEUConfig.HiddenLocationSpecific locationSpecific = NotEnoughUpdates.INSTANCE.config.getLocationSpecific(
+ commLocation);
+ if (commName != null && numberValue > 0) {
+ locationSpecific.commissionMaxes.put(commName, numberValue);
+ }
+ }
+ }
+ }
+
+ private static final Pattern timeRemainingForge = Pattern.compile(
+ "\\xA77Time Remaining: \\xA7a((?<Completed>Completed!)|(((?<days>[0-9]+)d)? ?((?<hours>[0-9]+)h)? ?((?<minutes>[0-9]+)m)? ?((?<seconds>[0-9]+)s)?))");
+ private static final Pattern timeRemainingTab = Pattern.compile(
+ ".*[1-5]\\) (?<ItemName>.*): ((?<Ready>Ready!)|(((?<days>[0-9]+)d)? ?((?<hours>[0-9]+)h)? ?((?<minutes>[0-9]+)m)? ?((?<seconds>[0-9]+)s)?))");
+
+ @Override
+ public void update() {
+ overlayStrings = null;
+ NEUConfig.HiddenProfileSpecific hidden = NotEnoughUpdates.INSTANCE.config.getProfileSpecific();
- public MiningOverlay(Position position, Supplier<List<String>> dummyStrings, Supplier<TextOverlayStyle> styleSupplier) {
- super(position, dummyStrings, styleSupplier);
- }
-
- private static final Pattern NUMBER_PATTERN = Pattern.compile("(?<number>\\d*,?\\d+)(?: |$)");
- public static Map<String, Float> commissionProgress = new LinkedHashMap<>();
-
- @Override
- public void updateFrequent() {
- if(Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
- GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
- ContainerChest container = (ContainerChest) chest.inventorySlots;
- IInventory lower = container.getLowerChestInventory();
- String containerName = lower.getDisplayName().getUnformattedText();
-
- if(containerName.equals("Commissions") && lower.getSizeInventory() >= 27) {
- UpdateCommissions(lower);
- } else if(containerName.equals("Forge") && lower.getSizeInventory() >= 36) {
- updateForge(lower);
- }
- }
- }
-
- private void updateForge(IInventory lower) {
- NEUConfig.HiddenProfileSpecific hidden = NotEnoughUpdates.INSTANCE.config.getProfileSpecific();
- if (hidden == null) {
- return;
- }
-
- itemLoop:
- for (int i = 0; i < 5; i++) {
- ItemStack stack = lower.getStackInSlot(i + 11);
- if (stack != null) {
- String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stack.getTagCompound());
-
- for (int i1 = 0; i1 < lore.length; i1++) {
- String line = lore[i1];
- Matcher matcher = timeRemainingForge.matcher(line);
- if (stack.getDisplayName().matches("\\xA7cSlot #([1-5])")) {
- ForgeItem newForgeItem = new ForgeItem(i, 1, false);
- replaceForgeOrAdd(newForgeItem, hidden.forgeItems, true);
- //empty Slot
- } else if (stack.getDisplayName().matches("\\xA7aSlot #([1-5])")) {
- ForgeItem newForgeItem = new ForgeItem(i, 0, false);
- replaceForgeOrAdd(newForgeItem, hidden.forgeItems, true);
- } else if (matcher.matches()) {
- String timeremainingString = matcher.group(1);
-
- long duration = 0;
-
- if (matcher.group("Completed") != null && !matcher.group("Completed").equals("")) {
- ForgeItem newForgeItem = new ForgeItem(Utils.cleanColour(stack.getDisplayName()), 0, i, false);
- replaceForgeOrAdd(newForgeItem, hidden.forgeItems, true);
- } else {
-
- try {
- if (matcher.group("days") != null && !matcher.group("days").equals("")) {
- duration = duration + (long) Integer.parseInt(matcher.group("days")) * 24 * 60 * 60 * 1000;
- }
- if (matcher.group("hours") != null && !matcher.group("hours").equals("")) {
- duration = duration + (long) Integer.parseInt(matcher.group("hours")) * 60 * 60 * 1000;
- }
- if (matcher.group("minutes") != null && !matcher.group("minutes").equals("")) {
- duration = duration + (long) Integer.parseInt(matcher.group("minutes")) * 60 * 1000;
- }
- if (matcher.group("seconds") != null && !matcher.group("seconds").equals("")) {
- duration = duration + (long) Integer.parseInt(matcher.group("seconds")) * 1000;
- }
- } catch (Exception ignored) {
- }
- if (duration > 0) {
- ForgeItem newForgeItem = new ForgeItem(Utils.cleanColour(stack.getDisplayName()), System.currentTimeMillis() + duration, i, false);
- replaceForgeOrAdd(newForgeItem, hidden.forgeItems, true);
- }
- }
-
- continue itemLoop;
- }
- }
-
- //Locked Slot
- }
- }
- }
-
- private void UpdateCommissions(IInventory lower) {
- // Get the location (type) of the currently shown commissions
- ItemStack commTypeStack = lower.getStackInSlot(27);
- if (commTypeStack == null || !commTypeStack.hasTagCompound())
- {
- return;
- }
-
- String name = Utils.cleanColour(commTypeStack.getDisplayName()).trim();
- if (!name.equals("Switch Type"))
- {
- return;
- }
-
- String commLocation = null;
- String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(commTypeStack.getTagCompound());
- for(String line : lore) {
- if (line == null) {
- continue;
- }
- String cleanLine = Utils.cleanColour(line).trim();
- if (cleanLine.equals("Dwarven Mines")) {
- commLocation = "mining_3";
- } else if (cleanLine.equals("Crystal Hollows")) {
- commLocation = "crystal_hollows";
- } else {
- continue;
- }
- break;
- }
- if (commLocation == null) {
- return;
- }
-
- // Now get the commission info
- for(int i=9; i<18; i++) {
- ItemStack stack = lower.getStackInSlot(i);
- if(stack != null && stack.hasTagCompound()) {
- lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stack.getTagCompound());
- String commName = null;
- int numberValue = -1;
- for(String line : lore) {
- if(commName != null) {
- String clean = Utils.cleanColour(line).trim();
- if(clean.isEmpty()) {
- break;
- } else {
- Matcher matcher = NUMBER_PATTERN.matcher(clean);
- if(matcher.find()) {
- try {
- numberValue = Integer.parseInt(matcher.group("number").replace(",", ""));
- } catch(NumberFormatException ignored) {}
- }
- }
- }
- if(line.startsWith("\u00a77\u00a79")) {
- String textAfter = line.substring(4);
- if(!textAfter.contains("\u00a7") && !textAfter.equals("Rewards") && !textAfter.equals("Progress")) {
- commName = textAfter;
- }
- }
- }
-
- NEUConfig.HiddenLocationSpecific locationSpecific = NotEnoughUpdates.INSTANCE.config.getLocationSpecific(commLocation);
- if(commName != null && numberValue > 0) {
- locationSpecific.commissionMaxes.put(commName, numberValue);
- }
- }
- }
- }
-
- private static final Pattern timeRemainingForge = Pattern.compile("\\xA77Time Remaining: \\xA7a((?<Completed>Completed!)|(((?<days>[0-9]+)d)? ?((?<hours>[0-9]+)h)? ?((?<minutes>[0-9]+)m)? ?((?<seconds>[0-9]+)s)?))");
- private static final Pattern timeRemainingTab = Pattern.compile(".*[1-5]\\) (?<ItemName>.*): ((?<Ready>Ready!)|(((?<days>[0-9]+)d)? ?((?<hours>[0-9]+)h)? ?((?<minutes>[0-9]+)m)? ?((?<seconds>[0-9]+)s)?))");
- @Override
- public void update() {
- overlayStrings = null;
- NEUConfig.HiddenProfileSpecific hidden = NotEnoughUpdates.INSTANCE.config.getProfileSpecific();
/*if(Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
@@ -264,142 +275,161 @@ public class MiningOverlay extends TextOverlay {
}
}*/
- if(!NotEnoughUpdates.INSTANCE.config.mining.dwarvenOverlay && NotEnoughUpdates.INSTANCE.config.mining.emissaryWaypoints == 0) return;
- if(SBInfo.getInstance().getLocation() == null) return;
- if(SBInfo.getInstance().getLocation().equals("mining_3") || SBInfo.getInstance().getLocation().equals("crystal_hollows")) {
-
- overlayStrings = new ArrayList<>();
- commissionProgress.clear();
-
- String mithrilPowder = null;
- String gemstonePowder = null;
- int forgeInt = 0;
- boolean commissions = false;
- boolean forges = false;
- List<NetworkPlayerInfo> players = playerOrdering.sortedCopy(Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap());
-
- for (NetworkPlayerInfo info : players) {
- String name = Minecraft.getMinecraft().ingameGUI.getTabList().getPlayerName(info);
- if (name.contains("Mithril Powder:")) {
- mithrilPowder = DARK_AQUA + Utils.trimIgnoreColour(name).replaceAll("\u00a7[f|F|r]", "");
- continue;
- }
- if (name.contains("Gemstone Powder:")) {
- gemstonePowder = DARK_AQUA + Utils.trimIgnoreColour(name).replaceAll("\u00a7[f|F|r]", "");
- continue;
- }
-
- if (name.matches("\\xa7r\\xa79\\xa7lForges \\xa7r(?:\\xa7f\\(\\+1 more\\)\\xa7r)?")) {
- commissions = false;
- forges = true;
- continue;
- } else if (name.equals(RESET.toString() + BLUE + BOLD + "Commissions" + RESET)) {
- commissions = true;
- forges = false;
- continue;
- }
- String clean = StringUtils.cleanColour(name);
- if (forges && clean.startsWith(" ")) {
-
- char firstChar = clean.trim().charAt(0);
- if (firstChar < '0' || firstChar > '9') {
- forges = false;
- } else {
-
- if (name.contains("LOCKED")) {
- ForgeItem item = new ForgeItem(forgeInt, 1,true);
- replaceForgeOrAdd(item, hidden.forgeItems, true);
- } else if (name.contains("EMPTY")) {
- ForgeItem item = new ForgeItem(forgeInt, 0,true);
- replaceForgeOrAdd(item, hidden.forgeItems, true);
- //forgeStringsEmpty.add(DARK_AQUA+"Forge "+ Utils.trimIgnoreColour(name).replaceAll("\u00a7[f|F|r]", ""));
- } else {
- String cleanName = Utils.cleanColour(name);
-
- Matcher matcher = timeRemainingTab.matcher(cleanName);
-
- if (matcher.matches()) {
-
- String itemName = matcher.group(1);
-
- if (matcher.group("Ready") != null && !matcher.group("Ready").equals("")) {
- ForgeItem item = new ForgeItem(Utils.cleanColour(itemName), 0, forgeInt, true);
- replaceForgeOrAdd(item, hidden.forgeItems, true);
- } else {
- long duration = 0;
- try {
- if (matcher.group("days") != null && !matcher.group("days").equals("")) {
- duration = duration + (long) Integer.parseInt(matcher.group("days")) * 24 * 60 * 60 * 1000;
- }
- if (matcher.group("hours") != null && !matcher.group("hours").equals("")) {
- duration = duration + (long) Integer.parseInt(matcher.group("hours")) * 60 * 60 * 1000;
- }
- if (matcher.group("minutes") != null && !matcher.group("minutes").equals("")) {
- duration = duration + (long) Integer.parseInt(matcher.group("minutes")) * 60 * 1000;
- }
- if (matcher.group("seconds") != null && !matcher.group("seconds").equals("")) {
- duration = duration + (long) Integer.parseInt(matcher.group("seconds")) * 1000;
- }
- } catch (Exception ignored) {
- }
- if (duration > 0) {
- duration = duration + 4000;
- ForgeItem item = new ForgeItem(Utils.cleanColour(itemName), System.currentTimeMillis() + duration, forgeInt, true);
- replaceForgeOrAdd(item, hidden.forgeItems, false);
- }
- }
- }
- }
- forgeInt++;
- }
- } else if (commissions && clean.startsWith(" ")) {
- String[] split = clean.trim().split(": ");
- if (split.length == 2) {
- if (split[1].endsWith("%")) {
- try {
- float progress = Float.parseFloat(split[1].replace("%", "")) / 100;
- progress = LerpUtils.clampZeroOne(progress);
- commissionProgress.put(split[0], progress);
- } catch (Exception ignored) {
- }
- } else {
- commissionProgress.put(split[0], 1.0f);
- }
- }
- } else {
- commissions = false;
- forges = false;
- }
- }
- if (!NotEnoughUpdates.INSTANCE.config.mining.dwarvenOverlay) {
- overlayStrings = null;
- return;
- }
-
- List<String> commissionsStrings = new ArrayList<>();
- for (Map.Entry<String, Float> entry : commissionProgress.entrySet()) {
- if (entry.getValue() >= 1) {
- commissionsStrings.add(DARK_AQUA + entry.getKey() + ": " + GREEN + "DONE");
- } else {
- EnumChatFormatting col = RED;
- if (entry.getValue() >= 0.75) {
- col = GREEN;
- } else if (entry.getValue() >= 0.5) {
- col = YELLOW;
- } else if (entry.getValue() >= 0.25) {
- col = GOLD;
- }
- NEUConfig.HiddenLocationSpecific locationSpecific = NotEnoughUpdates.INSTANCE.config.getLocationSpecific();
- int max;
- if (-1 != (max = locationSpecific.commissionMaxes.getOrDefault(entry.getKey(), -1))) {
- commissionsStrings.add(DARK_AQUA + entry.getKey() + ": " + col + Math.round(entry.getValue() * max) + "/" + max);
- } else {
- String valS = Utils.floatToString(entry.getValue() * 100, 1);
-
- commissionsStrings.add(DARK_AQUA + entry.getKey() + ": " + col + valS + "%");
- }
- }
- }
+ if (!NotEnoughUpdates.INSTANCE.config.mining.dwarvenOverlay &&
+ NotEnoughUpdates.INSTANCE.config.mining.emissaryWaypoints == 0 &&
+ !NotEnoughUpdates.INSTANCE.config.mining.titaniumAlert &&
+ NotEnoughUpdates.INSTANCE.config.mining.locWaypoints == 0) return;
+ //thanks to "Pure Genie#7250" for helping with this (makes tita alert and waypoints work without mine overlay)
+ if (SBInfo.getInstance().getLocation() == null) return;
+ if (SBInfo.getInstance().getLocation().equals("mining_3") || SBInfo.getInstance().getLocation().equals(
+ "crystal_hollows")) {
+
+ overlayStrings = new ArrayList<>();
+ commissionProgress.clear();
+
+ String mithrilPowder = null;
+ String gemstonePowder = null;
+ int forgeInt = 0;
+ boolean commissions = false;
+ boolean forges = false;
+ List<NetworkPlayerInfo> players =
+ playerOrdering.sortedCopy(Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap());
+
+ for (NetworkPlayerInfo info : players) {
+ String name = Minecraft.getMinecraft().ingameGUI.getTabList().getPlayerName(info);
+ if (name.contains("Mithril Powder:")) {
+ mithrilPowder = DARK_AQUA + Utils.trimIgnoreColour(name).replaceAll("\u00a7[f|F|r]", "");
+ continue;
+ } else if (mithrilPowder == null) {
+ mithrilPowder = RED + "[NEU] Failed to get data from your tablist";
+ continue;
+ }
+
+ if (name.contains("Gemstone Powder:")) {
+ gemstonePowder = DARK_AQUA + Utils.trimIgnoreColour(name).replaceAll("\u00a7[f|F|r]", "");
+ continue;
+ } else if (gemstonePowder == null) {
+ gemstonePowder = RED + "Please enable player list info in your skyblock settings";
+ continue;
+ }
+
+ if (name.matches("\\xa7r\\xa79\\xa7lForges \\xa7r(?:\\xa7f\\(\\+1 more\\)\\xa7r)?") && hidden != null) {
+ commissions = false;
+ forges = true;
+ continue;
+ } else if (name.equals(RESET.toString() + BLUE + BOLD + "Commissions" + RESET) && hidden != null) {
+ commissions = true;
+ forges = false;
+ continue;
+ }
+ String clean = StringUtils.cleanColour(name);
+ if (forges && clean.startsWith(" ") && hidden != null) {
+
+ char firstChar = clean.trim().charAt(0);
+ if (firstChar < '0' || firstChar > '9') {
+ forges = false;
+ } else {
+
+ if (name.contains("LOCKED")) {
+ ForgeItem item = new ForgeItem(forgeInt, 1, true);
+ replaceForgeOrAdd(item, hidden.forgeItems, true);
+ } else if (name.contains("EMPTY")) {
+ ForgeItem item = new ForgeItem(forgeInt, 0, true);
+ replaceForgeOrAdd(item, hidden.forgeItems, true);
+ //forgeStringsEmpty.add(DARK_AQUA+"Forge "+ Utils.trimIgnoreColour(name).replaceAll("\u00a7[f|F|r]", ""));
+ } else {
+ String cleanName = Utils.cleanColour(name);
+
+ Matcher matcher = timeRemainingTab.matcher(cleanName);
+
+ if (matcher.matches()) {
+
+ String itemName = matcher.group(1);
+
+ if (matcher.group("Ready") != null && !matcher.group("Ready").equals("")) {
+ ForgeItem item = new ForgeItem(Utils.cleanColour(itemName), 0, forgeInt, true);
+ replaceForgeOrAdd(item, hidden.forgeItems, true);
+ } else {
+ long duration = 0;
+ try {
+ if (matcher.group("days") != null && !matcher.group("days").equals("")) {
+ duration = duration + (long) Integer.parseInt(matcher.group("days")) * 24 * 60 * 60 * 1000;
+ }
+ if (matcher.group("hours") != null && !matcher.group("hours").equals("")) {
+ duration = duration + (long) Integer.parseInt(matcher.group("hours")) * 60 * 60 * 1000;
+ }
+ if (matcher.group("minutes") != null && !matcher.group("minutes").equals("")) {
+ duration = duration + (long) Integer.parseInt(matcher.group("minutes")) * 60 * 1000;
+ }
+ if (matcher.group("seconds") != null && !matcher.group("seconds").equals("")) {
+ duration = duration + (long) Integer.parseInt(matcher.group("seconds")) * 1000;
+ }
+ } catch (Exception ignored) {
+ }
+ if (duration > 0) {
+ duration = duration + 4000;
+ ForgeItem item = new ForgeItem(
+ Utils.cleanColour(itemName),
+ System.currentTimeMillis() + duration,
+ forgeInt,
+ true
+ );
+ replaceForgeOrAdd(item, hidden.forgeItems, false);
+ }
+ }
+ }
+ }
+ forgeInt++;
+ }
+ } else if (commissions && clean.startsWith(" ") && hidden != null) {
+ String[] split = clean.trim().split(": ");
+ if (split.length == 2) {
+ if (split[1].endsWith("%")) {
+ try {
+ float progress = Float.parseFloat(split[1].replace("%", "")) / 100;
+ progress = LerpUtils.clampZeroOne(progress);
+ commissionProgress.put(split[0], progress);
+ } catch (Exception ignored) {
+ }
+ } else {
+ commissionProgress.put(split[0], 1.0f);
+ }
+ }
+ } else {
+ commissions = false;
+ forges = false;
+ }
+ }
+ if (!NotEnoughUpdates.INSTANCE.config.mining.dwarvenOverlay) {
+ overlayStrings = null;
+ return;
+ }
+
+ List<String> commissionsStrings = new ArrayList<>();
+ for (Map.Entry<String, Float> entry : commissionProgress.entrySet()) {
+ if (entry.getValue() >= 1) {
+ commissionsStrings.add(DARK_AQUA + entry.getKey() + ": " + GREEN + "DONE");
+ } else {
+ EnumChatFormatting col = RED;
+ if (entry.getValue() >= 0.75) {
+ col = GREEN;
+ } else if (entry.getValue() >= 0.5) {
+ col = YELLOW;
+ } else if (entry.getValue() >= 0.25) {
+ col = GOLD;
+ }
+ NEUConfig.HiddenLocationSpecific locationSpecific = NotEnoughUpdates.INSTANCE.config.getLocationSpecific();
+ int max;
+ if (-1 != (max = locationSpecific.commissionMaxes.getOrDefault(entry.getKey(), -1))) {
+ commissionsStrings.add(
+ DARK_AQUA + entry.getKey() + ": " + col + Math.round(entry.getValue() * max) + "/" + max);
+ } else {
+ String valS = Utils.floatToString(entry.getValue() * 100, 1);
+
+ commissionsStrings.add(DARK_AQUA + entry.getKey() + ": " + col + valS + "%");
+ }
+ }
+ }
/*boolean hasAny = false;
if(NotEnoughUpdates.INSTANCE.config.mining.dwarvenOverlay) {
overlayStrings.addAll(commissionsStrings);
@@ -417,294 +447,410 @@ public class MiningOverlay extends TextOverlay {
overlayStrings.addAll(forgeStrings);
}*/
- String pickaxeCooldown;
- if (ItemCooldowns.pickaxeUseCooldownMillisRemaining <= 0) {
- pickaxeCooldown = DARK_AQUA + "Pickaxe CD: \u00a7aReady";
- } else {
- pickaxeCooldown = DARK_AQUA + "Pickaxe CD: \u00a7a" + (ItemCooldowns.pickaxeUseCooldownMillisRemaining / 1000) + "s";
- }
-
-
-
- for (int index : NotEnoughUpdates.INSTANCE.config.mining.dwarvenText2) {
- switch (index) {
- case 0:
- overlayStrings.addAll(commissionsStrings);
- break;
- case 1:
- overlayStrings.add(mithrilPowder);
- break;
- case 2:
- overlayStrings.add(gemstonePowder);
- break;
- case 3:
- overlayStrings.addAll(getForgeStrings(hidden.forgeItems));
- break;
- case 4:
- //overlayStrings.addAll(forgeStringsEmpty); break;
- case 5:
- overlayStrings.add(pickaxeCooldown);
- break;
- }
- }
- } else {
- overlayStrings = new ArrayList<>();
- if(hidden == null){
- return;
- }
- boolean forgeDisplay = false;
- for (int i = 0; i < NotEnoughUpdates.INSTANCE.config.mining.dwarvenText2.size(); i++) {
- if(NotEnoughUpdates.INSTANCE.config.mining.dwarvenText2.get(i) == 3){
- forgeDisplay = true;
- }
- }
- if(forgeDisplay){
- if(NotEnoughUpdates.INSTANCE.config.mining.forgeDisplayEnabledLocations == 1 && !SBInfo.getInstance().isInDungeon){
- overlayStrings.addAll(getForgeStrings(hidden.forgeItems));
- } else if(NotEnoughUpdates.INSTANCE.config.mining.forgeDisplayEnabledLocations == 2){
- overlayStrings.addAll(getForgeStrings(hidden.forgeItems));
- }
- }
- }
-
- if(overlayStrings.isEmpty()) overlayStrings = null;
- }
-
- private static List<String> getForgeStrings(List<ForgeItem> forgeItems){
- List<String> forgeString = new ArrayList<>();
- long currentTimeMillis = System.currentTimeMillis();
- forgeIDLabel:
- for (int i = 0; i < 5; i++) {
- for (int y = 0; y < forgeItems.size(); y++) {
- if (forgeItems.get(y).forgeID == i) {
- ForgeItem item = forgeItems.get(y);
- if (NotEnoughUpdates.INSTANCE.config.mining.forgeDisplay == 0) {
- if (item.status == 2 && item.finishTime < currentTimeMillis) {
-
- forgeString.add(item.getFormattedString(currentTimeMillis));
- continue forgeIDLabel;
- }
- } else if (NotEnoughUpdates.INSTANCE.config.mining.forgeDisplay == 1) {
- if (item.status == 2) {
-
- forgeString.add(item.getFormattedString(currentTimeMillis));
- continue forgeIDLabel;
- }
- } else if (NotEnoughUpdates.INSTANCE.config.mining.forgeDisplay == 2) {
- if (item.status == 2 || item.status ==0) {
-
- forgeString.add(item.getFormattedString(currentTimeMillis));
- continue forgeIDLabel;
- }
- } else if (NotEnoughUpdates.INSTANCE.config.mining.forgeDisplay == 3) {
-
- forgeString.add(item.getFormattedString(currentTimeMillis));
- continue forgeIDLabel;
- }
- }
- }
- }
- return forgeString;
- }
-
- private static void replaceForgeOrAdd(ForgeItem item, List<ForgeItem> forgeItems, boolean overwrite){
- for (int i = 0; i < forgeItems.size(); i++) {
- if (forgeItems.get(i).forgeID == item.forgeID) {
- if (overwrite) {
- forgeItems.set(i, item);
- return;
- } else {
- ForgeItem currentItem = forgeItems.get(i);
- if (!(currentItem.status == 2 && item.status ==2)) {
- forgeItems.set(i, item);
- return;
- } else if(currentItem.fromScoreBoard){
- forgeItems.set(i, item);
- return;
- }
- }
- return;
- }
- }
- forgeItems.add(item);
- return;
- }
-
- public static class ForgeItem{
- public ForgeItem(String itemName, long finishTime, int forgeID, boolean fromScoreBoard){
- this.itemName = itemName;
- this.finishTime = finishTime;
- this.status = 2;
- this.forgeID = forgeID;
- this.fromScoreBoard = fromScoreBoard;
- }
-
- public ForgeItem(int forgeID, int status, boolean fromScoreBoard){
- this.forgeID = forgeID;
- this.status = status;
- this.fromScoreBoard = fromScoreBoard;
- }
-
-
- @Expose public String itemName;
- @Expose public long finishTime;
- @Expose public final int status;
- @Expose public final int forgeID;
- @Expose public final boolean fromScoreBoard;
-
-
-
- public String getFormattedString(long currentTimeMillis){
- String returnText = EnumChatFormatting.DARK_AQUA+"Forge "+(this.forgeID+1)+": ";
- if(status == 0){
- return returnText +EnumChatFormatting.GRAY +"Empty";
- } else if(status == 1){
- return returnText+ EnumChatFormatting.DARK_RED+"Locked";
- }
-
- long timeDuration = finishTime - currentTimeMillis;
- returnText = returnText+ EnumChatFormatting.DARK_PURPLE +this.itemName+": ";
-
- int days = (int) (timeDuration / (1000*60*60*24));
- timeDuration = timeDuration-(days*(1000*60*60*24));
- int hours = (int) ((timeDuration / (1000*60*60)) % 24);
-
- if(days > 0){
- return returnText+EnumChatFormatting.AQUA+days+"d "+hours+"h";
- }
- timeDuration = timeDuration-(hours*(1000*60*60));
- int minutes = (int) ((timeDuration / (1000*60)) % 60);
- if(hours > 0){
- return returnText+EnumChatFormatting.AQUA+hours+"h "+minutes+"m";
- }
- timeDuration = timeDuration-(minutes*(1000*60));
- int seconds = (int) (timeDuration / 1000) % 60 ;
- if(minutes > 0){
- return returnText+EnumChatFormatting.AQUA+minutes+"m "+seconds+"s";
- } else if(seconds > 0){
- return returnText+EnumChatFormatting.AQUA+seconds+"s";
- } else {
- return returnText+ EnumChatFormatting.DARK_GREEN+"Done";
- }
- }
- }
-
- private static final Ordering<NetworkPlayerInfo> playerOrdering = Ordering.from(new PlayerComparator());
-
- @SideOnly(Side.CLIENT)
- static class PlayerComparator implements Comparator<NetworkPlayerInfo> {
- private PlayerComparator() { }
-
- public int compare(NetworkPlayerInfo o1, NetworkPlayerInfo o2) {
- ScorePlayerTeam team1 = o1.getPlayerTeam();
- ScorePlayerTeam team2 = o2.getPlayerTeam();
- return ComparisonChain.start().compareTrueFirst(
- o1.getGameType() != WorldSettings.GameType.SPECTATOR,
- o2.getGameType() != WorldSettings.GameType.SPECTATOR)
- .compare(team1 != null ? team1.getRegisteredName() : "", team2 != null ? team2.getRegisteredName() : "")
- .compare(o1.getGameProfile().getName(), o2.getGameProfile().getName()).result();
- }
- }
-
- @Override
- protected Vector2f getSize(List<String> strings) {
- if (NotEnoughUpdates.INSTANCE.config.mining.dwarvenOverlayIcons)
- return super.getSize(strings).translate(12, 0);
- return super.getSize(strings);
- }
-
- @Override
- protected void renderLine(String line, Vector2f position, boolean dummy) {
- if (!NotEnoughUpdates.INSTANCE.config.mining.dwarvenOverlayIcons) return;
- GlStateManager.enableDepth();
-
- ItemStack icon = null;
- String cleaned = Utils.cleanColour(line);
- String beforeColon = cleaned.split(":")[0];
- switch (beforeColon) {
- case "Mithril Powder":
- icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("INK_SACK-10"));
- break;
- case "Gemstone Powder":
- icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("INK_SACK-9"));
- break;
- case "Lucky Raffle":
- case "Raffle":
- icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("MINING_RAFFLE_TICKET"));
- break;
- case "Pickaxe CD":
- icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("DIAMOND_PICKAXE"));
- break;
- case "Thyst Slayer":
- icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("THYST_MONSTER"));
- break;
- case "Hard Stone Miner":
- icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("HARD_STONE"));
- break;
- case "Ice Walker Slayer":
- icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("ENCHANTED_ICE"));
- break;
- case "Goblin Slayer":
- icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("GOBLIN_MONSTER"));
- break;
- case "Star Sentry Puncher":
- icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("NETHER_STAR"));
- break;
- case "Goblin Raid":
- case "Goblin Raid Slayer":
- icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("ENCHANTED_GOLD"));
- break;
- case "Golden Goblin Slayer":
- icon = new ItemStack(Items.golden_helmet, 1, 0);
- break;
- case "2x Mithril Powder Collector":
- icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("ENCHANTED_GLOWSTONE_DUST"));
- break;
- case "Automaton Slayer":
- icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("AUTOMATON_MONSTER"));
- break;
- case "Sludge Slayer":
- icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("SLUDGE_MONSTER"));
- break;
- case "Team Treasurite Member Slayer":
- icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("EXECUTIVE_WENDY_MONSTER"));
- break;
- case "Yog Slayer":
- icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("YOG_MONSTER"));
- break;
- case "Boss Corleone Slayer":
- icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("BOSS_CORLEONE_BOSS"));
- break;
- case "Chest Looter":
- icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("CHEST"));
- break;
- }
- if (icon == null) {
- if(beforeColon.startsWith("Forge")){
- icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("ANVIL"));
- } else if (beforeColon.contains("Mithril")) {
- icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("MITHRIL_ORE"));
- } else if(beforeColon.endsWith(" Gemstone Collector")){
- icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("ROUGH_"
- + beforeColon.replace(" Gemstone Collector", "").toUpperCase() + "_GEM"));
- } else if (beforeColon.endsWith(" Crystal Hunter")){
- icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("PERFECT_"
- + beforeColon.replace(" Crystal Hunter", "").toUpperCase() + "_GEM"));
- } else if (beforeColon.contains("Titanium")) {
- icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("TITANIUM_ORE"));
- }
- }
-
- if (icon != null) {
- GlStateManager.pushMatrix();
- GlStateManager.translate(position.x, position.y, 0);
- GlStateManager.scale(0.5f, 0.5f, 1f);
- Utils.drawItemStack(icon, 0, 0);
- GlStateManager.popMatrix();
-
- position.x += 12;
- }
-
- super.renderLine(line, position, dummy);
- }
+ String pickaxeCooldown;
+ if (ItemCooldowns.pickaxeUseCooldownMillisRemaining <= 0) {
+ pickaxeCooldown = DARK_AQUA + "Pickaxe CD: \u00a7aReady";
+ } else {
+ pickaxeCooldown =
+ DARK_AQUA + "Pickaxe CD: \u00a7a" + (ItemCooldowns.pickaxeUseCooldownMillisRemaining / 1000) + "s";
+ }
+
+ for (int index : NotEnoughUpdates.INSTANCE.config.mining.dwarvenText2) {
+ switch (index) {
+ case 0:
+ overlayStrings.addAll(commissionsStrings);
+ break;
+ case 1:
+ overlayStrings.add(mithrilPowder);
+ break;
+ case 2:
+ overlayStrings.add(gemstonePowder);
+ break;
+ case 3:
+ if (hidden != null) {
+ overlayStrings.addAll(getForgeStrings(hidden.forgeItems));
+ }
+ break;
+ case 4:
+ //overlayStrings.addAll(forgeStringsEmpty); break;
+ case 5:
+ overlayStrings.add(pickaxeCooldown);
+ break;
+ }
+ }
+ } else {
+ overlayStrings = new ArrayList<>();
+ if (hidden == null) {
+ return;
+ }
+ boolean forgeDisplay = false;
+ for (int i = 0; i < NotEnoughUpdates.INSTANCE.config.mining.dwarvenText2.size(); i++) {
+ if (NotEnoughUpdates.INSTANCE.config.mining.dwarvenText2.get(i) == 3) {
+ forgeDisplay = true;
+ }
+ }
+ if (forgeDisplay) {
+ if (NotEnoughUpdates.INSTANCE.config.mining.forgeDisplayEnabledLocations == 1 &&
+ !SBInfo.getInstance().isInDungeon) {
+ overlayStrings.addAll(getForgeStrings(hidden.forgeItems));
+ } else if (NotEnoughUpdates.INSTANCE.config.mining.forgeDisplayEnabledLocations == 2) {
+ overlayStrings.addAll(getForgeStrings(hidden.forgeItems));
+ }
+ }
+ }
+
+ if (overlayStrings.isEmpty()) overlayStrings = null;
+ }
+
+ private static List<String> getForgeStrings(List<ForgeItem> forgeItems) {
+ List<String> forgeString = new ArrayList<>();
+ long currentTimeMillis = System.currentTimeMillis();
+ forgeIDLabel:
+ for (int i = 0; i < 5; i++) {
+ for (ForgeItem forgeItem : forgeItems) {
+ if (forgeItem.forgeID == i) {
+ ForgeItem item = forgeItem;
+ if (NotEnoughUpdates.INSTANCE.config.mining.forgeDisplay == 0) {
+ if (item.status == 2 && item.finishTime < currentTimeMillis) {
+
+ forgeString.add(item.getFormattedString(currentTimeMillis));
+ continue forgeIDLabel;
+ }
+ } else if (NotEnoughUpdates.INSTANCE.config.mining.forgeDisplay == 1) {
+ if (item.status == 2) {
+
+ forgeString.add(item.getFormattedString(currentTimeMillis));
+ continue forgeIDLabel;
+ }
+ } else if (NotEnoughUpdates.INSTANCE.config.mining.forgeDisplay == 2) {
+ if (item.status == 2 || item.status == 0) {
+
+ forgeString.add(item.getFormattedString(currentTimeMillis));
+ continue forgeIDLabel;
+ }
+ } else if (NotEnoughUpdates.INSTANCE.config.mining.forgeDisplay == 3) {
+
+ forgeString.add(item.getFormattedString(currentTimeMillis));
+ continue forgeIDLabel;
+ }
+ }
+ }
+ }
+ return forgeString;
+ }
+
+ private static void replaceForgeOrAdd(ForgeItem item, List<ForgeItem> forgeItems, boolean overwrite) {
+ for (int i = 0; i < forgeItems.size(); i++) {
+ if (forgeItems.get(i).forgeID == item.forgeID) {
+ if (overwrite) {
+ forgeItems.set(i, item);
+ return;
+ } else {
+ ForgeItem currentItem = forgeItems.get(i);
+ if (!(currentItem.status == 2 && item.status == 2)) {
+ forgeItems.set(i, item);
+ return;
+ } else if (currentItem.fromScoreBoard) {
+ forgeItems.set(i, item);
+ return;
+ }
+ }
+ return;
+ }
+ }
+ forgeItems.add(item);
+ return;
+ }
+
+ public static class ForgeItem {
+ public ForgeItem(String itemName, long finishTime, int forgeID, boolean fromScoreBoard) {
+ this.itemName = itemName;
+ this.finishTime = finishTime;
+ this.status = 2;
+ this.forgeID = forgeID;
+ this.fromScoreBoard = fromScoreBoard;
+ }
+
+ public ForgeItem(int forgeID, int status, boolean fromScoreBoard) {
+ this.forgeID = forgeID;
+ this.status = status;
+ this.fromScoreBoard = fromScoreBoard;
+ }
+
+ @Expose
+ public String itemName;
+ @Expose
+ public long finishTime;
+ @Expose
+ public final int status;
+ @Expose
+ public final int forgeID;
+ @Expose
+ public final boolean fromScoreBoard;
+
+ public String getFormattedString(long currentTimeMillis) {
+ String returnText = EnumChatFormatting.DARK_AQUA + "Forge " + (this.forgeID + 1) + ": ";
+ if (status == 0) {
+ return returnText + EnumChatFormatting.GRAY + "Empty";
+ } else if (status == 1) {
+ return returnText + EnumChatFormatting.DARK_RED + "Locked";
+ }
+
+ long timeDuration = finishTime - currentTimeMillis;
+ returnText = returnText + EnumChatFormatting.DARK_PURPLE + this.itemName + ": ";
+
+ int days = (int) (timeDuration / (1000 * 60 * 60 * 24));
+ timeDuration = timeDuration - (days * (1000 * 60 * 60 * 24));
+ int hours = (int) ((timeDuration / (1000 * 60 * 60)) % 24);
+
+ if (days > 0) {
+ return returnText + EnumChatFormatting.AQUA + days + "d " + hours + "h";
+ }
+ timeDuration = timeDuration - (hours * (1000 * 60 * 60));
+ int minutes = (int) ((timeDuration / (1000 * 60)) % 60);
+ if (hours > 0) {
+ return returnText + EnumChatFormatting.AQUA + hours + "h " + minutes + "m";
+ }
+ timeDuration = timeDuration - (minutes * (1000 * 60));
+ int seconds = (int) (timeDuration / 1000) % 60;
+ if (minutes > 0) {
+ return returnText + EnumChatFormatting.AQUA + minutes + "m " + seconds + "s";
+ } else if (seconds > 0) {
+ return returnText + EnumChatFormatting.AQUA + seconds + "s";
+ } else {
+ return returnText + EnumChatFormatting.DARK_GREEN + "Done";
+ }
+ }
+ }
+
+ private static final Ordering<NetworkPlayerInfo> playerOrdering = Ordering.from(new PlayerComparator());
+
+ @SideOnly(Side.CLIENT)
+ static class PlayerComparator implements Comparator<NetworkPlayerInfo> {
+ private PlayerComparator() {}
+
+ public int compare(NetworkPlayerInfo o1, NetworkPlayerInfo o2) {
+ ScorePlayerTeam team1 = o1.getPlayerTeam();
+ ScorePlayerTeam team2 = o2.getPlayerTeam();
+ return ComparisonChain.start().compareTrueFirst(
+ o1.getGameType() != WorldSettings.GameType.SPECTATOR,
+ o2.getGameType() != WorldSettings.GameType.SPECTATOR
+ )
+ .compare(
+ team1 != null ? team1.getRegisteredName() : "",
+ team2 != null ? team2.getRegisteredName() : ""
+ )
+ .compare(o1.getGameProfile().getName(), o2.getGameProfile().getName()).result();
+ }
+ }
+
+ @Override
+ protected Vector2f getSize(List<String> strings) {
+ if (NotEnoughUpdates.INSTANCE.config.mining.dwarvenOverlayIcons)
+ return super.getSize(strings).translate(12, 0);
+ return super.getSize(strings);
+ }
+
+ @Override
+ protected void renderLine(String line, Vector2f position, boolean dummy) {
+ if (!NotEnoughUpdates.INSTANCE.config.mining.dwarvenOverlayIcons) return;
+ GlStateManager.enableDepth();
+
+ ItemStack icon = null;
+ String cleaned = Utils.cleanColour(line);
+ String beforeColon = cleaned.split(":")[0];
+
+ if (miningOverlayCommisionItems == null) {
+ setupMiningOverlayCommisionItems();
+ }
+
+ if (miningOverlayCommisionItems.containsKey(beforeColon)) {
+ icon = miningOverlayCommisionItems.get(beforeColon);
+ } else {
+ if (beforeColon.startsWith("Forge")) {
+ icon = miningOverlayCommisionItems.get("Forge");
+ } else if (beforeColon.contains("Mithril")) {
+ icon = miningOverlayCommisionItems.get("Mithril");
+ } else if (beforeColon.endsWith(" Gemstone Collector")) {
+ String gemName = "ROUGH_"
+ + beforeColon.replace(" Gemstone Collector", "").toUpperCase() + "_GEM";
+ if (miningOverlayRoughGems.containsKey(gemName)) {
+ icon = miningOverlayRoughGems.get(gemName);
+ } else {
+ icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get(gemName));
+ miningOverlayRoughGems.put(gemName, icon);
+ }
+ } else if (beforeColon.endsWith(" Crystal Hunter")) {
+ String gemName = "PERFECT_"
+ + beforeColon.replace(" Crystal Hunter", "").toUpperCase() + "_GEM";
+ if (miningOverlayPerfectGems.containsKey(gemName)) {
+ icon = miningOverlayPerfectGems.get(gemName);
+ } else {
+ icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get(gemName));
+ miningOverlayPerfectGems.put(gemName, icon);
+ }
+ } else if (beforeColon.contains("Titanium")) {
+ icon = miningOverlayCommisionItems.get("Titanium");
+ }
+ }
+
+ if (icon != null) {
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(position.x, position.y, 0);
+ GlStateManager.scale(0.5f, 0.5f, 1f);
+ Utils.drawItemStack(icon, 0, 0);
+ GlStateManager.popMatrix();
+
+ position.x += 12;
+ }
+
+ super.renderLine(line, position, dummy);
+ }
+
+ private static final HashMap<String, ItemStack> miningOverlayRoughGems = new HashMap<String, ItemStack>() {};
+ private static final HashMap<String, ItemStack> miningOverlayPerfectGems = new HashMap<String, ItemStack>() {};
+
+ private static HashMap<String, ItemStack> miningOverlayCommisionItems;
+
+ private static void setupMiningOverlayCommisionItems() {
+ miningOverlayCommisionItems = new HashMap<String, ItemStack>() {{
+ put(
+ "Mithril Powder",
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("INK_SACK-10"))
+ );
+ put(
+ "Gemstone Powder",
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("INK_SACK-9"))
+ );
+ put(
+ "Lucky Raffle",
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("MINING_RAFFLE_TICKET"))
+ );
+ put(
+ "Raffle",
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("MINING_RAFFLE_TICKET"))
+ );
+ put(
+ "Pickaxe CD",
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("DIAMOND_PICKAXE"))
+ );
+ put(
+ "Thyst Slayer",
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("THYST_MONSTER"))
+ );
+ put(
+ "Hard Stone Miner",
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("HARD_STONE"))
+ );
+ put(
+ "Ice Walker Slayer",
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("ENCHANTED_ICE"))
+ );
+ put(
+ "Goblin Slayer",
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("GOBLIN_MONSTER"))
+ );
+ put(
+ "Star Sentry Puncher",
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("NETHER_STAR"))
+ );
+ put(
+ "Goblin Raid",
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("ENCHANTED_GOLD"))
+ );
+ put(
+ "Goblin Raid Slayer",
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("ENCHANTED_GOLD"))
+ );
+ put("Golden Goblin Slayer", new ItemStack(Items.golden_helmet, 1, 0));
+ put(
+ "2x Mithril Powder Collector",
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("ENCHANTED_GLOWSTONE_DUST"))
+ );
+ put(
+ "Automaton Slayer",
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("AUTOMATON_MONSTER"))
+ );
+ put(
+ "Sludge Slayer",
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("SLUDGE_MONSTER"))
+ );
+ put(
+ "Team Treasurite Member Slayer",
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("EXECUTIVE_WENDY_MONSTER"))
+ );
+ put(
+ "Yog Slayer",
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("YOG_MONSTER"))
+ );
+ put(
+ "Boss Corleone Slayer",
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("BOSS_CORLEONE_BOSS"))
+ );
+ put(
+ "Chest Looter",
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("CHEST"))
+ );
+ put(
+ "Titanium",
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("TITANIUM_ORE"))
+ );
+ put(
+ "Mithril",
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("MITHRIL_ORE"))
+ );
+ put(
+ "Forge",
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("ANVIL"))
+ );
+ }};
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningSkillOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningSkillOverlay.java
new file mode 100644
index 00000000..fb7cdab5
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningSkillOverlay.java
@@ -0,0 +1,361 @@
+package io.github.moulberry.notenoughupdates.overlays;
+
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.core.config.Position;
+import io.github.moulberry.notenoughupdates.core.util.lerp.LerpUtils;
+import io.github.moulberry.notenoughupdates.util.Utils;
+import io.github.moulberry.notenoughupdates.util.XPInformation;
+import net.minecraft.client.Minecraft;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.EnumChatFormatting;
+
+import java.text.NumberFormat;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.function.Supplier;
+
+public class MiningSkillOverlay
+ extends TextOverlay { //Im sure there is a much better way to do this besides making another class ¯\_(ツ)_/¯
+ private long lastUpdate = -1;
+ private int compactLast = -1;
+ private int compact = -1;
+ private int compactTier = -1;
+ private String compactTierAmount = "1";
+ private float minedPerSecondLast = 0;
+ private float minedPerSecond = 0;
+ private final LinkedList<Integer> compactQueue = new LinkedList<>();
+
+ private XPInformation.SkillInfo skillInfo = null;
+ private XPInformation.SkillInfo skillInfoLast = null;
+
+ private float lastTotalXp = -1;
+ private boolean isMining = false;
+ private final LinkedList<Float> xpGainQueue = new LinkedList<>();
+ private float xpGainHourLast = -1;
+ private float xpGainHour = -1;
+
+ private int xpGainTimer = 0;
+
+ private final String skillType = "Mining";
+
+ public MiningSkillOverlay(
+ Position position,
+ Supplier<List<String>> dummyStrings,
+ Supplier<TextOverlayStyle> styleSupplier
+ ) {
+ super(position, dummyStrings, styleSupplier);
+ }
+
+ private float interp(float now, float last) {
+ float interp = now;
+ if (last >= 0 && last != now) {
+ float factor = (System.currentTimeMillis() - lastUpdate) / 1000f;
+ factor = LerpUtils.clampZeroOne(factor);
+ interp = last + (now - last) * factor;
+ }
+ return interp;
+ }
+
+ @Override
+ public void update() {
+ if (!NotEnoughUpdates.INSTANCE.config.skillOverlays.miningSkillOverlay) {
+ compact = -1;
+ overlayStrings = null;
+ return;
+ }
+
+ lastUpdate = System.currentTimeMillis();
+ compactLast = compact;
+ xpGainHourLast = xpGainHour;
+ compact = -1;
+
+ if (Minecraft.getMinecraft().thePlayer == null) return;
+
+ ItemStack stack = Minecraft.getMinecraft().thePlayer.getHeldItem();
+ if (stack != null && stack.hasTagCompound()) {
+ NBTTagCompound tag = stack.getTagCompound();
+
+ if (tag.hasKey("ExtraAttributes", 10)) {
+ NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
+
+ if (ea.hasKey("compact_blocks", 99)) {
+ compact = ea.getInteger("compact_blocks");
+ compactQueue.add(0, compact);
+ }
+ }
+ }
+ if (compact < 100) {
+ compactTier = 1;
+ } else if (compact < 500) {
+ compactTier = 2;
+ } else if (compact < 1500) {
+ compactTier = 3;
+ } else if (compact < 5000) {
+ compactTier = 4;
+ } else if (compact < 15000) {
+ compactTier = 5;
+ } else if (compact < 50000) {
+ compactTier = 6;
+ } else if (compact < 150000) {
+ compactTier = 7;
+ } else if (compact < 500000) {
+ compactTier = 8;
+ } else if (compact < 1000000) {
+ compactTier = 9;
+ } else if (compact > 1000000) {
+ compactTier = 10;
+ }
+
+ switch (compactTier) {
+ case 1:
+ compactTierAmount = "100";
+ break;
+ case 2:
+ compactTierAmount = "500";
+ break;
+ case 3:
+ compactTierAmount = "1,500";
+ break;
+ case 4:
+ compactTierAmount = "5,000";
+ break;
+ case 5:
+ compactTierAmount = "15,000";
+ break;
+ case 6:
+ compactTierAmount = "50,000";
+ break;
+ case 7:
+ compactTierAmount = "150,000";
+ break;
+ case 8:
+ compactTierAmount = "500,000";
+ break;
+ case 9:
+ compactTierAmount = "1,000,000";
+ break;
+ case 10:
+ compactTierAmount = "Maxed";
+ break;
+ }
+
+ String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack);
+
+ skillInfoLast = skillInfo;
+ skillInfo = XPInformation.getInstance().getSkillInfo(skillType);
+ if (skillInfo != null) {
+ float totalXp = skillInfo.totalXp;
+
+ if (lastTotalXp > 0) {
+ float delta = totalXp - lastTotalXp;
+
+ if (delta > 0 && delta < 1000) {
+ xpGainTimer = 3;
+
+ xpGainQueue.add(0, delta);
+ while (xpGainQueue.size() > 30) {
+ xpGainQueue.removeLast();
+ }
+
+ float totalGain = 0;
+ for (float f : xpGainQueue) totalGain += f;
+
+ xpGainHour = totalGain * (60 * 60) / xpGainQueue.size();
+
+ isMining = true;
+ } else if (xpGainTimer > 0) {
+ xpGainTimer--;
+
+ xpGainQueue.add(0, 0f);
+ while (xpGainQueue.size() > 30) {
+ xpGainQueue.removeLast();
+ }
+
+ float totalGain = 0;
+ for (float f : xpGainQueue) totalGain += f;
+
+ xpGainHour = totalGain * (60 * 60) / xpGainQueue.size();
+
+ isMining = true;
+ } else if (delta <= 0) {
+ isMining = false;
+ }
+ }
+
+ lastTotalXp = totalXp;
+ }
+
+ while (compactQueue.size() >= 4) {
+ compactQueue.removeLast();
+ }
+
+ if (compactQueue.isEmpty()) {
+ minedPerSecond = -1;
+ minedPerSecondLast = 0;
+ } else {
+ minedPerSecondLast = minedPerSecond;
+ int last = compactQueue.getLast();
+ int first = compactQueue.getFirst();
+
+ minedPerSecond = (first - last) / 3f;
+ }
+
+ if (compact != -1) {
+ overlayStrings = new ArrayList<>();
+ } else {
+ overlayStrings = null;
+ }
+
+ }
+
+ @Override
+ public void updateFrequent() {
+ super.updateFrequent();
+
+ if (compact < 0) {
+ overlayStrings = null;
+ } else {
+ HashMap<Integer, String> lineMap = new HashMap<>();
+
+ overlayStrings = new ArrayList<>();
+
+ NumberFormat format = NumberFormat.getIntegerInstance();
+
+ if (compact >= 0) {
+ int counterInterp = (int) interp(compact, compactLast);
+
+ lineMap.put(
+ 0,
+ EnumChatFormatting.AQUA + "Compact: " + EnumChatFormatting.YELLOW + format.format(counterInterp)
+ );
+ }
+
+ if (compact >= 0) {
+ if (minedPerSecondLast == minedPerSecond && minedPerSecond <= 0) {
+ lineMap.put(1, EnumChatFormatting.AQUA + "Blocks/m: " + EnumChatFormatting.YELLOW + "N/A");
+ } else {
+ float cpsInterp = interp(minedPerSecond, minedPerSecondLast);
+
+ lineMap.put(1, EnumChatFormatting.AQUA + "Blocks/m: " + EnumChatFormatting.YELLOW +
+ String.format("%,.2f", cpsInterp * 60));
+ }
+ }
+
+ if (compactTier <= 9) {
+ int counterInterp = (int) interp(compact, compactLast);
+ lineMap.put(
+ 8,
+ EnumChatFormatting.AQUA + "Compact Progress: " + EnumChatFormatting.YELLOW + format.format(counterInterp) +
+ "/" + compactTierAmount
+ );
+ }
+ if (compactTier == 10) {
+ lineMap.put(8, EnumChatFormatting.AQUA + "Compact Progress: " + EnumChatFormatting.RED + compactTierAmount);
+ }
+
+ float xpInterp = xpGainHour;
+ if (xpGainHourLast == xpGainHour && xpGainHour <= 0) {
+ lineMap.put(5, EnumChatFormatting.AQUA + "XP/h: " + EnumChatFormatting.YELLOW + "N/A");
+ } else {
+ xpInterp = interp(xpGainHour, xpGainHourLast);
+
+ lineMap.put(5, EnumChatFormatting.AQUA + "XP/h: " + EnumChatFormatting.YELLOW +
+ format.format(xpInterp) + (isMining ? "" : EnumChatFormatting.RED + " (PAUSED)"));
+ }
+
+ if (skillInfo != null && skillInfo.level < 60) {
+ StringBuilder levelStr = new StringBuilder(EnumChatFormatting.AQUA + "Mining" + ": "); //yes ik its spelt wrong
+
+ levelStr.append(EnumChatFormatting.YELLOW)
+ .append(skillInfo.level)
+ .append(EnumChatFormatting.GRAY)
+ .append(" [");
+
+ float progress = skillInfo.currentXp / skillInfo.currentXpMax;
+ if (skillInfoLast != null && skillInfo.currentXpMax == skillInfoLast.currentXpMax) {
+ progress = interp(progress, skillInfoLast.currentXp / skillInfoLast.currentXpMax);
+ }
+
+ float lines = 25;
+ for (int i = 0; i < lines; i++) {
+ if (i / lines < progress) {
+ levelStr.append(EnumChatFormatting.YELLOW);
+ } else {
+ levelStr.append(EnumChatFormatting.DARK_GRAY);
+ }
+ levelStr.append('|');
+ }
+
+ levelStr.append(EnumChatFormatting.GRAY)
+ .append("] ")
+ .append(EnumChatFormatting.YELLOW)
+ .append((int) (progress * 100))
+ .append("%");
+
+ int current = (int) skillInfo.currentXp;
+ if (skillInfoLast != null && skillInfo.currentXpMax == skillInfoLast.currentXpMax) {
+ current = (int) interp(current, skillInfoLast.currentXp);
+ }
+
+ int remaining = (int) (skillInfo.currentXpMax - skillInfo.currentXp);
+ if (skillInfoLast != null && skillInfo.currentXpMax == skillInfoLast.currentXpMax) {
+ remaining = (int) interp(remaining, (int) (skillInfoLast.currentXpMax - skillInfoLast.currentXp));
+ }
+
+ lineMap.put(2, levelStr.toString());
+ lineMap.put(3, EnumChatFormatting.AQUA + "Current XP: " + EnumChatFormatting.YELLOW + format.format(current));
+ if (remaining < 0) {
+ lineMap.put(4, EnumChatFormatting.AQUA + "Remaining XP: " + EnumChatFormatting.YELLOW + "MAXED!");
+ lineMap.put(7, EnumChatFormatting.AQUA + "ETA: " + EnumChatFormatting.YELLOW + "MAXED!");
+ } else {
+ lineMap.put(
+ 4,
+ EnumChatFormatting.AQUA + "Remaining XP: " + EnumChatFormatting.YELLOW + format.format(remaining)
+ );
+ if (xpGainHour < 1000) {
+ lineMap.put(7, EnumChatFormatting.AQUA + "ETA: " + EnumChatFormatting.YELLOW + "N/A");
+ } else {
+ lineMap.put(
+ 7,
+ EnumChatFormatting.AQUA + "ETA: " + EnumChatFormatting.YELLOW +
+ Utils.prettyTime((long) (remaining) * 1000 * 60 * 60 / (long) xpInterp)
+ );
+ }
+ }
+
+ }
+
+ if (skillInfo != null && skillInfo.level == 60) {
+ int current = (int) skillInfo.currentXp;
+ if (skillInfoLast != null && skillInfo.currentXpMax == skillInfoLast.currentXpMax) {
+ current = (int) interp(current, skillInfoLast.currentXp);
+ }
+
+ lineMap.put(
+ 2,
+ EnumChatFormatting.AQUA + "Mining: " + EnumChatFormatting.YELLOW + "60 " + EnumChatFormatting.RED + "(Maxed)"
+ );
+ lineMap.put(3, EnumChatFormatting.AQUA + "Current XP: " + EnumChatFormatting.YELLOW + format.format(current));
+
+ }
+
+ float yaw = Minecraft.getMinecraft().thePlayer.rotationYawHead;
+ yaw %= 360;
+ if (yaw < 0) yaw += 360;
+ if (yaw > 180) yaw -= 360;
+
+ lineMap.put(6, EnumChatFormatting.AQUA + "Yaw: " + EnumChatFormatting.YELLOW +
+ String.format("%.2f", yaw) + EnumChatFormatting.BOLD + "\u1D52");
+
+ for (int strIndex : NotEnoughUpdates.INSTANCE.config.skillOverlays.miningText) {
+ if (lineMap.get(strIndex) != null) {
+ overlayStrings.add(lineMap.get(strIndex));
+ }
+ }
+ if (overlayStrings != null && overlayStrings.isEmpty()) overlayStrings = null;
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/OverlayManager.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/OverlayManager.java
index 409f1a70..8c25594e 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/OverlayManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/OverlayManager.java
@@ -8,171 +8,282 @@ import java.util.ArrayList;
import java.util.List;
public class OverlayManager {
+ public static Class<? extends TextOverlay> dontRenderOverlay = null;
- public static Class<? extends TextOverlay> dontRenderOverlay = null;
+ public static MiningOverlay miningOverlay;
+ public static FarmingOverlay farmingOverlay;
+ public static FishingSkillOverlay fishingSkillOverlay;
+ public static MiningSkillOverlay miningSkillOverlay;
+ public static CombatSkillOverlay combatSkillOverlay;
+ public static PetInfoOverlay petInfoOverlay;
+ public static TimersOverlay timersOverlay;
+ public static BonemerangOverlay bonemerangOverlay;
+ public static CrystalHollowOverlay crystalHollowOverlay;
+ public static SlayerOverlay slayerOverlay;
+ public static final List<TextOverlay> textOverlays = new ArrayList<>();
- public static MiningOverlay miningOverlay;
- public static FarmingOverlay farmingOverlay;
- public static PetInfoOverlay petInfoOverlay;
- public static TimersOverlay timersOverlay;
- public static BonemerangOverlay bonemerangOverlay;
- public static CrystalHollowOverlay crystalHollowOverlay;
- public static final List<TextOverlay> textOverlays = new ArrayList<>();
+ static {
+ List<String> todoDummy = Lists.newArrayList(
+ "\u00a73Cakes: \u00a7eInactive!",
+ "\u00a73Cookie Buff: \u00a7eInactive!",
+ "\u00a73Godpot: \u00a7eInactive!",
+ "\u00a73Puzzler: \u00a7eReady!",
+ "\u00a73Fetchur: \u00a7eReady!",
+ "\u00a73Commissions: \u00a7eReady!",
+ "\u00a73Experiments: \u00a7eReady!",
+ "\u00a73Daily Mithril Powder: \u00a7eReady",
+ "\u00a73Daily Gemstone Powder: \u00a7eReady",
+ "\u00a73Cakes: \u00a7e1d21h",
+ "\u00a73Cookie Buff: \u00a7e2d23h",
+ "\u00a73Godpot: \u00a7e19h",
+ "\u00a73Puzzler: \u00a7e13h",
+ "\u00a73Fetchur: \u00a7e3h38m",
+ "\u00a73Commissions: \u00a7e3h38m",
+ "\u00a73Experiments: \u00a7e3h38m",
+ "\u00a73Daily Mithril Powder: \u00a7e3h38m",
+ "\u00a73Daily Gemstone Powder: \u00a7e3h38m"
+ );
+ textOverlays.add(
+ timersOverlay = new TimersOverlay(NotEnoughUpdates.INSTANCE.config.miscOverlays.todoPosition, () -> {
+ List<String> strings = new ArrayList<>();
+ for (int i : NotEnoughUpdates.INSTANCE.config.miscOverlays.todoText2) {
+ if (i >= 0 && i < todoDummy.size()) strings.add(todoDummy.get(i));
+ }
+ return strings;
+ }, () -> {
+ int style = NotEnoughUpdates.INSTANCE.config.miscOverlays.todoStyle;
+ if (style >= 0 && style < TextOverlayStyle.values().length) {
+ return TextOverlayStyle.values()[style];
+ }
+ return TextOverlayStyle.BACKGROUND;
+ }));
- static {
- List<String> todoDummy = Lists.newArrayList(
- "\u00a73Cakes: \u00a7eInactive!",
- "\u00a73Cookie Buff: \u00a7eInactive!",
- "\u00a73Godpot: \u00a7eInactive!",
- "\u00a73Puzzler: \u00a7eReady!",
- "\u00a73Fetchur: \u00a7eReady!",
- "\u00a73Commissions: \u00a7eReady!",
- "\u00a73Experiments: \u00a7eReady!",
- "\u00a73Cakes: \u00a7e1d21h",
- "\u00a73Cookie Buff: \u00a7e2d23h",
- "\u00a73Godpot: \u00a7e19h",
- "\u00a73Puzzler: \u00a7e13h",
- "\u00a73Fetchur: \u00a7e3h38m",
- "\u00a73Commissions: \u00a7e3h38m",
- "\u00a73Experiments: \u00a7e3h38m");
- textOverlays.add(timersOverlay = new TimersOverlay(NotEnoughUpdates.INSTANCE.config.miscOverlays.todoPosition, () -> {
- List<String> strings = new ArrayList<>();
- for(int i : NotEnoughUpdates.INSTANCE.config.miscOverlays.todoText2) {
- if(i >= 0 && i < todoDummy.size()) strings.add(todoDummy.get(i));
- }
- return strings;
- }, () -> {
- int style = NotEnoughUpdates.INSTANCE.config.miscOverlays.todoStyle;
- if(style >= 0 && style < TextOverlayStyle.values().length) {
- return TextOverlayStyle.values()[style];
- }
- return TextOverlayStyle.BACKGROUND;
- }));
+ List<String> miningDummy = Lists.newArrayList(
+ "\u00a73Goblin Slayer: \u00a7626.5%\n\u00a73Lucky Raffle: \u00a7c0.0%",
+ "\u00a73Mithril Powder: \u00a726,243",
+ "\u00a73Forge 1) \u00a79Diamonite\u00a77: \u00a7aReady!",
+ "\u00a73Forge 2) \u00a77EMPTY\n\u00a73Forge 3) \u00a77EMPTY\n\u00a73Forge 4) \u00a77EMPTY"
+ );
+ miningOverlay = new MiningOverlay(NotEnoughUpdates.INSTANCE.config.mining.overlayPosition, () -> {
+ List<String> strings = new ArrayList<>();
+ for (int i : NotEnoughUpdates.INSTANCE.config.mining.dwarvenText2) {
+ if (i >= 0 && i < miningDummy.size()) strings.add(miningDummy.get(i));
+ }
+ return strings;
+ }, () -> {
+ int style = NotEnoughUpdates.INSTANCE.config.mining.overlayStyle;
+ if (style >= 0 && style < TextOverlayStyle.values().length) {
+ return TextOverlayStyle.values()[style];
+ }
+ return TextOverlayStyle.BACKGROUND;
+ });
- List<String> miningDummy = Lists.newArrayList("\u00a73Goblin Slayer: \u00a7626.5%\n\u00a73Lucky Raffle: \u00a7c0.0%",
- "\u00a73Mithril Powder: \u00a726,243",
- "\u00a73Forge 1) \u00a79Diamonite\u00a77: \u00a7aReady!",
- "\u00a73Forge 2) \u00a77EMPTY\n\u00a73Forge 3) \u00a77EMPTY\n\u00a73Forge 4) \u00a77EMPTY");
- miningOverlay = new MiningOverlay(NotEnoughUpdates.INSTANCE.config.mining.overlayPosition, () -> {
- List<String> strings = new ArrayList<>();
- for(int i : NotEnoughUpdates.INSTANCE.config.mining.dwarvenText2) {
- if(i >= 0 && i < miningDummy.size()) strings.add(miningDummy.get(i));
- }
- return strings;
- }, () -> {
- int style = NotEnoughUpdates.INSTANCE.config.mining.overlayStyle;
- if(style >= 0 && style < TextOverlayStyle.values().length) {
- return TextOverlayStyle.values()[style];
- }
- return TextOverlayStyle.BACKGROUND;
- });
+ List<String> farmingDummy = Lists.newArrayList(
+ "\u00a7bCounter: \u00a7e37,547,860",
+ "\u00a7bCrops/m: \u00a7e38.29",
+ "\u00a7bFarm: \u00a7e12\u00a77 [\u00a7e|||||||||||||||||\u00a78||||||||\u00a77] \u00a7e67%",
+ "\u00a7bCurrent XP: \u00a7e6,734",
+ "\u00a7bRemaining XP: \u00a7e3,265",
+ "\u00a7bXP/h: \u00a7e238,129",
+ "\u00a7bYaw: \u00a7e68.25\u00a7l\u1D52"
+ );
+ farmingOverlay = new FarmingOverlay(NotEnoughUpdates.INSTANCE.config.skillOverlays.farmingPosition, () -> {
+ List<String> strings = new ArrayList<>();
+ for (int i : NotEnoughUpdates.INSTANCE.config.skillOverlays.farmingText) {
+ if (i >= 0 && i < farmingDummy.size()) strings.add(farmingDummy.get(i));
+ }
+ return strings;
+ }, () -> {
+ int style = NotEnoughUpdates.INSTANCE.config.skillOverlays.farmingStyle;
+ if (style >= 0 && style < TextOverlayStyle.values().length) {
+ return TextOverlayStyle.values()[style];
+ }
+ return TextOverlayStyle.BACKGROUND;
+ });
+ List<String> miningSkillDummy = Lists.newArrayList(
+ "\u00a7bCompact: \u00a7e547,860",
+ "\u00a7bBlocks/m: \u00a7e38.29",
+ "\u00a7bMine: \u00a7e12\u00a77 [\u00a7e|||||||||||||||||\u00a78||||||||\u00a77] \u00a7e67%",
+ "\u00a7bCurrent XP: \u00a7e6,734",
+ "\u00a7bRemaining XP: \u00a7e3,265",
+ "\u00a7bXP/h: \u00a7e238,129",
+ "\u00a7bYaw: \u00a7e68.25\u00a7l\u1D52"
+ );
+ miningSkillOverlay = new MiningSkillOverlay(NotEnoughUpdates.INSTANCE.config.skillOverlays.miningPosition, () -> {
+ List<String> strings = new ArrayList<>();
+ for (int i : NotEnoughUpdates.INSTANCE.config.skillOverlays.miningText) {
+ if (i >= 0 && i < miningSkillDummy.size()) strings.add(miningSkillDummy.get(i));
+ }
+ return strings;
+ }, () -> {
+ int style = NotEnoughUpdates.INSTANCE.config.skillOverlays.miningStyle;
+ if (style >= 0 && style < TextOverlayStyle.values().length) {
+ return TextOverlayStyle.values()[style];
+ }
+ return TextOverlayStyle.BACKGROUND;
+ });
+ List<String> fishingDummy = Lists.newArrayList(
+ "\u00a7bCatches: \u00a7e37,547,860",
+ //"\u00a7bCatches/m: \u00a7e38.29",
+ "\u00a7bFish: \u00a7e12\u00a77 [\u00a7e|||||||||||||||||\u00a78||||||||\u00a77] \u00a7e67%",
+ "\u00a7bCurrent XP: \u00a7e6,734",
+ "\u00a7bRemaining XP: \u00a7e3,265",
+ "\u00a7bXP/h: \u00a7e238,129"
+ //"\u00a7bYaw: \u00a7e68.25\u00a7l\u1D52"
+ );
+ fishingSkillOverlay =
+ new FishingSkillOverlay(NotEnoughUpdates.INSTANCE.config.skillOverlays.fishingPosition, () -> {
+ List<String> strings = new ArrayList<>();
+ for (int i : NotEnoughUpdates.INSTANCE.config.skillOverlays.fishingText) {
+ if (i >= 0 && i < fishingDummy.size()) strings.add(fishingDummy.get(i));
+ }
+ return strings;
+ }, () -> {
+ int style = NotEnoughUpdates.INSTANCE.config.skillOverlays.fishingStyle;
+ if (style >= 0 && style < TextOverlayStyle.values().length) {
+ return TextOverlayStyle.values()[style];
+ }
+ return TextOverlayStyle.BACKGROUND;
+ });
+ List<String> combatSkillDummy = Lists.newArrayList(
+ "\u00a7bKills: \u00a7e547,860",
+ "\u00a7bCombat: \u00a7e12\u00a77 [\u00a7e|||||||||||||||||\u00a78||||||||\u00a77] \u00a7e67%",
+ "\u00a7bCurrent XP: \u00a7e6,734",
+ "\u00a7bRemaining XP: \u00a7e3,265",
+ "\u00a7bXP/h: \u00a7e238,129",
+ "\u00a7bETA: \u00a7e13h12m"
+ );
+ combatSkillOverlay = new CombatSkillOverlay(NotEnoughUpdates.INSTANCE.config.skillOverlays.combatPosition, () -> {
+ List<String> strings = new ArrayList<>();
+ for (int i : NotEnoughUpdates.INSTANCE.config.skillOverlays.combatText) {
+ if (i >= 0 && i < combatSkillDummy.size()) strings.add(combatSkillDummy.get(i));
+ }
+ return strings;
+ }, () -> {
+ int style = NotEnoughUpdates.INSTANCE.config.skillOverlays.combatStyle;
+ if (style >= 0 && style < TextOverlayStyle.values().length) {
+ return TextOverlayStyle.values()[style];
+ }
+ return TextOverlayStyle.BACKGROUND;
+ });
+ List<String> petInfoDummy = Lists.newArrayList(
+ "\u00a7a[Lvl 37] \u00a7fRock",
+ "\u00a7b2,312.9/2,700\u00a7e (85.7%)",
+ "\u00a7b2.3k/2.7k\u00a7e (85.7%)",
+ "\u00a7bXP/h: \u00a7e27,209",
+ "\u00a7bTotal XP: \u00a7e30,597.9",
+ "\u00a7bHeld Item: \u00a7fMining Exp Boost",
+ "\u00a7bUntil L38: \u00a7e5m13s",
+ "\u00a7bUntil L100: \u00a7e2d13h"
+ );
+ petInfoOverlay = new PetInfoOverlay(NotEnoughUpdates.INSTANCE.config.petOverlay.petInfoPosition, () -> {
+ List<String> strings = new ArrayList<>();
+ for (int i : NotEnoughUpdates.INSTANCE.config.petOverlay.petOverlayText) {
+ if (i >= 0 && i < petInfoDummy.size()) strings.add(petInfoDummy.get(i));
+ }
+ return strings;
+ }, () -> {
+ int style = NotEnoughUpdates.INSTANCE.config.petOverlay.petInfoOverlayStyle;
+ if (style >= 0 && style < TextOverlayStyle.values().length) {
+ return TextOverlayStyle.values()[style];
+ }
+ return TextOverlayStyle.BACKGROUND;
+ });
- List<String> farmingDummy = Lists.newArrayList("\u00a7bCounter: \u00a7e37,547,860",
- "\u00a7bCrops/m: \u00a7e38.29",
- "\u00a7bFarm: \u00a7e12\u00a77 [\u00a7e|||||||||||||||||\u00a78||||||||\u00a77] \u00a7e67%",
- "\u00a7bCurrent XP: \u00a7e6,734",
- "\u00a7bRemaining XP: \u00a7e3,265",
- "\u00a7bXP/h: \u00a7e238,129",
- "\u00a7bYaw: \u00a7e68.25\u00a7l\u1D52");
- farmingOverlay = new FarmingOverlay(NotEnoughUpdates.INSTANCE.config.skillOverlays.farmingPosition, () -> {
- List<String> strings = new ArrayList<>();
- for(int i : NotEnoughUpdates.INSTANCE.config.skillOverlays.farmingText) {
- if(i >= 0 && i < farmingDummy.size()) strings.add(farmingDummy.get(i));
- }
- return strings;
- }, () -> {
- int style = NotEnoughUpdates.INSTANCE.config.skillOverlays.farmingStyle;
- if(style >= 0 && style < TextOverlayStyle.values().length) {
- return TextOverlayStyle.values()[style];
- }
- return TextOverlayStyle.BACKGROUND;
- });
+ List<String> bonemerangDummy = Lists.newArrayList(
+ "\u00a7cBonemerang will break!",
+ "\u00a77Targets: \u00a76\u00a7l10"
+ );
+ bonemerangOverlay = new BonemerangOverlay(
+ NotEnoughUpdates.INSTANCE.config.itemOverlays.bonemerangPosition,
+ () -> bonemerangDummy,
+ () -> {
+ int style = NotEnoughUpdates.INSTANCE.config.itemOverlays.bonemerangOverlayStyle;
+ if (style >= 0 && style < TextOverlayStyle.values().length) {
+ return TextOverlayStyle.values()[style];
+ }
+ return TextOverlayStyle.BACKGROUND;
+ }
+ );
+ List<String> crystalHollowOverlayDummy = Lists.newArrayList(
+ "\u00a73Amber Crystal: \u00a7aPlaced\n" +
+ "\u00a73Sapphire Crystal: \u00a7eCollected\n" +
+ "\u00a73Jade Crystal: \u00a7eMissing\n" +
+ "\u00a73Amethyst Crystal: \u00a7cMissing\n" +
+ "\u00a73Topaz Crystal: \u00a7cMissing\n",
+ "\u00a73Crystals: \u00a7a4/5",
+ "\u00a73Crystals: \u00a7a80%",
+ "\u00a73Electron Transmitter: \u00a7aDone\n" +
+ "\u00a73Robotron Reflector: \u00a7eIn Storage\n" +
+ "\u00a73Superlite Motor: \u00a7eIn Inventory\n" +
+ "\u00a73Synthetic Hearth: \u00a7cMissing\n" +
+ "\u00a73Control Switch: \u00a7cMissing\n" +
+ "\u00a73FTX 3070: \u00a7cMissing",
+ "\u00a73Electron Transmitter: \u00a7a3\n" +
+ "\u00a73Robotron Reflector: \u00a7e2\n" +
+ "\u00a73Superlite Motor: \u00a7e1\n" +
+ "\u00a73Synthetic Hearth: \u00a7c0\n" +
+ "\u00a73Control Switch: \u00a7c0\n" +
+ "\u00a73FTX 3070: \u00a7c0",
+ "\u00a73Automaton parts: \u00a7a5/6",
+ "\u00a73Automaton parts: \u00a7a83%",
+ "\u00a73Scavenged Lapis Sword: \u00a7aDone\n" +
+ "\u00a73Scavenged Golden Hammer: \u00a7eIn Storage\n" +
+ "\u00a73Scavenged Diamond Axe: \u00a7eIn Inventory\n" +
+ "\u00a73Scavenged Emerald Hammer: \u00a7cMissing\n",
+ "\u00a73Scavenged Lapis Sword: \u00a7a3\n" +
+ "\u00a73Scavenged Golden Hammer: \u00a7e2\n" +
+ "\u00a73Scavenged Diamond Axe: \u00a7e1\n" +
+ "\u00a73Scavenged Emerald Hammer: \u00a7c0\n",
+ "\u00a73Mines of Divan parts: \u00a7a3/4",
+ "\u00a73Mines of Divan parts: \u00a7a75%"
+ );
+ crystalHollowOverlay =
+ new CrystalHollowOverlay(NotEnoughUpdates.INSTANCE.config.mining.crystalHollowOverlayPosition, () -> {
+ List<String> strings = new ArrayList<>();
+ for (int i : NotEnoughUpdates.INSTANCE.config.mining.crystalHollowText) {
+ if (i >= 0 && i < crystalHollowOverlayDummy.size()) strings.add(crystalHollowOverlayDummy.get(i));
+ }
+ return strings;
+ }, () -> {
+ int style = NotEnoughUpdates.INSTANCE.config.mining.crystalHollowOverlayStyle;
+ if (style >= 0 && style < TextOverlayStyle.values().length) {
+ return TextOverlayStyle.values()[style];
+ }
+ return TextOverlayStyle.BACKGROUND;
+ });
+ List<String> slayerDummy = Lists.newArrayList(
+ "\u00a7eSlayer: \u00a74Sven",
+ "\u00a7eRNG Meter: \u00a75100%",
+ "\u00a7eLvl: \u00a7d7",
+ "\u00a7eKill time: \u00a7c1:30",
+ "\u00a7eXP: \u00a7d75,450/100,000",
+ "\u00a7eBosses till next Lvl: \u00a7d17",
+ "\u00a7eAverage kill time: \u00a7c3:20"
+ );
+ slayerOverlay = new SlayerOverlay(NotEnoughUpdates.INSTANCE.config.slayerOverlay.slayerPosition, () -> {
+ List<String> strings = new ArrayList<>();
+ for (int i : NotEnoughUpdates.INSTANCE.config.slayerOverlay.slayerText) {
+ if (i >= 0 && i < slayerDummy.size()) strings.add(slayerDummy.get(i));
+ }
+ return strings;
+ }, () -> {
+ int style = NotEnoughUpdates.INSTANCE.config.slayerOverlay.slayerStyle;
+ if (style >= 0 && style < TextOverlayStyle.values().length) {
+ return TextOverlayStyle.values()[style];
+ }
+ return TextOverlayStyle.BACKGROUND;
+ });
- List<String> petInfoDummy = Lists.newArrayList("\u00a7a[Lvl 37] \u00a7fRock",
- "\u00a7b2,312.9/2,700\u00a7e (85.7%)",
- "\u00a7b2.3k/2.7k\u00a7e (85.7%)",
- "\u00a7bXP/h: \u00a7e27,209",
- "\u00a7bTotal XP: \u00a7e30,597.9",
- "\u00a7bHeld Item: \u00a7fMining Exp Boost",
- "\u00a7bUntil L38: \u00a7e5m13s",
- "\u00a7bUntil L100: \u00a7e2d13h");
- petInfoOverlay = new PetInfoOverlay(NotEnoughUpdates.INSTANCE.config.petOverlay.petInfoPosition, () -> {
- List<String> strings = new ArrayList<>();
- for(int i : NotEnoughUpdates.INSTANCE.config.petOverlay.petOverlayText) {
- if(i >= 0 && i < petInfoDummy.size()) strings.add(petInfoDummy.get(i));
- }
- return strings;
- }, () -> {
- int style = NotEnoughUpdates.INSTANCE.config.petOverlay.petInfoOverlayStyle;
- if(style >= 0 && style < TextOverlayStyle.values().length) {
- return TextOverlayStyle.values()[style];
- }
- return TextOverlayStyle.BACKGROUND;
- });
-
- List<String> bonemerangDummy = Lists.newArrayList(
- "\u00a7cBonemerang will break!",
- "\u00a77Targets: \u00a76\u00a7l10"
- );
- bonemerangOverlay = new BonemerangOverlay(NotEnoughUpdates.INSTANCE.config.itemOverlays.bonemerangPosition, () -> bonemerangDummy, () -> {
- int style = NotEnoughUpdates.INSTANCE.config.itemOverlays.bonemerangOverlayStyle;
- if(style >= 0 && style < TextOverlayStyle.values().length) {
- return TextOverlayStyle.values()[style];
- }
- return TextOverlayStyle.BACKGROUND;
- });
- List<String> crystalHollowOverlayDummy = Lists.newArrayList(
- "\u00a73Amber Crystal: \u00a7aPlaced\n" +
- "\u00a73Sapphire Crystal: \u00a7eCollected\n" +
- "\u00a73Jade Crystal: \u00a7eMissing\n" +
- "\u00a73Amethyst Crystal: \u00a7cMissing\n" +
- "\u00a73Topaz Crystal: \u00a7cMissing\n",
- "\u00a73Crystals: \u00a7a4/5",
- "\u00a73Crystals: \u00a7a80%",
- "\u00a73Electron Transmitter: \u00a7aDone\n" +
- "\u00a73Robotron Reflector: \u00a7eIn Storage\n" +
- "\u00a73Superlite Motor: \u00a7eIn Inventory\n" +
- "\u00a73Synthetic Hearth: \u00a7cMissing\n" +
- "\u00a73Control Switch: \u00a7cMissing\n" +
- "\u00a73FTX 3070: \u00a7cMissing",
- "\u00a73Electron Transmitter: \u00a7a3\n" +
- "\u00a73Robotron Reflector: \u00a7e2\n" +
- "\u00a73Superlite Motor: \u00a7e1\n" +
- "\u00a73Synthetic Hearth: \u00a7c0\n" +
- "\u00a73Control Switch: \u00a7c0\n" +
- "\u00a73FTX 3070: \u00a7c0",
- "\u00a73Automaton parts: \u00a7a5/6",
- "\u00a73Automaton parts: \u00a7a83%",
- "\u00a73Scavenged Lapis Sword: \u00a7aDone\n" +
- "\u00a73Scavenged Golden Hammer: \u00a7eIn Storage\n" +
- "\u00a73Scavenged Diamond Axe: \u00a7eIn Inventory\n" +
- "\u00a73Scavenged Emerald Hammer: \u00a7cMissing\n",
- "\u00a73Scavenged Lapis Sword: \u00a7a3\n" +
- "\u00a73Scavenged Golden Hammer: \u00a7e2\n" +
- "\u00a73Scavenged Diamond Axe: \u00a7e1\n" +
- "\u00a73Scavenged Emerald Hammer: \u00a7c0\n",
- "\u00a73Mines of Divan parts: \u00a7a3/4",
- "\u00a73Mines of Divan parts: \u00a7a75%"
- );
- crystalHollowOverlay = new CrystalHollowOverlay(NotEnoughUpdates.INSTANCE.config.mining.crystalHollowOverlayPosition, () -> {
- List<String> strings = new ArrayList<>();
- for (int i : NotEnoughUpdates.INSTANCE.config.mining.crystalHollowText) {
- if (i >= 0 && i < crystalHollowOverlayDummy.size()) strings.add(crystalHollowOverlayDummy.get(i));
- }
- return strings;
- }, () -> {
- int style = NotEnoughUpdates.INSTANCE.config.mining.crystalHollowOverlayStyle;
- if (style >= 0 && style < TextOverlayStyle.values().length) {
- return TextOverlayStyle.values()[style];
- }
- return TextOverlayStyle.BACKGROUND;
- });
-
- textOverlays.add(miningOverlay);
- textOverlays.add(farmingOverlay);
- textOverlays.add(petInfoOverlay);
- textOverlays.add(bonemerangOverlay);
- textOverlays.add(crystalHollowOverlay);
- }
+ textOverlays.add(miningOverlay);
+ textOverlays.add(farmingOverlay);
+ textOverlays.add(miningSkillOverlay);
+ textOverlays.add(combatSkillOverlay);
+ textOverlays.add(fishingSkillOverlay);
+ textOverlays.add(petInfoOverlay);
+ textOverlays.add(bonemerangOverlay);
+ textOverlays.add(crystalHollowOverlay);
+ textOverlays.add(slayerOverlay);
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/RancherBootOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/RancherBootOverlay.java
index 736f1488..94bd53a2 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/RancherBootOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/RancherBootOverlay.java
@@ -16,146 +16,156 @@ import org.lwjgl.input.Mouse;
import java.util.HashMap;
public class RancherBootOverlay {
-
- private static int selectedIndex = 0;
-
- private static HashMap<Integer, Integer> currentSpeeds = new HashMap<>();
- private static GuiElementSlider slider = new GuiElementSlider(0, 0, 145, 100, 400, 1, 300, (val) -> {
- setValue(val.intValue());
- });
- private static GuiElementTextField textField = new GuiElementTextField("", 48, 20, GuiElementTextField.NUM_ONLY);
- private static boolean textFieldClicked = false;
-
- public static boolean shouldReplace() {
- if(true) return false;
- //if(!NotEnoughUpdates.INSTANCE.config.auctionHouseSearch.enableSearchOverlay) return false;
-
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiEditSign)) return false;
-
- TileEntitySign tes = ((GuiEditSign)Minecraft.getMinecraft().currentScreen).tileSign;
-
- if(tes == null) return false;
- if(tes.getPos().getY() != 0) return false;
- if(!tes.signText[1].getUnformattedText().equals("^^^^^^")) return false;
- if(!tes.signText[2].getUnformattedText().equals("Set your")) return false;
- if(!tes.signText[3].getUnformattedText().equals("speed cap!")) return false;
-
- return true;
- }
-
- public static void render() {
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- int width = scaledResolution.getScaledWidth();
- int height = scaledResolution.getScaledHeight();
- int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
- int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
-
- Utils.drawGradientRect(0, 0, width, height, -1072689136, -804253680);
-
- int topY = height/4;
-
- //Gui.drawRect(width/2-100, topY, width/2+48, topY+20, 0xffffffff);
- Gui.drawRect(width/2+52, topY, width/2+100, topY+20, 0xffffffff);
-
- textField.render(width/2+52, topY);
-
- slider.x = width/2-100;
- slider.y = topY;
- slider.render();
-
- int numIcons = 3;
- int iconsLeft = width/2 - (numIcons*25 - 5)/2 ;
-
- for(int i=0; i<numIcons; i++) {
- Gui.drawRect(iconsLeft+i*25, topY+25, iconsLeft+i*25+20, topY+45, selectedIndex == i ? 0xff0000ff : 0xff808080);
- Utils.drawItemStack(new ItemStack(Items.carrot), iconsLeft+i*25+2, topY+25+2);
- Utils.drawStringCentered(""+currentSpeeds.get(i), Minecraft.getMinecraft().fontRendererObj, iconsLeft+i*25+10, topY+52, true, 0xffffffff);
- //Minecraft.getMinecraft().fontRendererObj.drawString("\u2710", iconsLeft+i*25+15, topY+40, 0xffffff, false);
- }
-
- //Minecraft.getMinecraft().fontRendererObj.drawString("Hello!", 100, 100, 0xffffff);
- }
-
- public static void close() {
-
- }
-
- public static void keyEvent() {
- if(Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
- Minecraft.getMinecraft().displayGuiScreen(null);
- } else {
- slider.keyboardInput();
-
- if(Keyboard.getEventKeyState()) {
- textField.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey());
- if(textField.getText().length() > 5) textField.setText(textField.getText().substring(0, 5));
-
- try {
- setCurrentSpeed(Integer.parseInt(textField.getText().trim()));
- slider.setValue(getCurrentSpeed());
- textField.setCustomBorderColour(0xfeffffff);
- } catch(NumberFormatException ignored) {
- textField.setCustomBorderColour(0xffff0000);
- }
- }
- }
- }
-
- private static int getCurrentSpeed() {
- return currentSpeeds.get(selectedIndex);
- }
-
- private static void setCurrentSpeed(int speed) {
- currentSpeeds.put(selectedIndex, speed);
- }
-
- public static void setValue(int value) {
- setCurrentSpeed(value);
- textField.setText(""+getCurrentSpeed());
- }
-
- public static void mouseEvent() {
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- int width = scaledResolution.getScaledWidth();
- int height = scaledResolution.getScaledHeight();
- int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
- int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
-
- int topY = height/4;
-
- slider.mouseInput(mouseX, mouseY);
-
- if(!Mouse.getEventButtonState() && Mouse.getEventButton() == -1 && textFieldClicked) {
- textField.mouseClickMove(mouseX-2, topY+10, 0, 0);
- }
-
- if(Mouse.getEventButton() != -1) {
- textFieldClicked = false;
- }
-
- if(mouseX > width/2+52 && mouseX < width/2+100 && mouseY > topY && mouseY < topY+20) {
- if(Mouse.getEventButtonState()) {
- textField.mouseClicked(mouseX, mouseY, Mouse.getEventButton());
- textFieldClicked = true;
- }
- }
-
- if(Mouse.getEventButtonState()) {
- int numIcons = 3;
- int iconsLeft = width/2 - (numIcons*25 - 5)/2 ;
-
- for(int i=0; i<numIcons; i++) {
- if(mouseX > iconsLeft+i*25 && mouseX < iconsLeft+i*25+20 && mouseY > topY+25 && mouseY < topY+45) {
- if(i != selectedIndex) {
- selectedIndex = i;
- slider.setValue(getCurrentSpeed());
- textField.setText(""+getCurrentSpeed());
- }
- return;
- }
- //Minecraft.getMinecraft().fontRendererObj.drawString("\u2710", iconsLeft+i*25+15, topY+40, 0xffffff, false);
- }
- }
- }
-
+ private static int selectedIndex = 0;
+
+ private static final HashMap<Integer, Integer> currentSpeeds = new HashMap<>();
+ private static final GuiElementSlider slider =
+ new GuiElementSlider(0, 0, 145, 100, 400, 1, 300, (val) -> setValue(val.intValue()));
+ private static final GuiElementTextField textField =
+ new GuiElementTextField("", 48, 20, GuiElementTextField.NUM_ONLY);
+ private static boolean textFieldClicked = false;
+
+ public static boolean shouldReplace() {
+ if (true) return false;
+ //if(!NotEnoughUpdates.INSTANCE.config.auctionHouseSearch.enableSearchOverlay) return false;
+
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiEditSign)) return false;
+
+ TileEntitySign tes = ((GuiEditSign) Minecraft.getMinecraft().currentScreen).tileSign;
+
+ if (tes == null) return false;
+ if (tes.getPos().getY() != 0) return false;
+ if (!tes.signText[1].getUnformattedText().equals("^^^^^^")) return false;
+ if (!tes.signText[2].getUnformattedText().equals("Set your")) return false;
+ return tes.signText[3].getUnformattedText().equals("speed cap!");
+ }
+
+ public static void render() {
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ int width = scaledResolution.getScaledWidth();
+ int height = scaledResolution.getScaledHeight();
+ int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
+ int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
+
+ Utils.drawGradientRect(0, 0, width, height, -1072689136, -804253680);
+
+ int topY = height / 4;
+
+ //Gui.drawRect(width/2-100, topY, width/2+48, topY+20, 0xffffffff);
+ Gui.drawRect(width / 2 + 52, topY, width / 2 + 100, topY + 20, 0xffffffff);
+
+ textField.render(width / 2 + 52, topY);
+
+ slider.x = width / 2 - 100;
+ slider.y = topY;
+ slider.render();
+
+ int numIcons = 3;
+ int iconsLeft = width / 2 - (numIcons * 25 - 5) / 2;
+
+ for (int i = 0; i < numIcons; i++) {
+ Gui.drawRect(
+ iconsLeft + i * 25,
+ topY + 25,
+ iconsLeft + i * 25 + 20,
+ topY + 45,
+ selectedIndex == i ? 0xff0000ff : 0xff808080
+ );
+ Utils.drawItemStack(new ItemStack(Items.carrot), iconsLeft + i * 25 + 2, topY + 25 + 2);
+ Utils.drawStringCentered(
+ "" + currentSpeeds.get(i),
+ Minecraft.getMinecraft().fontRendererObj,
+ iconsLeft + i * 25 + 10,
+ topY + 52,
+ true,
+ 0xffffffff
+ );
+ //Minecraft.getMinecraft().fontRendererObj.drawString("\u2710", iconsLeft+i*25+15, topY+40, 0xffffff, false);
+ }
+
+ //Minecraft.getMinecraft().fontRendererObj.drawString("Hello!", 100, 100, 0xffffff);
+ }
+
+ public static void close() {
+
+ }
+
+ public static void keyEvent() {
+ if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
+ Minecraft.getMinecraft().displayGuiScreen(null);
+ } else {
+ slider.keyboardInput();
+
+ if (Keyboard.getEventKeyState()) {
+ textField.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey());
+ if (textField.getText().length() > 5) textField.setText(textField.getText().substring(0, 5));
+
+ try {
+ setCurrentSpeed(Integer.parseInt(textField.getText().trim()));
+ slider.setValue(getCurrentSpeed());
+ textField.setCustomBorderColour(0xfeffffff);
+ } catch (NumberFormatException ignored) {
+ textField.setCustomBorderColour(0xffff0000);
+ }
+ }
+ }
+ }
+
+ private static int getCurrentSpeed() {
+ return currentSpeeds.get(selectedIndex);
+ }
+
+ private static void setCurrentSpeed(int speed) {
+ currentSpeeds.put(selectedIndex, speed);
+ }
+
+ public static void setValue(int value) {
+ setCurrentSpeed(value);
+ textField.setText("" + getCurrentSpeed());
+ }
+
+ public static void mouseEvent() {
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ int width = scaledResolution.getScaledWidth();
+ int height = scaledResolution.getScaledHeight();
+ int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
+ int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
+
+ int topY = height / 4;
+
+ slider.mouseInput(mouseX, mouseY);
+
+ if (!Mouse.getEventButtonState() && Mouse.getEventButton() == -1 && textFieldClicked) {
+ textField.mouseClickMove(mouseX - 2, topY + 10, 0, 0);
+ }
+
+ if (Mouse.getEventButton() != -1) {
+ textFieldClicked = false;
+ }
+
+ if (mouseX > width / 2 + 52 && mouseX < width / 2 + 100 && mouseY > topY && mouseY < topY + 20) {
+ if (Mouse.getEventButtonState()) {
+ textField.mouseClicked(mouseX, mouseY, Mouse.getEventButton());
+ textFieldClicked = true;
+ }
+ }
+
+ if (Mouse.getEventButtonState()) {
+ int numIcons = 3;
+ int iconsLeft = width / 2 - (numIcons * 25 - 5) / 2;
+
+ for (int i = 0; i < numIcons; i++) {
+ if (mouseX > iconsLeft + i * 25 && mouseX < iconsLeft + i * 25 + 20 && mouseY > topY + 25 &&
+ mouseY < topY + 45) {
+ if (i != selectedIndex) {
+ selectedIndex = i;
+ slider.setValue(getCurrentSpeed());
+ textField.setText("" + getCurrentSpeed());
+ }
+ return;
+ }
+ //Minecraft.getMinecraft().fontRendererObj.drawString("\u2710", iconsLeft+i*25+15, topY+40, 0xffffff, false);
+ }
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/SlayerOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/SlayerOverlay.java
new file mode 100644
index 00000000..89fce0f2
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/SlayerOverlay.java
@@ -0,0 +1,236 @@
+package io.github.moulberry.notenoughupdates.overlays;
+
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.core.config.Position;
+import io.github.moulberry.notenoughupdates.util.SBInfo;
+import io.github.moulberry.notenoughupdates.util.Utils;
+import net.minecraft.client.Minecraft;
+import net.minecraft.util.EnumChatFormatting;
+
+import java.text.NumberFormat;
+import java.util.*;
+import java.util.function.Supplier;
+
+public class SlayerOverlay extends TextOverlay {
+ public static boolean slayerQuest;
+ public static String RNGMeter = "?";
+ public static boolean isSlain = false;
+ public static String slayerLVL = "-1";
+ public static String slayerXp = "0";
+ public static long unloadOverlayTimer = -1;
+ public static long timeSinceLastBoss = 0;
+ public static long timeSinceLastBoss2 = 0;
+ public static int slayerTier = 0;
+
+ private static String slayerEXP = "0";
+ private static int slayerIntXP;
+ private static int untilNextSlayerLevel;
+ private static int xpToLevelUp;
+ private static boolean useSmallXpNext = true;
+ private static long agvSlayerTime = 0;
+ private static boolean isSlayerNine = false;
+ private static int xpPerBoss = 0;
+ private static int bossesUntilNextLevel = 0;
+ private final HashSet<String> revenantLocations = new HashSet<>(Arrays.asList("Graveyard", "Coal Mine"));
+ private boolean shouldUpdate = true;
+
+ public SlayerOverlay(
+ Position position,
+ Supplier<List<String>> dummyStrings,
+ Supplier<TextOverlayStyle> styleSupplier
+ ) {
+ super(position, dummyStrings, styleSupplier);
+ }
+
+ private boolean shouldUpdate() {
+ if (!NotEnoughUpdates.INSTANCE.config.slayerOverlay.onlyShowWhenRelevant || SBInfo.getInstance().stranded)
+ return true;
+ //Ignore if on stranded
+ String scoreboardLocation = SBInfo.getInstance().location;
+ String locrawLocation = SBInfo.getInstance().getLocation();
+ //In case something is broken still show the overlay
+ if (locrawLocation == null || scoreboardLocation == null) return true;
+ switch (SBInfo.getInstance().slayer) {
+ case "Tarantula":
+ if (!locrawLocation.equals("combat_1")) return false;
+ break;
+ case "Revenant":
+ if ((!locrawLocation.equals("hub") || !revenantLocations.contains(scoreboardLocation)) &&
+ !locrawLocation.equals("crystal_hollows")) return false;
+ break;
+ case "Sven":
+ if ((!locrawLocation.equals("hub") || !scoreboardLocation.equals("Ruins")) &&
+ (!locrawLocation.equals("foraging_1") || !scoreboardLocation.equals("Howling Cave")))
+ return false;
+ break;
+ case "Enderman":
+ if (!locrawLocation.equals("combat_3")) return false;
+ break;
+ default:
+ //A new slayer would need an update (see SBInfo)
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public void update() {
+ shouldUpdate = shouldUpdate();
+ if (!NotEnoughUpdates.INSTANCE.config.slayerOverlay.slayerOverlay || !shouldUpdate) {
+ overlayStrings = null;
+ return;
+ }
+
+ if (Minecraft.getMinecraft().thePlayer == null) return;
+
+ if (!slayerQuest) {
+ slayerTier = 0;
+ }
+
+ if (slayerXp.equals("maxed")) {
+ isSlayerNine = true;
+ } else if (!slayerXp.equals("0")) {
+ slayerEXP = slayerXp.replace(",", "");
+ slayerIntXP = Integer.parseInt(slayerEXP);
+ isSlayerNine = false;
+ } else {
+ slayerIntXP = 0;
+ isSlayerNine = false;
+ }
+ //System.out.println(slayerEXP);
+ if (SBInfo.getInstance().slayer.equals("Tarantula") || SBInfo.getInstance().slayer.equals("Revenant")) {
+ useSmallXpNext = true;
+ } else if (SBInfo.getInstance().slayer.equals("Sven") || SBInfo.getInstance().slayer.equals("Enderman")) {
+ useSmallXpNext = false;
+ }
+ switch (slayerLVL) {
+ case "9":
+ xpToLevelUp = 2000000;
+ break;
+ case "8":
+ xpToLevelUp = 1000000;
+ break;
+ case "7":
+ xpToLevelUp = 400000;
+ break;
+ case "6":
+ xpToLevelUp = 100000;
+ break;
+ case "5":
+ xpToLevelUp = 20000;
+ break;
+ case "4":
+ xpToLevelUp = 5000;
+ break;
+ case "3":
+ if (useSmallXpNext) {
+ xpToLevelUp = 1000;
+ } else {
+ xpToLevelUp = 1500;
+ }
+ break;
+ case "2":
+ if (useSmallXpNext) {
+ xpToLevelUp = 200;
+ } else {
+ xpToLevelUp = 250;
+ }
+ break;
+ case "1":
+ if (SBInfo.getInstance().slayer.equals("Revenant")) {
+ xpToLevelUp = 15;
+ } else if (SBInfo.getInstance().slayer.equals("Tarantula")) {
+ xpToLevelUp = 25;
+ } else {
+ xpToLevelUp = 30;
+ }
+ break;
+ case "0":
+ if (useSmallXpNext) {
+ xpToLevelUp = 5;
+ } else {
+ xpToLevelUp = 10;
+ }
+ break;
+ }
+ if (slayerTier == 5) {
+ xpPerBoss = 1500;
+ } else if (slayerTier == 4) {
+ xpPerBoss = 500;
+ } else if (slayerTier == 3) {
+ xpPerBoss = 100;
+ } else if (slayerTier == 2) {
+ xpPerBoss = 25;
+ } else if (slayerTier == 1) {
+ xpPerBoss = 5;
+ } else {
+ xpPerBoss = 0;
+ }
+ untilNextSlayerLevel = xpToLevelUp - slayerIntXP;
+ if (xpPerBoss != 0 && untilNextSlayerLevel != 0 && xpToLevelUp != 0) {
+ bossesUntilNextLevel = (xpToLevelUp - untilNextSlayerLevel) / xpPerBoss;
+ } else {
+ bossesUntilNextLevel = 0;
+ }
+ agvSlayerTime = (timeSinceLastBoss + timeSinceLastBoss2) / 2;
+ }
+
+ @Override
+ public void updateFrequent() {
+ super.updateFrequent();
+
+ if (!slayerQuest || !NotEnoughUpdates.INSTANCE.config.slayerOverlay.slayerOverlay || !shouldUpdate) {
+ overlayStrings = null;
+ } else {
+ HashMap<Integer, String> lineMap = new HashMap<>();
+
+ NumberFormat format = NumberFormat.getIntegerInstance();
+ //System.out.println(SBInfo.getInstance().isSlain);
+ overlayStrings = new ArrayList<>();
+ lineMap.put(
+ 0,
+ EnumChatFormatting.YELLOW + "Slayer: " + EnumChatFormatting.DARK_RED + SBInfo.getInstance().slayer +
+ EnumChatFormatting.GREEN + (isSlain ? " (Killed) " : " ")/* + slayerTier*/
+ );
+
+ if (!RNGMeter.equals("?")) {
+ lineMap.put(1, EnumChatFormatting.YELLOW + "RNG Meter: " + EnumChatFormatting.DARK_PURPLE + RNGMeter);
+ }
+
+ if (!slayerLVL.equals("-1")) {
+ lineMap.put(2, EnumChatFormatting.YELLOW + "Lvl: " + EnumChatFormatting.LIGHT_PURPLE + slayerLVL);
+ }
+
+ if (timeSinceLastBoss > 0) {
+ lineMap.put(
+ 3,
+ EnumChatFormatting.YELLOW + "Kill time: " + EnumChatFormatting.RED +
+ Utils.prettyTime((System.currentTimeMillis() - timeSinceLastBoss))
+ );
+ }
+
+ if (slayerIntXP > 0) {
+ lineMap.put(4, EnumChatFormatting.YELLOW + "XP: " + EnumChatFormatting.LIGHT_PURPLE
+ + format.format(untilNextSlayerLevel) + "/" + format.format(xpToLevelUp));
+ } else if (isSlayerNine) {
+ lineMap.put(4, EnumChatFormatting.YELLOW + "XP: " + EnumChatFormatting.LIGHT_PURPLE + "MAXED");
+ }
+
+ if (xpPerBoss != 0 && slayerIntXP > 0) {
+ lineMap.put(5, EnumChatFormatting.YELLOW + "Bosses till next Lvl: " + EnumChatFormatting.LIGHT_PURPLE +
+ (bossesUntilNextLevel > 2000 ? "?" : bossesUntilNextLevel));
+ }
+
+ if (timeSinceLastBoss > 0 && timeSinceLastBoss2 > 0) {
+ lineMap.put(6, EnumChatFormatting.YELLOW + "Average kill time: " + EnumChatFormatting.RED +
+ Utils.prettyTime((System.currentTimeMillis() - agvSlayerTime)));
+ }
+ for (int strIndex : NotEnoughUpdates.INSTANCE.config.slayerOverlay.slayerText) {
+ if (lineMap.get(strIndex) != null) {
+ overlayStrings.add(lineMap.get(strIndex));
+ }
+ }
+ if (overlayStrings != null && overlayStrings.isEmpty()) overlayStrings = null;
+ }
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlay.java
index c3f4ba99..5fe066f2 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlay.java
@@ -11,166 +11,173 @@ import org.lwjgl.opengl.GL14;
import org.lwjgl.util.vector.Vector2f;
import java.awt.*;
-import java.util.ArrayList;
import java.util.List;
import java.util.function.Supplier;
public abstract class TextOverlay {
-
- private Position position;
- protected Supplier<TextOverlayStyle> styleSupplier;
- public int overlayWidth = -1;
- public int overlayHeight = -1;
- public List<String> overlayStrings = null;
- private Supplier<List<String>> dummyStrings;
-
- public boolean shouldUpdateFrequent = false;
-
- private static final int PADDING_X = 5;
- private static final int PADDING_Y = 5;
-
- public TextOverlay(Position position, Supplier<List<String>> dummyStrings, Supplier<TextOverlayStyle> styleSupplier) {
- this.position = position;
- this.styleSupplier = styleSupplier;
- if(dummyStrings == null) {
- this.dummyStrings = () -> null;
- } else {
- this.dummyStrings = dummyStrings;
- }
- }
-
- public Vector2f getDummySize() {
- List<String> dummyStrings = this.dummyStrings.get();
-
- if(dummyStrings != null) {
- return getSize(dummyStrings);
- }
- return new Vector2f(100, 50);
- }
-
- public void tick() {
- update();
- }
-
- public void updateFrequent() {}
- public abstract void update();
-
- public void renderDummy() {
- List<String> dummyStrings = this.dummyStrings.get();
- render(dummyStrings, true);
- }
-
- public void render() {
- if(shouldUpdateFrequent) {
- updateFrequent();
- shouldUpdateFrequent = false;
- }
- render(overlayStrings, false);
- }
-
- protected Vector2f getSize(List<String> strings) {
- int overlayHeight = 0;
- int overlayWidth = 0;
- for(String s : strings) {
- if(s == null) {
- overlayHeight += 3;
- continue;
- }
- for(String s2 : s.split("\n")) {
- int sWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(s2);
- if(sWidth > overlayWidth) {
- overlayWidth = sWidth;
- }
- overlayHeight += 10;
- }
- }
- overlayHeight -= 2;
-
- int paddingX = 0;
- int paddingY = 0;
- if(styleSupplier.get() == TextOverlayStyle.BACKGROUND) {
- paddingX = PADDING_X;
- paddingY = PADDING_Y;
- }
- return new Vector2f(overlayWidth+paddingX*2, overlayHeight+paddingY*2);
- }
-
- protected Vector2f getTextOffset() {
- return new Vector2f();
- }
-
- protected Vector2f getPosition(int overlayWidth, int overlayHeight) {
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
-
- int x = position.getAbsX(scaledResolution, overlayWidth);
- int y = position.getAbsY(scaledResolution, overlayHeight);
-
- return new Vector2f(x, y);
- }
-
- protected void renderLine(String line, Vector2f position, boolean dummy) {}
-
- private void render(List<String> strings, boolean dummy) {
- if(strings == null) return;
-
- Vector2f size = getSize(strings);
- overlayHeight = (int)size.y;
- overlayWidth = (int)size.x;
-
- Vector2f position = getPosition(overlayWidth, overlayHeight);
- int x = (int)position.x;
- int y = (int)position.y;
-
- TextOverlayStyle style = styleSupplier.get();
-
- if(style == TextOverlayStyle.BACKGROUND) Gui.drawRect(x, y, x+overlayWidth, y+overlayHeight, 0x80000000);
-
- GlStateManager.enableBlend();
- GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
- GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
-
- int paddingX = 0;
- int paddingY = 0;
- if(styleSupplier.get() == TextOverlayStyle.BACKGROUND) {
- paddingX = PADDING_X;
- paddingY = PADDING_Y;
- }
-
- Vector2f textOffset = getTextOffset();
- paddingX += (int) textOffset.x;
- paddingY += (int) textOffset.y;
-
- int yOff = 0;
- for(String s : strings) {
- if(s == null) {
- yOff += 3;
- } else {
- for(String s2 : s.split("\n")) {
- Vector2f pos = new Vector2f(x+paddingX, y+paddingY+yOff);
- renderLine(s2, pos, dummy);
-
- int xPad = (int)pos.x;
- int yPad = (int)pos.y;
-
- if(style == TextOverlayStyle.FULL_SHADOW) {
- String clean = Utils.cleanColourNotModifiers(s2);
- for(int xO=-2; xO<=2; xO++) {
- for(int yO=-2; yO<=2; yO++) {
- if(Math.abs(xO) != Math.abs(yO)) {
- Minecraft.getMinecraft().fontRendererObj.drawString(clean,
- xPad+xO/2f, yPad+yO/2f,
- new Color(0, 0, 0, 200/Math.max(Math.abs(xO), Math.abs(yO))).getRGB(), false);
- }
- }
- }
- }
- Minecraft.getMinecraft().fontRendererObj.drawString(s2,
- xPad, yPad, 0xffffff, style == TextOverlayStyle.MC_SHADOW);
-
- yOff += 10;
- }
- }
- }
- }
-
+ private final Position position;
+ protected Supplier<TextOverlayStyle> styleSupplier;
+ public int overlayWidth = -1;
+ public int overlayHeight = -1;
+ public List<String> overlayStrings = null;
+ private final Supplier<List<String>> dummyStrings;
+
+ public boolean shouldUpdateFrequent = false;
+
+ private static final int PADDING_X = 5;
+ private static final int PADDING_Y = 5;
+
+ public TextOverlay(Position position, Supplier<List<String>> dummyStrings, Supplier<TextOverlayStyle> styleSupplier) {
+ this.position = position;
+ this.styleSupplier = styleSupplier;
+ if (dummyStrings == null) {
+ this.dummyStrings = () -> null;
+ } else {
+ this.dummyStrings = dummyStrings;
+ }
+ }
+
+ public Vector2f getDummySize() {
+ List<String> dummyStrings = this.dummyStrings.get();
+
+ if (dummyStrings != null) {
+ return getSize(dummyStrings);
+ }
+ return new Vector2f(100, 50);
+ }
+
+ public void tick() {
+ update();
+ }
+
+ public void updateFrequent() {
+ }
+
+ public abstract void update();
+
+ public void renderDummy() {
+ List<String> dummyStrings = this.dummyStrings.get();
+ render(dummyStrings, true);
+ }
+
+ public void render() {
+ if (shouldUpdateFrequent) {
+ updateFrequent();
+ shouldUpdateFrequent = false;
+ }
+ render(overlayStrings, false);
+ }
+
+ protected Vector2f getSize(List<String> strings) {
+ int overlayHeight = 0;
+ int overlayWidth = 0;
+ for (String s : strings) {
+ if (s == null) {
+ overlayHeight += 3;
+ continue;
+ }
+ for (String s2 : s.split("\n")) {
+ int sWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(s2);
+ if (sWidth > overlayWidth) {
+ overlayWidth = sWidth;
+ }
+ overlayHeight += 10;
+ }
+ }
+ overlayHeight -= 2;
+
+ int paddingX = 0;
+ int paddingY = 0;
+ if (styleSupplier.get() == TextOverlayStyle.BACKGROUND) {
+ paddingX = PADDING_X;
+ paddingY = PADDING_Y;
+ }
+ return new Vector2f(overlayWidth + paddingX * 2, overlayHeight + paddingY * 2);
+ }
+
+ protected Vector2f getTextOffset() {
+ return new Vector2f();
+ }
+
+ protected Vector2f getPosition(int overlayWidth, int overlayHeight) {
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+
+ int x = position.getAbsX(scaledResolution, overlayWidth);
+ int y = position.getAbsY(scaledResolution, overlayHeight);
+
+ return new Vector2f(x, y);
+ }
+
+ protected void renderLine(String line, Vector2f position, boolean dummy) {
+ }
+
+ private void render(List<String> strings, boolean dummy) {
+ if (strings == null) return;
+
+ Vector2f size = getSize(strings);
+ overlayHeight = (int) size.y;
+ overlayWidth = (int) size.x;
+
+ Vector2f position = getPosition(overlayWidth, overlayHeight);
+ int x = (int) position.x;
+ int y = (int) position.y;
+
+ TextOverlayStyle style = styleSupplier.get();
+
+ if (style == TextOverlayStyle.BACKGROUND) Gui.drawRect(x, y, x + overlayWidth, y + overlayHeight, 0x80000000);
+
+ GlStateManager.enableBlend();
+ GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ GlStateManager.tryBlendFuncSeparate(
+ GL11.GL_SRC_ALPHA,
+ GL11.GL_ONE_MINUS_SRC_ALPHA,
+ GL11.GL_ONE,
+ GL11.GL_ONE_MINUS_SRC_ALPHA
+ );
+
+ int paddingX = 0;
+ int paddingY = 0;
+ if (styleSupplier.get() == TextOverlayStyle.BACKGROUND) {
+ paddingX = PADDING_X;
+ paddingY = PADDING_Y;
+ }
+
+ Vector2f textOffset = getTextOffset();
+ paddingX += (int) textOffset.x;
+ paddingY += (int) textOffset.y;
+
+ int yOff = 0;
+ for (String s : strings) {
+ if (s == null) {
+ yOff += 3;
+ } else {
+ for (String s2 : s.split("\n")) {
+ Vector2f pos = new Vector2f(x + paddingX, y + paddingY + yOff);
+ renderLine(s2, pos, dummy);
+
+ int xPad = (int) pos.x;
+ int yPad = (int) pos.y;
+
+ if (style == TextOverlayStyle.FULL_SHADOW) {
+ String clean = Utils.cleanColourNotModifiers(s2);
+ for (int xO = -2; xO <= 2; xO++) {
+ for (int yO = -2; yO <= 2; yO++) {
+ if (Math.abs(xO) != Math.abs(yO)) {
+ Minecraft.getMinecraft().fontRendererObj.drawString(clean,
+ xPad + xO / 2f, yPad + yO / 2f,
+ new Color(0, 0, 0, 200 / Math.max(Math.abs(xO), Math.abs(yO))).getRGB(), false
+ );
+ }
+ }
+ }
+ }
+ Minecraft.getMinecraft().fontRendererObj.drawString(s2,
+ xPad, yPad, 0xffffff, style == TextOverlayStyle.MC_SHADOW
+ );
+
+ yOff += 10;
+ }
+ }
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlayStyle.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlayStyle.java
index b9b314d4..4a3a2b73 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlayStyle.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlayStyle.java
@@ -1,10 +1,8 @@
package io.github.moulberry.notenoughupdates.overlays;
public enum TextOverlayStyle {
-
- BACKGROUND,
- NO_SHADOW,
- MC_SHADOW,
- FULL_SHADOW
-
+ BACKGROUND,
+ NO_SHADOW,
+ MC_SHADOW,
+ FULL_SHADOW
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java
index 65c7d3f6..ede30448 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java
@@ -21,459 +21,760 @@ import org.lwjgl.util.vector.Vector2f;
import java.time.ZoneId;
import java.time.ZonedDateTime;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
import java.util.function.Supplier;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import static net.minecraft.util.EnumChatFormatting.*;
+import static net.minecraft.util.EnumChatFormatting.DARK_AQUA;
public class TimersOverlay extends TextOverlay {
-
- private static final Pattern PATTERN_ACTIVE_EFFECTS = Pattern.compile("\u00a7r\u00a7r\u00a77You have a \u00a7r\u00a7cGod Potion \u00a7r\u00a77active! \u00a7r\u00a7d([0-9]*?:?[0-9]*?:?[0-9]*)\u00a7r");
-
- public TimersOverlay(Position position, Supplier<List<String>> dummyStrings, Supplier<TextOverlayStyle> styleSupplier) {
- super(position, dummyStrings, styleSupplier);
- }
-
- private static final Pattern CAKE_PATTERN = Pattern.compile("\u00a7r\u00a7d\u00a7lYum! \u00a7r\u00a7eYou gain .+ \u00a7r\u00a7efor \u00a7r\u00a7a48 \u00a7r\u00a7ehours!\u00a7r");
- private static final Pattern PUZZLER_PATTERN = Pattern.compile("\u00a7r\u00a7dPuzzler\u00a7r\u00a76 gave you .+ \u00a7r\u00a76for solving the puzzle!\u00a7r");
- private static final Pattern FETCHUR_PATTERN = Pattern.compile("\u00a7e\\[NPC] Fetchur\u00a7f: \u00a7rthanks thats probably what i needed\u00a7r");
- private static final Pattern FETCHUR2_PATTERN = Pattern.compile("\u00a7e\\[NPC] Fetchur\u00a7f: \u00a7rcome back another time, maybe tmrw\u00a7r");
-
-
- private boolean hideGodpot = false;
-
- @SubscribeEvent(priority = EventPriority.HIGHEST, receiveCanceled = true)
- public void onChatMessageReceived(ClientChatReceivedEvent event) {
- NEUConfig.HiddenProfileSpecific hidden = NotEnoughUpdates.INSTANCE.config.getProfileSpecific();
- if(hidden == null) return;
-
- if(event.type == 0) {
- long currentTime = System.currentTimeMillis();
-
- Matcher cakeMatcher = CAKE_PATTERN.matcher(event.message.getFormattedText());
- if(cakeMatcher.matches()) {
- hidden.firstCakeAte = currentTime;
- return;
- }
-
- Matcher puzzlerMatcher = PUZZLER_PATTERN.matcher(event.message.getFormattedText());
- if(puzzlerMatcher.matches()) {
- hidden.puzzlerCompleted = currentTime;
- return;
- }
-
- Matcher fetchurMatcher = FETCHUR_PATTERN.matcher(event.message.getFormattedText());
- if(fetchurMatcher.matches()) {
- hidden.fetchurCompleted = currentTime;
- return;
- }
-
- Matcher fetchur2Matcher = FETCHUR2_PATTERN.matcher(event.message.getFormattedText());
- if(fetchur2Matcher.matches()) {
- hidden.fetchurCompleted = currentTime;
- return;
- }
-
-
- }
- }
-
- @Override
- protected Vector2f getSize(List<String> strings) {
- if(NotEnoughUpdates.INSTANCE.config.miscOverlays.todoIcons)
- return super.getSize(strings).translate(12, 0);
- return super.getSize(strings);
- }
-
- private static final ItemStack CAKES_ICON = new ItemStack(Items.cake);
- private static final ItemStack PUZZLER_ICON = new ItemStack(Items.book);
- private static ItemStack[] FETCHUR_ICONS = null;
- private static final ItemStack COMMISSIONS_ICON = new ItemStack(Items.iron_pickaxe);
- private static final ItemStack EXPERIMENTS_ICON = new ItemStack(Items.enchanted_book);
- private static final ItemStack COOKIE_ICON = new ItemStack(Items.cookie);
-
- @Override
- protected void renderLine(String line, Vector2f position, boolean dummy) {
- if(!NotEnoughUpdates.INSTANCE.config.miscOverlays.todoIcons) {
- return;
- }
- GlStateManager.enableDepth();
-
- ItemStack icon = null;
-
- String clean = Utils.cleanColour(line);
- String beforeColon = clean.split(":")[0];
- switch(beforeColon) {
- case "Cakes": icon = CAKES_ICON; break;
- case "Puzzler": icon = PUZZLER_ICON; break;
- case "Godpot": icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("GOD_POTION")); break;
- case "Fetchur": {
- if(FETCHUR_ICONS == null) {
- FETCHUR_ICONS = new ItemStack[] {
- new ItemStack(Blocks.wool, 50, 14),
- new ItemStack(Blocks.stained_glass, 20, 4),
- new ItemStack(Items.compass, 1, 0),
- new ItemStack(Items.prismarine_crystals, 20, 0),
- new ItemStack(Items.fireworks, 1, 0),
- NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("CHEAP_COFFEE")),
- new ItemStack(Items.oak_door, 1, 0),
- new ItemStack(Items.rabbit_foot, 3, 0),
- NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("SUPERBOOM_TNT")),
- new ItemStack(Blocks.pumpkin, 1, 0),
- new ItemStack(Items.flint_and_steel, 1, 0),
- new ItemStack(Blocks.quartz_ore, 50, 0),
- new ItemStack(Items.ender_pearl, 16, 0)
- };
- }
- long currentTime = System.currentTimeMillis();
-
- ZonedDateTime currentTimeEST = ZonedDateTime.now(ZoneId.of("America/Atikokan"));
-
- long fetchurIndex = ((currentTimeEST.getDayOfMonth()+1) % 13)-1;
- //Added because disabled fetchur and enabled it again but it was showing the wrong item
- //Lets see if this stays correct
-
- if(fetchurIndex < 0) fetchurIndex += 13;
-
- icon = FETCHUR_ICONS[(int)fetchurIndex];
- break;
- }
- case "Commissions": icon = COMMISSIONS_ICON; break;
- case "Experiments": icon = EXPERIMENTS_ICON; break;
- case "Cookie Buff": icon = COOKIE_ICON; break;
- }
-
- if(icon != null) {
- GlStateManager.pushMatrix();
- GlStateManager.translate(position.x, position.y, 0);
- GlStateManager.scale(0.5f, 0.5f, 1f);
- Utils.drawItemStack(icon, 0, 0);
- GlStateManager.popMatrix();
-
- position.x += 12;
- }
-
- super.renderLine(line, position, dummy);
- }
-
- @Override
- public void update() {
-
-
- long currentTime = System.currentTimeMillis();
-
- NEUConfig.HiddenProfileSpecific hidden = NotEnoughUpdates.INSTANCE.config.getProfileSpecific();
- if (hidden == null) return;
-
- if (Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
- GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
- ContainerChest container = (ContainerChest) chest.inventorySlots;
- IInventory lower = container.getLowerChestInventory();
- String containerName = lower.getDisplayName().getUnformattedText();
-
- if (containerName.equals("Commissions") && lower.getSizeInventory() >= 18) {
- if (hidden.commissionsCompleted == 0) {
- hidden.commissionsCompleted = currentTime;
- }
- for (int i = 9; i < 18; i++) {
- ItemStack stack = lower.getStackInSlot(i);
- if (stack != null && stack.hasTagCompound()) {
- String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stack.getTagCompound());
- for (String line : lore) {
- if (line.contains("(Daily")) {
- hidden.commissionsCompleted = 0;
- break;
- }
- }
- }
- }
- } else if (containerName.equals("Experimentation Table") && lower.getSizeInventory() >= 36) {
- ItemStack stack = lower.getStackInSlot(31);
- if (stack != null) {
- if (stack.getItem() == Items.blaze_powder) {
- if (hidden.experimentsCompleted == 0) {
- hidden.experimentsCompleted = currentTime;
- return;
- }
- }
- }
- ItemStack stackSuperPairs = lower.getStackInSlot(22);
- if(stackSuperPairs != null && stackSuperPairs.getItem() == Items.skull && stackSuperPairs.getTagCompound() != null){
- String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stackSuperPairs.getTagCompound());
- String text = lore[lore.length-1];
- String cleanText = Utils.cleanColour(text);
- if(cleanText.equals("Experiments on cooldown!")){
- hidden.experimentsCompleted = currentTime;
- return;
- }
- }
- hidden.experimentsCompleted = 0;
- return;
- } else if(containerName.equals("Superpairs Rewards") && lower.getSizeInventory() >= 27){
- ItemStack stack = lower.getStackInSlot(13);
- if(stack != null && Utils.cleanColour(stack.getDisplayName()).equals("Superpairs")){
- hidden.experimentsCompleted = currentTime;
- }
- }
- }
-
- boolean foundCookieBuffText = false;
- boolean foundGodPotText = false;
- if (SBInfo.getInstance().getLocation() != null && !SBInfo.getInstance().getLocation().equals("dungeon") && SBInfo.getInstance().footer != null) {
- String formatted = SBInfo.getInstance().footer.getFormattedText();
- for (String line : formatted.split("\n")) {
- Matcher activeEffectsMatcher = PATTERN_ACTIVE_EFFECTS.matcher(line);
- if (activeEffectsMatcher.matches()) {
- foundGodPotText = true;
- String[] godpotRemaingTimeUnformatted = activeEffectsMatcher.group(1).split(":");
- long godPotDuration = 0;
- try {
- int i = 0;
- if (godpotRemaingTimeUnformatted.length == 4) {
- godPotDuration = godPotDuration + (long) Integer.parseInt(godpotRemaingTimeUnformatted[i]) * 24 * 60 * 60 * 1000;
- i++;
- }
- if (godpotRemaingTimeUnformatted.length >= 3) {
- godPotDuration = godPotDuration + (long) Integer.parseInt(godpotRemaingTimeUnformatted[i]) * 60 * 60 * 1000;
- i++;
- }
- if (godpotRemaingTimeUnformatted.length >= 2) {
- godPotDuration = godPotDuration + (long) Integer.parseInt(godpotRemaingTimeUnformatted[i]) * 60 * 1000;
- i++;
- }
- if (godpotRemaingTimeUnformatted.length >= 1) {
- godPotDuration = godPotDuration + (long) Integer.parseInt(godpotRemaingTimeUnformatted[i]) * 1000;
- }
- } catch (Exception ignored) {
- }
-
- hidden.godPotionDuration = godPotDuration;
-
- } else if (line.contains("\u00a7d\u00a7lCookie Buff")) {
- foundCookieBuffText = true;
- } else if (foundCookieBuffText) {
- String cleanNoSpace = line.replaceAll("(\u00a7.| )", "");
-
- hidden.cookieBuffRemaining = 0;
- StringBuilder number = new StringBuilder();
- for (int i = 0; i < cleanNoSpace.length(); i++) {
- char c = cleanNoSpace.charAt(i);
-
- if (c >= '0' && c <= '9') {
- number.append(c);
- } else {
- if (number.length() == 0) {
- hidden.cookieBuffRemaining = 0;
- break;
- }
- if ("ydhms".contains("" + c)) {
- try {
- long val = Integer.parseInt(number.toString());
- switch (c) {
- case 'y':
- hidden.cookieBuffRemaining += val * 365 * 24 * 60 * 60 * 1000;
- break;
- case 'd':
- hidden.cookieBuffRemaining += val * 24 * 60 * 60 * 1000;
- break;
- case 'h':
- hidden.cookieBuffRemaining += val * 60 * 60 * 1000;
- break;
- case 'm':
- hidden.cookieBuffRemaining += val * 60 * 1000;
- break;
- case 's':
- hidden.cookieBuffRemaining += val * 1000;
- break;
- }
- } catch (NumberFormatException e) {
- hidden.cookieBuffRemaining = 0;
- break;
- }
-
- number = new StringBuilder();
- } else {
- hidden.cookieBuffRemaining = 0;
- break;
- }
- }
- }
-
- break;
- }
- }
- }
-
- if (!foundGodPotText) {
- hidden.godPotionDuration = 0;
- }
-
-
- if (!NotEnoughUpdates.INSTANCE.config.miscOverlays.todoOverlay2) {
- overlayStrings = null;
- return;
- }
-
- HashMap<Integer, String> map = new HashMap<>();
-
- long cakeEnd = hidden.firstCakeAte + 1000 * 60 * 60 * 48 - currentTime;
-
- //Cake Display
- if (cakeEnd <= 0) {
- map.put(0, DARK_AQUA + "Cakes: " + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.goneColour] + "Inactive!");
- } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.cakesDisplay >= DISPLAYTYPE.VERYSOON.ordinal() &&
- cakeEnd < TimeEnums.HOUR.time) {
- map.put(0, DARK_AQUA + "Cakes: " + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.verySoonColour] + Utils.prettyTime(cakeEnd));
- } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.cakesDisplay >= DISPLAYTYPE.SOON.ordinal() &&
- cakeEnd < TimeEnums.HALFDAY.time) {
- map.put(0, DARK_AQUA + "Cakes: " + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.soonColour] + Utils.prettyTime(cakeEnd));
- } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.cakesDisplay >= DISPLAYTYPE.KINDASOON.ordinal() &&
- cakeEnd < TimeEnums.DAY.time) {
- map.put(0, DARK_AQUA + "Cakes: " + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.kindaSoonColour] + Utils.prettyTime(cakeEnd));
- } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.cakesDisplay >= DISPLAYTYPE.ALWAYS.ordinal()) {
- map.put(0, DARK_AQUA + "Cakes: " + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.defaultColour] + Utils.prettyTime(cakeEnd));
- }
-
- //CookieBuff Display
- if (hidden.cookieBuffRemaining <= 0) {
- map.put(1, DARK_AQUA + "Cookie Buff: " + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.goneColour] + "Inactive!");
- } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.cookieBuffDisplay >= DISPLAYTYPE.VERYSOON.ordinal() &&
- hidden.cookieBuffRemaining < TimeEnums.HOUR.time) {
- map.put(1, DARK_AQUA + "Cookie Buff: " + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.verySoonColour] + Utils.prettyTime(hidden.cookieBuffRemaining));
- } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.cookieBuffDisplay >= DISPLAYTYPE.SOON.ordinal() &&
- hidden.cookieBuffRemaining < TimeEnums.HALFDAY.time) {
- map.put(1, DARK_AQUA + "Cookie Buff: " + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.soonColour] + Utils.prettyTime(hidden.cookieBuffRemaining));
- } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.cookieBuffDisplay >= DISPLAYTYPE.KINDASOON.ordinal() &&
- hidden.cookieBuffRemaining < TimeEnums.DAY.time) {
- map.put(1, DARK_AQUA + "Cookie Buff: " + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.kindaSoonColour] + Utils.prettyTime(hidden.cookieBuffRemaining));
- } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.cookieBuffDisplay >= DISPLAYTYPE.ALWAYS.ordinal()) {
- map.put(1, DARK_AQUA + "Cookie Buff: " + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.defaultColour] + Utils.prettyTime(hidden.cookieBuffRemaining));
- }
-
-
- long godpotEnd = hidden.godPotionDuration;
- //Godpot Display
- //do not display in dungeons due to dungeons not having
- if (!(SBInfo.getInstance().getLocation() != null && SBInfo.getInstance().getLocation().equals("dungeon"))){
- if (hidden.godPotionDuration <= 0) {
- map.put(2, DARK_AQUA + "Godpot: " + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.goneColour] + "Inactive!");
- } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.godpotDisplay >= DISPLAYTYPE.VERYSOON.ordinal() &&
- hidden.godPotionDuration < TimeEnums.HOUR.time) {
- map.put(2, DARK_AQUA + "Godpot: " + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.verySoonColour] + Utils.prettyTime(hidden.godPotionDuration));
- } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.godpotDisplay >= DISPLAYTYPE.SOON.ordinal() &&
- hidden.godPotionDuration < TimeEnums.HALFDAY.time) {
- map.put(2, DARK_AQUA + "Godpot: " + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.soonColour] + Utils.prettyTime(hidden.godPotionDuration));
- } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.godpotDisplay >= DISPLAYTYPE.KINDASOON.ordinal() &&
- hidden.godPotionDuration < TimeEnums.DAY.time) {
- map.put(2, DARK_AQUA + "Godpot: " + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.kindaSoonColour] + Utils.prettyTime(hidden.godPotionDuration));
- } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.godpotDisplay >= DISPLAYTYPE.ALWAYS.ordinal()) {
- map.put(2, DARK_AQUA + "Godpot: " + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.defaultColour] + Utils.prettyTime(hidden.godPotionDuration));
- }
- }
-
- long puzzlerEnd = hidden.puzzlerCompleted + 1000*60*60*24 - currentTime;
- //Puzzler Display
- if((hidden.puzzlerCompleted + TimeEnums.DAY.time) < currentTime) {
- map.put(3, DARK_AQUA+"Puzzler: "+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.readyColour]+"Ready!");
- } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.puzzlerDisplay >= DISPLAYTYPE.VERYSOON.ordinal() &&
- (hidden.puzzlerCompleted + (TimeEnums.DAY.time - TimeEnums.HALFANHOUR.time)) < currentTime){
- map.put(3, DARK_AQUA+"Puzzler: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.verySoonColour]+Utils.prettyTime(puzzlerEnd));
- } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.puzzlerDisplay >= DISPLAYTYPE.SOON.ordinal() &&
- (hidden.puzzlerCompleted + (TimeEnums.DAY.time - TimeEnums.HOUR.time)) < currentTime){
- map.put(3, DARK_AQUA+"Puzzler: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.soonColour]+Utils.prettyTime(puzzlerEnd));
- } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.puzzlerDisplay >= DISPLAYTYPE.KINDASOON.ordinal() &&
- (hidden.puzzlerCompleted + (TimeEnums.DAY.time - (TimeEnums.HOUR.time)*3)) < currentTime) {
- map.put(3, DARK_AQUA+"Puzzler: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.kindaSoonColour]+Utils.prettyTime(puzzlerEnd));
- } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.puzzlerDisplay >= DISPLAYTYPE.ALWAYS.ordinal()){
- map.put(3, DARK_AQUA+"Puzzler: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.defaultColour]+Utils.prettyTime(puzzlerEnd));
- }
-
- long midnightReset = (currentTime-18000000)/86400000*86400000+18000000;
- long fetchurComplete = hidden.fetchurCompleted;
-
- long timeDiffMidnightNow = midnightReset + 86400000 - currentTime;
-
- //Fetchur Display
- if(fetchurComplete < midnightReset) {
- map.put(4, DARK_AQUA+"Fetchur: "+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.readyColour]+"Ready!");
- } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.fetchurDisplay >= DISPLAYTYPE.VERYSOON.ordinal() &&
- (fetchurComplete < (midnightReset-TimeEnums.HALFANHOUR.time))){
- map.put(4, DARK_AQUA+"Fetchur: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.verySoonColour]+Utils.prettyTime(timeDiffMidnightNow));
- } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.fetchurDisplay >= DISPLAYTYPE.SOON.ordinal() &&
- (fetchurComplete < (midnightReset-TimeEnums.HOUR.time))){
- map.put(4, DARK_AQUA+"Fetchur: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.soonColour]+Utils.prettyTime(timeDiffMidnightNow));
- } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.fetchurDisplay >= DISPLAYTYPE.KINDASOON.ordinal() &&
- (fetchurComplete < (midnightReset-(TimeEnums.HOUR.time*3)))) {
- map.put(4, DARK_AQUA+"Fetchur: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.kindaSoonColour]+Utils.prettyTime(timeDiffMidnightNow));
- } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.fetchurDisplay >= DISPLAYTYPE.ALWAYS.ordinal()){
- map.put(4, DARK_AQUA+"Fetchur: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.defaultColour]+Utils.prettyTime(timeDiffMidnightNow));
- }
-
- //Commissions Display
- if(hidden.commissionsCompleted < midnightReset) {
- map.put(5, DARK_AQUA+"Commissions: "+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.readyColour]+"Ready!");
- } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.commissionDisplay >= DISPLAYTYPE.VERYSOON.ordinal() &&
- (hidden.commissionsCompleted < (midnightReset-TimeEnums.HALFANHOUR.time))){
- map.put(5, DARK_AQUA+"Commissions: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.verySoonColour]+Utils.prettyTime(timeDiffMidnightNow));
- } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.commissionDisplay >= DISPLAYTYPE.SOON.ordinal() &&
- (hidden.commissionsCompleted < (midnightReset-TimeEnums.HOUR.time))){
- map.put(5, DARK_AQUA+"Commissions: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.soonColour]+Utils.prettyTime(timeDiffMidnightNow));
- } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.commissionDisplay >= DISPLAYTYPE.KINDASOON.ordinal() &&
- (hidden.commissionsCompleted < (midnightReset-(TimeEnums.HOUR.time*3)))) {
- map.put(5, DARK_AQUA+"Commissions: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.kindaSoonColour]+Utils.prettyTime(timeDiffMidnightNow));
- } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.commissionDisplay >= DISPLAYTYPE.ALWAYS.ordinal()){
- map.put(5, DARK_AQUA+"Commissions: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.defaultColour]+Utils.prettyTime(timeDiffMidnightNow));
- }
-
- //Experiment Display
- if(hidden.experimentsCompleted < midnightReset) {
- map.put(6, DARK_AQUA+"Experiments: "+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.readyColour]+"Ready!");
- } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.experimentationDisplay >= DISPLAYTYPE.VERYSOON.ordinal() &&
- (hidden.experimentsCompleted < (midnightReset-TimeEnums.HALFANHOUR.time))){
- map.put(6, DARK_AQUA+"Experiments: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.verySoonColour]+Utils.prettyTime(timeDiffMidnightNow));
- } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.experimentationDisplay >= DISPLAYTYPE.SOON.ordinal() &&
- (hidden.experimentsCompleted < (midnightReset-TimeEnums.HOUR.time))){
- map.put(6, DARK_AQUA+"Experiments: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.soonColour]+Utils.prettyTime(timeDiffMidnightNow));
- } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.experimentationDisplay >= DISPLAYTYPE.KINDASOON.ordinal() &&
- (hidden.experimentsCompleted < (midnightReset-(TimeEnums.HOUR.time*3)))) {
- map.put(6, DARK_AQUA+"Experiments: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.kindaSoonColour]+Utils.prettyTime(timeDiffMidnightNow));
- } else if(NotEnoughUpdates.INSTANCE.config.miscOverlays.experimentationDisplay >= DISPLAYTYPE.ALWAYS.ordinal()){
- map.put(6, DARK_AQUA+"Experiments: "+EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.defaultColour]+Utils.prettyTime(timeDiffMidnightNow));
- }
-
- overlayStrings = new ArrayList<>();
- for(int index : NotEnoughUpdates.INSTANCE.config.miscOverlays.todoText2) {
- if(map.containsKey(index)) {
- overlayStrings.add(map.get(index));
- }
- }
- if(overlayStrings.isEmpty()) overlayStrings = null;
- }
-
-
- private enum TimeEnums {
- DAY (86400000),
- HALFDAY(43200000),
- HOUR(3600000),
- HALFANHOUR(1800000);
-
- TimeEnums(long time) {
- this.time = time;
- }
-
- public final long time;
- }
-
- private enum DISPLAYTYPE {
- NOW,
- VERYSOON,
- SOON,
- KINDASOON,
- ALWAYS,
-
- }
-
+ private static final Pattern PATTERN_ACTIVE_EFFECTS = Pattern.compile(
+ "\u00a7r\u00a7r\u00a77You have a \u00a7r\u00a7cGod Potion \u00a7r\u00a77active! \u00a7r\u00a7d([0-9]*?:?[0-9]*?:?[0-9]*)\u00a7r");
+
+ public TimersOverlay(
+ Position position,
+ Supplier<List<String>> dummyStrings,
+ Supplier<TextOverlayStyle> styleSupplier
+ ) {
+ super(position, dummyStrings, styleSupplier);
+ }
+
+ private static final Pattern CAKE_PATTERN = Pattern.compile(
+ "\u00a7r\u00a7d\u00a7lYum! \u00a7r\u00a7eYou gain .+ \u00a7r\u00a7efor \u00a7r\u00a7a48 \u00a7r\u00a7ehours!\u00a7r");
+ private static final Pattern PUZZLER_PATTERN =
+ Pattern.compile("\u00a7r\u00a7dPuzzler\u00a7r\u00a76 gave you .+ \u00a7r\u00a76for solving the puzzle!\u00a7r");
+ private static final Pattern FETCHUR_PATTERN =
+ Pattern.compile("\u00a7e\\[NPC] Fetchur\u00a7f: \u00a7rthanks thats probably what i needed\u00a7r");
+ private static final Pattern FETCHUR2_PATTERN =
+ Pattern.compile("\u00a7e\\[NPC] Fetchur\u00a7f: \u00a7rcome back another time, maybe tmrw\u00a7r");
+ private static final Pattern DAILY_MITHRIL_POWDER = Pattern.compile(
+ "\u00a7r\u00a79\u1805 \u00a7r\u00a7fYou've earned \u00a7r\u00a72.+ Mithril Powder \u00a7r\u00a7ffrom mining your first Mithril Ore of the day!\u00a7r");
+ private static final Pattern DAILY_GEMSTONE_POWDER = Pattern.compile(
+ "\u00a7r\u00a79\u1805 \u00a7r\u00a7fYou've earned \u00a7r\u00a7d.+ Gemstone Powder \u00a7r\u00a7ffrom mining your first Gemstone of the day!\u00a7r");
+
+ @SubscribeEvent(priority = EventPriority.HIGHEST, receiveCanceled = true)
+ public void onChatMessageReceived(ClientChatReceivedEvent event) {
+ NEUConfig.HiddenProfileSpecific hidden = NotEnoughUpdates.INSTANCE.config.getProfileSpecific();
+ if (hidden == null) return;
+
+ if (event.type == 0) {
+ long currentTime = System.currentTimeMillis();
+ Matcher cakeMatcher = CAKE_PATTERN.matcher(event.message.getFormattedText());
+ if (cakeMatcher.matches()) {
+ hidden.firstCakeAte = currentTime;
+ return;
+ }
+ Matcher puzzlerMatcher = PUZZLER_PATTERN.matcher(event.message.getFormattedText());
+ if (puzzlerMatcher.matches()) {
+ hidden.puzzlerCompleted = currentTime;
+ return;
+ }
+
+ Matcher fetchurMatcher = FETCHUR_PATTERN.matcher(event.message.getFormattedText());
+ if (fetchurMatcher.matches()) {
+ hidden.fetchurCompleted = currentTime;
+ return;
+ }
+
+ Matcher fetchur2Matcher = FETCHUR2_PATTERN.matcher(event.message.getFormattedText());
+ if (fetchur2Matcher.matches()) {
+ hidden.fetchurCompleted = currentTime;
+ return;
+ }
+ Matcher dailyGemstonePowder = DAILY_GEMSTONE_POWDER.matcher(event.message.getFormattedText());
+ if (dailyGemstonePowder.matches()) {
+ hidden.dailyGemstonePowderCompleted = currentTime;
+ return;
+ }
+ Matcher dailyMithrilPowder = DAILY_MITHRIL_POWDER.matcher(event.message.getFormattedText());
+ if (dailyMithrilPowder.matches()) {
+ hidden.dailyMithrilPowerCompleted = currentTime;
+ }
+ }
+ }
+
+ @Override
+ protected Vector2f getSize(List<String> strings) {
+ if (NotEnoughUpdates.INSTANCE.config.miscOverlays.todoIcons)
+ return super.getSize(strings).translate(12, 0);
+ return super.getSize(strings);
+ }
+
+ private static final ItemStack CAKES_ICON = new ItemStack(Items.cake);
+ private static final ItemStack PUZZLER_ICON = new ItemStack(Items.book);
+ private static ItemStack[] FETCHUR_ICONS = null;
+ private static final ItemStack COMMISSIONS_ICON = new ItemStack(Items.iron_pickaxe);
+ private static final ItemStack EXPERIMENTS_ICON = new ItemStack(Items.enchanted_book);
+ private static final ItemStack COOKIE_ICON = new ItemStack(Items.cookie);
+
+ @Override
+ protected void renderLine(String line, Vector2f position, boolean dummy) {
+ if (!NotEnoughUpdates.INSTANCE.config.miscOverlays.todoIcons) {
+ return;
+ }
+ GlStateManager.enableDepth();
+
+ ItemStack icon = null;
+
+ String clean = Utils.cleanColour(line);
+ String beforeColon = clean.split(":")[0];
+ switch (beforeColon) {
+ case "Cakes":
+ icon = CAKES_ICON;
+ break;
+ case "Puzzler":
+ icon = PUZZLER_ICON;
+ break;
+ case "Godpot":
+ icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("GOD_POTION"));
+ break;
+ case "Fetchur": {
+ if (FETCHUR_ICONS == null) {
+ FETCHUR_ICONS = new ItemStack[]{
+ new ItemStack(Blocks.wool, 50, 14),
+ new ItemStack(Blocks.stained_glass, 20, 4),
+ new ItemStack(Items.compass, 1, 0),
+ new ItemStack(Items.prismarine_crystals, 20, 0),
+ new ItemStack(Items.fireworks, 1, 0),
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("CHEAP_COFFEE")),
+ new ItemStack(Items.oak_door, 1, 0),
+ new ItemStack(Items.rabbit_foot, 3, 0),
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("SUPERBOOM_TNT")),
+ new ItemStack(Blocks.pumpkin, 1, 0),
+ new ItemStack(Items.flint_and_steel, 1, 0),
+ new ItemStack(Blocks.quartz_ore, 50, 0),
+ //new ItemStack(Items.ender_pearl, 16, 0)
+ };
+ }
+
+ ZonedDateTime currentTimeEST = ZonedDateTime.now(ZoneId.of("America/Atikokan"));
+
+ long fetchurIndex = ((currentTimeEST.getDayOfMonth() + 1) % 12) - 1;
+ //Added because disabled fetchur and enabled it again but it was showing the wrong item
+ //Lets see if this stays correct
+
+ if (fetchurIndex < 0) fetchurIndex += 12;
+
+ icon = FETCHUR_ICONS[(int) fetchurIndex];
+ break;
+ }
+ case "Commissions":
+ icon = COMMISSIONS_ICON;
+ break;
+ case "Experiments":
+ icon = EXPERIMENTS_ICON;
+ break;
+ case "Cookie Buff":
+ icon = COOKIE_ICON;
+ break;
+ case "Daily Mithril Powder":
+ icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("MITHRIL_ORE"));
+ break;
+ case "Daily Gemstone Powder":
+ icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("PERFECT_AMETHYST_GEM"));
+ break;
+ }
+
+ if (icon != null) {
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(position.x, position.y, 0);
+ GlStateManager.scale(0.5f, 0.5f, 1f);
+ Utils.drawItemStack(icon, 0, 0);
+ GlStateManager.popMatrix();
+
+ position.x += 12;
+ }
+
+ super.renderLine(line, position, dummy);
+ }
+
+ @Override
+ public void update() {
+
+ long currentTime = System.currentTimeMillis();
+
+ NEUConfig.HiddenProfileSpecific hidden = NotEnoughUpdates.INSTANCE.config.getProfileSpecific();
+ if (hidden == null) return;
+
+ if (Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
+ GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
+ ContainerChest container = (ContainerChest) chest.inventorySlots;
+ IInventory lower = container.getLowerChestInventory();
+ String containerName = lower.getDisplayName().getUnformattedText();
+
+ if (containerName.equals("Commissions") && lower.getSizeInventory() >= 18) {
+ if (hidden.commissionsCompleted == 0) {
+ hidden.commissionsCompleted = currentTime;
+ }
+ for (int i = 9; i < 18; i++) {
+ ItemStack stack = lower.getStackInSlot(i);
+ if (stack != null && stack.hasTagCompound()) {
+ String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stack.getTagCompound());
+ for (String line : lore) {
+ if (line.contains("(Daily")) {
+ hidden.commissionsCompleted = 0;
+ break;
+ }
+ }
+ }
+ }
+ } else if (containerName.equals("Experimentation Table") && lower.getSizeInventory() >= 36) {
+ ItemStack stack = lower.getStackInSlot(31);
+ if (stack != null) {
+ if (stack.getItem() == Items.blaze_powder) {
+ if (hidden.experimentsCompleted == 0) {
+ hidden.experimentsCompleted = currentTime;
+ return;
+ }
+ }
+ }
+ ItemStack stackSuperPairs = lower.getStackInSlot(22);
+ if (stackSuperPairs != null && stackSuperPairs.getItem() == Items.skull &&
+ stackSuperPairs.getTagCompound() != null) {
+ String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stackSuperPairs.getTagCompound());
+ String text = lore[lore.length - 1];
+ String cleanText = Utils.cleanColour(text);
+ if (cleanText.equals("Experiments on cooldown!")) {
+ hidden.experimentsCompleted = currentTime;
+ return;
+ }
+ }
+ hidden.experimentsCompleted = 0;
+ return;
+ } else if (containerName.equals("Superpairs Rewards") && lower.getSizeInventory() >= 27) {
+ ItemStack stack = lower.getStackInSlot(13);
+ if (stack != null && Utils.cleanColour(stack.getDisplayName()).equals("Superpairs")) {
+ hidden.experimentsCompleted = currentTime;
+ }
+ }
+ }
+
+ boolean foundCookieBuffText = false;
+ boolean foundGodPotText = false;
+ if (SBInfo.getInstance().getLocation() != null && !SBInfo.getInstance().getLocation().equals("dungeon") &&
+ SBInfo.getInstance().footer != null) {
+ String formatted = SBInfo.getInstance().footer.getFormattedText();
+ for (String line : formatted.split("\n")) {
+ Matcher activeEffectsMatcher = PATTERN_ACTIVE_EFFECTS.matcher(line);
+ if (activeEffectsMatcher.matches()) {
+ foundGodPotText = true;
+ String[] godpotRemaingTimeUnformatted = activeEffectsMatcher.group(1).split(":");
+ long godPotDuration = 0;
+ try {
+ int i = 0;
+ if (godpotRemaingTimeUnformatted.length == 4) {
+ godPotDuration =
+ godPotDuration + (long) Integer.parseInt(godpotRemaingTimeUnformatted[i]) * 24 * 60 * 60 * 1000;
+ i++;
+ }
+ if (godpotRemaingTimeUnformatted.length >= 3) {
+ godPotDuration =
+ godPotDuration + (long) Integer.parseInt(godpotRemaingTimeUnformatted[i]) * 60 * 60 * 1000;
+ i++;
+ }
+ if (godpotRemaingTimeUnformatted.length >= 2) {
+ godPotDuration = godPotDuration + (long) Integer.parseInt(godpotRemaingTimeUnformatted[i]) * 60 * 1000;
+ i++;
+ }
+ if (godpotRemaingTimeUnformatted.length >= 1) {
+ godPotDuration = godPotDuration + (long) Integer.parseInt(godpotRemaingTimeUnformatted[i]) * 1000;
+ }
+ } catch (Exception ignored) {
+ }
+
+ hidden.godPotionDuration = godPotDuration;
+
+ } else if (line.contains("\u00a7d\u00a7lCookie Buff")) {
+ foundCookieBuffText = true;
+ } else if (foundCookieBuffText) {
+ String cleanNoSpace = line.replaceAll("(\u00a7.| )", "");
+
+ hidden.cookieBuffRemaining = 0;
+ StringBuilder number = new StringBuilder();
+ for (int i = 0; i < cleanNoSpace.length(); i++) {
+ char c = cleanNoSpace.charAt(i);
+
+ if (c >= '0' && c <= '9') {
+ number.append(c);
+ } else {
+ if (number.length() == 0) {
+ hidden.cookieBuffRemaining = 0;
+ break;
+ }
+ if ("ydhms".contains("" + c)) {
+ try {
+ long val = Integer.parseInt(number.toString());
+ switch (c) {
+ case 'y':
+ hidden.cookieBuffRemaining += val * 365 * 24 * 60 * 60 * 1000;
+ break;
+ case 'd':
+ hidden.cookieBuffRemaining += val * 24 * 60 * 60 * 1000;
+ break;
+ case 'h':
+ hidden.cookieBuffRemaining += val * 60 * 60 * 1000;
+ break;
+ case 'm':
+ hidden.cookieBuffRemaining += val * 60 * 1000;
+ break;
+ case 's':
+ hidden.cookieBuffRemaining += val * 1000;
+ break;
+ }
+ } catch (NumberFormatException e) {
+ hidden.cookieBuffRemaining = 0;
+ break;
+ }
+
+ number = new StringBuilder();
+ } else {
+ hidden.cookieBuffRemaining = 0;
+ break;
+ }
+ }
+ }
+
+ break;
+ }
+ }
+ }
+
+ if (!foundGodPotText) {
+ hidden.godPotionDuration = 0;
+ }
+
+ if (!NotEnoughUpdates.INSTANCE.config.miscOverlays.todoOverlay2) {
+ overlayStrings = null;
+ return;
+ }
+
+ HashMap<Integer, String> map = new HashMap<>();
+
+ long cakeEnd = hidden.firstCakeAte + 1000 * 60 * 60 * 48 - currentTime;
+
+ //Cake Display
+ if (cakeEnd <= 0) {
+ map.put(
+ 0,
+ DARK_AQUA + "Cakes: " + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.goneColour] +
+ "Inactive!"
+ );
+ } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.cakesDisplay >= DISPLAYTYPE.VERYSOON.ordinal() &&
+ cakeEnd < TimeEnums.HOUR.time) {
+ map.put(
+ 0,
+ DARK_AQUA + "Cakes: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.verySoonColour] +
+ Utils.prettyTime(cakeEnd)
+ );
+ } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.cakesDisplay >= DISPLAYTYPE.SOON.ordinal() &&
+ cakeEnd < TimeEnums.HALFDAY.time) {
+ map.put(
+ 0,
+ DARK_AQUA + "Cakes: " + EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.soonColour] +
+ Utils.prettyTime(cakeEnd)
+ );
+ } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.cakesDisplay >= DISPLAYTYPE.KINDASOON.ordinal() &&
+ cakeEnd < TimeEnums.DAY.time) {
+ map.put(
+ 0,
+ DARK_AQUA + "Cakes: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.kindaSoonColour] +
+ Utils.prettyTime(cakeEnd)
+ );
+ } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.cakesDisplay >= DISPLAYTYPE.ALWAYS.ordinal()) {
+ map.put(
+ 0,
+ DARK_AQUA + "Cakes: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.defaultColour] +
+ Utils.prettyTime(cakeEnd)
+ );
+ }
+
+ //CookieBuff Display
+ if (hidden.cookieBuffRemaining <= 0) {
+ map.put(
+ 1,
+ DARK_AQUA + "Cookie Buff: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.goneColour] + "Inactive!"
+ );
+ } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.cookieBuffDisplay >= DISPLAYTYPE.VERYSOON.ordinal() &&
+ hidden.cookieBuffRemaining < TimeEnums.HOUR.time) {
+ map.put(
+ 1,
+ DARK_AQUA + "Cookie Buff: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.verySoonColour] +
+ Utils.prettyTime(hidden.cookieBuffRemaining)
+ );
+ } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.cookieBuffDisplay >= DISPLAYTYPE.SOON.ordinal() &&
+ hidden.cookieBuffRemaining < TimeEnums.HALFDAY.time) {
+ map.put(
+ 1,
+ DARK_AQUA + "Cookie Buff: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.soonColour] +
+ Utils.prettyTime(hidden.cookieBuffRemaining)
+ );
+ } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.cookieBuffDisplay >= DISPLAYTYPE.KINDASOON.ordinal() &&
+ hidden.cookieBuffRemaining < TimeEnums.DAY.time) {
+ map.put(
+ 1,
+ DARK_AQUA + "Cookie Buff: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.kindaSoonColour] +
+ Utils.prettyTime(hidden.cookieBuffRemaining)
+ );
+ } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.cookieBuffDisplay >= DISPLAYTYPE.ALWAYS.ordinal()) {
+ map.put(
+ 1,
+ DARK_AQUA + "Cookie Buff: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.defaultColour] +
+ Utils.prettyTime(hidden.cookieBuffRemaining)
+ );
+ }
+
+ //Godpot Display
+ //do not display in dungeons due to dungeons not having
+ if (!(SBInfo.getInstance().getLocation() != null && SBInfo.getInstance().getLocation().equals("dungeon"))) {
+ if (hidden.godPotionDuration <= 0) {
+ map.put(
+ 2,
+ DARK_AQUA + "Godpot: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.goneColour] + "Inactive!"
+ );
+ } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.godpotDisplay >= DISPLAYTYPE.VERYSOON.ordinal() &&
+ hidden.godPotionDuration < TimeEnums.HOUR.time) {
+ map.put(
+ 2,
+ DARK_AQUA + "Godpot: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.verySoonColour] +
+ Utils.prettyTime(hidden.godPotionDuration)
+ );
+ } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.godpotDisplay >= DISPLAYTYPE.SOON.ordinal() &&
+ hidden.godPotionDuration < TimeEnums.HALFDAY.time) {
+ map.put(
+ 2,
+ DARK_AQUA + "Godpot: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.soonColour] +
+ Utils.prettyTime(hidden.godPotionDuration)
+ );
+ } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.godpotDisplay >= DISPLAYTYPE.KINDASOON.ordinal() &&
+ hidden.godPotionDuration < TimeEnums.DAY.time) {
+ map.put(
+ 2,
+ DARK_AQUA + "Godpot: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.kindaSoonColour] +
+ Utils.prettyTime(hidden.godPotionDuration)
+ );
+ } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.godpotDisplay >= DISPLAYTYPE.ALWAYS.ordinal()) {
+ map.put(
+ 2,
+ DARK_AQUA + "Godpot: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.defaultColour] +
+ Utils.prettyTime(hidden.godPotionDuration)
+ );
+ }
+ }
+
+ long puzzlerEnd = hidden.puzzlerCompleted + 1000 * 60 * 60 * 24 - currentTime;
+ //Puzzler Display
+ if ((hidden.puzzlerCompleted + TimeEnums.DAY.time) < currentTime) {
+ map.put(
+ 3,
+ DARK_AQUA + "Puzzler: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.readyColour] + "Ready!"
+ );
+ } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.puzzlerDisplay >= DISPLAYTYPE.VERYSOON.ordinal() &&
+ (hidden.puzzlerCompleted + (TimeEnums.DAY.time - TimeEnums.HALFANHOUR.time)) < currentTime) {
+ map.put(
+ 3,
+ DARK_AQUA + "Puzzler: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.verySoonColour] +
+ Utils.prettyTime(puzzlerEnd)
+ );
+ } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.puzzlerDisplay >= DISPLAYTYPE.SOON.ordinal() &&
+ (hidden.puzzlerCompleted + (TimeEnums.DAY.time - TimeEnums.HOUR.time)) < currentTime) {
+ map.put(
+ 3,
+ DARK_AQUA + "Puzzler: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.soonColour] +
+ Utils.prettyTime(puzzlerEnd)
+ );
+ } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.puzzlerDisplay >= DISPLAYTYPE.KINDASOON.ordinal() &&
+ (hidden.puzzlerCompleted + (TimeEnums.DAY.time - (TimeEnums.HOUR.time) * 3)) < currentTime) {
+ map.put(
+ 3,
+ DARK_AQUA + "Puzzler: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.kindaSoonColour] +
+ Utils.prettyTime(puzzlerEnd)
+ );
+ } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.puzzlerDisplay >= DISPLAYTYPE.ALWAYS.ordinal()) {
+ map.put(
+ 3,
+ DARK_AQUA + "Puzzler: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.defaultColour] +
+ Utils.prettyTime(puzzlerEnd)
+ );
+ }
+
+ long midnightReset = (currentTime - 18000000) / 86400000 * 86400000 + 18000000; // 12am est
+ long catacombsReset = currentTime / 86400000 * 86400000; // 7pm est
+ long timeDiffMidnightNow = midnightReset + 86400000 - currentTime;
+ long catacombsDiffNow = catacombsReset + 86400000 - currentTime;
+ long fetchurComplete = hidden.fetchurCompleted;
+
+ //Fetchur Display
+ if (fetchurComplete < midnightReset) {
+ map.put(
+ 4,
+ DARK_AQUA + "Fetchur: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.readyColour] + "Ready!"
+ );
+ } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.fetchurDisplay >= DISPLAYTYPE.VERYSOON.ordinal() &&
+ (fetchurComplete < (midnightReset - TimeEnums.HALFANHOUR.time))) {
+ map.put(
+ 4,
+ DARK_AQUA + "Fetchur: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.verySoonColour] +
+ Utils.prettyTime(timeDiffMidnightNow)
+ );
+ } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.fetchurDisplay >= DISPLAYTYPE.SOON.ordinal() &&
+ (fetchurComplete < (midnightReset - TimeEnums.HOUR.time))) {
+ map.put(
+ 4,
+ DARK_AQUA + "Fetchur: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.soonColour] +
+ Utils.prettyTime(timeDiffMidnightNow)
+ );
+ } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.fetchurDisplay >= DISPLAYTYPE.KINDASOON.ordinal() &&
+ (fetchurComplete < (midnightReset - (TimeEnums.HOUR.time * 3)))) {
+ map.put(
+ 4,
+ DARK_AQUA + "Fetchur: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.kindaSoonColour] +
+ Utils.prettyTime(timeDiffMidnightNow)
+ );
+ } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.fetchurDisplay >= DISPLAYTYPE.ALWAYS.ordinal()) {
+ map.put(
+ 4,
+ DARK_AQUA + "Fetchur: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.defaultColour] +
+ Utils.prettyTime(timeDiffMidnightNow)
+ );
+ }
+
+ //Commissions Display
+ if (hidden.commissionsCompleted < midnightReset) {
+ map.put(
+ 5,
+ DARK_AQUA + "Commissions: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.readyColour] + "Ready!"
+ );
+ } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.commissionDisplay >= DISPLAYTYPE.VERYSOON.ordinal() &&
+ (hidden.commissionsCompleted < (midnightReset - TimeEnums.HALFANHOUR.time))) {
+ map.put(
+ 5,
+ DARK_AQUA + "Commissions: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.verySoonColour] +
+ Utils.prettyTime(timeDiffMidnightNow)
+ );
+ } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.commissionDisplay >= DISPLAYTYPE.SOON.ordinal() &&
+ (hidden.commissionsCompleted < (midnightReset - TimeEnums.HOUR.time))) {
+ map.put(
+ 5,
+ DARK_AQUA + "Commissions: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.soonColour] +
+ Utils.prettyTime(timeDiffMidnightNow)
+ );
+ } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.commissionDisplay >= DISPLAYTYPE.KINDASOON.ordinal() &&
+ (hidden.commissionsCompleted < (midnightReset - (TimeEnums.HOUR.time * 3)))) {
+ map.put(
+ 5,
+ DARK_AQUA + "Commissions: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.kindaSoonColour] +
+ Utils.prettyTime(timeDiffMidnightNow)
+ );
+ } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.commissionDisplay >= DISPLAYTYPE.ALWAYS.ordinal()) {
+ map.put(
+ 5,
+ DARK_AQUA + "Commissions: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.defaultColour] +
+ Utils.prettyTime(timeDiffMidnightNow)
+ );
+ }
+
+ //Experiment Display
+ if (hidden.experimentsCompleted < midnightReset) {
+ map.put(
+ 6,
+ DARK_AQUA + "Experiments: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.readyColour] + "Ready!"
+ );
+ } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.experimentationDisplay >= DISPLAYTYPE.VERYSOON.ordinal() &&
+ (hidden.experimentsCompleted < (midnightReset - TimeEnums.HALFANHOUR.time))) {
+ map.put(
+ 6,
+ DARK_AQUA + "Experiments: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.verySoonColour] +
+ Utils.prettyTime(catacombsReset)
+ );
+ } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.experimentationDisplay >= DISPLAYTYPE.SOON.ordinal() &&
+ (hidden.experimentsCompleted < (midnightReset - TimeEnums.HOUR.time))) {
+ map.put(
+ 6,
+ DARK_AQUA + "Experiments: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.soonColour] +
+ Utils.prettyTime(catacombsReset)
+ );
+ } else if (
+ NotEnoughUpdates.INSTANCE.config.miscOverlays.experimentationDisplay >= DISPLAYTYPE.KINDASOON.ordinal() &&
+ (hidden.experimentsCompleted < (midnightReset - (TimeEnums.HOUR.time * 3)))) {
+ map.put(
+ 6,
+ DARK_AQUA + "Experiments: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.kindaSoonColour] +
+ Utils.prettyTime(catacombsReset)
+ );
+ } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.experimentationDisplay >= DISPLAYTYPE.ALWAYS.ordinal()) {
+ map.put(
+ 6,
+ DARK_AQUA + "Experiments: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.defaultColour] +
+ Utils.prettyTime(catacombsReset)
+ );
+ }
+
+ // Daily Mithril Powder display
+ long mithrilPowderCompleted = hidden.dailyMithrilPowerCompleted + 1000 * 60 * 60 * 24 - currentTime;
+
+ if (hidden.dailyMithrilPowerCompleted < midnightReset) {
+ map.put(
+ 7,
+ DARK_AQUA + "Daily Mithril Powder: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.readyColour] + "Ready!"
+ );
+ } else if (
+ NotEnoughUpdates.INSTANCE.config.miscOverlays.dailyMithrilPowderDisplay >= DISPLAYTYPE.VERYSOON.ordinal() &&
+ (hidden.dailyMithrilPowerCompleted < (midnightReset - TimeEnums.HALFANHOUR.time))) {
+ map.put(
+ 7,
+ DARK_AQUA + "Daily Mithril Powder: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.verySoonColour] +
+ Utils.prettyTime(timeDiffMidnightNow)
+ );
+ } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.dailyMithrilPowderDisplay >= DISPLAYTYPE.SOON.ordinal() &&
+ (hidden.dailyMithrilPowerCompleted < (midnightReset - TimeEnums.HOUR.time))) {
+ map.put(
+ 7,
+ DARK_AQUA + "Daily Mithril Powder: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.soonColour] +
+ Utils.prettyTime(timeDiffMidnightNow)
+ );
+ } else if (
+ NotEnoughUpdates.INSTANCE.config.miscOverlays.dailyMithrilPowderDisplay >= DISPLAYTYPE.KINDASOON.ordinal() &&
+ (hidden.dailyMithrilPowerCompleted < (midnightReset - (TimeEnums.HOUR.time * 3)))) {
+ map.put(
+ 7,
+ DARK_AQUA + "Daily Mithril Powder: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.kindaSoonColour] +
+ Utils.prettyTime(timeDiffMidnightNow)
+ );
+ } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.dailyMithrilPowderDisplay >=
+ DISPLAYTYPE.ALWAYS.ordinal()) {
+ map.put(
+ 7,
+ DARK_AQUA + "Daily Mithril Powder: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.defaultColour] +
+ Utils.prettyTime(timeDiffMidnightNow)
+ );
+ }
+
+ // Daily Gemstone Powder Display
+ if (hidden.dailyGemstonePowderCompleted < midnightReset) {
+ map.put(
+ 8,
+ DARK_AQUA + "Daily Gemstone Powder: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.readyColour] + "Ready!"
+ );
+ } else if (
+ NotEnoughUpdates.INSTANCE.config.miscOverlays.dailyGemstonePowderDisplay >= DISPLAYTYPE.VERYSOON.ordinal() &&
+ (hidden.dailyGemstonePowderCompleted < (midnightReset - TimeEnums.HALFANHOUR.time))) {
+ map.put(
+ 8,
+ DARK_AQUA + "Daily Gemstone Powder: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.verySoonColour] +
+ Utils.prettyTime(timeDiffMidnightNow)
+ );
+ } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.dailyGemstonePowderDisplay >= DISPLAYTYPE.SOON.ordinal() &&
+ (hidden.dailyGemstonePowderCompleted < (midnightReset - TimeEnums.HOUR.time))) {
+ map.put(
+ 8,
+ DARK_AQUA + "Daily Gemstone Powder: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.soonColour] +
+ Utils.prettyTime(timeDiffMidnightNow)
+ );
+ } else if (
+ NotEnoughUpdates.INSTANCE.config.miscOverlays.dailyGemstonePowderDisplay >= DISPLAYTYPE.KINDASOON.ordinal() &&
+ (hidden.dailyGemstonePowderCompleted < (midnightReset - (TimeEnums.HOUR.time * 3)))) {
+ map.put(
+ 8,
+ DARK_AQUA + "Daily Gemstone Powder: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.kindaSoonColour] +
+ Utils.prettyTime(timeDiffMidnightNow)
+ );
+ } else if (NotEnoughUpdates.INSTANCE.config.miscOverlays.dailyGemstonePowderDisplay >=
+ DISPLAYTYPE.ALWAYS.ordinal()) {
+ map.put(
+ 8,
+ DARK_AQUA + "Daily Gemstone Powder: " +
+ EnumChatFormatting.values()[NotEnoughUpdates.INSTANCE.config.miscOverlays.defaultColour] +
+ Utils.prettyTime(timeDiffMidnightNow)
+ );
+ }
+
+ overlayStrings = new ArrayList<>();
+ for (int index : NotEnoughUpdates.INSTANCE.config.miscOverlays.todoText2) {
+ if (map.containsKey(index)) {
+ overlayStrings.add(map.get(index));
+ }
+ }
+ if (overlayStrings.isEmpty()) overlayStrings = null;
+ }
+
+ public String compactRemaining(int amount) {
+ return (5 - amount) + " remaining";
+ }
+
+ private enum TimeEnums {
+ DAY(86400000),
+ HALFDAY(43200000),
+ HOUR(3600000),
+ HALFANHOUR(1800000);
+
+ TimeEnums(long time) {
+ this.time = time;
+ }
+
+ public final long time;
+ }
+
+ private enum DISPLAYTYPE {
+ NOW,
+ VERYSOON,
+ SOON,
+ KINDASOON,
+ ALWAYS,
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java
index bf305b51..44ea686d 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java
@@ -7,7 +7,6 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import com.mojang.authlib.GameProfile;
-import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.cosmetics.ShaderManager;
import io.github.moulberry.notenoughupdates.itemeditor.GuiElementTextField;
@@ -24,7 +23,6 @@ import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.resources.DefaultPlayerSkin;
-import net.minecraft.client.resources.SkinManager;
import net.minecraft.client.shader.Framebuffer;
import net.minecraft.client.shader.Shader;
import net.minecraft.entity.EntityLivingBase;
@@ -58,3151 +56,4892 @@ import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
+import java.util.function.Supplier;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class GuiProfileViewer extends GuiScreen {
-
- private static final ResourceLocation CHEST_GUI_TEXTURE = new ResourceLocation("textures/gui/container/generic_54.png");
- public static final ResourceLocation pv_basic = new ResourceLocation("notenoughupdates:pv_basic.png");
- public static final ResourceLocation pv_dung = new ResourceLocation("notenoughupdates:pv_dung.png");
- public static final ResourceLocation pv_extra = new ResourceLocation("notenoughupdates:pv_extra.png");
- public static final ResourceLocation pv_invs = new ResourceLocation("notenoughupdates:pv_invs.png");
- public static final ResourceLocation pv_cols = new ResourceLocation("notenoughupdates:pv_cols.png");
- public static final ResourceLocation pv_pets = new ResourceLocation("notenoughupdates:pv_pets.png");
- public static final ResourceLocation pv_dropdown = new ResourceLocation("notenoughupdates:pv_dropdown.png");
- public static final ResourceLocation pv_bg = new ResourceLocation("notenoughupdates:pv_bg.png");
- public static final ResourceLocation pv_elements = new ResourceLocation("notenoughupdates:pv_elements.png");
- public static final ResourceLocation pv_ironman = new ResourceLocation("notenoughupdates:pv_ironman.png");
- public static final ResourceLocation resource_packs = new ResourceLocation("minecraft:textures/gui/resource_packs.png");
- public static final ResourceLocation icons = new ResourceLocation("textures/gui/icons.png");
-
- private static final NumberFormat numberFormat = NumberFormat.getInstance(Locale.US);
-
- private final ProfileViewer.Profile profile;
- public static ProfileViewerPage currentPage = ProfileViewerPage.BASIC;
- private int sizeX;
- private int sizeY;
- private int guiLeft;
- private int guiTop;
-
- private float backgroundRotation = 0;
-
- private long currentTime = 0;
- private long lastTime = 0;
- private long startTime = 0;
-
- private List<String> tooltipToDisplay = null;
-
- private String profileId = null;
- private boolean profileDropdownSelected = false;
-
- public enum ProfileViewerPage {
- LOADING(null),
- INVALID_NAME(null),
- NO_SKYBLOCK(null),
- BASIC(new ItemStack(Items.paper)),
- DUNG(new ItemStack(Item.getItemFromBlock(Blocks.deadbush))),
- EXTRA(new ItemStack(Items.book)),
- INVS(new ItemStack(Item.getItemFromBlock(Blocks.ender_chest))),
- COLS(new ItemStack(Items.painting)),
- PETS(new ItemStack(Items.bone));
-
- public final ItemStack stack;
-
- ProfileViewerPage(ItemStack stack) {
- this.stack = stack;
- }
- }
-
- public GuiProfileViewer(ProfileViewer.Profile profile) {
- this.profile = profile;
- String name = "";
- if(profile != null && profile.getHypixelProfile() != null) {
- name = profile.getHypixelProfile().get("displayname").getAsString();
- }
- playerNameTextField = new GuiElementTextField(name,
- GuiElementTextField.SCALE_TEXT);
- playerNameTextField.setSize(100, 20);
-
- if(currentPage == ProfileViewerPage.LOADING) {
- currentPage = ProfileViewerPage.BASIC;
- }
- }
-
- private GuiElementTextField playerNameTextField;
-
- @Override
- public void drawScreen(int mouseX, int mouseY, float partialTicks) {
- currentTime = System.currentTimeMillis();
- if(startTime == 0) startTime = currentTime;
-
- ProfileViewerPage page = currentPage;
- if(profile == null) {
- page = ProfileViewerPage.INVALID_NAME;
- } else if(profile.getPlayerInformation(null) == null) {
- page = ProfileViewerPage.LOADING;
- } else if(profile.getLatestProfile() == null) {
- page = ProfileViewerPage.NO_SKYBLOCK;
- }
-
- if(profileId == null && profile != null && profile.getLatestProfile() != null) {
- profileId = profile.getLatestProfile();
- }
- {
- //this is just to cache the guild info
- if(profile != null) {
- JsonObject guildinfo = profile.getGuildInfo(null);
- }
- }
-
- this.sizeX = 431;
- this.sizeY = 202;
- this.guiLeft = (this.width-this.sizeX)/2;
- this.guiTop = (this.height-this.sizeY)/2;
-
- super.drawScreen(mouseX, mouseY, partialTicks);
- drawDefaultBackground();
-
- blurBackground();
- renderBlurredBackground(width, height, guiLeft+2, guiTop+2, sizeX-4, sizeY-4);
-
- GlStateManager.enableDepth();
- GlStateManager.translate(0, 0, 5);
- renderTabs(true);
- GlStateManager.translate(0, 0, -3);
-
- GlStateManager.disableDepth();
- GlStateManager.translate(0, 0, -2);
- renderTabs(false);
- GlStateManager.translate(0, 0, 2);
-
- GlStateManager.disableLighting();
- GlStateManager.enableDepth();
- GlStateManager.enableBlend();
- GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
- GlStateManager.enableAlpha();
- GlStateManager.alphaFunc(516, 0.1F);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_bg);
- Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST);
-
- if(!(page == ProfileViewerPage.LOADING)) {
- playerNameTextField.render(guiLeft+sizeX-100, guiTop+sizeY+5);
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
-
- if(profile != null) {
- JsonObject currProfileInfo = profile.getProfileInformation(profileId);
- //Render Profile chooser button
- renderBlurredBackground(width, height, guiLeft+2, guiTop+sizeY+3+2, 100-4, 20-4);
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_dropdown);
- Utils.drawTexturedRect(guiLeft, guiTop+sizeY+3, 100, 20,
- 0, 100/200f, 0, 20/185f, GL11.GL_NEAREST);
- Utils.drawStringCenteredScaledMaxWidth(profileId, Minecraft.getMinecraft().fontRendererObj, guiLeft+50,
- guiTop+sizeY+3+10, true, 90, new Color(63, 224, 208, 255).getRGB());
- if(currProfileInfo != null && currProfileInfo.has("game_mode") && currProfileInfo.get("game_mode").getAsString().equals("ironman")) {
- GlStateManager.color(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_ironman);
- Utils.drawTexturedRect(guiLeft-16-5, guiTop+sizeY+5, 16, 16, GL11.GL_NEAREST);
- }
- //Render Open In Skycrypt button
- renderBlurredBackground(width, height, guiLeft+100+6+2, guiTop+sizeY+3+2, 100-4, 20-4);
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_dropdown);
- Utils.drawTexturedRect(guiLeft+100+6, guiTop+sizeY+3, 100, 20,
- 0, 100/200f, 0, 20/185f, GL11.GL_NEAREST);
- Utils.drawStringCenteredScaledMaxWidth("Open in Skycrypt", Minecraft.getMinecraft().fontRendererObj, guiLeft+50+100+6,
- guiTop+sizeY+3+10, true, 90, new Color(63, 224, 208, 255).getRGB());
-
-
-
-
- if(profileDropdownSelected && !profile.getProfileIds().isEmpty() && scaledResolution.getScaleFactor() != 4) {
- int dropdownOptionSize = scaledResolution.getScaleFactor()==3?10:20;
-
- int numProfiles = profile.getProfileIds().size();
- int sizeYDropdown = numProfiles*dropdownOptionSize;
- renderBlurredBackground(width, height, guiLeft+2, guiTop+sizeY+23, 100-4, sizeYDropdown-2);
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_dropdown);
- Utils.drawTexturedRect(guiLeft, guiTop+sizeY+23-3, 100, 3,
- 100/200f, 1, 0, 3/185f, GL11.GL_NEAREST);
- Utils.drawTexturedRect(guiLeft, guiTop+sizeY+23+sizeYDropdown-4, 100, 4,
- 100/200f, 1, 181/185f, 1, GL11.GL_NEAREST);
- Utils.drawTexturedRect(guiLeft, guiTop+sizeY+23, 100, sizeYDropdown-4,
- 100/200f, 1, (181-sizeYDropdown)/185f, 181/185f, GL11.GL_NEAREST);
-
- for(int yIndex = 0; yIndex<profile.getProfileIds().size(); yIndex++) {
- String otherProfileId = profile.getProfileIds().get(yIndex);
- Utils.drawStringCenteredScaledMaxWidth(otherProfileId, Minecraft.getMinecraft().fontRendererObj, guiLeft+50,
- guiTop+sizeY+23+dropdownOptionSize/2f+dropdownOptionSize*yIndex, true, 90, new Color(33, 112, 104, 255).getRGB());
- currProfileInfo = profile.getProfileInformation(otherProfileId);
- if(currProfileInfo != null && currProfileInfo.has("game_mode") && currProfileInfo.get("game_mode").getAsString().equals("ironman")) {
- GlStateManager.color(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_ironman);
- Utils.drawTexturedRect(guiLeft-16-5, guiTop+sizeY+2+23+dropdownOptionSize*yIndex, 16, 16, GL11.GL_NEAREST);
- }
- }
-
- }
- }
- }
-
- GlStateManager.color(1, 1, 1, 1);
- switch (page) {
- case BASIC:
- drawBasicPage(mouseX, mouseY, partialTicks);
- break;
- case DUNG:
- drawDungPage(mouseX, mouseY, partialTicks);
- break;
- case EXTRA:
- drawExtraPage(mouseX, mouseY, partialTicks);
- break;
- case INVS:
- drawInvsPage(mouseX, mouseY, partialTicks);
- break;
- case COLS:
- drawColsPage(mouseX, mouseY, partialTicks);
- break;
- case PETS:
- drawPetsPage(mouseX, mouseY, partialTicks);
- break;
- case LOADING:
- String str = EnumChatFormatting.YELLOW+"Loading player profiles.";
- long currentTimeMod = System.currentTimeMillis() % 1000;
- if(currentTimeMod > 333) {
- if(currentTimeMod < 666) {
- str += ".";
- } else {
- str += "..";
- }
- }
-
- Utils.drawStringCentered(str, Minecraft.getMinecraft().fontRendererObj,
- guiLeft+sizeX/2f, guiTop+101, true, 0);
-
- //This is just here to inform the player what to do
- //like typing /api new or telling them to go find a psychotherapist
- long timeDiff = System.currentTimeMillis() - startTime;
-
- if(timeDiff > 20000){
- Utils.drawStringCentered(EnumChatFormatting.YELLOW+"Its taking a while...", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+sizeX/2f, guiTop+111, true, 0);
- Utils.drawStringCentered(EnumChatFormatting.YELLOW+"Try \"/api new\".", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+sizeX/2f, guiTop+121, true, 0);
- if(timeDiff > 60000){
- Utils.drawStringCentered(EnumChatFormatting.YELLOW+"Might be hypixel's fault.", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+sizeX/2f, guiTop+131, true, 0);
- if(timeDiff > 180000){
- Utils.drawStringCentered(EnumChatFormatting.YELLOW+"Wow you're still here?", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+sizeX/2f, guiTop+141, true, 0);
- if(timeDiff > 360000){
- long second = (timeDiff / 1000) % 60;
- long minute = (timeDiff / (1000 * 60)) % 60;
- long hour = (timeDiff / (1000 * 60 * 60)) % 24;
-
- String time = String.format("%02d:%02d:%02d", hour, minute, second);
- Utils.drawStringCentered(EnumChatFormatting.YELLOW+"You've wasted your time here for: "+time, Minecraft.getMinecraft().fontRendererObj,
- guiLeft+sizeX/2f, guiTop+151, true, 0);
- Utils.drawStringCentered(EnumChatFormatting.YELLOW+""+EnumChatFormatting.BOLD+"What are you doing with your life?", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+sizeX/2f, guiTop+161, true, 0);
- if(timeDiff > 600000){
- Utils.drawStringCentered(EnumChatFormatting.RED+""+EnumChatFormatting.BOLD+"Maniac", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+sizeX/2f, guiTop+171, true, 0);
- if(timeDiff > 1200000){
- Utils.drawStringCentered(EnumChatFormatting.RED+""+EnumChatFormatting.BOLD+"You're a menace to society", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+sizeX/2f, guiTop+181, true, 0);
- if(timeDiff > 1800000){
- Utils.drawStringCentered(EnumChatFormatting.RED+""+EnumChatFormatting.BOLD+"You dont know whats gonna happen to you", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+sizeX/2f, guiTop+191, true, 0);
- if(timeDiff > 3000000){
- Utils.drawStringCentered(EnumChatFormatting.RED+""+EnumChatFormatting.BOLD+"You really want this?", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+sizeX/2f, guiTop+91, true, 0);
- if(timeDiff > 3300000){
- Utils.drawStringCentered(EnumChatFormatting.DARK_RED+""+EnumChatFormatting.BOLD+"OW LORD FORGIVE ME FOR THIS", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+sizeX/2f, guiTop+71, true, 0);
- if(timeDiff > 3600000){
- throw new Error("Go do something productive") {
- @Override
- public void printStackTrace() {
- throw new Error("Go do something productive");
- }
- };
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
-
- break;
- case INVALID_NAME:
- Utils.drawStringCentered(EnumChatFormatting.RED+"Invalid name or API is down!", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+sizeX/2f, guiTop+101, true, 0);
- break;
- case NO_SKYBLOCK:
- Utils.drawStringCentered(EnumChatFormatting.RED+"No skyblock data found!", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+sizeX/2f, guiTop+101, true, 0);
- break;
- }
-
- lastTime = currentTime;
-
- if(tooltipToDisplay != null) {
- List<String> grayTooltip = new ArrayList<>(tooltipToDisplay.size());
- for(String line : tooltipToDisplay) {
- grayTooltip.add(EnumChatFormatting.GRAY + line);
- }
- Utils.drawHoveringText(grayTooltip, mouseX, mouseY, width, height, -1, Minecraft.getMinecraft().fontRendererObj);
- tooltipToDisplay = null;
- }
- }
-
- private void renderTabs(boolean renderPressed) {
- int ignoredTabs = 0;
- for(int i=0; i<ProfileViewerPage.values().length; i++) {
- ProfileViewerPage page = ProfileViewerPage.values()[i];
- if(page.stack == null) {
- ignoredTabs++;
- continue;
- }
- boolean pressed = page == currentPage;
- if(pressed == renderPressed) {
- renderTab(page.stack, i-ignoredTabs, pressed);
- }
- }
- }
-
- private void renderTab(ItemStack stack, int xIndex, boolean pressed) {
- GlStateManager.disableLighting();
- GlStateManager.enableBlend();
- GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
- GlStateManager.enableAlpha();
- GlStateManager.alphaFunc(516, 0.1F);
-
- int x = guiLeft+xIndex*28;
- int y = guiTop-28;
-
- float uMin = 0;
- float uMax = 28/256f;
- float vMin = 20/256f;
- float vMax = 51/256f;
- if(pressed) {
- vMin = 52/256f;
- vMax = 84/256f;
-
- if(xIndex != 0) {
- uMin = 28/256f;
- uMax = 56/256f;
- }
-
- renderBlurredBackground(width, height, x+2, y+2, 28-4, 28-4);
- } else {
- renderBlurredBackground(width, height, x+2, y+4, 28-4, 28-4);
- }
-
- GlStateManager.disableLighting();
- GlStateManager.enableBlend();
- GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
- GlStateManager.enableAlpha();
- GlStateManager.alphaFunc(516, 0.1F);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements);
- Utils.drawTexturedRect(x, y, 28, pressed?32:31, uMin, uMax, vMin, vMax, GL11.GL_NEAREST);
-
- GlStateManager.enableDepth();
- Utils.drawItemStack(stack, x+6, y+9);
- }
-
- @Override
- protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
- if(currentPage != ProfileViewerPage.LOADING && currentPage != ProfileViewerPage.INVALID_NAME) {
- int ignoredTabs = 0;
- for(int i=0; i<ProfileViewerPage.values().length; i++) {
- ProfileViewerPage page = ProfileViewerPage.values()[i];
- if(page.stack == null) {
- ignoredTabs++;
- continue;
- }
- int i2 = i - ignoredTabs;
- int x = guiLeft+i2*28;
- int y = guiTop-28;
-
- if(mouseX > x && mouseX < x+28) {
- if(mouseY > y && mouseY < y+32) {
- if(currentPage != page) Utils.playPressSound();
- currentPage = page;
- inventoryTextField.otherComponentClick();
- playerNameTextField.otherComponentClick();
- return;
- }
- }
- }
- }
- switch (currentPage) {
- case DUNG:
- mouseClickedDung(mouseX, mouseY, mouseButton);
- break;
- case INVS:
- inventoryTextField.setSize(88, 20);
- if(mouseX > guiLeft+19 && mouseX < guiLeft+19+88) {
- if(mouseY > guiTop+sizeY-26-20 && mouseY < guiTop+sizeY-26) {
- inventoryTextField.mouseClicked(mouseX, mouseY, mouseButton);
- playerNameTextField.otherComponentClick();
- return;
- }
- }
- break;
- case PETS:
- if(sortedPets == null) break;
- for(int i=petsPage*20; i<Math.min(petsPage*20+20, sortedPets.size()); i++) {
- int xIndex = (i%20) % COLLS_XCOUNT;
- int yIndex = (i%20) / COLLS_XCOUNT;
-
- float x = 5 + COLLS_XPADDING + (COLLS_XPADDING + 20) * xIndex;
- float y = 7 + COLLS_YPADDING + (COLLS_YPADDING + 20) * yIndex;
-
- if(mouseX > guiLeft+x && mouseX < guiLeft+x+20) {
- if(mouseY > guiTop+y && mouseY < guiTop+y+20) {
- selectedPet = i;
- return;
- }
- }
- }
- break;
- }
- if(mouseX > guiLeft+sizeX-100 && mouseX < guiLeft+sizeX) {
- if(mouseY > guiTop+sizeY+5 && mouseY < guiTop+sizeY+25) {
- playerNameTextField.mouseClicked(mouseX, mouseY, mouseButton);
- inventoryTextField.otherComponentClick();
- return;
- }
- }
- if(mouseX > guiLeft+106 && mouseX < guiLeft+106+100 && profile != null && !profile.getProfileIds().isEmpty() && profileId != null) {
- if(mouseY > guiTop+sizeY+3 && mouseY < guiTop+sizeY+23) {
- try{
- Desktop desk = Desktop.getDesktop();
- desk.browse(new URI("https://sky.shiiyu.moe/stats/"+profile.getHypixelProfile().get("displayname").getAsString()+"/"+profileId));
- Utils.playPressSound();
- return;
- } catch (UnsupportedOperationException | IOException | URISyntaxException ignored) {
- //no idea how this sounds, but ya know just in case
- Utils.playSound(new ResourceLocation("game.player.hurt"), true);
- return;
- }
- }
- }
-
- if(mouseX > guiLeft && mouseX < guiLeft+100 && profile != null && !profile.getProfileIds().isEmpty()) {
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- if(mouseY > guiTop+sizeY+3 && mouseY < guiTop+sizeY+23) {
- if(scaledResolution.getScaleFactor() == 4) {
- profileDropdownSelected = false;
- int profileNum = 0;
- for(int index = 0; index<profile.getProfileIds().size(); index++) {
- if(profile.getProfileIds().get(index).equals(profileId)) {
- profileNum = index;
- break;
- }
- }
- if(mouseButton == 0) {
- profileNum++;
- } else {
- profileNum--;
- }
- if(profileNum >= profile.getProfileIds().size()) profileNum = 0;
- if(profileNum < 0) profileNum = profile.getProfileIds().size()-1;
-
- String newProfileId = profile.getProfileIds().get(profileNum);
- if(profileId != null && !profileId.equals(newProfileId)) {
- resetCache();
- }
- profileId = newProfileId;
- } else {
- profileDropdownSelected = !profileDropdownSelected;
- }
- } else if(scaledResolution.getScaleFactor() != 4 && profileDropdownSelected) {
- int dropdownOptionSize = scaledResolution.getScaleFactor()==3?10:20;
- int extraY = mouseY - (guiTop+sizeY+23);
- int index = extraY/dropdownOptionSize;
- if(index >= 0 && index < profile.getProfileIds().size()) {
- String newProfileId = profile.getProfileIds().get(index);
- if(profileId != null && !profileId.equals(newProfileId)) {
- resetCache();
- }
- profileId = newProfileId;
- }
- }
- playerNameTextField.otherComponentClick();
- inventoryTextField.otherComponentClick();
- return;
- }
- profileDropdownSelected = false;
- playerNameTextField.otherComponentClick();
- inventoryTextField.otherComponentClick();
- }
-
- @Override
- protected void keyTyped(char typedChar, int keyCode) throws IOException {
- super.keyTyped(typedChar, keyCode);
- switch (currentPage) {
- case INVS:
- keyTypedInvs(typedChar, keyCode);
- inventoryTextField.keyTyped(typedChar, keyCode);
- break;
- case COLS:
- keyTypedCols(typedChar, keyCode);
- break;
- case DUNG:
- keyTypedDung(typedChar, keyCode);
- break;
- }
- if(playerNameTextField.getFocus() && !(currentPage == ProfileViewerPage.LOADING)) {
- if(keyCode == Keyboard.KEY_RETURN) {
- currentPage = ProfileViewerPage.LOADING;
- NotEnoughUpdates.profileViewer.getProfileByName(playerNameTextField.getText(), profile -> { //todo: invalid name
- if(profile != null) profile.resetCache();
- Minecraft.getMinecraft().displayGuiScreen(new GuiProfileViewer(profile));
- });
- }
- playerNameTextField.keyTyped(typedChar, keyCode);
- }
- }
-
- @Override
- protected void mouseReleased(int mouseX, int mouseY, int mouseButton) {
- super.mouseReleased(mouseX, mouseY, mouseButton);
-
- switch (currentPage) {
- case INVS:
- mouseReleasedInvs(mouseX, mouseY, mouseButton);
- break;
- case COLS:
- mouseReleasedCols(mouseX, mouseY, mouseButton);
- break;
- case PETS:
- mouseReleasedPets(mouseX, mouseY, mouseButton);
- }
- }
-
- protected void mouseClickedDung(int mouseX, int mouseY, int mouseButton) {
- if(mouseX >= guiLeft+50 && mouseX <= guiLeft+70 &&
- mouseY >= guiTop+54 && mouseY <= guiTop+64) {
- dungeonLevelTextField.mouseClicked(mouseX, mouseY, mouseButton);
- } else {
- dungeonLevelTextField.otherComponentClick();
- }
-
- int cW = fontRendererObj.getStringWidth("Calculate");
- if(mouseX >= guiLeft+23+110-17-cW && mouseX <= guiLeft+23+110-17 &&
- mouseY >= guiTop+55 && mouseY <= guiTop+65) {
- calculateFloorLevelXP();
- }
-
- int y = guiTop+142;
-
- if(mouseY >= y-2 && mouseY <= y+9) {
- for(int i=1; i<=7; i++) {
- int w = fontRendererObj.getStringWidth(""+i);
-
- int x = guiLeft+23+110*i/8-w/2;
-
- if(mouseX >= x-2 && mouseX <= x+7) {
- floorTime = i;
- return;
- }
- }
- }
- if(mouseX >= guiLeft-29 && mouseX <= guiLeft){
- if(mouseY >= guiTop && mouseY<= guiTop+28){
- onMasterMode = false;
- return;
- } else if(mouseY+28 >= guiTop && mouseY<= guiTop+28*2){
- onMasterMode = true;
- return;
- }
- }
- }
-
- protected void keyTypedDung(char typedChar, int keyCode) {
- dungeonLevelTextField.keyTyped(typedChar, keyCode);
- }
-
- protected void keyTypedInvs(char typedChar, int keyCode) throws IOException {
- switch(keyCode) {
- case Keyboard.KEY_1:
- case Keyboard.KEY_NUMPAD1:
- selectedInventory = "inv_contents"; break;
- case Keyboard.KEY_2:
- case Keyboard.KEY_NUMPAD2:
- selectedInventory = "ender_chest_contents"; break;
- case Keyboard.KEY_3:
- case Keyboard.KEY_NUMPAD3:
- selectedInventory = "backpack_contents"; break;
- case Keyboard.KEY_4:
- case Keyboard.KEY_NUMPAD4:
- selectedInventory = "personal_vault_contents"; break;
- case Keyboard.KEY_5:
- case Keyboard.KEY_NUMPAD5:
- selectedInventory = "talisman_bag"; break;
- case Keyboard.KEY_6:
- case Keyboard.KEY_NUMPAD6:
- selectedInventory = "wardrobe_contents"; break;
- case Keyboard.KEY_7:
- case Keyboard.KEY_NUMPAD7:
- selectedInventory = "fishing_bag"; break;
- case Keyboard.KEY_8:
- case Keyboard.KEY_NUMPAD8:
- selectedInventory = "potion_bag"; break;
-
- }
- Utils.playPressSound();
- }
-
- protected void keyTypedCols(char typedChar, int keyCode) throws IOException {
- ItemStack stack = null;
- Iterator<ItemStack> items = ProfileViewer.getCollectionCatToCollectionMap().keySet().iterator();
- switch(keyCode) {
- case Keyboard.KEY_5:
- case Keyboard.KEY_NUMPAD5:
- stack = items.next();
- case Keyboard.KEY_4:
- case Keyboard.KEY_NUMPAD4:
- stack = items.next();
- case Keyboard.KEY_3:
- case Keyboard.KEY_NUMPAD3:
- stack = items.next();
- case Keyboard.KEY_2:
- case Keyboard.KEY_NUMPAD2:
- stack = items.next();
- case Keyboard.KEY_1:
- case Keyboard.KEY_NUMPAD1:
- stack = items.next();
- }
- if(stack != null) {
- selectedCollectionCategory = stack;
- }
- Utils.playPressSound();
- }
-
- private void mouseReleasedPets(int mouseX, int mouseY, int mouseButton) {
- if(mouseY > guiTop+6 && mouseY < guiTop+22) {
- if(mouseX > guiLeft+100-15-12 && mouseX < guiLeft+100-20) {
- if(petsPage > 0) {
- petsPage--;
- }
- return;
- } else if(mouseX > guiLeft+100+15 && mouseX < guiLeft+100+20+12) {
- if(sortedPets != null && petsPage < Math.ceil(sortedPets.size()/20f)-1) {
- petsPage++;
- }
- return;
- }
- }
- }
-
- private void mouseReleasedInvs(int mouseX, int mouseY, int mouseButton) {
- if(mouseButton == 0) {
- int i=0;
- for(Map.Entry<String, ItemStack> entry : invNameToDisplayMap.entrySet()) {
- int xIndex = i%3;
- int yIndex = i/3;
-
- int x = guiLeft+19+34*xIndex;
- int y = guiTop+26+34*yIndex;
-
- if(mouseX >= x && mouseX <= x+16) {
- if(mouseY >= y && mouseY <= y+16) {
- if(selectedInventory != entry.getKey()) Utils.playPressSound();
- selectedInventory = entry.getKey();
- return;
- }
- }
-
- i++;
- }
-
- JsonObject inventoryInfo = profile.getInventoryInfo(profileId);
- if(inventoryInfo == null) return;
-
- ItemStack[][][] inventories = getItemsForInventory(inventoryInfo, selectedInventory);
- if(currentInventoryIndex >= inventories.length) currentInventoryIndex = inventories.length-1;
- if(currentInventoryIndex < 0) currentInventoryIndex = 0;
-
- ItemStack[][] inventory = inventories[currentInventoryIndex];
- if(inventory == null) return;
-
- int inventoryRows = inventory.length;
- int invSizeY = inventoryRows*18+17+7;
-
- int y = guiTop+101-invSizeY/2;
- int staticSelectorHeight = guiTop+177;
-
- if(mouseY > staticSelectorHeight && mouseY < staticSelectorHeight+16) {
- if(mouseX > guiLeft+320-12 && mouseX < guiLeft+320+12) {
- if(mouseX < guiLeft+320) {
- currentInventoryIndex--;
- } else {
- currentInventoryIndex++;
- }
- }
- }
- }
- }
-
- private ItemStack selectedCollectionCategory = null;
-
- private void mouseReleasedCols(int mouseX, int mouseY, int mouseButton) {
- int collectionCatSize = ProfileViewer.getCollectionCatToCollectionMap().size();
- int collectionCatYSize = (int)(162f/(collectionCatSize-1+0.0000001f));
- int yIndex = 0;
- for(ItemStack stack : ProfileViewer.getCollectionCatToCollectionMap().keySet()) {
- if(mouseX > guiLeft+7 && mouseX < guiLeft+7+20) {
- if(mouseY > guiTop+10+collectionCatYSize*yIndex && mouseY < guiTop+10+collectionCatYSize*yIndex+20) {
- selectedCollectionCategory = stack;
- Utils.playPressSound();
- return;
- }
- }
- yIndex++;
- }
- }
-
- private static final ItemStack DEADBUSH = new ItemStack(Item.getItemFromBlock(Blocks.deadbush));
- private static final ItemStack[] BOSS_HEADS = new ItemStack[7];
-
- private HashMap<String, ProfileViewer.Level> levelObjCatas = new HashMap<>();
- private HashMap<String, HashMap<String, ProfileViewer.Level>> levelObjClasseses = new HashMap<>();
-
- private GuiElementTextField dungeonLevelTextField = new GuiElementTextField("", GuiElementTextField.SCALE_TEXT);
-
- private static final String[] dungSkillsName = {"Healer", "Mage", "Berserk", "Archer", "Tank"};
- private static final ItemStack[] dungSkillsStack = { new ItemStack(Items.potionitem, 1, 16389),
- new ItemStack(Items.blaze_rod), new ItemStack(Items.iron_sword), new ItemStack(Items.bow), new ItemStack(Items.leather_chestplate)};
- private static final String[] bossFloorArr = {"Bonzo", "Scarf", "Professor", "Thorn", "Livid", "Sadan", "Necron"};
- private static final String[] bossFloorHeads = {
- "12716ecbf5b8da00b05f316ec6af61e8bd02805b21eb8e440151468dc656549c",
- "7de7bbbdf22bfe17980d4e20687e386f11d59ee1db6f8b4762391b79a5ac532d",
- "9971cee8b833a62fc2a612f3503437fdf93cad692d216b8cf90bbb0538c47dd8",
- "8b6a72138d69fbbd2fea3fa251cabd87152e4f1c97e5f986bf685571db3cc0",
- "c1007c5b7114abec734206d4fc613da4f3a0e99f71ff949cedadc99079135a0b",
- "fa06cb0c471c1c9bc169af270cd466ea701946776056e472ecdaeb49f0f4a4dc",
- "a435164c05cea299a3f016bbbed05706ebb720dac912ce4351c2296626aecd9a"
- };
- private static int floorTime = 7;
- private int floorLevelTo = -1;
- private int floorLevelToXP = -1;
-
- private void calculateFloorLevelXP() {
- JsonObject leveling = Constants.LEVELING;
- if(leveling == null) return;
- ProfileViewer.Level levelObjCata = levelObjCatas.get(profileId);
- if(levelObjCata == null) return;
-
- try {
- dungeonLevelTextField.setCustomBorderColour(0xffffffff);
- floorLevelTo = Integer.parseInt(dungeonLevelTextField.getText());
-
- JsonArray levelingArray = Utils.getElement(leveling, "catacombs").getAsJsonArray();
-
- float remaining = -((levelObjCata.level % 1) * levelObjCata.maxXpForLevel);
-
- for(int level=0; level<Math.min(floorLevelTo, levelingArray.size()); level++) {
- if(level < Math.floor(levelObjCata.level)) {
- continue;
- }
- remaining += levelingArray.get(level).getAsFloat();
- }
-
- if(remaining < 0) {
- remaining = 0;
- }
- floorLevelToXP = (int) remaining;
- } catch(Exception e) {
- dungeonLevelTextField.setCustomBorderColour(0xffff0000);
- }
- }
-
- private static final LinkedHashMap<String, ItemStack> dungeonsModeIcons = new LinkedHashMap<>();
- static {
- dungeonsModeIcons.put("catacombs", Utils.editItemStackInfo(NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("DUNGEON_STONE")),EnumChatFormatting.GRAY+"Normal Mode", true));
- dungeonsModeIcons.put("master_catacombs", Utils.editItemStackInfo(NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("MASTER_SKULL_TIER_7")),EnumChatFormatting.GRAY+"Master Mode", true));
-
- }
-
- private void drawDungPage(int mouseX, int mouseY, float partialTicks) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_dung);
- Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST);
-
- JsonObject hypixelInfo = profile.getHypixelProfile();
- if(hypixelInfo == null) return;
- JsonObject profileInfo = profile.getProfileInformation(profileId);
- if(profileInfo == null) return;
-
- JsonObject leveling = Constants.LEVELING;
- if(leveling == null) return;
-
- int sectionWidth = 110;
-
- String dungeonString = onMasterMode?"master_catacombs":"catacombs";
-
- //Utils.drawStringCentered((onMasterMode?"Master Mode":"Catacombs"),fontRendererObj,(guiLeft+sizeX/2), guiTop+10, true, 0xffff0000);
- Utils.renderShadowedString(EnumChatFormatting.RED+(onMasterMode?"Master Mode":"Catacombs"),
- (guiLeft+sizeX/2), guiTop+5, sectionWidth);
-
-
- ProfileViewer.Level levelObjCata = levelObjCatas.get(profileId);
- //Catacombs level thingy
- {
- if(levelObjCata == null) {
- float cataXp = Utils.getElementAsFloat(Utils.getElement(profileInfo,
- "dungeons.dungeon_types.catacombs.experience"), 0);
- levelObjCata = ProfileViewer.getLevel(Utils.getElement(leveling, "catacombs").getAsJsonArray(),
- cataXp, 50, false);
- levelObjCatas.put(profileId, levelObjCata);
- }
-
- String skillName = EnumChatFormatting.RED+"Catacombs";
- float level = levelObjCata.level;
- int levelFloored = (int)Math.floor(level);
-
- if(floorLevelTo == -1 && levelFloored >= 0) {
- dungeonLevelTextField.setText(""+(levelFloored+1));
- calculateFloorLevelXP();
- }
-
- int x = guiLeft+23;
- int y = guiTop+25;
-
- renderXpBar(skillName, DEADBUSH, x, y, sectionWidth, levelObjCata, mouseX, mouseY);
-
- Utils.renderAlignedString(EnumChatFormatting.YELLOW+"Until Cata "+floorLevelTo+": ",
- EnumChatFormatting.WHITE.toString()+shortNumberFormat(floorLevelToXP, 0), x, y+16, sectionWidth);
-
- if(mouseX > x && mouseX < x + sectionWidth &&
- mouseY > y+16 && mouseY < y+24) {
- float xpF5 = 2000;
- float xpF6 = 4000;
- float xpF7 = 20000;
- if(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
- xpF5 *= 1.1;
- xpF6 *= 1.1;
- xpF7 *= 1.1;
- }
-
- long runsF5 = (int)Math.ceil(floorLevelToXP/xpF5);
- long runsF6 = (int)Math.ceil(floorLevelToXP/xpF6);
- long runsF7 = (int)Math.ceil(floorLevelToXP/xpF7);
-
- float timeF5 = Utils.getElementAsFloat(Utils.getElement(profileInfo,
- "dungeons.dungeon_types.catacombs.fastest_time_s_plus.5"), 0);
- float timeF6 = Utils.getElementAsFloat(Utils.getElement(profileInfo,
- "dungeons.dungeon_types.catacombs.fastest_time_s_plus.6"), 0);
- float timeF7 = Utils.getElementAsFloat(Utils.getElement(profileInfo,
- "dungeons.dungeon_types.catacombs.fastest_time_s_plus.7"), 0);
-
- tooltipToDisplay = Lists.newArrayList(
- String.format("# F5 Runs (%s xp) : %d", shortNumberFormat(xpF5, 0), runsF5),
- String.format("# F6 Runs (%s xp) : %d", shortNumberFormat(xpF6, 0), runsF6),
- String.format("# F7 Runs (%s xp) : %d", shortNumberFormat(xpF7, 0), runsF7),
- ""
- );
- boolean hasTime = false;
- if(timeF5 > 1000) {
- tooltipToDisplay.add(String.format("Expected Time (F5) : %s", Utils.prettyTime(runsF5*(long)(timeF5*1.2))));
- hasTime = true;
- }
- if(timeF6 > 1000) {
- tooltipToDisplay.add(String.format("Expected Time (F6) : %s", Utils.prettyTime(runsF6*(long)(timeF6*1.2))));
- hasTime = true;
- }
- if(timeF7 > 1000) {
- tooltipToDisplay.add(String.format("Expected Time (F7) : %s", Utils.prettyTime(runsF7*(long)(timeF7*1.2))));
- hasTime = true;
- }
- if(hasTime) {
- tooltipToDisplay.add("");
- }
- if(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
- tooltipToDisplay.add("[Hold "+EnumChatFormatting.YELLOW+"SHIFT"+EnumChatFormatting.GRAY+" to show without Expert Ring]");
- }
- if(Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) {
- if(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) tooltipToDisplay.add("");
- tooltipToDisplay.add("Number of runs is calculated as [Remaining XP]/[XP per Run].");
- tooltipToDisplay.add("The [XP per Run] is the average xp gained from an S+ run");
- tooltipToDisplay.add("The "+EnumChatFormatting.DARK_PURPLE+"Catacombs Expert Ring"+EnumChatFormatting.GRAY+
- " is assumed to be used, unless "+EnumChatFormatting.YELLOW+"SHIFT"+EnumChatFormatting.GRAY+" is held.");
- tooltipToDisplay.add("[Time per run] is calculated using fastestSPlus x 120%");
- } else {
- tooltipToDisplay.add("[Hold "+EnumChatFormatting.YELLOW+"CTRL"+EnumChatFormatting.GRAY+" to see details]");
- }
- }
-
- dungeonLevelTextField.setSize(20, 10);
- dungeonLevelTextField.render(x+22, y+29);
- int calcLen = fontRendererObj.getStringWidth("Calculate");
- Utils.renderShadowedString(EnumChatFormatting.WHITE+"Calculate", x+sectionWidth-17-calcLen/2f,
- y+30, 100);
-
- //Random stats
-
- float secrets = Utils.getElementAsFloat(Utils.getElement(hypixelInfo,
- "achievements.skyblock_treasure_hunter"), 0);
- float totalRuns = 0;
- float totalRunsF = 0;
- float totalRunsF5 = 0;
- for(int i=1; i<=7; i++) {
- float runs = Utils.getElementAsFloat(Utils.getElement(profileInfo,
- "dungeons.dungeon_types.catacombs.tier_completions."+i), 0);
- totalRunsF += runs;
- if(i >= 5) {
- totalRunsF5 += runs;
- }
- }
- float totalRunsM = 0;
- float totalRunsM5 = 0;
- for(int i=1; i<=7; i++) {
- float runs = Utils.getElementAsFloat(Utils.getElement(profileInfo,
- "dungeons.dungeon_types.master_catacombs.tier_completions."+i), 0);
- totalRunsM += runs;
- if(i >= 5) {
- totalRunsM5 += runs;
- }
- }
- totalRuns=totalRunsF+totalRunsM;
-
- float mobKills = 0;
- float mobKillsF = 0;
- float mobKillsF5 = 0;
- for(int i=1; i<=7; i++) {
- float kills = Utils.getElementAsFloat(Utils.getElement(profileInfo,
- "dungeons.dungeon_types.catacombs.mobs_killed."+i), 0);
- mobKillsF += kills;
- if(i >= 5) {
- mobKillsF5 += kills;
- }
- }
- float mobKillsM = 0;
- float mobKillsM5 = 0;
- for(int i=1; i<=7; i++) {
- float kills = Utils.getElementAsFloat(Utils.getElement(profileInfo,
- "dungeons.dungeon_types.master_catacombs.mobs_killed."+i), 0);
- mobKillsM += kills;
- if(i >= 5) {
- mobKillsM5 += kills;
- }
- }
- mobKills = mobKillsF+mobKillsM;
-
- int miscTopY = y+55;
-
- Utils.renderAlignedString(EnumChatFormatting.YELLOW+"Total Runs "+(onMasterMode?"M":"F"),
- EnumChatFormatting.WHITE.toString()+((int)(onMasterMode?totalRunsM:totalRunsF)), x, miscTopY, sectionWidth);
- Utils.renderAlignedString(EnumChatFormatting.YELLOW+"Total Runs ("+(onMasterMode?"M":"F")+ "5-7) ",
- EnumChatFormatting.WHITE.toString()+((int)(onMasterMode?totalRunsM5:totalRunsF5)), x, miscTopY+10, sectionWidth);
- Utils.renderAlignedString(EnumChatFormatting.YELLOW+"Secrets (Total) ",
- EnumChatFormatting.WHITE.toString()+shortNumberFormat(secrets, 0), x, miscTopY+20, sectionWidth);
- Utils.renderAlignedString(EnumChatFormatting.YELLOW+"Secrets (/Run) ",
- EnumChatFormatting.WHITE.toString()+(Math.round(secrets/Math.max(1, totalRuns)*100)/100f), x, miscTopY+30, sectionWidth);
- Utils.renderAlignedString(EnumChatFormatting.YELLOW+"Mob Kills (Total) ",
- EnumChatFormatting.WHITE.toString()+shortNumberFormat(mobKills, 0), x, miscTopY+40, sectionWidth);
-
- int y3 = y+117;
-
- for(int i=1; i<=7; i++) {
- int w = fontRendererObj.getStringWidth(""+i);
-
- int bx = x+sectionWidth*i/8-w/2;
-
- boolean invert = i == floorTime;
- float uMin = 20/256f;
- float uMax = 29/256f;
- float vMin = 0/256f;
- float vMax = 11/256f;
-
- GlStateManager.color(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements);
- Utils.drawTexturedRect(bx-2, y3-2, 9, 11,
- invert ? uMax : uMin, invert ? uMin : uMax,
- invert ? vMax : vMin, invert ? vMin : vMax, GL11.GL_NEAREST);
-
- Utils.renderShadowedString(EnumChatFormatting.WHITE.toString()+i, bx+w/2, y3, 10);
- }
-
- float timeNorm = Utils.getElementAsFloat(Utils.getElement(profileInfo,
- "dungeons.dungeon_types."+dungeonString+".fastest_time."+floorTime), 0);
- float timeS = Utils.getElementAsFloat(Utils.getElement(profileInfo,
- "dungeons.dungeon_types."+dungeonString+".fastest_time_s."+floorTime), 0);
- float timeSPLUS = Utils.getElementAsFloat(Utils.getElement(profileInfo,
- "dungeons.dungeon_types."+dungeonString+".fastest_time_s_plus."+floorTime), 0);
- String timeNormStr = timeNorm <= 0 ? "N/A" : Utils.prettyTime((long)timeNorm);
- String timeSStr = timeS <= 0 ? "N/A" : Utils.prettyTime((long)timeS);
- String timeSPlusStr = timeSPLUS <= 0 ? "N/A" : Utils.prettyTime((long)timeSPLUS);
- Utils.renderAlignedString(EnumChatFormatting.YELLOW+"Floor "+floorTime+" ",
- EnumChatFormatting.WHITE.toString()+timeNormStr, x, y3+10, sectionWidth);
- Utils.renderAlignedString(EnumChatFormatting.YELLOW+"Floor "+floorTime+" S",
- EnumChatFormatting.WHITE.toString()+timeSStr, x, y3+20, sectionWidth);
- Utils.renderAlignedString(EnumChatFormatting.YELLOW+"Floor "+floorTime+" S+",
- EnumChatFormatting.WHITE.toString()+timeSPlusStr, x, y3+30, sectionWidth);
- }
-
- //Completions
- {
- int x = guiLeft+161;
- int y = guiTop+27;
-
- Utils.renderShadowedString(EnumChatFormatting.RED+"Boss Collections",
- x+sectionWidth/2, y, sectionWidth);
- for(int i=1; i<=7; i++) {
- float compl = Utils.getElementAsFloat(Utils.getElement(profileInfo,
- "dungeons.dungeon_types."+dungeonString+".tier_completions."+i), 0);
-
- if(BOSS_HEADS[i-1] == null) {
- String textureLink = bossFloorHeads[i-1];
-
- String b64Decoded = "{\"textures\":{\"SKIN\":{\"url\":\"http://textures.minecraft.net/texture/" + textureLink + "\"}}}";
- String b64Encoded = new String(Base64.getEncoder().encode(b64Decoded.getBytes()));
-
- ItemStack stack = new ItemStack(Items.skull, 1, 3);
- NBTTagCompound nbt = new NBTTagCompound();
- NBTTagCompound skullOwner = new NBTTagCompound();
- NBTTagCompound properties = new NBTTagCompound();
- NBTTagList textures = new NBTTagList();
- NBTTagCompound textures_0 = new NBTTagCompound();
-
- String uuid = UUID.nameUUIDFromBytes(b64Encoded.getBytes()).toString();
- skullOwner.setString("Id", uuid);
- skullOwner.setString("Name", uuid);
-
- textures_0.setString("Value", b64Encoded);
- textures.appendTag(textures_0);
-
- properties.setTag("textures", textures);
- skullOwner.setTag("Properties", properties);
- nbt.setTag("SkullOwner", skullOwner);
- stack.setTagCompound(nbt);
-
- BOSS_HEADS[i-1] = stack;
- }
-
- GlStateManager.pushMatrix();
- GlStateManager.translate(x-4, y+10+20*(i-1), 0);
- GlStateManager.scale(1.3f, 1.3f, 1);
- Utils.drawItemStack(BOSS_HEADS[i-1], 0, 0);
- GlStateManager.popMatrix();
-
- Utils.renderAlignedString(String.format(EnumChatFormatting.YELLOW+"%s ("+(onMasterMode?"M":"F")+"%d) ", bossFloorArr[i-1], i),
- EnumChatFormatting.WHITE.toString()+(int)compl,
- x+16, y+18+20*(i-1), sectionWidth-15);
-
- }
- }
-
- //Skills
- {
- int x = guiLeft+298;
- int y = guiTop+27;
-
- //Gui.drawRect(x, y, x+120, y+147, 0xffffffff);
-
- Utils.renderShadowedString(EnumChatFormatting.DARK_PURPLE+"Class Levels",
- x+sectionWidth/2, y, sectionWidth);
-
- JsonElement activeClassElement = Utils.getElement(profileInfo, "dungeons.selected_dungeon_class");
- String activeClass = null;
- if(activeClassElement instanceof JsonPrimitive && ((JsonPrimitive) activeClassElement).isString()) {
- activeClass = activeClassElement.getAsString();
- }
-
- for(int i=0; i<dungSkillsName.length; i++) {
- String skillName = dungSkillsName[i];
-
-
- HashMap<String, ProfileViewer.Level> levelObjClasses = levelObjClasseses.computeIfAbsent(profileId, k->new HashMap<>());
- if(!levelObjClasses.containsKey(skillName)) {
- float cataXp = Utils.getElementAsFloat(Utils.getElement(profileInfo,
- "dungeons.player_classes."+skillName.toLowerCase()+".experience"), 0);
- ProfileViewer.Level levelObj = ProfileViewer.getLevel(Utils.getElement(leveling, "catacombs").getAsJsonArray(),
- cataXp, 50, false);
- levelObjClasses.put(skillName, levelObj);
- }
-
- String colour = EnumChatFormatting.WHITE.toString();
- if(skillName.toLowerCase().equals(activeClass)) {
- colour = EnumChatFormatting.GREEN.toString();
- }
-
- ProfileViewer.Level levelObj = levelObjClasses.get(skillName);
-
- renderXpBar(colour+skillName, dungSkillsStack[i], x, y+20+29*i, sectionWidth, levelObj, mouseX, mouseY);
- }
- }
-
- drawSideButtons();
-
- //drawSideButton(0, dungeonsModeIcons.get("catacombs"), true);
- //drawSideButton(1, dungeonsModeIcons.get("master_catacombs"), true);
- //drawSideButton(1, dungeonsModeIcons.get("catacombs"), true);
- //drawSideButton(2, dungeonsModeIcons.get("catacombs"), false);
-
-
- }
-
- private boolean onMasterMode = false;
-
- //TODO: improve this shit
- private void drawSideButtons(){
- // GlStateManager.pushMatrix();
- GlStateManager.enableDepth();
- GlStateManager.translate(0, 0, 5);
- if(onMasterMode){
- drawSideButton(1, dungeonsModeIcons.get("master_catacombs"), true);
- } else {
- drawSideButton(0, dungeonsModeIcons.get("catacombs"), true);
- }
- GlStateManager.translate(0, 0, -3);
-
- GlStateManager.translate(0, 0, -2);
- if(!onMasterMode){
- drawSideButton(1, dungeonsModeIcons.get("master_catacombs"), false);
- } else {
- drawSideButton(0, dungeonsModeIcons.get("catacombs"), false);
- }
- GlStateManager.disableDepth();
- //GlStateManager.popMatrix();
- }
-
-
-
-
- private void drawSideButton(int yIndex, ItemStack itemStack, boolean pressed){
- GlStateManager.disableLighting();
- GlStateManager.enableBlend();
- GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
- GlStateManager.enableAlpha();
- GlStateManager.alphaFunc(516, 0.1F);
-
- int x = guiLeft-28;
- int y = guiTop+yIndex*28;
-
- float uMin = 193/256f;
- float uMax = 223/256f;
- float vMin = 200/256f;
- float vMax = 228/256f;
- if(pressed) {
- uMin = 224/256f;
- uMax = 1f;
-
-
- if(yIndex != 0) {
- vMin = 228/256f;
- vMax = 1f;
- }
-
- renderBlurredBackground(width, height, x+2, y+2, 30, 28-4);
- } else {
- renderBlurredBackground(width, height, x+2, y+2, 28-2, 28-4);
- }
-
- GlStateManager.disableLighting();
- GlStateManager.enableBlend();
- GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
- GlStateManager.enableAlpha();
- GlStateManager.alphaFunc(516, 0.1F);
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements);
-
- Utils.drawTexturedRect(x, y, pressed?32:28, 28, uMin, uMax, vMin, vMax, GL11.GL_NEAREST);
-
- GlStateManager.enableDepth();
- Utils.drawItemStack(itemStack, x+8, y+7);
-
-
-
-
- }
-
- private void renderXpBar(String skillName, ItemStack stack, int x, int y, int xSize, ProfileViewer.Level levelObj, int mouseX, int mouseY) {
- float level = levelObj.level;
- int levelFloored = (int)Math.floor(level);
-
- Utils.renderAlignedString(skillName, EnumChatFormatting.WHITE.toString()+levelFloored, x+14, y-4, xSize-20);
-
- if(levelObj.maxed) {
- renderGoldBar(x, y+6, xSize);
- } else {
- renderBar(x, y+6, xSize, level%1);
- }
-
- if(mouseX > x && mouseX < x+120) {
- if(mouseY > y-4 && mouseY < y+13) {
- String levelStr;
- if(levelObj.maxed) {
- levelStr = EnumChatFormatting.GOLD+"MAXED!";
- } else {
- int maxXp = (int)levelObj.maxXpForLevel;
- levelStr = EnumChatFormatting.DARK_PURPLE.toString() + shortNumberFormat(Math.round((level%1)*maxXp),
- 0) + "/" + shortNumberFormat(maxXp, 0);
- }
-
- tooltipToDisplay = Utils.createList(levelStr);
- }
- }
-
- GL11.glTranslatef((x), (y-6f), 0);
- GL11.glScalef(0.7f, 0.7f, 1);
- Utils.drawItemStackLinear(stack, 0, 0);
- GL11.glScalef(1/0.7f, 1/0.7f, 1);
- GL11.glTranslatef(-(x), -(y-6f), 0);
- }
-
- public static class PetLevel {
- public float level;
- public float currentLevelRequirement;
- public float maxXP;
- public float levelPercentage;
- public float levelXp;
- public float totalXp;
- }
-
- private static JsonObject getPetInfo(String pet_name, String rarity){
- JsonObject petInfo = new JsonObject();
- //System.out.println(pet_name);
- //System.out.println(rarity);
-
- if(Constants.PETS.has("custom_pet_leveling") && Constants.PETS.getAsJsonObject("custom_pet_leveling").has(pet_name)){
- JsonObject pet = Constants.PETS.getAsJsonObject("custom_pet_leveling").getAsJsonObject(pet_name);
- if(pet.has("type") && pet.has("pet_levels")){
- int type = pet.get("type").getAsInt();
- switch (type) {
- case 1:
- JsonArray defaultLevels = Constants.PETS.getAsJsonArray("pet_levels");
- defaultLevels.addAll(pet.getAsJsonArray("pet_levels"));
- petInfo.add("pet_levels", Constants.PETS.getAsJsonArray("pet_levels"));
- break;
- case 2:
- petInfo.add("pet_levels", pet.getAsJsonArray("pet_levels"));
- break;
- default:
- petInfo.add("pet_levels", Constants.PETS.getAsJsonArray("pet_levels"));
- break;
- }
- } else {
- petInfo.add("pet_levels", Constants.PETS.getAsJsonArray("pet_levels"));
- }
- if(pet.has("max_level")){
- petInfo.add("max_level", pet.get("max_level"));
- } else {
- petInfo.add("max_level", new JsonPrimitive(100));
- }
-
- if(pet.has("pet_rarity_offset")){
- petInfo.add("offset", pet.get("pet_rarity_offset"));
- } else {
- petInfo.add("offset", Constants.PETS.getAsJsonObject("pet_rarity_offset").get(rarity));
- }
-
- } else {
- //System.out.println("Default Path");
- petInfo.add("offset", Constants.PETS.getAsJsonObject("pet_rarity_offset").get(rarity));
- petInfo.add("max_level", new JsonPrimitive(100));
- petInfo.add("pet_levels", Constants.PETS.getAsJsonArray("pet_levels"));
- }
-
-
- return petInfo;
-
- }
-
- public static PetLevel getPetLevel(String pet_name, String rarity, float exp) {
- JsonObject petInfo = getPetInfo(pet_name, rarity);
- int offset = petInfo.get("offset").getAsInt();
- int maxPetLevel = petInfo.get("max_level").getAsInt();
- JsonArray levels = petInfo.getAsJsonArray("pet_levels");
-
- float xpTotal = 0;
- float level = 1;
- float currentLevelRequirement = 0;
- float currentLevelProgress = 0;
-
- boolean addLevel = true;
-
- for(int i=offset; i<offset+maxPetLevel-1; i++) {
- if(addLevel) {
- currentLevelRequirement = levels.get(i).getAsFloat();
- xpTotal += currentLevelRequirement;
- if(xpTotal > exp) {
- currentLevelProgress = (exp-(xpTotal-currentLevelRequirement));
- addLevel = false;
- } else {
- level += 1;
- }
- } else {
-
- xpTotal += levels.get(i).getAsFloat();
-
- }
- }
-
- level += currentLevelProgress/currentLevelRequirement;
- if(level <= 0) {
- level = 1;
- } else if(level > maxPetLevel) {
- level = maxPetLevel;
- }
- PetLevel levelObj = new PetLevel();
- levelObj.level = level;
- levelObj.currentLevelRequirement = currentLevelRequirement;
- levelObj.maxXP = xpTotal;
- levelObj.levelPercentage = currentLevelProgress/currentLevelRequirement;
- levelObj.levelXp = currentLevelProgress;
- levelObj.totalXp = exp;
- return levelObj;
- }
-
- public static final HashMap<String, HashMap<String, Float>> PET_STAT_BOOSTS = new HashMap<>();
- static {
- HashMap<String, Float> bigTeeth = new HashMap<>();
- bigTeeth.put("CRIT_CHANCE", 5f);
- PET_STAT_BOOSTS.put("PET_ITEM_BIG_TEETH_COMMON", bigTeeth);
-
- HashMap<String, Float> hardenedScales = new HashMap<>();
- hardenedScales.put("DEFENCE", 25f);
- PET_STAT_BOOSTS.put("PET_ITEM_HARDENED_SCALES_UNCOMMON", hardenedScales);
-
- HashMap<String, Float> luckyClover = new HashMap<>();
- luckyClover.put("MAGIC_FIND", 7f);
- PET_STAT_BOOSTS.put("PET_ITEM_LUCKY_CLOVER", luckyClover);
-
- HashMap<String, Float> sharpenedClaws = new HashMap<>();
- sharpenedClaws.put("CRIT_DAMAGE", 15f);
- PET_STAT_BOOSTS.put("PET_ITEM_SHARPENED_CLAWS_UNCOMMON", sharpenedClaws);
- }
- public static final HashMap<String, HashMap<String, Float>> PET_STAT_BOOSTS_MULT = new HashMap<>();
- static {
- HashMap<String, Float> ironClaws = new HashMap<>();
- ironClaws.put("CRIT_DAMAGE", 1.4f);
- ironClaws.put("CRIT_CHANCE", 1.4f);
- PET_STAT_BOOSTS_MULT.put("PET_ITEM_IRON_CLAWS_COMMON", ironClaws);
-
- HashMap<String, Float> textbook = new HashMap<>();
- textbook.put("INTELLIGENCE", 2f);
- PET_STAT_BOOSTS_MULT.put("PET_ITEM_TEXTBOOK", textbook);
- }
-
- private int selectedPet = -1;
- private int petsPage = 0;
- private List<JsonObject> sortedPets = null;
- private List<ItemStack> sortedPetsStack = null;
- public static HashMap<String, String> MINION_RARITY_TO_NUM = new HashMap<>();
- static {
- MINION_RARITY_TO_NUM.put("COMMON", "0");
- MINION_RARITY_TO_NUM.put("UNCOMMON", "1");
- MINION_RARITY_TO_NUM.put("RARE", "2");
- MINION_RARITY_TO_NUM.put("EPIC", "3");
- MINION_RARITY_TO_NUM.put("LEGENDARY", "4");
- MINION_RARITY_TO_NUM.put("MYTHIC", "5");
- }
- private void drawPetsPage(int mouseX, int mouseY, float partialTicks) {
- JsonObject petsInfo = profile.getPetsInfo(profileId);
- if(petsInfo == null) return;
- JsonObject petsJson = Constants.PETS;
- if(petsJson == null) return;
-
- String location = null;
- JsonObject status = profile.getPlayerStatus();
- if(status != null && status.has("mode")) {
- location = status.get("mode").getAsString();
- }
-
- backgroundRotation += (currentTime - lastTime)/400f;
- backgroundRotation %= 360;
-
- String panoramaIdentifier = "day";
- if(SBInfo.getInstance().currentTimeDate != null) {
- if(SBInfo.getInstance().currentTimeDate.getHours() <= 6 ||
- SBInfo.getInstance().currentTimeDate.getHours() >= 20) {
- panoramaIdentifier = "night";
- }
- }
-
- JsonArray pets = petsInfo.get("pets").getAsJsonArray();
- if(sortedPets == null) {
- sortedPets = new ArrayList<>();
- sortedPetsStack = new ArrayList<>();
- for(int i=0; i<pets.size(); i++) {
- sortedPets.add(pets.get(i).getAsJsonObject());
- }
- sortedPets.sort((pet1, pet2) -> {
- String tier1 = pet1.get("tier").getAsString();
- String tierNum1 = MINION_RARITY_TO_NUM.get(tier1);
- if(tierNum1 == null) return 1;
- int tierNum1I = Integer.parseInt(tierNum1);
- float exp1 = pet1.get("exp").getAsFloat();
-
- String tier2 = pet2.get("tier").getAsString();
- String tierNum2 = MINION_RARITY_TO_NUM.get(tier2);
- if(tierNum2 == null) return -1;
- int tierNum2I = Integer.parseInt(tierNum2);
- float exp2 = pet2.get("exp").getAsFloat();
-
- if(tierNum1I != tierNum2I) {
- return tierNum2I - tierNum1I;
- } else {
- return (int)(exp2 - exp1);
- }
- });
- for(JsonObject pet : sortedPets) {
- String petname = pet.get("type").getAsString();
- String tier = pet.get("tier").getAsString();
- String heldItem = Utils.getElementAsString(pet.get("heldItem"), null);
- String skin = Utils.getElementAsString(pet.get("skin"), null);
- int candy = pet.get("candyUsed").getAsInt();
- JsonObject heldItemJson = heldItem==null?null:NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(heldItem);
- String tierNum = MINION_RARITY_TO_NUM.get(tier);
- float exp = pet.get("exp").getAsFloat();
- if(tierNum == null) continue;
-
- if(pet.has("heldItem") && !pet.get("heldItem").isJsonNull() && pet.get("heldItem").getAsString().equals("PET_ITEM_TIER_BOOST")) {
- tierNum = ""+(Integer.parseInt(tierNum)+1);
- }
-
- PetLevel levelObj = GuiProfileViewer.getPetLevel(petname, tier, exp);
-
- float level = levelObj.level;
- float currentLevelRequirement = levelObj.currentLevelRequirement;
- float maxXP = levelObj.maxXP;
- pet.addProperty("level", level);
- pet.addProperty("currentLevelRequirement", currentLevelRequirement);
- pet.addProperty("maxXP", maxXP);
-
- JsonObject petItem = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(petname+";"+tierNum);
- if(petItem == null) continue;
-
- ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(petItem, false, false);
- HashMap<String, String> replacements = NotEnoughUpdates.INSTANCE.manager.getLoreReplacements(petname, tier, (int)Math.floor(level));
-
- if(heldItem != null) {
- HashMap<String, Float> petStatBoots = PET_STAT_BOOSTS.get(heldItem);
- HashMap<String, Float> petStatBootsMult = PET_STAT_BOOSTS_MULT.get(heldItem);
- if(petStatBoots != null) {
- for(Map.Entry<String, Float> entryBoost : petStatBoots.entrySet()) {
- try {
- float value = Float.parseFloat(replacements.get(entryBoost.getKey()));
- replacements.put(entryBoost.getKey(), String.valueOf((int)Math.floor(value+entryBoost.getValue())));
- } catch(Exception ignored) {}
- }
-
- }
- if(petStatBootsMult != null) {
- for(Map.Entry<String, Float> entryBoost : petStatBootsMult.entrySet()) {
- try {
- float value = Float.parseFloat(replacements.get(entryBoost.getKey()));
- replacements.put(entryBoost.getKey(), String.valueOf((int)Math.floor(value*entryBoost.getValue())));
- } catch(Exception ignored) {}
- }
- }
- }
-
- NBTTagCompound tag = stack.getTagCompound()==null?new NBTTagCompound():stack.getTagCompound();
- if(tag.hasKey("display", 10)) {
- NBTTagCompound display = tag.getCompoundTag("display");
- if(display.hasKey("Lore", 9)) {
- NBTTagList newLore = new NBTTagList();
- NBTTagList lore = display.getTagList("Lore", 8);
- HashMap<Integer, Integer> blankLocations = new HashMap<>();
- for(int j=0; j<lore.tagCount(); j++) {
- String line = lore.getStringTagAt(j);
- if(line.trim().isEmpty()) {
- blankLocations.put(blankLocations.size(), j);
- }
- for(Map.Entry<String, String> replacement : replacements.entrySet()) {
- line = line.replace("{"+replacement.getKey()+"}", replacement.getValue());
- }
- newLore.appendTag(new NBTTagString(line));
- }
- Integer secondLastBlank = blankLocations.get(blankLocations.size()-2);
- if(skin != null){
- JsonObject petSkin = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("PET_SKIN_" + skin);
- if(petSkin != null){
- try {
- NBTTagCompound nbt = JsonToNBT.getTagFromJson(petSkin.get("nbttag").getAsString());
- tag.setTag("SkullOwner", nbt.getTag("SkullOwner"));
- String name = petSkin.get("displayname").getAsString();
- if(name != null){
- name = Utils.cleanColour(name);
- newLore.set(0, new NBTTagString(newLore.get(0).toString().replace("\"" , "") + ", " + name));
- }
- } catch (NBTException e) {
- e.printStackTrace();
- }
- }
- }
- for (int i = 0; i < newLore.tagCount() ; i++){
- String cleaned = Utils.cleanColour(newLore.get(i).toString());
- if (cleaned.equals("\"Right-click to add this pet to\"")){
- newLore.removeTag(i + 1);
- newLore.removeTag(i);
- secondLastBlank = i - 1;
- break;
- }
- }
- NBTTagList temp = new NBTTagList();
- for (int i = 0; i < newLore.tagCount(); i++) {
- temp.appendTag(newLore.get(i));
- if(secondLastBlank != null && i == secondLastBlank) {
- if (heldItem != null) {
- temp.appendTag(new NBTTagString(EnumChatFormatting.GOLD + "Held Item: " + heldItemJson.get("displayname").getAsString()));
- int blanks = 0;
- JsonArray heldItemLore = heldItemJson.get("lore").getAsJsonArray();
- for (int k = 0; k < heldItemLore.size(); k++) {
- String heldItemLine = heldItemLore.get(k).getAsString();
- if (heldItemLine.trim().isEmpty()) {
- blanks++;
- } else if (blanks == 2) {
- temp.appendTag(new NBTTagString(heldItemLine));
- } else if (blanks > 2) {
- break;
- }
- }
- temp.appendTag(new NBTTagString());
- }
- if (candy != 0) {
- temp.appendTag(new NBTTagString(EnumChatFormatting.GREEN + "(" + candy + "/10) Pet Candy Used"));
- temp.appendTag(new NBTTagString());
- }
- temp.removeTag(temp.tagCount() - 1);
- }
- }
- newLore = temp;
- display.setTag("Lore", newLore);
- }
- if(display.hasKey("Name", 8)) {
- String displayName = display.getString("Name");
- for(Map.Entry<String, String> replacement : replacements.entrySet()) {
- displayName = displayName.replace("{"+replacement.getKey()+"}", replacement.getValue());
- }
- display.setTag("Name", new NBTTagString(displayName));
- }
- tag.setTag("display", display);
- }
- stack.setTagCompound(tag);
-
- sortedPetsStack.add(stack);
- }
- }
-
- Panorama.drawPanorama(-backgroundRotation, guiLeft+212, guiTop+44, 81, 108, -0.37f, 0.6f,
- getPanoramasForLocation(location==null?"dynamic":location, panoramaIdentifier));
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_pets);
- Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST);
-
- Utils.drawStringCentered(EnumChatFormatting.DARK_PURPLE+"Pets", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+100, guiTop+14, true, 4210752);
- GlStateManager.color(1, 1, 1, 1);
-
- JsonElement activePetElement = petsInfo.get("active_pet");
- if(selectedPet == -1 && activePetElement != null && activePetElement.isJsonObject()) {
- JsonObject active = activePetElement.getAsJsonObject();
- for(int i=0; i<sortedPets.size(); i++) {
- if(sortedPets.get(i) == active) {
- selectedPet = i;
- break;
- }
- }
- }
-
- boolean leftHovered = false;
- boolean rightHovered = false;
- if(Mouse.isButtonDown(0)) {
- if(mouseY > guiTop+6 && mouseY < guiTop+22) {
- if(mouseX > guiLeft+100-20-12 && mouseX < guiLeft+100-20) {
- leftHovered = true;
- } else if(mouseX > guiLeft+100+20 && mouseX < guiLeft+100+20+12) {
- rightHovered = true;
- }
- }
- }
- Minecraft.getMinecraft().getTextureManager().bindTexture(resource_packs);
-
- if(petsPage > 0) {
- Utils.drawTexturedRect(guiLeft+100-15-12, guiTop+6, 12, 16,
- 29/256f, 53/256f, !leftHovered?0:32/256f, !leftHovered?32/256f:64/256f, GL11.GL_NEAREST);
- }
- if(petsPage < Math.ceil(pets.size()/20f)-1) {
- Utils.drawTexturedRect( guiLeft+100+15, guiTop+6, 12, 16,
- 5/256f, 29/256f, !rightHovered?0:32/256f, !rightHovered?32/256f:64/256f, GL11.GL_NEAREST);
- }
-
- for(int i=petsPage*20; i<Math.min(petsPage*20+20, Math.min(sortedPetsStack.size(), sortedPets.size())); i++) {
- JsonObject pet = sortedPets.get(i);
- ItemStack stack = sortedPetsStack.get(i);
-
-
- if(pet != null) {
- {
- NBTTagCompound tag = stack.getTagCompound();
- tag.setBoolean("DisablePetExp", true);
- stack.setTagCompound(tag);
- }
- int xIndex = (i%20) % COLLS_XCOUNT;
- int yIndex = (i%20) / COLLS_XCOUNT;
-
- float x = 5 + COLLS_XPADDING + (COLLS_XPADDING + 20) * xIndex;
- float y = 7 + COLLS_YPADDING + (COLLS_YPADDING + 20) * yIndex;
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements);
- if(i == selectedPet) {
- GlStateManager.color(1, 185/255f, 0, 1);
- Utils.drawTexturedRect(guiLeft+x, guiTop+y, 20, 20,
- 0, 20/256f, 0, 20/256f, GL11.GL_NEAREST);
- } else {
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawTexturedRect(guiLeft+x, guiTop+y, 20, 20,
- 0, 20/256f, 0, 20/256f, GL11.GL_NEAREST);
- }
-
- Utils.drawItemStack(stack, guiLeft+(int)x+2, guiTop+(int)y+2);
-
- if(mouseX > guiLeft+x && mouseX < guiLeft+x+20) {
- if(mouseY > guiTop+y && mouseY < guiTop+y+20) {
- tooltipToDisplay = stack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
- }
- }
- }
- }
-
- if(selectedPet >= 0) {
- ItemStack petStack = sortedPetsStack.get(selectedPet);
- String display = petStack.getDisplayName();
- JsonObject pet = sortedPets.get(selectedPet);
-
- int x = guiLeft+280;
- float y = guiTop+67+15*(float)Math.sin(((currentTime-startTime)/800f)%(2*Math.PI));
-
- int displayLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(display);
- int halfDisplayLen = displayLen/2;
-
- GlStateManager.pushMatrix();
- GlStateManager.translate(x, y, 0);
-
- drawRect(-halfDisplayLen-1-28, -1, halfDisplayLen+1-28, 8, new Color(0, 0, 0, 100).getRGB());
-
- Minecraft.getMinecraft().fontRendererObj.drawString(display, -halfDisplayLen-28, 0, 0, true);
-
- GlStateManager.enableDepth();
- GlStateManager.translate(-55, 0, 0);
- GlStateManager.scale(3.5f, 3.5f, 1);
- Utils.drawItemStack(petStack, 0, 0);
- GlStateManager.popMatrix();
-
- float level = pet.get("level").getAsFloat();
- float currentLevelRequirement = pet.get("currentLevelRequirement").getAsFloat();
- float exp = pet.get("exp").getAsFloat();
- float maxXP = pet.get("maxXP").getAsFloat();
-
- String[] split = display.split("] ");
- String colouredName = split[split.length-1];
-
- Utils.renderAlignedString(colouredName, EnumChatFormatting.WHITE+"Level "+(int)Math.floor(level), guiLeft+319, guiTop+28, 98);
-
- //Utils.drawStringCenteredScaledMaxWidth(, Minecraft.getMinecraft().fontRendererObj, guiLeft+368, guiTop+28+4, true, 98, 0);
- //renderAlignedString(display, EnumChatFormatting.YELLOW+"[LVL "+Math.floor(level)+"]", guiLeft+319, guiTop+28, 98);
- renderBar(guiLeft+319, guiTop+38, 98, (float)Math.floor(level)/100f);
-
- Utils.renderAlignedString(EnumChatFormatting.YELLOW+"To Next LVL", EnumChatFormatting.WHITE.toString()+(int)(level%1*100)+"%", guiLeft+319, guiTop+46, 98);
- renderBar(guiLeft+319, guiTop+56, 98, level%1);
-
- Utils.renderAlignedString(EnumChatFormatting.YELLOW+"To Max LVL", EnumChatFormatting.WHITE.toString()+Math.min(100, (int)(exp/maxXP*100))+"%", guiLeft+319, guiTop+64, 98);
- renderBar(guiLeft+319, guiTop+74, 98, exp/maxXP);
-
- Utils.renderAlignedString(EnumChatFormatting.YELLOW+"Total XP", EnumChatFormatting.WHITE.toString()+shortNumberFormat(exp, 0), guiLeft+319, guiTop+125, 98);
- Utils.renderAlignedString(EnumChatFormatting.YELLOW+"Current LVL XP",
- EnumChatFormatting.WHITE.toString()+shortNumberFormat((level%1)*currentLevelRequirement, 0), guiLeft+319, guiTop+143, 98);
- Utils.renderAlignedString(EnumChatFormatting.YELLOW+"Required LVL XP", EnumChatFormatting.WHITE.toString()+shortNumberFormat(currentLevelRequirement, 0), guiLeft+319, guiTop+161, 98);
- }
- }
-
- private String[] romans = new String[]{"I","II","III","IV","V","VI","VII","VIII","IX","X","XI",
- "XII","XIII","XIV","XV","XVI","XVII","XIX","XX"};
-
- private final int COLLS_XCOUNT = 5;
- private final int COLLS_YCOUNT = 4;
- private final float COLLS_XPADDING = (190-COLLS_XCOUNT*20)/(float)(COLLS_XCOUNT+1);
- private final float COLLS_YPADDING = (202-COLLS_YCOUNT*20)/(float)(COLLS_YCOUNT+1);
-
- private void drawColsPage(int mouseX, int mouseY, float partialTicks) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_cols);
- Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST);
-
- JsonObject collectionInfo = profile.getCollectionInfo(profileId);
- if(collectionInfo == null) {
- Utils.drawStringCentered(EnumChatFormatting.RED+"Collection API not enabled!", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+134, guiTop+101, true, 0);
- return;
- }
- JsonObject resourceCollectionInfo = ProfileViewer.getResourceCollectionInformation();
- if(resourceCollectionInfo == null) return;
-
- int collectionCatSize = ProfileViewer.getCollectionCatToCollectionMap().size();
- int collectionCatYSize = (int)(162f/(collectionCatSize-1+0.0000001f));
- {
- int yIndex = 0;
- for(ItemStack stack : ProfileViewer.getCollectionCatToCollectionMap().keySet()) {
- if(selectedCollectionCategory == null) selectedCollectionCategory = stack;
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements);
- if(stack == selectedCollectionCategory) {
- Utils.drawTexturedRect(guiLeft+7, guiTop+10+collectionCatYSize*yIndex, 20, 20,
- 20/256f, 0, 20/256f, 0, GL11.GL_NEAREST);
- Utils.drawItemStackWithText(stack, guiLeft+10, guiTop+13+collectionCatYSize*yIndex, ""+(yIndex+1));
- } else {
- Utils.drawTexturedRect(guiLeft+7, guiTop+10+collectionCatYSize*yIndex, 20, 20,
- 0, 20/256f, 0, 20/256f, GL11.GL_NEAREST);
- Utils.drawItemStackWithText(stack, guiLeft+9, guiTop+12+collectionCatYSize*yIndex, ""+(yIndex+1));
- }
- yIndex++;
- }
- }
-
- Utils.drawStringCentered(selectedCollectionCategory.getDisplayName() + " Collections", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+134, guiTop+14, true, 4210752);
-
- JsonObject minionTiers = collectionInfo.get("minion_tiers").getAsJsonObject();
- JsonObject collectionTiers = collectionInfo.get("collection_tiers").getAsJsonObject();
- JsonObject maxAmounts = collectionInfo.get("max_amounts").getAsJsonObject();
- JsonObject totalAmounts = collectionInfo.get("total_amounts").getAsJsonObject();
- JsonObject personalAmounts = collectionInfo.get("personal_amounts").getAsJsonObject();
-
- List<String> collections = ProfileViewer.getCollectionCatToCollectionMap().get(selectedCollectionCategory);
- if(collections != null) {
- for(int i=0; i<collections.size(); i++) {
- String collection = collections.get(i);
- if(collection != null) {
- ItemStack collectionItem = ProfileViewer.getCollectionToCollectionDisplayMap().get(collection);
- if(collectionItem != null) {
- int xIndex = i%COLLS_XCOUNT;
- int yIndex = i/COLLS_XCOUNT;
-
- float x = 39+COLLS_XPADDING+(COLLS_XPADDING+20)*xIndex;
- float y = 7+COLLS_YPADDING+(COLLS_YPADDING+20)*yIndex;
-
- String tierString;
- int tier = (int)Utils.getElementAsFloat(collectionTiers.get(collection), 0);
- if(tier > 20 || tier < 0) {
- tierString = String.valueOf(tier);
- } else {
- tierString = romans[tier];
- }
- float amount = Utils.getElementAsFloat(totalAmounts.get(collection), 0);
- float maxAmount = Utils.getElementAsFloat(maxAmounts.get(collection), 0);
- Color color = new Color(128, 128, 128, 255);
- int tierStringColour = color.getRGB();
- float completedness = 0;
- if(maxAmount > 0) {
- completedness = amount/maxAmount;
- }
- completedness = Math.min(1, completedness);
- if(maxAmounts.has(collection) && completedness >= 1) {
- tierStringColour = new Color(255, 215, 0).getRGB();
- }
-
- GlStateManager.color(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements);
- Utils.drawTexturedRect(guiLeft+x, guiTop+y, 20, 20*(1-completedness),
- 0, 20/256f, 0, 20*(1-completedness)/256f, GL11.GL_NEAREST);
- GlStateManager.color(1, 185/255f, 0, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements);
- Utils.drawTexturedRect(guiLeft+x, guiTop+y+20*(1-completedness), 20, 20*(completedness),
- 0, 20/256f, 20*(1-completedness)/256f, 20/256f, GL11.GL_NEAREST);
- Utils.drawItemStack(collectionItem, guiLeft+(int)x+2, guiTop+(int)y+2);
-
- if(mouseX > guiLeft+(int)x+2 && mouseX < guiLeft+(int)x+18) {
- if(mouseY > guiTop+(int)y+2 && mouseY < guiTop+(int)y+18) {
- tooltipToDisplay = new ArrayList<>();
- tooltipToDisplay.add(collectionItem.getDisplayName() + " " +
- (completedness>=1?EnumChatFormatting.GOLD:EnumChatFormatting.GRAY) + tierString);
- tooltipToDisplay.add("Collected: " + numberFormat.format(Utils.getElementAsFloat(personalAmounts.get(collection), 0)));
- tooltipToDisplay.add("Total Collected: " + numberFormat.format(amount));
- }
- }
-
- GlStateManager.color(1, 1, 1, 1);
- if(tier >= 0) {
- Utils.drawStringCentered(tierString, fontRendererObj,
- guiLeft+x+10, guiTop+y-4, true,
- tierStringColour);
- }
-
- Utils.drawStringCentered(shortNumberFormat(amount, 0)+"", fontRendererObj,
- guiLeft+x+10, guiTop+y+26, true,
- color.getRGB());
- }
- }
- }
- }
-
- Utils.drawStringCentered(selectedCollectionCategory.getDisplayName() + " Minions", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+326, guiTop+14, true, 4210752);
-
-
- List<String> minions = ProfileViewer.getCollectionCatToMinionMap().get(selectedCollectionCategory);
- if(minions != null) {
- for(int i=0; i<minions.size(); i++) {
- String minion = minions.get(i);
- if(minion != null) {
- JsonObject misc = Constants.MISC;
- float MAX_MINION_TIER = Utils.getElementAsFloat(Utils.getElement(misc, "minions." + minion + "_GENERATOR"), 11);
-
- int tier = (int) Utils.getElementAsFloat(minionTiers.get(minion), 0);
- JsonObject minionJson;
- if (tier == 0) {
- minionJson = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(minion + "_GENERATOR_1");
- } else {
- minionJson = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(minion + "_GENERATOR_" + tier);
- }
-
- if(minionJson != null) {
- int xIndex = i%COLLS_XCOUNT;
- int yIndex = i/COLLS_XCOUNT;
-
- float x = 231+COLLS_XPADDING+(COLLS_XPADDING+20)*xIndex;
- float y = 7+COLLS_YPADDING+(COLLS_YPADDING+20)*yIndex;
-
- String tierString;
-
- if(tier-1 >= romans.length || tier-1 < 0) {
- tierString = String.valueOf(tier);
- } else {
- tierString = romans[tier-1];
- }
-
- Color color = new Color(128, 128, 128, 255);
- int tierStringColour = color.getRGB();
- float completedness = tier/MAX_MINION_TIER;
-
- completedness = Math.min(1, completedness);
- if(completedness >= 1) {
- tierStringColour = new Color(255, 215, 0).getRGB();
- }
-
- GlStateManager.color(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements);
- Utils.drawTexturedRect(guiLeft+x, guiTop+y, 20, 20*(1-completedness),
- 0, 20/256f, 0, 20*(1-completedness)/256f, GL11.GL_NEAREST);
- GlStateManager.color(1, 185/255f, 0, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements);
- Utils.drawTexturedRect(guiLeft+x, guiTop+y+20*(1-completedness), 20, 20*(completedness),
- 0, 20/256f, 20*(1-completedness)/256f, 20/256f, GL11.GL_NEAREST);
-
- Utils.drawItemStack(NotEnoughUpdates.INSTANCE.manager.jsonToStack(minionJson), guiLeft+(int)x+2, guiTop+(int)y+2);
-
- if(mouseX > guiLeft+(int)x+2 && mouseX < guiLeft+(int)x+18) {
- if(mouseY > guiTop+(int)y+2 && mouseY < guiTop+(int)y+18) {
- tooltipToDisplay = NotEnoughUpdates.INSTANCE.manager.jsonToStack(minionJson)
- .getTooltip(Minecraft.getMinecraft().thePlayer, false);
- }
- }
-
- GlStateManager.color(1, 1, 1, 1);
- if(tier >= 0) {
- Utils.drawStringCentered(tierString, fontRendererObj,
- guiLeft+x+10, guiTop+y-4, true,
- tierStringColour);
- }
- }
- }
- }
- }
-
- //190
- }
-
- private static final LinkedHashMap<String, ItemStack> invNameToDisplayMap = new LinkedHashMap<>();
- static {
- invNameToDisplayMap.put("inv_contents", Utils.createItemStack(Item.getItemFromBlock(Blocks.chest), EnumChatFormatting.GRAY+"Inventory"));
- invNameToDisplayMap.put("ender_chest_contents", Utils.createItemStack(Item.getItemFromBlock(Blocks.ender_chest), EnumChatFormatting.GRAY+"Ender Chest"));
- //invNameToDisplayMap.put("backpack_contents", Utils.createItemStack(Item.getItemFromBlock(Blocks.dropper), EnumChatFormatting.GRAY+"Backpacks"));
- invNameToDisplayMap.put("backpack_contents", Utils.editItemStackInfo(NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("JUMBO_BACKPACK")),EnumChatFormatting.GRAY+"Backpacks", true));
- invNameToDisplayMap.put("personal_vault_contents", Utils.editItemStackInfo(NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("IRON_CHEST")),EnumChatFormatting.GRAY+"Personal vault", true));
- invNameToDisplayMap.put("talisman_bag", Utils.createItemStack(Items.golden_apple, EnumChatFormatting.GRAY+"Accessory Bag"));
- invNameToDisplayMap.put("wardrobe_contents", Utils.createItemStack(Items.leather_chestplate, EnumChatFormatting.GRAY+"Wardrobe"));
- invNameToDisplayMap.put("fishing_bag", Utils.createItemStack(Items.fish, EnumChatFormatting.GRAY+"Fishing Bag"));
- invNameToDisplayMap.put("potion_bag", Utils.createItemStack(Items.potionitem, EnumChatFormatting.GRAY+"Potion Bag"));
- }
-
-
- public int countItemsInInventory(String internalname, JsonObject inventoryInfo, boolean specific, String... invsToSearch) {
- int count = 0;
- for(String inv : invsToSearch) {
- JsonArray invItems = inventoryInfo.get(inv).getAsJsonArray();
- for(int i=0; i<invItems.size(); i++) {
- if(invItems.get(i) == null || !invItems.get(i).isJsonObject()) continue;
- JsonObject item = invItems.get(i).getAsJsonObject();
- if((specific && item.get("internalname").getAsString().equals(internalname)) ||
- (!specific && item.get("internalname").getAsString().contains(internalname))) {
- if(item.has("count")) {
- count += item.get("count").getAsInt();
- } else {
- count += 1;
- }
- }
- }
- }
- return count;
- }
-
- private static final Pattern DAMAGE_PATTERN = Pattern.compile("^Damage: \\+([0-9]+)");
- private static final Pattern STRENGTH_PATTERN = Pattern.compile("^Strength: \\+([0-9]+)");
- private static final Pattern FISHSPEED_PATTERN = Pattern.compile("^Increases fishing speed by \\+([0-9]+)");
-
- private ItemStack[] findBestItems(JsonObject inventoryInfo, int numItems, String[] invsToSearch, String[] typeMatches, Pattern... importantPatterns) {
- ItemStack[] bestItems = new ItemStack[numItems];
- TreeMap<Integer, Set<ItemStack>> map = new TreeMap<>();
- for(String inv : invsToSearch) {
- JsonArray invItems = inventoryInfo.get(inv).getAsJsonArray();
- for(int i=0; i<invItems.size(); i++) {
- if(invItems.get(i) == null || !invItems.get(i).isJsonObject()) continue;
- JsonObject item = invItems.get(i).getAsJsonObject();
- JsonArray lore = item.get("lore").getAsJsonArray();
- if(Utils.checkItemType(lore, true, typeMatches) >= 0) {
- int importance = 0;
- for(int j=0; j<lore.size(); j++) {
- String line = lore.get(j).getAsString();
- for(Pattern pattern : importantPatterns) {
- Matcher matcher = pattern.matcher(Utils.cleanColour(line));
- if(matcher.find()) {
- importance += Integer.parseInt(matcher.group(1));
- }
- }
- }
- map.computeIfAbsent(importance, k->new HashSet<>()).add(
- NotEnoughUpdates.INSTANCE.manager.jsonToStack(item, false));
- }
- }
- }
- int i=0;
- outer:
- for(int key : map.descendingKeySet()) {
- Set<ItemStack> items = map.get(key);
- for(ItemStack item : items) {
- bestItems[i] = item;
- if(++i >= bestItems.length) break outer;
- }
- }
-
- return bestItems;
- }
-
- private int getRowsForInventory(String invName) {
- switch(invName) {
- case "wardrobe_contents":
- return 4;
- case "backpack_contents":
- return 5;
- case "ender_chest_contents":
- return 5;
- }
- return 6;
- }
-
- private boolean useActualMax(String invName) {
- switch(invName) {
- case "talisman_bag":
- case "fishing_bag":
- case "potion_bag":
- case "personal_vault_contents":
- return true;
- }
- return false;
- }
-
- private int getIgnoredRowsForInventory(String invName) {
- switch(invName) {
- case "talisman_bag":
- case "fishing_bag":
- case "potion_bag":
- return 1;
- }
- return 0;
- }
-
- //unused function
- //Data has been removed from the repo
- @Deprecated
- private int getAvailableSlotsForInventory(JsonObject inventoryInfo, JsonObject collectionInfo, String invName) {
- if(collectionInfo == null) return -1;
- JsonObject misc = Constants.MISC;
- if(misc == null) return -1;
- JsonElement sizesElement = Utils.getElement(misc, "bag_size."+invName+".sizes");
- JsonElement collectionElement = Utils.getElement(misc, "bag_size."+invName+".collection");
-
- if(sizesElement == null || !sizesElement.isJsonArray()) return -1;
- if(collectionElement == null || !collectionElement.isJsonPrimitive()) return -1;
-
- JsonArray sizes = sizesElement.getAsJsonArray();
- String collection = collectionElement.getAsString();
-
- JsonElement tierElement = Utils.getElement(collectionInfo, "collection_tiers."+collection);
-
- if(tierElement == null || !tierElement.isJsonPrimitive()) {
- return 0;
- }
- int tier = tierElement.getAsInt();
-
- int currentSlots = 0;
- for(int i=0; i<sizes.size(); i++) {
- JsonObject sizeInfo = sizes.get(i).getAsJsonObject();
- if(sizeInfo.get("tier").getAsInt() <= tier) {
- currentSlots = sizeInfo.get("slots").getAsInt();
- }
- }
- return currentSlots;
- }
-
- private ItemStack fillerStack = new ItemStack(Item.getItemFromBlock(Blocks.stained_glass_pane), 1, 15);
- public ItemStack[][][] getItemsForInventory(JsonObject inventoryInfo, String invName) {
- if(inventoryItems.containsKey(invName)) return inventoryItems.get(invName);
-
- JsonArray jsonInv = Utils.getElement(inventoryInfo, invName).getAsJsonArray();
-
- if(jsonInv.size() == 0) return new ItemStack[1][][];
-
- int jsonInvSize;
- if(useActualMax(invName)) {
- jsonInvSize = (int)Math.ceil(jsonInv.size()/9f)*9;
- } else {
- jsonInvSize = 9*4;
- float divideBy = 9f;
- if(invName.equals("wardrobe_contents")){
- divideBy = 36f;
- }
- for(int i=9*4; i<jsonInv.size(); i++) {
- JsonElement item = jsonInv.get(i);
- if(item != null && item.isJsonObject()) {
- jsonInvSize = (int) (Math.ceil((i+1)/divideBy)*(int)divideBy);
- }
- }
- }
-
- int rowSize = 9;
- int rows = jsonInvSize/rowSize;
- int maxRowsPerPage = getRowsForInventory(invName);
- int maxInvSize = rowSize*maxRowsPerPage;
-
- int numInventories = (jsonInvSize-1)/maxInvSize+1;
- JsonArray backPackSizes = (JsonArray) inventoryInfo.get("backpack_sizes");
- if(invName.equals("backpack_contents")) {
- numInventories = backPackSizes.size();
- }
-
- ItemStack[][][] inventories = new ItemStack[numInventories][][];
-
- //int availableSlots = getAvailableSlotsForInventory(inventoryInfo, collectionInfo, invName);
- int startNumberJ = 0;
-
- for(int i=0; i<numInventories; i++) {
- int thisRows = Math.min(maxRowsPerPage, rows-maxRowsPerPage*i);
- int invSize =0;
-
-
- if(invName.equals("backpack_contents")) {
- thisRows = backPackSizes.get(i).getAsInt()/9;
- invSize = startNumberJ+(thisRows*9);
- maxInvSize = thisRows*9;
- } else {
- startNumberJ = maxInvSize*i;
- invSize = Math.min(jsonInvSize, maxInvSize + maxInvSize * i);
- }
- if(thisRows <= 0) break;
-
- ItemStack[][] items = new ItemStack[thisRows][rowSize];
-
- for(int j=startNumberJ; j<invSize; j++) {
-
- int xIndex = (j%maxInvSize)%rowSize;
- int yIndex = (j%maxInvSize)/rowSize;
- if(invName.equals("inv_contents")) {
- yIndex--;
- if(yIndex < 0) yIndex = rows-1;
- }
- if(yIndex >= thisRows) {
- break;
- }
-
- if(j >= jsonInv.size()) {
- items[yIndex][xIndex] = fillerStack;
- continue;
- }
- if(jsonInv.get(j) == null || !jsonInv.get(j).isJsonObject()) {
- continue;
- }
-
- JsonObject item = jsonInv.get(j).getAsJsonObject();
- ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(item, false);
- if(item.has("item_contents")) {
- JsonArray bytesArr = item.get("item_contents").getAsJsonArray();
- byte[] bytes = new byte[bytesArr.size()];
- for(int bytesArrI=0; bytesArrI<bytesArr.size(); bytesArrI++) {
- bytes[bytesArrI] = bytesArr.get(bytesArrI).getAsByte();
- }
- //byte[] bytes2 = null;
- NBTTagCompound tag = stack.getTagCompound();
- if(tag != null && tag.hasKey("ExtraAttributes", 10)) {
- NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
- for(String key : ea.getKeySet()) {
- if(key.endsWith("backpack_data") || key.equals("new_year_cake_bag_data")) {
- ea.setTag(key, new NBTTagByteArray(bytes));
- break;
- }
- }
- tag.setTag("ExtraAttributes", ea);
- stack.setTagCompound(tag);
- }
- }
-
- items[yIndex][xIndex] = stack;
- }
- inventories[i] = items;
- if(invName.equals("backpack_contents")) {
- startNumberJ = startNumberJ + backPackSizes.get(i).getAsInt();
- }
- }
-
- inventoryItems.put(invName, inventories);
- return inventories;
- }
-
-
- private ItemStack[] bestWeapons = null;
- private ItemStack[] bestRods = null;
- private ItemStack[] armorItems = null;
- private HashMap<String, ItemStack[][][]> inventoryItems = new HashMap<>();
- private String selectedInventory = "inv_contents";
- private int currentInventoryIndex = 0;
- private int arrowCount = -1;
- private int greenCandyCount = -1;
- private int purpleCandyCount = -1;
- private GuiElementTextField inventoryTextField = new GuiElementTextField("", GuiElementTextField.SCALE_TEXT);
- private ItemStack lastBackpack;
- private int lastBackpackX;
- private int lastBackpackY;
- private void drawInvsPage(int mouseX, int mouseY, float partialTicks) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_invs);
- Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST);
- inventoryTextField.setSize(88, 20);
-
- JsonObject inventoryInfo = profile.getInventoryInfo(profileId);
- if(inventoryInfo == null) return;
-
- int invNameIndex=0;
- for(Map.Entry<String, ItemStack> entry : invNameToDisplayMap.entrySet()) {
- int xIndex = invNameIndex%3;
- int yIndex = invNameIndex/3;
-
- int x = 19+34*xIndex;
- int y = 26+34*yIndex;
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements);
- if(entry.getKey().equals(selectedInventory)) {
- Utils.drawTexturedRect(guiLeft+x-2, guiTop+y-2, 20, 20, 20/256f, 0,
- 20/256f, 0, GL11.GL_NEAREST);
- x++;
- y++;
- } else {
- Utils.drawTexturedRect(guiLeft+x-2, guiTop+y-2, 20, 20, 0, 20/256f,
- 0, 20/256f, GL11.GL_NEAREST);
- }
-
- Utils.drawItemStackWithText(entry.getValue(), guiLeft+x, guiTop+y, ""+(invNameIndex+1));
-
- if(mouseX >= guiLeft+x && mouseX <= guiLeft+x+16) {
- if(mouseY >= guiTop+y && mouseY <= guiTop+y+16) {
- tooltipToDisplay = entry.getValue().getTooltip(Minecraft.getMinecraft().thePlayer, false);
- }
- }
-
- invNameIndex++;
- }
-
- inventoryTextField.render(guiLeft+19, guiTop+sizeY-26-20);
-
- if(armorItems == null) {
- armorItems = new ItemStack[4];
- JsonArray armor = Utils.getElement(inventoryInfo, "inv_armor").getAsJsonArray();
- for(int i=0; i<armor.size(); i++) {
- if(armor.get(i) == null || !armor.get(i).isJsonObject()) continue;
- armorItems[i] = NotEnoughUpdates.INSTANCE.manager.jsonToStack(armor.get(i).getAsJsonObject(), false);
- }
- }
-
- for(int i=0; i<armorItems.length; i++) {
- ItemStack stack = armorItems[i];
- if(stack != null) {
- Utils.drawItemStack(stack, guiLeft+173, guiTop+67-18*i);
- if(stack != fillerStack) {
- if(mouseX >= guiLeft+173-1 && mouseX <= guiLeft+173+16+1) {
- if(mouseY >= guiTop+67-18*i-1 && mouseY <= guiTop+67-18*i+16+1) {
- tooltipToDisplay = stack.getTooltip(Minecraft.getMinecraft().thePlayer,
- Minecraft.getMinecraft().gameSettings.advancedItemTooltips);
- }
- }
- }
- }
- }
-
- ItemStack[][][] inventories = getItemsForInventory(inventoryInfo, selectedInventory);
- if(currentInventoryIndex >= inventories.length) currentInventoryIndex = inventories.length-1;
- if(currentInventoryIndex < 0) currentInventoryIndex = 0;
-
- ItemStack[][] inventory = inventories[currentInventoryIndex];
- if(inventory == null) {
- if(selectedInventory.equalsIgnoreCase("personal_vault_contents")) {
- Utils.drawStringCentered(EnumChatFormatting.RED+"Personal Vault API not enabled!", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+317, guiTop+101, true, 0);
- } else {
- Utils.drawStringCentered(EnumChatFormatting.RED+"Inventory API not enabled!", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+317, guiTop+101, true, 0);
- }
- return;
- }
-
- if(bestWeapons == null) {
- bestWeapons = findBestItems(inventoryInfo, 6, new String[]{"inv_contents", "ender_chest_contents"},
- new String[]{"SWORD","BOW"}, DAMAGE_PATTERN, STRENGTH_PATTERN);
- }
- if(bestRods == null) {
- bestRods = findBestItems(inventoryInfo, 3, new String[]{"inv_contents", "ender_chest_contents"},
- new String[]{"FISHING ROD"}, FISHSPEED_PATTERN);
- }
-
- for(int i=0; i<bestWeapons.length; i++) {
- if(bestWeapons[i] == null) continue;
- ItemStack stack = bestWeapons[i];
- Utils.drawItemStack(stack, guiLeft+143, guiTop+13+18*i);
- if(mouseX >= guiLeft+143-1 && mouseX <= guiLeft+143+16+1) {
- if(mouseY >= guiTop+13+18*i-1 && mouseY <= guiTop+13+18*i+16+1) {
- tooltipToDisplay = stack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
- }
- }
- }
-
- for(int i=0; i<bestRods.length; i++) {
- if(bestRods[i] == null) continue;
- ItemStack stack = bestRods[i];
- Utils.drawItemStack(stack, guiLeft+143, guiTop+137+18*i);
- if(mouseX >= guiLeft+143-1 && mouseX <= guiLeft+143+16+1) {
- if(mouseY >= guiTop+137+18*i-1 && mouseY <= guiTop+137+18*i+16+1) {
- tooltipToDisplay = stack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
- }
- }
- }
-
- if(arrowCount == -1) {
- arrowCount = countItemsInInventory("ARROW", inventoryInfo, false,"quiver");
- }
- if(greenCandyCount == -1) {
- greenCandyCount = countItemsInInventory("GREEN_CANDY", inventoryInfo, true,"candy_inventory_contents");
- }
- if(purpleCandyCount == -1) {
- purpleCandyCount = countItemsInInventory("PURPLE_CANDY", inventoryInfo, true, "candy_inventory_contents");
- }
-
- Utils.drawItemStackWithText(NotEnoughUpdates.INSTANCE.manager.jsonToStack(
- NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("ARROW")), guiLeft+173, guiTop+101,
- ""+(arrowCount>999?shortNumberFormat(arrowCount, 0):arrowCount));
- Utils.drawItemStackWithText(NotEnoughUpdates.INSTANCE.manager.jsonToStack(
- NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("GREEN_CANDY")), guiLeft+173, guiTop+119, ""+greenCandyCount);
- Utils.drawItemStackWithText(NotEnoughUpdates.INSTANCE.manager.jsonToStack(
- NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("PURPLE_CANDY")), guiLeft+173, guiTop+137, ""+purpleCandyCount);
- if(mouseX > guiLeft+173 && mouseX < guiLeft+173+16) {
- if(mouseY > guiTop+101 && mouseY < guiTop+137+16) {
- if(mouseY < guiTop+101+17) {
- tooltipToDisplay = Utils.createList(EnumChatFormatting.WHITE+"Arrow "+EnumChatFormatting.GRAY+"x"+arrowCount);
- } else if(mouseY < guiTop+119+17) {
- tooltipToDisplay = Utils.createList(EnumChatFormatting.GREEN+"Green Candy "+EnumChatFormatting.GRAY+"x"+greenCandyCount);
- } else {
- tooltipToDisplay = Utils.createList(EnumChatFormatting.DARK_PURPLE+"Purple Candy "+EnumChatFormatting.GRAY+"x"+purpleCandyCount);
- }
- }
- }
-
- int inventoryRows = inventory.length;
-
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
- Minecraft.getMinecraft().getTextureManager().bindTexture(CHEST_GUI_TEXTURE);
-
- int invSizeY = inventoryRows*18+17+7;
-
- int x = guiLeft+320-176/2;
- int y = guiTop+101-invSizeY/2;
- int staticSelectorHeight = guiTop+177;
-
- this.drawTexturedModalRect(x, y, 0, 0, 176, inventoryRows*18+17);
- this.drawTexturedModalRect(x, y+inventoryRows*18+17, 0, 215, 176, 7);
-
- boolean leftHovered = false;
- boolean rightHovered = false;
- if(Mouse.isButtonDown(0)) {
- if(mouseY > staticSelectorHeight && mouseY < staticSelectorHeight+16) {
- if(mouseX > guiLeft+320-12 && mouseX < guiLeft+320+12) {
- if(mouseX < guiLeft+320) {
- leftHovered = true;
- } else {
- rightHovered = true;
- }
- }
- }
- }
- Minecraft.getMinecraft().getTextureManager().bindTexture(resource_packs);
-
- if(currentInventoryIndex > 0) {
- Utils.drawTexturedRect(guiLeft+320-12, staticSelectorHeight, 12, 16,
- 29/256f, 53/256f, !leftHovered?0:32/256f, !leftHovered?32/256f:64/256f, GL11.GL_NEAREST);
- }
- if(currentInventoryIndex < inventories.length-1) {
- Utils.drawTexturedRect(guiLeft+320, staticSelectorHeight, 12, 16,
- 5/256f, 29/256f, !rightHovered?0:32/256f, !rightHovered?32/256f:64/256f, GL11.GL_NEAREST);
- }
-
- fontRendererObj.drawString(Utils.cleanColour(invNameToDisplayMap.get(selectedInventory).getDisplayName()), x+8, y+6, 4210752);
-
- ItemStack stackToRender = null;
- int overlay = new Color(0, 0, 0, 100).getRGB();
- for(int yIndex=0; yIndex<inventory.length; yIndex++) {
- if(inventory[yIndex] == null) continue;
-
- for(int xIndex=0; xIndex<inventory[yIndex].length; xIndex++) {
- ItemStack stack = inventory[yIndex][xIndex];
-
- if(stack != null) Utils.drawItemStack(stack, x+8+xIndex*18, y+18+yIndex*18);
-
- if(inventoryTextField.getText() != null && !inventoryTextField.getText().isEmpty() &&
- (stack == null || !NotEnoughUpdates.INSTANCE.manager.doesStackMatchSearch(stack, inventoryTextField.getText()))) {
- GlStateManager.translate(0, 0, 50);
- drawRect(x+8+xIndex*18, y+18+yIndex*18, x+8+xIndex*18+16, y+18+yIndex*18+16, overlay);
- GlStateManager.translate(0, 0, -50);
- }
-
- if(stack == null || stack == fillerStack) continue;
-
- if(mouseX >= x+8+xIndex*18 && mouseX <= x+8+xIndex*18+16) {
- if(mouseY >= y+18+yIndex*18 && mouseY <= y+18+yIndex*18+16) {
- stackToRender = stack;
- }
- }
- }
- }
- if(stackToRender != null) {
- tooltipToDisplay = stackToRender.getTooltip(Minecraft.getMinecraft().thePlayer, false);
- }
-
- }
-
- private String niceUuid(String uuidStr) {
- if(uuidStr.length()!=32) return uuidStr;
-
- StringBuilder niceAucId = new StringBuilder();
- niceAucId.append(uuidStr, 0, 8);
- niceAucId.append("-");
- niceAucId.append(uuidStr, 8, 12);
- niceAucId.append("-");
- niceAucId.append(uuidStr, 12, 16);
- niceAucId.append("-");
- niceAucId.append(uuidStr, 16, 20);
- niceAucId.append("-");
- niceAucId.append(uuidStr, 20, 32);
- return niceAucId.toString();
- }
-
- public EntityOtherPlayerMP getEntityPlayer() {
- return entityPlayer;
- }
-
- private EntityOtherPlayerMP entityPlayer = null;
- private ResourceLocation playerLocationSkin = null;
- private ResourceLocation playerLocationCape = null;
- private String skinType = null;
-
- private HashMap<String, ResourceLocation[]> panoramasMap = new HashMap<>();
-
- public ResourceLocation[] getPanoramasForLocation(String location, String identifier) {
- if(panoramasMap.containsKey(location+identifier)) return panoramasMap.get(location+identifier);
- try {
- ResourceLocation[] panoramasArray = new ResourceLocation[6];
- for(int i=0; i<6; i++) {
- panoramasArray[i] = new ResourceLocation("notenoughupdates:panoramas/"+location+"_"+identifier+"/panorama_"+i+".jpg");
- Minecraft.getMinecraft().getResourceManager().getResource(panoramasArray[i]);
- }
- panoramasMap.put(location+identifier, panoramasArray);
- return panoramasArray;
- } catch(IOException e) {
- try {
- ResourceLocation[] panoramasArray = new ResourceLocation[6];
- for(int i=0; i<6; i++) {
- panoramasArray[i] = new ResourceLocation("notenoughupdates:panoramas/"+location+"/panorama_"+i+".jpg");
- Minecraft.getMinecraft().getResourceManager().getResource(panoramasArray[i]);
- }
- panoramasMap.put(location+identifier, panoramasArray);
- return panoramasArray;
- } catch(IOException e2) {
- ResourceLocation[] panoramasArray = new ResourceLocation[6];
- for(int i=0; i<6; i++) {
- panoramasArray[i] = new ResourceLocation("notenoughupdates:panoramas/unknown/panorama_"+i+".jpg");
- }
- panoramasMap.put(location+identifier, panoramasArray);
- return panoramasArray;
- }
- }
- }
-
- private TreeMap<Integer, Set<String>> topKills = null;
- private TreeMap<Integer, Set<String>> topDeaths = null;
-
- private void drawExtraPage(int mouseX, int mouseY, float partialTicks) {
- FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_extra);
- Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST);
-
- JsonObject profileInfo = profile.getProfileInformation(profileId);
- if(profileInfo == null) return;
- JsonObject skillInfo = profile.getSkillInfo(profileId);
-
- float xStart = 22;
- float xOffset = 103;
- float yStartTop = 27;
- float yStartBottom = 105;
- float yOffset = 10;
-
- float bankBalance = Utils.getElementAsFloat(Utils.getElement(profileInfo, "banking.balance"), 0);
- float purseBalance = Utils.getElementAsFloat(Utils.getElement(profileInfo, "coin_purse"), 0);
-
- Utils.renderAlignedString(EnumChatFormatting.GOLD+"Bank Balance", EnumChatFormatting.WHITE.toString()+shortNumberFormat(bankBalance, 0),
- guiLeft+xStart, guiTop+yStartTop, 76);
- Utils.renderAlignedString(EnumChatFormatting.GOLD+"Purse", EnumChatFormatting.WHITE.toString()+shortNumberFormat(purseBalance, 0),
- guiLeft+xStart, guiTop+yStartTop+yOffset, 76);
-
- {
- String lastSaveText = this.getTimeSinceString(profileInfo, "last_save");
- if(lastSaveText != null) {
- Utils.renderAlignedString(EnumChatFormatting.AQUA + "Last Seen", EnumChatFormatting.WHITE.toString() + lastSaveText,
- guiLeft + xStart, guiTop + yStartTop + yOffset * 2, 76);
- }
-
- }
- {
- String first_join = this.getTimeSinceString(profileInfo, "first_join");
- if(first_join != null) {
- Utils.renderAlignedString(EnumChatFormatting.AQUA + "Joined", EnumChatFormatting.WHITE.toString() + first_join,
- guiLeft + xStart, guiTop + yStartTop + yOffset * 3, 76);
- }
-
- }
- {
- JsonObject guildInfo = profile.getGuildInfo(null);
- if(guildInfo != null && guildInfo.has("name")){
- Utils.renderAlignedString(EnumChatFormatting.AQUA + "Guild", EnumChatFormatting.WHITE.toString() + guildInfo.get("name").getAsString(),
- guiLeft + xStart, guiTop + yStartTop + yOffset * 4, 76);
- }
- }
-
- float fairySouls = Utils.getElementAsFloat(Utils.getElement(profileInfo, "fairy_souls_collected"), 0);
-
- int fairySoulMax = 227;
- if(Constants.FAIRYSOULS != null && Constants.FAIRYSOULS.has("Max Souls")) {
- fairySoulMax = Constants.FAIRYSOULS.get("Max Souls").getAsInt();
- }
- Utils.renderAlignedString(EnumChatFormatting.LIGHT_PURPLE+"Fairy Souls", EnumChatFormatting.WHITE.toString()+(int)fairySouls+"/"+fairySoulMax,
- guiLeft+xStart, guiTop+yStartBottom, 76);
- if(skillInfo != null) {
- float totalSkillLVL = 0;
- float totalTrueSkillLVL = 0;
- float totalSlayerLVL = 0;
- float totalSkillCount = 0;
- float totalSlayerCount = 0;
- float totalSlayerXP = 0;
-
- for(Map.Entry<String, JsonElement> entry : skillInfo.entrySet()) {
- if(entry.getKey().startsWith("level_skill")) {
- if(entry.getKey().contains("runecrafting")) continue;
- if(entry.getKey().contains("carpentry")) continue;
- if(entry.getKey().contains("catacombs")) continue;
-
- totalSkillLVL += entry.getValue().getAsFloat();
- totalTrueSkillLVL += Math.floor(entry.getValue().getAsFloat());
- totalSkillCount++;
- } else if(entry.getKey().startsWith("level_slayer")) {
- totalSlayerLVL += entry.getValue().getAsFloat();
- totalSlayerCount++;
- } else if (entry.getKey().startsWith("experience_slayer")) {
- totalSlayerXP += entry.getValue().getAsFloat();
- }
- }
-
- float avgSkillLVL = totalSkillLVL/totalSkillCount;
- float avgTrueSkillLVL = totalTrueSkillLVL/totalSkillCount;
- float avgSlayerLVL = totalSlayerLVL/totalSlayerCount;
-
- Utils.renderAlignedString(EnumChatFormatting.RED+"AVG Skill Level", EnumChatFormatting.WHITE.toString()+Math.floor(avgSkillLVL*10)/10,
- guiLeft+xStart, guiTop+yStartBottom+yOffset, 76);
-
- Utils.renderAlignedString(EnumChatFormatting.RED+"True AVG Skill Level", EnumChatFormatting.WHITE.toString()+Math.floor(avgTrueSkillLVL*10)/10,
- guiLeft+xStart, guiTop+yStartBottom+yOffset*2, 76);
-
- Utils.renderAlignedString(EnumChatFormatting.RED+"AVG Slayer Level", EnumChatFormatting.WHITE.toString()+Math.floor(avgSlayerLVL*10)/10,
- guiLeft+xStart, guiTop+yStartBottom+yOffset*3, 76);
-
- Utils.renderAlignedString(EnumChatFormatting.RED + "Total Slayer XP", EnumChatFormatting.WHITE.toString() + shortNumberFormat(totalSlayerXP, 0),
- guiLeft + xStart, guiTop + yStartBottom + yOffset * 4, 76);
- }
-
-
- float auctions_bids = Utils.getElementAsFloat(Utils.getElement(profileInfo, "stats.auctions_bids"), 0);
- float auctions_highest_bid = Utils.getElementAsFloat(Utils.getElement(profileInfo, "stats.auctions_highest_bid"), 0);
- float auctions_won = Utils.getElementAsFloat(Utils.getElement(profileInfo, "stats.auctions_won"), 0);
- float auctions_created = Utils.getElementAsFloat(Utils.getElement(profileInfo, "stats.auctions_created"), 0);
- float auctions_gold_spent = Utils.getElementAsFloat(Utils.getElement(profileInfo, "stats.auctions_gold_spent"), 0);
- float auctions_gold_earned = Utils.getElementAsFloat(Utils.getElement(profileInfo, "stats.auctions_gold_earned"), 0);
-
- Utils.renderAlignedString(EnumChatFormatting.DARK_PURPLE+"Auction Bids", EnumChatFormatting.WHITE.toString()+(int)auctions_bids,
- guiLeft+xStart+xOffset, guiTop+yStartTop, 76);
- Utils.renderAlignedString(EnumChatFormatting.DARK_PURPLE+"Highest Bid", EnumChatFormatting.WHITE.toString()+shortNumberFormat(auctions_highest_bid, 0),
- guiLeft+xStart+xOffset, guiTop+yStartTop+yOffset, 76);
- Utils.renderAlignedString(EnumChatFormatting.DARK_PURPLE+"Auctions Won", EnumChatFormatting.WHITE.toString()+(int)auctions_won,
- guiLeft+xStart+xOffset, guiTop+yStartTop+yOffset*2, 76);
- Utils.renderAlignedString(EnumChatFormatting.DARK_PURPLE+"Auctions Created", EnumChatFormatting.WHITE.toString()+(int)auctions_created,
- guiLeft+xStart+xOffset, guiTop+yStartTop+yOffset*3, 76);
- Utils.renderAlignedString(EnumChatFormatting.DARK_PURPLE+"Gold Spent", EnumChatFormatting.WHITE.toString()+shortNumberFormat(auctions_gold_spent, 0),
- guiLeft+xStart+xOffset, guiTop+yStartTop+yOffset*4, 76);
- Utils.renderAlignedString(EnumChatFormatting.DARK_PURPLE+"Gold Earned", EnumChatFormatting.WHITE.toString()+shortNumberFormat(auctions_gold_earned, 0),
- guiLeft+xStart+xOffset, guiTop+yStartTop+yOffset*5, 76);
-
-
- //Slayer values
- float zombie_boss_kills_tier_2 = Utils.getElementAsFloat(Utils.getElement(profileInfo, "slayer_bosses.zombie.boss_kills_tier_2"), 0);
- float zombie_boss_kills_tier_3 = Utils.getElementAsFloat(Utils.getElement(profileInfo, "slayer_bosses.zombie.boss_kills_tier_3"), 0);
- float zombie_boss_kills_tier_4 = Utils.getElementAsFloat(Utils.getElement(profileInfo, "slayer_bosses.zombie.boss_kills_tier_4"), 0);
- float wolf_boss_kills_tier_2 = Utils.getElementAsFloat(Utils.getElement(profileInfo, "slayer_bosses.wolf.boss_kills_tier_2"), 0);
- float wolf_boss_kills_tier_3 = Utils.getElementAsFloat(Utils.getElement(profileInfo, "slayer_bosses.wolf.boss_kills_tier_3"), 0);
- float spider_boss_kills_tier_2 = Utils.getElementAsFloat(Utils.getElement(profileInfo, "slayer_bosses.spider.boss_kills_tier_2"), 0);
- float spider_boss_kills_tier_3 = Utils.getElementAsFloat(Utils.getElement(profileInfo, "slayer_bosses.spider.boss_kills_tier_3"), 0);
- float enderman_boss_kills_tier_2 = Utils.getElementAsFloat(Utils.getElement(profileInfo, "slayer_bosses.enderman.boss_kills_tier_2"), 0);
- float enderman_boss_kills_tier_3 = Utils.getElementAsFloat(Utils.getElement(profileInfo, "slayer_bosses.enderman.boss_kills_tier_3"), 0);
-
-
- Utils.renderAlignedString(EnumChatFormatting.DARK_AQUA+"Revenant T3", EnumChatFormatting.WHITE.toString()+(int)zombie_boss_kills_tier_2,
- guiLeft+xStart+xOffset, guiTop+yStartBottom, 76);
- Utils.renderAlignedString(EnumChatFormatting.DARK_AQUA+"Revenant T4", EnumChatFormatting.WHITE.toString()+(int)zombie_boss_kills_tier_3,
- guiLeft+xStart+xOffset, guiTop+yStartBottom+yOffset, 76);
- Utils.renderAlignedString(EnumChatFormatting.DARK_AQUA+"Revenant T5", EnumChatFormatting.WHITE.toString()+(int)zombie_boss_kills_tier_4,
- guiLeft+xStart+xOffset, guiTop+yStartBottom+yOffset*2, 76);
- Utils.renderAlignedString(EnumChatFormatting.DARK_AQUA+"Tarantula T3", EnumChatFormatting.WHITE.toString()+(int)spider_boss_kills_tier_2,
- guiLeft+xStart+xOffset, guiTop+yStartBottom+yOffset*3, 76);
- Utils.renderAlignedString(EnumChatFormatting.DARK_AQUA+"Tarantula T4", EnumChatFormatting.WHITE.toString()+(int)spider_boss_kills_tier_3,
- guiLeft+xStart+xOffset, guiTop+yStartBottom+yOffset*4, 76);
-
- Utils.renderAlignedString(EnumChatFormatting.DARK_AQUA+"Sven T3", EnumChatFormatting.WHITE.toString()+(int)wolf_boss_kills_tier_2,
- guiLeft+xStart+xOffset*2, guiTop+yStartBottom+yOffset*0, 76);
- Utils.renderAlignedString(EnumChatFormatting.DARK_AQUA+"Sven T4", EnumChatFormatting.WHITE.toString()+(int)wolf_boss_kills_tier_3,
- guiLeft+xStart+xOffset*2, guiTop+yStartBottom+yOffset*1, 76);
- Utils.renderAlignedString(EnumChatFormatting.DARK_AQUA+"Voidgloom Seraph T3", EnumChatFormatting.WHITE.toString()+(int)enderman_boss_kills_tier_2,
- guiLeft+xStart+xOffset*2, guiTop+yStartBottom+yOffset*2, 76);
- Utils.renderAlignedString(EnumChatFormatting.DARK_AQUA+"Voidgloom Seraph T4", EnumChatFormatting.WHITE.toString()+(int)enderman_boss_kills_tier_3,
- guiLeft+xStart+xOffset*2, guiTop+yStartBottom+yOffset*3, 76);
-
- float pet_milestone_ores_mined = Utils.getElementAsFloat(Utils.getElement(profileInfo, "stats.pet_milestone_ores_mined"), 0);
- float pet_milestone_sea_creatures_killed = Utils.getElementAsFloat(Utils.getElement(profileInfo, "stats.pet_milestone_sea_creatures_killed"), 0);
-
- float items_fished = Utils.getElementAsFloat(Utils.getElement(profileInfo, "stats.items_fished"), 0);
- float items_fished_treasure = Utils.getElementAsFloat(Utils.getElement(profileInfo, "stats.items_fished_treasure"), 0);
- float items_fished_large_treasure = Utils.getElementAsFloat(Utils.getElement(profileInfo, "stats.items_fished_large_treasure"), 0);
-
- Utils.renderAlignedString(EnumChatFormatting.GREEN+"Ores Mined", EnumChatFormatting.WHITE.toString()+(int)pet_milestone_ores_mined,
- guiLeft+xStart+xOffset*2, guiTop+yStartTop, 76);
- Utils.renderAlignedString(EnumChatFormatting.GREEN+"Sea Creatures Killed", EnumChatFormatting.WHITE.toString()+(int)pet_milestone_sea_creatures_killed,
- guiLeft+xStart+xOffset*2, guiTop+yStartTop+yOffset, 76);
-
- Utils.renderAlignedString(EnumChatFormatting.GREEN+"Items Fished", EnumChatFormatting.WHITE.toString()+(int)items_fished,
- guiLeft+xStart+xOffset*2, guiTop+yStartTop+yOffset*3, 76);
- Utils.renderAlignedString(EnumChatFormatting.GREEN+"Treasures Fished", EnumChatFormatting.WHITE.toString()+(int)items_fished_treasure,
- guiLeft+xStart+xOffset*2, guiTop+yStartTop+yOffset*4, 76);
- Utils.renderAlignedString(EnumChatFormatting.GREEN+"Large Treasures", EnumChatFormatting.WHITE.toString()+(int)items_fished_large_treasure,
- guiLeft+xStart+xOffset*2, guiTop+yStartTop+yOffset*5, 76);
-
- if(topKills == null) {
- topKills = new TreeMap<>();
- JsonObject stats = profileInfo.get("stats").getAsJsonObject();
- for(Map.Entry<String, JsonElement> entry : stats.entrySet()) {
- if(entry.getKey().startsWith("kills_")) {
- if(entry.getValue().isJsonPrimitive()) {
- JsonPrimitive prim = (JsonPrimitive) entry.getValue();
- if(prim.isNumber()) {
- String name = WordUtils.capitalizeFully(entry.getKey().substring("kills_".length()).replace("_", " "));
- Set<String> kills = topKills.computeIfAbsent(prim.getAsInt(), k->new HashSet<>());
- kills.add(name);
- }
- }
- }
- }
- }
- if(topDeaths == null) {
- topDeaths = new TreeMap<>();
- JsonObject stats = profileInfo.get("stats").getAsJsonObject();
- for(Map.Entry<String, JsonElement> entry : stats.entrySet()) {
- if(entry.getKey().startsWith("deaths_")) {
- if(entry.getValue().isJsonPrimitive()) {
- JsonPrimitive prim = (JsonPrimitive) entry.getValue();
- if(prim.isNumber()) {
- String name = WordUtils.capitalizeFully(entry.getKey().substring("deaths_".length()).replace("_", " "));
- Set<String> deaths = topDeaths.computeIfAbsent(prim.getAsInt(), k->new HashSet<>());
- deaths.add(name);
- }
- }
- }
- }
- }
-
- int index = 0;
- for(int killCount : topKills.descendingKeySet()) {
- if(index >= 6) break;
- Set<String> kills = topKills.get(killCount);
- for(String killType : kills) {
- if(index >= 6) break;
- Utils.renderAlignedString(EnumChatFormatting.YELLOW+killType+" Kills", EnumChatFormatting.WHITE.toString()+killCount,
- guiLeft+xStart+xOffset*3, guiTop+yStartTop+yOffset*index, 76);
- index++;
- }
- }
- index = 0;
- for(int deathCount : topDeaths.descendingKeySet()) {
- if(index >= 6) break;
- Set<String> deaths = topDeaths.get(deathCount);
- for(String deathType : deaths) {
- if(index >= 6) break;
- Utils.renderAlignedString(EnumChatFormatting.YELLOW+"Deaths: "+ deathType, EnumChatFormatting.WHITE.toString()+deathCount,
- guiLeft+xStart+xOffset*3, guiTop+yStartBottom+yOffset*index, 76);
- index++;
- }
- }
- }
-
- private String getTimeSinceString(JsonObject profileInfo, String path){
- JsonElement lastSaveElement = Utils.getElement(profileInfo, path);
-
- if (lastSaveElement.isJsonPrimitive()) {
-
- Instant lastSave = Instant.ofEpochMilli(lastSaveElement.getAsLong());
- LocalDateTime lastSaveTime = LocalDateTime.ofInstant(lastSave,TimeZone.getDefault().toZoneId());
- long timeDiff = System.currentTimeMillis() - lastSave.toEpochMilli();
- LocalDateTime sinceOnline= LocalDateTime.ofInstant(Instant.ofEpochMilli(timeDiff), ZoneId.of("UTC"));
- String renderText;
-
- if(timeDiff < 60000L){
- renderText = sinceOnline.getSecond()+" seconds ago.";
- } else if(timeDiff < 3600000L){
- renderText = sinceOnline.getMinute()+" minutes ago.";
- } else if(timeDiff < 86400000L){
- renderText = sinceOnline.getHour()+" hours ago.";
- } else if(timeDiff < 31556952000L){
- renderText = sinceOnline.getDayOfYear()+" days ago.";
- } else {
- renderText = lastSaveTime.format(DateTimeFormatter.ofPattern("dd-MM-yyyy"));
- }
- return renderText;
- }
- return null;
- }
-
- private int backgroundClickedX = -1;
-
- private static char[] c = new char[]{'k', 'm', 'b', 't'};
-
- public static String shortNumberFormat(double n, int iteration) {
- if(n < 1000) {
- if(n % 1 == 0) {
- return Integer.toString((int)n);
- } else {
- return String.format("%.2f", n);
- }
- }
-
- double d = ((long) n / 100) / 10.0;
- boolean isRound = (d * 10) %10 == 0;
- return (d < 1000?
- ((d > 99.9 || isRound || (!isRound && d > 9.99)?
- (int) d * 10 / 10 : d + ""
- ) + "" + c[iteration])
- : shortNumberFormat(d, iteration+1));
- }
-
- private boolean loadingProfile = false;
- private static final ExecutorService profileLoader = Executors.newFixedThreadPool(1);
-
- private void drawBasicPage(int mouseX, int mouseY, float partialTicks) {
- FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
-
- String location = null;
- JsonObject status = profile.getPlayerStatus();
- if(status != null && status.has("mode")) {
- location = status.get("mode").getAsString();
- }
-
- int extraRotation = 0;
- if(Mouse.isButtonDown(0) || Mouse.isButtonDown(1)) {
- if(backgroundClickedX == -1) {
- if(mouseX > guiLeft+23 && mouseX < guiLeft+23+81) {
- if(mouseY > guiTop+44 && mouseY < guiTop+44+108) {
- backgroundClickedX = mouseX;
- }
- }
- }
- } else {
- if(backgroundClickedX != -1) {
- backgroundRotation += mouseX - backgroundClickedX;
- backgroundClickedX = -1;
- }
- }
- if(backgroundClickedX == -1) {
- backgroundRotation += (currentTime - lastTime)/400f;
- } else {
- extraRotation = mouseX - backgroundClickedX;
- }
- backgroundRotation %= 360;
-
- String panoramaIdentifier = "day";
- if(SBInfo.getInstance().currentTimeDate != null) {
- if(SBInfo.getInstance().currentTimeDate.getHours() <= 6 ||
- SBInfo.getInstance().currentTimeDate.getHours() >= 20) {
- panoramaIdentifier = "night";
- }
- }
-
- Panorama.drawPanorama(-backgroundRotation-extraRotation, guiLeft+23, guiTop+44, 81, 108, 0.37f, 0.8f,
- getPanoramasForLocation(location==null?"unknown":location, panoramaIdentifier));
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(pv_basic);
- Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST);
-
- if(entityPlayer != null && profile.getHypixelProfile() != null) {
- String playerName = null;
- if(profile.getHypixelProfile().has("prefix")) {
- playerName = Utils.getElementAsString(profile.getHypixelProfile().get("prefix"), "") + " " + entityPlayer.getName();
- } else {
- String rank = Utils.getElementAsString(profile.getHypixelProfile().get("rank"),
- Utils.getElementAsString(profile.getHypixelProfile().get("newPackageRank"), "NONE"));
- String monthlyPackageRank = Utils.getElementAsString(profile.getHypixelProfile().get("monthlyPackageRank"), "NONE");
- if(!rank.equals("YOUTUBER") && !monthlyPackageRank.equals("NONE")) {
- rank = monthlyPackageRank;
- }
- EnumChatFormatting rankPlusColorECF = EnumChatFormatting.getValueByName(Utils.getElementAsString(profile.getHypixelProfile().get("rankPlusColor"),
- "GOLD"));
- String rankPlusColor = EnumChatFormatting.GOLD.toString();
- if(rankPlusColorECF != null) {
- rankPlusColor = rankPlusColorECF.toString();
- }
-
- JsonObject misc = Constants.MISC;
- if(misc != null) {
- if(misc.has("ranks")) {
- String rankName = Utils.getElementAsString(Utils.getElement(misc, "ranks."+rank+".tag"), null);
- String rankColor = Utils.getElementAsString(Utils.getElement(misc, "ranks."+rank+".color"), "7");
- String rankPlus = Utils.getElementAsString(Utils.getElement(misc, "ranks."+rank+".plus"), "");
-
- String name = entityPlayer.getName();
-
- if(misc.has("special_bois")) {
- JsonArray special_bois = misc.get("special_bois").getAsJsonArray();
- for(int i=0; i<special_bois.size(); i++) {
- if(special_bois.get(i).getAsString().equals(profile.getUuid())) {
- name = Utils.chromaString(name);
- break;
- }
- }
- }
-
- playerName = EnumChatFormatting.GRAY.toString() + name;
- if(rankName != null) {
- StringBuilder sb = new StringBuilder();
- sb.append("\u00A7"+rankColor);
- sb.append("[");
- sb.append(rankName);
- sb.append(rankPlusColor);
- sb.append(rankPlus);
- sb.append("\u00A7"+rankColor);
- sb.append("] ");
- sb.append(name);
- playerName = sb.toString();
- }
- }
- }
-
- }
- if(playerName != null) {
- int rankPrefixLen = fr.getStringWidth(playerName);
- int halfRankPrefixLen = rankPrefixLen/2;
-
- int x = guiLeft+63;
- int y = guiTop+54;
-
- drawRect(x-halfRankPrefixLen-1, y-1, x+halfRankPrefixLen+1, y+8, new Color(0, 0, 0, 64).getRGB());
-
- fr.drawString(playerName, x-halfRankPrefixLen, y, 0, true);
- }
- }
-
- long networth = profile.getNetWorth(profileId);
- if(networth > 0) {
- Utils.drawStringCentered(EnumChatFormatting.GREEN+"Net Worth: "+EnumChatFormatting.GOLD+numberFormat.format(networth), fr, guiLeft+63, guiTop+38, true, 0);
- try {
- double networthInCookies = (networth / NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarInfo("BOOSTER_COOKIE").get("avg_buy").getAsDouble());
- String networthIRLMoney = Long.toString(Math.round(((networthInCookies * 325) / 675) * 4.99));
-
- if(mouseX > guiLeft+8 && mouseX < guiLeft+8+fontRendererObj.getStringWidth("Net Worth: " + numberFormat.format(networth))) {
- if(mouseY > guiTop+32 && mouseY < guiTop+32+fontRendererObj.FONT_HEIGHT) {
- tooltipToDisplay = new ArrayList<>();
- tooltipToDisplay.add(EnumChatFormatting.GREEN+"Net worth in IRL money: "+EnumChatFormatting.DARK_GREEN+"$" +EnumChatFormatting.GOLD+networthIRLMoney);
- tooltipToDisplay.add("");
- if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
- tooltipToDisplay.add(EnumChatFormatting.RED+"This is calculated using the current");
- tooltipToDisplay.add(EnumChatFormatting.RED+"price of booster cookies on bazaar and the price");
- tooltipToDisplay.add(EnumChatFormatting.RED+"for cookies using gems, then the price of gems");
- tooltipToDisplay.add(EnumChatFormatting.RED+"is where we get the amount of IRL money you" );
- tooltipToDisplay.add(EnumChatFormatting.RED+"theoretically have on skyblock in net worth.");
- } else {
- tooltipToDisplay.add(EnumChatFormatting.GRAY+"[SHIFT for Info]");
- }
- if (!NotEnoughUpdates.INSTANCE.config.hidden.dev) {
- tooltipToDisplay.add("");
- tooltipToDisplay.add(EnumChatFormatting.RED + "THIS IS IN NO WAY ENDORSING IRL TRADING!");
- }
- }
- }
- } catch(Exception e){}
- }
-
- if(status != null) {
- JsonElement onlineElement = Utils.getElement(status, "online");
- boolean online = onlineElement != null && onlineElement.isJsonPrimitive() && onlineElement.getAsBoolean();
- String statusStr = online ? EnumChatFormatting.GREEN + "ONLINE" : EnumChatFormatting.RED + "OFFLINE";
- String locationStr = null;
- if(profile.getUuid().equals("20934ef9488c465180a78f861586b4cf")) {
- locationStr = "Ignoring DMs";
- } else {
- if(location != null) {
- JsonObject misc = Constants.MISC;
- if(misc != null) {
- locationStr = Utils.getElementAsString(Utils.getElement(misc, "area_names."+location), "Unknown");
- }
- }
- }
- if(locationStr != null) {
- statusStr += EnumChatFormatting.GRAY+" - "+EnumChatFormatting.GREEN+locationStr;
- }
-
- Utils.drawStringCentered(statusStr, fr, guiLeft+63, guiTop+160, true, 0);
- }
-
- if(entityPlayer == null) {
- if(!loadingProfile || ((ThreadPoolExecutor)profileLoader).getActiveCount() == 0) {
- loadingProfile = true;
- UUID playerUUID = UUID.fromString(niceUuid(profile.getUuid()));
-
- profileLoader.submit(() -> {
- GameProfile fakeProfile = Minecraft.getMinecraft().getSessionService().fillProfileProperties(new GameProfile(playerUUID, "CoolGuy123"), false);
- entityPlayer = new EntityOtherPlayerMP(Minecraft.getMinecraft().theWorld, fakeProfile) {
- public ResourceLocation getLocationSkin() {
- return playerLocationSkin == null ? DefaultPlayerSkin.getDefaultSkin(this.getUniqueID()) : playerLocationSkin;
- }
-
- public ResourceLocation getLocationCape() {
- return playerLocationCape;
- }
-
- public String getSkinType() {
- return skinType == null ? DefaultPlayerSkin.getSkinType(this.getUniqueID()) : skinType;
- }
- };
- entityPlayer.setAlwaysRenderNameTag(false);
- entityPlayer.setCustomNameTag("");
- });
- }
- } else {
- entityPlayer.refreshDisplayName();
- byte b = 0;
- for(EnumPlayerModelParts part : EnumPlayerModelParts.values()) {
- b |= part.getPartMask();
- }
- entityPlayer.getDataWatcher().updateObject(10, b);
- }
-
- JsonObject profileInfo = profile.getProfileInformation(profileId);
- if(profileInfo == null) return;
-
- JsonObject skillInfo = profile.getSkillInfo(profileId);
- JsonObject inventoryInfo = profile.getInventoryInfo(profileId);
-
- if(entityPlayer != null) {
- if(backgroundClickedX != -1 && Mouse.isButtonDown(1)) {
- Arrays.fill(entityPlayer.inventory.armorInventory, null);
- } else {
- if(inventoryInfo != null && inventoryInfo.has("inv_armor")) {
- JsonArray items = inventoryInfo.get("inv_armor").getAsJsonArray();
- if(items != null && items.size() == 4) {
- for(int i=0; i<entityPlayer.inventory.armorInventory.length; i++) {
- JsonElement itemElement = items.get(i);
- if(itemElement != null && itemElement.isJsonObject()) {
- entityPlayer.inventory.armorInventory[i] = NotEnoughUpdates.INSTANCE.manager.jsonToStack(itemElement.getAsJsonObject(), false);
- }
- }
- }
- } else {
- Arrays.fill(entityPlayer.inventory.armorInventory, null);
- }
- }
- if(entityPlayer.getUniqueID().toString().equals("ae6193ab-494a-4719-b6e7-d50392c8f012")) {
- entityPlayer.inventory.armorInventory[3] = NotEnoughUpdates.INSTANCE.manager.jsonToStack(
- NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("SMALL_BACKPACK"));
- }
- }
-
- if(entityPlayer != null && playerLocationSkin == null) {
- try {
- Minecraft.getMinecraft().getSkinManager().loadProfileTextures(entityPlayer.getGameProfile(), new SkinManager.SkinAvailableCallback() {
- public void skinAvailable(MinecraftProfileTexture.Type type, ResourceLocation location, MinecraftProfileTexture profileTexture) {
- switch (type) {
- case SKIN:
- playerLocationSkin = location;
- skinType = profileTexture.getMetadata("model");
-
- if(skinType == null) {
- skinType = "default";
- }
-
- break;
- case CAPE:
- playerLocationCape = location;
- }
- }
- }, false);
- } catch(Exception e){}
- }
-
- GlStateManager.color(1, 1, 1, 1);
- JsonObject petsInfo = profile.getPetsInfo(profileId);
- if(petsInfo != null) {
- JsonElement activePetElement = petsInfo.get("active_pet");
- if(activePetElement != null && activePetElement.isJsonObject()) {
- JsonObject activePet = activePetElement.getAsJsonObject();
-
- String type = activePet.get("type").getAsString();
-
- for(int i=0; i<4; i++) {
- JsonObject item = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(type+";"+i);
- if(item != null) {
- int x = guiLeft+20;
- float y = guiTop+82+15*(float)Math.sin(((currentTime-startTime)/800f)%(2*Math.PI));
- GlStateManager.translate(x, y, 0);
- ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(item, false);
-
- //Remove extra attributes so no CIT
- NBTTagCompound stackTag = stack.getTagCompound()==null?new NBTTagCompound():stack.getTagCompound();
- stackTag.removeTag("ExtraAttributes");
- stack.setTagCompound(stackTag);
-
- GlStateManager.scale(1.5f, 1.5f, 1);
- GlStateManager.enableDepth();
- Utils.drawItemStack(stack, 0, 0);
- GlStateManager.scale(1/1.5f, 1/1.5f, 1);
- GlStateManager.translate(-x, -y, 0);
- break;
- }
- }
- }
- }
- if(entityPlayer != null) {
- drawEntityOnScreen(guiLeft+63, guiTop+128+7, 36, guiLeft+63-mouseX, guiTop+129-mouseY, entityPlayer);
- }
-
- PlayerStats.Stats stats = profile.getStats(profileId);
-
- if(stats != null) {
- Splitter splitter = Splitter.on(" ").omitEmptyStrings().limit(2);
- for(int i=0; i<PlayerStats.defaultStatNames.length; i++) {
- String statName = PlayerStats.defaultStatNames[i];
- if(statName.equals("mining_fortune") || statName.equals("mining_speed")) continue;
- String statNamePretty = PlayerStats.defaultStatNamesPretty[i];
-
- int val = Math.round(stats.get(statName));
-
- GlStateManager.color(1, 1, 1, 1);
- GlStateManager.enableBlend();
- GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
- Utils.renderAlignedString(statNamePretty, EnumChatFormatting.WHITE.toString()+val, guiLeft+132, guiTop+27+11f*i, 80);
-
- if(mouseX > guiLeft+132 && mouseX < guiLeft+212) {
- if(mouseY > guiTop+27+11f*i && mouseY < guiTop+37+11f*i) {
- List<String> split = splitter.splitToList(statNamePretty);
- PlayerStats.Stats baseStats = PlayerStats.getBaseStats();
- tooltipToDisplay = new ArrayList<>();
- tooltipToDisplay.add(statNamePretty);
- int base = Math.round(baseStats.get(statName));
- tooltipToDisplay.add(EnumChatFormatting.GRAY+"Base "+split.get(1)+": "+EnumChatFormatting.GREEN+base+" "+split.get(0));
- int passive = Math.round(profile.getPassiveStats(profileId).get(statName)-baseStats.get(statName));
- tooltipToDisplay.add(EnumChatFormatting.GRAY+"Passive "+split.get(1)+" Bonus: +"+EnumChatFormatting.YELLOW+passive+" "+split.get(0));
- int itemBonus = Math.round(stats.get(statName)-profile.getPassiveStats(profileId).get(statName));
- tooltipToDisplay.add(EnumChatFormatting.GRAY+"Item "+split.get(1)+" Bonus: +"+EnumChatFormatting.DARK_PURPLE+itemBonus+" "+split.get(0));
- int finalStat = Math.round(stats.get(statName));
- tooltipToDisplay.add(EnumChatFormatting.GRAY+"Final "+split.get(1)+": +"+EnumChatFormatting.RED+finalStat+" "+split.get(0));
- }
- }
- }
- } else {
- Utils.drawStringCentered(EnumChatFormatting.RED+"Skill/Inv/Coll", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+172, guiTop+101-10, true, 0);
- Utils.drawStringCentered(EnumChatFormatting.RED+"APIs not", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+172, guiTop+101, true, 0);
- Utils.drawStringCentered(EnumChatFormatting.RED+"enabled!", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+172, guiTop+101+10, true, 0);
- }
-
- if(skillInfo != null) {
- int position = 0;
- for(Map.Entry<String, ItemStack> entry : ProfileViewer.getSkillToSkillDisplayMap().entrySet()) {
- if(entry.getValue() == null || entry.getKey() == null) {
- position++;
- continue;
- }
-
- int yPosition = position % 7;
- int xPosition = position / 7;
-
- String skillName = entry.getValue().getDisplayName();
-
- float level = Utils.getElementAsFloat(skillInfo.get("level_"+entry.getKey()), 0);
- int levelFloored = (int)Math.floor(level);
-
- int x = guiLeft+237+86*xPosition;
- int y = guiTop+31+21*yPosition;
-
- Utils.renderAlignedString(skillName, EnumChatFormatting.WHITE.toString()+levelFloored, x+14, y-4, 60);
-
- if(skillInfo.get("maxed_"+entry.getKey()).getAsBoolean()) {
- renderGoldBar(x, y+6, 80);
- } else {
- renderBar(x, y+6, 80, level%1);
- }
-
- if(mouseX > x && mouseX < x+80) {
- if(mouseY > y-4 && mouseY < y+13) {
- tooltipToDisplay = new ArrayList<>();
- tooltipToDisplay.add(skillName);
- if(skillInfo.get("maxed_"+entry.getKey()).getAsBoolean()) {
- tooltipToDisplay.add(EnumChatFormatting.GRAY+"Progress: "+EnumChatFormatting.GOLD+"MAXED!");
- } else {
- int maxXp = (int)skillInfo.get("maxxp_"+entry.getKey()).getAsFloat();
- tooltipToDisplay.add(EnumChatFormatting.GRAY+"Progress: "+EnumChatFormatting.DARK_PURPLE.toString() +
- shortNumberFormat(Math.round((level%1)*maxXp), 0) + "/" + shortNumberFormat(maxXp, 0));
- }
- String totalXpS = NumberFormat.getIntegerInstance().format((int)skillInfo.get("experience_"+entry.getKey()).getAsFloat());
- tooltipToDisplay.add(EnumChatFormatting.GRAY+"Total XP: " +
- EnumChatFormatting.DARK_PURPLE+totalXpS);
- }
- }
-
- GL11.glTranslatef((x), (y-6f), 0);
- GL11.glScalef(0.7f, 0.7f, 1);
- Utils.drawItemStackLinear(entry.getValue(), 0, 0);
- GL11.glScalef(1/0.7f, 1/0.7f, 1);
- GL11.glTranslatef(-(x), -(y-6f), 0);
-
- position++;
- }
- } else {
- Utils.drawStringCentered(EnumChatFormatting.RED+"Skills API not enabled!", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+322, guiTop+101, true, 0);
- }
- }
-
- private void renderGoldBar(float x, float y, float xSize) {
- if(!OpenGlHelper.areShadersSupported()) {
- renderBar(x, y, xSize, 1);
- return;
- }
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(icons);
- ShaderManager shaderManager = ShaderManager.getInstance();
- shaderManager.loadShader("make_gold");
- shaderManager.loadData("make_gold", "amount", (startTime-System.currentTimeMillis())/10000f);
-
- Utils.drawTexturedRect(x, y, xSize/2f, 5, 0/256f, (xSize/2f)/256f, 79/256f, 84/256f, GL11.GL_NEAREST);
- Utils.drawTexturedRect(x+xSize/2f, y, xSize/2f, 5, (182-xSize/2f)/256f, 182/256f, 79/256f, 84/256f, GL11.GL_NEAREST);
-
- GL20.glUseProgram(0);
- }
-
- private void renderBar(float x, float y, float xSize, float completed) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(icons);
-
- completed = Math.round(completed/0.05f)*0.05f;
-
- float notcompleted = 1-completed;
-
- int displayNum = 0;//tl.x%5;
-
- GlStateManager.color(1, 1, 1, 1);
- float width = 0;
-
- if(completed < 0.5f && (displayNum == 1 || displayNum == 0)) {
- width = (0.5f - completed) * xSize;
- Utils.drawTexturedRect(x+xSize*completed, y, width, 5, xSize*completed/256f, (xSize/2f)/256f, 74/256f, 79/256f, GL11.GL_NEAREST);
- }
- if(completed < 1f && (displayNum == 2 || displayNum == 0)) {
- width = Math.min(xSize*notcompleted, xSize/2f);
- Utils.drawTexturedRect(x+(xSize/2f)+Math.max(xSize*(completed-0.5f), 0), y, width, 5,
- (182-(xSize/2f)+Math.max(xSize*(completed-0.5f), 0))/256f, 182/256f, 74/256f, 79/256f, GL11.GL_NEAREST);
- }
-
- if(completed > 0f && (displayNum == 3 || displayNum == 0)) {
- width = Math.min(xSize*completed, xSize/2f);
- Utils.drawTexturedRect(x, y, width, 5,
- 0/256f, width/256f, 79/256f, 84/256f, GL11.GL_NEAREST);
- }
- if(completed > 0.5f && (displayNum == 4 || displayNum == 0)) {
- width = Math.min(xSize*(completed-0.5f), xSize/2f);
- Utils.drawTexturedRect(x+(xSize/2f), y, width, 5,
- (182-(xSize/2f))/256f, (182-(xSize/2f)+width)/256f, 79/256f, 84/256f, GL11.GL_NEAREST);
- }
- }
-
- private static final ResourceLocation shadowTextures = new ResourceLocation("textures/misc/shadow.png");
- public static void drawEntityOnScreen(int posX, int posY, int scale, float mouseX, float mouseY, EntityLivingBase ent) {
- GlStateManager.enableColorMaterial();
- GlStateManager.pushMatrix();
- GlStateManager.translate((float)posX, (float)posY, 50.0F);
- GlStateManager.scale((float)(-scale), (float)scale, (float)scale);
- GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
- float renderYawOffset = ent.renderYawOffset;
- float f1 = ent.rotationYaw;
- float f2 = ent.rotationPitch;
- float f3 = ent.prevRotationYawHead;
- float f4 = ent.rotationYawHead;
- GlStateManager.rotate(135.0F, 0.0F, 1.0F, 0.0F);
- RenderHelper.enableStandardItemLighting();
- GlStateManager.rotate(-135.0F, 0.0F, 1.0F, 0.0F);
- GlStateManager.rotate(25, 1.0F, 0.0F, 0.0F);
- ent.renderYawOffset = (float)Math.atan((double)(mouseX / 40.0F)) * 20.0F;
- ent.rotationYaw = (float)Math.atan((double)(mouseX / 40.0F)) * 40.0F;
- ent.rotationPitch = -((float)Math.atan((double)(mouseY / 40.0F))) * 20.0F;
- ent.rotationYawHead = ent.rotationYaw;
- ent.prevRotationYawHead = ent.rotationYaw;
- RenderManager rendermanager = Minecraft.getMinecraft().getRenderManager();
- rendermanager.setPlayerViewY(180.0F);
- rendermanager.setRenderShadow(false);
- rendermanager.renderEntityWithPosYaw(ent, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F);
+ private static final ResourceLocation CHEST_GUI_TEXTURE =
+ new ResourceLocation("textures/gui/container/generic_54.png");
+ public static final ResourceLocation pv_basic = new ResourceLocation("notenoughupdates:pv_basic.png");
+ public static final ResourceLocation pv_dung = new ResourceLocation("notenoughupdates:pv_dung.png");
+ public static final ResourceLocation pv_extra = new ResourceLocation("notenoughupdates:pv_extra.png");
+ public static final ResourceLocation pv_mining = new ResourceLocation("notenoughupdates:pv_mining.png");
+ public static final ResourceLocation pv_invs = new ResourceLocation("notenoughupdates:pv_invs.png");
+ public static final ResourceLocation pv_cols = new ResourceLocation("notenoughupdates:pv_cols.png");
+ public static final ResourceLocation pv_pets = new ResourceLocation("notenoughupdates:pv_pets.png");
+ public static final ResourceLocation pv_dropdown = new ResourceLocation("notenoughupdates:pv_dropdown.png");
+ public static final ResourceLocation pv_bg = new ResourceLocation("notenoughupdates:pv_bg.png");
+ public static final ResourceLocation pv_elements = new ResourceLocation("notenoughupdates:pv_elements.png");
+ public static final ResourceLocation pv_ironman = new ResourceLocation("notenoughupdates:pv_ironman.png");
+ public static final ResourceLocation pv_bingo = new ResourceLocation("notenoughupdates:pv_bingo.png");
+ public static final ResourceLocation pv_stranded = new ResourceLocation("notenoughupdates:pv_stranded.png");
+ public static final ResourceLocation pv_unknown = new ResourceLocation("notenoughupdates:pv_unknown.png");
+ public static final ResourceLocation resource_packs =
+ new ResourceLocation("minecraft:textures/gui/resource_packs.png");
+ public static final ResourceLocation icons = new ResourceLocation("textures/gui/icons.png");
+
+ private static final NumberFormat numberFormat = NumberFormat.getInstance(Locale.US);
+
+ private final ProfileViewer.Profile profile;
+ public static ProfileViewerPage currentPage = ProfileViewerPage.BASIC;
+ private int sizeX;
+ private int sizeY;
+ private int guiLeft;
+ private int guiTop;
+
+ private float backgroundRotation = 0;
+
+ private long currentTime = 0;
+ private long lastTime = 0;
+ private long startTime = 0;
+
+ private List<String> tooltipToDisplay = null;
+
+ private String profileId = null;
+ private boolean profileDropdownSelected = false;
+
+ public enum ProfileViewerPage {
+ LOADING(null),
+ INVALID_NAME(null),
+ NO_SKYBLOCK(null),
+ BASIC(new ItemStack(Items.paper)),
+ DUNG(new ItemStack(Item.getItemFromBlock(Blocks.deadbush))),
+ EXTRA(new ItemStack(Items.book)),
+ INVS(new ItemStack(Item.getItemFromBlock(Blocks.ender_chest))),
+ COLS(new ItemStack(Items.painting)),
+ PETS(new ItemStack(Items.bone)),
+ MINING(new ItemStack(Items.iron_pickaxe));
+
+ public final ItemStack stack;
+
+ ProfileViewerPage(ItemStack stack) {
+ this.stack = stack;
+ }
+ }
+
+ public GuiProfileViewer(ProfileViewer.Profile profile) {
+ this.profile = profile;
+ String name = "";
+ if (profile != null && profile.getHypixelProfile() != null) {
+ name = profile.getHypixelProfile().get("displayname").getAsString();
+ }
+ playerNameTextField = new GuiElementTextField(
+ name,
+ GuiElementTextField.SCALE_TEXT
+ );
+ playerNameTextField.setSize(100, 20);
+
+ if (currentPage == ProfileViewerPage.LOADING) {
+ currentPage = ProfileViewerPage.BASIC;
+ }
+ }
+
+ private final GuiElementTextField playerNameTextField;
+
+ @Override
+ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
+ currentTime = System.currentTimeMillis();
+ if (startTime == 0) startTime = currentTime;
+
+ ProfileViewerPage page = currentPage;
+ if (profile == null) {
+ page = ProfileViewerPage.INVALID_NAME;
+ } else if (profile.getPlayerInformation(null) == null) {
+ page = ProfileViewerPage.LOADING;
+ } else if (profile.getLatestProfile() == null) {
+ page = ProfileViewerPage.NO_SKYBLOCK;
+ }
+
+ if (profileId == null && profile != null && profile.getLatestProfile() != null) {
+ profileId = profile.getLatestProfile();
+ }
+ {
+ //this is just to cache the guild info
+ if (profile != null) {
+ JsonObject guildinfo = profile.getGuildInfo(null);
+ }
+ }
+
+ this.sizeX = 431;
+ this.sizeY = 202;
+ this.guiLeft = (this.width - this.sizeX) / 2;
+ this.guiTop = (this.height - this.sizeY) / 2;
+
+ super.drawScreen(mouseX, mouseY, partialTicks);
+ drawDefaultBackground();
+
+ blurBackground();
+ renderBlurredBackground(width, height, guiLeft + 2, guiTop + 2, sizeX - 4, sizeY - 4);
+
+ GlStateManager.enableDepth();
+ GlStateManager.translate(0, 0, 5);
+ renderTabs(true);
+ GlStateManager.translate(0, 0, -3);
+
+ GlStateManager.disableDepth();
+ GlStateManager.translate(0, 0, -2);
+ renderTabs(false);
+ GlStateManager.translate(0, 0, 2);
+
+ GlStateManager.disableLighting();
+ GlStateManager.enableDepth();
+ GlStateManager.enableBlend();
+ GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ GlStateManager.enableAlpha();
+ GlStateManager.alphaFunc(516, 0.1F);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_bg);
+ Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST);
+
+ if (!(page == ProfileViewerPage.LOADING)) {
+ playerNameTextField.render(guiLeft + sizeX - 100, guiTop + sizeY + 5);
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+
+ if (profile != null) {
+ JsonObject currProfileInfo = profile.getProfileInformation(profileId);
+ //Render Profile chooser button
+ renderBlurredBackground(width, height, guiLeft + 2, guiTop + sizeY + 3 + 2, 100 - 4, 20 - 4);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_dropdown);
+ Utils.drawTexturedRect(guiLeft, guiTop + sizeY + 3, 100, 20,
+ 0, 100 / 200f, 0, 20 / 185f, GL11.GL_NEAREST
+ );
+ Utils.drawStringCenteredScaledMaxWidth(profileId, Minecraft.getMinecraft().fontRendererObj, guiLeft + 50,
+ guiTop + sizeY + 3 + 10, true, 90, new Color(63, 224, 208, 255).getRGB()
+ );
+ //ironman icon
+ if (currProfileInfo != null && currProfileInfo.has("game_mode") &&
+ currProfileInfo.get("game_mode").getAsString().equals("ironman")) {
+ GlStateManager.color(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_ironman);
+ Utils.drawTexturedRect(guiLeft - 16 - 5, guiTop + sizeY + 5, 16, 16, GL11.GL_NEAREST);
+ }
+ //bingo! icon
+ if (currProfileInfo != null && currProfileInfo.has("game_mode") &&
+ currProfileInfo.get("game_mode").getAsString().equals("bingo")) {
+ GlStateManager.color(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_bingo);
+ Utils.drawTexturedRect(guiLeft - 16 - 5, guiTop + sizeY + 5, 16, 16, GL11.GL_NEAREST);
+ }
+ //stranded icon
+ if (currProfileInfo != null && currProfileInfo.has("game_mode") &&
+ currProfileInfo.get("game_mode").getAsString().equals("island")) {
+ GlStateManager.color(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_stranded);
+ Utils.drawTexturedRect(guiLeft - 16 - 5, guiTop + sizeY + 5, 16, 16, GL11.GL_NEAREST);
+ }
+ //icon if game mode is unknown
+ if (currProfileInfo != null && currProfileInfo.has("game_mode") &&
+ !currProfileInfo.get("game_mode").getAsString().equals("island") &&
+ !currProfileInfo.get("game_mode").getAsString().equals("bingo") &&
+ !currProfileInfo.get("game_mode").getAsString().equals("ironman")) {
+ GlStateManager.color(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_unknown);
+ Utils.drawTexturedRect(guiLeft - 16 - 5, guiTop + sizeY + 5, 16, 16, GL11.GL_NEAREST);
+ }
+ //Render Open In Skycrypt button
+ renderBlurredBackground(width, height, guiLeft + 100 + 6 + 2, guiTop + sizeY + 3 + 2, 100 - 4, 20 - 4);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_dropdown);
+ Utils.drawTexturedRect(guiLeft + 100 + 6, guiTop + sizeY + 3, 100, 20,
+ 0, 100 / 200f, 0, 20 / 185f, GL11.GL_NEAREST
+ );
+ Utils.drawStringCenteredScaledMaxWidth(
+ "Open in Skycrypt",
+ Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 50 + 100 + 6,
+ guiTop + sizeY + 3 + 10,
+ true,
+ 90,
+ new Color(63, 224, 208, 255).getRGB()
+ );
+
+ if (profileDropdownSelected && !profile.getProfileIds().isEmpty() && scaledResolution.getScaleFactor() != 4) {
+ int dropdownOptionSize = scaledResolution.getScaleFactor() == 3 ? 10 : 20;
+
+ int numProfiles = profile.getProfileIds().size();
+ int sizeYDropdown = numProfiles * dropdownOptionSize;
+ renderBlurredBackground(width, height, guiLeft + 2, guiTop + sizeY + 23, 100 - 4, sizeYDropdown - 2);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_dropdown);
+ Utils.drawTexturedRect(guiLeft, guiTop + sizeY + 23 - 3, 100, 3,
+ 100 / 200f, 1, 0, 3 / 185f, GL11.GL_NEAREST
+ );
+ Utils.drawTexturedRect(guiLeft, guiTop + sizeY + 23 + sizeYDropdown - 4, 100, 4,
+ 100 / 200f, 1, 181 / 185f, 1, GL11.GL_NEAREST
+ );
+ Utils.drawTexturedRect(guiLeft, guiTop + sizeY + 23, 100, sizeYDropdown - 4,
+ 100 / 200f, 1, (181 - sizeYDropdown) / 185f, 181 / 185f, GL11.GL_NEAREST
+ );
+
+ for (int yIndex = 0; yIndex < profile.getProfileIds().size(); yIndex++) {
+ String otherProfileId = profile.getProfileIds().get(yIndex);
+ Utils.drawStringCenteredScaledMaxWidth(
+ otherProfileId,
+ Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 50,
+ guiTop + sizeY + 23 + dropdownOptionSize / 2f + dropdownOptionSize * yIndex,
+ true,
+ 90,
+ new Color(33, 112, 104, 255).getRGB()
+ );
+ currProfileInfo = profile.getProfileInformation(otherProfileId);
+ if (currProfileInfo != null && currProfileInfo.has("game_mode") &&
+ currProfileInfo.get("game_mode").getAsString().equals("ironman")) {
+ GlStateManager.color(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_ironman);
+ Utils.drawTexturedRect(
+ guiLeft - 16 - 5,
+ guiTop + sizeY + 2 + 23 + dropdownOptionSize * yIndex,
+ 16,
+ 16,
+ GL11.GL_NEAREST
+ );
+ }
+ if (currProfileInfo != null && currProfileInfo.has("game_mode") &&
+ currProfileInfo.get("game_mode").getAsString().equals("bingo")) {
+ GlStateManager.color(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_bingo);
+ Utils.drawTexturedRect(
+ guiLeft - 16 - 5,
+ guiTop + sizeY + 2 + 23 + dropdownOptionSize * yIndex,
+ 16,
+ 16,
+ GL11.GL_NEAREST
+ );
+ }
+ if (currProfileInfo != null && currProfileInfo.has("game_mode") &&
+ currProfileInfo.get("game_mode").getAsString().equals("island")) {
+ GlStateManager.color(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_stranded);
+ Utils.drawTexturedRect(
+ guiLeft - 16 - 5,
+ guiTop + sizeY + 2 + 23 + dropdownOptionSize * yIndex,
+ 16,
+ 16,
+ GL11.GL_NEAREST
+ );
+ }
+ if (currProfileInfo != null && currProfileInfo.has("game_mode") &&
+ !currProfileInfo.get("game_mode").getAsString().equals("island") &&
+ !currProfileInfo.get("game_mode").getAsString().equals("bingo") &&
+ !currProfileInfo.get("game_mode").getAsString().equals("ironman")) {
+ GlStateManager.color(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_unknown);
+ Utils.drawTexturedRect(
+ guiLeft - 16 - 5,
+ guiTop + sizeY + 2 + 23 + dropdownOptionSize * yIndex,
+ 16,
+ 16,
+ GL11.GL_NEAREST
+ );
+ }
+ }
+
+ }
+ }
+ }
+
+ GlStateManager.color(1, 1, 1, 1);
+ switch (page) {
+ case BASIC:
+ drawBasicPage(mouseX, mouseY, partialTicks);
+ break;
+ case DUNG:
+ drawDungPage(mouseX, mouseY, partialTicks);
+ break;
+ case EXTRA:
+ drawExtraPage(mouseX, mouseY, partialTicks);
+ break;
+ case INVS:
+ drawInvsPage(mouseX, mouseY, partialTicks);
+ break;
+ case COLS:
+ drawColsPage(mouseX, mouseY, partialTicks);
+ break;
+ case PETS:
+ drawPetsPage(mouseX, mouseY, partialTicks);
+ break;
+ case MINING:
+ drawMiningPage(mouseX, mouseY, partialTicks);
+ break;
+ case LOADING:
+ String str = EnumChatFormatting.YELLOW + "Loading player profiles.";
+ long currentTimeMod = System.currentTimeMillis() % 1000;
+ if (currentTimeMod > 333) {
+ if (currentTimeMod < 666) {
+ str += ".";
+ } else {
+ str += "..";
+ }
+ }
+
+ Utils.drawStringCentered(str, Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + sizeX / 2f, guiTop + 101, true, 0
+ );
+
+ //This is just here to inform the player what to do
+ //like typing /api new or telling them to go find a psychotherapist
+ long timeDiff = System.currentTimeMillis() - startTime;
+
+ if (timeDiff > 20000) {
+ Utils.drawStringCentered(
+ EnumChatFormatting.YELLOW + "Its taking a while...",
+ Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + sizeX / 2f,
+ guiTop + 111,
+ true,
+ 0
+ );
+ Utils.drawStringCentered(
+ EnumChatFormatting.YELLOW + "Try \"/api new\".",
+ Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + sizeX / 2f,
+ guiTop + 121,
+ true,
+ 0
+ );
+ if (timeDiff > 60000) {
+ Utils.drawStringCentered(
+ EnumChatFormatting.YELLOW + "Might be hypixel's fault.",
+ Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + sizeX / 2f,
+ guiTop + 131,
+ true,
+ 0
+ );
+ if (timeDiff > 180000) {
+ Utils.drawStringCentered(
+ EnumChatFormatting.YELLOW + "Wow you're still here?",
+ Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + sizeX / 2f,
+ guiTop + 141,
+ true,
+ 0
+ );
+ if (timeDiff > 360000) {
+ long second = (timeDiff / 1000) % 60;
+ long minute = (timeDiff / (1000 * 60)) % 60;
+ long hour = (timeDiff / (1000 * 60 * 60)) % 24;
+
+ String time = String.format("%02d:%02d:%02d", hour, minute, second);
+ Utils.drawStringCentered(
+ EnumChatFormatting.YELLOW + "You've wasted your time here for: " + time,
+ Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + sizeX / 2f,
+ guiTop + 151,
+ true,
+ 0
+ );
+ Utils.drawStringCentered(
+ EnumChatFormatting.YELLOW + "" + EnumChatFormatting.BOLD + "What are you doing with your life?",
+ Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + sizeX / 2f,
+ guiTop + 161,
+ true,
+ 0
+ );
+ if (timeDiff > 600000) {
+ Utils.drawStringCentered(
+ EnumChatFormatting.RED + "" + EnumChatFormatting.BOLD + "Maniac",
+ Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + sizeX / 2f,
+ guiTop + 171,
+ true,
+ 0
+ );
+ if (timeDiff > 1200000) {
+ Utils.drawStringCentered(
+ EnumChatFormatting.RED + "" + EnumChatFormatting.BOLD + "You're a menace to society",
+ Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + sizeX / 2f,
+ guiTop + 181,
+ true,
+ 0
+ );
+ if (timeDiff > 1800000) {
+ Utils.drawStringCentered(
+ EnumChatFormatting.RED + "" + EnumChatFormatting.BOLD +
+ "You don't know what's gonna happen to you",
+ Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + sizeX / 2f,
+ guiTop + 191,
+ true,
+ 0
+ );
+ if (timeDiff > 3000000) {
+ Utils.drawStringCentered(
+ EnumChatFormatting.RED + "" + EnumChatFormatting.BOLD + "You really want this?",
+ Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + sizeX / 2f,
+ guiTop + 91,
+ true,
+ 0
+ );
+ if (timeDiff > 3300000) {
+ Utils.drawStringCentered(
+ EnumChatFormatting.DARK_RED + "" + EnumChatFormatting.BOLD + "OW LORD FORGIVE ME FOR THIS",
+ Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + sizeX / 2f,
+ guiTop + 71,
+ true,
+ 0
+ );
+ if (timeDiff > 3600000) {
+ throw new Error("Go do something productive") {
+ @Override
+ public void printStackTrace() {
+ throw new Error("Go do something productive");
+ }
+ };
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ break;
+ case INVALID_NAME:
+ Utils.drawStringCentered(
+ EnumChatFormatting.RED + "Invalid name or API is down!",
+ Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + sizeX / 2f,
+ guiTop + 101,
+ true,
+ 0
+ );
+ break;
+ case NO_SKYBLOCK:
+ Utils.drawStringCentered(
+ EnumChatFormatting.RED + "No skyblock data found!",
+ Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + sizeX / 2f,
+ guiTop + 101,
+ true,
+ 0
+ );
+ break;
+ }
+
+ lastTime = currentTime;
+
+ if (tooltipToDisplay != null) {
+ List<String> grayTooltip = new ArrayList<>(tooltipToDisplay.size());
+ for (String line : tooltipToDisplay) {
+ grayTooltip.add(EnumChatFormatting.GRAY + line);
+ }
+ Utils.drawHoveringText(grayTooltip, mouseX, mouseY, width, height, -1, Minecraft.getMinecraft().fontRendererObj);
+ tooltipToDisplay = null;
+ }
+ }
+
+ private void renderTabs(boolean renderPressed) {
+ int ignoredTabs = 0;
+ for (int i = 0; i < ProfileViewerPage.values().length; i++) {
+ ProfileViewerPage page = ProfileViewerPage.values()[i];
+ if (page.stack == null) {
+ ignoredTabs++;
+ continue;
+ }
+ boolean pressed = page == currentPage;
+ if (pressed == renderPressed) {
+ renderTab(page.stack, i - ignoredTabs, pressed);
+ }
+ }
+ }
+
+ private void renderTab(ItemStack stack, int xIndex, boolean pressed) {
+ GlStateManager.disableLighting();
+ GlStateManager.enableBlend();
+ GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ GlStateManager.enableAlpha();
+ GlStateManager.alphaFunc(516, 0.1F);
+
+ int x = guiLeft + xIndex * 28;
+ int y = guiTop - 28;
+
+ float uMin = 0;
+ float uMax = 28 / 256f;
+ float vMin = 20 / 256f;
+ float vMax = 51 / 256f;
+ if (pressed) {
+ vMin = 52 / 256f;
+ vMax = 84 / 256f;
+
+ if (xIndex != 0) {
+ uMin = 28 / 256f;
+ uMax = 56 / 256f;
+ }
+
+ renderBlurredBackground(width, height, x + 2, y + 2, 28 - 4, 28 - 4);
+ } else {
+ renderBlurredBackground(width, height, x + 2, y + 4, 28 - 4, 28 - 4);
+ }
+
+ GlStateManager.disableLighting();
+ GlStateManager.enableBlend();
+ GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ GlStateManager.enableAlpha();
+ GlStateManager.alphaFunc(516, 0.1F);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements);
+ Utils.drawTexturedRect(x, y, 28, pressed ? 32 : 31, uMin, uMax, vMin, vMax, GL11.GL_NEAREST);
+
+ GlStateManager.enableDepth();
+ Utils.drawItemStack(stack, x + 6, y + 9);
+ }
+
+ @Override
+ protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
+ if (currentPage != ProfileViewerPage.LOADING && currentPage != ProfileViewerPage.INVALID_NAME) {
+ int ignoredTabs = 0;
+ for (int i = 0; i < ProfileViewerPage.values().length; i++) {
+ ProfileViewerPage page = ProfileViewerPage.values()[i];
+ if (page.stack == null) {
+ ignoredTabs++;
+ continue;
+ }
+ int i2 = i - ignoredTabs;
+ int x = guiLeft + i2 * 28;
+ int y = guiTop - 28;
+
+ if (mouseX > x && mouseX < x + 28) {
+ if (mouseY > y && mouseY < y + 32) {
+ if (currentPage != page) Utils.playPressSound();
+ currentPage = page;
+ inventoryTextField.otherComponentClick();
+ playerNameTextField.otherComponentClick();
+ return;
+ }
+ }
+ }
+ }
+ switch (currentPage) {
+ case DUNG:
+ mouseClickedDung(mouseX, mouseY, mouseButton);
+ break;
+ case INVS:
+ inventoryTextField.setSize(88, 20);
+ if (mouseX > guiLeft + 19 && mouseX < guiLeft + 19 + 88) {
+ if (mouseY > guiTop + sizeY - 26 - 20 && mouseY < guiTop + sizeY - 26) {
+ inventoryTextField.mouseClicked(mouseX, mouseY, mouseButton);
+ playerNameTextField.otherComponentClick();
+ return;
+ }
+ }
+ break;
+ case PETS:
+ if (sortedPets == null) break;
+ for (int i = petsPage * 20; i < Math.min(petsPage * 20 + 20, sortedPets.size()); i++) {
+ int xIndex = (i % 20) % COLLS_XCOUNT;
+ int yIndex = (i % 20) / COLLS_XCOUNT;
+
+ float x = 5 + COLLS_XPADDING + (COLLS_XPADDING + 20) * xIndex;
+ float y = 7 + COLLS_YPADDING + (COLLS_YPADDING + 20) * yIndex;
+
+ if (mouseX > guiLeft + x && mouseX < guiLeft + x + 20) {
+ if (mouseY > guiTop + y && mouseY < guiTop + y + 20) {
+ selectedPet = i;
+ return;
+ }
+ }
+ }
+ break;
+ }
+ if (mouseX > guiLeft + sizeX - 100 && mouseX < guiLeft + sizeX) {
+ if (mouseY > guiTop + sizeY + 5 && mouseY < guiTop + sizeY + 25) {
+ playerNameTextField.mouseClicked(mouseX, mouseY, mouseButton);
+ inventoryTextField.otherComponentClick();
+ return;
+ }
+ }
+ if (mouseX > guiLeft + 106 && mouseX < guiLeft + 106 + 100 && profile != null &&
+ !profile.getProfileIds().isEmpty() && profileId != null) {
+ if (mouseY > guiTop + sizeY + 3 && mouseY < guiTop + sizeY + 23) {
+ try {
+ Desktop desk = Desktop.getDesktop();
+ desk.browse(new URI(
+ "https://sky.shiiyu.moe/stats/" + profile.getHypixelProfile().get("displayname").getAsString() + "/" +
+ profileId));
+ Utils.playPressSound();
+ return;
+ } catch (UnsupportedOperationException | IOException | URISyntaxException ignored) {
+ //no idea how this sounds, but ya know just in case
+ Utils.playSound(new ResourceLocation("game.player.hurt"), true);
+ return;
+ }
+ }
+ }
+
+ if (mouseX > guiLeft && mouseX < guiLeft + 100 && profile != null && !profile.getProfileIds().isEmpty()) {
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ if (mouseY > guiTop + sizeY + 3 && mouseY < guiTop + sizeY + 23) {
+ if (scaledResolution.getScaleFactor() == 4) {
+ profileDropdownSelected = false;
+ int profileNum = 0;
+ for (int index = 0; index < profile.getProfileIds().size(); index++) {
+ if (profile.getProfileIds().get(index).equals(profileId)) {
+ profileNum = index;
+ break;
+ }
+ }
+ if (mouseButton == 0) {
+ profileNum++;
+ } else {
+ profileNum--;
+ }
+ if (profileNum >= profile.getProfileIds().size()) profileNum = 0;
+ if (profileNum < 0) profileNum = profile.getProfileIds().size() - 1;
+
+ String newProfileId = profile.getProfileIds().get(profileNum);
+ if (profileId != null && !profileId.equals(newProfileId)) {
+ resetCache();
+ }
+ profileId = newProfileId;
+ } else {
+ profileDropdownSelected = !profileDropdownSelected;
+ }
+ } else if (scaledResolution.getScaleFactor() != 4 && profileDropdownSelected) {
+ int dropdownOptionSize = scaledResolution.getScaleFactor() == 3 ? 10 : 20;
+ int extraY = mouseY - (guiTop + sizeY + 23);
+ int index = extraY / dropdownOptionSize;
+ if (index >= 0 && index < profile.getProfileIds().size()) {
+ String newProfileId = profile.getProfileIds().get(index);
+ if (profileId != null && !profileId.equals(newProfileId)) {
+ resetCache();
+ }
+ profileId = newProfileId;
+ }
+ }
+ playerNameTextField.otherComponentClick();
+ inventoryTextField.otherComponentClick();
+ return;
+ }
+ profileDropdownSelected = false;
+ playerNameTextField.otherComponentClick();
+ inventoryTextField.otherComponentClick();
+ }
+
+ @Override
+ protected void keyTyped(char typedChar, int keyCode) throws IOException {
+ super.keyTyped(typedChar, keyCode);
+ switch (currentPage) {
+ case INVS:
+ keyTypedInvs(typedChar, keyCode);
+ inventoryTextField.keyTyped(typedChar, keyCode);
+ break;
+ case COLS:
+ keyTypedCols(typedChar, keyCode);
+ break;
+ case DUNG:
+ keyTypedDung(typedChar, keyCode);
+ break;
+ }
+ if (playerNameTextField.getFocus() && !(currentPage == ProfileViewerPage.LOADING)) {
+ if (keyCode == Keyboard.KEY_RETURN) {
+ currentPage = ProfileViewerPage.LOADING;
+ NotEnoughUpdates.profileViewer.getProfileByName(playerNameTextField.getText(), profile -> { //todo: invalid name
+ if (profile != null) profile.resetCache();
+ Minecraft.getMinecraft().displayGuiScreen(new GuiProfileViewer(profile));
+ });
+ }
+ playerNameTextField.keyTyped(typedChar, keyCode);
+ }
+ }
+
+ @Override
+ protected void mouseReleased(int mouseX, int mouseY, int mouseButton) {
+ super.mouseReleased(mouseX, mouseY, mouseButton);
+
+ switch (currentPage) {
+ case INVS:
+ mouseReleasedInvs(mouseX, mouseY, mouseButton);
+ break;
+ case COLS:
+ mouseReleasedCols(mouseX, mouseY, mouseButton);
+ break;
+ case PETS:
+ mouseReleasedPets(mouseX, mouseY, mouseButton);
+ }
+ }
+
+ protected void mouseClickedDung(int mouseX, int mouseY, int mouseButton) {
+ if (mouseX >= guiLeft + 50 && mouseX <= guiLeft + 70 &&
+ mouseY >= guiTop + 54 && mouseY <= guiTop + 64) {
+ dungeonLevelTextField.mouseClicked(mouseX, mouseY, mouseButton);
+ } else {
+ dungeonLevelTextField.otherComponentClick();
+ }
+
+ int cW = fontRendererObj.getStringWidth("Calculate");
+ if (mouseX >= guiLeft + 23 + 110 - 17 - cW && mouseX <= guiLeft + 23 + 110 - 17 &&
+ mouseY >= guiTop + 55 && mouseY <= guiTop + 65) {
+ calculateFloorLevelXP();
+ }
+
+ int y = guiTop + 142;
+
+ if (mouseY >= y - 2 && mouseY <= y + 9) {
+ for (int i = 1; i <= 7; i++) {
+ int w = fontRendererObj.getStringWidth("" + i);
+
+ int x = guiLeft + 23 + 110 * i / 8 - w / 2;
+
+ if (mouseX >= x - 2 && mouseX <= x + 7) {
+ floorTime = i;
+ return;
+ }
+ }
+ }
+ if (mouseX >= guiLeft - 29 && mouseX <= guiLeft) {
+ if (mouseY >= guiTop && mouseY <= guiTop + 28) {
+ onMasterMode = false;
+ return;
+ } else if (mouseY + 28 >= guiTop && mouseY <= guiTop + 28 * 2) {
+ onMasterMode = true;
+ return;
+ }
+ }
+ }
+
+ protected void keyTypedDung(char typedChar, int keyCode) {
+ dungeonLevelTextField.keyTyped(typedChar, keyCode);
+ }
+
+ protected void keyTypedInvs(char typedChar, int keyCode) throws IOException {
+ switch (keyCode) {
+ case Keyboard.KEY_1:
+ case Keyboard.KEY_NUMPAD1:
+ selectedInventory = "inv_contents";
+ break;
+ case Keyboard.KEY_2:
+ case Keyboard.KEY_NUMPAD2:
+ selectedInventory = "ender_chest_contents";
+ break;
+ case Keyboard.KEY_3:
+ case Keyboard.KEY_NUMPAD3:
+ selectedInventory = "backpack_contents";
+ break;
+ case Keyboard.KEY_4:
+ case Keyboard.KEY_NUMPAD4:
+ selectedInventory = "personal_vault_contents";
+ break;
+ case Keyboard.KEY_5:
+ case Keyboard.KEY_NUMPAD5:
+ selectedInventory = "talisman_bag";
+ break;
+ case Keyboard.KEY_6:
+ case Keyboard.KEY_NUMPAD6:
+ selectedInventory = "wardrobe_contents";
+ break;
+ case Keyboard.KEY_7:
+ case Keyboard.KEY_NUMPAD7:
+ selectedInventory = "fishing_bag";
+ break;
+ case Keyboard.KEY_8:
+ case Keyboard.KEY_NUMPAD8:
+ selectedInventory = "potion_bag";
+ break;
+
+ }
+ Utils.playPressSound();
+ }
+
+ protected void keyTypedCols(char typedChar, int keyCode) throws IOException {
+ ItemStack stack = null;
+ Iterator<ItemStack> items = ProfileViewer.getCollectionCatToCollectionMap().keySet().iterator();
+ switch (keyCode) {
+ case Keyboard.KEY_5:
+ case Keyboard.KEY_NUMPAD5:
+ stack = items.next();
+ case Keyboard.KEY_4:
+ case Keyboard.KEY_NUMPAD4:
+ stack = items.next();
+ case Keyboard.KEY_3:
+ case Keyboard.KEY_NUMPAD3:
+ stack = items.next();
+ case Keyboard.KEY_2:
+ case Keyboard.KEY_NUMPAD2:
+ stack = items.next();
+ case Keyboard.KEY_1:
+ case Keyboard.KEY_NUMPAD1:
+ stack = items.next();
+ }
+ if (stack != null) {
+ selectedCollectionCategory = stack;
+ }
+ Utils.playPressSound();
+ }
+
+ private void mouseReleasedPets(int mouseX, int mouseY, int mouseButton) {
+ if (mouseY > guiTop + 6 && mouseY < guiTop + 22) {
+ if (mouseX > guiLeft + 100 - 15 - 12 && mouseX < guiLeft + 100 - 20) {
+ if (petsPage > 0) {
+ petsPage--;
+ }
+ return;
+ } else if (mouseX > guiLeft + 100 + 15 && mouseX < guiLeft + 100 + 20 + 12) {
+ if (sortedPets != null && petsPage < Math.ceil(sortedPets.size() / 20f) - 1) {
+ petsPage++;
+ }
+ return;
+ }
+ }
+ }
+
+ private void mouseReleasedInvs(int mouseX, int mouseY, int mouseButton) {
+ if (mouseButton == 0) {
+ int i = 0;
+ for (Map.Entry<String, ItemStack> entry : invNameToDisplayMap.entrySet()) {
+ int xIndex = i % 3;
+ int yIndex = i / 3;
+
+ int x = guiLeft + 19 + 34 * xIndex;
+ int y = guiTop + 26 + 34 * yIndex;
+
+ if (mouseX >= x && mouseX <= x + 16) {
+ if (mouseY >= y && mouseY <= y + 16) {
+ if (selectedInventory != entry.getKey()) Utils.playPressSound();
+ selectedInventory = entry.getKey();
+ return;
+ }
+ }
+
+ i++;
+ }
+
+ JsonObject inventoryInfo = profile.getInventoryInfo(profileId);
+ if (inventoryInfo == null) return;
+
+ ItemStack[][][] inventories = getItemsForInventory(inventoryInfo, selectedInventory);
+ if (currentInventoryIndex >= inventories.length) currentInventoryIndex = inventories.length - 1;
+ if (currentInventoryIndex < 0) currentInventoryIndex = 0;
+
+ ItemStack[][] inventory = inventories[currentInventoryIndex];
+ if (inventory == null) return;
+
+ int inventoryRows = inventory.length;
+ int invSizeY = inventoryRows * 18 + 17 + 7;
+
+ int y = guiTop + 101 - invSizeY / 2;
+ int staticSelectorHeight = guiTop + 177;
+
+ if (mouseY > staticSelectorHeight && mouseY < staticSelectorHeight + 16) {
+ if (mouseX > guiLeft + 320 - 12 && mouseX < guiLeft + 320 + 12) {
+ if (mouseX < guiLeft + 320) {
+ currentInventoryIndex--;
+ } else {
+ currentInventoryIndex++;
+ }
+ }
+ }
+ }
+ }
+
+ private ItemStack selectedCollectionCategory = null;
+
+ private void mouseReleasedCols(int mouseX, int mouseY, int mouseButton) {
+ int collectionCatSize = ProfileViewer.getCollectionCatToCollectionMap().size();
+ int collectionCatYSize = (int) (162f / (collectionCatSize - 1 + 0.0000001f));
+ int yIndex = 0;
+ for (ItemStack stack : ProfileViewer.getCollectionCatToCollectionMap().keySet()) {
+ if (mouseX > guiLeft + 7 && mouseX < guiLeft + 7 + 20) {
+ if (mouseY > guiTop + 10 + collectionCatYSize * yIndex &&
+ mouseY < guiTop + 10 + collectionCatYSize * yIndex + 20) {
+ selectedCollectionCategory = stack;
+ Utils.playPressSound();
+ return;
+ }
+ }
+ yIndex++;
+ }
+ }
+
+ private static final ItemStack DEADBUSH = new ItemStack(Item.getItemFromBlock(Blocks.deadbush));
+ private static final ItemStack iron_pick = new ItemStack(Items.iron_pickaxe);
+ private static final ItemStack[] BOSS_HEADS = new ItemStack[7];
+
+ private final HashMap<String, ProfileViewer.Level> levelObjCatas = new HashMap<>();
+ private final HashMap<String, ProfileViewer.Level> levelObjhotms = new HashMap<>();
+ private final HashMap<String, HashMap<String, ProfileViewer.Level>> levelObjClasseses = new HashMap<>();
+
+ private final GuiElementTextField dungeonLevelTextField = new GuiElementTextField("", GuiElementTextField.SCALE_TEXT);
+
+ private static final String[] dungSkillsName = {"Healer", "Mage", "Berserk", "Archer", "Tank"};
+ private static final ItemStack[] dungSkillsStack = {
+ new ItemStack(Items.potionitem, 1, 16389),
+ new ItemStack(Items.blaze_rod),
+ new ItemStack(Items.iron_sword),
+ new ItemStack(Items.bow),
+ new ItemStack(Items.leather_chestplate)
+ };
+ private static final String[] bossFloorArr = {"Bonzo", "Scarf", "Professor", "Thorn", "Livid", "Sadan", "Necron"};
+ private static final String[] bossFloorHeads = {
+ "12716ecbf5b8da00b05f316ec6af61e8bd02805b21eb8e440151468dc656549c",
+ "7de7bbbdf22bfe17980d4e20687e386f11d59ee1db6f8b4762391b79a5ac532d",
+ "9971cee8b833a62fc2a612f3503437fdf93cad692d216b8cf90bbb0538c47dd8",
+ "8b6a72138d69fbbd2fea3fa251cabd87152e4f1c97e5f986bf685571db3cc0",
+ "c1007c5b7114abec734206d4fc613da4f3a0e99f71ff949cedadc99079135a0b",
+ "fa06cb0c471c1c9bc169af270cd466ea701946776056e472ecdaeb49f0f4a4dc",
+ "a435164c05cea299a3f016bbbed05706ebb720dac912ce4351c2296626aecd9a"
+ };
+ private static int floorTime = 7;
+ private int floorLevelTo = -1;
+ private int floorLevelToXP = -1;
+
+ private void calculateFloorLevelXP() {
+ JsonObject leveling = Constants.LEVELING;
+ if (leveling == null) return;
+ ProfileViewer.Level levelObjCata = levelObjCatas.get(profileId);
+ if (levelObjCata == null) return;
+
+ try {
+ dungeonLevelTextField.setCustomBorderColour(0xffffffff);
+ floorLevelTo = Integer.parseInt(dungeonLevelTextField.getText());
+
+ JsonArray levelingArray = Utils.getElement(leveling, "catacombs").getAsJsonArray();
+
+ float remaining = -((levelObjCata.level % 1) * levelObjCata.maxXpForLevel);
+
+ for (int level = 0; level < Math.min(floorLevelTo, levelingArray.size()); level++) {
+ if (level < Math.floor(levelObjCata.level)) {
+ continue;
+ }
+ remaining += levelingArray.get(level).getAsFloat();
+ }
+
+ if (remaining < 0) {
+ remaining = 0;
+ }
+ floorLevelToXP = (int) remaining;
+ } catch (Exception e) {
+ dungeonLevelTextField.setCustomBorderColour(0xffff0000);
+ }
+ }
+
+ private static final LinkedHashMap<String, ItemStack> dungeonsModeIcons = new LinkedHashMap<String, ItemStack>() {{
+ put(
+ "catacombs",
+ Utils.editItemStackInfo(NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("DUNGEON_STONE")), EnumChatFormatting.GRAY + "Normal Mode", true)
+ );
+ put(
+ "master_catacombs",
+ Utils.editItemStackInfo(NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("MASTER_SKULL_TIER_7")), EnumChatFormatting.GRAY + "Master Mode", true)
+ );
+ }};
+
+ private void drawDungPage(int mouseX, int mouseY, float partialTicks) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_dung);
+ Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST);
+
+ JsonObject hypixelInfo = profile.getHypixelProfile();
+ if (hypixelInfo == null) return;
+ JsonObject profileInfo = profile.getProfileInformation(profileId);
+ if (profileInfo == null) return;
+
+ JsonObject leveling = Constants.LEVELING;
+ if (leveling == null) return;
+
+ int sectionWidth = 110;
+
+ String dungeonString = onMasterMode ? "master_catacombs" : "catacombs";
+
+ //Utils.drawStringCentered((onMasterMode?"Master Mode":"Catacombs"),fontRendererObj,(guiLeft+sizeX/2), guiTop+10, true, 0xffff0000);
+ Utils.renderShadowedString(EnumChatFormatting.RED + (onMasterMode ? "Master Mode" : "Catacombs"),
+ (guiLeft + sizeX / 2), guiTop + 5, sectionWidth
+ );
+
+ ProfileViewer.Level levelObjCata = levelObjCatas.get(profileId);
+ //Catacombs level thingy
+ {
+ if (levelObjCata == null) {
+ float cataXp = Utils.getElementAsFloat(Utils.getElement(
+ profileInfo,
+ "dungeons.dungeon_types.catacombs.experience"
+ ), 0);
+ levelObjCata = ProfileViewer.getLevel(Utils.getElement(leveling, "catacombs").getAsJsonArray(),
+ cataXp, 50, false
+ );
+ levelObjCata.totalXp = cataXp;
+ levelObjCatas.put(profileId, levelObjCata);
+ }
+
+ String skillName = EnumChatFormatting.RED + "Catacombs";
+ float level = levelObjCata.level;
+ int levelFloored = (int) Math.floor(level);
+
+ if (floorLevelTo == -1 && levelFloored >= 0) {
+ dungeonLevelTextField.setText("" + (levelFloored + 1));
+ calculateFloorLevelXP();
+ }
+
+ int x = guiLeft + 23;
+ int y = guiTop + 25;
+
+ renderXpBar(skillName, DEADBUSH, x, y, sectionWidth, levelObjCata, mouseX, mouseY);
+
+ Utils.renderAlignedString(EnumChatFormatting.YELLOW + "Until Cata " + floorLevelTo + ": ",
+ EnumChatFormatting.WHITE + shortNumberFormat(floorLevelToXP, 0), x, y + 16, sectionWidth
+ );
+
+ if (mouseX > x && mouseX < x + sectionWidth && mouseY > y + 16 && mouseY < y + 24 && !onMasterMode) {
+ float F5 = (Utils.getElementAsFloat(Utils.getElement(
+ profileInfo,
+ "dungeons.dungeon_types.catacombs.tier_completions." + 5
+ ), 0)); //this can prob be done better
+ float F6 = (Utils.getElementAsFloat(Utils.getElement(
+ profileInfo,
+ "dungeons.dungeon_types.catacombs.tier_completions." + 6
+ ), 0));
+ float F7 = (Utils.getElementAsFloat(Utils.getElement(
+ profileInfo,
+ "dungeons.dungeon_types.catacombs.tier_completions." + 7
+ ), 0));
+ if (F5 > 150) {
+ F5 = 150;
+ }
+ if (F6 > 100) {
+ F6 = 100;
+ }
+ if (F7 > 50) {
+ F7 = 50;
+ }
+ float xpF5 = 2000 * (F5 / 100 + 1);
+ float xpF6 = 4000 * (F6 / 100 + 1);
+ float xpF7 = 20000 * (F7 / 100 + 1);
+ if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
+ xpF5 *= 1.1;
+ xpF6 *= 1.1;
+ xpF7 *= 1.1;
+ }
+
+ long runsF5 = (int) Math.ceil(floorLevelToXP / xpF5);
+ long runsF6 = (int) Math.ceil(floorLevelToXP / xpF6);
+ long runsF7 = (int) Math.ceil(floorLevelToXP / xpF7);
+
+ float timeF5 = Utils.getElementAsFloat(Utils.getElement(
+ profileInfo,
+ "dungeons.dungeon_types.catacombs.fastest_time_s_plus.5"
+ ), 0);
+ float timeF6 = Utils.getElementAsFloat(Utils.getElement(
+ profileInfo,
+ "dungeons.dungeon_types.catacombs.fastest_time_s_plus.6"
+ ), 0);
+ float timeF7 = Utils.getElementAsFloat(Utils.getElement(
+ profileInfo,
+ "dungeons.dungeon_types.catacombs.fastest_time_s_plus.7"
+ ), 0);
+
+ tooltipToDisplay = Lists.newArrayList(
+ String.format("# F5 Runs (%s xp) : %d", shortNumberFormat(xpF5, 0), runsF5),
+ String.format("# F6 Runs (%s xp) : %d", shortNumberFormat(xpF6, 0), runsF6),
+ String.format("# F7 Runs (%s xp) : %d", shortNumberFormat(xpF7, 0), runsF7),
+ ""
+ );
+ boolean hasTime = false;
+ if (timeF5 > 1000) {
+ tooltipToDisplay.add(String.format(
+ "Expected Time (F5) : %s",
+ Utils.prettyTime(runsF5 * (long) (timeF5 * 1.2))
+ ));
+ hasTime = true;
+ }
+ if (timeF6 > 1000) {
+ tooltipToDisplay.add(String.format(
+ "Expected Time (F6) : %s",
+ Utils.prettyTime(runsF6 * (long) (timeF6 * 1.2))
+ ));
+ hasTime = true;
+ }
+ if (timeF7 > 1000) {
+ tooltipToDisplay.add(String.format(
+ "Expected Time (F7) : %s",
+ Utils.prettyTime(runsF7 * (long) (timeF7 * 1.2))
+ ));
+ hasTime = true;
+ }
+ if (hasTime) {
+ tooltipToDisplay.add("");
+ }
+ if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
+ tooltipToDisplay.add(
+ "[Hold " + EnumChatFormatting.YELLOW + "SHIFT" + EnumChatFormatting.GRAY + " to show without Expert Ring]");
+ }
+ if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) {
+ if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) tooltipToDisplay.add("");
+ tooltipToDisplay.add("Number of runs is calculated as [Remaining XP]/[XP per Run].");
+ tooltipToDisplay.add("The [XP per Run] is the average xp gained from an S+ run");
+ tooltipToDisplay.add(
+ "The " + EnumChatFormatting.DARK_PURPLE + "Catacombs Expert Ring" + EnumChatFormatting.GRAY +
+ " is assumed to be used, unless " + EnumChatFormatting.YELLOW + "SHIFT" + EnumChatFormatting.GRAY +
+ " is held.");
+ tooltipToDisplay.add("[Time per run] is calculated using Fastest S+ x 120%");
+ } else {
+ tooltipToDisplay.add(
+ "[Hold " + EnumChatFormatting.YELLOW + "CTRL" + EnumChatFormatting.GRAY + " to see details]");
+ }
+ }
+
+ if (mouseX > x && mouseX < x + sectionWidth && mouseY > y + 16 && mouseY < y + 24 && onMasterMode) {
+ float M3 = (Utils.getElementAsFloat(Utils.getElement(
+ profileInfo,
+ "dungeons.dungeon_types.master_catacombs.tier_completions." + 3
+ ), 0));
+ float M4 = (Utils.getElementAsFloat(Utils.getElement(
+ profileInfo,
+ "dungeons.dungeon_types.master_catacombs.tier_completions." + 4
+ ), 0));
+ float M5 = (Utils.getElementAsFloat(Utils.getElement(
+ profileInfo,
+ "dungeons.dungeon_types.master_catacombs.tier_completions." + 5
+ ), 0)); //this can prob be done better
+ float M6 = (Utils.getElementAsFloat(Utils.getElement(
+ profileInfo,
+ "dungeons.dungeon_types.master_catacombs.tier_completions." + 6
+ ), 0));
+ if (M3 > 50) {
+ M3 = 50;
+ }
+ if (M4 > 50) {
+ M4 = 50;
+ }
+ if (M5 > 50) {
+ M5 = 50;
+ }
+ if (M6 > 50) {
+ M6 = 50;
+ }
+ float xpM3 = 36500 * (M3 / 100 + 1);
+ float xpM4 = 48500 * (M4 / 100 + 1);
+ float xpM5 = 70000 * (M5 / 100 + 1);
+ float xpM6 = 100000 * (M6 / 100 + 1);
+ //No clue if M3 or M4 xp values are right
+ if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
+ xpM3 *= 1.1;
+ xpM4 *= 1.1;
+ xpM5 *= 1.1;
+ xpM6 *= 1.1;
+ }
+
+ long runsM3 = (int) Math.ceil(floorLevelToXP / xpM3);
+ long runsM4 = (int) Math.ceil(floorLevelToXP / xpM4);
+ long runsM5 = (int) Math.ceil(floorLevelToXP / xpM5);
+ long runsM6 = (int) Math.ceil(floorLevelToXP / xpM6);
+
+ float timeM3 = Utils.getElementAsFloat(Utils.getElement(
+ profileInfo,
+ "dungeons.dungeon_types.master_catacombs.fastest_time_s_plus.3"
+ ), 0);
+ float timeM4 = Utils.getElementAsFloat(Utils.getElement(
+ profileInfo,
+ "dungeons.dungeon_types.master_catacombs.fastest_time_s_plus.4"
+ ), 0);
+ float timeM5 = Utils.getElementAsFloat(Utils.getElement(
+ profileInfo,
+ "dungeons.dungeon_types.master_catacombs.fastest_time_s_plus.5"
+ ), 0);
+ float timeM6 = Utils.getElementAsFloat(Utils.getElement(
+ profileInfo,
+ "dungeons.dungeon_types.master_catacombs.fastest_time_s_plus.6"
+ ), 0);
+
+ tooltipToDisplay = Lists.newArrayList(
+ String.format("# M3 Runs (%s xp) : %d", shortNumberFormat(xpM3, 0), runsM3),
+ String.format("# M4 Runs (%s xp) : %d", shortNumberFormat(xpM4, 0), runsM4),
+ String.format("# M5 Runs (%s xp) : %d", shortNumberFormat(xpM5, 0), runsM5),
+ String.format("# M6 Runs (%s xp) : %d", shortNumberFormat(xpM6, 0), runsM6),
+ ""
+ );
+ boolean hasTime = false;
+ if (timeM3 > 1000) {
+ tooltipToDisplay.add(String.format(
+ "Expected Time (M3) : %s",
+ Utils.prettyTime(runsM3 * (long) (timeM3 * 1.2))
+ ));
+ hasTime = true;
+ }
+ if (timeM4 > 1000) {
+ tooltipToDisplay.add(String.format(
+ "Expected Time (M4) : %s",
+ Utils.prettyTime(runsM4 * (long) (timeM4 * 1.2))
+ ));
+ hasTime = true;
+ }
+ if (timeM5 > 1000) {
+ tooltipToDisplay.add(String.format(
+ "Expected Time (M5) : %s",
+ Utils.prettyTime(runsM5 * (long) (timeM5 * 1.2))
+ ));
+ hasTime = true;
+ }
+ if (timeM6 > 1000) {
+ tooltipToDisplay.add(String.format(
+ "Expected Time (M6) : %s",
+ Utils.prettyTime(runsM6 * (long) (timeM6 * 1.2))
+ ));
+ hasTime = true;
+ }
+ if (hasTime) {
+ tooltipToDisplay.add("");
+ }
+ if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
+ tooltipToDisplay.add(
+ "[Hold " + EnumChatFormatting.YELLOW + "SHIFT" + EnumChatFormatting.GRAY + " to show without Expert Ring]");
+ }
+ if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) {
+ if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) tooltipToDisplay.add("");
+ tooltipToDisplay.add("Number of runs is calculated as [Remaining XP]/[XP per Run].");
+ tooltipToDisplay.add("The [XP per Run] is the average xp gained from an S+ run");
+ tooltipToDisplay.add(
+ "The " + EnumChatFormatting.DARK_PURPLE + "Catacombs Expert Ring" + EnumChatFormatting.GRAY +
+ " is assumed to be used, unless " + EnumChatFormatting.YELLOW + "SHIFT" + EnumChatFormatting.GRAY +
+ " is held.");
+ tooltipToDisplay.add("[Time per run] is calculated using Fastest S+ x 120%");
+ } else {
+ tooltipToDisplay.add(
+ "[Hold " + EnumChatFormatting.YELLOW + "CTRL" + EnumChatFormatting.GRAY + " to see details]");
+ }
+ }
+
+ dungeonLevelTextField.setSize(20, 10);
+ dungeonLevelTextField.render(x + 22, y + 29);
+ int calcLen = fontRendererObj.getStringWidth("Calculate");
+ Utils.renderShadowedString(EnumChatFormatting.WHITE + "Calculate", x + sectionWidth - 17 - calcLen / 2f,
+ y + 30, 100
+ );
+
+ //Random stats
+
+ float secrets = Utils.getElementAsFloat(Utils.getElement(
+ hypixelInfo,
+ "achievements.skyblock_treasure_hunter"
+ ), 0);
+ float totalRuns = 0;
+ float totalRunsF = 0;
+ float totalRunsF5 = 0;
+ for (int i = 1; i <= 7; i++) {
+ float runs = Utils.getElementAsFloat(Utils.getElement(
+ profileInfo,
+ "dungeons.dungeon_types.catacombs.tier_completions." + i
+ ), 0);
+ totalRunsF += runs;
+ if (i >= 5) {
+ totalRunsF5 += runs;
+ }
+ }
+ float totalRunsM = 0;
+ float totalRunsM5 = 0;
+ for (int i = 1; i <= 7; i++) {
+ float runs = Utils.getElementAsFloat(Utils.getElement(
+ profileInfo,
+ "dungeons.dungeon_types.master_catacombs.tier_completions." + i
+ ), 0);
+ totalRunsM += runs;
+ if (i >= 5) {
+ totalRunsM5 += runs;
+ }
+ }
+ totalRuns = totalRunsF + totalRunsM;
+
+ float mobKills = 0;
+ float mobKillsF = 0;
+ float mobKillsF5 = 0;
+ for (int i = 1; i <= 7; i++) {
+ float kills = Utils.getElementAsFloat(Utils.getElement(
+ profileInfo,
+ "dungeons.dungeon_types.catacombs.mobs_killed." + i
+ ), 0);
+ mobKillsF += kills;
+ if (i >= 5) {
+ mobKillsF5 += kills;
+ }
+ }
+ float mobKillsM = 0;
+ float mobKillsM5 = 0;
+ for (int i = 1; i <= 7; i++) {
+ float kills = Utils.getElementAsFloat(Utils.getElement(
+ profileInfo,
+ "dungeons.dungeon_types.master_catacombs.mobs_killed." + i
+ ), 0);
+ mobKillsM += kills;
+ if (i >= 5) {
+ mobKillsM5 += kills;
+ }
+ }
+ mobKills = mobKillsF + mobKillsM;
+
+ int miscTopY = y + 55;
+
+ Utils.renderAlignedString(
+ EnumChatFormatting.YELLOW + "Total Runs " + (onMasterMode ? "M" : "F"),
+ EnumChatFormatting.WHITE.toString() + ((int) (onMasterMode ? totalRunsM : totalRunsF)),
+ x,
+ miscTopY,
+ sectionWidth
+ );
+ Utils.renderAlignedString(
+ EnumChatFormatting.YELLOW + "Total Runs (" + (onMasterMode ? "M" : "F") + "5-7) ",
+ EnumChatFormatting.WHITE.toString() + ((int) (onMasterMode ? totalRunsM5 : totalRunsF5)),
+ x,
+ miscTopY + 10,
+ sectionWidth
+ );
+ Utils.renderAlignedString(EnumChatFormatting.YELLOW + "Secrets (Total) ",
+ EnumChatFormatting.WHITE + shortNumberFormat(secrets, 0), x, miscTopY + 20, sectionWidth
+ );
+ Utils.renderAlignedString(
+ EnumChatFormatting.YELLOW + "Secrets (/Run) ",
+ EnumChatFormatting.WHITE.toString() + (Math.round(secrets / Math.max(1, totalRuns) * 100) / 100f),
+ x,
+ miscTopY + 30,
+ sectionWidth
+ );
+ Utils.renderAlignedString(EnumChatFormatting.YELLOW + "Mob Kills (Total) ",
+ EnumChatFormatting.WHITE + shortNumberFormat(mobKills, 0), x, miscTopY + 40, sectionWidth
+ );
+
+ int y3 = y + 117;
+
+ for (int i = 1; i <= 7; i++) {
+ int w = fontRendererObj.getStringWidth("" + i);
+
+ int bx = x + sectionWidth * i / 8 - w / 2;
+
+ boolean invert = i == floorTime;
+ float uMin = 20 / 256f;
+ float uMax = 29 / 256f;
+ float vMin = 0 / 256f;
+ float vMax = 11 / 256f;
+
+ GlStateManager.color(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements);
+ Utils.drawTexturedRect(bx - 2, y3 - 2, 9, 11,
+ invert ? uMax : uMin, invert ? uMin : uMax,
+ invert ? vMax : vMin, invert ? vMin : vMax, GL11.GL_NEAREST
+ );
+
+ Utils.renderShadowedString(EnumChatFormatting.WHITE.toString() + i, bx + w / 2, y3, 10);
+ }
+
+ float timeNorm = Utils.getElementAsFloat(Utils.getElement(
+ profileInfo,
+ "dungeons.dungeon_types." + dungeonString + ".fastest_time." + floorTime
+ ), 0);
+ float timeS = Utils.getElementAsFloat(Utils.getElement(
+ profileInfo,
+ "dungeons.dungeon_types." + dungeonString + ".fastest_time_s." + floorTime
+ ), 0);
+ float timeSPLUS = Utils.getElementAsFloat(Utils.getElement(
+ profileInfo,
+ "dungeons.dungeon_types." + dungeonString + ".fastest_time_s_plus." + floorTime
+ ), 0);
+ String timeNormStr = timeNorm <= 0 ? "N/A" : Utils.prettyTime((long) timeNorm);
+ String timeSStr = timeS <= 0 ? "N/A" : Utils.prettyTime((long) timeS);
+ String timeSPlusStr = timeSPLUS <= 0 ? "N/A" : Utils.prettyTime((long) timeSPLUS);
+ Utils.renderAlignedString(EnumChatFormatting.YELLOW + "Floor " + floorTime + " ",
+ EnumChatFormatting.WHITE + timeNormStr, x, y3 + 10, sectionWidth
+ );
+ Utils.renderAlignedString(EnumChatFormatting.YELLOW + "Floor " + floorTime + " S",
+ EnumChatFormatting.WHITE + timeSStr, x, y3 + 20, sectionWidth
+ );
+ Utils.renderAlignedString(EnumChatFormatting.YELLOW + "Floor " + floorTime + " S+",
+ EnumChatFormatting.WHITE + timeSPlusStr, x, y3 + 30, sectionWidth
+ );
+ }
+
+ //Completions
+ {
+ int x = guiLeft + 161;
+ int y = guiTop + 27;
+
+ Utils.renderShadowedString(EnumChatFormatting.RED + "Boss Collections",
+ x + sectionWidth / 2, y, sectionWidth
+ );
+ for (int i = 1; i <= 7; i++) {
+ float compl = Utils.getElementAsFloat(Utils.getElement(
+ profileInfo,
+ "dungeons.dungeon_types." + dungeonString + ".tier_completions." + i
+ ), 0);
+
+ if (BOSS_HEADS[i - 1] == null) {
+ String textureLink = bossFloorHeads[i - 1];
+
+ String b64Decoded =
+ "{\"textures\":{\"SKIN\":{\"url\":\"http://textures.minecraft.net/texture/" + textureLink + "\"}}}";
+ String b64Encoded = new String(Base64.getEncoder().encode(b64Decoded.getBytes()));
+
+ ItemStack stack = new ItemStack(Items.skull, 1, 3);
+ NBTTagCompound nbt = new NBTTagCompound();
+ NBTTagCompound skullOwner = new NBTTagCompound();
+ NBTTagCompound properties = new NBTTagCompound();
+ NBTTagList textures = new NBTTagList();
+ NBTTagCompound textures_0 = new NBTTagCompound();
+
+ String uuid = UUID.nameUUIDFromBytes(b64Encoded.getBytes()).toString();
+ skullOwner.setString("Id", uuid);
+ skullOwner.setString("Name", uuid);
+
+ textures_0.setString("Value", b64Encoded);
+ textures.appendTag(textures_0);
+
+ properties.setTag("textures", textures);
+ skullOwner.setTag("Properties", properties);
+ nbt.setTag("SkullOwner", skullOwner);
+ stack.setTagCompound(nbt);
+
+ BOSS_HEADS[i - 1] = stack;
+ }
+
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(x - 4, y + 10 + 20 * (i - 1), 0);
+ GlStateManager.scale(1.3f, 1.3f, 1);
+ Utils.drawItemStack(BOSS_HEADS[i - 1], 0, 0);
+ GlStateManager.popMatrix();
+
+ Utils.renderAlignedString(String.format(
+ EnumChatFormatting.YELLOW + "%s (" + (onMasterMode ? "M" : "F") + "%d) ",
+ bossFloorArr[i - 1],
+ i
+ ),
+ EnumChatFormatting.WHITE.toString() + (int) compl,
+ x + 16, y + 18 + 20 * (i - 1), sectionWidth - 15
+ );
+
+ }
+ }
+
+ //Skills
+ {
+ int x = guiLeft + 298;
+ int y = guiTop + 27;
+
+ //Gui.drawRect(x, y, x+120, y+147, 0xffffffff);
+
+ Utils.renderShadowedString(EnumChatFormatting.DARK_PURPLE + "Class Levels",
+ x + sectionWidth / 2, y, sectionWidth
+ );
+
+ JsonElement activeClassElement = Utils.getElement(profileInfo, "dungeons.selected_dungeon_class");
+ String activeClass = null;
+ if (activeClassElement instanceof JsonPrimitive && ((JsonPrimitive) activeClassElement).isString()) {
+ activeClass = activeClassElement.getAsString();
+ }
+
+ for (int i = 0; i < dungSkillsName.length; i++) {
+ String skillName = dungSkillsName[i];
+
+ HashMap<String, ProfileViewer.Level> levelObjClasses =
+ levelObjClasseses.computeIfAbsent(profileId, k -> new HashMap<>());
+ if (!levelObjClasses.containsKey(skillName)) {
+ float cataXp = Utils.getElementAsFloat(Utils.getElement(
+ profileInfo,
+ "dungeons.player_classes." + skillName.toLowerCase() + ".experience"
+ ), 0);
+ ProfileViewer.Level levelObj =
+ ProfileViewer.getLevel(Utils.getElement(leveling, "catacombs").getAsJsonArray(),
+ cataXp, 50, false
+ );
+ levelObjClasses.put(skillName, levelObj);
+ }
+
+ String colour = EnumChatFormatting.WHITE.toString();
+ if (skillName.toLowerCase().equals(activeClass)) {
+ colour = EnumChatFormatting.GREEN.toString();
+ }
+
+ ProfileViewer.Level levelObj = levelObjClasses.get(skillName);
+
+ renderXpBar(colour + skillName, dungSkillsStack[i], x, y + 20 + 29 * i, sectionWidth, levelObj, mouseX, mouseY);
+ }
+ }
+
+ drawSideButtons();
+
+ //drawSideButton(0, dungeonsModeIcons.get("catacombs"), true);
+ //drawSideButton(1, dungeonsModeIcons.get("master_catacombs"), true);
+ //drawSideButton(1, dungeonsModeIcons.get("catacombs"), true);
+ //drawSideButton(2, dungeonsModeIcons.get("catacombs"), false);
+ }
+
+ private boolean onMasterMode = false;
+
+ //TODO: improve this shit
+ private void drawSideButtons() {
+ // GlStateManager.pushMatrix();
+ GlStateManager.enableDepth();
+ GlStateManager.translate(0, 0, 5);
+ if (onMasterMode) {
+ drawSideButton(1, dungeonsModeIcons.get("master_catacombs"), true);
+ } else {
+ drawSideButton(0, dungeonsModeIcons.get("catacombs"), true);
+ }
+ GlStateManager.translate(0, 0, -3);
+
+ GlStateManager.translate(0, 0, -2);
+ if (!onMasterMode) {
+ drawSideButton(1, dungeonsModeIcons.get("master_catacombs"), false);
+ } else {
+ drawSideButton(0, dungeonsModeIcons.get("catacombs"), false);
+ }
+ GlStateManager.disableDepth();
+ //GlStateManager.popMatrix();
+ }
+
+ private void drawSideButton(int yIndex, ItemStack itemStack, boolean pressed) {
+ GlStateManager.disableLighting();
+ GlStateManager.enableBlend();
+ GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ GlStateManager.enableAlpha();
+ GlStateManager.alphaFunc(516, 0.1F);
+
+ int x = guiLeft - 28;
+ int y = guiTop + yIndex * 28;
+
+ float uMin = 193 / 256f;
+ float uMax = 223 / 256f;
+ float vMin = 200 / 256f;
+ float vMax = 228 / 256f;
+ if (pressed) {
+ uMin = 224 / 256f;
+ uMax = 1f;
+
+ if (yIndex != 0) {
+ vMin = 228 / 256f;
+ vMax = 1f;
+ }
+
+ renderBlurredBackground(width, height, x + 2, y + 2, 30, 28 - 4);
+ } else {
+ renderBlurredBackground(width, height, x + 2, y + 2, 28 - 2, 28 - 4);
+ }
+
+ GlStateManager.disableLighting();
+ GlStateManager.enableBlend();
+ GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ GlStateManager.enableAlpha();
+ GlStateManager.alphaFunc(516, 0.1F);
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements);
+
+ Utils.drawTexturedRect(x, y, pressed ? 32 : 28, 28, uMin, uMax, vMin, vMax, GL11.GL_NEAREST);
+
+ GlStateManager.enableDepth();
+ Utils.drawItemStack(itemStack, x + 8, y + 7);
+ }
+
+ private void renderXpBar(
+ String skillName,
+ ItemStack stack,
+ int x,
+ int y,
+ int xSize,
+ ProfileViewer.Level levelObj,
+ int mouseX,
+ int mouseY
+ ) {
+ float level = levelObj.level;
+ int levelFloored = (int) Math.floor(level);
+
+ Utils.renderAlignedString(skillName, EnumChatFormatting.WHITE.toString() + levelFloored, x + 14, y - 4, xSize - 20);
+
+ if (levelObj.maxed) {
+ renderGoldBar(x, y + 6, xSize);
+ } else {
+ renderBar(x, y + 6, xSize, level % 1);
+ }
+
+ if (mouseX > x && mouseX < x + 120) {
+ if (mouseY > y - 4 && mouseY < y + 13) {
+ String levelStr;
+ String totalXpStr = null;
+ if (levelObj.maxed) {
+ levelStr = EnumChatFormatting.GOLD + "MAXED!";
+ if (skillName.contains("Catacombs"))
+ totalXpStr = EnumChatFormatting.GRAY + "Total XP: " + EnumChatFormatting.DARK_PURPLE +
+ Utils.formatNumberWithDots((long) levelObj.totalXp);
+ } else {
+ int maxXp = (int) levelObj.maxXpForLevel;
+ levelStr = EnumChatFormatting.DARK_PURPLE + shortNumberFormat(
+ Math.round((level % 1) * maxXp),
+ 0
+ ) + "/" + shortNumberFormat(maxXp, 0);
+ }
+ if (totalXpStr != null) {
+ tooltipToDisplay = Utils.createList(levelStr, totalXpStr);
+ } else {
+ tooltipToDisplay = Utils.createList(levelStr);
+ }
+ }
+ }
+
+ GL11.glTranslatef((x), (y - 6f), 0);
+ GL11.glScalef(0.7f, 0.7f, 1);
+ Utils.drawItemStackLinear(stack, 0, 0);
+ GL11.glScalef(1 / 0.7f, 1 / 0.7f, 1);
+ GL11.glTranslatef(-(x), -(y - 6f), 0);
+ }
+
+ public static class PetLevel {
+ public float level;
+ public float currentLevelRequirement;
+ public float maxXP;
+ public float levelPercentage;
+ public float levelXp;
+ public float totalXp;
+ }
+
+ private static JsonObject getPetInfo(String pet_name, String rarity) {
+ JsonObject petInfo = new JsonObject();
+ //System.out.println(pet_name);
+ //System.out.println(rarity);
+
+ if (Constants.PETS.has("custom_pet_leveling") &&
+ Constants.PETS.getAsJsonObject("custom_pet_leveling").has(pet_name)) {
+ JsonObject pet = Constants.PETS.getAsJsonObject("custom_pet_leveling").getAsJsonObject(pet_name);
+ if (pet.has("type") && pet.has("pet_levels")) {
+ int type = pet.get("type").getAsInt();
+ switch (type) {
+ case 1:
+ JsonArray defaultLevels = Constants.PETS.getAsJsonArray("pet_levels");
+ defaultLevels.addAll(pet.getAsJsonArray("pet_levels"));
+ petInfo.add("pet_levels", Constants.PETS.getAsJsonArray("pet_levels"));
+ break;
+ case 2:
+ petInfo.add("pet_levels", pet.getAsJsonArray("pet_levels"));
+ break;
+ default:
+ petInfo.add("pet_levels", Constants.PETS.getAsJsonArray("pet_levels"));
+ break;
+ }
+ } else {
+ petInfo.add("pet_levels", Constants.PETS.getAsJsonArray("pet_levels"));
+ }
+ if (pet.has("max_level")) {
+ petInfo.add("max_level", pet.get("max_level"));
+ } else {
+ petInfo.add("max_level", new JsonPrimitive(100));
+ }
+
+ if (pet.has("pet_rarity_offset")) {
+ petInfo.add("offset", pet.get("pet_rarity_offset"));
+ } else {
+ petInfo.add("offset", Constants.PETS.getAsJsonObject("pet_rarity_offset").get(rarity));
+ }
+
+ } else {
+ //System.out.println("Default Path");
+ petInfo.add("offset", Constants.PETS.getAsJsonObject("pet_rarity_offset").get(rarity));
+ petInfo.add("max_level", new JsonPrimitive(100));
+ petInfo.add("pet_levels", Constants.PETS.getAsJsonArray("pet_levels"));
+ }
+
+ return petInfo;
+
+ }
+
+ public static PetLevel getPetLevel(String pet_name, String rarity, float exp) {
+ JsonObject petInfo = getPetInfo(pet_name, rarity);
+ int offset = petInfo.get("offset").getAsInt();
+ int maxPetLevel = petInfo.get("max_level").getAsInt();
+ JsonArray levels = petInfo.getAsJsonArray("pet_levels");
+
+ float xpTotal = 0;
+ float level = 1;
+ float currentLevelRequirement = 0;
+ float currentLevelProgress = 0;
+
+ boolean addLevel = true;
+
+ for (int i = offset; i < offset + maxPetLevel - 1; i++) {
+ if (addLevel) {
+ currentLevelRequirement = levels.get(i).getAsFloat();
+ xpTotal += currentLevelRequirement;
+ if (xpTotal > exp) {
+ currentLevelProgress = (exp - (xpTotal - currentLevelRequirement));
+ addLevel = false;
+ } else {
+ level += 1;
+ }
+ } else {
+
+ xpTotal += levels.get(i).getAsFloat();
+
+ }
+ }
+
+ level += currentLevelProgress / currentLevelRequirement;
+ if (level <= 0) {
+ level = 1;
+ } else if (level > maxPetLevel) {
+ level = maxPetLevel;
+ }
+ PetLevel levelObj = new PetLevel();
+ levelObj.level = level;
+ levelObj.currentLevelRequirement = currentLevelRequirement;
+ levelObj.maxXP = xpTotal;
+ levelObj.levelPercentage = currentLevelProgress / currentLevelRequirement;
+ levelObj.levelXp = currentLevelProgress;
+ levelObj.totalXp = exp;
+ return levelObj;
+ }
+
+ public static final HashMap<String, HashMap<String, Float>> PET_STAT_BOOSTS =
+ new HashMap<String, HashMap<String, Float>>() {{
+ put("PET_ITEM_BIG_TEETH_COMMON", new HashMap<String, Float>() {{
+ put("CRIT_CHANCE", 5f);
+ }});
+ put("PET_ITEM_HARDENED_SCALES_UNCOMMON", new HashMap<String, Float>() {{
+ put("DEFENCE", 25f);
+ }});
+ put("PET_ITEM_LUCKY_CLOVER", new HashMap<String, Float>() {{
+ put("MAGIC_FIND", 7f);
+ }});
+ put("PET_ITEM_SHARPENED_CLAWS_UNCOMMON", new HashMap<String, Float>() {{
+ put("CRIT_DAMAGE", 15f);
+ }});
+ }};
+
+ public static final HashMap<String, HashMap<String, Float>> PET_STAT_BOOSTS_MULT =
+ new HashMap<String, HashMap<String, Float>>() {{
+ put("PET_ITEM_IRON_CLAWS_COMMON", new HashMap<String, Float>() {{
+ put("CRIT_DAMAGE", 1.4f);
+ put("CRIT_CHANCE", 1.4f);
+ }});
+ put("PET_ITEM_TEXTBOOK", new HashMap<String, Float>() {{
+ put("INTELLIGENCE", 2f);
+ }});
+ }};
+
+ private int selectedPet = -1;
+ private int petsPage = 0;
+ private List<JsonObject> sortedPets = null;
+ private List<ItemStack> sortedPetsStack = null;
+ public static HashMap<String, String> MINION_RARITY_TO_NUM = new HashMap<String, String>() {{
+ put("COMMON", "0");
+ put("UNCOMMON", "1");
+ put("RARE", "2");
+ put("EPIC", "3");
+ put("LEGENDARY", "4");
+ put("MYTHIC", "5");
+ }};
+
+ private void drawPetsPage(int mouseX, int mouseY, float partialTicks) {
+ JsonObject petsInfo = profile.getPetsInfo(profileId);
+ if (petsInfo == null) return;
+ JsonObject petsJson = Constants.PETS;
+ if (petsJson == null) return;
+
+ String location = null;
+ JsonObject status = profile.getPlayerStatus();
+ if (status != null && status.has("mode")) {
+ location = status.get("mode").getAsString();
+ }
+
+ backgroundRotation += (currentTime - lastTime) / 400f;
+ backgroundRotation %= 360;
+
+ String panoramaIdentifier = "day";
+ if (SBInfo.getInstance().currentTimeDate != null) {
+ if (SBInfo.getInstance().currentTimeDate.getHours() <= 6 ||
+ SBInfo.getInstance().currentTimeDate.getHours() >= 20) {
+ panoramaIdentifier = "night";
+ }
+ }
+
+ JsonArray pets = petsInfo.get("pets").getAsJsonArray();
+ if (sortedPets == null) {
+ sortedPets = new ArrayList<>();
+ sortedPetsStack = new ArrayList<>();
+ for (int i = 0; i < pets.size(); i++) {
+ sortedPets.add(pets.get(i).getAsJsonObject());
+ }
+ sortedPets.sort((pet1, pet2) -> {
+ String tier1 = pet1.get("tier").getAsString();
+ String tierNum1 = MINION_RARITY_TO_NUM.get(tier1);
+ if (tierNum1 == null) return 1;
+ int tierNum1I = Integer.parseInt(tierNum1);
+ float exp1 = pet1.get("exp").getAsFloat();
+
+ String tier2 = pet2.get("tier").getAsString();
+ String tierNum2 = MINION_RARITY_TO_NUM.get(tier2);
+ if (tierNum2 == null) return -1;
+ int tierNum2I = Integer.parseInt(tierNum2);
+ float exp2 = pet2.get("exp").getAsFloat();
+
+ if (tierNum1I != tierNum2I) {
+ return tierNum2I - tierNum1I;
+ } else {
+ return (int) (exp2 - exp1);
+ }
+ });
+ for (JsonObject pet : sortedPets) {
+ String petname = pet.get("type").getAsString();
+ String tier = pet.get("tier").getAsString();
+ String heldItem = Utils.getElementAsString(pet.get("heldItem"), null);
+ String skin = Utils.getElementAsString(pet.get("skin"), null);
+ int candy = pet.get("candyUsed").getAsInt();
+ JsonObject heldItemJson =
+ heldItem == null ? null : NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(heldItem);
+ String tierNum = MINION_RARITY_TO_NUM.get(tier);
+ float exp = pet.get("exp").getAsFloat();
+ if (tierNum == null) continue;
+
+ if (pet.has("heldItem") && !pet.get("heldItem").isJsonNull() &&
+ pet.get("heldItem").getAsString().equals("PET_ITEM_TIER_BOOST")) {
+ tierNum = "" + (Integer.parseInt(tierNum) + 1);
+ }
+
+ PetLevel levelObj = GuiProfileViewer.getPetLevel(petname, tier, exp);
+
+ float level = levelObj.level;
+ float currentLevelRequirement = levelObj.currentLevelRequirement;
+ float maxXP = levelObj.maxXP;
+ pet.addProperty("level", level);
+ pet.addProperty("currentLevelRequirement", currentLevelRequirement);
+ pet.addProperty("maxXP", maxXP);
+
+ JsonObject petItem = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(petname + ";" + tierNum);
+ if (petItem == null) continue;
+
+ ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(petItem, false, false);
+ HashMap<String, String> replacements =
+ NotEnoughUpdates.INSTANCE.manager.getLoreReplacements(petname, tier, (int) Math.floor(level));
+
+ if (heldItem != null) {
+ HashMap<String, Float> petStatBoots = PET_STAT_BOOSTS.get(heldItem);
+ HashMap<String, Float> petStatBootsMult = PET_STAT_BOOSTS_MULT.get(heldItem);
+ if (petStatBoots != null) {
+ for (Map.Entry<String, Float> entryBoost : petStatBoots.entrySet()) {
+ try {
+ float value = Float.parseFloat(replacements.get(entryBoost.getKey()));
+ replacements.put(entryBoost.getKey(), String.valueOf((int) Math.floor(value + entryBoost.getValue())));
+ } catch (Exception ignored) {
+ }
+ }
+
+ }
+ if (petStatBootsMult != null) {
+ for (Map.Entry<String, Float> entryBoost : petStatBootsMult.entrySet()) {
+ try {
+ float value = Float.parseFloat(replacements.get(entryBoost.getKey()));
+ replacements.put(entryBoost.getKey(), String.valueOf((int) Math.floor(value * entryBoost.getValue())));
+ } catch (Exception ignored) {
+ }
+ }
+ }
+ }
+
+ NBTTagCompound tag = stack.getTagCompound() == null ? new NBTTagCompound() : stack.getTagCompound();
+ if (tag.hasKey("display", 10)) {
+ NBTTagCompound display = tag.getCompoundTag("display");
+ if (display.hasKey("Lore", 9)) {
+ NBTTagList newLore = new NBTTagList();
+ NBTTagList lore = display.getTagList("Lore", 8);
+ HashMap<Integer, Integer> blankLocations = new HashMap<>();
+ for (int j = 0; j < lore.tagCount(); j++) {
+ String line = lore.getStringTagAt(j);
+ if (line.trim().isEmpty()) {
+ blankLocations.put(blankLocations.size(), j);
+ }
+ for (Map.Entry<String, String> replacement : replacements.entrySet()) {
+ line = line.replace("{" + replacement.getKey() + "}", replacement.getValue());
+ }
+ newLore.appendTag(new NBTTagString(line));
+ }
+ Integer secondLastBlank = blankLocations.get(blankLocations.size() - 2);
+ if (skin != null) {
+ JsonObject petSkin = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("PET_SKIN_" + skin);
+ if (petSkin != null) {
+ try {
+ NBTTagCompound nbt = JsonToNBT.getTagFromJson(petSkin.get("nbttag").getAsString());
+ tag.setTag("SkullOwner", nbt.getTag("SkullOwner"));
+ String name = petSkin.get("displayname").getAsString();
+ if (name != null) {
+ name = Utils.cleanColour(name);
+ newLore.set(0, new NBTTagString(newLore.get(0).toString().replace("\"", "") + ", " + name));
+ }
+ } catch (NBTException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ for (int i = 0; i < newLore.tagCount(); i++) {
+ String cleaned = Utils.cleanColour(newLore.get(i).toString());
+ if (cleaned.equals("\"Right-click to add this pet to\"")) {
+ newLore.removeTag(i + 1);
+ newLore.removeTag(i);
+ secondLastBlank = i - 1;
+ break;
+ }
+ }
+ NBTTagList temp = new NBTTagList();
+ for (int i = 0; i < newLore.tagCount(); i++) {
+ temp.appendTag(newLore.get(i));
+ if (secondLastBlank != null && i == secondLastBlank) {
+ if (heldItem != null) {
+ temp.appendTag(new NBTTagString(
+ EnumChatFormatting.GOLD + "Held Item: " + heldItemJson.get("displayname").getAsString()));
+ int blanks = 0;
+ JsonArray heldItemLore = heldItemJson.get("lore").getAsJsonArray();
+ for (int k = 0; k < heldItemLore.size(); k++) {
+ String heldItemLine = heldItemLore.get(k).getAsString();
+ if (heldItemLine.trim().isEmpty()) {
+ blanks++;
+ } else if (blanks == 2) {
+ temp.appendTag(new NBTTagString(heldItemLine));
+ } else if (blanks > 2) {
+ break;
+ }
+ }
+ temp.appendTag(new NBTTagString());
+ }
+ if (candy != 0) {
+ temp.appendTag(new NBTTagString(EnumChatFormatting.GREEN + "(" + candy + "/10) Pet Candy Used"));
+ temp.appendTag(new NBTTagString());
+ }
+ temp.removeTag(temp.tagCount() - 1);
+ }
+ }
+ newLore = temp;
+ display.setTag("Lore", newLore);
+ }
+ if (display.hasKey("Name", 8)) {
+ String displayName = display.getString("Name");
+ for (Map.Entry<String, String> replacement : replacements.entrySet()) {
+ displayName = displayName.replace("{" + replacement.getKey() + "}", replacement.getValue());
+ }
+ display.setTag("Name", new NBTTagString(displayName));
+ }
+ tag.setTag("display", display);
+ }
+ stack.setTagCompound(tag);
+
+ sortedPetsStack.add(stack);
+ }
+ }
+
+ Panorama.drawPanorama(-backgroundRotation, guiLeft + 212, guiTop + 44, 81, 108, -0.37f, 0.6f,
+ getPanoramasForLocation(location == null ? "dynamic" : location, panoramaIdentifier)
+ );
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_pets);
+ Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST);
+
+ Utils.drawStringCentered(EnumChatFormatting.DARK_PURPLE + "Pets", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 100, guiTop + 14, true, 4210752
+ );
+ GlStateManager.color(1, 1, 1, 1);
+
+ JsonElement activePetElement = petsInfo.get("active_pet");
+ if (selectedPet == -1 && activePetElement != null && activePetElement.isJsonObject()) {
+ JsonObject active = activePetElement.getAsJsonObject();
+ for (int i = 0; i < sortedPets.size(); i++) {
+ if (sortedPets.get(i) == active) {
+ selectedPet = i;
+ break;
+ }
+ }
+ }
+
+ boolean leftHovered = false;
+ boolean rightHovered = false;
+ if (Mouse.isButtonDown(0)) {
+ if (mouseY > guiTop + 6 && mouseY < guiTop + 22) {
+ if (mouseX > guiLeft + 100 - 20 - 12 && mouseX < guiLeft + 100 - 20) {
+ leftHovered = true;
+ } else if (mouseX > guiLeft + 100 + 20 && mouseX < guiLeft + 100 + 20 + 12) {
+ rightHovered = true;
+ }
+ }
+ }
+ Minecraft.getMinecraft().getTextureManager().bindTexture(resource_packs);
+
+ if (petsPage > 0) {
+ Utils.drawTexturedRect(guiLeft + 100 - 15 - 12, guiTop + 6, 12, 16,
+ 29 / 256f, 53 / 256f, !leftHovered ? 0 : 32 / 256f, !leftHovered ? 32 / 256f : 64 / 256f, GL11.GL_NEAREST
+ );
+ }
+ if (petsPage < Math.ceil(pets.size() / 20f) - 1) {
+ Utils.drawTexturedRect(guiLeft + 100 + 15, guiTop + 6, 12, 16,
+ 5 / 256f, 29 / 256f, !rightHovered ? 0 : 32 / 256f, !rightHovered ? 32 / 256f : 64 / 256f, GL11.GL_NEAREST
+ );
+ }
+
+ for (
+ int i = petsPage * 20;
+ i < Math.min(petsPage * 20 + 20, Math.min(sortedPetsStack.size(), sortedPets.size()));
+ i++
+ ) {
+ JsonObject pet = sortedPets.get(i);
+ ItemStack stack = sortedPetsStack.get(i);
+
+ if (pet != null) {
+ {
+ NBTTagCompound tag = stack.getTagCompound();
+ tag.setBoolean("DisablePetExp", true);
+ stack.setTagCompound(tag);
+ }
+ int xIndex = (i % 20) % COLLS_XCOUNT;
+ int yIndex = (i % 20) / COLLS_XCOUNT;
+
+ float x = 5 + COLLS_XPADDING + (COLLS_XPADDING + 20) * xIndex;
+ float y = 7 + COLLS_YPADDING + (COLLS_YPADDING + 20) * yIndex;
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements);
+ if (i == selectedPet) {
+ GlStateManager.color(1, 185 / 255f, 0, 1);
+ } else {
+ GlStateManager.color(1, 1, 1, 1);
+ }
+ Utils.drawTexturedRect(guiLeft + x, guiTop + y, 20, 20, 0, 20 / 256f, 0, 20 / 256f, GL11.GL_NEAREST);
+
+ Utils.drawItemStack(stack, guiLeft + (int) x + 2, guiTop + (int) y + 2);
+
+ if (mouseX > guiLeft + x && mouseX < guiLeft + x + 20) {
+ if (mouseY > guiTop + y && mouseY < guiTop + y + 20) {
+ tooltipToDisplay = stack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ }
+ }
+ }
+ }
+
+ if (selectedPet >= 0) {
+ ItemStack petStack = sortedPetsStack.get(selectedPet);
+ String display = petStack.getDisplayName();
+ JsonObject pet = sortedPets.get(selectedPet);
+
+ int x = guiLeft + 280;
+ float y = guiTop + 67 + 15 * (float) Math.sin(((currentTime - startTime) / 800f) % (2 * Math.PI));
+
+ int displayLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(display);
+ int halfDisplayLen = displayLen / 2;
+
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(x, y, 0);
+
+ drawRect(-halfDisplayLen - 1 - 28, -1, halfDisplayLen + 1 - 28, 8, new Color(0, 0, 0, 100).getRGB());
+
+ Minecraft.getMinecraft().fontRendererObj.drawString(display, -halfDisplayLen - 28, 0, 0, true);
+
+ GlStateManager.enableDepth();
+ GlStateManager.translate(-55, 0, 0);
+ GlStateManager.scale(3.5f, 3.5f, 1);
+ Utils.drawItemStack(petStack, 0, 0);
+ GlStateManager.popMatrix();
+
+ float level = pet.get("level").getAsFloat();
+ float currentLevelRequirement = pet.get("currentLevelRequirement").getAsFloat();
+ float exp = pet.get("exp").getAsFloat();
+ float maxXP = pet.get("maxXP").getAsFloat();
+
+ String[] split = display.split("] ");
+ String colouredName = split[split.length - 1];
+
+ Utils.renderAlignedString(
+ colouredName,
+ EnumChatFormatting.WHITE + "Level " + (int) Math.floor(level),
+ guiLeft + 319,
+ guiTop + 28,
+ 98
+ );
+
+ //Utils.drawStringCenteredScaledMaxWidth(, Minecraft.getMinecraft().fontRendererObj, guiLeft+368, guiTop+28+4, true, 98, 0);
+ //renderAlignedString(display, EnumChatFormatting.YELLOW+"[LVL "+Math.floor(level)+"]", guiLeft+319, guiTop+28, 98);
+ renderBar(guiLeft + 319, guiTop + 38, 98, (float) Math.floor(level) / 100f);
+
+ Utils.renderAlignedString(
+ EnumChatFormatting.YELLOW + "To Next LVL",
+ EnumChatFormatting.WHITE.toString() + (int) (level % 1 * 100) + "%",
+ guiLeft + 319,
+ guiTop + 46,
+ 98
+ );
+ renderBar(guiLeft + 319, guiTop + 56, 98, level % 1);
+
+ Utils.renderAlignedString(
+ EnumChatFormatting.YELLOW + "To Max LVL",
+ EnumChatFormatting.WHITE.toString() + Math.min(100, (int) (exp / maxXP * 100)) + "%",
+ guiLeft + 319,
+ guiTop + 64,
+ 98
+ );
+ renderBar(guiLeft + 319, guiTop + 74, 98, exp / maxXP);
+
+ Utils.renderAlignedString(
+ EnumChatFormatting.YELLOW + "Total XP",
+ EnumChatFormatting.WHITE + shortNumberFormat(exp, 0),
+ guiLeft + 319,
+ guiTop + 125,
+ 98
+ );
+ Utils.renderAlignedString(
+ EnumChatFormatting.YELLOW + "Current LVL XP",
+ EnumChatFormatting.WHITE + shortNumberFormat((level % 1) * currentLevelRequirement, 0),
+ guiLeft + 319,
+ guiTop + 143,
+ 98
+ );
+ Utils.renderAlignedString(
+ EnumChatFormatting.YELLOW + "Required LVL XP",
+ EnumChatFormatting.WHITE + shortNumberFormat(currentLevelRequirement, 0),
+ guiLeft + 319,
+ guiTop + 161,
+ 98
+ );
+ }
+ }
+
+ private final String[] romans = new String[]{
+ "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI",
+ "XII", "XIII", "XIV", "XV", "XVI", "XVII", "XIX", "XX"
+ };
+
+ private final int COLLS_XCOUNT = 5;
+ private final int COLLS_YCOUNT = 4;
+ private final float COLLS_XPADDING = (190 - COLLS_XCOUNT * 20) / (float) (COLLS_XCOUNT + 1);
+ private final float COLLS_YPADDING = (202 - COLLS_YCOUNT * 20) / (float) (COLLS_YCOUNT + 1);
+
+ private void drawColsPage(int mouseX, int mouseY, float partialTicks) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_cols);
+ Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST);
+
+ JsonObject collectionInfo = profile.getCollectionInfo(profileId);
+ if (collectionInfo == null) {
+ Utils.drawStringCentered(
+ EnumChatFormatting.RED + "Collection API not enabled!",
+ Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 134,
+ guiTop + 101,
+ true,
+ 0
+ );
+ return;
+ }
+ JsonObject resourceCollectionInfo = ProfileViewer.getResourceCollectionInformation();
+ if (resourceCollectionInfo == null) return;
+
+ int collectionCatSize = ProfileViewer.getCollectionCatToCollectionMap().size();
+ int collectionCatYSize = (int) (162f / (collectionCatSize - 1 + 0.0000001f));
+ {
+ int yIndex = 0;
+ for (ItemStack stack : ProfileViewer.getCollectionCatToCollectionMap().keySet()) {
+ if (selectedCollectionCategory == null) selectedCollectionCategory = stack;
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements);
+ if (stack == selectedCollectionCategory) {
+ Utils.drawTexturedRect(guiLeft + 7, guiTop + 10 + collectionCatYSize * yIndex, 20, 20,
+ 20 / 256f, 0, 20 / 256f, 0, GL11.GL_NEAREST
+ );
+ Utils.drawItemStackWithText(
+ stack,
+ guiLeft + 10,
+ guiTop + 13 + collectionCatYSize * yIndex,
+ "" + (yIndex + 1)
+ );
+ } else {
+ Utils.drawTexturedRect(guiLeft + 7, guiTop + 10 + collectionCatYSize * yIndex, 20, 20,
+ 0, 20 / 256f, 0, 20 / 256f, GL11.GL_NEAREST
+ );
+ Utils.drawItemStackWithText(stack, guiLeft + 9, guiTop + 12 + collectionCatYSize * yIndex, "" + (yIndex + 1));
+ }
+ yIndex++;
+ }
+ }
+
+ Utils.drawStringCentered(
+ selectedCollectionCategory.getDisplayName() + " Collections",
+ Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 134,
+ guiTop + 14,
+ true,
+ 4210752
+ );
+
+ JsonObject minionTiers = collectionInfo.get("minion_tiers").getAsJsonObject();
+ JsonObject collectionTiers = collectionInfo.get("collection_tiers").getAsJsonObject();
+ JsonObject maxAmounts = collectionInfo.get("max_amounts").getAsJsonObject();
+ JsonObject totalAmounts = collectionInfo.get("total_amounts").getAsJsonObject();
+ JsonObject personalAmounts = collectionInfo.get("personal_amounts").getAsJsonObject();
+
+ List<String> collections = ProfileViewer.getCollectionCatToCollectionMap().get(selectedCollectionCategory);
+ if (collections != null) {
+ for (int i = 0; i < collections.size(); i++) {
+ String collection = collections.get(i);
+ if (collection != null) {
+ ItemStack collectionItem = ProfileViewer.getCollectionToCollectionDisplayMap().get(collection);
+ if (collectionItem != null) {
+ int xIndex = i % COLLS_XCOUNT;
+ int yIndex = i / COLLS_XCOUNT;
+
+ float x = 39 + COLLS_XPADDING + (COLLS_XPADDING + 20) * xIndex;
+ float y = 7 + COLLS_YPADDING + (COLLS_YPADDING + 20) * yIndex;
+
+ String tierString;
+ int tier = (int) Utils.getElementAsFloat(collectionTiers.get(collection), 0);
+ if (tier > 20 || tier < 0) {
+ tierString = String.valueOf(tier);
+ } else {
+ tierString = romans[tier];
+ }
+ float amount = Utils.getElementAsFloat(totalAmounts.get(collection), 0);
+ float maxAmount = Utils.getElementAsFloat(maxAmounts.get(collection), 0);
+ Color color = new Color(128, 128, 128, 255);
+ int tierStringColour = color.getRGB();
+ float completedness = 0;
+ if (maxAmount > 0) {
+ completedness = amount / maxAmount;
+ }
+ completedness = Math.min(1, completedness);
+ if (maxAmounts.has(collection) && completedness >= 1) {
+ tierStringColour = new Color(255, 215, 0).getRGB();
+ }
+
+ GlStateManager.color(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements);
+ Utils.drawTexturedRect(guiLeft + x, guiTop + y, 20, 20 * (1 - completedness),
+ 0, 20 / 256f, 0, 20 * (1 - completedness) / 256f, GL11.GL_NEAREST
+ );
+ GlStateManager.color(1, 185 / 255f, 0, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements);
+ Utils.drawTexturedRect(guiLeft + x, guiTop + y + 20 * (1 - completedness), 20, 20 * (completedness),
+ 0, 20 / 256f, 20 * (1 - completedness) / 256f, 20 / 256f, GL11.GL_NEAREST
+ );
+ Utils.drawItemStack(collectionItem, guiLeft + (int) x + 2, guiTop + (int) y + 2);
+
+ if (mouseX > guiLeft + (int) x + 2 && mouseX < guiLeft + (int) x + 18) {
+ if (mouseY > guiTop + (int) y + 2 && mouseY < guiTop + (int) y + 18) {
+ tooltipToDisplay = new ArrayList<>();
+ tooltipToDisplay.add(collectionItem.getDisplayName() + " " +
+ (completedness >= 1 ? EnumChatFormatting.GOLD : EnumChatFormatting.GRAY) + tierString);
+ tooltipToDisplay.add(
+ "Collected: " + numberFormat.format(Utils.getElementAsFloat(personalAmounts.get(collection), 0)));
+ tooltipToDisplay.add("Total Collected: " + numberFormat.format(amount));
+ }
+ }
+
+ GlStateManager.color(1, 1, 1, 1);
+ if (tier >= 0) {
+ Utils.drawStringCentered(tierString, fontRendererObj,
+ guiLeft + x + 10, guiTop + y - 4, true,
+ tierStringColour
+ );
+ }
+
+ Utils.drawStringCentered(shortNumberFormat(amount, 0) + "", fontRendererObj,
+ guiLeft + x + 10, guiTop + y + 26, true,
+ color.getRGB()
+ );
+ }
+ }
+ }
+ }
+
+ Utils.drawStringCentered(
+ selectedCollectionCategory.getDisplayName() + " Minions",
+ Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 326,
+ guiTop + 14,
+ true,
+ 4210752
+ );
+
+ List<String> minions = ProfileViewer.getCollectionCatToMinionMap().get(selectedCollectionCategory);
+ if (minions != null) {
+ for (int i = 0; i < minions.size(); i++) {
+ String minion = minions.get(i);
+ if (minion != null) {
+ JsonObject misc = Constants.MISC;
+ float MAX_MINION_TIER =
+ Utils.getElementAsFloat(Utils.getElement(misc, "minions." + minion + "_GENERATOR"), 11);
+
+ int tier = (int) Utils.getElementAsFloat(minionTiers.get(minion), 0);
+ JsonObject minionJson;
+ if (tier == 0) {
+ minionJson = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(minion + "_GENERATOR_1");
+ } else {
+ minionJson = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(minion + "_GENERATOR_" + tier);
+ }
+
+ if (minionJson != null) {
+ int xIndex = i % COLLS_XCOUNT;
+ int yIndex = i / COLLS_XCOUNT;
+
+ float x = 231 + COLLS_XPADDING + (COLLS_XPADDING + 20) * xIndex;
+ float y = 7 + COLLS_YPADDING + (COLLS_YPADDING + 20) * yIndex;
+
+ String tierString;
+
+ if (tier - 1 >= romans.length || tier - 1 < 0) {
+ tierString = String.valueOf(tier);
+ } else {
+ tierString = romans[tier - 1];
+ }
+
+ Color color = new Color(128, 128, 128, 255);
+ int tierStringColour = color.getRGB();
+ float completedness = tier / MAX_MINION_TIER;
+
+ completedness = Math.min(1, completedness);
+ if (completedness >= 1) {
+ tierStringColour = new Color(255, 215, 0).getRGB();
+ }
+
+ GlStateManager.color(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements);
+ Utils.drawTexturedRect(guiLeft + x, guiTop + y, 20, 20 * (1 - completedness),
+ 0, 20 / 256f, 0, 20 * (1 - completedness) / 256f, GL11.GL_NEAREST
+ );
+ GlStateManager.color(1, 185 / 255f, 0, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements);
+ Utils.drawTexturedRect(guiLeft + x, guiTop + y + 20 * (1 - completedness), 20, 20 * (completedness),
+ 0, 20 / 256f, 20 * (1 - completedness) / 256f, 20 / 256f, GL11.GL_NEAREST
+ );
+
+ Utils.drawItemStack(
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(minionJson),
+ guiLeft + (int) x + 2,
+ guiTop + (int) y + 2
+ );
+
+ if (mouseX > guiLeft + (int) x + 2 && mouseX < guiLeft + (int) x + 18) {
+ if (mouseY > guiTop + (int) y + 2 && mouseY < guiTop + (int) y + 18) {
+ tooltipToDisplay = NotEnoughUpdates.INSTANCE.manager.jsonToStack(minionJson)
+ .getTooltip(
+ Minecraft.getMinecraft().thePlayer,
+ false
+ );
+ }
+ }
+
+ GlStateManager.color(1, 1, 1, 1);
+ if (tier >= 0) {
+ Utils.drawStringCentered(tierString, fontRendererObj,
+ guiLeft + x + 10, guiTop + y - 4, true,
+ tierStringColour
+ );
+ }
+ }
+ }
+ }
+ }
+
+ //190
+ }
+
+ private static final LinkedHashMap<String, ItemStack> invNameToDisplayMap = new LinkedHashMap<String, ItemStack>() {{
+ put(
+ "inv_contents",
+ Utils.createItemStack(Item.getItemFromBlock(Blocks.chest), EnumChatFormatting.GRAY + "Inventory")
+ );
+ put(
+ "ender_chest_contents",
+ Utils.createItemStack(Item.getItemFromBlock(Blocks.ender_chest), EnumChatFormatting.GRAY + "Ender Chest")
+ );
+ // put("backpack_contents", Utils.createItemStack(Item.getItemFromBlock(Blocks.dropper), EnumChatFormatting.GRAY+"Backpacks"));
+ put(
+ "backpack_contents",
+ Utils.editItemStackInfo(NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("JUMBO_BACKPACK")), EnumChatFormatting.GRAY + "Backpacks", true)
+ );
+ put(
+ "personal_vault_contents",
+ Utils.editItemStackInfo(NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager
+ .getItemInformation()
+ .get("IRON_CHEST")), EnumChatFormatting.GRAY + "Personal vault", true)
+ );
+ put("talisman_bag", Utils.createItemStack(Items.golden_apple, EnumChatFormatting.GRAY + "Accessory Bag"));
+ put("wardrobe_contents", Utils.createItemStack(Items.leather_chestplate, EnumChatFormatting.GRAY + "Wardrobe"));
+ put("fishing_bag", Utils.createItemStack(Items.fish, EnumChatFormatting.GRAY + "Fishing Bag"));
+ put("potion_bag", Utils.createItemStack(Items.potionitem, EnumChatFormatting.GRAY + "Potion Bag"));
+ }};
+
+ public int countItemsInInventory(
+ String internalname,
+ JsonObject inventoryInfo,
+ boolean specific,
+ String... invsToSearch
+ ) {
+ int count = 0;
+ for (String inv : invsToSearch) {
+ JsonArray invItems = inventoryInfo.get(inv).getAsJsonArray();
+ for (int i = 0; i < invItems.size(); i++) {
+ if (invItems.get(i) == null || !invItems.get(i).isJsonObject()) continue;
+ JsonObject item = invItems.get(i).getAsJsonObject();
+ if ((specific && item.get("internalname").getAsString().equals(internalname)) ||
+ (!specific && item.get("internalname").getAsString().contains(internalname))) {
+ if (item.has("count")) {
+ count += item.get("count").getAsInt();
+ } else {
+ count += 1;
+ }
+ }
+ }
+ }
+ return count;
+ }
+
+ private static final Pattern DAMAGE_PATTERN = Pattern.compile("^Damage: \\+([0-9]+)");
+ private static final Pattern STRENGTH_PATTERN = Pattern.compile("^Strength: \\+([0-9]+)");
+ private static final Pattern FISHSPEED_PATTERN = Pattern.compile("^Increases fishing speed by \\+([0-9]+)");
+
+ private ItemStack[] findBestItems(
+ JsonObject inventoryInfo,
+ int numItems,
+ String[] invsToSearch,
+ String[] typeMatches,
+ Pattern... importantPatterns
+ ) {
+ ItemStack[] bestItems = new ItemStack[numItems];
+ TreeMap<Integer, Set<ItemStack>> map = new TreeMap<>();
+ for (String inv : invsToSearch) {
+ JsonArray invItems = inventoryInfo.get(inv).getAsJsonArray();
+ for (int i = 0; i < invItems.size(); i++) {
+ if (invItems.get(i) == null || !invItems.get(i).isJsonObject()) continue;
+ JsonObject item = invItems.get(i).getAsJsonObject();
+ JsonArray lore = item.get("lore").getAsJsonArray();
+ if (Utils.checkItemType(lore, true, typeMatches) >= 0) {
+ int importance = 0;
+ for (int j = 0; j < lore.size(); j++) {
+ String line = lore.get(j).getAsString();
+ for (Pattern pattern : importantPatterns) {
+ Matcher matcher = pattern.matcher(Utils.cleanColour(line));
+ if (matcher.find()) {
+ importance += Integer.parseInt(matcher.group(1));
+ }
+ }
+ }
+ map.computeIfAbsent(importance, k -> new HashSet<>()).add(
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(item, false));
+ }
+ }
+ }
+ int i = 0;
+ outer:
+ for (int key : map.descendingKeySet()) {
+ Set<ItemStack> items = map.get(key);
+ for (ItemStack item : items) {
+ bestItems[i] = item;
+ if (++i >= bestItems.length) break outer;
+ }
+ }
+
+ return bestItems;
+ }
+
+ private int getRowsForInventory(String invName) {
+ switch (invName) {
+ case "wardrobe_contents":
+ return 4;
+ case "backpack_contents":
+ return 5;
+ case "ender_chest_contents":
+ return 5;
+ }
+ return 6;
+ }
+
+ private boolean useActualMax(String invName) {
+ switch (invName) {
+ case "talisman_bag":
+ case "fishing_bag":
+ case "potion_bag":
+ case "personal_vault_contents":
+ return true;
+ }
+ return false;
+ }
+
+ private int getIgnoredRowsForInventory(String invName) {
+ switch (invName) {
+ case "talisman_bag":
+ case "fishing_bag":
+ case "potion_bag":
+ return 1;
+ }
+ return 0;
+ }
+
+ private final ItemStack fillerStack = new ItemStack(Item.getItemFromBlock(Blocks.stained_glass_pane), 1, 15);
+
+ public ItemStack[][][] getItemsForInventory(JsonObject inventoryInfo, String invName) {
+ if (inventoryItems.containsKey(invName)) return inventoryItems.get(invName);
+
+ JsonArray jsonInv = Utils.getElement(inventoryInfo, invName).getAsJsonArray();
+
+ if (jsonInv.size() == 0) return new ItemStack[1][][];
+
+ int jsonInvSize;
+ if (useActualMax(invName)) {
+ jsonInvSize = (int) Math.ceil(jsonInv.size() / 9f) * 9;
+ } else {
+ jsonInvSize = 9 * 4;
+ float divideBy = 9f;
+ if (invName.equals("wardrobe_contents")) {
+ divideBy = 36f;
+ }
+ for (int i = 9 * 4; i < jsonInv.size(); i++) {
+ JsonElement item = jsonInv.get(i);
+ if (item != null && item.isJsonObject()) {
+ jsonInvSize = (int) (Math.ceil((i + 1) / divideBy) * (int) divideBy);
+ }
+ }
+ }
+
+ int rowSize = 9;
+ int rows = jsonInvSize / rowSize;
+ int maxRowsPerPage = getRowsForInventory(invName);
+ int maxInvSize = rowSize * maxRowsPerPage;
+
+ int numInventories = (jsonInvSize - 1) / maxInvSize + 1;
+ JsonArray backPackSizes = (JsonArray) inventoryInfo.get("backpack_sizes");
+ if (invName.equals("backpack_contents")) {
+ numInventories = backPackSizes.size();
+ }
+
+ ItemStack[][][] inventories = new ItemStack[numInventories][][];
+
+ //int availableSlots = getAvailableSlotsForInventory(inventoryInfo, collectionInfo, invName);
+ int startNumberJ = 0;
+
+ for (int i = 0; i < numInventories; i++) {
+ int thisRows = Math.min(maxRowsPerPage, rows - maxRowsPerPage * i);
+ int invSize = 0;
+
+ if (invName.equals("backpack_contents")) {
+ thisRows = backPackSizes.get(i).getAsInt() / 9;
+ invSize = startNumberJ + (thisRows * 9);
+ maxInvSize = thisRows * 9;
+ } else {
+ startNumberJ = maxInvSize * i;
+ invSize = Math.min(jsonInvSize, maxInvSize + maxInvSize * i);
+ }
+ if (thisRows <= 0) break;
+
+ ItemStack[][] items = new ItemStack[thisRows][rowSize];
+
+ for (int j = startNumberJ; j < invSize; j++) {
+
+ int xIndex = (j % maxInvSize) % rowSize;
+ int yIndex = (j % maxInvSize) / rowSize;
+ if (invName.equals("inv_contents")) {
+ yIndex--;
+ if (yIndex < 0) yIndex = rows - 1;
+ }
+ if (yIndex >= thisRows) {
+ break;
+ }
+
+ if (j >= jsonInv.size()) {
+ items[yIndex][xIndex] = fillerStack;
+ continue;
+ }
+ if (jsonInv.get(j) == null || !jsonInv.get(j).isJsonObject()) {
+ continue;
+ }
+
+ JsonObject item = jsonInv.get(j).getAsJsonObject();
+ ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(item, false);
+ if (item.has("item_contents")) {
+ JsonArray bytesArr = item.get("item_contents").getAsJsonArray();
+ byte[] bytes = new byte[bytesArr.size()];
+ for (int bytesArrI = 0; bytesArrI < bytesArr.size(); bytesArrI++) {
+ bytes[bytesArrI] = bytesArr.get(bytesArrI).getAsByte();
+ }
+ //byte[] bytes2 = null;
+ NBTTagCompound tag = stack.getTagCompound();
+ if (tag != null && tag.hasKey("ExtraAttributes", 10)) {
+ NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
+ for (String key : ea.getKeySet()) {
+ if (key.endsWith("backpack_data") || key.equals("new_year_cake_bag_data")) {
+ ea.setTag(key, new NBTTagByteArray(bytes));
+ break;
+ }
+ }
+ tag.setTag("ExtraAttributes", ea);
+ stack.setTagCompound(tag);
+ }
+ }
+
+ items[yIndex][xIndex] = stack;
+ }
+ inventories[i] = items;
+ if (invName.equals("backpack_contents")) {
+ startNumberJ = startNumberJ + backPackSizes.get(i).getAsInt();
+ }
+ }
+
+ inventoryItems.put(invName, inventories);
+ return inventories;
+ }
+
+ private ItemStack[] bestWeapons = null;
+ private ItemStack[] bestRods = null;
+ private ItemStack[] armorItems = null;
+ private HashMap<String, ItemStack[][][]> inventoryItems = new HashMap<>();
+ private String selectedInventory = "inv_contents";
+ private int currentInventoryIndex = 0;
+ private int arrowCount = -1;
+ private int greenCandyCount = -1;
+ private int purpleCandyCount = -1;
+ private final GuiElementTextField inventoryTextField = new GuiElementTextField("", GuiElementTextField.SCALE_TEXT);
+ private ItemStack lastBackpack;
+ private int lastBackpackX;
+ private int lastBackpackY;
+
+ private void drawInvsPage(int mouseX, int mouseY, float partialTicks) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_invs);
+ Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST);
+ inventoryTextField.setSize(88, 20);
+
+ JsonObject inventoryInfo = profile.getInventoryInfo(profileId);
+ if (inventoryInfo == null) return;
+
+ int invNameIndex = 0;
+ for (Map.Entry<String, ItemStack> entry : invNameToDisplayMap.entrySet()) {
+ int xIndex = invNameIndex % 3;
+ int yIndex = invNameIndex / 3;
+
+ int x = 19 + 34 * xIndex;
+ int y = 26 + 34 * yIndex;
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements);
+ if (entry.getKey().equals(selectedInventory)) {
+ Utils.drawTexturedRect(guiLeft + x - 2, guiTop + y - 2, 20, 20, 20 / 256f, 0,
+ 20 / 256f, 0, GL11.GL_NEAREST
+ );
+ x++;
+ y++;
+ } else {
+ Utils.drawTexturedRect(guiLeft + x - 2, guiTop + y - 2, 20, 20, 0, 20 / 256f,
+ 0, 20 / 256f, GL11.GL_NEAREST
+ );
+ }
+
+ Utils.drawItemStackWithText(entry.getValue(), guiLeft + x, guiTop + y, "" + (invNameIndex + 1));
+
+ if (mouseX >= guiLeft + x && mouseX <= guiLeft + x + 16) {
+ if (mouseY >= guiTop + y && mouseY <= guiTop + y + 16) {
+ tooltipToDisplay = entry.getValue().getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ }
+ }
+
+ invNameIndex++;
+ }
+
+ inventoryTextField.render(guiLeft + 19, guiTop + sizeY - 26 - 20);
+
+ if (armorItems == null) {
+ armorItems = new ItemStack[4];
+ JsonArray armor = Utils.getElement(inventoryInfo, "inv_armor").getAsJsonArray();
+ for (int i = 0; i < armor.size(); i++) {
+ if (armor.get(i) == null || !armor.get(i).isJsonObject()) continue;
+ armorItems[i] = NotEnoughUpdates.INSTANCE.manager.jsonToStack(armor.get(i).getAsJsonObject(), false);
+ }
+ }
+
+ for (int i = 0; i < armorItems.length; i++) {
+ ItemStack stack = armorItems[i];
+ if (stack != null) {
+ Utils.drawItemStack(stack, guiLeft + 173, guiTop + 67 - 18 * i);
+ if (stack != fillerStack) {
+ if (mouseX >= guiLeft + 173 - 1 && mouseX <= guiLeft + 173 + 16 + 1) {
+ if (mouseY >= guiTop + 67 - 18 * i - 1 && mouseY <= guiTop + 67 - 18 * i + 16 + 1) {
+ tooltipToDisplay = stack.getTooltip(
+ Minecraft.getMinecraft().thePlayer,
+ Minecraft.getMinecraft().gameSettings.advancedItemTooltips
+ );
+ }
+ }
+ }
+ }
+ }
+
+ ItemStack[][][] inventories = getItemsForInventory(inventoryInfo, selectedInventory);
+ if (currentInventoryIndex >= inventories.length) currentInventoryIndex = inventories.length - 1;
+ if (currentInventoryIndex < 0) currentInventoryIndex = 0;
+
+ ItemStack[][] inventory = inventories[currentInventoryIndex];
+ if (inventory == null) {
+ if (selectedInventory.equalsIgnoreCase("personal_vault_contents")) {
+ Utils.drawStringCentered(
+ EnumChatFormatting.RED + "Personal Vault API not enabled!",
+ Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 317,
+ guiTop + 101,
+ true,
+ 0
+ );
+ } else {
+ Utils.drawStringCentered(
+ EnumChatFormatting.RED + "Inventory API not enabled!",
+ Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 317,
+ guiTop + 101,
+ true,
+ 0
+ );
+ }
+ return;
+ }
+
+ if (bestWeapons == null) {
+ bestWeapons = findBestItems(inventoryInfo, 6, new String[]{"inv_contents", "ender_chest_contents"},
+ new String[]{"SWORD", "BOW"}, DAMAGE_PATTERN, STRENGTH_PATTERN
+ );
+ }
+ if (bestRods == null) {
+ bestRods = findBestItems(inventoryInfo, 3, new String[]{"inv_contents", "ender_chest_contents"},
+ new String[]{"FISHING ROD"}, FISHSPEED_PATTERN
+ );
+ }
+
+ for (int i = 0; i < bestWeapons.length; i++) {
+ if (bestWeapons[i] == null) continue;
+ ItemStack stack = bestWeapons[i];
+ Utils.drawItemStack(stack, guiLeft + 143, guiTop + 13 + 18 * i);
+ if (mouseX >= guiLeft + 143 - 1 && mouseX <= guiLeft + 143 + 16 + 1) {
+ if (mouseY >= guiTop + 13 + 18 * i - 1 && mouseY <= guiTop + 13 + 18 * i + 16 + 1) {
+ tooltipToDisplay = stack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ }
+ }
+ }
+
+ for (int i = 0; i < bestRods.length; i++) {
+ if (bestRods[i] == null) continue;
+ ItemStack stack = bestRods[i];
+ Utils.drawItemStack(stack, guiLeft + 143, guiTop + 137 + 18 * i);
+ if (mouseX >= guiLeft + 143 - 1 && mouseX <= guiLeft + 143 + 16 + 1) {
+ if (mouseY >= guiTop + 137 + 18 * i - 1 && mouseY <= guiTop + 137 + 18 * i + 16 + 1) {
+ tooltipToDisplay = stack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ }
+ }
+ }
+
+ if (arrowCount == -1) {
+ arrowCount = countItemsInInventory("ARROW", inventoryInfo, false, "quiver");
+ }
+ if (greenCandyCount == -1) {
+ greenCandyCount = countItemsInInventory("GREEN_CANDY", inventoryInfo, true, "candy_inventory_contents");
+ }
+ if (purpleCandyCount == -1) {
+ purpleCandyCount = countItemsInInventory("PURPLE_CANDY", inventoryInfo, true, "candy_inventory_contents");
+ }
+
+ Utils.drawItemStackWithText(NotEnoughUpdates.INSTANCE.manager.jsonToStack(
+ NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("ARROW")), guiLeft + 173, guiTop + 101,
+ "" + (arrowCount > 999 ? shortNumberFormat(arrowCount, 0) : arrowCount)
+ );
+ Utils.drawItemStackWithText(
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(
+ NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("GREEN_CANDY")),
+ guiLeft + 173,
+ guiTop + 119,
+ "" + greenCandyCount
+ );
+ Utils.drawItemStackWithText(
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(
+ NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("PURPLE_CANDY")),
+ guiLeft + 173,
+ guiTop + 137,
+ "" + purpleCandyCount
+ );
+ if (mouseX > guiLeft + 173 && mouseX < guiLeft + 173 + 16) {
+ if (mouseY > guiTop + 101 && mouseY < guiTop + 137 + 16) {
+ if (mouseY < guiTop + 101 + 17) {
+ tooltipToDisplay =
+ Utils.createList(EnumChatFormatting.WHITE + "Arrow " + EnumChatFormatting.GRAY + "x" + arrowCount);
+ } else if (mouseY < guiTop + 119 + 17) {
+ tooltipToDisplay = Utils.createList(
+ EnumChatFormatting.GREEN + "Green Candy " + EnumChatFormatting.GRAY + "x" + greenCandyCount);
+ } else {
+ tooltipToDisplay = Utils.createList(
+ EnumChatFormatting.DARK_PURPLE + "Purple Candy " + EnumChatFormatting.GRAY + "x" + purpleCandyCount);
+ }
+ }
+ }
+
+ int inventoryRows = inventory.length;
+
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(CHEST_GUI_TEXTURE);
+
+ int invSizeY = inventoryRows * 18 + 17 + 7;
+
+ int x = guiLeft + 320 - 176 / 2;
+ int y = guiTop + 101 - invSizeY / 2;
+ int staticSelectorHeight = guiTop + 177;
+
+ this.drawTexturedModalRect(x, y, 0, 0, 176, inventoryRows * 18 + 17);
+ this.drawTexturedModalRect(x, y + inventoryRows * 18 + 17, 0, 215, 176, 7);
+
+ boolean leftHovered = false;
+ boolean rightHovered = false;
+ if (Mouse.isButtonDown(0)) {
+ if (mouseY > staticSelectorHeight && mouseY < staticSelectorHeight + 16) {
+ if (mouseX > guiLeft + 320 - 12 && mouseX < guiLeft + 320 + 12) {
+ if (mouseX < guiLeft + 320) {
+ leftHovered = true;
+ } else {
+ rightHovered = true;
+ }
+ }
+ }
+ }
+ Minecraft.getMinecraft().getTextureManager().bindTexture(resource_packs);
+
+ if (currentInventoryIndex > 0) {
+ Utils.drawTexturedRect(guiLeft + 320 - 12, staticSelectorHeight, 12, 16,
+ 29 / 256f, 53 / 256f, !leftHovered ? 0 : 32 / 256f, !leftHovered ? 32 / 256f : 64 / 256f, GL11.GL_NEAREST
+ );
+ }
+ if (currentInventoryIndex < inventories.length - 1) {
+ Utils.drawTexturedRect(guiLeft + 320, staticSelectorHeight, 12, 16,
+ 5 / 256f, 29 / 256f, !rightHovered ? 0 : 32 / 256f, !rightHovered ? 32 / 256f : 64 / 256f, GL11.GL_NEAREST
+ );
+ }
+
+ fontRendererObj.drawString(
+ Utils.cleanColour(invNameToDisplayMap.get(selectedInventory).getDisplayName()),
+ x + 8,
+ y + 6,
+ 4210752
+ );
+
+ ItemStack stackToRender = null;
+ int overlay = new Color(0, 0, 0, 100).getRGB();
+ for (int yIndex = 0; yIndex < inventory.length; yIndex++) {
+ if (inventory[yIndex] == null) continue;
+
+ for (int xIndex = 0; xIndex < inventory[yIndex].length; xIndex++) {
+ ItemStack stack = inventory[yIndex][xIndex];
+
+ if (stack != null) Utils.drawItemStack(stack, x + 8 + xIndex * 18, y + 18 + yIndex * 18);
+
+ if (inventoryTextField.getText() != null && !inventoryTextField.getText().isEmpty() &&
+ (stack == null ||
+ !NotEnoughUpdates.INSTANCE.manager.doesStackMatchSearch(stack, inventoryTextField.getText()))) {
+ GlStateManager.translate(0, 0, 50);
+ drawRect(
+ x + 8 + xIndex * 18,
+ y + 18 + yIndex * 18,
+ x + 8 + xIndex * 18 + 16,
+ y + 18 + yIndex * 18 + 16,
+ overlay
+ );
+ GlStateManager.translate(0, 0, -50);
+ }
+
+ if (stack == null || stack == fillerStack) continue;
+
+ if (mouseX >= x + 8 + xIndex * 18 && mouseX <= x + 8 + xIndex * 18 + 16) {
+ if (mouseY >= y + 18 + yIndex * 18 && mouseY <= y + 18 + yIndex * 18 + 16) {
+ stackToRender = stack;
+ }
+ }
+ }
+ }
+ if (stackToRender != null) {
+ tooltipToDisplay = stackToRender.getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ }
+
+ }
+
+ private String niceUuid(String uuidStr) {
+ if (uuidStr.length() != 32) return uuidStr;
+
+ StringBuilder niceAucId = new StringBuilder();
+ niceAucId.append(uuidStr, 0, 8);
+ niceAucId.append("-");
+ niceAucId.append(uuidStr, 8, 12);
+ niceAucId.append("-");
+ niceAucId.append(uuidStr, 12, 16);
+ niceAucId.append("-");
+ niceAucId.append(uuidStr, 16, 20);
+ niceAucId.append("-");
+ niceAucId.append(uuidStr, 20, 32);
+ return niceAucId.toString();
+ }
+
+ public EntityOtherPlayerMP getEntityPlayer() {
+ return entityPlayer;
+ }
+
+ private EntityOtherPlayerMP entityPlayer = null;
+ private ResourceLocation playerLocationSkin = null;
+ private ResourceLocation playerLocationCape = null;
+ private String skinType = null;
+
+ private final HashMap<String, ResourceLocation[]> panoramasMap = new HashMap<>();
+
+ public ResourceLocation[] getPanoramasForLocation(String location, String identifier) {
+ if (panoramasMap.containsKey(location + identifier)) return panoramasMap.get(location + identifier);
+ try {
+ ResourceLocation[] panoramasArray = new ResourceLocation[6];
+ for (int i = 0; i < 6; i++) {
+ panoramasArray[i] =
+ new ResourceLocation("notenoughupdates:panoramas/" + location + "_" + identifier + "/panorama_" + i + ".jpg");
+ Minecraft.getMinecraft().getResourceManager().getResource(panoramasArray[i]);
+ }
+ panoramasMap.put(location + identifier, panoramasArray);
+ return panoramasArray;
+ } catch (IOException e) {
+ try {
+ ResourceLocation[] panoramasArray = new ResourceLocation[6];
+ for (int i = 0; i < 6; i++) {
+ panoramasArray[i] =
+ new ResourceLocation("notenoughupdates:panoramas/" + location + "/panorama_" + i + ".jpg");
+ Minecraft.getMinecraft().getResourceManager().getResource(panoramasArray[i]);
+ }
+ panoramasMap.put(location + identifier, panoramasArray);
+ return panoramasArray;
+ } catch (IOException e2) {
+ ResourceLocation[] panoramasArray = new ResourceLocation[6];
+ for (int i = 0; i < 6; i++) {
+ panoramasArray[i] = new ResourceLocation("notenoughupdates:panoramas/unknown/panorama_" + i + ".jpg");
+ }
+ panoramasMap.put(location + identifier, panoramasArray);
+ return panoramasArray;
+ }
+ }
+ }
+
+ private TreeMap<Integer, Set<String>> topKills = null;
+ private TreeMap<Integer, Set<String>> topDeaths = null;
+
+ private void drawExtraPage(int mouseX, int mouseY, float partialTicks) {
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_extra);
+ Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST);
+
+ JsonObject profileInfo = profile.getProfileInformation(profileId);
+ if (profileInfo == null) return;
+ JsonObject skillInfo = profile.getSkillInfo(profileId);
+
+ float xStart = 22;
+ float xOffset = 103;
+ float yStartTop = 27;
+ float yStartBottom = 105;
+ float yOffset = 10;
+
+ float bankBalance = Utils.getElementAsFloat(Utils.getElement(profileInfo, "banking.balance"), 0);
+ float purseBalance = Utils.getElementAsFloat(Utils.getElement(profileInfo, "coin_purse"), 0);
+
+ Utils.renderAlignedString(
+ EnumChatFormatting.GOLD + "Bank Balance",
+ EnumChatFormatting.WHITE + shortNumberFormat(bankBalance, 0),
+ guiLeft + xStart,
+ guiTop + yStartTop,
+ 76
+ );
+ Utils.renderAlignedString(
+ EnumChatFormatting.GOLD + "Purse",
+ EnumChatFormatting.WHITE + shortNumberFormat(purseBalance, 0),
+ guiLeft + xStart,
+ guiTop + yStartTop + yOffset,
+ 76
+ );
+
+ {
+ String lastSaveText = this.getTimeSinceString(profileInfo, "last_save");
+ if (lastSaveText != null) {
+ Utils.renderAlignedString(EnumChatFormatting.AQUA + "Last Seen", EnumChatFormatting.WHITE + lastSaveText,
+ guiLeft + xStart, guiTop + yStartTop + yOffset * 2, 76
+ );
+ }
+
+ }
+ {
+ String first_join = this.getTimeSinceString(profileInfo, "first_join");
+ if (first_join != null) {
+ Utils.renderAlignedString(EnumChatFormatting.AQUA + "Joined", EnumChatFormatting.WHITE + first_join,
+ guiLeft + xStart, guiTop + yStartTop + yOffset * 3, 76
+ );
+ }
+
+ }
+ {
+ JsonObject guildInfo = profile.getGuildInfo(null);
+ if (guildInfo != null && guildInfo.has("name")) {
+ Utils.renderAlignedString(
+ EnumChatFormatting.AQUA + "Guild",
+ EnumChatFormatting.WHITE + guildInfo.get("name").getAsString(),
+ guiLeft + xStart,
+ guiTop + yStartTop + yOffset * 4,
+ 76
+ );
+ }
+ }
+
+ float fairySouls = Utils.getElementAsFloat(Utils.getElement(profileInfo, "fairy_souls_collected"), 0);
+
+ int fairySoulMax = 227;
+ if (Constants.FAIRYSOULS != null && Constants.FAIRYSOULS.has("Max Souls")) {
+ fairySoulMax = Constants.FAIRYSOULS.get("Max Souls").getAsInt();
+ }
+ Utils.renderAlignedString(
+ EnumChatFormatting.LIGHT_PURPLE + "Fairy Souls",
+ EnumChatFormatting.WHITE.toString() + (int) fairySouls + "/" + fairySoulMax,
+ guiLeft + xStart,
+ guiTop + yStartBottom,
+ 76
+ );
+ if (skillInfo != null) {
+ float totalSkillLVL = 0;
+ float totalTrueSkillLVL = 0;
+ float totalSlayerLVL = 0;
+ float totalSkillCount = 0;
+ float totalSlayerCount = 0;
+ float totalSlayerXP = 0;
+
+ for (Map.Entry<String, JsonElement> entry : skillInfo.entrySet()) {
+ if (entry.getKey().startsWith("level_skill")) {
+ if (entry.getKey().contains("runecrafting")) continue;
+ if (entry.getKey().contains("carpentry")) continue;
+ if (entry.getKey().contains("catacombs")) continue;
+
+ totalSkillLVL += entry.getValue().getAsFloat();
+ totalTrueSkillLVL += Math.floor(entry.getValue().getAsFloat());
+ totalSkillCount++;
+ } else if (entry.getKey().startsWith("level_slayer")) {
+ totalSlayerLVL += entry.getValue().getAsFloat();
+ totalSlayerCount++;
+ } else if (entry.getKey().startsWith("experience_slayer")) {
+ totalSlayerXP += entry.getValue().getAsFloat();
+ }
+ }
+
+ float avgSkillLVL = totalSkillLVL / totalSkillCount;
+ float avgTrueSkillLVL = totalTrueSkillLVL / totalSkillCount;
+ float avgSlayerLVL = totalSlayerLVL / totalSlayerCount;
+
+ Utils.renderAlignedString(
+ EnumChatFormatting.RED + "AVG Skill Level",
+ EnumChatFormatting.WHITE.toString() + Math.floor(avgSkillLVL * 10) / 10,
+ guiLeft + xStart,
+ guiTop + yStartBottom + yOffset,
+ 76
+ );
+
+ Utils.renderAlignedString(
+ EnumChatFormatting.RED + "True AVG Skill Level",
+ EnumChatFormatting.WHITE.toString() + Math.floor(avgTrueSkillLVL * 10) / 10,
+ guiLeft + xStart,
+ guiTop + yStartBottom + yOffset * 2,
+ 76
+ );
+
+ Utils.renderAlignedString(
+ EnumChatFormatting.RED + "AVG Slayer Level",
+ EnumChatFormatting.WHITE.toString() + Math.floor(avgSlayerLVL * 10) / 10,
+ guiLeft + xStart,
+ guiTop + yStartBottom + yOffset * 3,
+ 76
+ );
+
+ Utils.renderAlignedString(
+ EnumChatFormatting.RED + "Total Slayer XP",
+ EnumChatFormatting.WHITE + shortNumberFormat(totalSlayerXP, 0),
+ guiLeft + xStart,
+ guiTop + yStartBottom + yOffset * 4,
+ 76
+ );
+ }
+
+ float auctions_bids = Utils.getElementAsFloat(Utils.getElement(profileInfo, "stats.auctions_bids"), 0);
+ float auctions_highest_bid =
+ Utils.getElementAsFloat(Utils.getElement(profileInfo, "stats.auctions_highest_bid"), 0);
+ float auctions_won = Utils.getElementAsFloat(Utils.getElement(profileInfo, "stats.auctions_won"), 0);
+ float auctions_created = Utils.getElementAsFloat(Utils.getElement(profileInfo, "stats.auctions_created"), 0);
+ float auctions_gold_spent = Utils.getElementAsFloat(Utils.getElement(profileInfo, "stats.auctions_gold_spent"), 0);
+ float auctions_gold_earned =
+ Utils.getElementAsFloat(Utils.getElement(profileInfo, "stats.auctions_gold_earned"), 0);
+
+ Utils.renderAlignedString(
+ EnumChatFormatting.DARK_PURPLE + "Auction Bids",
+ EnumChatFormatting.WHITE.toString() + (int) auctions_bids,
+ guiLeft + xStart + xOffset,
+ guiTop + yStartTop,
+ 76
+ );
+ Utils.renderAlignedString(
+ EnumChatFormatting.DARK_PURPLE + "Highest Bid",
+ EnumChatFormatting.WHITE + shortNumberFormat(auctions_highest_bid, 0),
+ guiLeft + xStart + xOffset,
+ guiTop + yStartTop + yOffset,
+ 76
+ );
+ Utils.renderAlignedString(
+ EnumChatFormatting.DARK_PURPLE + "Auctions Won",
+ EnumChatFormatting.WHITE.toString() + (int) auctions_won,
+ guiLeft + xStart + xOffset,
+ guiTop + yStartTop + yOffset * 2,
+ 76
+ );
+ Utils.renderAlignedString(
+ EnumChatFormatting.DARK_PURPLE + "Auctions Created",
+ EnumChatFormatting.WHITE.toString() + (int) auctions_created,
+ guiLeft + xStart + xOffset,
+ guiTop + yStartTop + yOffset * 3,
+ 76
+ );
+ Utils.renderAlignedString(
+ EnumChatFormatting.DARK_PURPLE + "Gold Spent",
+ EnumChatFormatting.WHITE + shortNumberFormat(auctions_gold_spent, 0),
+ guiLeft + xStart + xOffset,
+ guiTop + yStartTop + yOffset * 4,
+ 76
+ );
+ Utils.renderAlignedString(
+ EnumChatFormatting.DARK_PURPLE + "Gold Earned",
+ EnumChatFormatting.WHITE + shortNumberFormat(auctions_gold_earned, 0),
+ guiLeft + xStart + xOffset,
+ guiTop + yStartTop + yOffset * 5,
+ 76
+ );
+
+ //Slayer values
+ float zombie_boss_kills_tier_2 =
+ Utils.getElementAsFloat(Utils.getElement(profileInfo, "slayer_bosses.zombie.boss_kills_tier_2"), 0);
+ float zombie_boss_kills_tier_3 =
+ Utils.getElementAsFloat(Utils.getElement(profileInfo, "slayer_bosses.zombie.boss_kills_tier_3"), 0);
+ float zombie_boss_kills_tier_4 =
+ Utils.getElementAsFloat(Utils.getElement(profileInfo, "slayer_bosses.zombie.boss_kills_tier_4"), 0);
+ float wolf_boss_kills_tier_2 =
+ Utils.getElementAsFloat(Utils.getElement(profileInfo, "slayer_bosses.wolf.boss_kills_tier_2"), 0);
+ float wolf_boss_kills_tier_3 =
+ Utils.getElementAsFloat(Utils.getElement(profileInfo, "slayer_bosses.wolf.boss_kills_tier_3"), 0);
+ float spider_boss_kills_tier_2 =
+ Utils.getElementAsFloat(Utils.getElement(profileInfo, "slayer_bosses.spider.boss_kills_tier_2"), 0);
+ float spider_boss_kills_tier_3 =
+ Utils.getElementAsFloat(Utils.getElement(profileInfo, "slayer_bosses.spider.boss_kills_tier_3"), 0);
+ float enderman_boss_kills_tier_2 =
+ Utils.getElementAsFloat(Utils.getElement(profileInfo, "slayer_bosses.enderman.boss_kills_tier_2"), 0);
+ float enderman_boss_kills_tier_3 =
+ Utils.getElementAsFloat(Utils.getElement(profileInfo, "slayer_bosses.enderman.boss_kills_tier_3"), 0);
+
+ Utils.renderAlignedString(
+ EnumChatFormatting.DARK_AQUA + "Revenant T3",
+ EnumChatFormatting.WHITE.toString() + (int) zombie_boss_kills_tier_2,
+ guiLeft + xStart + xOffset,
+ guiTop + yStartBottom,
+ 76
+ );
+ Utils.renderAlignedString(
+ EnumChatFormatting.DARK_AQUA + "Revenant T4",
+ EnumChatFormatting.WHITE.toString() + (int) zombie_boss_kills_tier_3,
+ guiLeft + xStart + xOffset,
+ guiTop + yStartBottom + yOffset,
+ 76
+ );
+ Utils.renderAlignedString(
+ EnumChatFormatting.DARK_AQUA + "Revenant T5",
+ EnumChatFormatting.WHITE.toString() + (int) zombie_boss_kills_tier_4,
+ guiLeft + xStart + xOffset,
+ guiTop + yStartBottom + yOffset * 2,
+ 76
+ );
+ Utils.renderAlignedString(
+ EnumChatFormatting.DARK_AQUA + "Tarantula T3",
+ EnumChatFormatting.WHITE.toString() + (int) spider_boss_kills_tier_2,
+ guiLeft + xStart + xOffset,
+ guiTop + yStartBottom + yOffset * 3,
+ 76
+ );
+ Utils.renderAlignedString(
+ EnumChatFormatting.DARK_AQUA + "Tarantula T4",
+ EnumChatFormatting.WHITE.toString() + (int) spider_boss_kills_tier_3,
+ guiLeft + xStart + xOffset,
+ guiTop + yStartBottom + yOffset * 4,
+ 76
+ );
+
+ Utils.renderAlignedString(
+ EnumChatFormatting.DARK_AQUA + "Sven T3",
+ EnumChatFormatting.WHITE.toString() + (int) wolf_boss_kills_tier_2,
+ guiLeft + xStart + xOffset * 2,
+ guiTop + yStartBottom + yOffset * 0,
+ 76
+ );
+ Utils.renderAlignedString(
+ EnumChatFormatting.DARK_AQUA + "Sven T4",
+ EnumChatFormatting.WHITE.toString() + (int) wolf_boss_kills_tier_3,
+ guiLeft + xStart + xOffset * 2,
+ guiTop + yStartBottom + yOffset * 1,
+ 76
+ );
+ Utils.renderAlignedString(
+ EnumChatFormatting.DARK_AQUA + "Voidgloom T3",
+ EnumChatFormatting.WHITE.toString() + (int) enderman_boss_kills_tier_2,
+ guiLeft + xStart + xOffset * 2,
+ guiTop + yStartBottom + yOffset * 2,
+ 76
+ );
+ Utils.renderAlignedString(
+ EnumChatFormatting.DARK_AQUA + "Voidgloom T4",
+ EnumChatFormatting.WHITE.toString() + (int) enderman_boss_kills_tier_3,
+ guiLeft + xStart + xOffset * 2,
+ guiTop + yStartBottom + yOffset * 3,
+ 76
+ );
+
+ float pet_milestone_ores_mined =
+ Utils.getElementAsFloat(Utils.getElement(profileInfo, "stats.pet_milestone_ores_mined"), 0);
+ float pet_milestone_sea_creatures_killed =
+ Utils.getElementAsFloat(Utils.getElement(profileInfo, "stats.pet_milestone_sea_creatures_killed"), 0);
+
+ float items_fished = Utils.getElementAsFloat(Utils.getElement(profileInfo, "stats.items_fished"), 0);
+ float items_fished_treasure =
+ Utils.getElementAsFloat(Utils.getElement(profileInfo, "stats.items_fished_treasure"), 0);
+ float items_fished_large_treasure =
+ Utils.getElementAsFloat(Utils.getElement(profileInfo, "stats.items_fished_large_treasure"), 0);
+
+ Utils.renderAlignedString(
+ EnumChatFormatting.GREEN + "Ores Mined",
+ EnumChatFormatting.WHITE.toString() + (int) pet_milestone_ores_mined,
+ guiLeft + xStart + xOffset * 2,
+ guiTop + yStartTop,
+ 76
+ );
+ Utils.renderAlignedString(
+ EnumChatFormatting.GREEN + "Sea Creatures Killed",
+ EnumChatFormatting.WHITE.toString() + (int) pet_milestone_sea_creatures_killed,
+ guiLeft + xStart + xOffset * 2,
+ guiTop + yStartTop + yOffset,
+ 76
+ );
+
+ Utils.renderAlignedString(
+ EnumChatFormatting.GREEN + "Items Fished",
+ EnumChatFormatting.WHITE.toString() + (int) items_fished,
+ guiLeft + xStart + xOffset * 2,
+ guiTop + yStartTop + yOffset * 3,
+ 76
+ );
+ Utils.renderAlignedString(
+ EnumChatFormatting.GREEN + "Treasures Fished",
+ EnumChatFormatting.WHITE.toString() + (int) items_fished_treasure,
+ guiLeft + xStart + xOffset * 2,
+ guiTop + yStartTop + yOffset * 4,
+ 76
+ );
+ Utils.renderAlignedString(
+ EnumChatFormatting.GREEN + "Large Treasures",
+ EnumChatFormatting.WHITE.toString() + (int) items_fished_large_treasure,
+ guiLeft + xStart + xOffset * 2,
+ guiTop + yStartTop + yOffset * 5,
+ 76
+ );
+
+ if (topKills == null) {
+ topKills = new TreeMap<>();
+ JsonObject stats = profileInfo.get("stats").getAsJsonObject();
+ for (Map.Entry<String, JsonElement> entry : stats.entrySet()) {
+ if (entry.getKey().startsWith("kills_")) {
+ if (entry.getValue().isJsonPrimitive()) {
+ JsonPrimitive prim = (JsonPrimitive) entry.getValue();
+ if (prim.isNumber()) {
+ String name = WordUtils.capitalizeFully(entry.getKey().substring("kills_".length()).replace("_", " "));
+ Set<String> kills = topKills.computeIfAbsent(prim.getAsInt(), k -> new HashSet<>());
+ kills.add(name);
+ }
+ }
+ }
+ }
+ }
+ if (topDeaths == null) {
+ topDeaths = new TreeMap<>();
+ JsonObject stats = profileInfo.get("stats").getAsJsonObject();
+ for (Map.Entry<String, JsonElement> entry : stats.entrySet()) {
+ if (entry.getKey().startsWith("deaths_")) {
+ if (entry.getValue().isJsonPrimitive()) {
+ JsonPrimitive prim = (JsonPrimitive) entry.getValue();
+ if (prim.isNumber()) {
+ String name = WordUtils.capitalizeFully(entry.getKey().substring("deaths_".length()).replace("_", " "));
+ Set<String> deaths = topDeaths.computeIfAbsent(prim.getAsInt(), k -> new HashSet<>());
+ deaths.add(name);
+ }
+ }
+ }
+ }
+ }
+
+ int index = 0;
+ for (int killCount : topKills.descendingKeySet()) {
+ if (index >= 6) break;
+ Set<String> kills = topKills.get(killCount);
+ for (String killType : kills) {
+ if (index >= 6) break;
+ Utils.renderAlignedString(
+ EnumChatFormatting.YELLOW + killType + " Kills",
+ EnumChatFormatting.WHITE.toString() + killCount,
+ guiLeft + xStart + xOffset * 3,
+ guiTop + yStartTop + yOffset * index,
+ 76
+ );
+ index++;
+ }
+ }
+ index = 0;
+ for (int deathCount : topDeaths.descendingKeySet()) {
+ if (index >= 6) break;
+ Set<String> deaths = topDeaths.get(deathCount);
+ for (String deathType : deaths) {
+ if (index >= 6) break;
+ Utils.renderAlignedString(
+ EnumChatFormatting.YELLOW + "Deaths: " + deathType,
+ EnumChatFormatting.WHITE.toString() + deathCount,
+ guiLeft + xStart + xOffset * 3,
+ guiTop + yStartBottom + yOffset * index,
+ 76
+ );
+ index++;
+ }
+ }
+ }
+
+ private void drawMiningPage(int mouseX, int mouseY, float partialTicks) {
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_mining);
+ Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST);
+
+ JsonObject profileInfo = profile.getProfileInformation(profileId);
+ if (profileInfo == null) return;
+ JsonObject skillInfo = profile.getSkillInfo(profileId);
+
+ float xStart = 22;
+ float xOffset = 103;
+ float yStartTop = 27;
+ float yStartBottom = 105;
+ float yOffset = 10;
+
+ int x = guiLeft + 23;
+ int y = guiTop + 25;
+ int sectionWidth = 110;
+ JsonObject leveling = Constants.LEVELING;
+ ProfileViewer.Level levelObjhotm = levelObjhotms.get(profileId);
+ if (levelObjhotm == null) {
+ float hotmXp = Utils.getElementAsFloat(Utils.getElement(profileInfo, "mining_core.experience"), 0);
+ levelObjhotm = ProfileViewer.getLevel(Utils.getElement(leveling, "HOTM").getAsJsonArray(),
+ hotmXp, 7, false
+ );
+ levelObjhotms.put(profileId, levelObjhotm);
+ }
+
+ String skillName = EnumChatFormatting.RED + "HOTM";
+ //The stats that show
+ float mithrilPowder = Utils.getElementAsFloat(Utils.getElement(profileInfo, "mining_core.powder_mithril"), 0);
+ float gemstonePowder = Utils.getElementAsFloat(Utils.getElement(profileInfo, "mining_core.powder_gemstone"), 0);
+ float mithrilPowderTotal =
+ Utils.getElementAsFloat(Utils.getElement(profileInfo, "mining_core.powder_spent_mithril"), 0);
+ float gemstonePowderTotal =
+ (Utils.getElementAsFloat(Utils.getElement(profileInfo, "mining_core.powder_spent_gemstone"), 0));
+ String jadeCrystal =
+ (Utils.getElementAsString(Utils.getElement(profileInfo, "mining_core.crystals.jade_crystal.state"), "Not Found"));
+ float crystalPlacedAmount =
+ (Utils.getElementAsFloat(Utils.getElement(profileInfo, "mining_core.crystals.jade_crystal.total_placed"), 0));
+ String jadeCrystalString = "§c✖";
+ String amethystCrystal = (Utils.getElementAsString(
+ Utils.getElement(profileInfo, "mining_core.crystals.amethyst_crystal.state"),
+ "Not Found"
+ ));
+ String amethystCrystalString = "§c✖";
+ String amberCrystal = (Utils.getElementAsString(
+ Utils.getElement(profileInfo, "mining_core.crystals.amber_crystal.state"),
+ "Not Found"
+ ));
+ String amberCrystalString = "§c✖";
+ String sapphireCrystal = (Utils.getElementAsString(
+ Utils.getElement(profileInfo, "mining_core.crystals.sapphire_crystal.state"),
+ "Not Found"
+ ));
+ String sapphireCrystalString = "§c✖";
+ String topazCrystal = (Utils.getElementAsString(
+ Utils.getElement(profileInfo, "mining_core.crystals.topaz_crystal.state"),
+ "Not Found"
+ ));
+ String topazCrystalString = "§c✖";
+ String jasperCrystal = (Utils.getElementAsString(
+ Utils.getElement(profileInfo, "mining_core.crystals.jasper_crystal.state"),
+ "Not Found"
+ ));
+ String jasperCrystalString = "§c✖";
+ String rubyCrystal =
+ (Utils.getElementAsString(Utils.getElement(profileInfo, "mining_core.crystals.ruby_crystal.state"), "Not Found"));
+ String rubyCrystalString = "§c✖";
+ int miningFortune = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.mining_fortune"), 0)));
+ int miningFortuneStat =
+ ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.mining_fortune"), 0)) * 5);
+ int miningSpeed = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.mining_speed"), 0)));
+ int miningSpeedStat =
+ ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.mining_speed"), 0)) * 20);
+ int dailyPowder = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.daily_powder"), 0)));
+ int dailyPowderStat =
+ ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.daily_powder"), 0)) * 36 + 364);
+ int effMiner = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.efficient_miner"), 0)));
+ float effMinerStat =
+ (float) ((Utils.getElementAsFloat(Utils.getElement(profileInfo, "mining_core.nodes.efficient_miner"), 0)) * 0.4 +
+ 10.4);
+ float effMinerStat2 =
+ (float) ((Utils.getElementAsFloat(Utils.getElement(profileInfo, "mining_core.nodes.efficient_miner"), 0)) * .06 +
+ 0.31);
+ int tittyInsane =
+ ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.titanium_insanium"), 0)));
+ float tittyInsaneStat =
+ (float) ((Utils.getElementAsFloat(Utils.getElement(profileInfo, "mining_core.nodes.titanium_insanium"), 0)) * .1 +
+ 2);
+ int luckofcave = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.random_event"), 0)));
+ int luckofcaveStat = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.random_event"), 0)));
+ int madMining = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.mining_madness"), 0)));
+ int skyMall = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.daily_effect"), 0)));
+ int goblinKiller = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.goblin_killer"), 0)));
+ int seasonMine = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.mining_experience"), 0)));
+ float seasonMineStat = (float) (
+ (Utils.getElementAsFloat(Utils.getElement(profileInfo, "mining_core.nodes.mining_experience"), 0)) * 0.1 + 5);
+ int quickForge = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.forge_time"), 0)));
+ float quickForgeStat =
+ (float) ((Utils.getElementAsFloat(Utils.getElement(profileInfo, "mining_core.nodes.forge_time"), 0)) * .5 + 10);
+ int frontLoad = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.front_loaded"), 0)));
+ int orbit = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.experience_orbs"), 0)));
+ float orbitStat =
+ (float) ((Utils.getElementAsFloat(Utils.getElement(profileInfo, "mining_core.nodes.experience_orbs"), 0)) * .01 +
+ 0.2);
+ int crystallized =
+ ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.fallen_star_bonus"), 0)));
+ int crystallizedStat =
+ ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.fallen_star_bonus"), 0)) * 6 + 14);
+ int professional = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.professional"), 0)));
+ int professionalStat =
+ ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.professional"), 0)) * 5 + 50);
+ int greatExplorer = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.great_explorer"), 0)));
+ int greatExplorerStat =
+ ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.great_explorer"), 0)) * 4 + 16);
+ int fortunate = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.fortunate"), 0)));
+ int fortunateStat =
+ ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.fortunate"), 0)) * 4 + 20);
+ int lonesomeMiner = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.lonesome_miner"), 0)));
+ float lonesomeMinerStat =
+ (float) ((Utils.getElementAsFloat(Utils.getElement(profileInfo, "mining_core.nodes.lonesome_miner"), 0)) * .5 +
+ 5);
+ int miningFortune2 =
+ ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.mining_fortune_2"), 0)));
+ int miningFortune2Stat =
+ ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.mining_fortune_2"), 0)) * 5);
+ int miningSpeed2 = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.mining_speed_2"), 0)));
+ int miningSpeed2Stat =
+ ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.mining_speed_2"), 0)) * 40);
+ int miningSpeedBoost =
+ ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.mining_speed_boost"), 0)));
+ int veinSeeker = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.vein_seeker"), 0)));
+ int powderBuff = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.powder_buff"), 0)));
+ int potm = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.special_0"), 0)));
+ int fortnite = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.precision_mining"), 0)));
+ int starPowder = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.star_powder"), 0)));
+ int pickoblus = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.pickaxe_toss"), 0)));
+ int maniacMiner = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.maniac_miner"), 0)));
+
+ if (effMinerStat2 < 1) {
+ effMinerStat2 = 1;
+ }
+ int mole = ((Utils.getElementAsInt(Utils.getElement(profileInfo, "mining_core.nodes.mole"), 0)));
+ float moleStat =
+ (float) ((Utils.getElementAsFloat(Utils.getElement(profileInfo, "mining_core.nodes.mole"), 0)) * 0.051);
+ double moleperkstat = (double) mole / 20 - 0.55 + 50;
+ double moleperkstat2 = (double) Math.round(moleperkstat * 100) / 100;
+
+ float output = Math.round((float) (moleperkstat2 % 1) * 100);
+ if (output == 0) {
+ output = 100;
+ }
+
+ //The logic for some of the stats
+ if (Objects.equals(jadeCrystal, "NOT_FOUND")) {
+ jadeCrystalString = "§c✖";
+ } else if (Objects.equals(jadeCrystal, "FOUND")) {
+ jadeCrystalString = "§a✔";
+ }
+ if (Objects.equals(amethystCrystal, "NOT_FOUND")) {
+ amethystCrystalString = "§c✖";
+ } else if (Objects.equals(amethystCrystal, "FOUND")) {
+ amethystCrystalString = "§a✔";
+ }
+ if (Objects.equals(amberCrystal, "NOT_FOUND")) {
+ amberCrystalString = "§c✖";
+ } else if (Objects.equals(amberCrystal, "FOUND")) {
+ amberCrystalString = "§a✔";
+ }
+ if (Objects.equals(sapphireCrystal, "NOT_FOUND")) {
+ sapphireCrystalString = "§c✖";
+ } else if (Objects.equals(sapphireCrystal, "FOUND")) {
+ sapphireCrystalString = "§a✔";
+ }
+ if (Objects.equals(topazCrystal, "NOT_FOUND")) {
+ topazCrystalString = "§c✖";
+ } else if (Objects.equals(topazCrystal, "FOUND")) {
+ topazCrystalString = "§a✔";
+ }
+ if (Objects.equals(jasperCrystal, "NOT_FOUND")) {
+ jasperCrystalString = "§c✖";
+ } else if (Objects.equals(jasperCrystal, "FOUND")) {
+ jasperCrystalString = "§a✔";
+ }
+ if (Objects.equals(rubyCrystal, "NOT_FOUND")) {
+ rubyCrystalString = "§c✖";
+ } else if (Objects.equals(rubyCrystal, "FOUND")) {
+ rubyCrystalString = "§a✔";
+ }
+
+ //The rendering of the stats
+ //hotm level
+ renderXpBar(skillName, iron_pick, x, y, sectionWidth, levelObjhotm, mouseX, mouseY);
+ //Powder
+ Utils.renderAlignedString(
+ EnumChatFormatting.DARK_GREEN + "Mithril Powder",
+ EnumChatFormatting.WHITE + shortNumberFormat(mithrilPowder, 0),
+ guiLeft + xStart,
+ guiTop + yStartTop + 24,
+ 115
+ );
+ Utils.renderAlignedString(
+ EnumChatFormatting.LIGHT_PURPLE + "Gemstone Powder",
+ EnumChatFormatting.WHITE + shortNumberFormat(gemstonePowder, 0),
+ guiLeft + xStart,
+ guiTop + yStartTop + 44,
+ 115
+ );
+ Utils.renderAlignedString(
+ EnumChatFormatting.DARK_GREEN + "Total Mithril Powder",
+ EnumChatFormatting.WHITE + shortNumberFormat(mithrilPowderTotal + mithrilPowder, 0),
+ guiLeft + xStart,
+ guiTop + yStartTop + 34,
+ 115
+ );
+ Utils.renderAlignedString(
+ EnumChatFormatting.LIGHT_PURPLE + "Total Gemstone Powder",
+ EnumChatFormatting.WHITE + shortNumberFormat(gemstonePowderTotal + gemstonePowder, 0),
+ guiLeft + xStart,
+ guiTop + yStartTop + 54,
+ 115
+ );
+ //Crystals
+ Utils.renderAlignedString(EnumChatFormatting.GREEN + "Jade Crystal:", EnumChatFormatting.WHITE + jadeCrystalString,
+ guiLeft + xStart, guiTop + yStartTop + 74, 110
+ );
+ Utils.renderAlignedString(EnumChatFormatting.GOLD + "Amber Crystal:", EnumChatFormatting.WHITE + amberCrystalString,
+ guiLeft + xStart, guiTop + yStartTop + 84, 110
+ );
+ Utils.renderAlignedString(
+ EnumChatFormatting.DARK_PURPLE + "Amethyst Crystal:",
+ EnumChatFormatting.WHITE + amethystCrystalString,
+ guiLeft + xStart,
+ guiTop + yStartTop + 94,
+ 110
+ );
+ Utils.renderAlignedString(
+ EnumChatFormatting.AQUA + "Sapphire Crystal:",
+ EnumChatFormatting.WHITE + sapphireCrystalString,
+ guiLeft + xStart,
+ guiTop + yStartTop + 104,
+ 110
+ );
+ Utils.renderAlignedString(
+ EnumChatFormatting.YELLOW + "Topaz Crystal:",
+ EnumChatFormatting.WHITE + topazCrystalString,
+ guiLeft + xStart,
+ guiTop + yStartTop + 114,
+ 110
+ );
+ Utils.renderAlignedString(
+ EnumChatFormatting.LIGHT_PURPLE + "Jasper Crystal:",
+ EnumChatFormatting.WHITE + jasperCrystalString,
+ guiLeft + xStart,
+ guiTop + yStartTop + 124,
+ 110
+ );
+ Utils.renderAlignedString(EnumChatFormatting.RED + "Ruby Crystal:", EnumChatFormatting.WHITE + rubyCrystalString,
+ guiLeft + xStart, guiTop + yStartTop + 134, 110
+ );
+ Utils.renderAlignedString(
+ EnumChatFormatting.BLUE + "Total Placed Crystals:",
+ EnumChatFormatting.WHITE + shortNumberFormat(crystalPlacedAmount, 0),
+ guiLeft + xStart,
+ guiTop + yStartTop + 149,
+ 110
+ );
+
+ //hotm render
+ //Pain
+
+ renderHotmPerk(
+ miningSpeed,
+ (int) (guiLeft + xStart + 255),
+ (int) (guiTop + yStartTop + 138),
+ mouseX,
+ mouseY,
+ () -> Lists.newArrayList(
+ "Mining Speed",
+ EnumChatFormatting.GRAY + "Level " + miningSpeed + EnumChatFormatting.DARK_GRAY + "/50",
+ "",
+ EnumChatFormatting.GRAY + "Grants " + EnumChatFormatting.GREEN + "+" + miningSpeedStat +
+ EnumChatFormatting.GOLD + " ⸕ Mining",
+ EnumChatFormatting.GOLD + "Speed" + EnumChatFormatting.GRAY + "."
+ ),
+ 50
+ );
+
+ renderHotmPerk(
+ miningFortune,
+ (int) (guiLeft + xStart + 255), (int) (guiTop + yStartTop + 114),
+ mouseX, mouseY,
+ () -> Lists.newArrayList(
+ "Mining Fortune",
+ EnumChatFormatting.GRAY + "Level " + miningFortune + EnumChatFormatting.DARK_GRAY + "/50",
+ "",
+ EnumChatFormatting.GRAY + "Grants " + EnumChatFormatting.GREEN + "+" + miningFortuneStat +
+ EnumChatFormatting.GOLD + " ☘ Mining",
+ EnumChatFormatting.GOLD + "Fortune" + EnumChatFormatting.GRAY + "."
+ ),
+ 50
+ );
+
+ renderHotmPerk(
+ tittyInsane,
+ (int) (guiLeft + xStart + 231), (int) (guiTop + yStartTop + 114),
+ mouseX, mouseY,
+ () -> Lists.newArrayList(
+ "Titanium Insanium",
+ EnumChatFormatting.GRAY + "Level " + tittyInsane + EnumChatFormatting.DARK_GRAY + "/50",
+ "",
+ EnumChatFormatting.GRAY + "When mining Mithril Ore, you",
+ EnumChatFormatting.GRAY + "have a " + EnumChatFormatting.GREEN + tittyInsaneStat + "% " +
+ EnumChatFormatting.GRAY + "chance to",
+ EnumChatFormatting.GRAY + "convert the block into Titanium",
+ EnumChatFormatting.GRAY + "Ore."
+ ),
+ 50
+ );
+
+ renderPickaxeAbility(
+ miningSpeedBoost,
+ (int) (guiLeft + xStart + 207), (int) (guiTop + yStartTop + 114),
+ mouseX, mouseY,
+ () -> potm == 0 ? Lists.newArrayList( // Peak of the mountain == 0
+ "Mining Speed Boost",
+ "",
+ EnumChatFormatting.GRAY + "Pickaxe Ability: Mining Speed Boost",
+ EnumChatFormatting.GRAY + "Grants " + EnumChatFormatting.GREEN + "200% " + EnumChatFormatting.GOLD + "⸕ Mining",
+ EnumChatFormatting.GOLD + "Speed " + EnumChatFormatting.GRAY + "for " + EnumChatFormatting.GREEN + "15s" +
+ EnumChatFormatting.GRAY,
+ EnumChatFormatting.DARK_GRAY + "Cooldown: " + EnumChatFormatting.GREEN + "120s"
+ ) : Lists.newArrayList( // Peak of the mountain > 0
+ "Mining Speed Boost",
+ "",
+ EnumChatFormatting.GRAY + "Pickaxe Ability: Mining Speed Boost",
+ EnumChatFormatting.GRAY + "Grants " + EnumChatFormatting.GREEN + "300% " + EnumChatFormatting.GOLD + "⸕ Mining",
+ EnumChatFormatting.GOLD + "Speed " + EnumChatFormatting.GRAY + "for " + EnumChatFormatting.GREEN + "20s" +
+ EnumChatFormatting.GRAY,
+ EnumChatFormatting.DARK_GRAY + "Cooldown: " + EnumChatFormatting.GREEN + "120s"
+ )
+ );
+
+ renderPickaxeAbility(
+ veinSeeker,
+ (int) (guiLeft + xStart + 183), (int) (guiTop + yStartTop + 18),
+ mouseX, mouseY,
+ () -> Lists.newArrayList(
+ "Vein Seeker",
+ "",
+ "§6Pickaxe Ability: Vein Seeker",
+ "§7Points in the direction of the",
+ "§7nearest vein and grants §a+§a3§7",
+ "§7§6Mining Spread §7for §a14s§7§7.",
+ "§8Cooldown: §a60s"
+ )
+ );
+
+ renderHotmPerk(
+ luckofcave,
+ (int) (guiLeft + xStart + 207), (int) (guiTop + yStartTop + 90),
+ mouseX, mouseY,
+ () -> Lists.newArrayList(
+ "Luck of the Cave",
+ "§7Level " + luckofcave + EnumChatFormatting.DARK_GRAY + "/45",
+ "",
+ "§7Increases the chance for you to",
+ "§7trigger rare occurrences im",
+ "§2Dwarven Mines " + EnumChatFormatting.GRAY + "by " + EnumChatFormatting.GREEN + luckofcaveStat + "%§7."
+ ),
+ 45
+ );
+
+ renderHotmPerk(
+ dailyPowder,
+ (int) (guiLeft + xStart + 255), (int) (guiTop + yStartTop + 90),
+ mouseX, mouseY,
+ () -> Lists.newArrayList(
+ "Daily Powder",
+ EnumChatFormatting.GRAY + "Level " + dailyPowder + EnumChatFormatting.DARK_GRAY + "/100",
+ "",
+ EnumChatFormatting.GRAY + "Gains " + EnumChatFormatting.GREEN + dailyPowderStat + " Powder" +
+ EnumChatFormatting.GRAY + " from the",
+ EnumChatFormatting.GRAY + "first ore you mine every day.",
+ EnumChatFormatting.GRAY + "Works for all Powder types."
+ ),
+ 100
+ );
+
+ float finalEffMinerStat2 = effMinerStat2;
+ renderHotmPerk(
+ effMiner,
+ (int) (guiLeft + xStart + 255), (int) (guiTop + yStartTop + 66),
+ mouseX, mouseY,
+ () -> Lists.newArrayList(
+ "Efficient Miner",
+ EnumChatFormatting.GRAY + "Level " + effMiner + EnumChatFormatting.DARK_GRAY + "/100",
+ "",
+ EnumChatFormatting.GRAY + "When mining ores, you have a",
+ EnumChatFormatting.GREEN + "" + effMinerStat + "%" + EnumChatFormatting.GRAY + " chance to mine " +
+ EnumChatFormatting.GREEN + Math.round(finalEffMinerStat2),
+ EnumChatFormatting.GRAY + "adjacent ores."
+ ),
+ 100
+ );
+
+ renderHotmPerk(
+ potm,
+ (int) (guiLeft + xStart + 255), (int) (guiTop + yStartTop + 42),
+ mouseX, mouseY,
+ () -> {
+ switch (potm) {
+ case 0:
+ return Lists.newArrayList(
+ EnumChatFormatting.RED + "Peak of the Mountain",
+ EnumChatFormatting.GRAY + "Level " + potm + EnumChatFormatting.DARK_GRAY + "/5"
+ );
+ case 1:
+ return Lists.newArrayList(
+ EnumChatFormatting.YELLOW + "Peak of the Mountain",
+ EnumChatFormatting.GRAY + "Level " + potm + EnumChatFormatting.DARK_GRAY + "/5",
+ "",
+ "§7§8+§c1 Pickaxe Ability Level",
+ "§7§8+§51 Token of the Mountain"
+ );
+ case 2:
+ return Lists.newArrayList(
+ EnumChatFormatting.YELLOW + "Peak of the Mountain",
+ EnumChatFormatting.GRAY + "Level " + potm + EnumChatFormatting.DARK_GRAY + "/5",
+ "",
+ "§7§8+§c1 Pickaxe Ability Level",
+ "§7§8+§51 Token of the Mountain",
+ "§7§8+§a1 Forge Slot"
+ );
+ case 3:
+ return Lists.newArrayList(
+ EnumChatFormatting.YELLOW + "Peak of the Mountain",
+ EnumChatFormatting.GRAY + "Level " + potm + EnumChatFormatting.DARK_GRAY + "/5",
+ "",
+ "§7§8+§c1 Pickaxe Ability Level",
+ "§7§8+§51 Token of the Mountain",
+ "§7§8+§a1 Forge Slot",
+ "§7§8+§a1 Commission Slot"
+ );
+ case 4:
+ return Lists.newArrayList(
+ EnumChatFormatting.YELLOW + "Peak of the Mountain",
+ EnumChatFormatting.GRAY + "Level " + potm + EnumChatFormatting.DARK_GRAY + "/5",
+ "",
+ "§7§8+§c1 Pickaxe Ability Level",
+ "§7§8+§51 Token of the Mountain",
+ "§7§8+§a1 Forge Slot",
+ "§7§8+§a1 Commission Slot",
+ "§7§8+§21 Mithril Powder §7when",
+ "§7mining §fMithril"
+ );
+ case 5:
+ return Lists.newArrayList(
+ EnumChatFormatting.GREEN + "Peak of the Mountain",
+ EnumChatFormatting.GRAY + "Level " + potm + EnumChatFormatting.DARK_GRAY + "/5",
+ "",
+ "§7§8+§c1 Pickaxe Ability Level",
+ "§7§8+§51 Token of the Mountain",
+ "§7§8+§a1 Forge Slot",
+ "§7§8+§a1 Commission Slot",
+ "§7§8+§21 Mithril Powder §7when",
+ "§7mining §fMithril",
+ "§7§8+§51 Token of the Mountain"
+ );
+ }
+ return null;
+ },
+ potm > 0 ? new ItemStack(Blocks.redstone_block) : new ItemStack(Blocks.bedrock),
+ true // A redstone block or bedrock is being rendered, so standard GUI item lighting needs to be enabled.
+ );
+
+ float finalOutput = output;
+ renderHotmPerk(
+ mole,
+ (int) (guiLeft + xStart + 255), (int) (guiTop + yStartTop + 18),
+ mouseX, mouseY,
+ () -> Lists.newArrayList(
+ "Mole",
+ EnumChatFormatting.GRAY + "Level " + mole + EnumChatFormatting.DARK_GRAY + "/190",
+ "",
+ EnumChatFormatting.GRAY + "When mining hard stone, you have",
+ EnumChatFormatting.GRAY + "a " + EnumChatFormatting.GREEN + finalOutput + "% " + EnumChatFormatting.GRAY +
+ "chance to mine " + EnumChatFormatting.GREEN,
+ EnumChatFormatting.GREEN + "" + Math.round(moleStat) + EnumChatFormatting.GRAY + " adjacent hard stone block" +
+ (moleStat == 1.0 ? "." : "s.")
+ ),
+ 190
+ );
+
+ renderHotmPerk(
+ powderBuff,
+ (int) (guiLeft + xStart + 255), (int) (guiTop + yStartTop - 6),
+ mouseX, mouseY,
+ () -> Lists.newArrayList(
+ "Powder Buff",
+ EnumChatFormatting.GRAY + "Level " + powderBuff + EnumChatFormatting.DARK_GRAY + "/50",
+ "",
+ EnumChatFormatting.GRAY + "Gain " + EnumChatFormatting.GREEN + powderBuff + "% " + EnumChatFormatting.GRAY +
+ "more Mithril",
+ EnumChatFormatting.GRAY + "Powder and Gemstone Powder§7."
+ ),
+ 50
+ );
+
+ renderHotmPerk(
+ skyMall,
+ (int) (guiLeft + xStart + 183), (int) (guiTop + yStartTop + 66),
+ mouseX, mouseY,
+ () -> Lists.newArrayList(
+ "Sky Mall",
+ "§7Every SkyBlock day, you receive",
+ "§7a random buff in the §2Dwarven",
+ "§2Mines§7.",
+ "",
+ "§7Possible Buffs",
+ "§8 ■ §7Gain §a+100 §6⸕ Mining Speed.",
+ "§8 ■ §7Gain §a+50 §6☘ Mining Fortune.",
+ "§8 ■ §7Gain §a+15% §7chance to gain",
+ " §7extra Powder while mining.",
+ "§8 ■ §7Reduce Pickaxe Ability cooldown",
+ " §7by §a20%", "§8 ■ §7§a10x §7chance to find Goblins",
+ " §7while mining.",
+ "§8 ■ §7Gain §a5x §9Titanium §7drops."
+ ),
+ new ItemStack(skyMall > 0 ? Items.diamond : Items.coal)
+ );
+
+ renderHotmPerk(
+ goblinKiller,
+ (int) (guiLeft + xStart + 207), (int) (guiTop + yStartTop + 42),
+ mouseX, mouseY,
+ () -> Lists.newArrayList(
+ "Goblin Killer",
+ "§7Killing a §6Golden Goblin",
+ "§6§7gives §2200 §7extra §2Mithril",
+ "§2Powder§7, while killing other",
+ "§7Goblins gives some based on",
+ "§7their wits."
+ ),
+ new ItemStack(goblinKiller > 0 ? Items.diamond : Items.coal)
+ );
+
+ renderHotmPerk(
+ seasonMine,
+ (int) (guiLeft + xStart + 231), (int) (guiTop + yStartTop + 66),
+ mouseX, mouseY,
+ () -> Lists.newArrayList(
+ "Seasoned Mineman",
+ "§7Level " + seasonMine + "§8/100",
+ "",
+ "§7Increases your Mining",
+ "§7experience gain by " + EnumChatFormatting.GREEN + seasonMineStat + "%§7."
+ ),
+ 100
+ );
+
+ renderHotmPerk(
+ madMining,
+ (int) (guiLeft + xStart + 207), (int) (guiTop + yStartTop + 66),
+ mouseX, mouseY,
+ () -> Lists.newArrayList(
+ "Mining Madness",
+ "§7Grants §a+50 §6⸕ Mining Speed",
+ "§7and §6☘ Mining Fortune§7."
+ ),
+ new ItemStack(madMining > 0 ? Items.diamond : Items.coal)
+ );
+
+ renderHotmPerk(
+ lonesomeMiner,
+ (int) (guiLeft + xStart + 207), (int) (guiTop + yStartTop + 18),
+ mouseX, mouseY,
+ () -> Lists.newArrayList(
+ "Lonesome Miner",
+ "§7Level " + lonesomeMiner + EnumChatFormatting.DARK_GRAY + "/45",
+ "",
+ "§7Increases §c❁ Strength, §9☣ Crit",
+ "§9Chance, §9☠ Crit Damage, §a❈",
+ "§aDefense, and §c❤ Health",
+ "§c§7statistics gain by " + EnumChatFormatting.GREEN + lonesomeMinerStat + "%§7",
+ "§7while in the Crystal Hollows."
+ ),
+ 45
+ );
+
+ renderHotmPerk(
+ professional,
+ (int) (guiLeft + xStart + 231), (int) (guiTop + yStartTop + 18),
+ mouseX, mouseY,
+ () -> Lists.newArrayList(
+ "Professional",
+ "§7Level " + professional + EnumChatFormatting.DARK_GRAY + "/140",
+ "",
+ "§7Gain §a+" + professionalStat + "§6 ⸕ Mining",
+ "§6Speed§7 when mining Gemstones."
+ ),
+ 140
+ );
+
+ renderHotmPerk(
+ miningSpeed2,
+ (int) (guiLeft + xStart + 207), (int) (guiTop + yStartTop - 6),
+ mouseX, mouseY,
+ () -> Lists.newArrayList(
+ "Mining Speed 2",
+ "§7Level " + miningSpeed2 + EnumChatFormatting.DARK_GRAY + "/50",
+ "",
+ "§7Grants " + EnumChatFormatting.GREEN + "+" + miningSpeed2Stat + EnumChatFormatting.GOLD + " ⸕ Mining",
+ "§6Speed§7."
+ ),
+ 50
+ );
+
+ renderHotmPerk(
+ quickForge,
+ (int) (guiLeft + xStart + 279), (int) (guiTop + yStartTop + 114),
+ mouseX, mouseY,
+ () -> Lists.newArrayList(
+ "Quick Forge",
+ "§7Level " + quickForge + EnumChatFormatting.DARK_GRAY + "/20",
+ "",
+ "§7Decreases the time it takes to",
+ "§7forge by §a" + (quickForgeStat < 20 ? quickForgeStat : 30) + "%§7."
+ ),
+ 20
+ );
+
+ renderHotmPerk(
+ fortunate,
+ (int) (guiLeft + xStart + 279), (int) (guiTop + yStartTop + 18),
+ mouseX, mouseY,
+ () -> Lists.newArrayList(
+ "Fortunate",
+ "§7Level " + fortunate + EnumChatFormatting.DARK_GRAY + "/20",
+ "",
+ "§7Gain " + EnumChatFormatting.GREEN + "+" + fortunateStat + " §6☘ Mining",
+ "§6Fortune§7 when mining Gemstone."
+ ),
+ 20
+ );
+
+ renderHotmPerk(
+ greatExplorer,
+ (int) (guiLeft + xStart + 303), (int) (guiTop + yStartTop + 18),
+ mouseX, mouseY,
+ () -> Lists.newArrayList(
+ "Great Explorer",
+ "§7Level " + greatExplorer + EnumChatFormatting.DARK_GRAY + "/20",
+ "",
+ "§7Grants " + EnumChatFormatting.GREEN + "+" + greatExplorerStat + "% " + EnumChatFormatting.GRAY + "chance to",
+ "§7find treasure."
+ ),
+ 20
+ );
+
+ renderHotmPerk(
+ miningFortune2,
+ (int) (guiLeft + xStart + 303), (int) (guiTop + yStartTop - 6),
+ mouseX, mouseY,
+ () -> Lists.newArrayList(
+ "Mining Fortune 2",
+ "§7Level " + miningFortune2 + EnumChatFormatting.DARK_GRAY + "/50",
+ "",
+ "§7Grants §a+§a" + miningFortune2Stat + "§7 §6☘ Mining", "§6Fortune§7."
+ ),
+ 50
+ );
+
+ renderHotmPerk(
+ orbit,
+ (int) (guiLeft + xStart + 279), (int) (guiTop + yStartTop + 66),
+ mouseX, mouseY,
+ () -> Lists.newArrayList(
+ "Orbiter",
+ "§7Level " + orbit + EnumChatFormatting.DARK_GRAY + "/80",
+ "",
+ "§7When mining ores, you have a",
+ EnumChatFormatting.GREEN + "" + orbitStat + "%" + EnumChatFormatting.GRAY + " chance to get a random",
+ "§7amount of experience orbs."
+ ),
+ 80
+ );
+
+ renderHotmPerk(
+ frontLoad,
+ (int) (guiLeft + xStart + 303), (int) (guiTop + yStartTop + 66),
+ mouseX, mouseY,
+ () -> Lists.newArrayList(
+ "Front Loaded",
+ "§7Grants §a+100 §6⸕ Mining Speed",
+ "§7and §6☘ Mining Fortune §7for",
+ "§7the first §e2,500 §7ores you",
+ "§7mine in a day."
+ ),
+ new ItemStack(frontLoad > 0 ? Items.diamond : Items.coal)
+ );
+
+ renderHotmPerk(
+ starPowder,
+ (int) (guiLeft + xStart + 303), (int) (guiTop + yStartTop + 42),
+ mouseX, mouseY,
+ () -> Lists.newArrayList(
+ "Star Powder",
+ "§7Mining Mithril Ore near §5Fallen",
+ "§5Crystals §7gives §a+3 §7extra",
+ "§7Mithril Powder§7."
+ ),
+ new ItemStack(starPowder > 0 ? Items.diamond : Items.coal)
+ );
+
+ renderHotmPerk(
+ fortnite,
+ (int) (guiLeft + xStart + 327), (int) (guiTop + yStartTop + 66),
+ mouseX, mouseY,
+ () -> Lists.newArrayList(
+ "Precision Mining",
+ "§7When mining ore, a particle",
+ "§7target appears on the block that",
+ "§7increases your §6⸕ Mining Speed",
+ "§7by §a30% §7when aiming at it."
+ ),
+ new ItemStack(fortnite > 0 ? Items.diamond : Items.coal)
+ );
+
+ renderHotmPerk(
+ crystallized,
+ (int) (guiLeft + xStart + 303), (int) (guiTop + yStartTop + 90),
+ mouseX, mouseY,
+ () -> Lists.newArrayList(
+ "Crystallized",
+ "§7Level " + crystallized + EnumChatFormatting.DARK_GRAY + "/30",
+ "",
+ "§7Grants §a+§a" + crystallizedStat + "§7 §6⸕ Mining",
+ "§6Speed §7and a §a" + crystallizedStat + "%§7 §7chance",
+ "§7to deal §a+1 §7extra damage near",
+ "§7§5Fallen Stars§7."
+ ),
+ 30
+ );
+
+ renderPickaxeAbility(
+ pickoblus,
+ (int) (guiLeft + xStart + 303), (int) (guiTop + yStartTop + 114),
+ mouseX, mouseY,
+ () -> Lists.newArrayList(
+ "Pickobulus",
+ "",
+ "§6Pickaxe Ability: Pickobulus",
+ "§7Throw your pickaxe to create an",
+ "§7explosion on impact, mining all",
+ "§7ores within a §a2§7 block",
+ "§7radius.",
+ "§8Cooldown: §a" + (potm == 0 ? "120s" : "110s")
+ )
+ );
+
+ renderPickaxeAbility(
+ maniacMiner,
+ (int) (guiLeft + xStart + 327), (int) (guiTop + yStartTop + 18),
+ mouseX, mouseY,
+ () -> Lists.newArrayList(
+ EnumChatFormatting.RED + "Maniac Miner",
+ "",
+ "§6Pickaxe Ability: Maniac Miner",
+ "§7Spends all your Mana and grants",
+ "§7§a+1 §6⸕ Mining Speed §7for",
+ "§7every 10 Mana spent, for",
+ "§7§a§a15s§7§7.",
+ "§8Cooldown: §a59s"
+ )
+ );
+ }
+
+ /**
+ * Renders a standard HOTM perk that can be levelled.
+ */
+ private void renderHotmPerk(
+ int perkLevel,
+ int xPosition,
+ int yPosition,
+ int mouseX,
+ int mouseY,
+ Supplier<ArrayList<String>> tooltipSupplier,
+ int maxLevel
+ ) {
+ renderHotmPerk(perkLevel, xPosition, yPosition, mouseX, mouseY, tooltipSupplier, false, maxLevel);
+ }
+
+ /**
+ * Renders a pickaxe ability that can be unlocked once and not levelled.
+ */
+ private void renderPickaxeAbility(
+ int perkLevel,
+ int xPosition,
+ int yPosition,
+ int mouseX,
+ int mouseY,
+ Supplier<ArrayList<String>> tooltipSupplier
+ ) {
+ renderHotmPerk(perkLevel, xPosition, yPosition, mouseX, mouseY, tooltipSupplier, true, -1);
+ }
+
+ /**
+ * Renders a HOTM perk. This method is only called from its overloads above.
+ */
+ private void renderHotmPerk(
+ int perkLevel,
+ int xPosition,
+ int yPosition,
+ int mouseX,
+ int mouseY,
+ Supplier<ArrayList<String>> tooltipSupplier,
+ boolean isPickaxeAbility,
+ int maxLevel
+ ) {
+ boolean unlocked = perkLevel > 0;
+ GlStateManager.color(1, 1, 1, 1);
+ GlStateManager.disableLighting();
+
+ ItemStack itemStack;
+ if (isPickaxeAbility) {
+ RenderHelper.enableGUIStandardItemLighting(); // GUI standard item lighting must be enabled for items that are rendered as blocks, like emerald blocks.
+ itemStack =
+ new ItemStack(unlocked ? Blocks.emerald_block : Blocks.coal_block); // Pickaxe abilities are rendered as blocks
+ } else { // Non-pickaxe abilities are rendered as items
+ itemStack = new ItemStack(unlocked ? (perkLevel >= maxLevel ? Items.diamond : Items.emerald) : Items.coal);
+ }
+
+ ArrayList<String> tooltip = tooltipSupplier.get();
+ // Prepend the green, yellow, or red color on the first line of each tooltip depending on if the perk is unlocked
+ tooltip.set(
+ 0,
+ (unlocked
+ ? (perkLevel >= maxLevel ? EnumChatFormatting.GREEN : EnumChatFormatting.YELLOW)
+ : EnumChatFormatting.RED) + tooltip.get(0)
+ );
+
+ NBTTagCompound nbt = new NBTTagCompound(); //Adding NBT Data for Custom Resource Packs
+ NBTTagCompound display = new NBTTagCompound();
+ display.setString("Name", tooltip.get(0));
+ nbt.setTag("display", display);
+ itemStack.setTagCompound(nbt);
+
+ Minecraft.getMinecraft().getRenderItem().renderItemIntoGUI(itemStack, xPosition, yPosition);
+ GlStateManager.enableLighting();
+ if (mouseX >= xPosition && mouseX < xPosition + 16) {
+ if (mouseY >= yPosition && mouseY <= yPosition + 16) {
+ Utils.drawHoveringText(tooltip, mouseX, mouseY, width, height, -1, Minecraft.getMinecraft().fontRendererObj);
+ }
+ }
+ }
+
+ /**
+ * A separate method similar to the one above, but allowing the caller to specify an ItemStack to render.
+ * Used for rendering Peak of the Mountain and perks that are unlocked once and not upgraded.
+ */
+ private void renderHotmPerk(
+ int perkLevel,
+ int xPosition,
+ int yPosition,
+ int mouseX,
+ int mouseY,
+ Supplier<ArrayList<String>> tooltipSupplier,
+ ItemStack itemStack
+ ) {
+ renderHotmPerk(perkLevel, xPosition, yPosition, mouseX, mouseY, tooltipSupplier, itemStack, false);
+ }
+
+ /**
+ * This method renders a HOTM perk using the provided ItemStack.
+ * It is overloaded by the method above, and is only called directly to render Peak of the Mountain.
+ */
+ private void renderHotmPerk(
+ int perkLevel,
+ int xPosition,
+ int yPosition,
+ int mouseX,
+ int mouseY,
+ Supplier<ArrayList<String>> tooltipSupplier,
+ ItemStack itemStack,
+ boolean isRenderingBlock
+ ) {
+ boolean unlocked = perkLevel > 0;
+ GlStateManager.color(1, 1, 1, 1);
+ GlStateManager.disableLighting();
+ if (isRenderingBlock) RenderHelper.enableGUIStandardItemLighting();
+
+ ArrayList<String> tooltip = tooltipSupplier.get();
+ // Prepend the green or red color on the first line of each tooltip depending on if the perk is unlocked
+ if (!tooltip.get(0).contains("Peak of the Mountain")) tooltip.set(
+ 0,
+ (unlocked ? EnumChatFormatting.GREEN : EnumChatFormatting.RED) + tooltip.get(0)
+ ); //Peak of the Moutain has three color options, and is set already
+
+ NBTTagCompound nbt = new NBTTagCompound(); //Adding NBT Data for Resource Packs
+ NBTTagCompound display = new NBTTagCompound();
+ display.setString("Name", tooltip.get(0));
+ if (tooltip.get(0).contains("Peak of the Mountain")) display.setString("Lore", tooltip.get(1)); //Set Lore to Level
+ nbt.setTag("display", display);
+ itemStack.setTagCompound(nbt);
+
+ Minecraft.getMinecraft().getRenderItem().renderItemIntoGUI(itemStack, xPosition, yPosition);
+ GlStateManager.enableLighting();
+ if (mouseX >= xPosition && mouseX < xPosition + 16) {
+ if (mouseY >= yPosition && mouseY <= yPosition + 16) {
+ Utils.drawHoveringText(tooltip, mouseX, mouseY, width, height, -1, Minecraft.getMinecraft().fontRendererObj);
+ }
+ }
+ }
+
+ private String getTimeSinceString(JsonObject profileInfo, String path) {
+ JsonElement lastSaveElement = Utils.getElement(profileInfo, path);
+
+ if (lastSaveElement != null && lastSaveElement.isJsonPrimitive()) {
+
+ Instant lastSave = Instant.ofEpochMilli(lastSaveElement.getAsLong());
+ LocalDateTime lastSaveTime = LocalDateTime.ofInstant(lastSave, TimeZone.getDefault().toZoneId());
+ long timeDiff = System.currentTimeMillis() - lastSave.toEpochMilli();
+ LocalDateTime sinceOnline = LocalDateTime.ofInstant(Instant.ofEpochMilli(timeDiff), ZoneId.of("UTC"));
+ String renderText;
+
+ if (timeDiff < 60000L) {
+ renderText = sinceOnline.getSecond() + " seconds ago.";
+ } else if (timeDiff < 3600000L) {
+ renderText = sinceOnline.getMinute() + " minutes ago.";
+ } else if (timeDiff < 86400000L) {
+ renderText = sinceOnline.getHour() + " hours ago.";
+ } else if (timeDiff < 31556952000L) {
+ renderText = sinceOnline.getDayOfYear() + " days ago.";
+ } else {
+ renderText = lastSaveTime.format(DateTimeFormatter.ofPattern("dd-MM-yyyy"));
+ }
+ return renderText;
+ }
+ return null;
+ }
+
+ private int backgroundClickedX = -1;
+
+ private static final char[] c = new char[]{'k', 'm', 'b', 't'};
+
+ public static String shortNumberFormat(double n, int iteration) {
+ if (n < 1000) {
+ if (n % 1 == 0) {
+ return Integer.toString((int) n);
+ } else {
+ return String.format("%.2f", n);
+ }
+ }
+
+ double d = ((long) n / 100) / 10.0;
+ boolean isRound = (d * 10) % 10 == 0;
+ return (d < 1000 ?
+ ((d > 99.9 || isRound || (!isRound && d > 9.99) ?
+ (int) d * 10 / 10 : d + ""
+ ) + "" + c[iteration])
+ : shortNumberFormat(d, iteration + 1));
+ }
+
+ private boolean loadingProfile = false;
+ private static final ExecutorService profileLoader = Executors.newFixedThreadPool(1);
+
+ private void drawBasicPage(int mouseX, int mouseY, float partialTicks) {
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+
+ String location = null;
+ JsonObject status = profile.getPlayerStatus();
+ if (status != null && status.has("mode")) {
+ location = status.get("mode").getAsString();
+ }
+
+ int extraRotation = 0;
+ if (Mouse.isButtonDown(0) || Mouse.isButtonDown(1)) {
+ if (backgroundClickedX == -1) {
+ if (mouseX > guiLeft + 23 && mouseX < guiLeft + 23 + 81) {
+ if (mouseY > guiTop + 44 && mouseY < guiTop + 44 + 108) {
+ backgroundClickedX = mouseX;
+ }
+ }
+ }
+ } else {
+ if (backgroundClickedX != -1) {
+ backgroundRotation += mouseX - backgroundClickedX;
+ backgroundClickedX = -1;
+ }
+ }
+ if (backgroundClickedX == -1) {
+ backgroundRotation += (currentTime - lastTime) / 400f;
+ } else {
+ extraRotation = mouseX - backgroundClickedX;
+ }
+ backgroundRotation %= 360;
+
+ String panoramaIdentifier = "day";
+ if (SBInfo.getInstance().currentTimeDate != null) {
+ if (SBInfo.getInstance().currentTimeDate.getHours() <= 6 ||
+ SBInfo.getInstance().currentTimeDate.getHours() >= 20) {
+ panoramaIdentifier = "night";
+ }
+ }
+
+ Panorama.drawPanorama(-backgroundRotation - extraRotation, guiLeft + 23, guiTop + 44, 81, 108, 0.37f, 0.8f,
+ getPanoramasForLocation(location == null ? "unknown" : location, panoramaIdentifier)
+ );
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(pv_basic);
+ Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST);
+
+ if (entityPlayer != null && profile.getHypixelProfile() != null) {
+ String playerName = null;
+ if (profile.getHypixelProfile().has("prefix")) {
+ playerName =
+ Utils.getElementAsString(profile.getHypixelProfile().get("prefix"), "") + " " + entityPlayer.getName();
+ } else {
+ String rank = Utils.getElementAsString(
+ profile.getHypixelProfile().get("rank"),
+ Utils.getElementAsString(profile.getHypixelProfile().get("newPackageRank"), "NONE")
+ );
+ String monthlyPackageRank =
+ Utils.getElementAsString(profile.getHypixelProfile().get("monthlyPackageRank"), "NONE");
+ if (!rank.equals("YOUTUBER") && !monthlyPackageRank.equals("NONE")) {
+ rank = monthlyPackageRank;
+ }
+ EnumChatFormatting rankPlusColorECF = EnumChatFormatting.getValueByName(Utils.getElementAsString(
+ profile.getHypixelProfile().get("rankPlusColor"),
+ "GOLD"
+ ));
+ String rankPlusColor = EnumChatFormatting.GOLD.toString();
+ if (rankPlusColorECF != null) {
+ rankPlusColor = rankPlusColorECF.toString();
+ }
+
+ JsonObject misc = Constants.MISC;
+ if (misc != null) {
+ if (misc.has("ranks")) {
+ String rankName = Utils.getElementAsString(Utils.getElement(misc, "ranks." + rank + ".tag"), null);
+ String rankColor = Utils.getElementAsString(Utils.getElement(misc, "ranks." + rank + ".color"), "7");
+ String rankPlus = Utils.getElementAsString(Utils.getElement(misc, "ranks." + rank + ".plus"), "");
+
+ String name = entityPlayer.getName();
+
+ if (misc.has("special_bois")) {
+ JsonArray special_bois = misc.get("special_bois").getAsJsonArray();
+ for (int i = 0; i < special_bois.size(); i++) {
+ if (special_bois.get(i).getAsString().equals(profile.getUuid())) {
+ name = Utils.chromaString(name);
+ break;
+ }
+ }
+ }
+
+ playerName = EnumChatFormatting.GRAY + name;
+ if (rankName != null) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("\u00A7" + rankColor);
+ sb.append("[");
+ sb.append(rankName);
+ sb.append(rankPlusColor);
+ sb.append(rankPlus);
+ sb.append("\u00A7" + rankColor);
+ sb.append("] ");
+ sb.append(name);
+ playerName = sb.toString();
+ }
+ }
+ }
+
+ }
+ if (playerName != null) {
+ int rankPrefixLen = fr.getStringWidth(playerName);
+ int halfRankPrefixLen = rankPrefixLen / 2;
+
+ int x = guiLeft + 63;
+ int y = guiTop + 54;
+
+ drawRect(x - halfRankPrefixLen - 1, y - 1, x + halfRankPrefixLen + 1, y + 8, new Color(0, 0, 0, 64).getRGB());
+
+ fr.drawString(playerName, x - halfRankPrefixLen, y, 0, true);
+ }
+ }
+
+ long networth = profile.getNetWorth(profileId);
+ if (networth > 0) {
+ Utils.drawStringCentered(
+ EnumChatFormatting.GREEN + "Net Worth: " + EnumChatFormatting.GOLD + numberFormat.format(networth),
+ fr,
+ guiLeft + 63,
+ guiTop + 38,
+ true,
+ 0
+ );
+ try {
+ double networthInCookies = (networth / NotEnoughUpdates.INSTANCE.manager.auctionManager
+ .getBazaarInfo("BOOSTER_COOKIE")
+ .get("avg_buy")
+ .getAsDouble());
+ String networthIRLMoney = Long.toString(Math.round(((networthInCookies * 325) / 675) * 4.99));
+
+ if (mouseX > guiLeft + 8 &&
+ mouseX < guiLeft + 8 + fontRendererObj.getStringWidth("Net Worth: " + numberFormat.format(networth))) {
+ if (mouseY > guiTop + 32 && mouseY < guiTop + 32 + fontRendererObj.FONT_HEIGHT) {
+ tooltipToDisplay = new ArrayList<>();
+ tooltipToDisplay.add(
+ EnumChatFormatting.GREEN + "Net worth in IRL money: " + EnumChatFormatting.DARK_GREEN + "$" +
+ EnumChatFormatting.GOLD + networthIRLMoney);
+ tooltipToDisplay.add("");
+ if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
+ tooltipToDisplay.add(EnumChatFormatting.RED + "This is calculated using the current");
+ tooltipToDisplay.add(EnumChatFormatting.RED + "price of booster cookies on bazaar and the price");
+ tooltipToDisplay.add(EnumChatFormatting.RED + "for cookies using gems, then the price of gems");
+ tooltipToDisplay.add(EnumChatFormatting.RED + "is where we get the amount of IRL money you");
+ tooltipToDisplay.add(EnumChatFormatting.RED + "theoretically have on skyblock in net worth.");
+ } else {
+ tooltipToDisplay.add(EnumChatFormatting.GRAY + "[SHIFT for Info]");
+ }
+ if (!NotEnoughUpdates.INSTANCE.config.hidden.dev) {
+ tooltipToDisplay.add("");
+ tooltipToDisplay.add(EnumChatFormatting.RED + "THIS IS IN NO WAY ENDORSING IRL TRADING!");
+ }
+ }
+ }
+ } catch (Exception ignored) {
+ }
+ }
+
+ if (status != null) {
+ JsonElement onlineElement = Utils.getElement(status, "online");
+ boolean online = onlineElement != null && onlineElement.isJsonPrimitive() && onlineElement.getAsBoolean();
+ String statusStr = online ? EnumChatFormatting.GREEN + "ONLINE" : EnumChatFormatting.RED + "OFFLINE";
+ String locationStr = null;
+ if (profile.getUuid().equals("20934ef9488c465180a78f861586b4cf")) {
+ locationStr = "Ignoring DMs";
+ } else {
+ if (location != null) {
+ JsonObject misc = Constants.MISC;
+ if (misc != null) {
+ locationStr = Utils.getElementAsString(Utils.getElement(misc, "area_names." + location), "Unknown");
+ }
+ }
+ }
+ if (locationStr != null) {
+ statusStr += EnumChatFormatting.GRAY + " - " + EnumChatFormatting.GREEN + locationStr;
+ }
+
+ Utils.drawStringCentered(statusStr, fr, guiLeft + 63, guiTop + 160, true, 0);
+ }
+
+ if (entityPlayer == null) {
+ if (!loadingProfile || ((ThreadPoolExecutor) profileLoader).getActiveCount() == 0) {
+ loadingProfile = true;
+ UUID playerUUID = UUID.fromString(niceUuid(profile.getUuid()));
+
+ profileLoader.submit(() -> {
+ GameProfile fakeProfile = Minecraft
+ .getMinecraft()
+ .getSessionService()
+ .fillProfileProperties(new GameProfile(playerUUID, "CoolGuy123"), false);
+ entityPlayer = new EntityOtherPlayerMP(Minecraft.getMinecraft().theWorld, fakeProfile) {
+ public ResourceLocation getLocationSkin() {
+ return playerLocationSkin == null
+ ? DefaultPlayerSkin.getDefaultSkin(this.getUniqueID())
+ : playerLocationSkin;
+ }
+
+ public ResourceLocation getLocationCape() {
+ return playerLocationCape;
+ }
+
+ public String getSkinType() {
+ return skinType == null ? DefaultPlayerSkin.getSkinType(this.getUniqueID()) : skinType;
+ }
+ };
+ entityPlayer.setAlwaysRenderNameTag(false);
+ entityPlayer.setCustomNameTag("");
+ });
+ }
+ } else {
+ entityPlayer.refreshDisplayName();
+ byte b = 0;
+ for (EnumPlayerModelParts part : EnumPlayerModelParts.values()) {
+ b |= part.getPartMask();
+ }
+ entityPlayer.getDataWatcher().updateObject(10, b);
+ }
+
+ JsonObject profileInfo = profile.getProfileInformation(profileId);
+ if (profileInfo == null) return;
+
+ JsonObject skillInfo = profile.getSkillInfo(profileId);
+ JsonObject inventoryInfo = profile.getInventoryInfo(profileId);
+
+ if (entityPlayer != null) {
+ if (backgroundClickedX != -1 && Mouse.isButtonDown(1)) {
+ Arrays.fill(entityPlayer.inventory.armorInventory, null);
+ } else {
+ if (inventoryInfo != null && inventoryInfo.has("inv_armor")) {
+ JsonArray items = inventoryInfo.get("inv_armor").getAsJsonArray();
+ if (items != null && items.size() == 4) {
+ for (int i = 0; i < entityPlayer.inventory.armorInventory.length; i++) {
+ JsonElement itemElement = items.get(i);
+ if (itemElement != null && itemElement.isJsonObject()) {
+ entityPlayer.inventory.armorInventory[i] =
+ NotEnoughUpdates.INSTANCE.manager.jsonToStack(itemElement.getAsJsonObject(), false);
+ }
+ }
+ }
+ } else {
+ Arrays.fill(entityPlayer.inventory.armorInventory, null);
+ }
+ }
+ if (entityPlayer.getUniqueID().toString().equals("ae6193ab-494a-4719-b6e7-d50392c8f012")) {
+ entityPlayer.inventory.armorInventory[3] = NotEnoughUpdates.INSTANCE.manager.jsonToStack(
+ NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("SMALL_BACKPACK"));
+ }
+ }
+
+ if (entityPlayer != null && playerLocationSkin == null) {
+ try {
+ Minecraft
+ .getMinecraft()
+ .getSkinManager()
+ .loadProfileTextures(entityPlayer.getGameProfile(), (type, location1, profileTexture) -> {
+ switch (type) {
+ case SKIN:
+ playerLocationSkin = location1;
+ skinType = profileTexture.getMetadata("model");
+
+ if (skinType == null) {
+ skinType = "default";
+ }
+
+ break;
+ case CAPE:
+ playerLocationCape = location1;
+ }
+ }, false);
+ } catch (Exception ignored) {
+ }
+ }
+
+ GlStateManager.color(1, 1, 1, 1);
+ JsonObject petsInfo = profile.getPetsInfo(profileId);
+ if (petsInfo != null) {
+ JsonElement activePetElement = petsInfo.get("active_pet");
+ if (activePetElement != null && activePetElement.isJsonObject()) {
+ JsonObject activePet = activePetElement.getAsJsonObject();
+
+ String type = activePet.get("type").getAsString();
+
+ for (int i = 0; i < 4; i++) {
+ JsonObject item = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(type + ";" + i);
+ if (item != null) {
+ int x = guiLeft + 20;
+ float y = guiTop + 82 + 15 * (float) Math.sin(((currentTime - startTime) / 800f) % (2 * Math.PI));
+ GlStateManager.translate(x, y, 0);
+ ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(item, false);
+
+ //Remove extra attributes so no CIT
+ NBTTagCompound stackTag = stack.getTagCompound() == null ? new NBTTagCompound() : stack.getTagCompound();
+ stackTag.removeTag("ExtraAttributes");
+ stack.setTagCompound(stackTag);
+
+ GlStateManager.scale(1.5f, 1.5f, 1);
+ GlStateManager.enableDepth();
+ Utils.drawItemStack(stack, 0, 0);
+ GlStateManager.scale(1 / 1.5f, 1 / 1.5f, 1);
+ GlStateManager.translate(-x, -y, 0);
+ break;
+ }
+ }
+ }
+ }
+ if (entityPlayer != null) {
+ drawEntityOnScreen(
+ guiLeft + 63,
+ guiTop + 128 + 7,
+ 36,
+ guiLeft + 63 - mouseX,
+ guiTop + 129 - mouseY,
+ entityPlayer
+ );
+ }
+
+ PlayerStats.Stats stats = profile.getStats(profileId);
+
+ if (stats != null) {
+ Splitter splitter = Splitter.on(" ").omitEmptyStrings().limit(2);
+ for (int i = 0; i < PlayerStats.defaultStatNames.length; i++) {
+ String statName = PlayerStats.defaultStatNames[i];
+ if (statName.equals("mining_fortune") || statName.equals("mining_speed")) continue;
+ String statNamePretty = PlayerStats.defaultStatNamesPretty[i];
+
+ int val = Math.round(stats.get(statName));
+
+ GlStateManager.color(1, 1, 1, 1);
+ GlStateManager.enableBlend();
+ GL14.glBlendFuncSeparate(
+ GL11.GL_SRC_ALPHA,
+ GL11.GL_ONE_MINUS_SRC_ALPHA,
+ GL11.GL_ONE,
+ GL11.GL_ONE_MINUS_SRC_ALPHA
+ );
+ Utils.renderAlignedString(
+ statNamePretty,
+ EnumChatFormatting.WHITE.toString() + val,
+ guiLeft + 132,
+ guiTop + 27 + 11f * i,
+ 80
+ );
+
+ if (mouseX > guiLeft + 132 && mouseX < guiLeft + 212) {
+ if (mouseY > guiTop + 27 + 11f * i && mouseY < guiTop + 37 + 11f * i) {
+ List<String> split = splitter.splitToList(statNamePretty);
+ PlayerStats.Stats baseStats = PlayerStats.getBaseStats();
+ tooltipToDisplay = new ArrayList<>();
+ tooltipToDisplay.add(statNamePretty);
+ int base = Math.round(baseStats.get(statName));
+ tooltipToDisplay.add(
+ EnumChatFormatting.GRAY + "Base " + split.get(1) + ": " + EnumChatFormatting.GREEN + base + " " +
+ split.get(0));
+ int passive = Math.round(profile.getPassiveStats(profileId).get(statName) - baseStats.get(statName));
+ tooltipToDisplay.add(
+ EnumChatFormatting.GRAY + "Passive " + split.get(1) + " Bonus: +" + EnumChatFormatting.YELLOW + passive +
+ " " + split.get(0));
+ int itemBonus = Math.round(stats.get(statName) - profile.getPassiveStats(profileId).get(statName));
+ tooltipToDisplay.add(
+ EnumChatFormatting.GRAY + "Item " + split.get(1) + " Bonus: +" + EnumChatFormatting.DARK_PURPLE +
+ itemBonus + " " + split.get(0));
+ int finalStat = Math.round(stats.get(statName));
+ tooltipToDisplay.add(
+ EnumChatFormatting.GRAY + "Final " + split.get(1) + ": +" + EnumChatFormatting.RED + finalStat + " " +
+ split.get(0));
+ }
+ }
+ }
+ } else {
+ Utils.drawStringCentered(EnumChatFormatting.RED + "Skill/Inv/Coll", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 172, guiTop + 101 - 10, true, 0
+ );
+ Utils.drawStringCentered(EnumChatFormatting.RED + "APIs not", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 172, guiTop + 101, true, 0
+ );
+ Utils.drawStringCentered(EnumChatFormatting.RED + "enabled!", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 172, guiTop + 101 + 10, true, 0
+ );
+ }
+
+ if (skillInfo != null) {
+ int position = 0;
+ for (Map.Entry<String, ItemStack> entry : ProfileViewer.getSkillToSkillDisplayMap().entrySet()) {
+ if (entry.getValue() == null || entry.getKey() == null) {
+ position++;
+ continue;
+ }
+
+ int yPosition = position % 7;
+ int xPosition = position / 7;
+
+ String skillName = entry.getValue().getDisplayName();
+
+ float level = Utils.getElementAsFloat(skillInfo.get("level_" + entry.getKey()), 0);
+ int levelFloored = (int) Math.floor(level);
+
+ int x = guiLeft + 237 + 86 * xPosition;
+ int y = guiTop + 31 + 21 * yPosition;
+
+ Utils.renderAlignedString(skillName, EnumChatFormatting.WHITE.toString() + levelFloored, x + 14, y - 4, 60);
+
+ if (skillInfo.get("maxed_" + entry.getKey()).getAsBoolean()) {
+ renderGoldBar(x, y + 6, 80);
+ } else {
+ renderBar(x, y + 6, 80, level % 1);
+ }
+
+ if (mouseX > x && mouseX < x + 80) {
+ if (mouseY > y - 4 && mouseY < y + 13) {
+ tooltipToDisplay = new ArrayList<>();
+ tooltipToDisplay.add(skillName);
+ if (skillInfo.get("maxed_" + entry.getKey()).getAsBoolean()) {
+ tooltipToDisplay.add(EnumChatFormatting.GRAY + "Progress: " + EnumChatFormatting.GOLD + "MAXED!");
+ } else {
+ int maxXp = (int) skillInfo.get("maxxp_" + entry.getKey()).getAsFloat();
+ tooltipToDisplay.add(EnumChatFormatting.GRAY + "Progress: " + EnumChatFormatting.DARK_PURPLE +
+ shortNumberFormat(Math.round((level % 1) * maxXp), 0) + "/" + shortNumberFormat(maxXp, 0));
+ }
+ String totalXpS = NumberFormat
+ .getIntegerInstance()
+ .format((int) skillInfo.get("experience_" + entry.getKey()).getAsFloat());
+ tooltipToDisplay.add(EnumChatFormatting.GRAY + "Total XP: " +
+ EnumChatFormatting.DARK_PURPLE + totalXpS);
+ }
+ }
+
+ GL11.glTranslatef((x), (y - 6f), 0);
+ GL11.glScalef(0.7f, 0.7f, 1);
+ Utils.drawItemStackLinear(entry.getValue(), 0, 0);
+ GL11.glScalef(1 / 0.7f, 1 / 0.7f, 1);
+ GL11.glTranslatef(-(x), -(y - 6f), 0);
+
+ position++;
+ }
+ } else {
+ Utils.drawStringCentered(
+ EnumChatFormatting.RED + "Skills API not enabled!",
+ Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 322,
+ guiTop + 101,
+ true,
+ 0
+ );
+ }
+ }
+
+ private void renderGoldBar(float x, float y, float xSize) {
+ if (!OpenGlHelper.areShadersSupported()) {
+ renderBar(x, y, xSize, 1);
+ return;
+ }
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(icons);
+ ShaderManager shaderManager = ShaderManager.getInstance();
+ shaderManager.loadShader("make_gold");
+ shaderManager.loadData("make_gold", "amount", (startTime - System.currentTimeMillis()) / 10000f);
+
+ Utils.drawTexturedRect(x, y, xSize / 2f, 5, 0 / 256f, (xSize / 2f) / 256f, 79 / 256f, 84 / 256f, GL11.GL_NEAREST);
+ Utils.drawTexturedRect(
+ x + xSize / 2f,
+ y,
+ xSize / 2f,
+ 5,
+ (182 - xSize / 2f) / 256f,
+ 182 / 256f,
+ 79 / 256f,
+ 84 / 256f,
+ GL11.GL_NEAREST
+ );
+
+ GL20.glUseProgram(0);
+ }
+
+ private void renderBar(float x, float y, float xSize, float completed) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(icons);
+
+ completed = Math.round(completed / 0.05f) * 0.05f;
+
+ float notcompleted = 1 - completed;
+
+ int displayNum = 0;//tl.x%5;
+
+ GlStateManager.color(1, 1, 1, 1);
+ float width = 0;
+
+ if (completed < 0.5f && (displayNum == 1 || displayNum == 0)) {
+ width = (0.5f - completed) * xSize;
+ Utils.drawTexturedRect(
+ x + xSize * completed,
+ y,
+ width,
+ 5,
+ xSize * completed / 256f,
+ (xSize / 2f) / 256f,
+ 74 / 256f,
+ 79 / 256f,
+ GL11.GL_NEAREST
+ );
+ }
+ if (completed < 1f && (displayNum == 2 || displayNum == 0)) {
+ width = Math.min(xSize * notcompleted, xSize / 2f);
+ Utils.drawTexturedRect(
+ x + (xSize / 2f) + Math.max(xSize * (completed - 0.5f), 0),
+ y,
+ width,
+ 5,
+ (182 - (xSize / 2f) + Math.max(xSize * (completed - 0.5f), 0)) / 256f,
+ 182 / 256f,
+ 74 / 256f,
+ 79 / 256f,
+ GL11.GL_NEAREST
+ );
+ }
+
+ if (completed > 0f && (displayNum == 3 || displayNum == 0)) {
+ width = Math.min(xSize * completed, xSize / 2f);
+ Utils.drawTexturedRect(x, y, width, 5,
+ 0 / 256f, width / 256f, 79 / 256f, 84 / 256f, GL11.GL_NEAREST
+ );
+ }
+ if (completed > 0.5f && (displayNum == 4 || displayNum == 0)) {
+ width = Math.min(xSize * (completed - 0.5f), xSize / 2f);
+ Utils.drawTexturedRect(x + (xSize / 2f), y, width, 5,
+ (182 - (xSize / 2f)) / 256f, (182 - (xSize / 2f) + width) / 256f, 79 / 256f, 84 / 256f, GL11.GL_NEAREST
+ );
+ }
+ }
+
+ private static final ResourceLocation shadowTextures = new ResourceLocation("textures/misc/shadow.png");
+
+ public static void drawEntityOnScreen(
+ int posX,
+ int posY,
+ int scale,
+ float mouseX,
+ float mouseY,
+ EntityLivingBase ent
+ ) {
+ GlStateManager.enableColorMaterial();
+ GlStateManager.pushMatrix();
+ GlStateManager.translate((float) posX, (float) posY, 50.0F);
+ GlStateManager.scale((float) (-scale), (float) scale, (float) scale);
+ GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
+ float renderYawOffset = ent.renderYawOffset;
+ float f1 = ent.rotationYaw;
+ float f2 = ent.rotationPitch;
+ float f3 = ent.prevRotationYawHead;
+ float f4 = ent.rotationYawHead;
+ GlStateManager.rotate(135.0F, 0.0F, 1.0F, 0.0F);
+ RenderHelper.enableStandardItemLighting();
+ GlStateManager.rotate(-135.0F, 0.0F, 1.0F, 0.0F);
+ GlStateManager.rotate(25, 1.0F, 0.0F, 0.0F);
+ ent.renderYawOffset = (float) Math.atan(mouseX / 40.0F) * 20.0F;
+ ent.rotationYaw = (float) Math.atan(mouseX / 40.0F) * 40.0F;
+ ent.rotationPitch = -((float) Math.atan(mouseY / 40.0F)) * 20.0F;
+ ent.rotationYawHead = ent.rotationYaw;
+ ent.prevRotationYawHead = ent.rotationYaw;
+ RenderManager rendermanager = Minecraft.getMinecraft().getRenderManager();
+ rendermanager.setPlayerViewY(180.0F);
+ rendermanager.setRenderShadow(false);
+ rendermanager.renderEntityWithPosYaw(ent, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F);
/*{
GlStateManager.enableBlend();
@@ -3240,144 +4979,149 @@ public class GuiProfileViewer extends GuiScreen {
GlStateManager.depthMask(true);
}*/
- ent.renderYawOffset = renderYawOffset;
- ent.rotationYaw = f1;
- ent.rotationPitch = f2;
- ent.prevRotationYawHead = f3;
- ent.rotationYawHead = f4;
- GlStateManager.popMatrix();
- RenderHelper.disableStandardItemLighting();
- GlStateManager.disableRescaleNormal();
- GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
- GlStateManager.disableTexture2D();
- GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
- }
-
- public void resetCache() {
- bestWeapons = null;
- bestRods = null;
- armorItems = null;
- inventoryItems = new HashMap<>();
- currentInventoryIndex = 0;
- arrowCount = -1;
- greenCandyCount = -1;
- purpleCandyCount = -1;
- entityPlayer = null;
- playerLocationSkin = null;
- playerLocationCape = null;
- skinType = null;
- petsPage = 0;
- sortedPets = null;
- sortedPetsStack = null;
- selectedPet = -1;
- }
-
- Shader blurShaderHorz = null;
- Framebuffer blurOutputHorz = null;
- Shader blurShaderVert = null;
- Framebuffer blurOutputVert = null;
-
- /**
- * Creates a projection matrix that projects from our coordinate space [0->width; 0->height] to OpenGL coordinate
- * space [-1 -> 1; 1 -> -1] (Note: flipped y-axis).
- *
- * This is so that we can render to and from the framebuffer in a way that is familiar to us, instead of needing to
- * apply scales and translations manually.
- */
- private Matrix4f createProjectionMatrix(int width, int height) {
- Matrix4f projMatrix = new Matrix4f();
- projMatrix.setIdentity();
- projMatrix.m00 = 2.0F / (float)width;
- projMatrix.m11 = 2.0F / (float)(-height);
- projMatrix.m22 = -0.0020001999F;
- projMatrix.m33 = 1.0F;
- projMatrix.m03 = -1.0F;
- projMatrix.m13 = 1.0F;
- projMatrix.m23 = -1.0001999F;
- return projMatrix;
- }
-
- /**
- * Renders whatever is currently in the Minecraft framebuffer to our two framebuffers, applying a horizontal
- * and vertical blur separately in order to significantly save computation time.
- * This is only possible if framebuffers are supported by the system, so this method will exit prematurely
- * if framebuffers are not available. (Apple machines, for example, have poor framebuffer support).
- */
- private double lastBgBlurFactor = -1;
- private void blurBackground() {
- if(!OpenGlHelper.isFramebufferEnabled()) return;
-
- int width = Minecraft.getMinecraft().displayWidth;
- int height = Minecraft.getMinecraft().displayHeight;
-
- if(blurOutputHorz == null) {
- blurOutputHorz = new Framebuffer(width, height, false);
- blurOutputHorz.setFramebufferFilter(GL11.GL_NEAREST);
- }
- if(blurOutputVert == null) {
- blurOutputVert = new Framebuffer(width, height, false);
- blurOutputVert.setFramebufferFilter(GL11.GL_NEAREST);
- }
- if(blurOutputHorz.framebufferWidth != width || blurOutputHorz.framebufferHeight != height) {
- blurOutputHorz.createBindFramebuffer(width, height);
- blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height));
- Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
- }
- if(blurOutputVert.framebufferWidth != width || blurOutputVert.framebufferHeight != height) {
- blurOutputVert.createBindFramebuffer(width, height);
- blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height));
- Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
- }
-
- if(blurShaderHorz == null) {
- try {
- blurShaderHorz = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur",
- Minecraft.getMinecraft().getFramebuffer(), blurOutputHorz);
- blurShaderHorz.getShaderManager().getShaderUniform("BlurDir").set(1, 0);
- blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height));
- } catch(Exception e) { }
- }
- if(blurShaderVert == null) {
- try {
- blurShaderVert = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur",
- blurOutputHorz, blurOutputVert);
- blurShaderVert.getShaderManager().getShaderUniform("BlurDir").set(0, 1);
- blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height));
- } catch(Exception e) { }
- }
- if(blurShaderHorz != null && blurShaderVert != null) {
- if(15 != lastBgBlurFactor) {
- blurShaderHorz.getShaderManager().getShaderUniform("Radius").set((float)15);
- blurShaderVert.getShaderManager().getShaderUniform("Radius").set((float)15);
- lastBgBlurFactor = 15;
- }
- GL11.glPushMatrix();
- blurShaderHorz.loadShader(0);
- blurShaderVert.loadShader(0);
- GlStateManager.enableDepth();
- GL11.glPopMatrix();
-
- Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
- }
- }
-
- /**
- * Renders a subsection of the blurred framebuffer on to the corresponding section of the screen.
- * Essentially, this method will "blur" the background inside the bounds specified by [x->x+blurWidth, y->y+blurHeight]
- */
- public void renderBlurredBackground(int width, int height, int x, int y, int blurWidth, int blurHeight) {
- if(!OpenGlHelper.isFramebufferEnabled()) return;
-
- float uMin = x/(float)width;
- float uMax = (x+blurWidth)/(float)width;
- float vMin = (height-y)/(float)height;
- float vMax = (height-y-blurHeight)/(float)height;
-
- blurOutputVert.bindFramebufferTexture();
- GlStateManager.color(1f, 1f, 1f, 1f);
- //Utils.setScreen(width*f, height*f, f);
- Utils.drawTexturedRect(x, y, blurWidth, blurHeight, uMin, uMax, vMin, vMax);
- //Utils.setScreen(width, height, f);
- blurOutputVert.unbindFramebufferTexture();
- }
+ ent.renderYawOffset = renderYawOffset;
+ ent.rotationYaw = f1;
+ ent.rotationPitch = f2;
+ ent.prevRotationYawHead = f3;
+ ent.rotationYawHead = f4;
+ GlStateManager.popMatrix();
+ RenderHelper.disableStandardItemLighting();
+ GlStateManager.disableRescaleNormal();
+ GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
+ GlStateManager.disableTexture2D();
+ GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
+ }
+
+ public void resetCache() {
+ bestWeapons = null;
+ bestRods = null;
+ armorItems = null;
+ inventoryItems = new HashMap<>();
+ currentInventoryIndex = 0;
+ arrowCount = -1;
+ greenCandyCount = -1;
+ purpleCandyCount = -1;
+ entityPlayer = null;
+ playerLocationSkin = null;
+ playerLocationCape = null;
+ skinType = null;
+ petsPage = 0;
+ sortedPets = null;
+ sortedPetsStack = null;
+ selectedPet = -1;
+ }
+
+ Shader blurShaderHorz = null;
+ Framebuffer blurOutputHorz = null;
+ Shader blurShaderVert = null;
+ Framebuffer blurOutputVert = null;
+
+ /**
+ * Creates a projection matrix that projects from our coordinate space [0->width; 0->height] to OpenGL coordinate
+ * space [-1 -> 1; 1 -> -1] (Note: flipped y-axis).
+ * <p>
+ * This is so that we can render to and from the framebuffer in a way that is familiar to us, instead of needing to
+ * apply scales and translations manually.
+ */
+ private Matrix4f createProjectionMatrix(int width, int height) {
+ Matrix4f projMatrix = new Matrix4f();
+ projMatrix.setIdentity();
+ projMatrix.m00 = 2.0F / (float) width;
+ projMatrix.m11 = 2.0F / (float) (-height);
+ projMatrix.m22 = -0.0020001999F;
+ projMatrix.m33 = 1.0F;
+ projMatrix.m03 = -1.0F;
+ projMatrix.m13 = 1.0F;
+ projMatrix.m23 = -1.0001999F;
+ return projMatrix;
+ }
+
+ /**
+ * Renders whatever is currently in the Minecraft framebuffer to our two framebuffers, applying a horizontal
+ * and vertical blur separately in order to significantly save computation time.
+ * This is only possible if framebuffers are supported by the system, so this method will exit prematurely
+ * if framebuffers are not available. (Apple machines, for example, have poor framebuffer support).
+ */
+ private double lastBgBlurFactor = -1;
+
+ private void blurBackground() {
+ if (!OpenGlHelper.isFramebufferEnabled()) return;
+
+ int width = Minecraft.getMinecraft().displayWidth;
+ int height = Minecraft.getMinecraft().displayHeight;
+
+ if (blurOutputHorz == null) {
+ blurOutputHorz = new Framebuffer(width, height, false);
+ blurOutputHorz.setFramebufferFilter(GL11.GL_NEAREST);
+ }
+ if (blurOutputVert == null) {
+ blurOutputVert = new Framebuffer(width, height, false);
+ blurOutputVert.setFramebufferFilter(GL11.GL_NEAREST);
+ }
+ if (blurOutputHorz.framebufferWidth != width || blurOutputHorz.framebufferHeight != height) {
+ blurOutputHorz.createBindFramebuffer(width, height);
+ blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height));
+ Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
+ }
+ if (blurOutputVert.framebufferWidth != width || blurOutputVert.framebufferHeight != height) {
+ blurOutputVert.createBindFramebuffer(width, height);
+ blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height));
+ Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
+ }
+
+ if (blurShaderHorz == null) {
+ try {
+ blurShaderHorz = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur",
+ Minecraft.getMinecraft().getFramebuffer(), blurOutputHorz
+ );
+ blurShaderHorz.getShaderManager().getShaderUniform("BlurDir").set(1, 0);
+ blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height));
+ } catch (Exception ignored) {
+ }
+ }
+ if (blurShaderVert == null) {
+ try {
+ blurShaderVert = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur",
+ blurOutputHorz, blurOutputVert
+ );
+ blurShaderVert.getShaderManager().getShaderUniform("BlurDir").set(0, 1);
+ blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height));
+ } catch (Exception ignored) {
+ }
+ }
+ if (blurShaderHorz != null && blurShaderVert != null) {
+ if (15 != lastBgBlurFactor) {
+ blurShaderHorz.getShaderManager().getShaderUniform("Radius").set((float) 15);
+ blurShaderVert.getShaderManager().getShaderUniform("Radius").set((float) 15);
+ lastBgBlurFactor = 15;
+ }
+ GL11.glPushMatrix();
+ blurShaderHorz.loadShader(0);
+ blurShaderVert.loadShader(0);
+ GlStateManager.enableDepth();
+ GL11.glPopMatrix();
+
+ Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
+ }
+ }
+
+ /**
+ * Renders a subsection of the blurred framebuffer on to the corresponding section of the screen.
+ * Essentially, this method will "blur" the background inside the bounds specified by [x->x+blurWidth, y->y+blurHeight]
+ */
+ public void renderBlurredBackground(int width, int height, int x, int y, int blurWidth, int blurHeight) {
+ if (!OpenGlHelper.isFramebufferEnabled()) return;
+
+ float uMin = x / (float) width;
+ float uMax = (x + blurWidth) / (float) width;
+ float vMin = (height - y) / (float) height;
+ float vMax = (height - y - blurHeight) / (float) height;
+
+ blurOutputVert.bindFramebufferTexture();
+ GlStateManager.color(1f, 1f, 1f, 1f);
+ //Utils.setScreen(width*f, height*f, f);
+ Utils.drawTexturedRect(x, y, blurWidth, blurHeight, uMin, uMax, vMin, vMax);
+ //Utils.setScreen(width, height, f);
+ blurOutputVert.unbindFramebufferTexture();
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/Panorama.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/Panorama.java
index 379935ad..ac117bc2 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/Panorama.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/Panorama.java
@@ -16,142 +16,166 @@ import org.lwjgl.opengl.GL11;
import org.lwjgl.util.glu.Project;
public class Panorama {
-
- private static TexLoc tl = new TexLoc(97, 19, Keyboard.KEY_P);
- private static TexLoc tl2 = new TexLoc(37, 80, Keyboard.KEY_L);
-
- private static ResourceLocation backgroundTexture = null;
-
- private static int lastWidth = 0;
- private static int lastHeight = 0;
-
- public static void drawPanorama(float angle, int x, int y, int width, int height, float yOffset, float zOffset, ResourceLocation[] panoramas) {
- if(!OpenGlHelper.isFramebufferEnabled()) {
- Minecraft.getMinecraft().getTextureManager().bindTexture(panoramas[0]);
-
- float aspect = width/(float)height;
- Utils.drawTexturedRect(x, y, width, height, 0.5f-aspect/2, 0.5f+aspect/2, 0, 1);
-
- return;
- }
-
- Minecraft.getMinecraft().getFramebuffer().unbindFramebuffer();
-
- ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
-
- GL11.glViewport(0, 0, width*scaledresolution.getScaleFactor(), height*scaledresolution.getScaleFactor());
-
- float fov = 97;
-
- {
- Tessellator tessellator = Tessellator.getInstance();
- WorldRenderer worldrenderer = tessellator.getWorldRenderer();
- GlStateManager.matrixMode(5889);
- GlStateManager.pushMatrix();
- GlStateManager.loadIdentity();
- Project.gluPerspective(fov, (float)height/width, 0.05F, 10.0F);
- GlStateManager.matrixMode(5888);
- GlStateManager.pushMatrix();
- GlStateManager.loadIdentity();
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
- GlStateManager.rotate(180F, 1.0F, 0.0F, 0.0F);
- GlStateManager.rotate(90, 0.0F, 0.0F, 1.0F);
- GlStateManager.rotate(19, 1.0F, 0.0F, 0.0F);
- //GlStateManager.rotate(tl.x, 0.0F, 0.0F, 1.0F);
- GlStateManager.enableBlend();
- GlStateManager.disableAlpha();
- GlStateManager.disableCull();
- GlStateManager.depthMask(false);
- GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
-
- GlStateManager.pushMatrix();
-
- GlStateManager.translate(0, yOffset, zOffset);
-
- GlStateManager.rotate(angle, 0.0F, 1.0F, 0.0F);
-
- for (int k = 0; k < 6; ++k) {
- GlStateManager.pushMatrix();
-
- switch (k) {
- case 1:
- GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F); break;
- case 2:
- GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F); break;
- case 3:
- GlStateManager.rotate(-90.0F, 0.0F, 1.0F, 0.0F); break;
- case 4:
- GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F); break;
- case 5:
- GlStateManager.rotate(-90.0F, 1.0F, 0.0F, 0.0F); break;
- }
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(panoramas[k]);
- float splits = 0.1f;
- for(float x1=0; x1<1; x1+=splits) {
- for(float y1=0; y1<1; y1+=splits) {
- worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
-
- for(int i=0; i<4; i++) {
- float x2 = (i == 0 || i == 3) ? x1 : x1+splits;
- float y2 = (i >= 2) ? y1 : y1+splits;
-
- float xr = x2*2-1;
- float yr = y2*2-1;
-
- float distSq = xr*xr+yr*yr+1;
- float scale = (float)Math.sqrt(3/distSq);
-
- worldrenderer.pos(xr*scale , yr*scale , scale).tex(x2, y2).color(255, 255, 255, 255).endVertex();
-
- }
-
- tessellator.draw();
- }
- }
-
- GlStateManager.popMatrix();
- }
-
- GlStateManager.popMatrix();
- GlStateManager.colorMask(true, true, true, false);
-
- worldrenderer.setTranslation(0.0D, 0.0D, 0.0D);
- GlStateManager.colorMask(true, true, true, true);
- GlStateManager.matrixMode(5889);
- GlStateManager.popMatrix();
- GlStateManager.matrixMode(5888);
- GlStateManager.popMatrix();
- GlStateManager.depthMask(true);
- GlStateManager.enableCull();
- GlStateManager.enableDepth();
- }
-
- if(backgroundTexture == null || lastWidth != width*scaledresolution.getScaleFactor() || lastHeight != height*scaledresolution.getScaleFactor()) {
- DynamicTexture viewportTexture = new DynamicTexture(width*scaledresolution.getScaleFactor(), height*scaledresolution.getScaleFactor());
- backgroundTexture = Minecraft.getMinecraft().getTextureManager().getDynamicTextureLocation("background", viewportTexture);
- lastWidth = width*scaledresolution.getScaleFactor();
- lastHeight = height*scaledresolution.getScaleFactor();
- }
-
- Minecraft.getMinecraft().getTextureManager().bindTexture(backgroundTexture);
- 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);
- GL11.glCopyTexSubImage2D(GL11.GL_TEXTURE_2D, 0, 0, 0, 0, 0, width*scaledresolution.getScaleFactor(), height*scaledresolution.getScaleFactor());
-
- Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true);
- Tessellator tessellator = Tessellator.getInstance();
- WorldRenderer worldrenderer = tessellator.getWorldRenderer();
- worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
- worldrenderer.pos(x, y+height, 0)
- .tex(0, 1).endVertex();
- worldrenderer.pos(x+width, y+height, 0)
- .tex(0, 0).endVertex();
- worldrenderer.pos(x+width, y, 0)
- .tex(1, 0).endVertex();
- worldrenderer.pos(x, y, 0)
- .tex(1, 1).endVertex();
- tessellator.draw();
- }
-
+ private static final TexLoc tl = new TexLoc(97, 19, Keyboard.KEY_P);
+ private static final TexLoc tl2 = new TexLoc(37, 80, Keyboard.KEY_L);
+
+ private static ResourceLocation backgroundTexture = null;
+
+ private static int lastWidth = 0;
+ private static int lastHeight = 0;
+
+ public static void drawPanorama(
+ float angle,
+ int x,
+ int y,
+ int width,
+ int height,
+ float yOffset,
+ float zOffset,
+ ResourceLocation[] panoramas
+ ) {
+ if (!OpenGlHelper.isFramebufferEnabled()) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(panoramas[0]);
+
+ float aspect = width / (float) height;
+ Utils.drawTexturedRect(x, y, width, height, 0.5f - aspect / 2, 0.5f + aspect / 2, 0, 1);
+
+ return;
+ }
+
+ Minecraft.getMinecraft().getFramebuffer().unbindFramebuffer();
+
+ ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
+
+ GL11.glViewport(0, 0, width * scaledresolution.getScaleFactor(), height * scaledresolution.getScaleFactor());
+
+ float fov = 97;
+
+ {
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+ GlStateManager.matrixMode(5889);
+ GlStateManager.pushMatrix();
+ GlStateManager.loadIdentity();
+ Project.gluPerspective(fov, (float) height / width, 0.05F, 10.0F);
+ GlStateManager.matrixMode(5888);
+ GlStateManager.pushMatrix();
+ GlStateManager.loadIdentity();
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ GlStateManager.rotate(180F, 1.0F, 0.0F, 0.0F);
+ GlStateManager.rotate(90, 0.0F, 0.0F, 1.0F);
+ GlStateManager.rotate(19, 1.0F, 0.0F, 0.0F);
+ //GlStateManager.rotate(tl.x, 0.0F, 0.0F, 1.0F);
+ GlStateManager.enableBlend();
+ GlStateManager.disableAlpha();
+ GlStateManager.disableCull();
+ GlStateManager.depthMask(false);
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+
+ GlStateManager.pushMatrix();
+
+ GlStateManager.translate(0, yOffset, zOffset);
+
+ GlStateManager.rotate(angle, 0.0F, 1.0F, 0.0F);
+
+ for (int k = 0; k < 6; ++k) {
+ GlStateManager.pushMatrix();
+
+ switch (k) {
+ case 1:
+ GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F);
+ break;
+ case 2:
+ GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
+ break;
+ case 3:
+ GlStateManager.rotate(-90.0F, 0.0F, 1.0F, 0.0F);
+ break;
+ case 4:
+ GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F);
+ break;
+ case 5:
+ GlStateManager.rotate(-90.0F, 1.0F, 0.0F, 0.0F);
+ break;
+ }
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(panoramas[k]);
+ float splits = 0.1f;
+ for (float x1 = 0; x1 < 1; x1 += splits) {
+ for (float y1 = 0; y1 < 1; y1 += splits) {
+ worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
+
+ for (int i = 0; i < 4; i++) {
+ float x2 = (i == 0 || i == 3) ? x1 : x1 + splits;
+ float y2 = (i >= 2) ? y1 : y1 + splits;
+
+ float xr = x2 * 2 - 1;
+ float yr = y2 * 2 - 1;
+
+ float distSq = xr * xr + yr * yr + 1;
+ float scale = (float) Math.sqrt(3 / distSq);
+
+ worldrenderer.pos(xr * scale, yr * scale, scale).tex(x2, y2).color(255, 255, 255, 255).endVertex();
+
+ }
+
+ tessellator.draw();
+ }
+ }
+
+ GlStateManager.popMatrix();
+ }
+
+ GlStateManager.popMatrix();
+ GlStateManager.colorMask(true, true, true, false);
+
+ worldrenderer.setTranslation(0.0D, 0.0D, 0.0D);
+ GlStateManager.colorMask(true, true, true, true);
+ GlStateManager.matrixMode(5889);
+ GlStateManager.popMatrix();
+ GlStateManager.matrixMode(5888);
+ GlStateManager.popMatrix();
+ GlStateManager.depthMask(true);
+ GlStateManager.enableCull();
+ GlStateManager.enableDepth();
+ }
+
+ if (backgroundTexture == null || lastWidth != width * scaledresolution.getScaleFactor() ||
+ lastHeight != height * scaledresolution.getScaleFactor()) {
+ DynamicTexture viewportTexture =
+ new DynamicTexture(width * scaledresolution.getScaleFactor(), height * scaledresolution.getScaleFactor());
+ backgroundTexture =
+ Minecraft.getMinecraft().getTextureManager().getDynamicTextureLocation("background", viewportTexture);
+ lastWidth = width * scaledresolution.getScaleFactor();
+ lastHeight = height * scaledresolution.getScaleFactor();
+ }
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(backgroundTexture);
+ 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);
+ GL11.glCopyTexSubImage2D(
+ GL11.GL_TEXTURE_2D,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ width * scaledresolution.getScaleFactor(),
+ height * scaledresolution.getScaleFactor()
+ );
+
+ Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true);
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+ worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
+ worldrenderer.pos(x, y + height, 0)
+ .tex(0, 1).endVertex();
+ worldrenderer.pos(x + width, y + height, 0)
+ .tex(0, 0).endVertex();
+ worldrenderer.pos(x + width, y, 0)
+ .tex(1, 0).endVertex();
+ worldrenderer.pos(x, y, 0)
+ .tex(1, 1).endVertex();
+ tessellator.draw();
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java
index 76427cc8..4a915111 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java
@@ -1,10 +1,15 @@
package io.github.moulberry.notenoughupdates.profileviewer;
-import com.google.gson.*;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.Utils;
-import net.minecraft.nbt.*;
+import net.minecraft.nbt.CompressedStreamTools;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.EnumChatFormatting;
import org.apache.commons.lang3.StringUtils;
@@ -17,609 +22,643 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class PlayerStats {
- public static final String HEALTH = "health";
- public static final String DEFENCE = "defence";
- public static final String STRENGTH = "strength";
- public static final String SPEED = "speed";
- public static final String CRIT_CHANCE = "crit_chance";
- public static final String CRIT_DAMAGE = "crit_damage";
- public static final String BONUS_ATTACK_SPEED = "bonus_attack_speed";
- public static final String INTELLIGENCE = "intelligence";
- public static final String SEA_CREATURE_CHANCE = "sea_creature_chance";
- public static final String MAGIC_FIND = "magic_find";
- public static final String PET_LUCK = "pet_luck";
-
- public static final String[] defaultStatNames = new String[]{"health","defence","strength","speed","crit_chance",
- "crit_damage","bonus_attack_speed","intelligence","sea_creature_chance","magic_find","pet_luck","ferocity","ability_damage","mining_fortune", "mining_speed"};
- public static final String[] defaultStatNamesPretty = new String[]{EnumChatFormatting.RED+"\u2764 Health",EnumChatFormatting.GREEN+"\u2748 Defence",
- EnumChatFormatting.RED+"\u2741 Strength",EnumChatFormatting.WHITE+"\u2726 Speed",EnumChatFormatting.BLUE+"\u2623 Crit Chance",
- EnumChatFormatting.BLUE+"\u2620 Crit Damage",EnumChatFormatting.YELLOW+"\u2694 Attack Speed",EnumChatFormatting.AQUA+"\u270e Intelligence",
- EnumChatFormatting.DARK_AQUA+"\u03b1 SC Chance",EnumChatFormatting.AQUA+"\u272f Magic Find",EnumChatFormatting.LIGHT_PURPLE+"\u2663 Pet Luck",
- EnumChatFormatting.RED+"\u2AFD Ferocity",EnumChatFormatting.RED+"\u2739 Ability Damage", EnumChatFormatting.GOLD+"\u2618 Mining Fortune" ,EnumChatFormatting.GOLD+"\u2E15 Mining Speed"};
-
- public static class Stats {
- JsonObject statsJson = new JsonObject();
-
- /*public float health;
- public float defence;
- public float strength;
- public float speed;
- public float crit_chance;
- public float crit_damage;
- public float bonus_attack_speed;
- public float intelligence;
- public float sea_creature_chance;
- public float magic_find;
- public float pet_luck;*/
-
- public Stats(Stats... statses) {
- for(Stats stats : statses) {
- add(stats);
- }
- }
-
- /*@Override
- public String toString() {
- return String.format("{health=%s,defence=%s,strength=%s,speed=%s,crit_chance=%s,crit_damage=%s," +
- "bonus_attack_speed=%s,intelligence=%s,sea_creature_chance=%s,magic_find=%s,pet_luck=%s}",
- stats.get("health"), defence, strength, speed, crit_chance, crit_damage, bonus_attack_speed, intelligence,
- sea_creature_chance, magic_find, pet_luck);
- }*/
-
- public float get(String statName) {
- if(statsJson.has(statName)) {
- return statsJson.get(statName).getAsFloat();
- } else {
- return 0;
- }
- }
-
- public Stats add(Stats stats) {
- for(Map.Entry<String, JsonElement> statEntry : stats.statsJson.entrySet()) {
- if(statEntry.getValue().isJsonPrimitive() && ((JsonPrimitive)statEntry.getValue()).isNumber()) {
- if(!statsJson.has(statEntry.getKey())) {
- statsJson.add(statEntry.getKey(), statEntry.getValue());
- } else {
- JsonPrimitive e = statsJson.get(statEntry.getKey()).getAsJsonPrimitive();
- float statNum = e.getAsFloat() + statEntry.getValue().getAsFloat();
- statsJson.add(statEntry.getKey(), new JsonPrimitive(statNum));
- }
- }
- }
- return this;
- }
-
- public void scale(String statName, float scale) {
- if(statsJson.has(statName)) {
- statsJson.add(statName, new JsonPrimitive(statsJson.get(statName).getAsFloat()*scale));
- }
- }
-
- public void scaleAll(float scale) {
- for(Map.Entry<String, JsonElement> statEntry : statsJson.entrySet()) {
- statsJson.add(statEntry.getKey(), new JsonPrimitive(statEntry.getValue().getAsFloat()*scale));
- }
- }
-
- public void addStat(String statName, float amount) {
- if(!statsJson.has(statName)) {
- statsJson.add(statName, new JsonPrimitive(amount));
- } else {
- JsonPrimitive e = statsJson.get(statName).getAsJsonPrimitive();
- statsJson.add(statName, new JsonPrimitive(e.getAsFloat() + amount));
- }
- }
- }
-
- public static Stats getBaseStats() {
- JsonObject misc = Constants.MISC;
- if(misc == null) return null;
-
- Stats stats = new Stats();
- for(String statName : defaultStatNames) {
- stats.addStat(statName, Utils.getElementAsFloat(Utils.getElement(misc, "base_stats."+statName), 0));
- }
- return stats;
- }
-
- private static Stats getFairyBonus(int fairyExchanges) {
- Stats bonus = new Stats();
-
- bonus.addStat(SPEED, fairyExchanges/10);
-
- for(int i=0; i<fairyExchanges; i++) {
- bonus.addStat(STRENGTH, (i + 1) % 5 == 0 ? 2 : 1);
- bonus.addStat(DEFENCE, (i + 1) % 5 == 0 ? 2 : 1);
- bonus.addStat(HEALTH, 3 + i / 2);
- }
-
- return bonus;
- }
-
- private static Stats getSkillBonus(JsonObject skillInfo) {
- JsonObject bonuses = Constants.BONUSES;
- if(bonuses == null) return null;
-
- Stats skillBonus = new Stats();
-
- for(Map.Entry<String, JsonElement> entry : skillInfo.entrySet()) {
- if(entry.getKey().startsWith("level_")) {
- String skill = entry.getKey().substring("level_".length());
- JsonElement element = Utils.getElement(bonuses, "bonus_stats."+skill);
- if(element != null && element.isJsonObject()) {
- JsonObject skillStatMap = element.getAsJsonObject();
-
- Stats currentBonus = new Stats();
- for(int i=1; i<=entry.getValue().getAsFloat(); i++) {
- if(skillStatMap.has(""+i)) {
- currentBonus = new Stats();
- for(Map.Entry<String, JsonElement> entry2 : skillStatMap.get(""+i).getAsJsonObject().entrySet()) {
- currentBonus.addStat(entry2.getKey(), entry2.getValue().getAsFloat());
- }
- }
- skillBonus.add(currentBonus);
- }
- }
- }
- }
-
- return skillBonus;
- }
-
- private static Stats getTamingBonus(JsonObject profile) {
- JsonObject bonuses = Constants.BONUSES;
- if(bonuses == null) return null;
-
- JsonElement petsElement = Utils.getElement(profile, "pets");
- if(petsElement == null) return new Stats();
-
- JsonArray pets = petsElement.getAsJsonArray();
-
- HashMap<String, String> highestRarityMap = new HashMap<>();
-
- for(int i=0; i<pets.size(); i++) {
- JsonObject pet = pets.get(i).getAsJsonObject();
- highestRarityMap.put(pet.get("type").getAsString(), pet.get("tier").getAsString());
- }
-
- int petScore = 0;
- for(String value : highestRarityMap.values()) {
- petScore += Utils.getElementAsFloat(Utils.getElement(bonuses, "pet_value."+value.toUpperCase()), 0);
- }
-
- JsonElement petRewardsElement = Utils.getElement(bonuses, "pet_rewards");
- if(petRewardsElement == null) return null;
- JsonObject petRewards = petRewardsElement.getAsJsonObject();
-
- Stats petBonus = new Stats();
- for(int i=0; i<=petScore; i++) {
- if(petRewards.has(""+i)) {
- petBonus = new Stats();
- for(Map.Entry<String, JsonElement> entry : petRewards.get(""+i).getAsJsonObject().entrySet()) {
- petBonus.addStat(entry.getKey(), entry.getValue().getAsFloat());
- }
- }
- }
- return petBonus;
- }
-
- private static float harpBonus(JsonObject profile) {
- String talk_to_melody = Utils.getElementAsString(Utils.getElement(profile, "objectives.talk_to_melody.status"), "INCOMPLETE");
- if(talk_to_melody.equalsIgnoreCase("COMPLETE")) {
- return 26;
- } else {
- return 0;
- }
- }
-
-
- public static Stats getPassiveBonuses(JsonObject skillInfo, JsonObject profile) {
- Stats passiveBonuses = new Stats();
-
- Stats fairyBonus = getFairyBonus((int)Utils.getElementAsFloat(Utils.getElement(profile, "fairy_exchanges"), 0));
- Stats skillBonus = getSkillBonus(skillInfo);
- Stats petBonus = getTamingBonus(profile);
-
- if(skillBonus == null || petBonus == null) {
- return null;
- }
-
- passiveBonuses.add(fairyBonus);
- passiveBonuses.add(skillBonus);
- passiveBonuses.addStat(INTELLIGENCE, harpBonus(profile));
- passiveBonuses.add(petBonus);
-
- return passiveBonuses;
- }
-
- private static String getFullset(JsonArray armor, int ignore) {
- String fullset = null;
- for(int i=0; i<armor.size(); i++) {
- if(i == ignore) continue;
-
- JsonElement itemElement = armor.get(i);
- if(itemElement == null || !itemElement.isJsonObject()) {
- fullset = null;
- break;
- }
- JsonObject item = itemElement.getAsJsonObject();
- String internalname = item.get("internalname").getAsString();
-
- String[] split = internalname.split("_");
- split[split.length-1] = "";
- String armorname = StringUtils.join(split, "_");
-
- if(fullset == null) {
- fullset = armorname;
- } else if(!fullset.equalsIgnoreCase(armorname)){
- fullset = null;
- break;
- }
- }
- return fullset;
- }
-
- private static Stats getSetBonuses(Stats stats, JsonObject inventoryInfo, JsonObject collectionInfo, JsonObject skillInfo, JsonObject profile) {
- JsonArray armor = Utils.getElement(inventoryInfo, "inv_armor").getAsJsonArray();
-
- Stats bonuses = new Stats();
-
- String fullset = getFullset(armor, -1);
-
- if(fullset != null) {
- switch(fullset) {
- case "LAPIS_ARMOR_":
- bonuses.addStat(HEALTH, 60);
- break;
- case "EMERALD_ARMOR_":
- {
- int bonus = (int)Math.floor(Utils.getElementAsFloat(Utils.getElement(collectionInfo, "EMERALD"), 0)/3000);
- bonuses.addStat(HEALTH, bonus);
- bonuses.addStat(DEFENCE, bonus);
- }
- break;
- case "FAIRY_":
- bonuses.addStat(HEALTH, Utils.getElementAsFloat(Utils.getElement(profile, "fairy_souls_collected"), 0));
- break;
- case "SPEEDSTER_":
- bonuses.addStat(SPEED, 20);
- break;
- case "YOUNG_DRAGON_":
- bonuses.addStat(SPEED, 70);
- break;
- case "MASTIFF_":
- bonuses.addStat(HEALTH, 50*Math.round(stats.get(CRIT_DAMAGE)));
- break;
- case "ANGLER_":
- bonuses.addStat(HEALTH, 10*(float)Math.floor(Utils.getElementAsFloat(Utils.getElement(skillInfo, "level_skill_fishing"), 0)));
- bonuses.addStat(SEA_CREATURE_CHANCE, 4);
- break;
- case "ARMOR_OF_MAGMA_":
- int bonus = (int)Math.min(200, Math.floor(Utils.getElementAsFloat(Utils.getElement(profile, "stats.kills_magma_cube"), 0)/10));
- bonuses.addStat(HEALTH, bonus);
- bonuses.addStat(INTELLIGENCE, bonus);
- case "OLD_DRAGON_":
- bonuses.addStat(HEALTH, 200);
- bonuses.addStat(DEFENCE, 40);
- break;
- }
- }
-
- JsonElement chestplateElement = armor.get(2);
- if(chestplateElement != null && chestplateElement.isJsonObject()) {
- JsonObject chestplate = chestplateElement.getAsJsonObject();
- if(chestplate.get("internalname").getAsString().equals("OBSIDIAN_CHESTPLATE")) {
- JsonArray inventory = Utils.getElement(inventoryInfo, "inv_contents").getAsJsonArray();
- for(int i=0; i<inventory.size(); i++) {
- JsonElement itemElement = inventory.get(i);
- if(itemElement != null && itemElement.isJsonObject()) {
- JsonObject item = itemElement.getAsJsonObject();
- if(item.get("internalname").getAsString().equals("OBSIDIAN")) {
- int count = 1;
- if(item.has("count")) {
- count = item.get("count").getAsInt();
- }
- bonuses.addStat(SPEED, count/20);
- }
- }
- }
- }
- }
-
- return bonuses;
- }
-
- private static final Pattern HEALTH_PATTERN = Pattern.compile("^Health: ((?:\\+|-)[0-9]+)");
- private static final Pattern DEFENCE_PATTERN = Pattern.compile("^Defense: ((?:\\+|-)[0-9]+)");
- private static final Pattern STRENGTH_PATTERN = Pattern.compile("^Strength: ((?:\\+|-)[0-9]+)");
- private static final Pattern SPEED_PATTERN = Pattern.compile("^Speed: ((?:\\+|-)[0-9]+)");
- private static final Pattern CC_PATTERN = Pattern.compile("^Crit Chance: ((?:\\+|-)[0-9]+)");
- private static final Pattern CD_PATTERN = Pattern.compile("^Crit Damage: ((?:\\+|-)[0-9]+)");
- private static final Pattern ATKSPEED_PATTERN = Pattern.compile("^Bonus Attack Speed: ((?:\\+|-)[0-9]+)");
- private static final Pattern INTELLIGENCE_PATTERN = Pattern.compile("^Intelligence: ((?:\\+|-)[0-9]+)");
- private static final Pattern SCC_PATTERN = Pattern.compile("^Sea Creature Chance: ((?:\\+|-)[0-9]+)");
- private static final Pattern FEROCITY_PATTERN = Pattern.compile("^Ferocity: ((?:\\+|-)[0-9]+)");
- private static final Pattern AD_PATTERN = Pattern.compile("^Ability Damage: ((?:\\+|-)[0-9]+)");
- private static final HashMap<String, Pattern> STAT_PATTERN_MAP = new HashMap<>();
- static {
- STAT_PATTERN_MAP.put("health", HEALTH_PATTERN);
- STAT_PATTERN_MAP.put("defence", DEFENCE_PATTERN);
- STAT_PATTERN_MAP.put("strength", STRENGTH_PATTERN);
- STAT_PATTERN_MAP.put("speed", SPEED_PATTERN);
- STAT_PATTERN_MAP.put("crit_chance", CC_PATTERN);
- STAT_PATTERN_MAP.put("crit_damage", CD_PATTERN);
- STAT_PATTERN_MAP.put("bonus_attack_speed", ATKSPEED_PATTERN);
- STAT_PATTERN_MAP.put("intelligence", INTELLIGENCE_PATTERN);
- STAT_PATTERN_MAP.put("sea_creature_chance", SCC_PATTERN);
- STAT_PATTERN_MAP.put("ferocity", FEROCITY_PATTERN);
- STAT_PATTERN_MAP.put("ability_damage", AD_PATTERN);
- }
- private static Stats getStatForItem(String internalname, JsonObject item, JsonArray lore) {
- Stats stats = new Stats();
- for(int i=0; i<lore.size(); i++) {
- String line = lore.get(i).getAsString();
- for(Map.Entry<String, Pattern> entry : STAT_PATTERN_MAP.entrySet()) {
- Matcher matcher = entry.getValue().matcher(Utils.cleanColour(line));
- if(matcher.find()) {
- int bonus = Integer.parseInt(matcher.group(1));
- stats.addStat(entry.getKey(), bonus);
- }
- }
- }
- if(internalname.equals("DAY_CRYSTAL") || internalname.equals("NIGHT_CRYSTAL")) {
- stats.addStat(STRENGTH, 2.5f);
- stats.addStat(DEFENCE, 2.5f);
- }
- if(internalname.equals("NEW_YEAR_CAKE_BAG") && item.has("item_contents")) {
- JsonArray bytesArr = item.get("item_contents").getAsJsonArray();
- byte[] bytes = new byte[bytesArr.size()];
- for(int i=0; i<bytesArr.size(); i++) {
- bytes[i] = bytesArr.get(i).getAsByte();
- }
- try {
- NBTTagCompound contents_nbt = CompressedStreamTools.readCompressed(new ByteArrayInputStream(bytes));
- NBTTagList items = contents_nbt.getTagList("i", 10);
- HashSet<Integer> cakes = new HashSet<>();
- for(int j=0; j<items.tagCount(); j++) {
- if(items.getCompoundTagAt(j).getKeySet().size() > 0) {
- NBTTagCompound nbt = items.getCompoundTagAt(j).getCompoundTag("tag");
- if(nbt != null && nbt.hasKey("ExtraAttributes", 10)) {
- NBTTagCompound ea = nbt.getCompoundTag("ExtraAttributes");
- if (ea.hasKey("new_years_cake")) {
- cakes.add(ea.getInteger("new_years_cake"));
- }
- }
- }
- }
- stats.addStat(HEALTH, cakes.size());
- } catch(IOException e) {
- e.printStackTrace();
- return stats;
- }
- }
- return stats;
- }
- private static Stats getItemBonuses(boolean talismanOnly, JsonArray... inventories) {
- JsonObject misc = Constants.MISC;
- if(misc == null) return null;
- JsonElement talisman_upgrades_element = misc.get("talisman_upgrades");
- if(talisman_upgrades_element == null) return null;
- JsonObject talisman_upgrades = talisman_upgrades_element.getAsJsonObject();
-
- HashMap<String, Stats> itemBonuses = new HashMap<>();
- for(JsonArray inventory : inventories) {
- for(int i=0; i<inventory.size(); i++) {
- JsonElement itemElement = inventory.get(i);
- if(itemElement != null && itemElement.isJsonObject()) {
- JsonObject item = itemElement.getAsJsonObject();
- String internalname = item.get("internalname").getAsString();
- if(itemBonuses.containsKey(internalname)) {
- continue;
- }
- if(!talismanOnly || Utils.checkItemType(item.get("lore").getAsJsonArray(), true, "ACCESSORY", "HATCCESSORY") >= 0) {
- Stats itemBonus = getStatForItem(internalname, item, item.get("lore").getAsJsonArray());
-
- itemBonuses.put(internalname, itemBonus);
-
- for(Map.Entry<String, JsonElement> talisman_upgrades_item : talisman_upgrades.entrySet()) {
- JsonArray upgrades = talisman_upgrades_item.getValue().getAsJsonArray();
- for(int j=0; j<upgrades.size(); j++) {
- String upgrade = upgrades.get(j).getAsString();
- if(upgrade.equals(internalname)) {
- itemBonuses.put(talisman_upgrades_item.getKey(), new Stats());
- break;
- }
- }
- }
- }
- }
- }
- }
- Stats itemBonusesStats = new Stats();
- for(Stats stats : itemBonuses.values()) {
- itemBonusesStats.add(stats);
- }
-
- return itemBonusesStats;
- }
-
- public static Stats getPetStatBonuses(JsonObject petsInfo) {
- JsonObject petsJson = Constants.PETS;
- JsonObject petnums = Constants.PETNUMS;
- if(petsJson == null || petnums == null) return new Stats();
-
- if(petsInfo != null && petsInfo.has("active_pet") && petsInfo.get("active_pet") != null &&
- petsInfo.get("active_pet").isJsonObject()) {
- JsonObject pet = petsInfo.get("active_pet").getAsJsonObject();
- if(pet.has("type") && pet.get("type") != null &&
- pet.has("tier") && pet.get("tier") != null &&
- pet.has("exp") && pet.get("exp") != null) {
-
- String petname = pet.get("type").getAsString();
- String tier = pet.get("tier").getAsString();
- String heldItem = Utils.getElementAsString(pet.get("heldItem"), null);
-
- if(!petnums.has(petname)) {
- return new Stats();
- }
-
- String tierNum = GuiProfileViewer.MINION_RARITY_TO_NUM.get(tier);
- float exp = pet.get("exp").getAsFloat();
- if(tierNum == null) return new Stats();
-
- if(pet.has("heldItem") && !pet.get("heldItem").isJsonNull() && pet.get("heldItem").getAsString().equals("PET_ITEM_TIER_BOOST")) {
- tierNum = ""+(Integer.parseInt(tierNum)+1);
- }
-
- GuiProfileViewer.PetLevel levelObj = GuiProfileViewer.getPetLevel(petname, tier, exp);
-
- float level = levelObj.level;
- float currentLevelRequirement = levelObj.currentLevelRequirement;
- float maxXP = levelObj.maxXP;
- pet.addProperty("level", level);
- pet.addProperty("currentLevelRequirement", currentLevelRequirement);
- pet.addProperty("maxXP", maxXP);
-
- JsonObject petItem = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(petname+";"+tierNum);
- if(petItem == null) return new Stats();
-
- Stats stats = new Stats();
-
- JsonObject petInfo = petnums.get(petname).getAsJsonObject();
- if(petInfo.has(tier)) {
- JsonObject petInfoTier = petInfo.get(tier).getAsJsonObject();
- if(petInfoTier == null || !petInfoTier.has("1") || !petInfoTier.has("100")) {
- return new Stats();
- }
-
- JsonObject min = petInfoTier.get("1").getAsJsonObject();
- JsonObject max = petInfoTier.get("100").getAsJsonObject();
-
- float minMix = (100-level)/99f;
- float maxMix = (level-1)/99f;
-
- for(Map.Entry<String, JsonElement> entry : max.get("statNums").getAsJsonObject().entrySet()) {
- float statMax = entry.getValue().getAsFloat();
- float statMin = min.get("statNums").getAsJsonObject().get(entry.getKey()).getAsFloat();
- float val = statMin*minMix + statMax*maxMix;
-
- stats.addStat(entry.getKey().toLowerCase(), (int)Math.floor(val));
- }
- }
-
- if(heldItem != null) {
- HashMap<String, Float> petStatBoots = GuiProfileViewer.PET_STAT_BOOSTS.get(heldItem);
- HashMap<String, Float> petStatBootsMult = GuiProfileViewer.PET_STAT_BOOSTS_MULT.get(heldItem);
- if(petStatBoots != null) {
- for(Map.Entry<String, Float> entryBoost : petStatBoots.entrySet()) {
- String key = entryBoost.getKey().toLowerCase();
- try {
- stats.addStat(key, entryBoost.getValue());
- } catch(Exception ignored) {}
- }
-
- }
- if(petStatBootsMult != null) {
- for(Map.Entry<String, Float> entryBoost : petStatBootsMult.entrySet()) {
- String key = entryBoost.getKey().toLowerCase();
- try {
- stats.scale(key, entryBoost.getValue());
- } catch(Exception ignored) {}
- }
- }
- }
-
- return stats;
- }
- }
- return new Stats();
- }
-
- private static float getStatMult(JsonObject inventoryInfo) {
- float mult = 1f;
-
- JsonArray armor = Utils.getElement(inventoryInfo, "inv_armor").getAsJsonArray();
-
- String fullset = getFullset(armor, -1);
-
- if(fullset != null && fullset.equals("SUPERIOR_DRAGON_")) {
- mult *= 1.05f;
- }
-
- for(int i=0; i<armor.size(); i++) {
- JsonElement itemElement = armor.get(i);
- if(itemElement == null || !itemElement.isJsonObject()) continue;
-
- JsonObject item = itemElement.getAsJsonObject();
- String internalname = item.get("internalname").getAsString();
-
- String reforge = Utils.getElementAsString(Utils.getElement(item, "ExtraAttributes.modifier"), "");
-
- if(reforge.equals("renowned")) {
- mult *= 1.01f;
- }
- }
-
- return mult;
- }
-
- private static void applyLimits(Stats stats, JsonObject inventoryInfo) {
- //>0
- JsonArray armor = Utils.getElement(inventoryInfo, "inv_armor").getAsJsonArray();
-
- String fullset = getFullset(armor, 3);
-
- if(fullset != null) {
- switch(fullset) {
- case "CHEAP_TUXEDO_":
- stats.statsJson.add(HEALTH, new JsonPrimitive(Math.min(75, stats.get(HEALTH))));
- case "FANCY_TUXEDO_":
- stats.statsJson.add(HEALTH, new JsonPrimitive(Math.min(150, stats.get(HEALTH))));
- case "ELEGANT_TUXEDO_":
- stats.statsJson.add(HEALTH, new JsonPrimitive(Math.min(250, stats.get(HEALTH))));
- }
- }
+ public static final String HEALTH = "health";
+ public static final String DEFENCE = "defence";
+ public static final String STRENGTH = "strength";
+ public static final String SPEED = "speed";
+ public static final String CRIT_CHANCE = "crit_chance";
+ public static final String CRIT_DAMAGE = "crit_damage";
+ public static final String BONUS_ATTACK_SPEED = "bonus_attack_speed";
+ public static final String INTELLIGENCE = "intelligence";
+ public static final String SEA_CREATURE_CHANCE = "sea_creature_chance";
+ public static final String MAGIC_FIND = "magic_find";
+ public static final String PET_LUCK = "pet_luck";
+
+ public static final String[] defaultStatNames = new String[]{
+ "health",
+ "defence",
+ "strength",
+ "speed",
+ "crit_chance",
+ "crit_damage",
+ "bonus_attack_speed",
+ "intelligence",
+ "sea_creature_chance",
+ "magic_find",
+ "pet_luck",
+ "ferocity",
+ "ability_damage",
+ "mining_fortune",
+ "mining_speed"
+ };
+ public static final String[] defaultStatNamesPretty = new String[]{
+ EnumChatFormatting.RED + "\u2764 Health",
+ EnumChatFormatting.GREEN + "\u2748 Defence",
+ EnumChatFormatting.RED + "\u2741 Strength",
+ EnumChatFormatting.WHITE + "\u2726 Speed",
+ EnumChatFormatting.BLUE + "\u2623 Crit Chance",
+ EnumChatFormatting.BLUE + "\u2620 Crit Damage",
+ EnumChatFormatting.YELLOW + "\u2694 Attack Speed",
+ EnumChatFormatting.AQUA + "\u270e Intelligence",
+ EnumChatFormatting.DARK_AQUA + "\u03b1 SC Chance",
+ EnumChatFormatting.AQUA + "\u272f Magic Find",
+ EnumChatFormatting.LIGHT_PURPLE + "\u2663 Pet Luck",
+ EnumChatFormatting.RED + "\u2AFD Ferocity",
+ EnumChatFormatting.RED + "\u2739 Ability Damage",
+ EnumChatFormatting.GOLD + "\u2618 Mining Fortune",
+ EnumChatFormatting.GOLD + "\u2E15 Mining Speed"
+ };
+
+ public static class Stats {
+ JsonObject statsJson = new JsonObject();
+
+ /*public float health;
+ public float defence;
+ public float strength;
+ public float speed;
+ public float crit_chance;
+ public float crit_damage;
+ public float bonus_attack_speed;
+ public float intelligence;
+ public float sea_creature_chance;
+ public float magic_find;
+ public float pet_luck;*/
+
+ public Stats(Stats... statses) {
+ for (Stats stats : statses) {
+ add(stats);
+ }
+ }
+
+ /*@Override
+ public String toString() {
+ return String.format("{health=%s,defence=%s,strength=%s,speed=%s,crit_chance=%s,crit_damage=%s," +
+ "bonus_attack_speed=%s,intelligence=%s,sea_creature_chance=%s,magic_find=%s,pet_luck=%s}",
+ stats.get("health"), defence, strength, speed, crit_chance, crit_damage, bonus_attack_speed, intelligence,
+ sea_creature_chance, magic_find, pet_luck
+ );
+ }*/
+
+ public float get(String statName) {
+ if (statsJson.has(statName)) {
+ return statsJson.get(statName).getAsFloat();
+ } else {
+ return 0;
+ }
+ }
+
+ public Stats add(Stats stats) {
+ for (Map.Entry<String, JsonElement> statEntry : stats.statsJson.entrySet()) {
+ if (statEntry.getValue().isJsonPrimitive() && ((JsonPrimitive) statEntry.getValue()).isNumber()) {
+ if (!statsJson.has(statEntry.getKey())) {
+ statsJson.add(statEntry.getKey(), statEntry.getValue());
+ } else {
+ JsonPrimitive e = statsJson.get(statEntry.getKey()).getAsJsonPrimitive();
+ float statNum = e.getAsFloat() + statEntry.getValue().getAsFloat();
+ statsJson.add(statEntry.getKey(), new JsonPrimitive(statNum));
+ }
+ }
+ }
+ return this;
+ }
+
+ public void scale(String statName, float scale) {
+ if (statsJson.has(statName)) {
+ statsJson.add(statName, new JsonPrimitive(statsJson.get(statName).getAsFloat() * scale));
+ }
+ }
+
+ public void scaleAll(float scale) {
+ for (Map.Entry<String, JsonElement> statEntry : statsJson.entrySet()) {
+ statsJson.add(statEntry.getKey(), new JsonPrimitive(statEntry.getValue().getAsFloat() * scale));
+ }
+ }
+
+ public void addStat(String statName, float amount) {
+ if (!statsJson.has(statName)) {
+ statsJson.add(statName, new JsonPrimitive(amount));
+ } else {
+ JsonPrimitive e = statsJson.get(statName).getAsJsonPrimitive();
+ statsJson.add(statName, new JsonPrimitive(e.getAsFloat() + amount));
+ }
+ }
+ }
+
+ public static Stats getBaseStats() {
+ JsonObject misc = Constants.MISC;
+ if (misc == null) return null;
+
+ Stats stats = new Stats();
+ for (String statName : defaultStatNames) {
+ stats.addStat(statName, Utils.getElementAsFloat(Utils.getElement(misc, "base_stats." + statName), 0));
+ }
+ return stats;
+ }
+
+ private static Stats getFairyBonus(int fairyExchanges) {
+ Stats bonus = new Stats();
+
+ bonus.addStat(SPEED, fairyExchanges / 10);
+
+ for (int i = 0; i < fairyExchanges; i++) {
+ bonus.addStat(STRENGTH, (i + 1) % 5 == 0 ? 2 : 1);
+ bonus.addStat(DEFENCE, (i + 1) % 5 == 0 ? 2 : 1);
+ bonus.addStat(HEALTH, 3 + i / 2);
+ }
+
+ return bonus;
+ }
+
+ private static Stats getSkillBonus(JsonObject skillInfo) {
+ JsonObject bonuses = Constants.BONUSES;
+ if (bonuses == null) return null;
+
+ Stats skillBonus = new Stats();
+
+ for (Map.Entry<String, JsonElement> entry : skillInfo.entrySet()) {
+ if (entry.getKey().startsWith("level_")) {
+ String skill = entry.getKey().substring("level_".length());
+ JsonElement element = Utils.getElement(bonuses, "bonus_stats." + skill);
+ if (element != null && element.isJsonObject()) {
+ JsonObject skillStatMap = element.getAsJsonObject();
+
+ Stats currentBonus = new Stats();
+ for (int i = 1; i <= entry.getValue().getAsFloat(); i++) {
+ if (skillStatMap.has("" + i)) {
+ currentBonus = new Stats();
+ for (Map.Entry<String, JsonElement> entry2 : skillStatMap.get("" + i).getAsJsonObject().entrySet()) {
+ currentBonus.addStat(entry2.getKey(), entry2.getValue().getAsFloat());
+ }
+ }
+ skillBonus.add(currentBonus);
+ }
+ }
+ }
+ }
+
+ return skillBonus;
+ }
+
+ private static Stats getTamingBonus(JsonObject profile) {
+ JsonObject bonuses = Constants.BONUSES;
+ if (bonuses == null) return null;
+
+ JsonElement petsElement = Utils.getElement(profile, "pets");
+ if (petsElement == null) return new Stats();
+
+ JsonArray pets = petsElement.getAsJsonArray();
+
+ HashMap<String, String> highestRarityMap = new HashMap<>();
+
+ for (int i = 0; i < pets.size(); i++) {
+ JsonObject pet = pets.get(i).getAsJsonObject();
+ highestRarityMap.put(pet.get("type").getAsString(), pet.get("tier").getAsString());
+ }
+
+ int petScore = 0;
+ for (String value : highestRarityMap.values()) {
+ petScore += Utils.getElementAsFloat(Utils.getElement(bonuses, "pet_value." + value.toUpperCase()), 0);
+ }
+
+ JsonElement petRewardsElement = Utils.getElement(bonuses, "pet_rewards");
+ if (petRewardsElement == null) return null;
+ JsonObject petRewards = petRewardsElement.getAsJsonObject();
+
+ Stats petBonus = new Stats();
+ for (int i = 0; i <= petScore; i++) {
+ if (petRewards.has("" + i)) {
+ petBonus = new Stats();
+ for (Map.Entry<String, JsonElement> entry : petRewards.get("" + i).getAsJsonObject().entrySet()) {
+ petBonus.addStat(entry.getKey(), entry.getValue().getAsFloat());
+ }
+ }
+ }
+ return petBonus;
+ }
+
+ private static float harpBonus(JsonObject profile) {
+ String talk_to_melody =
+ Utils.getElementAsString(Utils.getElement(profile, "objectives.talk_to_melody.status"), "INCOMPLETE");
+ if (talk_to_melody.equalsIgnoreCase("COMPLETE")) {
+ return 26;
+ } else {
+ return 0;
+ }
+ }
+
+ public static Stats getPassiveBonuses(JsonObject skillInfo, JsonObject profile) {
+ Stats passiveBonuses = new Stats();
+
+ Stats fairyBonus = getFairyBonus((int) Utils.getElementAsFloat(Utils.getElement(profile, "fairy_exchanges"), 0));
+ Stats skillBonus = getSkillBonus(skillInfo);
+ Stats petBonus = getTamingBonus(profile);
+
+ if (skillBonus == null || petBonus == null) {
+ return null;
+ }
+
+ passiveBonuses.add(fairyBonus);
+ passiveBonuses.add(skillBonus);
+ passiveBonuses.addStat(INTELLIGENCE, harpBonus(profile));
+ passiveBonuses.add(petBonus);
+
+ return passiveBonuses;
+ }
+
+ private static String getFullset(JsonArray armor, int ignore) {
+ String fullset = null;
+ for (int i = 0; i < armor.size(); i++) {
+ if (i == ignore) continue;
+
+ JsonElement itemElement = armor.get(i);
+ if (itemElement == null || !itemElement.isJsonObject()) {
+ fullset = null;
+ break;
+ }
+ JsonObject item = itemElement.getAsJsonObject();
+ String internalname = item.get("internalname").getAsString();
+
+ String[] split = internalname.split("_");
+ split[split.length - 1] = "";
+ String armorname = StringUtils.join(split, "_");
+
+ if (fullset == null) {
+ fullset = armorname;
+ } else if (!fullset.equalsIgnoreCase(armorname)) {
+ fullset = null;
+ break;
+ }
+ }
+ return fullset;
+ }
+
+ private static Stats getSetBonuses(
+ Stats stats,
+ JsonObject inventoryInfo,
+ JsonObject collectionInfo,
+ JsonObject skillInfo,
+ JsonObject profile
+ ) {
+ JsonArray armor = Utils.getElement(inventoryInfo, "inv_armor").getAsJsonArray();
+
+ Stats bonuses = new Stats();
+
+ String fullset = getFullset(armor, -1);
+
+ if (fullset != null) {
+ switch (fullset) {
+ case "LAPIS_ARMOR_":
+ bonuses.addStat(HEALTH, 60);
+ break;
+ case "EMERALD_ARMOR_": {
+ int bonus = (int) Math.floor(Utils.getElementAsFloat(Utils.getElement(collectionInfo, "EMERALD"), 0) / 3000);
+ bonuses.addStat(HEALTH, bonus);
+ bonuses.addStat(DEFENCE, bonus);
+ }
+ break;
+ case "FAIRY_":
+ bonuses.addStat(HEALTH, Utils.getElementAsFloat(Utils.getElement(profile, "fairy_souls_collected"), 0));
+ break;
+ case "SPEEDSTER_":
+ bonuses.addStat(SPEED, 20);
+ break;
+ case "YOUNG_DRAGON_":
+ bonuses.addStat(SPEED, 70);
+ break;
+ case "MASTIFF_":
+ bonuses.addStat(HEALTH, 50 * Math.round(stats.get(CRIT_DAMAGE)));
+ break;
+ case "ANGLER_":
+ bonuses.addStat(
+ HEALTH,
+ 10 * (float) Math.floor(Utils.getElementAsFloat(Utils.getElement(skillInfo, "level_skill_fishing"), 0))
+ );
+ bonuses.addStat(SEA_CREATURE_CHANCE, 4);
+ break;
+ case "ARMOR_OF_MAGMA_":
+ int bonus = (int) Math.min(
+ 200,
+ Math.floor(Utils.getElementAsFloat(Utils.getElement(profile, "stats.kills_magma_cube"), 0) / 10)
+ );
+ bonuses.addStat(HEALTH, bonus);
+ bonuses.addStat(INTELLIGENCE, bonus);
+ case "OLD_DRAGON_":
+ bonuses.addStat(HEALTH, 200);
+ bonuses.addStat(DEFENCE, 40);
+ break;
+ }
+ }
+
+ JsonElement chestplateElement = armor.get(2);
+ if (chestplateElement != null && chestplateElement.isJsonObject()) {
+ JsonObject chestplate = chestplateElement.getAsJsonObject();
+ if (chestplate.get("internalname").getAsString().equals("OBSIDIAN_CHESTPLATE")) {
+ JsonArray inventory = Utils.getElement(inventoryInfo, "inv_contents").getAsJsonArray();
+ for (int i = 0; i < inventory.size(); i++) {
+ JsonElement itemElement = inventory.get(i);
+ if (itemElement != null && itemElement.isJsonObject()) {
+ JsonObject item = itemElement.getAsJsonObject();
+ if (item.get("internalname").getAsString().equals("OBSIDIAN")) {
+ int count = 1;
+ if (item.has("count")) {
+ count = item.get("count").getAsInt();
+ }
+ bonuses.addStat(SPEED, count / 20);
+ }
+ }
+ }
+ }
+ }
+
+ return bonuses;
+ }
+
+ private static final HashMap<String, Pattern> STAT_PATTERN_MAP = new HashMap<String, Pattern>() {{
+ put(HEALTH, Pattern.compile("^Health: ((?:\\+|-)[0-9]+)"));
+ put(DEFENCE, Pattern.compile("^Defense: ((?:\\+|-)[0-9]+)"));
+ put(STRENGTH, Pattern.compile("^Strength: ((?:\\+|-)[0-9]+)"));
+ put(SPEED, Pattern.compile("^Speed: ((?:\\+|-)[0-9]+)"));
+ put(CRIT_CHANCE, Pattern.compile("^Crit Chance: ((?:\\+|-)[0-9]+)"));
+ put(CRIT_DAMAGE, Pattern.compile("^Crit Damage: ((?:\\+|-)[0-9]+)"));
+ put(BONUS_ATTACK_SPEED, Pattern.compile("^Bonus Attack Speed: ((?:\\+|-)[0-9]+)"));
+ put(INTELLIGENCE, Pattern.compile("^Intelligence: ((?:\\+|-)[0-9]+)"));
+ put(SEA_CREATURE_CHANCE, Pattern.compile("^Sea Creature Chance: ((?:\\+|-)[0-9]+)"));
+ put("ferocity", Pattern.compile("^Ferocity: ((?:\\+|-)[0-9]+)"));
+ put("ability_damage", Pattern.compile("^Ability Damage: ((?:\\+|-)[0-9]+)"));
+ }};
+
+ private static Stats getStatForItem(String internalname, JsonObject item, JsonArray lore) {
+ Stats stats = new Stats();
+ for (int i = 0; i < lore.size(); i++) {
+ String line = lore.get(i).getAsString();
+ for (Map.Entry<String, Pattern> entry : STAT_PATTERN_MAP.entrySet()) {
+ Matcher matcher = entry.getValue().matcher(Utils.cleanColour(line));
+ if (matcher.find()) {
+ int bonus = Integer.parseInt(matcher.group(1));
+ stats.addStat(entry.getKey(), bonus);
+ }
+ }
+ }
+ if (internalname.equals("DAY_CRYSTAL") || internalname.equals("NIGHT_CRYSTAL")) {
+ stats.addStat(STRENGTH, 2.5f);
+ stats.addStat(DEFENCE, 2.5f);
+ }
+ if (internalname.equals("NEW_YEAR_CAKE_BAG") && item.has("item_contents")) {
+ JsonArray bytesArr = item.get("item_contents").getAsJsonArray();
+ byte[] bytes = new byte[bytesArr.size()];
+ for (int i = 0; i < bytesArr.size(); i++) {
+ bytes[i] = bytesArr.get(i).getAsByte();
+ }
+ try {
+ NBTTagCompound contents_nbt = CompressedStreamTools.readCompressed(new ByteArrayInputStream(bytes));
+ NBTTagList items = contents_nbt.getTagList("i", 10);
+ HashSet<Integer> cakes = new HashSet<>();
+ for (int j = 0; j < items.tagCount(); j++) {
+ if (items.getCompoundTagAt(j).getKeySet().size() > 0) {
+ NBTTagCompound nbt = items.getCompoundTagAt(j).getCompoundTag("tag");
+ if (nbt != null && nbt.hasKey("ExtraAttributes", 10)) {
+ NBTTagCompound ea = nbt.getCompoundTag("ExtraAttributes");
+ if (ea.hasKey("new_years_cake")) {
+ cakes.add(ea.getInteger("new_years_cake"));
+ }
+ }
+ }
+ }
+ stats.addStat(HEALTH, cakes.size());
+ } catch (IOException e) {
+ e.printStackTrace();
+ return stats;
+ }
+ }
+ return stats;
+ }
+
+ private static Stats getItemBonuses(boolean talismanOnly, JsonArray... inventories) {
+ JsonObject misc = Constants.MISC;
+ if (misc == null) return null;
+ JsonElement talisman_upgrades_element = misc.get("talisman_upgrades");
+ if (talisman_upgrades_element == null) return null;
+ JsonObject talisman_upgrades = talisman_upgrades_element.getAsJsonObject();
+
+ HashMap<String, Stats> itemBonuses = new HashMap<>();
+ for (JsonArray inventory : inventories) {
+ for (int i = 0; i < inventory.size(); i++) {
+ JsonElement itemElement = inventory.get(i);
+ if (itemElement != null && itemElement.isJsonObject()) {
+ JsonObject item = itemElement.getAsJsonObject();
+ String internalname = item.get("internalname").getAsString();
+ if (itemBonuses.containsKey(internalname)) {
+ continue;
+ }
+ if (!talismanOnly ||
+ Utils.checkItemType(item.get("lore").getAsJsonArray(), true, "ACCESSORY", "HATCCESSORY") >= 0) {
+ Stats itemBonus = getStatForItem(internalname, item, item.get("lore").getAsJsonArray());
+
+ itemBonuses.put(internalname, itemBonus);
+
+ for (Map.Entry<String, JsonElement> talisman_upgrades_item : talisman_upgrades.entrySet()) {
+ JsonArray upgrades = talisman_upgrades_item.getValue().getAsJsonArray();
+ for (int j = 0; j < upgrades.size(); j++) {
+ String upgrade = upgrades.get(j).getAsString();
+ if (upgrade.equals(internalname)) {
+ itemBonuses.put(talisman_upgrades_item.getKey(), new Stats());
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ Stats itemBonusesStats = new Stats();
+ for (Stats stats : itemBonuses.values()) {
+ itemBonusesStats.add(stats);
+ }
+
+ return itemBonusesStats;
+ }
+
+ public static Stats getPetStatBonuses(JsonObject petsInfo) {
+ JsonObject petsJson = Constants.PETS;
+ JsonObject petnums = Constants.PETNUMS;
+ if (petsJson == null || petnums == null) return new Stats();
+
+ if (petsInfo != null && petsInfo.has("active_pet") && petsInfo.get("active_pet") != null &&
+ petsInfo.get("active_pet").isJsonObject()) {
+ JsonObject pet = petsInfo.get("active_pet").getAsJsonObject();
+ if (pet.has("type") && pet.get("type") != null &&
+ pet.has("tier") && pet.get("tier") != null &&
+ pet.has("exp") && pet.get("exp") != null) {
+
+ String petname = pet.get("type").getAsString();
+ String tier = pet.get("tier").getAsString();
+ String heldItem = Utils.getElementAsString(pet.get("heldItem"), null);
+
+ if (!petnums.has(petname)) {
+ return new Stats();
+ }
+
+ String tierNum = GuiProfileViewer.MINION_RARITY_TO_NUM.get(tier);
+ float exp = pet.get("exp").getAsFloat();
+ if (tierNum == null) return new Stats();
+
+ if (pet.has("heldItem") && !pet.get("heldItem").isJsonNull() &&
+ pet.get("heldItem").getAsString().equals("PET_ITEM_TIER_BOOST")) {
+ tierNum = "" + (Integer.parseInt(tierNum) + 1);
+ }
+
+ GuiProfileViewer.PetLevel levelObj = GuiProfileViewer.getPetLevel(petname, tier, exp);
+
+ float level = levelObj.level;
+ float currentLevelRequirement = levelObj.currentLevelRequirement;
+ float maxXP = levelObj.maxXP;
+ pet.addProperty("level", level);
+ pet.addProperty("currentLevelRequirement", currentLevelRequirement);
+ pet.addProperty("maxXP", maxXP);
+
+ JsonObject petItem = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(petname + ";" + tierNum);
+ if (petItem == null) return new Stats();
+
+ Stats stats = new Stats();
+
+ JsonObject petInfo = petnums.get(petname).getAsJsonObject();
+ if (petInfo.has(tier)) {
+ JsonObject petInfoTier = petInfo.get(tier).getAsJsonObject();
+ if (petInfoTier == null || !petInfoTier.has("1") || !petInfoTier.has("100")) {
+ return new Stats();
+ }
+
+ JsonObject min = petInfoTier.get("1").getAsJsonObject();
+ JsonObject max = petInfoTier.get("100").getAsJsonObject();
+
+ float minMix = (100 - level) / 99f;
+ float maxMix = (level - 1) / 99f;
+
+ for (Map.Entry<String, JsonElement> entry : max.get("statNums").getAsJsonObject().entrySet()) {
+ float statMax = entry.getValue().getAsFloat();
+ float statMin = min.get("statNums").getAsJsonObject().get(entry.getKey()).getAsFloat();
+ float val = statMin * minMix + statMax * maxMix;
+
+ stats.addStat(entry.getKey().toLowerCase(), (int) Math.floor(val));
+ }
+ }
+
+ if (heldItem != null) {
+ HashMap<String, Float> petStatBoots = GuiProfileViewer.PET_STAT_BOOSTS.get(heldItem);
+ HashMap<String, Float> petStatBootsMult = GuiProfileViewer.PET_STAT_BOOSTS_MULT.get(heldItem);
+ if (petStatBoots != null) {
+ for (Map.Entry<String, Float> entryBoost : petStatBoots.entrySet()) {
+ String key = entryBoost.getKey().toLowerCase();
+ try {
+ stats.addStat(key, entryBoost.getValue());
+ } catch (Exception ignored) {
+ }
+ }
+
+ }
+ if (petStatBootsMult != null) {
+ for (Map.Entry<String, Float> entryBoost : petStatBootsMult.entrySet()) {
+ String key = entryBoost.getKey().toLowerCase();
+ try {
+ stats.scale(key, entryBoost.getValue());
+ } catch (Exception ignored) {
+ }
+ }
+ }
+ }
+
+ return stats;
+ }
+ }
+ return new Stats();
+ }
+
+ private static float getStatMult(JsonObject inventoryInfo) {
+ float mult = 1f;
+
+ JsonArray armor = Utils.getElement(inventoryInfo, "inv_armor").getAsJsonArray();
+
+ String fullset = getFullset(armor, -1);
+
+ if (fullset != null && fullset.equals("SUPERIOR_DRAGON_")) {
+ mult *= 1.05f;
+ }
+
+ for (int i = 0; i < armor.size(); i++) {
+ JsonElement itemElement = armor.get(i);
+ if (itemElement == null || !itemElement.isJsonObject()) continue;
+
+ JsonObject item = itemElement.getAsJsonObject();
+ String internalname = item.get("internalname").getAsString();
+
+ String reforge = Utils.getElementAsString(Utils.getElement(item, "ExtraAttributes.modifier"), "");
+
+ if (reforge.equals("renowned")) {
+ mult *= 1.01f;
+ }
+ }
+
+ return mult;
+ }
+
+ private static void applyLimits(Stats stats, JsonObject inventoryInfo) {
+ //>0
+ JsonArray armor = Utils.getElement(inventoryInfo, "inv_armor").getAsJsonArray();
+
+ String fullset = getFullset(armor, 3);
+
+ if (fullset != null) {
+ switch (fullset) {
+ case "CHEAP_TUXEDO_":
+ stats.statsJson.add(HEALTH, new JsonPrimitive(Math.min(75, stats.get(HEALTH))));
+ case "FANCY_TUXEDO_":
+ stats.statsJson.add(HEALTH, new JsonPrimitive(Math.min(150, stats.get(HEALTH))));
+ case "ELEGANT_TUXEDO_":
+ stats.statsJson.add(HEALTH, new JsonPrimitive(Math.min(250, stats.get(HEALTH))));
+ }
+ }
+
+ for (Map.Entry<String, JsonElement> statEntry : stats.statsJson.entrySet()) {
+ if (statEntry.getKey().equals(CRIT_DAMAGE) ||
+ statEntry.getKey().equals(INTELLIGENCE) ||
+ statEntry.getKey().equals(BONUS_ATTACK_SPEED)) continue;
+ stats.statsJson.add(statEntry.getKey(), new JsonPrimitive(Math.max(0, statEntry.getValue().getAsFloat())));
+ }
+ }
+
+ public static Stats getStats(
+ JsonObject skillInfo, JsonObject inventoryInfo, JsonObject collectionInfo,
+ JsonObject petsInfo, JsonObject profile
+ ) {
+ if (skillInfo == null || inventoryInfo == null || collectionInfo == null || profile == null) return null;
+
+ JsonArray armor = Utils.getElement(inventoryInfo, "inv_armor").getAsJsonArray();
+ JsonArray inventory = Utils.getElement(inventoryInfo, "inv_contents").getAsJsonArray();
+ JsonArray talisman_bag = Utils.getElement(inventoryInfo, "talisman_bag").getAsJsonArray();
+
+ Stats passiveBonuses = getPassiveBonuses(skillInfo, profile);
+ Stats armorBonuses = getItemBonuses(false, armor);
+ Stats talismanBonuses = getItemBonuses(true, inventory, talisman_bag);
+
+ if (passiveBonuses == null || armorBonuses == null || talismanBonuses == null) {
+ return null;
+ }
+
+ Stats stats = getBaseStats();
+ if (stats == null) {
+ return null;
+ }
+
+ Stats petBonus = getPetStatBonuses(petsInfo);
+
+ stats = stats.add(passiveBonuses).add(armorBonuses).add(talismanBonuses).add(petBonus);
+
+ stats.add(getSetBonuses(stats, inventoryInfo, collectionInfo, skillInfo, profile));
- for(Map.Entry<String, JsonElement> statEntry : stats.statsJson.entrySet()) {
- if(statEntry.getKey().equals(CRIT_DAMAGE) ||
- statEntry.getKey().equals(INTELLIGENCE) ||
- statEntry.getKey().equals(BONUS_ATTACK_SPEED)) continue;
- stats.statsJson.add(statEntry.getKey(), new JsonPrimitive(Math.max(0, statEntry.getValue().getAsFloat())));
- }
- }
-
- public static Stats getStats(JsonObject skillInfo, JsonObject inventoryInfo, JsonObject collectionInfo,
- JsonObject petsInfo, JsonObject profile) {
- if(skillInfo == null || inventoryInfo == null || collectionInfo == null || profile == null) return null;
-
- JsonArray armor = Utils.getElement(inventoryInfo, "inv_armor").getAsJsonArray();
- JsonArray inventory = Utils.getElement(inventoryInfo, "inv_contents").getAsJsonArray();
- JsonArray talisman_bag = Utils.getElement(inventoryInfo, "talisman_bag").getAsJsonArray();
-
- Stats passiveBonuses = getPassiveBonuses(skillInfo, profile);
- Stats armorBonuses = getItemBonuses(false, armor);
- Stats talismanBonuses = getItemBonuses(true, inventory, talisman_bag);
-
- if(passiveBonuses == null || armorBonuses == null || talismanBonuses == null) {
- return null;
- }
-
- Stats stats = getBaseStats();
- if(stats == null) {
- return null;
- }
-
- Stats petBonus = getPetStatBonuses(petsInfo);
-
- stats = stats.add(passiveBonuses).add(armorBonuses).add(talismanBonuses).add(petBonus);
-
- stats.add(getSetBonuses(stats, inventoryInfo, collectionInfo, skillInfo, profile));
-
- stats.scaleAll(getStatMult(inventoryInfo));
-
- applyLimits(stats, inventoryInfo);
-
- return stats;
- }
+ stats.scaleAll(getStatMult(inventoryInfo));
+
+ applyLimits(stats, inventoryInfo);
+ return stats;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java
index 371e9ef3..674f08af 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java
@@ -1,6 +1,5 @@
package io.github.moulberry.notenoughupdates.profileviewer;
-import com.google.common.base.Splitter;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
@@ -28,1243 +27,1327 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class ProfileViewer {
-
- private final NEUManager manager;
-
- public ProfileViewer(NEUManager manager) {
- this.manager = manager;
- }
-
-
- private static HashMap<String, String> petRarityToNumMap = new HashMap<>();
- static {
- petRarityToNumMap.put("COMMON", "0");
- petRarityToNumMap.put("UNCOMMON", "1");
- petRarityToNumMap.put("RARE", "2");
- petRarityToNumMap.put("EPIC", "3");
- petRarityToNumMap.put("LEGENDARY", "4");
- petRarityToNumMap.put("MYTHIC", "5");
- }
-
- private static final LinkedHashMap<String, ItemStack> skillToSkillDisplayMap = new LinkedHashMap<>();
- static {
- skillToSkillDisplayMap.put("skill_taming", Utils.createItemStack(Items.spawn_egg, EnumChatFormatting.LIGHT_PURPLE+"Taming"));
- skillToSkillDisplayMap.put("skill_mining", Utils.createItemStack(Items.stone_pickaxe, EnumChatFormatting.GRAY+"Mining"));
- skillToSkillDisplayMap.put("skill_foraging", Utils.createItemStack(Item.getItemFromBlock(Blocks.sapling), EnumChatFormatting.DARK_GREEN+"Foraging"));
- skillToSkillDisplayMap.put("skill_enchanting", Utils.createItemStack(Item.getItemFromBlock(Blocks.enchanting_table), EnumChatFormatting.GREEN+"Enchanting"));
- skillToSkillDisplayMap.put("skill_carpentry", Utils.createItemStack(Item.getItemFromBlock(Blocks.crafting_table), EnumChatFormatting.DARK_RED+"Carpentry"));
- skillToSkillDisplayMap.put("skill_farming", Utils.createItemStack(Items.golden_hoe, EnumChatFormatting.YELLOW+"Farming"));
- skillToSkillDisplayMap.put("skill_combat", Utils.createItemStack(Items.stone_sword, EnumChatFormatting.RED+"Combat"));
- skillToSkillDisplayMap.put("skill_fishing", Utils.createItemStack(Items.fishing_rod, EnumChatFormatting.AQUA+"Fishing"));
- skillToSkillDisplayMap.put("skill_alchemy", Utils.createItemStack(Items.brewing_stand, EnumChatFormatting.BLUE+"Alchemy"));
- skillToSkillDisplayMap.put("skill_runecrafting", Utils.createItemStack(Items.magma_cream, EnumChatFormatting.DARK_PURPLE+"Runecrafting"));
- //skillToSkillDisplayMap.put("skill_catacombs", Utils.createItemStack(Item.getItemFromBlock(Blocks.deadbush), EnumChatFormatting.GOLD+"Catacombs"));
- skillToSkillDisplayMap.put("slayer_zombie", Utils.createItemStack(Items.rotten_flesh, EnumChatFormatting.GOLD+"Rev Slayer"));
- skillToSkillDisplayMap.put("slayer_spider", Utils.createItemStack(Items.spider_eye, EnumChatFormatting.GOLD+"Tara Slayer"));
- skillToSkillDisplayMap.put("slayer_wolf", Utils.createItemStack(Items.bone, EnumChatFormatting.GOLD+"Sven Slayer"));
- skillToSkillDisplayMap.put("slayer_enderman", Utils.createItemStack(Items.ender_pearl, EnumChatFormatting.GOLD+"Ender Slayer"));
- }
-
- private static final ItemStack CAT_FARMING = Utils.createItemStack(Items.golden_hoe, EnumChatFormatting.YELLOW+"Farming");
- private static final ItemStack CAT_MINING = Utils.createItemStack(Items.stone_pickaxe, EnumChatFormatting.GRAY+"Mining");
- private static final ItemStack CAT_COMBAT = Utils.createItemStack(Items.stone_sword, EnumChatFormatting.RED+"Combat");
- private static final ItemStack CAT_FORAGING = Utils.createItemStack(Item.getItemFromBlock(Blocks.sapling), EnumChatFormatting.DARK_GREEN+"Foraging");
- private static final ItemStack CAT_FISHING = Utils.createItemStack(Items.fishing_rod, EnumChatFormatting.AQUA+"Fishing");
-
- private static final LinkedHashMap<ItemStack, List<String>> collectionCatToCollectionMap = new LinkedHashMap<>();
- static {
- collectionCatToCollectionMap.put(CAT_FARMING,
- Utils.createList("WHEAT", "CARROT_ITEM", "POTATO_ITEM", "PUMPKIN", "MELON", "SEEDS", "MUSHROOM_COLLECTION",
- "INK_SACK:3", "CACTUS", "SUGAR_CANE", "FEATHER", "LEATHER", "PORK", "RAW_CHICKEN", "MUTTON",
- "RABBIT", "NETHER_STALK"));
- collectionCatToCollectionMap.put(CAT_MINING,
- Utils.createList("COBBLESTONE", "COAL", "IRON_INGOT", "GOLD_INGOT", "DIAMOND", "INK_SACK:4",
- "EMERALD", "REDSTONE", "QUARTZ", "OBSIDIAN", "GLOWSTONE_DUST", "GRAVEL", "ICE", "NETHERRACK",
- "SAND", "ENDER_STONE", null ,"MITHRIL_ORE", "HARD_STONE", "GEMSTONE_COLLECTION"));
- collectionCatToCollectionMap.put(CAT_COMBAT,
- Utils.createList("ROTTEN_FLESH", "BONE", "STRING", "SPIDER_EYE", "SULPHUR", "ENDER_PEARL",
- "GHAST_TEAR", "SLIME_BALL", "BLAZE_ROD", "MAGMA_CREAM", null, null, null));
- collectionCatToCollectionMap.put(CAT_FORAGING,
- Utils.createList("LOG", "LOG:1", "LOG:2", "LOG_2:1", "LOG_2", "LOG:3", null));
- collectionCatToCollectionMap.put(CAT_FISHING,
- Utils.createList("RAW_FISH", "RAW_FISH:1", "RAW_FISH:2", "RAW_FISH:3", "PRISMARINE_SHARD",
- "PRISMARINE_CRYSTALS", "CLAY_BALL", "WATER_LILY", "INK_SACK", "SPONGE"));
- }
-
- private static final LinkedHashMap<ItemStack, List<String>> collectionCatToMinionMap = new LinkedHashMap<>();
- static {
- collectionCatToMinionMap.put(CAT_FARMING,
- Utils.createList("WHEAT", "CARROT", "POTATO", "PUMPKIN", "MELON", null, "MUSHROOM",
- "COCOA", "CACTUS", "SUGAR_CANE", "CHICKEN", "COW", "PIG", null, "SHEEP",
- "RABBIT", "NETHER_WARTS"));
- collectionCatToMinionMap.put(CAT_MINING,
- Utils.createList("COBBLESTONE", "COAL", "IRON", "GOLD", "DIAMOND", "LAPIS",
- "EMERALD", "REDSTONE", "QUARTZ", "OBSIDIAN", "GLOWSTONE", "GRAVEL", "ICE", null,
- "SAND", "ENDER_STONE", "SNOW", "MITHRIL", "HARD_STONE", null));
- collectionCatToMinionMap.put(CAT_COMBAT,
- Utils.createList("ZOMBIE", "SKELETON", "SPIDER", "CAVESPIDER", "CREEPER", "ENDERMAN",
- "GHAST", "SLIME", "BLAZE", "MAGMA_CUBE", "REVENANT", "TARANTULA", "VOIDLING"));
- collectionCatToMinionMap.put(CAT_FORAGING,
- Utils.createList("OAK", "SPRUCE", "BIRCH", "DARK_OAK", "ACACIA", "JUNGLE", "FLOWER"));
- collectionCatToMinionMap.put(CAT_FISHING,
- Utils.createList("FISHING", null, null, null, null,
- null, "CLAY", null, null, null));
- }
-
- private static final LinkedHashMap<String, ItemStack> collectionToCollectionDisplayMap = new LinkedHashMap<>();
- static {
- /* FARMING COLLECTIONS **/
- collectionToCollectionDisplayMap.put("WHEAT", Utils.createItemStack(Items.wheat,
- EnumChatFormatting.YELLOW+"Wheat"));
- collectionToCollectionDisplayMap.put("CARROT_ITEM", Utils.createItemStack(Items.carrot,
- EnumChatFormatting.YELLOW+"Carrot"));
- collectionToCollectionDisplayMap.put("POTATO_ITEM", Utils.createItemStack(Items.potato,
- EnumChatFormatting.YELLOW+"Potato"));
- collectionToCollectionDisplayMap.put("PUMPKIN", Utils.createItemStack(Item.getItemFromBlock(Blocks.pumpkin),
- EnumChatFormatting.YELLOW+"Pumpkin"));
- collectionToCollectionDisplayMap.put("MELON", Utils.createItemStack(Items.melon,
- EnumChatFormatting.YELLOW+"Melon"));
- collectionToCollectionDisplayMap.put("SEEDS", Utils.createItemStack(Items.wheat_seeds,
- EnumChatFormatting.YELLOW+"Seeds"));
- collectionToCollectionDisplayMap.put("MUSHROOM_COLLECTION",
- Utils.createItemStack(Item.getItemFromBlock(Blocks.red_mushroom)
- , EnumChatFormatting.YELLOW+"Mushroom"));
- collectionToCollectionDisplayMap.put("INK_SACK:3", Utils.createItemStack(Items.dye,
- EnumChatFormatting.YELLOW+"Cocoa Beans", 3));
- collectionToCollectionDisplayMap.put("CACTUS", Utils.createItemStack(Item.getItemFromBlock(Blocks.cactus),
- EnumChatFormatting.YELLOW+"Cactus"));
- collectionToCollectionDisplayMap.put("SUGAR_CANE", Utils.createItemStack(Items.reeds,
- EnumChatFormatting.YELLOW+"Sugar Cane"));
- collectionToCollectionDisplayMap.put("FEATHER", Utils.createItemStack(Items.feather,
- EnumChatFormatting.YELLOW+"Feather"));
- collectionToCollectionDisplayMap.put("LEATHER", Utils.createItemStack(Items.leather,
- EnumChatFormatting.YELLOW+"Leather"));
- collectionToCollectionDisplayMap.put("PORK", Utils.createItemStack(Items.porkchop,
- EnumChatFormatting.YELLOW+"Porkchop"));
- collectionToCollectionDisplayMap.put("RAW_CHICKEN", Utils.createItemStack(Items.chicken,
- EnumChatFormatting.YELLOW+"Chicken"));
- collectionToCollectionDisplayMap.put("MUTTON", Utils.createItemStack(Items.mutton,
- EnumChatFormatting.YELLOW+"Mutton"));
- collectionToCollectionDisplayMap.put("RABBIT", Utils.createItemStack(Items.rabbit,
- EnumChatFormatting.YELLOW+"Rabbit"));
- collectionToCollectionDisplayMap.put("NETHER_STALK", Utils.createItemStack(Items.nether_wart,
- EnumChatFormatting.YELLOW+"Nether Wart"));
-
- /* MINING COLLECTIONS **/
- collectionToCollectionDisplayMap.put("COBBLESTONE", Utils.createItemStack(Item.getItemFromBlock(Blocks.cobblestone),
- EnumChatFormatting.GRAY+"Cobblestone"));
- collectionToCollectionDisplayMap.put("COAL", Utils.createItemStack(Items.coal,
- EnumChatFormatting.GRAY+"Coal"));
- collectionToCollectionDisplayMap.put("IRON_INGOT", Utils.createItemStack(Items.iron_ingot,
- EnumChatFormatting.GRAY+"Iron Ingot"));
- collectionToCollectionDisplayMap.put("GOLD_INGOT", Utils.createItemStack(Items.gold_ingot,
- EnumChatFormatting.GRAY+"Gold Ingot"));
- collectionToCollectionDisplayMap.put("DIAMOND", Utils.createItemStack(Items.diamond,
- EnumChatFormatting.GRAY+"Diamond"));
- collectionToCollectionDisplayMap.put("INK_SACK:4", Utils.createItemStack(Items.dye,
- EnumChatFormatting.GRAY+"Lapis Lazuli", 4));
- collectionToCollectionDisplayMap.put("EMERALD", Utils.createItemStack(Items.emerald,
- EnumChatFormatting.GRAY+"Emerald"));
- collectionToCollectionDisplayMap.put("REDSTONE", Utils.createItemStack(Items.redstone,
- EnumChatFormatting.GRAY+"Redstone"));
- collectionToCollectionDisplayMap.put("QUARTZ", Utils.createItemStack(Items.quartz,
- EnumChatFormatting.GRAY+"Nether Quartz"));
- collectionToCollectionDisplayMap.put("OBSIDIAN", Utils.createItemStack(Item.getItemFromBlock(Blocks.obsidian),
- EnumChatFormatting.GRAY+"Obsidian"));
- collectionToCollectionDisplayMap.put("GLOWSTONE_DUST", Utils.createItemStack(Items.glowstone_dust,
- EnumChatFormatting.GRAY+"Glowstone"));
- collectionToCollectionDisplayMap.put("GRAVEL", Utils.createItemStack(Item.getItemFromBlock(Blocks.gravel),
- EnumChatFormatting.GRAY+"Gravel"));
- collectionToCollectionDisplayMap.put("ICE", Utils.createItemStack(Item.getItemFromBlock(Blocks.ice),
- EnumChatFormatting.GRAY+"Ice"));
- collectionToCollectionDisplayMap.put("NETHERRACK", Utils.createItemStack(Item.getItemFromBlock(Blocks.netherrack),
- EnumChatFormatting.GRAY+"Netherrack"));
- collectionToCollectionDisplayMap.put("SAND", Utils.createItemStack(Item.getItemFromBlock(Blocks.sand),
- EnumChatFormatting.GRAY+"Sand"));
- collectionToCollectionDisplayMap.put("ENDER_STONE", Utils.createItemStack(Item.getItemFromBlock(Blocks.end_stone),
- EnumChatFormatting.GRAY+"End Stone"));
- collectionToCollectionDisplayMap.put("MITHRIL_ORE", Utils.createItemStack(Items.prismarine_crystals,
- EnumChatFormatting.GRAY+"Mithril"));
- collectionToCollectionDisplayMap.put("HARD_STONE", Utils.createItemStack(Item.getItemFromBlock(Blocks.stone),
- EnumChatFormatting.GRAY+"Hard Stone"));
- ItemStack gemstone = Utils.createItemStack(Item.getItemFromBlock(Blocks.stained_glass),
- EnumChatFormatting.GRAY+"Gem Stones");
- gemstone.setItemDamage(14);
- collectionToCollectionDisplayMap.put("GEMSTONE_COLLECTION", gemstone);
-
-
- /* COMBAT COLLECTIONS **/
- collectionToCollectionDisplayMap.put("ROTTEN_FLESH", Utils.createItemStack(Items.rotten_flesh,
- EnumChatFormatting.RED+"Rotten Flesh"));
- collectionToCollectionDisplayMap.put("BONE", Utils.createItemStack(Items.bone,
- EnumChatFormatting.RED+"Bone"));
- collectionToCollectionDisplayMap.put("STRING", Utils.createItemStack(Items.string,
- EnumChatFormatting.RED+"String"));
- collectionToCollectionDisplayMap.put("SPIDER_EYE", Utils.createItemStack(Items.spider_eye,
- EnumChatFormatting.RED+"Spider Eye"));
- collectionToCollectionDisplayMap.put("SULPHUR", Utils.createItemStack(Items.gunpowder,
- EnumChatFormatting.RED+"Gunpowder"));
- collectionToCollectionDisplayMap.put("ENDER_PEARL", Utils.createItemStack(Items.ender_pearl,
- EnumChatFormatting.RED+"Ender Pearl"));
- collectionToCollectionDisplayMap.put("GHAST_TEAR", Utils.createItemStack(Items.ghast_tear,
- EnumChatFormatting.RED+"Ghast Tear"));
- collectionToCollectionDisplayMap.put("SLIME_BALL", Utils.createItemStack(Items.slime_ball,
- EnumChatFormatting.RED+"Slimeball"));
- collectionToCollectionDisplayMap.put("BLAZE_ROD", Utils.createItemStack(Items.blaze_rod,
- EnumChatFormatting.RED+"Blaze Rod"));
- collectionToCollectionDisplayMap.put("MAGMA_CREAM", Utils.createItemStack(Items.magma_cream,
- EnumChatFormatting.RED+"Magma Cream"));
-
- /* FORAGING COLLECTIONS **/
- collectionToCollectionDisplayMap.put("LOG", Utils.createItemStack(Item.getItemFromBlock(Blocks.log),
- EnumChatFormatting.DARK_GREEN+"Oak"));
- collectionToCollectionDisplayMap.put("LOG:1", Utils.createItemStack(Item.getItemFromBlock(Blocks.log),
- EnumChatFormatting.DARK_GREEN+"Spruce", 1));
- collectionToCollectionDisplayMap.put("LOG:2", Utils.createItemStack(Item.getItemFromBlock(Blocks.log),
- EnumChatFormatting.DARK_GREEN+"Birch", 2));
- collectionToCollectionDisplayMap.put("LOG_2:1", Utils.createItemStack(Item.getItemFromBlock(Blocks.log2),
- EnumChatFormatting.DARK_GREEN+"Dark Oak", 1));
- collectionToCollectionDisplayMap.put("LOG_2", Utils.createItemStack(Item.getItemFromBlock(Blocks.log2),
- EnumChatFormatting.DARK_GREEN+"Acacia"));
- collectionToCollectionDisplayMap.put("LOG:3", Utils.createItemStack(Item.getItemFromBlock(Blocks.log),
- EnumChatFormatting.DARK_GREEN+"Jungle", 3));
-
- /* FISHING COLLECTIONS **/
- collectionToCollectionDisplayMap.put("RAW_FISH", Utils.createItemStack(Items.fish,
- EnumChatFormatting.AQUA+"Fish"));
- collectionToCollectionDisplayMap.put("RAW_FISH:1", Utils.createItemStack(Items.fish,
- EnumChatFormatting.AQUA+"Salmon", 1));
- collectionToCollectionDisplayMap.put("RAW_FISH:2", Utils.createItemStack(Items.fish,
- EnumChatFormatting.AQUA+"Clownfish", 2));
- collectionToCollectionDisplayMap.put("RAW_FISH:3", Utils.createItemStack(Items.fish,
- EnumChatFormatting.AQUA+"Pufferfish", 3));
- collectionToCollectionDisplayMap.put("PRISMARINE_SHARD", Utils.createItemStack(Items.prismarine_shard,
- EnumChatFormatting.AQUA+"Prismarine Shard"));
- collectionToCollectionDisplayMap.put("PRISMARINE_CRYSTALS", Utils.createItemStack(Items.prismarine_crystals,
- EnumChatFormatting.AQUA+"Prismarine Crystals"));
- collectionToCollectionDisplayMap.put("CLAY_BALL", Utils.createItemStack(Items.clay_ball,
- EnumChatFormatting.AQUA+"Clay"));
- collectionToCollectionDisplayMap.put("WATER_LILY", Utils.createItemStack(Item.getItemFromBlock(Blocks.waterlily),
- EnumChatFormatting.AQUA+"Lilypad"));
- collectionToCollectionDisplayMap.put("INK_SACK", Utils.createItemStack(Items.dye,
- EnumChatFormatting.AQUA+"Ink Sack"));
- collectionToCollectionDisplayMap.put("SPONGE", Utils.createItemStack(Item.getItemFromBlock(Blocks.sponge),
- EnumChatFormatting.AQUA+"Sponge"));
- }
-
- public static LinkedHashMap<ItemStack, List<String>> getCollectionCatToMinionMap() {
- return collectionCatToMinionMap;
- }
-
- public static LinkedHashMap<String, ItemStack> getCollectionToCollectionDisplayMap() {
- return collectionToCollectionDisplayMap;
- }
-
- public static LinkedHashMap<ItemStack, List<String>> getCollectionCatToCollectionMap() {
- return collectionCatToCollectionMap;
- }
-
- public static Map<String, ItemStack> getSkillToSkillDisplayMap() {
- return Collections.unmodifiableMap(skillToSkillDisplayMap);
- }
-
- public static class Level {
- public float level = 0;
- public float maxXpForLevel = 0;
- public boolean maxed = false;
- }
-
- public static Level getLevel(JsonArray levelingArray, float xp, int levelCap, boolean cumulative) {
- Level levelObj = new Level();
- for(int level=0; level<levelingArray.size(); level++) {
- float levelXp = levelingArray.get(level).getAsFloat();
- if(levelXp > xp) {
- if(cumulative) {
- float previous = 0;
- if(level > 0) previous = levelingArray.get(level-1).getAsFloat();
- levelObj.maxXpForLevel = (levelXp-previous);
- levelObj.level = 1 + level + (xp-levelXp)/levelObj.maxXpForLevel;
- } else {
- levelObj.maxXpForLevel = levelXp;
- levelObj.level = level + xp/levelXp;
- }
- if(levelObj.level > levelCap) {
- levelObj.level = levelCap;
- levelObj.maxed = true;
- }
- return levelObj;
- } else {
- if(!cumulative) xp -= levelXp;
- }
- }
- levelObj.level = levelingArray.size();
- if(levelObj.level > levelCap) {
- levelObj.level = levelCap;
- }
- levelObj.maxed = true;
- return levelObj;
- }
-
- public class Profile {
- private final String uuid;
- private String latestProfile = null;
-
- private JsonArray playerInformation = null;
- private JsonObject guildInformation = null;
- private JsonObject basicInfo = null;
-
- private final HashMap<String, JsonObject> profileMap = new HashMap<>();
- private final HashMap<String, JsonObject> petsInfoMap = new HashMap<>();
- private final HashMap<String, List<JsonObject>> coopProfileMap = new HashMap<>();
- private final HashMap<String, JsonObject> skillInfoMap = new HashMap<>();
- private final HashMap<String, JsonObject> inventoryInfoMap = new HashMap<>();
- private final HashMap<String, JsonObject> collectionInfoMap = new HashMap<>();
- private List<String> profileIds = new ArrayList<>();
- private JsonObject playerStatus = null;
- private HashMap<String, PlayerStats.Stats> stats = new HashMap<>();
- private HashMap<String, PlayerStats.Stats> passiveStats = new HashMap<>();
- private HashMap<String, Long> networth = new HashMap<>();
-
- public Profile(String uuid) {
- this.uuid = uuid;
- }
-
- private AtomicBoolean updatingPlayerInfoState = new AtomicBoolean(false);
- private long lastPlayerInfoState = 0;
- private AtomicBoolean updatingPlayerStatusState = new AtomicBoolean(false);
- private AtomicBoolean updatingGuildInfoState = new AtomicBoolean(false);
- private long lastGuildInfoState = 0;
- private AtomicBoolean updatingGuildStatusState = new AtomicBoolean(false);
-
- public JsonObject getPlayerStatus() {
- if(playerStatus != null) return playerStatus;
- if(updatingPlayerStatusState.get()) return null;
-
- updatingPlayerStatusState.set(true);
-
- HashMap<String, String> args = new HashMap<>();
- args.put("uuid", ""+uuid);
- manager.hypixelApi.getHypixelApiAsync(NotEnoughUpdates.INSTANCE.config.apiKey.apiKey, "status",
- args, jsonObject -> {
- if(jsonObject == null) return;
-
- updatingPlayerStatusState.set(false);
- if(jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) {
- playerStatus = jsonObject.get("session").getAsJsonObject();
- }
- }, () -> updatingPlayerStatusState.set(false)
- );
-
- return null;
- }
-
-
- public long getNetWorth(String profileId) {
- if(profileId == null) profileId = latestProfile;
- if(networth.get(profileId) != null) return networth.get(profileId);
- if(getProfileInformation(profileId) == null) return -1;
- if(getInventoryInfo(profileId) == null) return -1;
-
- JsonObject inventoryInfo = getInventoryInfo(profileId);
- JsonObject profileInfo = getProfileInformation(profileId);
-
- HashMap<String, Long> mostExpensiveInternal = new HashMap<>();
-
- long networth = 0;
- for(Map.Entry<String, JsonElement> entry : inventoryInfo.entrySet()) {
- if(entry.getValue().isJsonArray()) {
- for(JsonElement element : entry.getValue().getAsJsonArray()) {
- if(element != null && element.isJsonObject()) {
- JsonObject item = element.getAsJsonObject();
- String internalname = item.get("internalname").getAsString();
-
- if(manager.auctionManager.isVanillaItem(internalname)) continue;
-
- JsonObject bzInfo = manager.auctionManager.getBazaarInfo(internalname);
-
- int auctionPrice;
- if(bzInfo != null && bzInfo.has("curr_sell")) {
- auctionPrice = (int)bzInfo.get("curr_sell").getAsFloat();
- } else {
- auctionPrice = (int)manager.auctionManager.getItemAvgBin(internalname);
- if(auctionPrice <= 0) {
- auctionPrice = manager.auctionManager.getLowestBin(internalname);
- }
- }
-
- try {
- if(item.has("item_contents")) {
- JsonArray bytesArr = item.get("item_contents").getAsJsonArray();
- byte[] bytes = new byte[bytesArr.size()];
- for (int bytesArrI = 0; bytesArrI < bytesArr.size(); bytesArrI++) {
- bytes[bytesArrI] = bytesArr.get(bytesArrI).getAsByte();
- }
- NBTTagCompound contents_nbt = CompressedStreamTools.readCompressed(new ByteArrayInputStream(bytes));
- NBTTagList items = contents_nbt.getTagList("i", 10);
- for(int j=0; j<items.tagCount(); j++) {
- if(items.getCompoundTagAt(j).getKeySet().size() > 0) {
- NBTTagCompound nbt = items.getCompoundTagAt(j).getCompoundTag("tag");
- String internalname2 = manager.getInternalnameFromNBT(nbt);
- if(internalname2 != null) {
- if(manager.auctionManager.isVanillaItem(internalname2)) continue;
-
- JsonObject bzInfo2 = manager.auctionManager.getBazaarInfo(internalname2);
-
- int auctionPrice2;
- if(bzInfo2 != null && bzInfo2.has("curr_sell")) {
- auctionPrice2 = (int)bzInfo2.get("curr_sell").getAsFloat();
- } else {
- auctionPrice2 = (int)manager.auctionManager.getItemAvgBin(internalname2);
- if(auctionPrice2 <= 0) {
- auctionPrice2 = manager.auctionManager.getLowestBin(internalname2);
- }
- }
-
- int count2 = items.getCompoundTagAt(j).getByte("Count");
-
- mostExpensiveInternal.put(internalname2, auctionPrice2 * count2 + mostExpensiveInternal.getOrDefault(internalname2, 0L));
- networth += auctionPrice2 * count2;
- }
- }
- }
- }
- } catch(IOException ignored) {}
-
- int count = 1;
- if(element.getAsJsonObject().has("count")) {
- count = element.getAsJsonObject().get("count").getAsInt();
- }
- mostExpensiveInternal.put(internalname, auctionPrice * count + mostExpensiveInternal.getOrDefault(internalname, 0L));
- networth += auctionPrice * count;
- }
- }
- }
- }
- if(networth == 0) return -1;
-
- //System.out.println(profileId);
- for(Map.Entry<String, Long> entry : mostExpensiveInternal.entrySet()) {
- //System.out.println(entry.getKey() + ":" + entry.getValue());
- }
-
- networth = (int)(networth*1.3f);
-
- JsonObject petsInfo = getPetsInfo(profileId);
- if(petsInfo != null && petsInfo.has("pets")) {
- if(petsInfo.get("pets").isJsonArray()) {
- JsonArray pets = petsInfo.get("pets").getAsJsonArray();
- for(JsonElement element : pets) {
- if(element.isJsonObject()) {
- JsonObject pet = element.getAsJsonObject();
-
- String petname = pet.get("type").getAsString();
- String tier = pet.get("tier").getAsString();
- String tierNum = petRarityToNumMap.get(tier);
- if(tierNum != null) {
- String internalname2 = petname+";"+tierNum;
- JsonObject info2 = manager.auctionManager.getItemAuctionInfo(internalname2);
- if(info2 == null || !info2.has("price") || !info2.has("count")) continue;
- int auctionPrice2 = (int)(info2.get("price").getAsFloat() / info2.get("count").getAsFloat());
-
- networth += auctionPrice2;
- }
- }
- }
- }
- }
-
- float bankBalance = Utils.getElementAsFloat(Utils.getElement(profileInfo, "banking.balance"), 0);
- float purseBalance = Utils.getElementAsFloat(Utils.getElement(profileInfo, "coin_purse"), 0);
-
- networth += bankBalance+purseBalance;
-
- this.networth.put(profileId, networth);
- return networth;
- }
-
- public String getLatestProfile() {
- return latestProfile;
- }
-
- public JsonArray getPlayerInformation(Runnable runnable) {
- if (playerInformation != null) return playerInformation;
-
- long currentTime = System.currentTimeMillis();
-
- if (currentTime - lastPlayerInfoState < 15*1000 && updatingPlayerInfoState.get()) return null;
-
- lastPlayerInfoState = currentTime;
- updatingPlayerInfoState.set(true);
-
- HashMap<String, String> args = new HashMap<>();
- args.put("uuid", "" + uuid);
- manager.hypixelApi.getHypixelApiAsync(NotEnoughUpdates.INSTANCE.config.apiKey.apiKey, "skyblock/profiles",
- args, jsonObject -> {
- updatingPlayerInfoState.set(false);
-
- if (jsonObject == null) return;
- if (jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) {
- playerInformation = jsonObject.get("profiles").getAsJsonArray();
- if (playerInformation == null) return;
- String backup = null;
- long backupLastSave = 0;
-
- profileIds.clear();
-
- for (int i = 0; i < playerInformation.size(); i++) {
- JsonObject profile = playerInformation.get(i).getAsJsonObject();
-
- if (!profile.has("members")) continue;
- JsonObject members = profile.get("members").getAsJsonObject();
-
- if (members.has(uuid)) {
- JsonObject member = members.get(uuid).getAsJsonObject();
-
- if(member.has("coop_invitation")) {
- JsonObject coop_invitation = member.get("coop_invitation").getAsJsonObject();
- if(!coop_invitation.get("confirmed").getAsBoolean()) {
- continue;
- }
- }
-
-
- String cute_name = profile.get("cute_name").getAsString();
- if (backup == null) backup = cute_name;
- profileIds.add(cute_name);
- if (member.has("last_save")) {
- long last_save = member.get("last_save").getAsLong();
- if (last_save > backupLastSave) {
- backupLastSave = last_save;
- backup = cute_name;
- }
- }
-
- }
- }
- latestProfile = backup;
- if (runnable != null) runnable.run();
- }
- }, () -> {
- updatingPlayerInfoState.set(false);
- }
- );
-
- return null;
- }
- public JsonObject getGuildInfo(Runnable runnable) {
- if (guildInformation != null) return guildInformation;
-
- long currentTime = System.currentTimeMillis();
-
- if (currentTime - lastGuildInfoState < 15*1000 && updatingGuildInfoState.get()) return null;
-
- lastGuildInfoState = currentTime;
- updatingGuildInfoState.set(true);
-
- HashMap<String, String> args = new HashMap<>();
- args.put("player", "" + uuid);
- manager.hypixelApi.getHypixelApiAsync(NotEnoughUpdates.INSTANCE.config.apiKey.apiKey, "guild",
- args, jsonObject -> {
- updatingGuildInfoState.set(false);
-
- if (jsonObject == null) return;
- if (jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) {
- guildInformation = jsonObject.get("guild").getAsJsonObject();
- if (guildInformation == null) return;
- if (runnable != null) runnable.run();
- }
- }, () -> {
- updatingGuildInfoState.set(false);
- }
- );
-
- return null;
- }
-
- public List<String> getProfileIds() {
- return profileIds;
- }
-
- public JsonObject getProfileInformation(String profileId) {
- JsonArray playerInfo = getPlayerInformation(() -> {});
- if(playerInfo == null) return null;
- if(profileId == null) profileId = latestProfile;
- if(profileMap.containsKey(profileId)) return profileMap.get(profileId);
-
- for(int i=0; i<playerInformation.size(); i++) {
- if(!playerInformation.get(i).isJsonObject()) {
- playerInformation = null;
- return null;
- }
- JsonObject profile = playerInformation.get(i).getAsJsonObject();
- if(profile.get("cute_name").getAsString().equalsIgnoreCase(profileId)) {
- if(!profile.has("members")) return null;
- JsonObject members = profile.get("members").getAsJsonObject();
- if(!members.has(uuid)) continue;
- JsonObject profileInfo = members.get(uuid).getAsJsonObject();
- if(profile.has("banking")) {
- profileInfo.add("banking", profile.get("banking").getAsJsonObject());
- }
- if(profile.has("game_mode")){
- profileInfo.add("game_mode", profile.get("game_mode"));
- }
- profileMap.put(profileId, profileInfo);
- return profileInfo;
- }
- }
-
- return null;
- }
-
- public List<JsonObject> getCoopProfileInformation(String profileId) {
- JsonArray playerInfo = getPlayerInformation(() -> {});
- if(playerInfo == null) return null;
- if(profileId == null) profileId = latestProfile;
- if(coopProfileMap.containsKey(profileId)) return coopProfileMap.get(profileId);
-
- for(int i=0; i<playerInformation.size(); i++) {
- if(!playerInformation.get(i).isJsonObject()) {
- playerInformation = null;
- return null;
- }
- JsonObject profile = playerInformation.get(i).getAsJsonObject();
- if(profile.get("cute_name").getAsString().equalsIgnoreCase(profileId)) {
- if(!profile.has("members")) return null;
- JsonObject members = profile.get("members").getAsJsonObject();
- if(!members.has(uuid)) return null;
- List<JsonObject> coopList = new ArrayList<>();
- for(Map.Entry<String, JsonElement> islandMember : members.entrySet()) {
- if(!islandMember.getKey().equals(uuid)) {
- JsonObject coopProfileInfo = islandMember.getValue().getAsJsonObject();
- coopList.add(coopProfileInfo);
- }
- }
- coopProfileMap.put(profileId, coopList);
- return coopList;
- }
- }
-
- return null;
- }
-
- public void resetCache() {
- playerInformation = null;
- guildInformation = null;
- basicInfo = null;
- playerStatus = null;
- stats.clear();
- passiveStats.clear();
- profileIds.clear();
- profileMap.clear();
- coopProfileMap.clear();
- petsInfoMap.clear();
- skillInfoMap.clear();
- inventoryInfoMap.clear();
- collectionInfoMap.clear();
- networth.clear();
- }
-
- public int getCap(JsonObject leveling, String skillName) {
- JsonElement capsElement = Utils.getElement(leveling, "leveling_caps");
- if(capsElement == null || !capsElement.isJsonObject()) {
- return 50;
- }
- JsonObject caps = capsElement.getAsJsonObject();
- if(caps.has(skillName)) {
- return caps.get(skillName).getAsInt();
- }
- return 50;
- }
-
- public JsonObject getSkillInfo(String profileId) {
- JsonObject profileInfo = getProfileInformation(profileId);
- if(profileInfo == null) return null;
- if(profileId == null) profileId = latestProfile;
- if(skillInfoMap.containsKey(profileId)) return skillInfoMap.get(profileId);
- JsonObject leveling = Constants.LEVELING;
- if(leveling == null) return null;
-
- float experience_skill_taming = Utils.getElementAsFloat(Utils.getElement(profileInfo, "experience_skill_taming"), 0);
- float experience_skill_mining = Utils.getElementAsFloat(Utils.getElement(profileInfo, "experience_skill_mining"), 0);
- float experience_skill_foraging = Utils.getElementAsFloat(Utils.getElement(profileInfo, "experience_skill_foraging"), 0);
- float experience_skill_enchanting = Utils.getElementAsFloat(Utils.getElement(profileInfo, "experience_skill_enchanting"), 0);
- float experience_skill_carpentry = Utils.getElementAsFloat(Utils.getElement(profileInfo, "experience_skill_carpentry"), 0);
- float experience_skill_farming = Utils.getElementAsFloat(Utils.getElement(profileInfo, "experience_skill_farming"), 0);
- float experience_skill_combat = Utils.getElementAsFloat(Utils.getElement(profileInfo, "experience_skill_combat"), 0);
- float experience_skill_fishing = Utils.getElementAsFloat(Utils.getElement(profileInfo, "experience_skill_fishing"), 0);
- float experience_skill_alchemy = Utils.getElementAsFloat(Utils.getElement(profileInfo, "experience_skill_alchemy"), 0);
- float experience_skill_runecrafting = Utils.getElementAsFloat(Utils.getElement(profileInfo, "experience_skill_runecrafting"), 0);
-
- float experience_skill_catacombs = Utils.getElementAsFloat(Utils.getElement(profileInfo, "dungeons.dungeon_types.catacombs.experience"), 0);
-
- float experience_slayer_zombie = Utils.getElementAsFloat(Utils.getElement(profileInfo, "slayer_bosses.zombie.xp"), 0);
- float experience_slayer_spider = Utils.getElementAsFloat(Utils.getElement(profileInfo, "slayer_bosses.spider.xp"), 0);
- float experience_slayer_wolf = Utils.getElementAsFloat(Utils.getElement(profileInfo, "slayer_bosses.wolf.xp"), 0);
- float experience_slayer_enderman = Utils.getElementAsFloat(Utils.getElement(profileInfo, "slayer_bosses.enderman.xp"), 0);
-
-
- float totalSkillXP = experience_skill_taming + experience_skill_mining + experience_skill_foraging
- + experience_skill_enchanting + experience_skill_carpentry + experience_skill_farming
- + experience_skill_combat + experience_skill_fishing + experience_skill_alchemy
- + experience_skill_runecrafting;
-
- if(totalSkillXP <= 0) {
- return null;
- }
-
- JsonObject skillInfo = new JsonObject();
-
- skillInfo.addProperty("experience_skill_taming", experience_skill_taming);
- skillInfo.addProperty("experience_skill_mining", experience_skill_mining);
- skillInfo.addProperty("experience_skill_foraging", experience_skill_foraging);
- skillInfo.addProperty("experience_skill_enchanting", experience_skill_enchanting);
- skillInfo.addProperty("experience_skill_carpentry", experience_skill_carpentry);
- skillInfo.addProperty("experience_skill_farming", experience_skill_farming);
- skillInfo.addProperty("experience_skill_combat", experience_skill_combat);
- skillInfo.addProperty("experience_skill_fishing", experience_skill_fishing);
- skillInfo.addProperty("experience_skill_alchemy", experience_skill_alchemy);
- skillInfo.addProperty("experience_skill_runecrafting", experience_skill_runecrafting);
-
- skillInfo.addProperty("experience_skill_catacombs", experience_skill_catacombs);
-
- skillInfo.addProperty("experience_slayer_zombie", experience_slayer_zombie);
- skillInfo.addProperty("experience_slayer_spider", experience_slayer_spider);
- skillInfo.addProperty("experience_slayer_wolf", experience_slayer_wolf);
- skillInfo.addProperty("experience_slayer_enderman", experience_slayer_enderman);
-
- JsonArray levelingArray = Utils.getElement(leveling, "leveling_xp").getAsJsonArray();
- int farmingCap = getCap(leveling, "farming") + (int)Utils.getElementAsFloat(
- Utils.getElement(profileInfo, "jacob2.perks.farming_level_cap"), 0);
- Level level_skill_taming = getLevel(levelingArray, experience_skill_taming, getCap(leveling, "taming"), false);
- Level level_skill_mining = getLevel(levelingArray, experience_skill_mining, getCap(leveling, "mining"), false);
- Level level_skill_foraging = getLevel(levelingArray, experience_skill_foraging, getCap(leveling, "foraging"), false);
- Level level_skill_enchanting = getLevel(levelingArray, experience_skill_enchanting, getCap(leveling, "enchanting"), false);
- Level level_skill_carpentry = getLevel(levelingArray, experience_skill_carpentry,getCap(leveling, "carpentry"), false);
- Level level_skill_farming = getLevel(levelingArray, experience_skill_farming, farmingCap, false);
- Level level_skill_combat = getLevel(levelingArray, experience_skill_combat, getCap(leveling, "combat"), false);
- Level level_skill_fishing = getLevel(levelingArray, experience_skill_fishing, getCap(leveling, "fishing"), false);
- Level level_skill_alchemy = getLevel(levelingArray, experience_skill_alchemy, getCap(leveling, "alchemy"), false);
- Level level_skill_runecrafting = getLevel(Utils.getElement(leveling, "runecrafting_xp").getAsJsonArray(),
- experience_skill_runecrafting, getCap(leveling, "runecrafting"), false);
-
- Level level_skill_catacombs = getLevel(Utils.getElement(leveling, "catacombs").getAsJsonArray(),
- experience_skill_catacombs, getCap(leveling, "catacombs"), false);
-
- Level level_slayer_zombie = getLevel(Utils.getElement(leveling, "slayer_xp.zombie").getAsJsonArray(),
- experience_slayer_zombie, 9,true);
- Level level_slayer_spider = getLevel(Utils.getElement(leveling, "slayer_xp.spider").getAsJsonArray(),
- experience_slayer_spider, 9,true);
- Level level_slayer_wolf = getLevel(Utils.getElement(leveling, "slayer_xp.wolf").getAsJsonArray(),
- experience_slayer_wolf, 9,true);
- Level level_slayer_enderman = getLevel(Utils.getElement(leveling, "slayer_xp.enderman").getAsJsonArray(),
- experience_slayer_enderman, 9,true);
-
- skillInfo.addProperty("level_skill_taming", level_skill_taming.level);
- skillInfo.addProperty("level_skill_mining", level_skill_mining.level);
- skillInfo.addProperty("level_skill_foraging", level_skill_foraging.level);
- skillInfo.addProperty("level_skill_enchanting", level_skill_enchanting.level);
- skillInfo.addProperty("level_skill_carpentry", level_skill_carpentry.level);
- skillInfo.addProperty("level_skill_farming", level_skill_farming.level);
- skillInfo.addProperty("level_skill_combat", level_skill_combat.level);
- skillInfo.addProperty("level_skill_fishing", level_skill_fishing.level);
- skillInfo.addProperty("level_skill_alchemy", level_skill_alchemy.level);
- skillInfo.addProperty("level_skill_runecrafting", level_skill_runecrafting.level);
-
- skillInfo.addProperty("level_skill_catacombs", level_skill_catacombs.level);
-
- skillInfo.addProperty("level_slayer_zombie", level_slayer_zombie.level);
- skillInfo.addProperty("level_slayer_spider", level_slayer_spider.level);
- skillInfo.addProperty("level_slayer_wolf", level_slayer_wolf.level);
- skillInfo.addProperty("level_slayer_enderman", level_slayer_enderman.level);
-
- skillInfo.addProperty("maxed_skill_taming", level_skill_taming.maxed);
- skillInfo.addProperty("maxed_skill_mining", level_skill_mining.maxed);
- skillInfo.addProperty("maxed_skill_foraging", level_skill_foraging.maxed);
- skillInfo.addProperty("maxed_skill_enchanting", level_skill_enchanting.maxed);
- skillInfo.addProperty("maxed_skill_carpentry", level_skill_carpentry.maxed);
- skillInfo.addProperty("maxed_skill_farming", level_skill_farming.maxed);
- skillInfo.addProperty("maxed_skill_combat", level_skill_combat.maxed);
- skillInfo.addProperty("maxed_skill_fishing", level_skill_fishing.maxed);
- skillInfo.addProperty("maxed_skill_alchemy", level_skill_alchemy.maxed);
- skillInfo.addProperty("maxed_skill_runecrafting", level_skill_runecrafting.maxed);
-
- skillInfo.addProperty("maxed_skill_catacombs", level_skill_catacombs.maxed);
-
- skillInfo.addProperty("maxed_slayer_zombie", level_slayer_zombie.maxed);
- skillInfo.addProperty("maxed_slayer_spider", level_slayer_spider.maxed);
- skillInfo.addProperty("maxed_slayer_wolf", level_slayer_wolf.maxed);
- skillInfo.addProperty("maxed_slayer_enderman", level_slayer_enderman.maxed);
-
- skillInfo.addProperty("maxxp_skill_taming", level_skill_taming.maxXpForLevel);
- skillInfo.addProperty("maxxp_skill_mining", level_skill_mining.maxXpForLevel);
- skillInfo.addProperty("maxxp_skill_foraging", level_skill_foraging.maxXpForLevel);
- skillInfo.addProperty("maxxp_skill_enchanting", level_skill_enchanting.maxXpForLevel);
- skillInfo.addProperty("maxxp_skill_carpentry", level_skill_carpentry.maxXpForLevel);
- skillInfo.addProperty("maxxp_skill_farming", level_skill_farming.maxXpForLevel);
- skillInfo.addProperty("maxxp_skill_combat", level_skill_combat.maxXpForLevel);
- skillInfo.addProperty("maxxp_skill_fishing", level_skill_fishing.maxXpForLevel);
- skillInfo.addProperty("maxxp_skill_alchemy", level_skill_alchemy.maxXpForLevel);
- skillInfo.addProperty("maxxp_skill_runecrafting", level_skill_runecrafting.maxXpForLevel);
-
- skillInfo.addProperty("maxxp_skill_catacombs", level_skill_catacombs.maxXpForLevel);
-
- skillInfo.addProperty("maxxp_slayer_zombie", level_slayer_zombie.maxXpForLevel);
- skillInfo.addProperty("maxxp_slayer_spider", level_slayer_spider.maxXpForLevel);
- skillInfo.addProperty("maxxp_slayer_wolf", level_slayer_wolf.maxXpForLevel);
- skillInfo.addProperty("maxxp_slayer_enderman", level_slayer_enderman.maxXpForLevel);
-
- return skillInfo;
- }
-
- public JsonObject getInventoryInfo(String profileId) {
- JsonObject profileInfo = getProfileInformation(profileId);
- if(profileInfo == null) return null;
- if(profileId == null) profileId = latestProfile;
- if(inventoryInfoMap.containsKey(profileId)) return inventoryInfoMap.get(profileId);
-
- String inv_armor_bytes = Utils.getElementAsString(Utils.getElement(profileInfo, "inv_armor.data"), "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA=");
- String fishing_bag_bytes = Utils.getElementAsString(Utils.getElement(profileInfo, "fishing_bag.data"), "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA=");
- String quiver_bytes = Utils.getElementAsString(Utils.getElement(profileInfo, "quiver.data"), "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA=");
- String ender_chest_contents_bytes = Utils.getElementAsString(Utils.getElement(profileInfo, "ender_chest_contents.data"), "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA=");
- //Todo clean this up
- //Fake string is so for I loop works the same
- String backpack_contents_json_fake = "fake should fix later";
- JsonObject backpack_contents_json = (JsonObject) Utils.getElement(profileInfo, "backpack_contents");
- JsonObject backpack_icons = (JsonObject) Utils.getElement(profileInfo, "backpack_icons");
- String personal_vault_contents_bytes = Utils.getElementAsString(Utils.getElement(profileInfo, "personal_vault_contents.data"), "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA=");
- String wardrobe_contents_bytes = Utils.getElementAsString(Utils.getElement(profileInfo, "wardrobe_contents.data"), "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA=");
- String potion_bag_bytes = Utils.getElementAsString(Utils.getElement(profileInfo, "potion_bag.data"), "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA=");
- String inv_contents_bytes = Utils.getElementAsString(Utils.getElement(profileInfo, "inv_contents.data"), "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA=");
- String talisman_bag_bytes = Utils.getElementAsString(Utils.getElement(profileInfo, "talisman_bag.data"), "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA=");
- String candy_inventory_contents_bytes = Utils.getElementAsString(Utils.getElement(profileInfo, "candy_inventory_contents.data"), "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA=");
-
-
- JsonObject inventoryInfo = new JsonObject();
-
- String[] inv_names = new String[]{"inv_armor", "fishing_bag", "quiver", "ender_chest_contents", "backpack_contents", "personal_vault_contents", "wardrobe_contents",
- "potion_bag", "inv_contents", "talisman_bag", "candy_inventory_contents"};
- String[] inv_bytes = new String[]{inv_armor_bytes, fishing_bag_bytes, quiver_bytes, ender_chest_contents_bytes, backpack_contents_json_fake, personal_vault_contents_bytes, wardrobe_contents_bytes,
- potion_bag_bytes, inv_contents_bytes, talisman_bag_bytes, candy_inventory_contents_bytes};
- for(int i=0; i<inv_bytes.length; i++) {
- try {
- String bytes = inv_bytes[i];
-
- JsonArray contents = new JsonArray();
-
- if(inv_names[i].equals("backpack_contents")){
- JsonObject temp = getBackpackData(backpack_contents_json, backpack_icons);
- contents = (JsonArray) temp.get("contents");
- inventoryInfo.add("backpack_sizes", temp.get("backpack_sizes"));
-
- } else {
-
- NBTTagCompound inv_contents_nbt = CompressedStreamTools.readCompressed(new ByteArrayInputStream(Base64.getDecoder().decode(bytes)));
- NBTTagList items = inv_contents_nbt.getTagList("i", 10);
- for (int j = 0; j < items.tagCount(); j++) {
- JsonObject item = manager.getJsonFromNBTEntry(items.getCompoundTagAt(j));
- contents.add(item);
- }
- }
- inventoryInfo.add(inv_names[i], contents);
- } catch(IOException e) {
- inventoryInfo.add(inv_names[i], new JsonArray());
- }
- }
-
- inventoryInfoMap.put(profileId, inventoryInfo);
-
- return inventoryInfo;
- }
-
- public boolean checkIfValidJson(JsonElement element){
- return element != null;
- }
-
- public JsonObject getBackpackData(JsonObject backpack_contents_json, JsonObject backpack_icons) {
-
- JsonArray contents = new JsonArray();
- if(!(checkIfValidJson(backpack_contents_json) && checkIfValidJson(backpack_icons))){
- JsonObject bundledReturn = new JsonObject();
- bundledReturn.add("contents", new JsonArray());
- bundledReturn.add("backpack_sizes", new JsonArray());
-
- return bundledReturn;
- }
-
- String[] backpackArray = new String[0];
-
- //Create backpack array which sizes up
- for(Map.Entry<String, JsonElement> backpackIcon : backpack_icons.entrySet()) {
- if(backpackIcon.getValue() instanceof JsonObject){
- JsonObject backpackData = (JsonObject)backpack_contents_json.get(backpackIcon.getKey());
- String bytes = Utils.getElementAsString(backpackData.get("data"), "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA=");
- backpackArray = growArray(bytes, Integer.parseInt(backpackIcon.getKey()), backpackArray);
- }
- }
-
-
- //reduce backpack array to filter out not existent backpacks
- {
- int backpackCount = 0;
- String[] tempBackpackArray = new String[0];
- for (String s : backpackArray) {
- if (s != null) {
- backpackCount++;
- String[] veryTempBackpackArray = new String[tempBackpackArray.length + 1];
- System.arraycopy(tempBackpackArray, 0, veryTempBackpackArray, 0, tempBackpackArray.length);
-
- veryTempBackpackArray[veryTempBackpackArray.length - 1] = s;
- tempBackpackArray = veryTempBackpackArray;
- }
- }
- backpackArray = tempBackpackArray;
- }
-
- JsonArray backpackSizes = new JsonArray();
-
- for (String backpack : backpackArray) {
- try {
- NBTTagCompound inv_contents_nbt = CompressedStreamTools.readCompressed(new ByteArrayInputStream(Base64.getDecoder().decode(backpack)));
- NBTTagList items = inv_contents_nbt.getTagList("i", 10);
-
- backpackSizes.add(new JsonPrimitive(items.tagCount()));
- for (int j = 0; j < items.tagCount(); j++) {
- JsonObject item = manager.getJsonFromNBTEntry(items.getCompoundTagAt(j));
- contents.add(item);
- }
- } catch (IOException ignored) {
- }
- }
-
-
- JsonObject bundledReturn = new JsonObject();
- bundledReturn.add("contents", contents);
- bundledReturn.add("backpack_sizes", backpackSizes);
-
- return bundledReturn;
- }
-
- public String[] growArray(String bytes, int index, String[] oldArray){
- int newSize = Math.max(index+1, oldArray.length);
-
- String[] newArray = new String[newSize];
- for (int i = 0; i < oldArray.length; i++) {
- newArray[i] = oldArray[i];
- }
- newArray[index] = bytes;
-
- return newArray;
- }
-
-
-
- public JsonObject getPetsInfo(String profileId) {
- JsonObject profileInfo = getProfileInformation(profileId);
- if(profileInfo == null) return null;
- if(petsInfoMap.containsKey(profileId)) return petsInfoMap.get(profileId);
-
- JsonObject petsInfo = new JsonObject();
- JsonElement petsElement = profileInfo.get("pets");
- if(petsElement != null && petsElement.isJsonArray()) {
- JsonObject activePet = null;
- JsonArray pets = petsElement.getAsJsonArray();
- for(int i=0; i<pets.size(); i++) {
- JsonObject pet = pets.get(i).getAsJsonObject();
- if(pet.has("active") && pet.get("active").getAsJsonPrimitive().getAsBoolean()) {
- activePet = pet;
- break;
- }
- }
- petsInfo.add("active_pet", activePet);
- petsInfo.add("pets", pets);
- petsInfoMap.put(profileId, petsInfo);
- return petsInfo;
- }
- return null;
- }
-
- private final Pattern COLL_TIER_PATTERN = Pattern.compile("_(-?[0-9]+)");
- public JsonObject getCollectionInfo(String profileId) {
- JsonObject profileInfo = getProfileInformation(profileId);
- if(profileInfo == null) return null;
- JsonObject resourceCollectionInfo = getResourceCollectionInformation();
- if(resourceCollectionInfo == null) return null;
- if(profileId == null) profileId = latestProfile;
- if(collectionInfoMap.containsKey(profileId)) return collectionInfoMap.get(profileId);
-
- JsonElement unlocked_coll_tiers_element = Utils.getElement(profileInfo, "unlocked_coll_tiers");
- JsonElement crafted_generators_element = Utils.getElement(profileInfo, "crafted_generators");
- JsonElement collectionInfoElement = Utils.getElement(profileInfo, "collection");
-
- if(unlocked_coll_tiers_element == null || collectionInfoElement == null) {
- return null;
- }
-
- JsonObject collectionInfo = new JsonObject();
- JsonObject collectionTiers = new JsonObject();
- JsonObject minionTiers = new JsonObject();
- JsonObject personalAmounts = new JsonObject();
- JsonObject totalAmounts = new JsonObject();
-
- if(collectionInfoElement.isJsonObject()) {
- personalAmounts = collectionInfoElement.getAsJsonObject();
- }
-
- for(Map.Entry<String, JsonElement> entry : personalAmounts.entrySet()) {
- totalAmounts.addProperty(entry.getKey(), entry.getValue().getAsInt());
- }
-
- List<JsonObject> coopProfiles = getCoopProfileInformation(profileId);
- if(coopProfiles != null) {
- for(JsonObject coopProfile : coopProfiles) {
- JsonElement coopCollectionInfoElement = Utils.getElement(coopProfile, "collection");
- if(coopCollectionInfoElement != null && coopCollectionInfoElement.isJsonObject()) {
- for(Map.Entry<String, JsonElement> entry : coopCollectionInfoElement.getAsJsonObject().entrySet()) {
- float existing = Utils.getElementAsFloat(totalAmounts.get(entry.getKey()), 0);
- totalAmounts.addProperty(entry.getKey(), existing+entry.getValue().getAsInt());
- }
- }
- }
- }
-
- if(unlocked_coll_tiers_element.isJsonArray()) {
- JsonArray unlocked_coll_tiers = unlocked_coll_tiers_element.getAsJsonArray();
- for(int i=0; i<unlocked_coll_tiers.size(); i++) {
- String unlocked = unlocked_coll_tiers.get(i).getAsString();
-
- Matcher matcher = COLL_TIER_PATTERN.matcher(unlocked);
-
- if(matcher.find()) {
- String tier_str = matcher.group(1);
- int tier = Integer.parseInt(tier_str);
- String coll = unlocked.substring(0, unlocked.length()-(matcher.group().length()));
- if(!collectionTiers.has(coll) || collectionTiers.get(coll).getAsInt() < tier) {
- collectionTiers.addProperty(coll, tier);
- }
- }
- }
- }
-
- if(crafted_generators_element != null && crafted_generators_element.isJsonArray()) {
- JsonArray crafted_generators = crafted_generators_element.getAsJsonArray();
- for(int i=0; i<crafted_generators.size(); i++) {
- String unlocked = crafted_generators.get(i).getAsString();
-
- Matcher matcher = COLL_TIER_PATTERN.matcher(unlocked);
-
- if(matcher.find()) {
- String tier_str = matcher.group(1);
- int tier = Integer.parseInt(tier_str);
- String coll = unlocked.substring(0, unlocked.length()-(matcher.group().length()));
- if(!minionTiers.has(coll) || minionTiers.get(coll).getAsInt() < tier) {
- minionTiers.addProperty(coll, tier);
- }
- }
- }
- }
-
- JsonObject maxAmount = new JsonObject();
- JsonObject updatedCollectionTiers = new JsonObject();
- for(Map.Entry<String, JsonElement> totalAmountsEntry : totalAmounts.entrySet()) {
- String collName = totalAmountsEntry.getKey();
- int collTier = (int)Utils.getElementAsFloat(collectionTiers.get(collName), 0);
-
- int currentAmount = (int)Utils.getElementAsFloat(totalAmounts.get(collName), 0);
- if(currentAmount > 0) {
- for(Map.Entry<String, JsonElement> resourceEntry : resourceCollectionInfo.entrySet()) {
- JsonElement tiersElement = Utils.getElement(resourceEntry.getValue(), "items."+collName+".tiers");
- if(tiersElement != null && tiersElement.isJsonArray()) {
- JsonArray tiers = tiersElement.getAsJsonArray();
- int maxTierAcquired = -1;
- int maxAmountRequired = -1;
- for(int i=0; i<tiers.size(); i++) {
- JsonObject tierInfo = tiers.get(i).getAsJsonObject();
- int tier = tierInfo.get("tier").getAsInt();
- int amountRequired = tierInfo.get("amountRequired").getAsInt();
- if(currentAmount >= amountRequired) {
- maxTierAcquired = tier;
- }
- maxAmountRequired = amountRequired;
- }
- if(maxTierAcquired >= 0 && maxTierAcquired > collTier) {
- updatedCollectionTiers.addProperty(collName, maxTierAcquired);
- }
- maxAmount.addProperty(collName, maxAmountRequired);
- }
- }
- }
- }
-
- for(Map.Entry<String, JsonElement> collectionTiersEntry : updatedCollectionTiers.entrySet()) {
- collectionTiers.add(collectionTiersEntry.getKey(), collectionTiersEntry.getValue());
- }
-
- collectionInfo.add("minion_tiers", minionTiers);
- collectionInfo.add("max_amounts", maxAmount);
- collectionInfo.add("personal_amounts", personalAmounts);
- collectionInfo.add("total_amounts", totalAmounts);
- collectionInfo.add("collection_tiers", collectionTiers);
-
- return collectionInfo;
- }
-
- public PlayerStats.Stats getPassiveStats(String profileId) {
- if(passiveStats.get(profileId) != null) return passiveStats.get(profileId);
- JsonObject profileInfo = getProfileInformation(profileId);
- if(profileInfo == null) return null;
-
- PlayerStats.Stats passiveStats = PlayerStats.getPassiveBonuses(getSkillInfo(profileId), profileInfo);
-
- if(passiveStats != null) {
- passiveStats.add(PlayerStats.getBaseStats());
- }
-
- this.passiveStats.put(profileId, passiveStats);
-
- return passiveStats;
- }
-
- public PlayerStats.Stats getStats(String profileId) {
- //if(stats.get(profileId) != null) return stats.get(profileId);
- JsonObject profileInfo = getProfileInformation(profileId);
- if(profileInfo == null) {
- return null;
- }
-
- PlayerStats.Stats stats = PlayerStats.getStats(getSkillInfo(profileId), getInventoryInfo(profileId), getCollectionInfo(profileId),
- getPetsInfo(profileId), profileInfo);
- this.stats.put(profileId, stats);
- return stats;
- }
-
- public String getUuid() {
- return uuid;
- }
-
- public @Nullable JsonObject getHypixelProfile() {
- if(uuidToHypixelProfile.containsKey(uuid)) return uuidToHypixelProfile.get(uuid);
- return null;
- }
- }
-
- private HashMap<String, JsonObject> nameToHypixelProfile = new HashMap<>();
- private HashMap<String, JsonObject> uuidToHypixelProfile = new HashMap<>();
- private HashMap<String, Profile> uuidToProfileMap = new HashMap<>();
-
- public void getHypixelProfile(String name, Consumer<JsonObject> callback) {
- String nameF = name.toLowerCase();
- HashMap<String, String> args = new HashMap<>();
- args.put("name", ""+nameF);
- manager.hypixelApi.getHypixelApiAsync(NotEnoughUpdates.INSTANCE.config.apiKey.apiKey, "player",
- args, jsonObject -> {
- if(jsonObject != null && jsonObject.has("success") && jsonObject.get("success").getAsBoolean()
- && jsonObject.get("player").isJsonObject()) {
- nameToUuid.put(nameF, jsonObject.get("player").getAsJsonObject().get("uuid").getAsString());
- uuidToHypixelProfile.put(jsonObject.get("player").getAsJsonObject().get("uuid").getAsString(), jsonObject.get("player").getAsJsonObject());
- if(callback != null) callback.accept(jsonObject);
- } else {
- if(callback != null) callback.accept(null);
- }
- }
- );
- }
-
- private final HashMap<String, String> nameToUuid = new HashMap<>();
-
- public void putNameUuid(String name, String uuid) {
- nameToUuid.put(name, uuid);
- }
-
- public void getPlayerUUID(String name, Consumer<String> uuidCallback) {
- String nameF = name.toLowerCase();
- if(nameToUuid.containsKey(nameF)) {
- uuidCallback.accept(nameToUuid.get(nameF));
- return;
- }
-
- manager.hypixelApi.getApiAsync("https://api.mojang.com/users/profiles/minecraft/"+nameF,
- (jsonObject) -> {
- if(jsonObject.has("id") && jsonObject.get("id").isJsonPrimitive() &&
- ((JsonPrimitive)jsonObject.get("id")).isString()) {
- String uuid = jsonObject.get("id").getAsString();
- nameToUuid.put(nameF, uuid);
- uuidCallback.accept(uuid);
- return;
- }
- uuidCallback.accept(null);
- }, () -> uuidCallback.accept(null)
- );
- }
-
- public void getProfileByName(String name, Consumer<Profile> callback) {
- String nameF = name.toLowerCase();
-
- if(nameToUuid.containsKey(nameF) && nameToUuid.get(nameF) == null) {
- callback.accept(null);
- return;
- }
-
- getPlayerUUID(nameF, (uuid) -> {
- if(uuid == null) {
- getHypixelProfile(nameF, jsonObject -> {
- if(jsonObject != null) {
- callback.accept(getProfileReset(nameToUuid.get(nameF), ignored -> {}));
- } else {
- callback.accept(null);
- nameToUuid.put(nameF, null);
- }
- });
- } else {
- if(!uuidToHypixelProfile.containsKey(uuid)) {
- getHypixelProfile(nameF, jsonObject -> {});
- }
- callback.accept(getProfileReset(uuid, ignored -> {}));
- }
- });
-
- return;
- }
-
- public Profile getProfileRaw(String uuid) {
- return uuidToProfileMap.get(uuid);
- }
-
- public Profile getProfile(String uuid, Consumer<Profile> callback) {
- Profile profile = uuidToProfileMap.computeIfAbsent(uuid, k -> new Profile(uuid));
- if(profile.playerInformation != null) {
- callback.accept(profile);
- } else {
- profile.getPlayerInformation(() -> callback.accept(profile));
- }
- return profile;
- }
-
- public Profile getProfileReset(String uuid, Consumer<Profile> callback) {
- if(uuidToProfileMap.containsKey(uuid)) uuidToProfileMap.get(uuid).resetCache();
- return getProfile(uuid, callback);
- }
-
- private static JsonObject resourceCollection = null;
- private static AtomicBoolean updatingResourceCollection = new AtomicBoolean(false);
- public static JsonObject getResourceCollectionInformation() {
- if(resourceCollection != null) return resourceCollection;
- if(updatingResourceCollection.get()) return null;
-
- updatingResourceCollection.set(true);
-
- HashMap<String, String> args = new HashMap<>();
- NotEnoughUpdates.INSTANCE.manager.hypixelApi.getHypixelApiAsync(NotEnoughUpdates.INSTANCE.config.apiKey.apiKey, "resources/skyblock/collections",
- args, jsonObject -> {
- updatingResourceCollection.set(false);
- if(jsonObject != null && jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) {
- resourceCollection = jsonObject.get("collections").getAsJsonObject();
- }
- }, () -> {
- updatingResourceCollection.set(false);
- }
- );
-
- return null;
- }
-
+ private final NEUManager manager;
+
+ public ProfileViewer(NEUManager manager) {
+ this.manager = manager;
+ }
+
+ private static final HashMap<String, String> petRarityToNumMap = new HashMap<String, String>() {{
+ put("COMMON", "0");
+ put("UNCOMMON", "1");
+ put("RARE", "2");
+ put("EPIC", "3");
+ put("LEGENDARY", "4");
+ put("MYTHIC", "5");
+ }};
+
+ private static final LinkedHashMap<String, ItemStack> skillToSkillDisplayMap =
+ new LinkedHashMap<String, ItemStack>() {{
+ put("skill_taming", Utils.createItemStack(Items.spawn_egg, EnumChatFormatting.LIGHT_PURPLE + "Taming"));
+ put("skill_mining", Utils.createItemStack(Items.stone_pickaxe, EnumChatFormatting.GRAY + "Mining"));
+ put(
+ "skill_foraging",
+ Utils.createItemStack(Item.getItemFromBlock(Blocks.sapling), EnumChatFormatting.DARK_GREEN + "Foraging")
+ );
+ put(
+ "skill_enchanting",
+ Utils.createItemStack(Item.getItemFromBlock(Blocks.enchanting_table), EnumChatFormatting.GREEN + "Enchanting")
+ );
+ put(
+ "skill_carpentry",
+ Utils.createItemStack(Item.getItemFromBlock(Blocks.crafting_table), EnumChatFormatting.DARK_RED + "Carpentry")
+ );
+ put("skill_farming", Utils.createItemStack(Items.golden_hoe, EnumChatFormatting.YELLOW + "Farming"));
+ put("skill_combat", Utils.createItemStack(Items.stone_sword, EnumChatFormatting.RED + "Combat"));
+ put("skill_fishing", Utils.createItemStack(Items.fishing_rod, EnumChatFormatting.AQUA + "Fishing"));
+ put("skill_alchemy", Utils.createItemStack(Items.brewing_stand, EnumChatFormatting.BLUE + "Alchemy"));
+ put(
+ "skill_runecrafting",
+ Utils.createItemStack(Items.magma_cream, EnumChatFormatting.DARK_PURPLE + "Runecrafting")
+ );
+ // put("skill_catacombs", Utils.createItemStack(Item.getItemFromBlock(Blocks.deadbush), EnumChatFormatting.GOLD+"Catacombs"));
+ put("slayer_zombie", Utils.createItemStack(Items.rotten_flesh, EnumChatFormatting.GOLD + "Rev Slayer"));
+ put("slayer_spider", Utils.createItemStack(Items.spider_eye, EnumChatFormatting.GOLD + "Tara Slayer"));
+ put("slayer_wolf", Utils.createItemStack(Items.bone, EnumChatFormatting.GOLD + "Sven Slayer"));
+ put("slayer_enderman", Utils.createItemStack(Items.ender_pearl, EnumChatFormatting.GOLD + "Ender Slayer"));
+ }};
+
+ private static final ItemStack CAT_FARMING =
+ Utils.createItemStack(Items.golden_hoe, EnumChatFormatting.YELLOW + "Farming");
+ private static final ItemStack CAT_MINING =
+ Utils.createItemStack(Items.stone_pickaxe, EnumChatFormatting.GRAY + "Mining");
+ private static final ItemStack CAT_COMBAT =
+ Utils.createItemStack(Items.stone_sword, EnumChatFormatting.RED + "Combat");
+ private static final ItemStack CAT_FORAGING =
+ Utils.createItemStack(Item.getItemFromBlock(Blocks.sapling), EnumChatFormatting.DARK_GREEN + "Foraging");
+ private static final ItemStack CAT_FISHING =
+ Utils.createItemStack(Items.fishing_rod, EnumChatFormatting.AQUA + "Fishing");
+
+ private static final LinkedHashMap<ItemStack, List<String>> collectionCatToCollectionMap =
+ new LinkedHashMap<ItemStack, List<String>>() {{
+ put(CAT_FARMING, Utils.createList("WHEAT", "CARROT_ITEM", "POTATO_ITEM", "PUMPKIN", "MELON", "SEEDS",
+ "MUSHROOM_COLLECTION", "INK_SACK:3", "CACTUS", "SUGAR_CANE", "FEATHER", "LEATHER", "PORK", "RAW_CHICKEN",
+ "MUTTON", "RABBIT", "NETHER_STALK"
+ ));
+ put(CAT_MINING, Utils.createList("COBBLESTONE", "COAL", "IRON_INGOT", "GOLD_INGOT", "DIAMOND", "INK_SACK:4",
+ "EMERALD", "REDSTONE", "QUARTZ", "OBSIDIAN", "GLOWSTONE_DUST", "GRAVEL", "ICE", "NETHERRACK", "SAND",
+ "ENDER_STONE", null, "MITHRIL_ORE", "HARD_STONE", "GEMSTONE_COLLECTION"
+ ));
+ put(CAT_COMBAT, Utils.createList("ROTTEN_FLESH", "BONE", "STRING", "SPIDER_EYE", "SULPHUR", "ENDER_PEARL",
+ "GHAST_TEAR", "SLIME_BALL", "BLAZE_ROD", "MAGMA_CREAM", null, null, null
+ ));
+ put(CAT_FORAGING, Utils.createList("LOG", "LOG:1", "LOG:2", "LOG_2:1", "LOG_2", "LOG:3", null));
+ put(CAT_FISHING, Utils.createList("RAW_FISH", "RAW_FISH:1", "RAW_FISH:2", "RAW_FISH:3", "PRISMARINE_SHARD",
+ "PRISMARINE_CRYSTALS", "CLAY_BALL", "WATER_LILY", "INK_SACK", "SPONGE"
+ ));
+
+ }};
+
+ private static final LinkedHashMap<ItemStack, List<String>> collectionCatToMinionMap =
+ new LinkedHashMap<ItemStack, List<String>>() {{
+ put(CAT_FARMING, Utils.createList("WHEAT", "CARROT", "POTATO", "PUMPKIN", "MELON", null, "MUSHROOM",
+ "COCOA", "CACTUS", "SUGAR_CANE", "CHICKEN", "COW", "PIG", null, "SHEEP", "RABBIT", "NETHER_WARTS"
+ ));
+ put(CAT_MINING, Utils.createList("COBBLESTONE", "COAL", "IRON", "GOLD", "DIAMOND", "LAPIS", "EMERALD",
+ "REDSTONE", "QUARTZ", "OBSIDIAN", "GLOWSTONE", "GRAVEL", "ICE", null, "SAND", "ENDER_STONE", "SNOW",
+ "MITHRIL", "HARD_STONE", null
+ ));
+ put(CAT_COMBAT, Utils.createList("ZOMBIE", "SKELETON", "SPIDER", "CAVESPIDER", "CREEPER", "ENDERMAN",
+ "GHAST", "SLIME", "BLAZE", "MAGMA_CUBE", "REVENANT", "TARANTULA", "VOIDLING"
+ ));
+ put(CAT_FORAGING, Utils.createList("OAK", "SPRUCE", "BIRCH", "DARK_OAK", "ACACIA", "JUNGLE", "FLOWER"));
+ put(CAT_FISHING, Utils.createList("FISHING", null, null, null, null, null, "CLAY", null, null, null));
+
+ }};
+
+ private static final LinkedHashMap<String, ItemStack> collectionToCollectionDisplayMap =
+ new LinkedHashMap<String, ItemStack>() {{
+ /* FARMING COLLECTIONS */
+ put("WHEAT", Utils.createItemStack(Items.wheat, EnumChatFormatting.YELLOW + "Wheat"));
+ put("CARROT_ITEM", Utils.createItemStack(Items.carrot, EnumChatFormatting.YELLOW + "Carrot"));
+ put("POTATO_ITEM", Utils.createItemStack(Items.potato, EnumChatFormatting.YELLOW + "Potato"));
+ put(
+ "PUMPKIN",
+ Utils.createItemStack(Item.getItemFromBlock(Blocks.pumpkin), EnumChatFormatting.YELLOW + "Pumpkin")
+ );
+ put("MELON", Utils.createItemStack(Items.melon, EnumChatFormatting.YELLOW + "Melon"));
+ put("SEEDS", Utils.createItemStack(Items.wheat_seeds, EnumChatFormatting.YELLOW + "Seeds"));
+ put(
+ "MUSHROOM_COLLECTION",
+ Utils.createItemStack(Item.getItemFromBlock(Blocks.red_mushroom), EnumChatFormatting.YELLOW + "Mushroom")
+ );
+ put("INK_SACK:3", Utils.createItemStack(Items.dye, EnumChatFormatting.YELLOW + "Cocoa Beans", 3));
+ put("CACTUS", Utils.createItemStack(Item.getItemFromBlock(Blocks.cactus), EnumChatFormatting.YELLOW + "Cactus"));
+ put("SUGAR_CANE", Utils.createItemStack(Items.reeds, EnumChatFormatting.YELLOW + "Sugar Cane"));
+ put("FEATHER", Utils.createItemStack(Items.feather, EnumChatFormatting.YELLOW + "Feather"));
+ put("LEATHER", Utils.createItemStack(Items.leather, EnumChatFormatting.YELLOW + "Leather"));
+ put("PORK", Utils.createItemStack(Items.porkchop, EnumChatFormatting.YELLOW + "Porkchop"));
+ put("RAW_CHICKEN", Utils.createItemStack(Items.chicken, EnumChatFormatting.YELLOW + "Chicken"));
+ put("MUTTON", Utils.createItemStack(Items.mutton, EnumChatFormatting.YELLOW + "Mutton"));
+ put("RABBIT", Utils.createItemStack(Items.rabbit, EnumChatFormatting.YELLOW + "Rabbit"));
+ put("NETHER_STALK", Utils.createItemStack(Items.nether_wart, EnumChatFormatting.YELLOW + "Nether Wart"));
+
+ /* MINING COLLECTIONS */
+ put(
+ "COBBLESTONE",
+ Utils.createItemStack(Item.getItemFromBlock(Blocks.cobblestone), EnumChatFormatting.GRAY + "Cobblestone")
+ );
+ put("COAL", Utils.createItemStack(Items.coal, EnumChatFormatting.GRAY + "Coal"));
+ put("IRON_INGOT", Utils.createItemStack(Items.iron_ingot, EnumChatFormatting.GRAY + "Iron Ingot"));
+ put("GOLD_INGOT", Utils.createItemStack(Items.gold_ingot, EnumChatFormatting.GRAY + "Gold Ingot"));
+ put("DIAMOND", Utils.createItemStack(Items.diamond, EnumChatFormatting.GRAY + "Diamond"));
+ put("INK_SACK:4", Utils.createItemStack(Items.dye, EnumChatFormatting.GRAY + "Lapis Lazuli", 4));
+ put("EMERALD", Utils.createItemStack(Items.emerald, EnumChatFormatting.GRAY + "Emerald"));
+ put("REDSTONE", Utils.createItemStack(Items.redstone, EnumChatFormatting.GRAY + "Redstone"));
+ put("QUARTZ", Utils.createItemStack(Items.quartz, EnumChatFormatting.GRAY + "Nether Quartz"));
+ put(
+ "OBSIDIAN",
+ Utils.createItemStack(Item.getItemFromBlock(Blocks.obsidian), EnumChatFormatting.GRAY + "Obsidian")
+ );
+ put("GLOWSTONE_DUST", Utils.createItemStack(Items.glowstone_dust, EnumChatFormatting.GRAY + "Glowstone"));
+ put("GRAVEL", Utils.createItemStack(Item.getItemFromBlock(Blocks.gravel), EnumChatFormatting.GRAY + "Gravel"));
+ put("ICE", Utils.createItemStack(Item.getItemFromBlock(Blocks.ice), EnumChatFormatting.GRAY + "Ice"));
+ put(
+ "NETHERRACK",
+ Utils.createItemStack(Item.getItemFromBlock(Blocks.netherrack), EnumChatFormatting.GRAY + "Netherrack")
+ );
+ put("SAND", Utils.createItemStack(Item.getItemFromBlock(Blocks.sand), EnumChatFormatting.GRAY + "Sand"));
+ put(
+ "ENDER_STONE",
+ Utils.createItemStack(Item.getItemFromBlock(Blocks.end_stone), EnumChatFormatting.GRAY + "End Stone")
+ );
+ put("MITHRIL_ORE", Utils.createItemStack(Items.prismarine_crystals, EnumChatFormatting.GRAY + "Mithril"));
+ put(
+ "HARD_STONE",
+ Utils.createItemStack(Item.getItemFromBlock(Blocks.stone), EnumChatFormatting.GRAY + "Hard Stone")
+ );
+ put(
+ "GEMSTONE_COLLECTION",
+ Utils.createSkull(
+ EnumChatFormatting.GRAY + "Gemstone",
+ "e942eb66-a350-38e5-aafa-0dfc3e17b4ac",
+ "ewogICJ0aW1lc3RhbXAiIDogMTYxODA4Mzg4ODc3MSwKICAicHJvZmlsZUlkIiA6ICJjNTBhZmE4YWJlYjk0ZTQ1OTRiZjFiNDI1YTk4MGYwMiIsCiAgInByb2ZpbGVOYW1lIiA6ICJUd29FQmFlIiwKICAic2lnbmF0dXJlUmVxdWlyZWQiIDogdHJ1ZSwKICAidGV4dHVyZXMiIDogewogICAgIlNLSU4iIDogewogICAgICAidXJsIiA6ICJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2FhYzE1ZjZmY2YyY2U5NjNlZjRjYTcxZjFhODY4NWFkYjk3ZWI3NjllMWQxMTE5NGNiYmQyZTk2NGE4ODk3OGMiCiAgICB9CiAgfQp9"
+ )
+ );
+
+ /* COMBAT COLLECTIONS */
+ put("ROTTEN_FLESH", Utils.createItemStack(Items.rotten_flesh, EnumChatFormatting.RED + "Rotten Flesh"));
+ put("BONE", Utils.createItemStack(Items.bone, EnumChatFormatting.RED + "Bone"));
+ put("STRING", Utils.createItemStack(Items.string, EnumChatFormatting.RED + "String"));
+ put("SPIDER_EYE", Utils.createItemStack(Items.spider_eye, EnumChatFormatting.RED + "Spider Eye"));
+ put("SULPHUR", Utils.createItemStack(Items.gunpowder, EnumChatFormatting.RED + "Gunpowder"));
+ put("ENDER_PEARL", Utils.createItemStack(Items.ender_pearl, EnumChatFormatting.RED + "Ender Pearl"));
+ put("GHAST_TEAR", Utils.createItemStack(Items.ghast_tear, EnumChatFormatting.RED + "Ghast Tear"));
+ put("SLIME_BALL", Utils.createItemStack(Items.slime_ball, EnumChatFormatting.RED + "Slimeball"));
+ put("BLAZE_ROD", Utils.createItemStack(Items.blaze_rod, EnumChatFormatting.RED + "Blaze Rod"));
+ put("MAGMA_CREAM", Utils.createItemStack(Items.magma_cream, EnumChatFormatting.RED + "Magma Cream"));
+
+ /* FORAGING COLLECTIONS */
+ put("LOG", Utils.createItemStack(Item.getItemFromBlock(Blocks.log), EnumChatFormatting.DARK_GREEN + "Oak"));
+ put(
+ "LOG:1",
+ Utils.createItemStack(Item.getItemFromBlock(Blocks.log), EnumChatFormatting.DARK_GREEN + "Spruce", 1)
+ );
+ put(
+ "LOG:2",
+ Utils.createItemStack(Item.getItemFromBlock(Blocks.log), EnumChatFormatting.DARK_GREEN + "Birch", 2)
+ );
+ put(
+ "LOG_2:1",
+ Utils.createItemStack(Item.getItemFromBlock(Blocks.log2), EnumChatFormatting.DARK_GREEN + "Dark Oak", 1)
+ );
+ put("LOG_2", Utils.createItemStack(Item.getItemFromBlock(Blocks.log2), EnumChatFormatting.DARK_GREEN + "Acacia"));
+ put(
+ "LOG:3",
+ Utils.createItemStack(Item.getItemFromBlock(Blocks.log), EnumChatFormatting.DARK_GREEN + "Jungle", 3)
+ );
+
+ /* FISHING COLLECTIONS */
+ put("RAW_FISH", Utils.createItemStack(Items.fish, EnumChatFormatting.AQUA + "Fish"));
+ put("RAW_FISH:1", Utils.createItemStack(Items.fish, EnumChatFormatting.AQUA + "Salmon", 1));
+ put("RAW_FISH:2", Utils.createItemStack(Items.fish, EnumChatFormatting.AQUA + "Clownfish", 2));
+ put("RAW_FISH:3", Utils.createItemStack(Items.fish, EnumChatFormatting.AQUA + "Pufferfish", 3));
+ put(
+ "PRISMARINE_SHARD",
+ Utils.createItemStack(Items.prismarine_shard, EnumChatFormatting.AQUA + "Prismarine Shard")
+ );
+ put(
+ "PRISMARINE_CRYSTALS",
+ Utils.createItemStack(Items.prismarine_crystals, EnumChatFormatting.AQUA + "Prismarine Crystals")
+ );
+ put("CLAY_BALL", Utils.createItemStack(Items.clay_ball, EnumChatFormatting.AQUA + "Clay"));
+ put(
+ "WATER_LILY",
+ Utils.createItemStack(Item.getItemFromBlock(Blocks.waterlily), EnumChatFormatting.AQUA + "Lilypad")
+ );
+ put("INK_SACK", Utils.createItemStack(Items.dye, EnumChatFormatting.AQUA + "Ink Sack"));
+ put("SPONGE", Utils.createItemStack(Item.getItemFromBlock(Blocks.sponge), EnumChatFormatting.AQUA + "Sponge"));
+ }};
+
+ public static LinkedHashMap<ItemStack, List<String>> getCollectionCatToMinionMap() {
+ return collectionCatToMinionMap;
+ }
+
+ public static LinkedHashMap<String, ItemStack> getCollectionToCollectionDisplayMap() {
+ return collectionToCollectionDisplayMap;
+ }
+
+ public static LinkedHashMap<ItemStack, List<String>> getCollectionCatToCollectionMap() {
+ return collectionCatToCollectionMap;
+ }
+
+ public static Map<String, ItemStack> getSkillToSkillDisplayMap() {
+ return Collections.unmodifiableMap(skillToSkillDisplayMap);
+ }
+
+ public static class Level {
+ public float level = 0;
+ public float maxXpForLevel = 0;
+ public boolean maxed = false;
+ public double totalXp;
+ }
+
+ public static Level getLevel(JsonArray levelingArray, float xp, int levelCap, boolean cumulative) {
+ Level levelObj = new Level();
+ for (int level = 0; level < levelingArray.size(); level++) {
+ float levelXp = levelingArray.get(level).getAsFloat();
+ if (levelXp > xp) {
+ if (cumulative) {
+ float previous = 0;
+ if (level > 0) previous = levelingArray.get(level - 1).getAsFloat();
+ levelObj.maxXpForLevel = (levelXp - previous);
+ levelObj.level = 1 + level + (xp - levelXp) / levelObj.maxXpForLevel;
+ } else {
+ levelObj.maxXpForLevel = levelXp;
+ levelObj.level = level + xp / levelXp;
+ }
+ if (levelObj.level > levelCap) {
+ levelObj.level = levelCap;
+ levelObj.maxed = true;
+ }
+ return levelObj;
+ } else {
+ if (!cumulative) xp -= levelXp;
+ }
+ }
+ levelObj.level = levelingArray.size();
+ if (levelObj.level > levelCap) {
+ levelObj.level = levelCap;
+ }
+ levelObj.maxed = true;
+ return levelObj;
+ }
+
+ public class Profile {
+ private final String uuid;
+ private String latestProfile = null;
+
+ private JsonArray playerInformation = null;
+ private JsonObject guildInformation = null;
+ private JsonObject basicInfo = null;
+
+ private final HashMap<String, JsonObject> profileMap = new HashMap<>();
+ private final HashMap<String, JsonObject> petsInfoMap = new HashMap<>();
+ private final HashMap<String, List<JsonObject>> coopProfileMap = new HashMap<>();
+ private final HashMap<String, JsonObject> skillInfoMap = new HashMap<>();
+ private final HashMap<String, JsonObject> inventoryInfoMap = new HashMap<>();
+ private final HashMap<String, JsonObject> collectionInfoMap = new HashMap<>();
+ private final List<String> profileIds = new ArrayList<>();
+ private JsonObject playerStatus = null;
+ private final HashMap<String, PlayerStats.Stats> stats = new HashMap<>();
+ private final HashMap<String, PlayerStats.Stats> passiveStats = new HashMap<>();
+ private final HashMap<String, Long> networth = new HashMap<>();
+
+ public Profile(String uuid) {
+ this.uuid = uuid;
+ }
+
+ private final AtomicBoolean updatingPlayerInfoState = new AtomicBoolean(false);
+ private long lastPlayerInfoState = 0;
+ private final AtomicBoolean updatingPlayerStatusState = new AtomicBoolean(false);
+ private final AtomicBoolean updatingGuildInfoState = new AtomicBoolean(false);
+ private long lastGuildInfoState = 0;
+ private final AtomicBoolean updatingGuildStatusState = new AtomicBoolean(false);
+
+ public JsonObject getPlayerStatus() {
+ if (playerStatus != null) return playerStatus;
+ if (updatingPlayerStatusState.get()) return null;
+
+ updatingPlayerStatusState.set(true);
+
+ HashMap<String, String> args = new HashMap<>();
+ args.put("uuid", "" + uuid);
+ manager.hypixelApi.getHypixelApiAsync(NotEnoughUpdates.INSTANCE.config.apiKey.apiKey, "status",
+ args, jsonObject -> {
+ if (jsonObject == null) return;
+
+ updatingPlayerStatusState.set(false);
+ if (jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) {
+ playerStatus = jsonObject.get("session").getAsJsonObject();
+ }
+ }, () -> updatingPlayerStatusState.set(false)
+ );
+
+ return null;
+ }
+
+ public long getNetWorth(String profileId) {
+ if (profileId == null) profileId = latestProfile;
+ if (networth.get(profileId) != null) return networth.get(profileId);
+ if (getProfileInformation(profileId) == null) return -1;
+ if (getInventoryInfo(profileId) == null) return -1;
+
+ JsonObject inventoryInfo = getInventoryInfo(profileId);
+ JsonObject profileInfo = getProfileInformation(profileId);
+
+ HashMap<String, Long> mostExpensiveInternal = new HashMap<>();
+
+ long networth = 0;
+ for (Map.Entry<String, JsonElement> entry : inventoryInfo.entrySet()) {
+ if (entry.getValue().isJsonArray()) {
+ for (JsonElement element : entry.getValue().getAsJsonArray()) {
+ if (element != null && element.isJsonObject()) {
+ JsonObject item = element.getAsJsonObject();
+ String internalname = item.get("internalname").getAsString();
+
+ if (manager.auctionManager.isVanillaItem(internalname)) continue;
+
+ JsonObject bzInfo = manager.auctionManager.getBazaarInfo(internalname);
+
+ int auctionPrice;
+ if (bzInfo != null && bzInfo.has("curr_sell")) {
+ auctionPrice = (int) bzInfo.get("curr_sell").getAsFloat();
+ } else {
+ auctionPrice = (int) manager.auctionManager.getItemAvgBin(internalname);
+ if (auctionPrice <= 0) {
+ auctionPrice = manager.auctionManager.getLowestBin(internalname);
+ }
+ }
+
+ try {
+ if (item.has("item_contents")) {
+ JsonArray bytesArr = item.get("item_contents").getAsJsonArray();
+ byte[] bytes = new byte[bytesArr.size()];
+ for (int bytesArrI = 0; bytesArrI < bytesArr.size(); bytesArrI++) {
+ bytes[bytesArrI] = bytesArr.get(bytesArrI).getAsByte();
+ }
+ NBTTagCompound contents_nbt = CompressedStreamTools.readCompressed(new ByteArrayInputStream(bytes));
+ NBTTagList items = contents_nbt.getTagList("i", 10);
+ for (int j = 0; j < items.tagCount(); j++) {
+ if (items.getCompoundTagAt(j).getKeySet().size() > 0) {
+ NBTTagCompound nbt = items.getCompoundTagAt(j).getCompoundTag("tag");
+ String internalname2 = manager.getInternalnameFromNBT(nbt);
+ if (internalname2 != null) {
+ if (manager.auctionManager.isVanillaItem(internalname2)) continue;
+
+ JsonObject bzInfo2 = manager.auctionManager.getBazaarInfo(internalname2);
+
+ int auctionPrice2;
+ if (bzInfo2 != null && bzInfo2.has("curr_sell")) {
+ auctionPrice2 = (int) bzInfo2.get("curr_sell").getAsFloat();
+ } else {
+ auctionPrice2 = (int) manager.auctionManager.getItemAvgBin(internalname2);
+ if (auctionPrice2 <= 0) {
+ auctionPrice2 = manager.auctionManager.getLowestBin(internalname2);
+ }
+ }
+
+ int count2 = items.getCompoundTagAt(j).getByte("Count");
+
+ mostExpensiveInternal.put(
+ internalname2,
+ auctionPrice2 * count2 + mostExpensiveInternal.getOrDefault(internalname2, 0L)
+ );
+ networth += auctionPrice2 * count2;
+ }
+ }
+ }
+ }
+ } catch (IOException ignored) {
+ }
+
+ int count = 1;
+ if (element.getAsJsonObject().has("count")) {
+ count = element.getAsJsonObject().get("count").getAsInt();
+ }
+ mostExpensiveInternal.put(
+ internalname,
+ auctionPrice * count + mostExpensiveInternal.getOrDefault(internalname, 0L)
+ );
+ networth += auctionPrice * count;
+ }
+ }
+ }
+ }
+ if (networth == 0) return -1;
+
+ //System.out.println(profileId);
+ //for (Map.Entry<String, Long> entry : mostExpensiveInternal.entrySet()) {
+ //System.out.println(entry.getKey() + ":" + entry.getValue());
+ //}
+
+ networth = (int) (networth * 1.3f);
+
+ JsonObject petsInfo = getPetsInfo(profileId);
+ if (petsInfo != null && petsInfo.has("pets")) {
+ if (petsInfo.get("pets").isJsonArray()) {
+ JsonArray pets = petsInfo.get("pets").getAsJsonArray();
+ for (JsonElement element : pets) {
+ if (element.isJsonObject()) {
+ JsonObject pet = element.getAsJsonObject();
+
+ String petname = pet.get("type").getAsString();
+ String tier = pet.get("tier").getAsString();
+ String tierNum = petRarityToNumMap.get(tier);
+ if (tierNum != null) {
+ String internalname2 = petname + ";" + tierNum;
+ JsonObject info2 = manager.auctionManager.getItemAuctionInfo(internalname2);
+ if (info2 == null || !info2.has("price") || !info2.has("count")) continue;
+ int auctionPrice2 = (int) (info2.get("price").getAsFloat() / info2.get("count").getAsFloat());
+
+ networth += auctionPrice2;
+ }
+ }
+ }
+ }
+ }
+
+ float bankBalance = Utils.getElementAsFloat(Utils.getElement(profileInfo, "banking.balance"), 0);
+ float purseBalance = Utils.getElementAsFloat(Utils.getElement(profileInfo, "coin_purse"), 0);
+
+ networth += bankBalance + purseBalance;
+
+ this.networth.put(profileId, networth);
+ return networth;
+ }
+
+ public String getLatestProfile() {
+ return latestProfile;
+ }
+
+ public JsonArray getPlayerInformation(Runnable runnable) {
+ if (playerInformation != null) return playerInformation;
+
+ long currentTime = System.currentTimeMillis();
+
+ if (currentTime - lastPlayerInfoState < 15 * 1000 && updatingPlayerInfoState.get()) return null;
+
+ lastPlayerInfoState = currentTime;
+ updatingPlayerInfoState.set(true);
+
+ HashMap<String, String> args = new HashMap<>();
+ args.put("uuid", "" + uuid);
+ manager.hypixelApi.getHypixelApiAsync(NotEnoughUpdates.INSTANCE.config.apiKey.apiKey, "skyblock/profiles",
+ args, jsonObject -> {
+ updatingPlayerInfoState.set(false);
+
+ if (jsonObject == null) return;
+ if (jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) {
+ playerInformation = jsonObject.get("profiles").getAsJsonArray();
+ if (playerInformation == null) return;
+ String backup = null;
+ long backupLastSave = 0;
+
+ profileIds.clear();
+
+ for (int i = 0; i < playerInformation.size(); i++) {
+ JsonObject profile = playerInformation.get(i).getAsJsonObject();
+
+ if (!profile.has("members")) continue;
+ JsonObject members = profile.get("members").getAsJsonObject();
+
+ if (members.has(uuid)) {
+ JsonObject member = members.get(uuid).getAsJsonObject();
+
+ if (member.has("coop_invitation")) {
+ JsonObject coop_invitation = member.get("coop_invitation").getAsJsonObject();
+ if (!coop_invitation.get("confirmed").getAsBoolean()) {
+ continue;
+ }
+ }
+
+ String cute_name = profile.get("cute_name").getAsString();
+ if (backup == null) backup = cute_name;
+ profileIds.add(cute_name);
+ if (member.has("last_save")) {
+ long last_save = member.get("last_save").getAsLong();
+ if (last_save > backupLastSave) {
+ backupLastSave = last_save;
+ backup = cute_name;
+ }
+ }
+
+ }
+ }
+ latestProfile = backup;
+ if (runnable != null) runnable.run();
+ }
+ }, () -> updatingPlayerInfoState.set(false)
+ );
+
+ return null;
+ }
+
+ public JsonObject getGuildInfo(Runnable runnable) {
+ if (guildInformation != null) return guildInformation;
+
+ long currentTime = System.currentTimeMillis();
+
+ if (currentTime - lastGuildInfoState < 15 * 1000 && updatingGuildInfoState.get()) return null;
+
+ lastGuildInfoState = currentTime;
+ updatingGuildInfoState.set(true);
+
+ HashMap<String, String> args = new HashMap<>();
+ args.put("player", "" + uuid);
+ manager.hypixelApi.getHypixelApiAsync(NotEnoughUpdates.INSTANCE.config.apiKey.apiKey, "guild",
+ args, jsonObject -> {
+ updatingGuildInfoState.set(false);
+
+ if (jsonObject == null) return;
+ if (jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) {
+ guildInformation = jsonObject.get("guild").getAsJsonObject();
+ if (guildInformation == null) return;
+ if (runnable != null) runnable.run();
+ }
+ }, () -> updatingGuildInfoState.set(false)
+ );
+
+ return null;
+ }
+
+ public List<String> getProfileIds() {
+ return profileIds;
+ }
+
+ public JsonObject getProfileInformation(String profileId) {
+ JsonArray playerInfo = getPlayerInformation(() -> {
+ });
+ if (playerInfo == null) return null;
+ if (profileId == null) profileId = latestProfile;
+ if (profileMap.containsKey(profileId)) return profileMap.get(profileId);
+
+ for (int i = 0; i < playerInformation.size(); i++) {
+ if (!playerInformation.get(i).isJsonObject()) {
+ playerInformation = null;
+ return null;
+ }
+ JsonObject profile = playerInformation.get(i).getAsJsonObject();
+ if (profile.get("cute_name").getAsString().equalsIgnoreCase(profileId)) {
+ if (!profile.has("members")) return null;
+ JsonObject members = profile.get("members").getAsJsonObject();
+ if (!members.has(uuid)) continue;
+ JsonObject profileInfo = members.get(uuid).getAsJsonObject();
+ if (profile.has("banking")) {
+ profileInfo.add("banking", profile.get("banking").getAsJsonObject());
+ }
+ if (profile.has("game_mode")) {
+ profileInfo.add("game_mode", profile.get("game_mode"));
+ }
+ profileMap.put(profileId, profileInfo);
+ return profileInfo;
+ }
+ }
+
+ return null;
+ }
+
+ public List<JsonObject> getCoopProfileInformation(String profileId) {
+ JsonArray playerInfo = getPlayerInformation(() -> {
+ });
+ if (playerInfo == null) return null;
+ if (profileId == null) profileId = latestProfile;
+ if (coopProfileMap.containsKey(profileId)) return coopProfileMap.get(profileId);
+
+ for (int i = 0; i < playerInformation.size(); i++) {
+ if (!playerInformation.get(i).isJsonObject()) {
+ playerInformation = null;
+ return null;
+ }
+ JsonObject profile = playerInformation.get(i).getAsJsonObject();
+ if (profile.get("cute_name").getAsString().equalsIgnoreCase(profileId)) {
+ if (!profile.has("members")) return null;
+ JsonObject members = profile.get("members").getAsJsonObject();
+ if (!members.has(uuid)) return null;
+ List<JsonObject> coopList = new ArrayList<>();
+ for (Map.Entry<String, JsonElement> islandMember : members.entrySet()) {
+ if (!islandMember.getKey().equals(uuid)) {
+ JsonObject coopProfileInfo = islandMember.getValue().getAsJsonObject();
+ coopList.add(coopProfileInfo);
+ }
+ }
+ coopProfileMap.put(profileId, coopList);
+ return coopList;
+ }
+ }
+
+ return null;
+ }
+
+ public void resetCache() {
+ playerInformation = null;
+ guildInformation = null;
+ basicInfo = null;
+ playerStatus = null;
+ stats.clear();
+ passiveStats.clear();
+ profileIds.clear();
+ profileMap.clear();
+ coopProfileMap.clear();
+ petsInfoMap.clear();
+ skillInfoMap.clear();
+ inventoryInfoMap.clear();
+ collectionInfoMap.clear();
+ networth.clear();
+ }
+
+ public int getCap(JsonObject leveling, String skillName) {
+ JsonElement capsElement = Utils.getElement(leveling, "leveling_caps");
+ if (capsElement == null || !capsElement.isJsonObject()) {
+ return 50;
+ }
+ JsonObject caps = capsElement.getAsJsonObject();
+ if (caps.has(skillName)) {
+ return caps.get(skillName).getAsInt();
+ }
+ return 50;
+ }
+
+ public JsonObject getSkillInfo(String profileId) {
+ JsonObject profileInfo = getProfileInformation(profileId);
+ if (profileInfo == null) return null;
+ if (profileId == null) profileId = latestProfile;
+ if (skillInfoMap.containsKey(profileId)) return skillInfoMap.get(profileId);
+ JsonObject leveling = Constants.LEVELING;
+ if (leveling == null) return null;
+
+ float experience_skill_taming =
+ Utils.getElementAsFloat(Utils.getElement(profileInfo, "experience_skill_taming"), 0);
+ float experience_skill_mining =
+ Utils.getElementAsFloat(Utils.getElement(profileInfo, "experience_skill_mining"), 0);
+ float experience_skill_foraging =
+ Utils.getElementAsFloat(Utils.getElement(profileInfo, "experience_skill_foraging"), 0);
+ float experience_skill_enchanting =
+ Utils.getElementAsFloat(Utils.getElement(profileInfo, "experience_skill_enchanting"), 0);
+ float experience_skill_carpentry =
+ Utils.getElementAsFloat(Utils.getElement(profileInfo, "experience_skill_carpentry"), 0);
+ float experience_skill_farming =
+ Utils.getElementAsFloat(Utils.getElement(profileInfo, "experience_skill_farming"), 0);
+ float experience_skill_combat =
+ Utils.getElementAsFloat(Utils.getElement(profileInfo, "experience_skill_combat"), 0);
+ float experience_skill_fishing =
+ Utils.getElementAsFloat(Utils.getElement(profileInfo, "experience_skill_fishing"), 0);
+ float experience_skill_alchemy =
+ Utils.getElementAsFloat(Utils.getElement(profileInfo, "experience_skill_alchemy"), 0);
+ float experience_skill_runecrafting =
+ Utils.getElementAsFloat(Utils.getElement(profileInfo, "experience_skill_runecrafting"), 0);
+ float experience_skill_hotm = Utils.getElementAsFloat(Utils.getElement(profileInfo, "mining_core.experience"), 0);
+
+ float experience_skill_catacombs =
+ Utils.getElementAsFloat(Utils.getElement(profileInfo, "dungeons.dungeon_types.catacombs.experience"), 0);
+
+ float experience_slayer_zombie =
+ Utils.getElementAsFloat(Utils.getElement(profileInfo, "slayer_bosses.zombie.xp"), 0);
+ float experience_slayer_spider =
+ Utils.getElementAsFloat(Utils.getElement(profileInfo, "slayer_bosses.spider.xp"), 0);
+ float experience_slayer_wolf = Utils.getElementAsFloat(Utils.getElement(profileInfo, "slayer_bosses.wolf.xp"), 0);
+ float experience_slayer_enderman =
+ Utils.getElementAsFloat(Utils.getElement(profileInfo, "slayer_bosses.enderman.xp"), 0);
+
+ float totalSkillXP = experience_skill_taming + experience_skill_mining + experience_skill_foraging
+ + experience_skill_enchanting + experience_skill_carpentry + experience_skill_farming
+ + experience_skill_combat + experience_skill_fishing + experience_skill_alchemy
+ + experience_skill_runecrafting;
+
+ if (totalSkillXP <= 0) {
+ return null;
+ }
+
+ JsonObject skillInfo = new JsonObject();
+
+ skillInfo.addProperty("experience_skill_taming", experience_skill_taming);
+ skillInfo.addProperty("experience_skill_mining", experience_skill_mining);
+ skillInfo.addProperty("experience_skill_foraging", experience_skill_foraging);
+ skillInfo.addProperty("experience_skill_enchanting", experience_skill_enchanting);
+ skillInfo.addProperty("experience_skill_carpentry", experience_skill_carpentry);
+ skillInfo.addProperty("experience_skill_farming", experience_skill_farming);
+ skillInfo.addProperty("experience_skill_combat", experience_skill_combat);
+ skillInfo.addProperty("experience_skill_fishing", experience_skill_fishing);
+ skillInfo.addProperty("experience_skill_alchemy", experience_skill_alchemy);
+ skillInfo.addProperty("experience_skill_runecrafting", experience_skill_runecrafting);
+ skillInfo.addProperty("experience_skill_hotm", experience_skill_hotm);
+
+ skillInfo.addProperty("experience_skill_catacombs", experience_skill_catacombs);
+
+ skillInfo.addProperty("experience_slayer_zombie", experience_slayer_zombie);
+ skillInfo.addProperty("experience_slayer_spider", experience_slayer_spider);
+ skillInfo.addProperty("experience_slayer_wolf", experience_slayer_wolf);
+ skillInfo.addProperty("experience_slayer_enderman", experience_slayer_enderman);
+
+ JsonArray levelingArray = Utils.getElement(leveling, "leveling_xp").getAsJsonArray();
+ int farmingCap = getCap(leveling, "farming") + (int) Utils.getElementAsFloat(
+ Utils.getElement(profileInfo, "jacob2.perks.farming_level_cap"), 0);
+ Level level_skill_taming = getLevel(levelingArray, experience_skill_taming, getCap(leveling, "taming"), false);
+ Level level_skill_mining = getLevel(levelingArray, experience_skill_mining, getCap(leveling, "mining"), false);
+ Level level_skill_foraging =
+ getLevel(levelingArray, experience_skill_foraging, getCap(leveling, "foraging"), false);
+ Level level_skill_enchanting =
+ getLevel(levelingArray, experience_skill_enchanting, getCap(leveling, "enchanting"), false);
+ Level level_skill_carpentry =
+ getLevel(levelingArray, experience_skill_carpentry, getCap(leveling, "carpentry"), false);
+ Level level_skill_farming = getLevel(levelingArray, experience_skill_farming, farmingCap, false);
+ Level level_skill_combat = getLevel(levelingArray, experience_skill_combat, getCap(leveling, "combat"), false);
+ Level level_skill_fishing = getLevel(levelingArray, experience_skill_fishing, getCap(leveling, "fishing"), false);
+ Level level_skill_alchemy = getLevel(levelingArray, experience_skill_alchemy, getCap(leveling, "alchemy"), false);
+ Level level_skill_hotm = getLevel(levelingArray, experience_skill_hotm, getCap(leveling, "HOTM"), false);
+ Level level_skill_runecrafting = getLevel(Utils.getElement(leveling, "runecrafting_xp").getAsJsonArray(),
+ experience_skill_runecrafting, getCap(leveling, "runecrafting"), false
+ );
+ Level level_skill_catacombs = getLevel(Utils.getElement(leveling, "catacombs").getAsJsonArray(),
+ experience_skill_catacombs, getCap(leveling, "catacombs"), false
+ );
+
+ Level level_slayer_zombie = getLevel(Utils.getElement(leveling, "slayer_xp.zombie").getAsJsonArray(),
+ experience_slayer_zombie, 9, true
+ );
+ Level level_slayer_spider = getLevel(Utils.getElement(leveling, "slayer_xp.spider").getAsJsonArray(),
+ experience_slayer_spider, 9, true
+ );
+ Level level_slayer_wolf = getLevel(Utils.getElement(leveling, "slayer_xp.wolf").getAsJsonArray(),
+ experience_slayer_wolf, 9, true
+ );
+ Level level_slayer_enderman = getLevel(Utils.getElement(leveling, "slayer_xp.enderman").getAsJsonArray(),
+ experience_slayer_enderman, 9, true
+ );
+
+ skillInfo.addProperty("level_skill_taming", level_skill_taming.level);
+ skillInfo.addProperty("level_skill_mining", level_skill_mining.level);
+ skillInfo.addProperty("level_skill_foraging", level_skill_foraging.level);
+ skillInfo.addProperty("level_skill_enchanting", level_skill_enchanting.level);
+ skillInfo.addProperty("level_skill_carpentry", level_skill_carpentry.level);
+ skillInfo.addProperty("level_skill_farming", level_skill_farming.level);
+ skillInfo.addProperty("level_skill_combat", level_skill_combat.level);
+ skillInfo.addProperty("level_skill_fishing", level_skill_fishing.level);
+ skillInfo.addProperty("level_skill_alchemy", level_skill_alchemy.level);
+ skillInfo.addProperty("level_skill_runecrafting", level_skill_runecrafting.level);
+
+ skillInfo.addProperty("level_skill_catacombs", level_skill_catacombs.level);
+
+ skillInfo.addProperty("level_slayer_zombie", level_slayer_zombie.level);
+ skillInfo.addProperty("level_slayer_spider", level_slayer_spider.level);
+ skillInfo.addProperty("level_slayer_wolf", level_slayer_wolf.level);
+ skillInfo.addProperty("level_slayer_enderman", level_slayer_enderman.level);
+
+ skillInfo.addProperty("maxed_skill_taming", level_skill_taming.maxed);
+ skillInfo.addProperty("maxed_skill_mining", level_skill_mining.maxed);
+ skillInfo.addProperty("maxed_skill_foraging", level_skill_foraging.maxed);
+ skillInfo.addProperty("maxed_skill_enchanting", level_skill_enchanting.maxed);
+ skillInfo.addProperty("maxed_skill_carpentry", level_skill_carpentry.maxed);
+ skillInfo.addProperty("maxed_skill_farming", level_skill_farming.maxed);
+ skillInfo.addProperty("maxed_skill_combat", level_skill_combat.maxed);
+ skillInfo.addProperty("maxed_skill_fishing", level_skill_fishing.maxed);
+ skillInfo.addProperty("maxed_skill_alchemy", level_skill_alchemy.maxed);
+ skillInfo.addProperty("maxed_skill_runecrafting", level_skill_runecrafting.maxed);
+
+ skillInfo.addProperty("maxed_skill_catacombs", level_skill_catacombs.maxed);
+
+ skillInfo.addProperty("maxed_slayer_zombie", level_slayer_zombie.maxed);
+ skillInfo.addProperty("maxed_slayer_spider", level_slayer_spider.maxed);
+ skillInfo.addProperty("maxed_slayer_wolf", level_slayer_wolf.maxed);
+ skillInfo.addProperty("maxed_slayer_enderman", level_slayer_enderman.maxed);
+
+ skillInfo.addProperty("maxxp_skill_taming", level_skill_taming.maxXpForLevel);
+ skillInfo.addProperty("maxxp_skill_mining", level_skill_mining.maxXpForLevel);
+ skillInfo.addProperty("maxxp_skill_foraging", level_skill_foraging.maxXpForLevel);
+ skillInfo.addProperty("maxxp_skill_enchanting", level_skill_enchanting.maxXpForLevel);
+ skillInfo.addProperty("maxxp_skill_carpentry", level_skill_carpentry.maxXpForLevel);
+ skillInfo.addProperty("maxxp_skill_farming", level_skill_farming.maxXpForLevel);
+ skillInfo.addProperty("maxxp_skill_combat", level_skill_combat.maxXpForLevel);
+ skillInfo.addProperty("maxxp_skill_fishing", level_skill_fishing.maxXpForLevel);
+ skillInfo.addProperty("maxxp_skill_alchemy", level_skill_alchemy.maxXpForLevel);
+ skillInfo.addProperty("maxxp_skill_runecrafting", level_skill_runecrafting.maxXpForLevel);
+
+ skillInfo.addProperty("maxxp_skill_catacombs", level_skill_catacombs.maxXpForLevel);
+
+ skillInfo.addProperty("maxxp_slayer_zombie", level_slayer_zombie.maxXpForLevel);
+ skillInfo.addProperty("maxxp_slayer_spider", level_slayer_spider.maxXpForLevel);
+ skillInfo.addProperty("maxxp_slayer_wolf", level_slayer_wolf.maxXpForLevel);
+ skillInfo.addProperty("maxxp_slayer_enderman", level_slayer_enderman.maxXpForLevel);
+
+ return skillInfo;
+ }
+
+ public JsonObject getInventoryInfo(String profileId) {
+ JsonObject profileInfo = getProfileInformation(profileId);
+ if (profileInfo == null) return null;
+ if (profileId == null) profileId = latestProfile;
+ if (inventoryInfoMap.containsKey(profileId)) return inventoryInfoMap.get(profileId);
+
+ String inv_armor_bytes = Utils.getElementAsString(
+ Utils.getElement(profileInfo, "inv_armor.data"),
+ "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA="
+ );
+ String fishing_bag_bytes = Utils.getElementAsString(
+ Utils.getElement(profileInfo, "fishing_bag.data"),
+ "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA="
+ );
+ String quiver_bytes = Utils.getElementAsString(
+ Utils.getElement(profileInfo, "quiver.data"),
+ "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA="
+ );
+ String ender_chest_contents_bytes = Utils.getElementAsString(
+ Utils.getElement(profileInfo, "ender_chest_contents.data"),
+ "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA="
+ );
+ //Todo clean this up
+ //Fake string is so for I loop works the same
+ String backpack_contents_json_fake = "fake should fix later";
+ JsonObject backpack_contents_json = (JsonObject) Utils.getElement(profileInfo, "backpack_contents");
+ JsonObject backpack_icons = (JsonObject) Utils.getElement(profileInfo, "backpack_icons");
+ String personal_vault_contents_bytes = Utils.getElementAsString(
+ Utils.getElement(profileInfo, "personal_vault_contents.data"),
+ "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA="
+ );
+ String wardrobe_contents_bytes = Utils.getElementAsString(
+ Utils.getElement(profileInfo, "wardrobe_contents.data"),
+ "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA="
+ );
+ String potion_bag_bytes = Utils.getElementAsString(
+ Utils.getElement(profileInfo, "potion_bag.data"),
+ "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA="
+ );
+ String inv_contents_bytes = Utils.getElementAsString(
+ Utils.getElement(profileInfo, "inv_contents.data"),
+ "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA="
+ );
+ String talisman_bag_bytes = Utils.getElementAsString(
+ Utils.getElement(profileInfo, "talisman_bag.data"),
+ "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA="
+ );
+ String candy_inventory_contents_bytes = Utils.getElementAsString(
+ Utils.getElement(profileInfo, "candy_inventory_contents.data"),
+ "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA="
+ );
+
+ JsonObject inventoryInfo = new JsonObject();
+
+ String[] inv_names = new String[]{
+ "inv_armor",
+ "fishing_bag",
+ "quiver",
+ "ender_chest_contents",
+ "backpack_contents",
+ "personal_vault_contents",
+ "wardrobe_contents",
+ "potion_bag",
+ "inv_contents",
+ "talisman_bag",
+ "candy_inventory_contents"
+ };
+ String[] inv_bytes = new String[]{
+ inv_armor_bytes,
+ fishing_bag_bytes,
+ quiver_bytes,
+ ender_chest_contents_bytes,
+ backpack_contents_json_fake,
+ personal_vault_contents_bytes,
+ wardrobe_contents_bytes,
+ potion_bag_bytes,
+ inv_contents_bytes,
+ talisman_bag_bytes,
+ candy_inventory_contents_bytes
+ };
+ for (int i = 0; i < inv_bytes.length; i++) {
+ try {
+ String bytes = inv_bytes[i];
+
+ JsonArray contents = new JsonArray();
+
+ if (inv_names[i].equals("backpack_contents")) {
+ JsonObject temp = getBackpackData(backpack_contents_json, backpack_icons);
+ contents = (JsonArray) temp.get("contents");
+ inventoryInfo.add("backpack_sizes", temp.get("backpack_sizes"));
+
+ } else {
+
+ NBTTagCompound inv_contents_nbt =
+ CompressedStreamTools.readCompressed(new ByteArrayInputStream(Base64.getDecoder().decode(bytes)));
+ NBTTagList items = inv_contents_nbt.getTagList("i", 10);
+ for (int j = 0; j < items.tagCount(); j++) {
+ JsonObject item = manager.getJsonFromNBTEntry(items.getCompoundTagAt(j));
+ contents.add(item);
+ }
+ }
+ inventoryInfo.add(inv_names[i], contents);
+ } catch (IOException e) {
+ inventoryInfo.add(inv_names[i], new JsonArray());
+ }
+ }
+
+ inventoryInfoMap.put(profileId, inventoryInfo);
+
+ return inventoryInfo;
+ }
+
+ public boolean checkIfValidJson(JsonElement element) {
+ return element != null;
+ }
+
+ public JsonObject getBackpackData(JsonObject backpack_contents_json, JsonObject backpack_icons) {
+
+ JsonArray contents = new JsonArray();
+ if (!(checkIfValidJson(backpack_contents_json) && checkIfValidJson(backpack_icons))) {
+ JsonObject bundledReturn = new JsonObject();
+ bundledReturn.add("contents", new JsonArray());
+ bundledReturn.add("backpack_sizes", new JsonArray());
+
+ return bundledReturn;
+ }
+
+ String[] backpackArray = new String[0];
+
+ //Create backpack array which sizes up
+ for (Map.Entry<String, JsonElement> backpackIcon : backpack_icons.entrySet()) {
+ if (backpackIcon.getValue() instanceof JsonObject) {
+ JsonObject backpackData = (JsonObject) backpack_contents_json.get(backpackIcon.getKey());
+ String bytes = Utils.getElementAsString(backpackData.get("data"), "Hz8IAAAAAAAAAD9iYD9kYD9kAAMAPwI/Gw0AAAA=");
+ backpackArray = growArray(bytes, Integer.parseInt(backpackIcon.getKey()), backpackArray);
+ }
+ }
+
+ //reduce backpack array to filter out not existent backpacks
+ {
+ int backpackCount = 0;
+ String[] tempBackpackArray = new String[0];
+ for (String s : backpackArray) {
+ if (s != null) {
+ backpackCount++;
+ String[] veryTempBackpackArray = new String[tempBackpackArray.length + 1];
+ System.arraycopy(tempBackpackArray, 0, veryTempBackpackArray, 0, tempBackpackArray.length);
+
+ veryTempBackpackArray[veryTempBackpackArray.length - 1] = s;
+ tempBackpackArray = veryTempBackpackArray;
+ }
+ }
+ backpackArray = tempBackpackArray;
+ }
+
+ JsonArray backpackSizes = new JsonArray();
+
+ for (String backpack : backpackArray) {
+ try {
+ NBTTagCompound inv_contents_nbt =
+ CompressedStreamTools.readCompressed(new ByteArrayInputStream(Base64.getDecoder().decode(backpack)));
+ NBTTagList items = inv_contents_nbt.getTagList("i", 10);
+
+ backpackSizes.add(new JsonPrimitive(items.tagCount()));
+ for (int j = 0; j < items.tagCount(); j++) {
+ JsonObject item = manager.getJsonFromNBTEntry(items.getCompoundTagAt(j));
+ contents.add(item);
+ }
+ } catch (IOException ignored) {
+ }
+ }
+
+ JsonObject bundledReturn = new JsonObject();
+ bundledReturn.add("contents", contents);
+ bundledReturn.add("backpack_sizes", backpackSizes);
+
+ return bundledReturn;
+ }
+
+ public String[] growArray(String bytes, int index, String[] oldArray) {
+ int newSize = Math.max(index + 1, oldArray.length);
+
+ String[] newArray = new String[newSize];
+ for (int i = 0; i < oldArray.length; i++) {
+ newArray[i] = oldArray[i];
+ }
+ newArray[index] = bytes;
+
+ return newArray;
+ }
+
+ public JsonObject getPetsInfo(String profileId) {
+ JsonObject profileInfo = getProfileInformation(profileId);
+ if (profileInfo == null) return null;
+ if (petsInfoMap.containsKey(profileId)) return petsInfoMap.get(profileId);
+
+ JsonObject petsInfo = new JsonObject();
+ JsonElement petsElement = profileInfo.get("pets");
+ if (petsElement != null && petsElement.isJsonArray()) {
+ JsonObject activePet = null;
+ JsonArray pets = petsElement.getAsJsonArray();
+ for (int i = 0; i < pets.size(); i++) {
+ JsonObject pet = pets.get(i).getAsJsonObject();
+ if (pet.has("active") && pet.get("active").getAsJsonPrimitive().getAsBoolean()) {
+ activePet = pet;
+ break;
+ }
+ }
+ petsInfo.add("active_pet", activePet);
+ petsInfo.add("pets", pets);
+ petsInfoMap.put(profileId, petsInfo);
+ return petsInfo;
+ }
+ return null;
+ }
+
+ private final Pattern COLL_TIER_PATTERN = Pattern.compile("_(-?[0-9]+)");
+
+ public JsonObject getCollectionInfo(String profileId) {
+ JsonObject profileInfo = getProfileInformation(profileId);
+ if (profileInfo == null) return null;
+ JsonObject resourceCollectionInfo = getResourceCollectionInformation();
+ if (resourceCollectionInfo == null) return null;
+ if (profileId == null) profileId = latestProfile;
+ if (collectionInfoMap.containsKey(profileId)) return collectionInfoMap.get(profileId);
+
+ JsonElement unlocked_coll_tiers_element = Utils.getElement(profileInfo, "unlocked_coll_tiers");
+ JsonElement crafted_generators_element = Utils.getElement(profileInfo, "crafted_generators");
+ JsonElement collectionInfoElement = Utils.getElement(profileInfo, "collection");
+
+ if (unlocked_coll_tiers_element == null || collectionInfoElement == null) {
+ return null;
+ }
+
+ JsonObject collectionInfo = new JsonObject();
+ JsonObject collectionTiers = new JsonObject();
+ JsonObject minionTiers = new JsonObject();
+ JsonObject personalAmounts = new JsonObject();
+ JsonObject totalAmounts = new JsonObject();
+
+ if (collectionInfoElement.isJsonObject()) {
+ personalAmounts = collectionInfoElement.getAsJsonObject();
+ }
+
+ for (Map.Entry<String, JsonElement> entry : personalAmounts.entrySet()) {
+ totalAmounts.addProperty(entry.getKey(), entry.getValue().getAsInt());
+ }
+
+ List<JsonObject> coopProfiles = getCoopProfileInformation(profileId);
+ if (coopProfiles != null) {
+ for (JsonObject coopProfile : coopProfiles) {
+ JsonElement coopCollectionInfoElement = Utils.getElement(coopProfile, "collection");
+ if (coopCollectionInfoElement != null && coopCollectionInfoElement.isJsonObject()) {
+ for (Map.Entry<String, JsonElement> entry : coopCollectionInfoElement.getAsJsonObject().entrySet()) {
+ float existing = Utils.getElementAsFloat(totalAmounts.get(entry.getKey()), 0);
+ totalAmounts.addProperty(entry.getKey(), existing + entry.getValue().getAsInt());
+ }
+ }
+ }
+ }
+
+ if (unlocked_coll_tiers_element.isJsonArray()) {
+ JsonArray unlocked_coll_tiers = unlocked_coll_tiers_element.getAsJsonArray();
+ for (int i = 0; i < unlocked_coll_tiers.size(); i++) {
+ String unlocked = unlocked_coll_tiers.get(i).getAsString();
+
+ Matcher matcher = COLL_TIER_PATTERN.matcher(unlocked);
+
+ if (matcher.find()) {
+ String tier_str = matcher.group(1);
+ int tier = Integer.parseInt(tier_str);
+ String coll = unlocked.substring(0, unlocked.length() - (matcher.group().length()));
+ if (!collectionTiers.has(coll) || collectionTiers.get(coll).getAsInt() < tier) {
+ collectionTiers.addProperty(coll, tier);
+ }
+ }
+ }
+ }
+
+ if (crafted_generators_element != null && crafted_generators_element.isJsonArray()) {
+ JsonArray crafted_generators = crafted_generators_element.getAsJsonArray();
+ for (int i = 0; i < crafted_generators.size(); i++) {
+ String unlocked = crafted_generators.get(i).getAsString();
+
+ Matcher matcher = COLL_TIER_PATTERN.matcher(unlocked);
+
+ if (matcher.find()) {
+ String tier_str = matcher.group(1);
+ int tier = Integer.parseInt(tier_str);
+ String coll = unlocked.substring(0, unlocked.length() - (matcher.group().length()));
+ if (!minionTiers.has(coll) || minionTiers.get(coll).getAsInt() < tier) {
+ minionTiers.addProperty(coll, tier);
+ }
+ }
+ }
+ }
+
+ JsonObject maxAmount = new JsonObject();
+ JsonObject updatedCollectionTiers = new JsonObject();
+ for (Map.Entry<String, JsonElement> totalAmountsEntry : totalAmounts.entrySet()) {
+ String collName = totalAmountsEntry.getKey();
+ int collTier = (int) Utils.getElementAsFloat(collectionTiers.get(collName), 0);
+
+ int currentAmount = (int) Utils.getElementAsFloat(totalAmounts.get(collName), 0);
+ if (currentAmount > 0) {
+ for (Map.Entry<String, JsonElement> resourceEntry : resourceCollectionInfo.entrySet()) {
+ JsonElement tiersElement = Utils.getElement(resourceEntry.getValue(), "items." + collName + ".tiers");
+ if (tiersElement != null && tiersElement.isJsonArray()) {
+ JsonArray tiers = tiersElement.getAsJsonArray();
+ int maxTierAcquired = -1;
+ int maxAmountRequired = -1;
+ for (int i = 0; i < tiers.size(); i++) {
+ JsonObject tierInfo = tiers.get(i).getAsJsonObject();
+ int tier = tierInfo.get("tier").getAsInt();
+ int amountRequired = tierInfo.get("amountRequired").getAsInt();
+ if (currentAmount >= amountRequired) {
+ maxTierAcquired = tier;
+ }
+ maxAmountRequired = amountRequired;
+ }
+ if (maxTierAcquired >= 0 && maxTierAcquired > collTier) {
+ updatedCollectionTiers.addProperty(collName, maxTierAcquired);
+ }
+ maxAmount.addProperty(collName, maxAmountRequired);
+ }
+ }
+ }
+ }
+
+ for (Map.Entry<String, JsonElement> collectionTiersEntry : updatedCollectionTiers.entrySet()) {
+ collectionTiers.add(collectionTiersEntry.getKey(), collectionTiersEntry.getValue());
+ }
+
+ collectionInfo.add("minion_tiers", minionTiers);
+ collectionInfo.add("max_amounts", maxAmount);
+ collectionInfo.add("personal_amounts", personalAmounts);
+ collectionInfo.add("total_amounts", totalAmounts);
+ collectionInfo.add("collection_tiers", collectionTiers);
+
+ return collectionInfo;
+ }
+
+ public PlayerStats.Stats getPassiveStats(String profileId) {
+ if (passiveStats.get(profileId) != null) return passiveStats.get(profileId);
+ JsonObject profileInfo = getProfileInformation(profileId);
+ if (profileInfo == null) return null;
+
+ PlayerStats.Stats passiveStats = PlayerStats.getPassiveBonuses(getSkillInfo(profileId), profileInfo);
+
+ if (passiveStats != null) {
+ passiveStats.add(PlayerStats.getBaseStats());
+ }
+
+ this.passiveStats.put(profileId, passiveStats);
+
+ return passiveStats;
+ }
+
+ public PlayerStats.Stats getStats(String profileId) {
+ //if(stats.get(profileId) != null) return stats.get(profileId);
+ JsonObject profileInfo = getProfileInformation(profileId);
+ if (profileInfo == null) {
+ return null;
+ }
+
+ PlayerStats.Stats stats =
+ PlayerStats.getStats(getSkillInfo(profileId), getInventoryInfo(profileId), getCollectionInfo(profileId),
+ getPetsInfo(profileId), profileInfo
+ );
+ this.stats.put(profileId, stats);
+ return stats;
+ }
+
+ public String getUuid() {
+ return uuid;
+ }
+
+ public @Nullable
+ JsonObject getHypixelProfile() {
+ if (uuidToHypixelProfile.containsKey(uuid)) return uuidToHypixelProfile.get(uuid);
+ return null;
+ }
+ }
+
+ private final HashMap<String, JsonObject> nameToHypixelProfile = new HashMap<>();
+ private final HashMap<String, JsonObject> uuidToHypixelProfile = new HashMap<>();
+ private final HashMap<String, Profile> uuidToProfileMap = new HashMap<>();
+
+ public void getHypixelProfile(String name, Consumer<JsonObject> callback) {
+ String nameF = name.toLowerCase();
+ HashMap<String, String> args = new HashMap<>();
+ args.put("name", "" + nameF);
+ manager.hypixelApi.getHypixelApiAsync(NotEnoughUpdates.INSTANCE.config.apiKey.apiKey, "player",
+ args, jsonObject -> {
+ if (jsonObject != null && jsonObject.has("success") && jsonObject.get("success").getAsBoolean()
+ && jsonObject.get("player").isJsonObject()) {
+ nameToUuid.put(nameF, jsonObject.get("player").getAsJsonObject().get("uuid").getAsString());
+ uuidToHypixelProfile.put(
+ jsonObject.get("player").getAsJsonObject().get("uuid").getAsString(),
+ jsonObject.get("player").getAsJsonObject()
+ );
+ if (callback != null) callback.accept(jsonObject);
+ } else {
+ if (callback != null) callback.accept(null);
+ }
+ }
+ );
+ }
+
+ private final HashMap<String, String> nameToUuid = new HashMap<>();
+
+ public void putNameUuid(String name, String uuid) {
+ nameToUuid.put(name, uuid);
+ }
+
+ public void getPlayerUUID(String name, Consumer<String> uuidCallback) {
+ String nameF = name.toLowerCase();
+ if (nameToUuid.containsKey(nameF)) {
+ uuidCallback.accept(nameToUuid.get(nameF));
+ return;
+ }
+
+ manager.hypixelApi.getApiAsync("https://api.mojang.com/users/profiles/minecraft/" + nameF,
+ (jsonObject) -> {
+ if (jsonObject.has("id") && jsonObject.get("id").isJsonPrimitive() &&
+ ((JsonPrimitive) jsonObject.get("id")).isString()) {
+ String uuid = jsonObject.get("id").getAsString();
+ nameToUuid.put(nameF, uuid);
+ uuidCallback.accept(uuid);
+ return;
+ }
+ uuidCallback.accept(null);
+ }, () -> uuidCallback.accept(null)
+ );
+ }
+
+ public void getProfileByName(String name, Consumer<Profile> callback) {
+ String nameF = name.toLowerCase();
+
+ if (nameToUuid.containsKey(nameF) && nameToUuid.get(nameF) == null) {
+ callback.accept(null);
+ return;
+ }
+
+ getPlayerUUID(nameF, (uuid) -> {
+ if (uuid == null) {
+ getHypixelProfile(nameF, jsonObject -> {
+ if (jsonObject != null) {
+ callback.accept(getProfileReset(nameToUuid.get(nameF), ignored -> {
+ }));
+ } else {
+ callback.accept(null);
+ nameToUuid.put(nameF, null);
+ }
+ });
+ } else {
+ if (!uuidToHypixelProfile.containsKey(uuid)) {
+ getHypixelProfile(nameF, jsonObject -> {
+ });
+ }
+ callback.accept(getProfileReset(uuid, ignored -> {
+ }));
+ }
+ });
+
+ return;
+ }
+
+ public Profile getProfileRaw(String uuid) {
+ return uuidToProfileMap.get(uuid);
+ }
+
+ public Profile getProfile(String uuid, Consumer<Profile> callback) {
+ Profile profile = uuidToProfileMap.computeIfAbsent(uuid, k -> new Profile(uuid));
+ if (profile.playerInformation != null) {
+ callback.accept(profile);
+ } else {
+ profile.getPlayerInformation(() -> callback.accept(profile));
+ }
+ return profile;
+ }
+
+ public Profile getProfileReset(String uuid, Consumer<Profile> callback) {
+ if (uuidToProfileMap.containsKey(uuid)) uuidToProfileMap.get(uuid).resetCache();
+ return getProfile(uuid, callback);
+ }
+
+ private static JsonObject resourceCollection = null;
+ private static final AtomicBoolean updatingResourceCollection = new AtomicBoolean(false);
+
+ public static JsonObject getResourceCollectionInformation() {
+ if (resourceCollection != null) return resourceCollection;
+ if (updatingResourceCollection.get()) return null;
+
+ updatingResourceCollection.set(true);
+
+ HashMap<String, String> args = new HashMap<>();
+ NotEnoughUpdates.INSTANCE.manager.hypixelApi.getHypixelApiAsync(
+ NotEnoughUpdates.INSTANCE.config.apiKey.apiKey,
+ "resources/skyblock/collections",
+ args,
+ jsonObject -> {
+ updatingResourceCollection.set(false);
+ if (jsonObject != null && jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) {
+ resourceCollection = jsonObject.get("collections").getAsJsonObject();
+ }
+ },
+ () -> updatingResourceCollection.set(false)
+ );
+
+ return null;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/recipes/CraftingOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/recipes/CraftingOverlay.java
new file mode 100644
index 00000000..d0b464f6
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/recipes/CraftingOverlay.java
@@ -0,0 +1,150 @@
+package io.github.moulberry.notenoughupdates.recipes;
+
+import io.github.moulberry.notenoughupdates.NEUManager;
+import io.github.moulberry.notenoughupdates.util.Utils;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.gui.Gui;
+import net.minecraft.client.gui.inventory.GuiChest;
+import net.minecraft.inventory.ContainerChest;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.client.event.GuiOpenEvent;
+import net.minecraftforge.client.event.GuiScreenEvent;
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+import org.lwjgl.input.Keyboard;
+
+import java.util.function.BiConsumer;
+
+public class CraftingOverlay {
+
+ private final NEUManager manager;
+ private CraftingRecipe currentRecipe = null;
+
+ public CraftingOverlay(NEUManager manager) {
+ this.manager = manager;
+ MinecraftForge.EVENT_BUS.register(this);
+ }
+
+ public void setShownRecipe(CraftingRecipe recipe) {
+ currentRecipe = recipe;
+ }
+
+ private void forEachSlot(ContainerChest chest, BiConsumer<Ingredient, Slot> block) {
+ for (int i = 0; i < 9; i++) {
+ Ingredient recipeIngredient = currentRecipe.getInputs()[i];
+ Slot slot = chest.inventorySlots.get(10 + 9 * (i / 3) + (i % 3));
+ block.accept(recipeIngredient, slot);
+ }
+ }
+
+ private void forEachHoveredSlot(
+ GuiChest gui,
+ ContainerChest chest,
+ int mouseX,
+ int mouseY,
+ BiConsumer<Ingredient, Slot> block
+ ) {
+ forEachSlot(chest, (recipeIngredient, slot) -> {
+ if (Utils.isWithinRect(
+ mouseX, mouseY,
+ slot.xDisplayPosition + gui.guiLeft,
+ slot.yDisplayPosition + gui.guiTop,
+ 16, 16
+ ))
+ block.accept(recipeIngredient, slot);
+ });
+ }
+
+ private void runIfCraftingOverlayIsPresent(Gui gui, BiConsumer<GuiChest, ContainerChest> block) {
+ if (currentRecipe == null) return;
+ if (!(gui instanceof GuiChest)) return;
+ GuiChest guiChest = (GuiChest) gui;
+ ContainerChest chest = (ContainerChest) guiChest.inventorySlots;
+ IInventory chestInventory = chest.getLowerChestInventory();
+ if (!"Craft Item".equals(chestInventory.getDisplayName().getUnformattedText())) return;
+ block.accept(guiChest, chest);
+ }
+
+ @SubscribeEvent
+ public void onGuiOpen(GuiOpenEvent event) {
+ currentRecipe = null;
+ }
+
+ @SubscribeEvent
+ public void onRender(GuiScreenEvent.DrawScreenEvent.Post event) {
+ runIfCraftingOverlayIsPresent(event.gui, (guiChest, chest) -> {
+ renderSlots(guiChest, chest);
+ if (currentRecipe.getCraftText() != null) {
+ FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj;
+ fontRenderer.drawStringWithShadow(
+ currentRecipe.getCraftText(),
+ Utils.peekGuiScale().getScaledWidth() / 2f - fontRenderer.getStringWidth(currentRecipe.getCraftText()) / 2f,
+ guiChest.guiTop - 15f, 0x808080
+ );
+ }
+ renderTooltip(guiChest, chest);
+ });
+ }
+
+ @SubscribeEvent
+ public void onKeyDown(GuiScreenEvent.KeyboardInputEvent.Pre event) {
+ if (!Keyboard.getEventKeyState() ||
+ (Keyboard.getEventKey() != Keyboard.KEY_U && Keyboard.getEventKey() != Keyboard.KEY_R))
+ return;
+ runIfCraftingOverlayIsPresent(event.gui, (guiChest, chest) -> {
+ int mouseX = Utils.getMouseX();
+ int mouseY = Utils.getMouseY();
+
+ forEachHoveredSlot(guiChest, chest, mouseX, mouseY, (recipeIngredient, slot) -> {
+ if (slot.getStack() == null && recipeIngredient != null) {
+ if (Keyboard.getEventKey() == Keyboard.KEY_R)
+ manager.showRecipe(recipeIngredient.getInternalItemId());
+ if (Keyboard.getEventKey() == Keyboard.KEY_U)
+ manager.displayGuiItemRecipe(recipeIngredient.getInternalItemId(), null);
+ }
+ });
+ });
+ }
+
+ private void renderTooltip(GuiChest guiChest, ContainerChest chest) {
+ int mouseX = Utils.getMouseX();
+ int mouseY = Utils.getMouseY();
+ forEachHoveredSlot(guiChest, chest, mouseX, mouseY, (recipeIngredient, slot) -> {
+ ItemStack actualItem = slot.getStack();
+ if (actualItem == null && recipeIngredient != null) {
+ Utils.drawHoveringText(
+ recipeIngredient.getItemStack().getTooltip(Minecraft.getMinecraft().thePlayer, false),
+ mouseX, mouseY,
+ Utils.peekGuiScale().getScaledWidth(), Utils.peekGuiScale().getScaledHeight(), -1,
+ Minecraft.getMinecraft().fontRendererObj
+ );
+ }
+ });
+ }
+
+ private void renderSlots(GuiChest guiChest, ContainerChest chest) {
+ forEachSlot(chest, (recipeIngredient, slot) -> {
+ ItemStack actualItem = slot.getStack();
+ if (actualItem != null && (recipeIngredient == null ||
+ !recipeIngredient.getInternalItemId().equals(manager.getInternalNameForItem(actualItem)) ||
+ actualItem.stackSize < recipeIngredient.getCount())) {
+ drawItemStack(guiChest, slot, actualItem);
+ }
+ if (recipeIngredient != null && actualItem == null) {
+ drawItemStack(guiChest, slot, recipeIngredient.getItemStack());
+ }
+ });
+ }
+
+ private void drawItemStack(GuiChest gui, Slot slot, ItemStack item) {
+ int slotX = slot.xDisplayPosition + gui.guiLeft;
+ int slotY = slot.yDisplayPosition + gui.guiTop;
+ Gui.drawRect(slotX, slotY, slotX + 16, slotY + 16, 0x64ff0000);
+ if (item != null)
+ Utils.drawItemStack(item, slotX, slotY);
+ }
+
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/recipes/CraftingRecipe.java b/src/main/java/io/github/moulberry/notenoughupdates/recipes/CraftingRecipe.java
new file mode 100644
index 00000000..576cbbd4
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/recipes/CraftingRecipe.java
@@ -0,0 +1,146 @@
+package io.github.moulberry.notenoughupdates.recipes;
+
+import com.google.common.collect.Sets;
+import com.google.gson.JsonObject;
+import io.github.moulberry.notenoughupdates.NEUManager;
+import io.github.moulberry.notenoughupdates.miscgui.GuiItemRecipe;
+import io.github.moulberry.notenoughupdates.util.Utils;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.ResourceLocation;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+public class CraftingRecipe implements NeuRecipe {
+
+ public static final ResourceLocation BACKGROUND = new ResourceLocation("textures/gui/container/crafting_table.png");
+
+ private static final int EXTRA_STRING_X = 132;
+ private static final int EXTRA_STRING_Y = 25;
+
+ private final NEUManager manager;
+ private final Ingredient[] inputs;
+ private final String extraText;
+ private final Ingredient outputIngredient;
+ private List<RecipeSlot> slots;
+
+ public CraftingRecipe(NEUManager manager, Ingredient[] inputs, Ingredient output, String extra) {
+ this.manager = manager;
+ this.inputs = inputs;
+ this.outputIngredient = output;
+ this.extraText = extra;
+ if (inputs.length != 9)
+ throw new IllegalArgumentException("Cannot construct crafting recipe with non standard crafting grid size");
+ }
+
+ @Override
+ public Set<Ingredient> getIngredients() {
+ Set<Ingredient> ingredients = Sets.newHashSet(inputs);
+ ingredients.remove(null);
+ return ingredients;
+ }
+
+ @Override
+ public boolean hasVariableCost() {
+ return false;
+ }
+
+ @Override
+ public Set<Ingredient> getOutputs() {
+ return Collections.singleton(getOutput());
+ }
+
+ public Ingredient getOutput() {
+ return outputIngredient;
+ }
+
+ public Ingredient[] getInputs() {
+ return inputs;
+ }
+
+ @Override
+ public List<RecipeSlot> getSlots() {
+ if (slots != null) return slots;
+ slots = new ArrayList<>();
+ for (int x = 0; x < 3; x++) {
+ for (int y = 0; y < 3; y++) {
+ Ingredient input = inputs[x + y * 3];
+ if (input == null) continue;
+ ItemStack item = input.getItemStack();
+ if (item == null) continue;
+ slots.add(new RecipeSlot(30 + x * GuiItemRecipe.SLOT_SPACING, 17 + y * GuiItemRecipe.SLOT_SPACING, item));
+ }
+ }
+ slots.add(new RecipeSlot(124, 35, outputIngredient.getItemStack()));
+ return slots;
+ }
+
+ public String getCraftText() {
+ return extraText;
+ }
+
+ @Override
+ public ResourceLocation getBackground() {
+ return BACKGROUND;
+ }
+
+ @Override
+ public void drawExtraInfo(GuiItemRecipe gui, int mouseX, int mouseY) {
+ FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj;
+
+ String craftingText = getCraftText();
+ if (craftingText != null)
+ Utils.drawStringCenteredScaledMaxWidth(craftingText, fontRenderer,
+ gui.guiLeft + EXTRA_STRING_X, gui.guiTop + EXTRA_STRING_Y, false, 75, 0x404040
+ );
+ }
+
+ @Override
+ public JsonObject serialize() {
+ JsonObject object = new JsonObject();
+ object.addProperty("type", "crafting");
+ object.addProperty("count", outputIngredient.getCount());
+ object.addProperty("overrideOutputId", outputIngredient.getInternalItemId());
+ for (int i = 0; i < 9; i++) {
+ Ingredient ingredient = inputs[i];
+ if (ingredient == null) continue;
+ String[] x = {"1", "2", "3"};
+ String[] y = {"A", "B", "C"};
+ String name = x[i / 3] + y[i % 3];
+ object.addProperty(name, ingredient.serialize());
+ }
+ if (extraText != null)
+ object.addProperty("crafttext", extraText);
+ return object;
+ }
+
+ public static CraftingRecipe parseCraftingRecipe(NEUManager manager, JsonObject recipe, JsonObject outputItem) {
+ Ingredient[] craftMatrix = new Ingredient[9];
+
+ String[] x = {"1", "2", "3"};
+ String[] y = {"A", "B", "C"};
+ for (int i = 0; i < 9; i++) {
+ String name = y[i / 3] + x[i % 3];
+ if (!recipe.has(name)) continue;
+ String item = recipe.get(name).getAsString();
+ if (item == null || item.isEmpty()) continue;
+ craftMatrix[i] = new Ingredient(manager, item);
+ }
+ int resultCount = 1;
+ if (recipe.has("count"))
+ resultCount = recipe.get("count").getAsInt();
+ String extra = null;
+ if (outputItem.has("crafttext"))
+ extra = outputItem.get("crafttext").getAsString();
+ if (recipe.has("crafttext"))
+ extra = recipe.get("crafttext").getAsString();
+ String outputItemId = outputItem.get("internalname").getAsString();
+ if (recipe.has("overrideOutputId"))
+ outputItemId = recipe.get("overrideOutputId").getAsString();
+ return new CraftingRecipe(manager, craftMatrix, new Ingredient(manager, outputItemId, resultCount), extra);
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/recipes/ForgeRecipe.java b/src/main/java/io/github/moulberry/notenoughupdates/recipes/ForgeRecipe.java
new file mode 100644
index 00000000..c971d82a
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/recipes/ForgeRecipe.java
@@ -0,0 +1,256 @@
+package io.github.moulberry.notenoughupdates.recipes;
+
+import com.google.common.collect.Sets;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+import io.github.moulberry.notenoughupdates.NEUManager;
+import io.github.moulberry.notenoughupdates.miscgui.GuiItemRecipe;
+import io.github.moulberry.notenoughupdates.util.HotmInformation;
+import io.github.moulberry.notenoughupdates.util.Utils;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.ResourceLocation;
+
+import java.util.*;
+
+public class ForgeRecipe implements NeuRecipe {
+
+ private static final ResourceLocation BACKGROUND =
+ new ResourceLocation("notenoughupdates", "textures/gui/forge_recipe.png");
+
+ private static final int SLOT_IMAGE_U = 176;
+ private static final int SLOT_IMAGE_V = 0;
+ private static final int SLOT_IMAGE_SIZE = 18;
+ private static final int SLOT_PADDING = 1;
+ private static final int EXTRA_INFO_MAX_WIDTH = 75;
+ public static final int EXTRA_INFO_X = 132;
+ public static final int EXTRA_INFO_Y = 25;
+
+ public enum ForgeType {
+ REFINING, ITEM_FORGING
+ }
+
+ private final NEUManager manager;
+ private final List<Ingredient> inputs;
+ private final Ingredient output;
+ private final int hotmLevel;
+ private final int timeInSeconds; // TODO: quick forge
+ private List<RecipeSlot> slots;
+
+ public ForgeRecipe(
+ NEUManager manager,
+ List<Ingredient> inputs,
+ Ingredient output,
+ int durationInSeconds,
+ int hotmLevel
+ ) {
+ this.manager = manager;
+ this.inputs = inputs;
+ this.output = output;
+ this.hotmLevel = hotmLevel;
+ this.timeInSeconds = durationInSeconds;
+ }
+
+ public List<Ingredient> getInputs() {
+ return inputs;
+ }
+
+ public Ingredient getOutput() {
+ return output;
+ }
+
+ public int getHotmLevel() {
+ return hotmLevel;
+ }
+
+ public int getTimeInSeconds() {
+ return timeInSeconds;
+ }
+
+ @Override
+ public ResourceLocation getBackground() {
+ return BACKGROUND;
+ }
+
+ @Override
+ public Set<Ingredient> getIngredients() {
+ return Sets.newHashSet(inputs);
+ }
+
+ @Override
+ public boolean hasVariableCost() {
+ return false;
+ }
+
+ @Override
+ public Set<Ingredient> getOutputs() {
+ return Collections.singleton(output);
+ }
+
+ @Override
+ public List<RecipeSlot> getSlots() {
+ if (slots != null) return slots;
+ slots = new ArrayList<>();
+ for (int i = 0; i < inputs.size(); i++) {
+ Ingredient input = inputs.get(i);
+ ItemStack itemStack = input.getItemStack();
+ if (itemStack == null) continue;
+ int[] slotCoordinates = getSlotCoordinates(i, inputs.size());
+ slots.add(new RecipeSlot(slotCoordinates[0], slotCoordinates[1], itemStack));
+ }
+ slots.add(new RecipeSlot(124, 35, output.getItemStack()));
+ return slots;
+ }
+
+ @Override
+ public void drawExtraBackground(GuiItemRecipe gui, int mouseX, int mouseY) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(BACKGROUND);
+ for (int i = 0; i < inputs.size(); i++) {
+ int[] slotCoordinates = getSlotCoordinates(i, inputs.size());
+ gui.drawTexturedModalRect(
+ gui.guiLeft + slotCoordinates[0] - SLOT_PADDING, gui.guiTop + slotCoordinates[1] - SLOT_PADDING,
+ SLOT_IMAGE_U, SLOT_IMAGE_V,
+ SLOT_IMAGE_SIZE, SLOT_IMAGE_SIZE
+ );
+ }
+ }
+
+ @Override
+ public void drawExtraInfo(GuiItemRecipe gui, int mouseX, int mouseY) {
+ FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj;
+ if (timeInSeconds > 0)
+ Utils.drawStringCenteredScaledMaxWidth(
+ formatDuration(timeInSeconds),
+ fontRenderer,
+ gui.guiLeft + EXTRA_INFO_X,
+ gui.guiTop + EXTRA_INFO_Y,
+ false,
+ EXTRA_INFO_MAX_WIDTH,
+ 0xff00ff
+ );
+ }
+
+ @Override
+ public void drawHoverInformation(GuiItemRecipe gui, int mouseX, int mouseY) {
+ manager.hotm.getInformationOnCurrentProfile().ifPresent(hotmTree -> {
+ if (timeInSeconds > 0 && gui.isWithinRect(
+ mouseX, mouseY,
+ gui.guiLeft + EXTRA_INFO_X - EXTRA_INFO_MAX_WIDTH / 2,
+ gui.guiTop + EXTRA_INFO_Y - 8,
+ EXTRA_INFO_MAX_WIDTH, 16
+ )) {
+ int qf = hotmTree.getLevel("forge_time");
+ int reducedTime = getReducedTime(qf);
+ if (qf > 0) {
+
+ Utils.drawHoveringText(
+ Arrays.asList(
+ EnumChatFormatting.YELLOW + formatDuration(reducedTime) + " with Quick Forge (Level " + qf + ")"),
+ mouseX,
+ mouseY,
+ gui.width,
+ gui.height,
+ 500,
+ Minecraft.getMinecraft().fontRendererObj
+ );
+ }
+ }
+ });
+ }
+
+ public int getReducedTime(int quickForgeUpgradeLevel) {
+ return HotmInformation.getQuickForgeMultiplier(quickForgeUpgradeLevel) * timeInSeconds / 1000;
+ }
+
+ @Override
+ public JsonObject serialize() {
+ JsonObject object = new JsonObject();
+ JsonArray ingredients = new JsonArray();
+ for (Ingredient input : inputs) {
+ ingredients.add(new JsonPrimitive(input.serialize()));
+ }
+ object.addProperty("type", "forge");
+ object.add("inputs", ingredients);
+ object.addProperty("count", output.getCount());
+ object.addProperty("overrideOutputId", output.getInternalItemId());
+ if (hotmLevel >= 0)
+ object.addProperty("hotmLevel", hotmLevel);
+ if (timeInSeconds >= 0)
+ object.addProperty("duration", timeInSeconds);
+ return object;
+ }
+
+ static ForgeRecipe parseForgeRecipe(NEUManager manager, JsonObject recipe, JsonObject output) {
+ List<Ingredient> ingredients = new ArrayList<>();
+ for (JsonElement element : recipe.getAsJsonArray("inputs")) {
+ String ingredientString = element.getAsString();
+ ingredients.add(new Ingredient(manager, ingredientString));
+ }
+ String internalItemId = output.get("internalname").getAsString();
+ if (recipe.has("overrideOutputId"))
+ internalItemId = recipe.get("overrideOutputId").getAsString();
+ int resultCount = 1;
+ if (recipe.has("count")) {
+ resultCount = recipe.get("count").getAsInt();
+ }
+ int duration = -1;
+ if (recipe.has("duration")) {
+ duration = recipe.get("duration").getAsInt();
+ }
+ int hotmLevel = -1;
+ if (recipe.has("hotmLevel")) {
+ hotmLevel = recipe.get("hotmLevel").getAsInt();
+ }
+ return new ForgeRecipe(
+ manager,
+ ingredients,
+ new Ingredient(manager, internalItemId, resultCount),
+ duration,
+ hotmLevel
+ );
+ }
+
+ private static final int RECIPE_CENTER_X = 40;
+ private static final int RECIPE_CENTER_Y = 34;
+ private static final int SLOT_DISTANCE_FROM_CENTER = 22;
+ private static final int RECIPE_FALLBACK_X = 20;
+ private static final int RECIPE_FALLBACK_Y = 15;
+
+ static int[] getSlotCoordinates(int slotNumber, int totalSlotCount) {
+ if (totalSlotCount > 6) {
+ return new int[]{
+ RECIPE_FALLBACK_X + (slotNumber % 4) * GuiItemRecipe.SLOT_SPACING,
+ RECIPE_FALLBACK_Y + (slotNumber / 4) * GuiItemRecipe.SLOT_SPACING,
+ };
+ }
+ if (totalSlotCount == 1) {
+ return new int[]{
+ RECIPE_CENTER_X - GuiItemRecipe.SLOT_SIZE / 2,
+ RECIPE_CENTER_Y - GuiItemRecipe.SLOT_SIZE / 2
+ };
+ }
+ double rad = Math.PI * 2 * slotNumber / totalSlotCount;
+ int x = (int) (Math.cos(rad) * SLOT_DISTANCE_FROM_CENTER);
+ int y = (int) (Math.sin(rad) * SLOT_DISTANCE_FROM_CENTER);
+ return new int[]{RECIPE_CENTER_X + x, RECIPE_CENTER_Y + y};
+ }
+
+ static String formatDuration(int seconds) {
+ int minutes = seconds / 60;
+ seconds %= 60;
+ int hours = minutes / 60;
+ minutes %= 60;
+ int days = hours / 24;
+ hours %= 24;
+ StringBuilder sB = new StringBuilder();
+ if (days != 0) sB.append(days).append("d ");
+ if (hours != 0) sB.append(hours).append("h ");
+ if (minutes != 0) sB.append(minutes).append("m ");
+ if (seconds != 0) sB.append(seconds).append("s ");
+ return sB.substring(0, sB.length() - 1);
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/recipes/Ingredient.java b/src/main/java/io/github/moulberry/notenoughupdates/recipes/Ingredient.java
new file mode 100644
index 00000000..79b548da
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/recipes/Ingredient.java
@@ -0,0 +1,91 @@
+package io.github.moulberry.notenoughupdates.recipes;
+
+import com.google.gson.JsonObject;
+import io.github.moulberry.notenoughupdates.NEUManager;
+import io.github.moulberry.notenoughupdates.util.Utils;
+import net.minecraft.init.Items;
+import net.minecraft.item.ItemStack;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+public class Ingredient {
+
+ public static final String SKYBLOCK_COIN = "SKYBLOCK_COIN";
+ private final int count;
+ private final String internalItemId;
+ private final NEUManager manager;
+ private ItemStack itemStack;
+
+ public Ingredient(NEUManager manager, String ingredientIdentifier) {
+ this.manager = manager;
+ String[] parts = ingredientIdentifier.split(":");
+ internalItemId = parts[0];
+ if (parts.length == 2) {
+ count = Integer.parseInt(parts[1]);
+ } else if (parts.length == 1) {
+ count = 1;
+ } else {
+ throw new IllegalArgumentException("Could not parse ingredient " + ingredientIdentifier);
+ }
+ }
+
+ public Ingredient(NEUManager manager, String internalItemId, int count) {
+ this.manager = manager;
+ this.count = count;
+ this.internalItemId = internalItemId;
+ }
+
+ private Ingredient(NEUManager manager, int coinValue) {
+ this.manager = manager;
+ this.internalItemId = SKYBLOCK_COIN;
+ this.count = coinValue;
+ }
+
+ public static Set<Ingredient> mergeIngredients(Iterable<Ingredient> ingredients) {
+ Map<String, Ingredient> newIngredients = new HashMap<>();
+ for (Ingredient i : ingredients) {
+ newIngredients.merge(
+ i.getInternalItemId(),
+ i,
+ (a, b) -> new Ingredient(i.manager, i.internalItemId, a.count + b.count)
+ );
+ }
+ return new HashSet<>(newIngredients.values());
+ }
+
+ public static Ingredient coinIngredient(NEUManager manager, int coins) {
+ return new Ingredient(manager, coins);
+ }
+
+ public boolean isCoins() {
+ return "SKYBLOCK_COIN".equals(internalItemId);
+ }
+
+ public int getCount() {
+ return count;
+ }
+
+ public String getInternalItemId() {
+ return internalItemId;
+ }
+
+ public ItemStack getItemStack() {
+ if (itemStack != null) return itemStack;
+ if (isCoins()) {
+ itemStack = new ItemStack(Items.gold_nugget);
+ itemStack.setStackDisplayName("\u00A7r\u00A76" + Utils.formatNumberWithDots(getCount()) + " Coins");
+ return itemStack;
+ }
+ JsonObject itemInfo = manager.getItemInformation().get(internalItemId);
+ itemStack = manager.jsonToStack(itemInfo);
+ itemStack.stackSize = count;
+ return itemStack;
+ }
+
+ public String serialize() {
+ return internalItemId + ":" + count;
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/recipes/NeuRecipe.java b/src/main/java/io/github/moulberry/notenoughupdates/recipes/NeuRecipe.java
new file mode 100644
index 00000000..3516f707
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/recipes/NeuRecipe.java
@@ -0,0 +1,52 @@
+package io.github.moulberry.notenoughupdates.recipes;
+
+import com.google.gson.JsonObject;
+import io.github.moulberry.notenoughupdates.NEUManager;
+import io.github.moulberry.notenoughupdates.miscgui.GuiItemRecipe;
+import net.minecraft.util.ResourceLocation;
+
+import java.util.List;
+import java.util.Set;
+
+public interface NeuRecipe {
+ Set<Ingredient> getIngredients();
+
+ Set<Ingredient> getOutputs();
+
+ List<RecipeSlot> getSlots();
+
+ default void drawExtraInfo(GuiItemRecipe gui, int mouseX, int mouseY) {
+ }
+
+ default void drawExtraBackground(GuiItemRecipe gui, int mouseX, int mouseY) {
+ }
+
+ default void drawHoverInformation(GuiItemRecipe gui, int mouseX, int mouseY) {
+ }
+
+ boolean hasVariableCost();
+
+ JsonObject serialize();
+
+ ResourceLocation getBackground();
+
+ static NeuRecipe parseRecipe(NEUManager manager, JsonObject recipe, JsonObject output) {
+ if (recipe.has("type")) {
+ switch (recipe.get("type").getAsString().intern()) {
+ case "forge":
+ return ForgeRecipe.parseForgeRecipe(manager, recipe, output);
+ case "trade":
+ return VillagerTradeRecipe.parseStaticRecipe(manager, recipe);
+ }
+ }
+ return CraftingRecipe.parseCraftingRecipe(manager, recipe, output);
+ }
+
+ default boolean shouldUseForCraftCost() {
+ return true;
+ }
+
+ default boolean isAvailable() {
+ return true;
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/recipes/RecipeGenerator.java b/src/main/java/io/github/moulberry/notenoughupdates/recipes/RecipeGenerator.java
new file mode 100644
index 00000000..46aff6c4
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/recipes/RecipeGenerator.java
@@ -0,0 +1,192 @@
+package io.github.moulberry.notenoughupdates.recipes;
+
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.util.Debouncer;
+import io.github.moulberry.notenoughupdates.util.Utils;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.entity.EntityPlayerSP;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.client.gui.inventory.GuiChest;
+import net.minecraft.inventory.ContainerChest;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.ChatComponentText;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+import net.minecraftforge.fml.common.gameevent.TickEvent;
+import org.lwjgl.input.Keyboard;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class RecipeGenerator {
+ public static final String DURATION = "Duration: ";
+ public static final String COINS_SUFFIX = " Coins";
+
+ private final NotEnoughUpdates neu;
+
+ private final Map<String, String> savedForgingDurations = new HashMap<>();
+
+ private final Debouncer debouncer = new Debouncer(1000 * 1000 * 50 /* 50 ms */);
+ private final Debouncer durationDebouncer = new Debouncer(1000 * 1000 * 500);
+
+ public RecipeGenerator(NotEnoughUpdates neu) {
+ this.neu = neu;
+ }
+
+ @SubscribeEvent
+ public void onTick(TickEvent event) {
+ if (!neu.config.hidden.enableItemEditing) return;
+ GuiScreen currentScreen = Minecraft.getMinecraft().currentScreen;
+ if (currentScreen == null) return;
+ if (!(currentScreen instanceof GuiChest)) return;
+ analyzeUI((GuiChest) currentScreen);
+ }
+
+ private boolean shouldSaveRecipe() {
+ return Keyboard.isKeyDown(Keyboard.KEY_O) && debouncer.trigger();
+ }
+
+ public void analyzeUI(GuiChest gui) {
+ ContainerChest container = (ContainerChest) gui.inventorySlots;
+ IInventory menu = container.getLowerChestInventory();
+ String uiTitle = menu.getDisplayName().getUnformattedText();
+ EntityPlayerSP p = Minecraft.getMinecraft().thePlayer;
+ if (uiTitle.startsWith("Item Casting") || uiTitle.startsWith("Refine")) {
+ if (durationDebouncer.trigger())
+ parseAllForgeItemMetadata(menu);
+ }
+ boolean saveRecipe = shouldSaveRecipe();
+ if (uiTitle.equals("Confirm Process") && saveRecipe) {
+ ForgeRecipe recipe = parseSingleForgeRecipe(menu);
+ if (recipe == null) {
+ p.addChatMessage(new ChatComponentText(
+ "" + EnumChatFormatting.DARK_RED + EnumChatFormatting.BOLD + "Could not parse recipe for this UI"));
+ } else {
+ p.addChatMessage(new ChatComponentText(
+ "" + EnumChatFormatting.GREEN + EnumChatFormatting.BOLD + "Parsed recipe:"));
+ p.addChatMessage(new ChatComponentText("" + EnumChatFormatting.AQUA + " Inputs:"));
+ for (Ingredient i : recipe.getInputs())
+ p.addChatMessage(new ChatComponentText(
+ " - " + EnumChatFormatting.AQUA + i.getInternalItemId() + " x " + i.getCount()));
+ p.addChatMessage(new ChatComponentText("" + EnumChatFormatting.AQUA + " Output: " + EnumChatFormatting.GOLD +
+ recipe.getOutput().getInternalItemId() + " x " + recipe.getOutput().getCount()));
+ p.addChatMessage(new ChatComponentText(
+ "" + EnumChatFormatting.AQUA + " Time: " + EnumChatFormatting.GRAY + recipe.getTimeInSeconds() +
+ " seconds (no QF) ."));
+ boolean saved = false;
+ try {
+ saved = saveRecipe(recipe);
+ } catch (IOException e) {
+ }
+ if (!saved)
+ p.addChatMessage(new ChatComponentText("" +
+ EnumChatFormatting.DARK_RED + EnumChatFormatting.BOLD + EnumChatFormatting.OBFUSCATED + "#" +
+ EnumChatFormatting.RESET + EnumChatFormatting.DARK_RED + EnumChatFormatting.BOLD + " ERROR " +
+ EnumChatFormatting.DARK_RED + EnumChatFormatting.BOLD + EnumChatFormatting.OBFUSCATED + "#" +
+ EnumChatFormatting.RESET + EnumChatFormatting.DARK_RED + EnumChatFormatting.BOLD +
+ " Failed to save recipe. Does the item already exist?"));
+ }
+ }
+ }
+
+ public boolean saveRecipe(NeuRecipe recipe) throws IOException {
+ JsonObject recipeJson = recipe.serialize();
+ for (Ingredient i : recipe.getOutputs()) {
+ if (i.isCoins()) continue;
+ JsonObject outputJson = neu.manager.readJsonDefaultDir(i.getInternalItemId() + ".json");
+ if (outputJson == null) return false;
+ outputJson.addProperty("clickcommand", "viewrecipe");
+ JsonArray array = new JsonArray();
+ array.add(recipeJson);
+ outputJson.add("recipes", array);
+ neu.manager.writeJsonDefaultDir(outputJson, i.getInternalItemId() + ".json");
+ neu.manager.loadItem(i.getInternalItemId());
+ }
+ return true;
+ }
+
+ public ForgeRecipe parseSingleForgeRecipe(IInventory chest) {
+ int durationInSeconds = -1;
+ List<Ingredient> inputs = new ArrayList<>();
+ Ingredient output = null;
+ for (int i = 0; i < chest.getSizeInventory(); i++) {
+ int col = i % 9;
+ ItemStack itemStack = chest.getStackInSlot(i);
+ if (itemStack == null) continue;
+ String name = Utils.cleanColour(itemStack.getDisplayName());
+ String internalId = neu.manager.getInternalNameForItem(itemStack);
+ Ingredient ingredient = null;
+ if (itemStack.getDisplayName().endsWith(COINS_SUFFIX)) {
+ int coinCost = Integer.parseInt(
+ name.substring(0, name.length() - COINS_SUFFIX.length())
+ .replace(",", ""));
+ ingredient = Ingredient.coinIngredient(neu.manager, coinCost);
+ } else if (internalId != null) {
+ ingredient = new Ingredient(neu.manager, internalId, itemStack.stackSize);
+ }
+ if (ingredient == null) continue;
+ if (col < 4) {
+ inputs.add(ingredient);
+ } else {
+ output = ingredient;
+ }
+ }
+ if (output == null || inputs.isEmpty()) return null;
+ if (savedForgingDurations.containsKey(output.getInternalItemId()))
+ durationInSeconds = parseDuration(savedForgingDurations.get(output.getInternalItemId()));
+ return new ForgeRecipe(
+ neu.manager,
+ new ArrayList<>(Ingredient.mergeIngredients(inputs)),
+ output,
+ durationInSeconds,
+ -1
+ );
+ }
+
+ private static final Map<Character, Integer> durationSuffixLengthMap = new HashMap<Character, Integer>() {{
+ put('d', 60 * 60 * 24);
+ put('h', 60 * 60);
+ put('m', 60);
+ put('s', 1);
+ }};
+
+ public int parseDuration(String durationString) {
+ String[] parts = durationString.split(" ");
+ int timeInSeconds = 0;
+ for (String part : parts) {
+ char signifier = part.charAt(part.length() - 1);
+ int value = Integer.parseInt(part.substring(0, part.length() - 1));
+ if (!durationSuffixLengthMap.containsKey(signifier)) {
+ return -1;
+ }
+ timeInSeconds += value * durationSuffixLengthMap.get(signifier);
+ }
+ return timeInSeconds;
+ }
+
+ private void parseAllForgeItemMetadata(IInventory chest) {
+ for (int i = 0; i < chest.getSizeInventory(); i++) {
+ ItemStack stack = chest.getStackInSlot(i);
+ if (stack == null) continue;
+ String internalName = neu.manager.getInternalNameForItem(stack);
+ if (internalName == null) continue;
+ List<String> tooltip = stack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ String durationInfo = null;
+ for (String s : tooltip) {
+ String info = Utils.cleanColour(s);
+ if (info.startsWith(DURATION)) {
+ durationInfo = info.substring(DURATION.length());
+ }
+ }
+ if (durationInfo != null)
+ savedForgingDurations.put(internalName, durationInfo);
+ }
+ }
+
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/recipes/RecipeSlot.java b/src/main/java/io/github/moulberry/notenoughupdates/recipes/RecipeSlot.java
new file mode 100644
index 00000000..61f8ef27
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/recipes/RecipeSlot.java
@@ -0,0 +1,28 @@
+package io.github.moulberry.notenoughupdates.recipes;
+
+import io.github.moulberry.notenoughupdates.miscgui.GuiItemRecipe;
+import net.minecraft.item.ItemStack;
+
+public class RecipeSlot {
+ private final int x;
+ private final int y;
+ private final ItemStack itemStack;
+
+ public RecipeSlot(int x, int y, ItemStack itemStack) {
+ this.x = x;
+ this.y = y;
+ this.itemStack = itemStack;
+ }
+
+ public ItemStack getItemStack() {
+ return itemStack;
+ }
+
+ public int getX(GuiItemRecipe recipe) {
+ return recipe.guiLeft + x;
+ }
+
+ public int getY(GuiItemRecipe recipe) {
+ return recipe.guiTop + y;
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/recipes/VillagerTradeRecipe.java b/src/main/java/io/github/moulberry/notenoughupdates/recipes/VillagerTradeRecipe.java
new file mode 100644
index 00000000..371d4f3c
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/recipes/VillagerTradeRecipe.java
@@ -0,0 +1,156 @@
+package io.github.moulberry.notenoughupdates.recipes;
+
+import com.google.common.collect.Sets;
+import com.google.gson.JsonObject;
+import com.mojang.authlib.GameProfile;
+import io.github.moulberry.notenoughupdates.NEUManager;
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.miscgui.GuiItemRecipe;
+import io.github.moulberry.notenoughupdates.util.SBInfo;
+import io.github.moulberry.notenoughupdates.util.Utils;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.entity.AbstractClientPlayer;
+import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.gui.inventory.GuiInventory;
+import net.minecraft.client.network.NetworkPlayerInfo;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.passive.EntityVillager;
+import net.minecraft.util.ResourceLocation;
+
+import java.util.*;
+
+public class VillagerTradeRecipe implements NeuRecipe {
+
+ public static final int COST_SLOT_X = 51;
+ public static final int COST_SLOT_Y = 34;
+ public static final int RESULT_SLOT_Y = 35;
+ public static final int RESULT_SLOT_X = 124;
+
+ private static class Holder { // This holder object exists to defer initialization to first access
+ private static final GameProfile DREAM_PROFILE =
+ new GameProfile(UUID.fromString("ec70bcaf-702f-4bb8-b48d-276fa52a780c"), "Dream");
+ private static final EntityLivingBase DEMO_DREAM = new AbstractClientPlayer(null, DREAM_PROFILE) {
+ @Override
+ protected NetworkPlayerInfo getPlayerInfo() {
+ return new NetworkPlayerInfo(DREAM_PROFILE) {
+ @Override
+ public ResourceLocation getLocationSkin() {
+ return new ResourceLocation("notenoughupdates", "dreamskin.png");
+ }
+ };
+ }
+ };
+ private static final EntityLivingBase DEMO_VILLAGER = new EntityVillager(null);
+
+ private static boolean isAprilFirst() {
+ Calendar cal = Calendar.getInstance();
+ return cal.get(Calendar.DAY_OF_MONTH) == 1 && cal.get(Calendar.MONTH) == Calendar.APRIL;
+ }
+
+ private static final EntityLivingBase DEMO_ENTITY = isAprilFirst() ? DEMO_DREAM : DEMO_VILLAGER;
+
+ }
+
+ private final static ResourceLocation BACKGROUND =
+ new ResourceLocation("notenoughupdates", "textures/gui/villager_recipe.png");
+
+ private final Ingredient result;
+ private final Ingredient cost;
+ private final int minCost, maxCost;
+
+ public VillagerTradeRecipe(Ingredient result, Ingredient cost, int minCost, int maxCost) {
+ this.result = result;
+ this.cost = cost;
+ this.minCost = minCost;
+ this.maxCost = maxCost;
+ }
+
+ public VillagerTradeRecipe(Ingredient result, Ingredient cost) {
+ this(result, cost, -1, -1);
+ }
+
+ public boolean hasVariableCost() {
+ return minCost != -1 && maxCost != -1;
+ }
+
+ @Override
+ public Set<Ingredient> getIngredients() {
+ return Sets.newHashSet(cost);
+ }
+
+ @Override
+ public Set<Ingredient> getOutputs() {
+ return Sets.newHashSet(result);
+ }
+
+ @Override
+ public List<RecipeSlot> getSlots() {
+ return Arrays.asList(
+ new RecipeSlot(COST_SLOT_X, COST_SLOT_Y, cost.getItemStack()),
+ new RecipeSlot(RESULT_SLOT_X, RESULT_SLOT_Y, result.getItemStack())
+ );
+ }
+
+ @Override
+ public boolean shouldUseForCraftCost() {
+ return false;
+ }
+
+ @Override
+ public boolean isAvailable() {
+ return SBInfo.getInstance().getCurrentMode() == SBInfo.Gamemode.STRANDED ||
+ NotEnoughUpdates.INSTANCE.config.hidden.dev;
+ }
+
+ @Override
+ public void drawExtraInfo(GuiItemRecipe gui, int mouseX, int mouseY) {
+ if (hasVariableCost()) {
+ FontRenderer fontRenderer = Minecraft.getMinecraft().fontRendererObj;
+ Utils.drawStringCenteredScaledMaxWidth(
+ minCost + " - " + maxCost, fontRenderer,
+ gui.guiLeft + 50, gui.guiTop + 60, false, 75, 0xff00ff
+ );
+
+ }
+ }
+
+ @Override
+ public void drawExtraBackground(GuiItemRecipe gui, int mouseX, int mouseY) {
+ GuiInventory.drawEntityOnScreen(
+ gui.guiLeft + 90,
+ gui.guiTop + 75,
+ 30,
+ gui.guiLeft - mouseX + 80,
+ gui.guiTop + 60 - mouseY,
+ Holder.DEMO_ENTITY
+ );
+ }
+
+ @Override
+ public JsonObject serialize() {
+ JsonObject jsonObject = new JsonObject();
+ jsonObject.addProperty("type", "trade");
+ jsonObject.addProperty("result", result.serialize());
+ jsonObject.addProperty("cost", cost.getInternalItemId());
+ if (minCost > 0)
+ jsonObject.addProperty("min", minCost);
+ if (maxCost > 0)
+ jsonObject.addProperty("max", maxCost);
+ return jsonObject;
+ }
+
+ @Override
+ public ResourceLocation getBackground() {
+ return BACKGROUND;
+ }
+
+ public static VillagerTradeRecipe parseStaticRecipe(NEUManager manager, JsonObject recipe) {
+ return new VillagerTradeRecipe(
+ new Ingredient(manager, recipe.get("result").getAsString()),
+ new Ingredient(manager, recipe.get("cost").getAsString()),
+ recipe.has("min") ? recipe.get("min").getAsInt() : -1,
+ recipe.has("max") ? recipe.get("max").getAsInt() : -1
+ );
+ }
+
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/AllowEmptyHTMLTag.java b/src/main/java/io/github/moulberry/notenoughupdates/util/AllowEmptyHTMLTag.java
index e6baff16..b7fc55e4 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/AllowEmptyHTMLTag.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/AllowEmptyHTMLTag.java
@@ -10,65 +10,65 @@ import java.util.List;
import java.util.Map;
public class AllowEmptyHTMLTag extends HTMLTag {
- public AllowEmptyHTMLTag(String name) {
- super(name);
- }
+ public AllowEmptyHTMLTag(String name) {
+ super(name);
+ }
- public void renderHTML(ITextConverter converter, Appendable buf, IWikiModel model) throws IOException {
- boolean newLinesAfterTag = false;
- boolean newLinesAfterChildren = false;
- TagNode node = this;
- String name = node.getName();
- List<Object> children = node.getChildren();
+ public void renderHTML(ITextConverter converter, Appendable buf, IWikiModel model) throws IOException {
+ boolean newLinesAfterTag = false;
+ boolean newLinesAfterChildren = false;
+ TagNode node = this;
+ String name = node.getName();
+ List<Object> children = node.getChildren();
- if (NEW_LINES) {
- switch (name) {
- case "div":
- case "p":
- case "li":
- case "td":
- buf.append('\n');
- break;
- case "table":
- case "ul":
- case "ol":
- case "th":
- case "tr":
- buf.append('\n');
- newLinesAfterTag = true;
- newLinesAfterChildren = true;
- break;
- case "pre":
- buf.append('\n');
- newLinesAfterTag = false;
- newLinesAfterChildren = true;
- break;
- case "blockquote":
- newLinesAfterChildren = true;
- break;
- }
- }
- buf.append('<');
- buf.append(name);
+ if (NEW_LINES) {
+ switch (name) {
+ case "div":
+ case "p":
+ case "li":
+ case "td":
+ buf.append('\n');
+ break;
+ case "table":
+ case "ul":
+ case "ol":
+ case "th":
+ case "tr":
+ buf.append('\n');
+ newLinesAfterTag = true;
+ newLinesAfterChildren = true;
+ break;
+ case "pre":
+ buf.append('\n');
+ newLinesAfterTag = false;
+ newLinesAfterChildren = true;
+ break;
+ case "blockquote":
+ newLinesAfterChildren = true;
+ break;
+ }
+ }
+ buf.append('<');
+ buf.append(name);
- Map<String, String> tagAtttributes = node.getAttributes();
+ Map<String, String> tagAtttributes = node.getAttributes();
- appendAttributes(buf, tagAtttributes);
+ appendAttributes(buf, tagAtttributes);
- if (children.size() == 0) {
- buf.append(" />");
- } else {
- buf.append('>');
- if (newLinesAfterTag) {
- buf.append('\n');
- }
- converter.nodesToText(children, buf, model);
- if (newLinesAfterChildren) {
- buf.append('\n');
- }
- buf.append("</");
- buf.append(node.getName());
- buf.append('>');
- }
- }
+ if (children.size() == 0) {
+ buf.append(" />");
+ } else {
+ buf.append('>');
+ if (newLinesAfterTag) {
+ buf.append('\n');
+ }
+ converter.nodesToText(children, buf, model);
+ if (newLinesAfterChildren) {
+ buf.append('\n');
+ }
+ buf.append("</");
+ buf.append(node.getName());
+ buf.append('>');
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java
index f095fc64..bb3b3425 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java
@@ -8,55 +8,60 @@ import java.util.concurrent.locks.ReentrantLock;
import java.util.regex.Pattern;
public class Constants {
+ private static class PatternSerializer implements JsonDeserializer<Pattern>, JsonSerializer<Pattern> {
+ @Override
+ public Pattern deserialize(
+ JsonElement json,
+ Type typeOfT,
+ JsonDeserializationContext context
+ ) throws JsonParseException {
+ return Pattern.compile(json.getAsString());
+ }
- private static class PatternSerializer implements JsonDeserializer<Pattern>, JsonSerializer<Pattern> {
- @Override
- public Pattern deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
- return Pattern.compile(json.getAsString());
- }
- @Override
- public JsonElement serialize(Pattern src, Type typeOfSrc, JsonSerializationContext context) {
- return new JsonPrimitive(src.pattern());
- }
- }
-
- private static final Gson gson = new GsonBuilder().setPrettyPrinting()
- .registerTypeAdapter(Pattern.class, new PatternSerializer()).create();
-
- public static JsonObject BONUSES;
- public static JsonObject DISABLE;
- public static JsonObject ENCHANTS;
- public static JsonObject LEVELING;
- public static JsonObject MISC;
- public static JsonObject PETNUMS;
- public static JsonObject PETS;
- public static JsonObject PARENTS;
- public static JsonObject ESSENCECOSTS;
- public static JsonObject FAIRYSOULS;
- public static JsonObject REFORGESTONES;
- public static CollectionConstant COLLECTIONLOG;
-
- private static final ReentrantLock lock = new ReentrantLock();
-
- public static void reload() {
- try {
- lock.lock();
-
- BONUSES = Utils.getConstant("bonuses", gson);
- DISABLE = Utils.getConstant("disable", gson);
- ENCHANTS = Utils.getConstant("enchants", gson);
- LEVELING = Utils.getConstant("leveling", gson);
- MISC = Utils.getConstant("misc", gson);
- PETNUMS = Utils.getConstant("petnums", gson);
- PETS = Utils.getConstant("pets", gson);
- PARENTS = Utils.getConstant("parents", gson);
- ESSENCECOSTS = Utils.getConstant("essencecosts", gson);
- FAIRYSOULS = Utils.getConstant("fairy_souls", gson);
- REFORGESTONES = Utils.getConstant("reforgestones", gson);
- //COLLECTIONLOG = Utils.getConstant("collectionlog", gson, CollectionConstant.class);
- } finally {
- lock.unlock();
- }
- }
+ @Override
+ public JsonElement serialize(Pattern src, Type typeOfSrc, JsonSerializationContext context) {
+ return new JsonPrimitive(src.pattern());
+ }
+ }
+ private static final Gson gson = new GsonBuilder()
+ .setPrettyPrinting()
+ .registerTypeAdapter(Pattern.class, new PatternSerializer())
+ .create();
+
+ public static JsonObject BONUSES;
+ public static JsonObject DISABLE;
+ public static JsonObject ENCHANTS;
+ public static JsonObject LEVELING;
+ public static JsonObject MISC;
+ public static JsonObject PETNUMS;
+ public static JsonObject PETS;
+ public static JsonObject PARENTS;
+ public static JsonObject ESSENCECOSTS;
+ public static JsonObject FAIRYSOULS;
+ public static JsonObject REFORGESTONES;
+ public static CollectionConstant COLLECTIONLOG;
+
+ private static final ReentrantLock lock = new ReentrantLock();
+
+ public static void reload() {
+ try {
+ lock.lock();
+
+ BONUSES = Utils.getConstant("bonuses", gson);
+ DISABLE = Utils.getConstant("disable", gson);
+ ENCHANTS = Utils.getConstant("enchants", gson);
+ LEVELING = Utils.getConstant("leveling", gson);
+ MISC = Utils.getConstant("misc", gson);
+ PETNUMS = Utils.getConstant("petnums", gson);
+ PETS = Utils.getConstant("pets", gson);
+ PARENTS = Utils.getConstant("parents", gson);
+ ESSENCECOSTS = Utils.getConstant("essencecosts", gson);
+ FAIRYSOULS = Utils.getConstant("fairy_souls", gson);
+ REFORGESTONES = Utils.getConstant("reforgestones", gson);
+ //COLLECTIONLOG = Utils.getConstant("collectionlog", gson, CollectionConstant.class);
+ } finally {
+ lock.unlock();
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Debouncer.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Debouncer.java
new file mode 100644
index 00000000..15808a29
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Debouncer.java
@@ -0,0 +1,34 @@
+package io.github.moulberry.notenoughupdates.util;
+
+/**
+ * This debouncer always triggers on the leading edge.
+ * <p>
+ * Calling {@link #trigger} will only result in a truthy return value the first time it is called
+ * within {@link #getDelayInNanoSeconds()} nanoseconds.
+ */
+public class Debouncer {
+ private long lastPinged = 0L;
+ private final long delay;
+
+ public Debouncer(long minimumDelayInNanoSeconds) {
+ this.delay = minimumDelayInNanoSeconds;
+ }
+
+ public long getDelayInNanoSeconds() {
+ return delay;
+ }
+
+ public synchronized long timePassed() {
+ // longs are technically not atomic reads since they use two 32 bit registers
+ // so, yes, this technically has to be synchronized
+ return System.nanoTime() - lastPinged;
+ }
+
+ public synchronized boolean trigger() {
+ long newPingTime = System.nanoTime();
+ long newDelay = newPingTime - lastPinged;
+ lastPinged = newPingTime;
+ return newDelay >= this.delay;
+ }
+
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/DiscordMarkdownBuilder.java b/src/main/java/io/github/moulberry/notenoughupdates/util/DiscordMarkdownBuilder.java
index ccffa313..1c78f924 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/DiscordMarkdownBuilder.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/DiscordMarkdownBuilder.java
@@ -1,26 +1,25 @@
package io.github.moulberry.notenoughupdates.util;
public class DiscordMarkdownBuilder {
+ private final StringBuilder builder;
- private final StringBuilder builder;
+ public DiscordMarkdownBuilder() {
+ this.builder = new StringBuilder();
+ this.builder.append("```md\n");
+ }
- public DiscordMarkdownBuilder() {
- this.builder = new StringBuilder();
- this.builder.append("```md\n");
- }
+ public DiscordMarkdownBuilder category(String name) {
+ builder.append("# ").append(name).append("\n");
+ return this;
+ }
- public DiscordMarkdownBuilder category(String name) {
- builder.append("# ").append(name).append("\n");
- return this;
- }
+ public DiscordMarkdownBuilder append(String key, Object value) {
+ builder.append("[").append(key).append("]").append("[").append(value).append("]").append("\n");
+ return this;
+ }
- public DiscordMarkdownBuilder append(String key, Object value) {
- builder.append("[").append(key).append("]").append("[").append(value).append("]").append("\n");
- return this;
- }
-
- @Override
- public String toString() {
- return builder.append("```").toString();
- }
+ @Override
+ public String toString() {
+ return builder.append("```").toString();
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/GuiTextures.java b/src/main/java/io/github/moulberry/notenoughupdates/util/GuiTextures.java
index 0740274e..48a6915b 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/GuiTextures.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/GuiTextures.java
@@ -3,101 +3,135 @@ package io.github.moulberry.notenoughupdates.util;
import net.minecraft.util.ResourceLocation;
public class GuiTextures {
-
- private GuiTextures() {} //Not instantiable. Use import static to access class members.
-
- public static final ResourceLocation itemPaneTabArrow = new ResourceLocation("notenoughupdates:item_pane_tab_arrow.png");
- //public static final ResourceLocation prev = new ResourceLocation("notenoughupdates:prev.png");
- //public static final ResourceLocation next = new ResourceLocation("notenoughupdates:next.png");
- public static final ResourceLocation rightarrow_overlay = new ResourceLocation("notenoughupdates:rightarrow_overlay.png");
- public static final ResourceLocation rightarrow = new ResourceLocation("notenoughupdates:rightarrow.png");
- public static final ResourceLocation close = new ResourceLocation("notenoughupdates:close.png");
- public static final ResourceLocation settings = new ResourceLocation("notenoughupdates:settings.png");
-
- public static final ResourceLocation off = new ResourceLocation("notenoughupdates:off.png");
- public static final ResourceLocation on = new ResourceLocation("notenoughupdates:on.png");
- public static final ResourceLocation help = new ResourceLocation("notenoughupdates:help.png");
- public static final ResourceLocation slider_off = new ResourceLocation("notenoughupdates:slider_off.png");
- public static final ResourceLocation slider_on = new ResourceLocation("notenoughupdates:slider_on.png");
- public static final ResourceLocation slider_off_large = new ResourceLocation("notenoughupdates:slider_off_large.png");
- public static final ResourceLocation slider_on_large = new ResourceLocation("notenoughupdates:slider_on_large.png");
- public static final ResourceLocation slider_button = new ResourceLocation("notenoughupdates:slider_button.png");
-
- public static final ResourceLocation DISCORD = new ResourceLocation("notenoughupdates:social/discord.png");
- public static final ResourceLocation GITHUB = new ResourceLocation("notenoughupdates:social/github.png");
- public static final ResourceLocation PATREON = new ResourceLocation("notenoughupdates:social/patreon.png");
- public static final ResourceLocation TWITTER = new ResourceLocation("notenoughupdates:social/twitter.png");
- public static final ResourceLocation YOUTUBE = new ResourceLocation("notenoughupdates:social/youtube.png");
-
- public static final ResourceLocation item_mask = new ResourceLocation("notenoughupdates:item_mask.png");
- public static final ResourceLocation item_haschild = new ResourceLocation("notenoughupdates:item_haschild.png");
- public static final ResourceLocation button_tex = new ResourceLocation("notenoughupdates:button.png");
-
- public static final ResourceLocation setting_border = new ResourceLocation("notenoughupdates:setting_border.png");
-
- public static final ResourceLocation button_white = new ResourceLocation("notenoughupdates:button_white.png");
- public static final ResourceLocation colour_selector_dot = new ResourceLocation("notenoughupdates:colour_selector_dot.png");
- public static final ResourceLocation colour_selector_bar = new ResourceLocation("notenoughupdates:colour_selector_bar.png");
- public static final ResourceLocation colour_selector_bar_alpha = new ResourceLocation("notenoughupdates:colour_selector_bar_alpha.png");
- public static final ResourceLocation colour_selector_chroma = new ResourceLocation("notenoughupdates:colour_selector_chroma.png");
-
- public static final ResourceLocation accessory_bag_overlay = new ResourceLocation("notenoughupdates:accessory_bag_overlay.png");
-
- public static final ResourceLocation quickcommand_background = new ResourceLocation("notenoughupdates:quickcommand_background.png");
-
- public static final ResourceLocation gamemodes = new ResourceLocation("notenoughupdates:gamemodes.png");
- public static final ResourceLocation radial_square_off = new ResourceLocation("notenoughupdates:radial_square_off.png");
- public static final ResourceLocation radial_square_on = new ResourceLocation("notenoughupdates:radial_square_on.png");
- public static final ResourceLocation radial_circle_off = new ResourceLocation("notenoughupdates:radial_circle_off.png");
- public static final ResourceLocation radial_circle_on = new ResourceLocation("notenoughupdates:radial_circle_on.png");
-
- public static final ResourceLocation dungeon_chest_worth = new ResourceLocation("notenoughupdates:dungeon_chest_worth.png");
-
- public static final ResourceLocation auction_view = new ResourceLocation("notenoughupdates:auction_view.png");
- public static final ResourceLocation auction_accept = new ResourceLocation("notenoughupdates:auction_accept.png");
- public static final ResourceLocation auction_price = new ResourceLocation("notenoughupdates:auction_price.png");
- public static final ResourceLocation auction_view_buttons = new ResourceLocation("notenoughupdates:auction_view_buttons.png");
-
- public static final ResourceLocation logo = new ResourceLocation("notenoughupdates:logo.png");
- public static final ResourceLocation logo_fg = new ResourceLocation("notenoughupdates:logo_fg.png");
- public static final ResourceLocation logo_bg = new ResourceLocation("notenoughupdates:logo_bg.png");
-
- public static final ResourceLocation sort_all = new ResourceLocation("notenoughupdates:sort_all.png");
- public static final ResourceLocation sort_mob = new ResourceLocation("notenoughupdates:sort_mob.png");
- public static final ResourceLocation sort_pet = new ResourceLocation("notenoughupdates:sort_pet.png");
- public static final ResourceLocation sort_tool = new ResourceLocation("notenoughupdates:sort_weapon.png");
- public static final ResourceLocation sort_armor = new ResourceLocation("notenoughupdates:sort_armor.png");
- public static final ResourceLocation sort_accessory = new ResourceLocation("notenoughupdates:sort_accessory.png");
- public static final ResourceLocation sort_all_active = new ResourceLocation("notenoughupdates:sort_all_active.png");
- public static final ResourceLocation sort_mob_active = new ResourceLocation("notenoughupdates:sort_mob_active.png");
- public static final ResourceLocation sort_pet_active = new ResourceLocation("notenoughupdates:sort_pet_active.png");
- public static final ResourceLocation sort_tool_active = new ResourceLocation("notenoughupdates:sort_weapon_active.png");
- public static final ResourceLocation sort_armor_active = new ResourceLocation("notenoughupdates:sort_armor_active.png");
- public static final ResourceLocation sort_accessory_active = new ResourceLocation("notenoughupdates:sort_accessory_active.png");
-
- public static final ResourceLocation order_alphabetical = new ResourceLocation("notenoughupdates:order_alphabetical.png");
- public static final ResourceLocation order_rarity = new ResourceLocation("notenoughupdates:order_rarity.png");
- public static final ResourceLocation order_value = new ResourceLocation("notenoughupdates:order_value.png");
- public static final ResourceLocation order_alphabetical_active = new ResourceLocation("notenoughupdates:order_alphabetical_active.png");
- public static final ResourceLocation order_rarity_active = new ResourceLocation("notenoughupdates:order_rarity_active.png");
- public static final ResourceLocation order_value_active = new ResourceLocation("notenoughupdates:order_value_active.png");
- public static final ResourceLocation ascending_overlay = new ResourceLocation("notenoughupdates:ascending_overlay.png");
- public static final ResourceLocation descending_overlay = new ResourceLocation("notenoughupdates:descending_overlay.png");
-
- public static final ResourceLocation BAR = new ResourceLocation("notenoughupdates:core/bar.png");
- public static final ResourceLocation OFF = new ResourceLocation("notenoughupdates:core/toggle_off.png");
- public static final ResourceLocation ONE = new ResourceLocation("notenoughupdates:core/toggle_1.png");
- public static final ResourceLocation TWO = new ResourceLocation("notenoughupdates:core/toggle_2.png");
- public static final ResourceLocation THREE = new ResourceLocation("notenoughupdates:core/toggle_3.png");
- public static final ResourceLocation ON = new ResourceLocation("notenoughupdates:core/toggle_on.png");
-
- public static final ResourceLocation slider_off_cap = new ResourceLocation("notenoughupdates:core/slider/slider_off_cap.png");
- public static final ResourceLocation slider_off_notch = new ResourceLocation("notenoughupdates:core/slider/slider_off_notch.png");
- public static final ResourceLocation slider_off_segment = new ResourceLocation("notenoughupdates:core/slider/slider_off_segment.png");
- public static final ResourceLocation slider_on_cap = new ResourceLocation("notenoughupdates:core/slider/slider_on_cap.png");
- public static final ResourceLocation slider_on_notch = new ResourceLocation("notenoughupdates:core/slider/slider_on_notch.png");
- public static final ResourceLocation slider_on_segment = new ResourceLocation("notenoughupdates:core/slider/slider_on_segment.png");
- public static final ResourceLocation slider_button_new = new ResourceLocation("notenoughupdates:core/slider/slider_button.png");
-
+ private GuiTextures() {
+ } // Not instantiable. Use import static to access class members.
+
+ public static final ResourceLocation itemPaneTabArrow =
+ new ResourceLocation("notenoughupdates:item_pane_tab_arrow.png");
+ //public static final ResourceLocation prev = new ResourceLocation("notenoughupdates:prev.png");
+ //public static final ResourceLocation next = new ResourceLocation("notenoughupdates:next.png");
+ public static final ResourceLocation rightarrow_overlay =
+ new ResourceLocation("notenoughupdates:rightarrow_overlay.png");
+ public static final ResourceLocation rightarrow = new ResourceLocation("notenoughupdates:rightarrow.png");
+ public static final ResourceLocation close = new ResourceLocation("notenoughupdates:close.png");
+ public static final ResourceLocation settings = new ResourceLocation("notenoughupdates:settings.png");
+
+ public static final ResourceLocation off = new ResourceLocation("notenoughupdates:off.png");
+ public static final ResourceLocation on = new ResourceLocation("notenoughupdates:on.png");
+ public static final ResourceLocation help = new ResourceLocation("notenoughupdates:help.png");
+ public static final ResourceLocation slider_off = new ResourceLocation("notenoughupdates:slider_off.png");
+ public static final ResourceLocation slider_on = new ResourceLocation("notenoughupdates:slider_on.png");
+ public static final ResourceLocation slider_off_large = new ResourceLocation("notenoughupdates:slider_off_large.png");
+ public static final ResourceLocation slider_on_large = new ResourceLocation("notenoughupdates:slider_on_large.png");
+ public static final ResourceLocation slider_button = new ResourceLocation("notenoughupdates:slider_button.png");
+
+ public static final ResourceLocation DISCORD = new ResourceLocation("notenoughupdates:social/discord.png");
+ public static final ResourceLocation GITHUB = new ResourceLocation("notenoughupdates:social/github.png");
+ public static final ResourceLocation PATREON = new ResourceLocation("notenoughupdates:social/patreon.png");
+ public static final ResourceLocation TWITTER = new ResourceLocation("notenoughupdates:social/twitter.png");
+ public static final ResourceLocation YOUTUBE = new ResourceLocation("notenoughupdates:social/youtube.png");
+ public static final ResourceLocation TWITCH = new ResourceLocation("notenoughupdates:social/twitch.png");
+
+ public static final ResourceLocation item_mask = new ResourceLocation("notenoughupdates:item_mask.png");
+ public static final ResourceLocation item_haschild = new ResourceLocation("notenoughupdates:item_haschild.png");
+ public static final ResourceLocation button_tex = new ResourceLocation("notenoughupdates:button.png");
+ public static final ResourceLocation button_fsr =
+ new ResourceLocation("notenoughupdates:FSR_do_not_texture_this_please.png");
+
+ public static final ResourceLocation setting_border = new ResourceLocation("notenoughupdates:setting_border.png");
+
+ public static final ResourceLocation button_white = new ResourceLocation("notenoughupdates:button_white.png");
+ public static final ResourceLocation colour_selector_dot =
+ new ResourceLocation("notenoughupdates:colour_selector_dot.png");
+ public static final ResourceLocation colour_selector_bar =
+ new ResourceLocation("notenoughupdates:colour_selector_bar.png");
+ public static final ResourceLocation colour_selector_bar_alpha =
+ new ResourceLocation("notenoughupdates:colour_selector_bar_alpha.png");
+ public static final ResourceLocation colour_selector_chroma =
+ new ResourceLocation("notenoughupdates:colour_selector_chroma.png");
+
+ public static final ResourceLocation accessory_bag_overlay =
+ new ResourceLocation("notenoughupdates:accessory_bag_overlay.png");
+
+ public static final ResourceLocation quickcommand_background =
+ new ResourceLocation("notenoughupdates:quickcommand_background.png");
+
+ public static final ResourceLocation gamemodes = new ResourceLocation("notenoughupdates:gamemodes.png");
+ public static final ResourceLocation radial_square_off =
+ new ResourceLocation("notenoughupdates:radial_square_off.png");
+ public static final ResourceLocation radial_square_on = new ResourceLocation("notenoughupdates:radial_square_on.png");
+ public static final ResourceLocation radial_circle_off =
+ new ResourceLocation("notenoughupdates:radial_circle_off.png");
+ public static final ResourceLocation radial_circle_on = new ResourceLocation("notenoughupdates:radial_circle_on.png");
+
+ public static final ResourceLocation dungeon_chest_worth =
+ new ResourceLocation("notenoughupdates:dungeon_chest_worth.png");
+
+ public static final ResourceLocation auction_view = new ResourceLocation("notenoughupdates:auction_view.png");
+ public static final ResourceLocation auction_accept = new ResourceLocation("notenoughupdates:auction_accept.png");
+ public static final ResourceLocation auction_price = new ResourceLocation("notenoughupdates:auction_price.png");
+ public static final ResourceLocation auction_view_buttons =
+ new ResourceLocation("notenoughupdates:auction_view_buttons.png");
+
+ public static final ResourceLocation logo = new ResourceLocation("notenoughupdates:logo.png");
+ public static final ResourceLocation logo_fg = new ResourceLocation("notenoughupdates:logo_fg.png");
+ public static final ResourceLocation logo_bg = new ResourceLocation("notenoughupdates:logo_bg.png");
+
+ public static final ResourceLocation sort_all = new ResourceLocation("notenoughupdates:sort_all.png");
+ public static final ResourceLocation sort_mob = new ResourceLocation("notenoughupdates:sort_mob.png");
+ public static final ResourceLocation sort_pet = new ResourceLocation("notenoughupdates:sort_pet.png");
+ public static final ResourceLocation sort_tool = new ResourceLocation("notenoughupdates:sort_weapon.png");
+ public static final ResourceLocation sort_armor = new ResourceLocation("notenoughupdates:sort_armor.png");
+ public static final ResourceLocation sort_accessory = new ResourceLocation("notenoughupdates:sort_accessory.png");
+ public static final ResourceLocation sort_all_active = new ResourceLocation("notenoughupdates:sort_all_active.png");
+ public static final ResourceLocation sort_mob_active = new ResourceLocation("notenoughupdates:sort_mob_active.png");
+ public static final ResourceLocation sort_pet_active = new ResourceLocation("notenoughupdates:sort_pet_active.png");
+ public static final ResourceLocation sort_tool_active =
+ new ResourceLocation("notenoughupdates:sort_weapon_active.png");
+ public static final ResourceLocation sort_armor_active =
+ new ResourceLocation("notenoughupdates:sort_armor_active.png");
+ public static final ResourceLocation sort_accessory_active =
+ new ResourceLocation("notenoughupdates:sort_accessory_active.png");
+
+ public static final ResourceLocation order_alphabetical =
+ new ResourceLocation("notenoughupdates:order_alphabetical.png");
+ public static final ResourceLocation order_rarity = new ResourceLocation("notenoughupdates:order_rarity.png");
+ public static final ResourceLocation order_value = new ResourceLocation("notenoughupdates:order_value.png");
+ public static final ResourceLocation order_alphabetical_active =
+ new ResourceLocation("notenoughupdates:order_alphabetical_active.png");
+ public static final ResourceLocation order_rarity_active =
+ new ResourceLocation("notenoughupdates:order_rarity_active.png");
+ public static final ResourceLocation order_value_active =
+ new ResourceLocation("notenoughupdates:order_value_active.png");
+ public static final ResourceLocation ascending_overlay =
+ new ResourceLocation("notenoughupdates:ascending_overlay.png");
+ public static final ResourceLocation descending_overlay =
+ new ResourceLocation("notenoughupdates:descending_overlay.png");
+
+ public static final ResourceLocation BAR = new ResourceLocation("notenoughupdates:core/bar.png");
+ public static final ResourceLocation BAR_ONE = new ResourceLocation("notenoughupdates:core/bar_1.png");
+ public static final ResourceLocation BAR_TWO = new ResourceLocation("notenoughupdates:core/bar_2.png");
+ public static final ResourceLocation BAR_THREE = new ResourceLocation("notenoughupdates:core/bar_3.png");
+ public static final ResourceLocation BAR_ON = new ResourceLocation("notenoughupdates:core/bar_on.png");
+ public static final ResourceLocation OFF = new ResourceLocation("notenoughupdates:core/toggle_off.png");
+ public static final ResourceLocation ONE = new ResourceLocation("notenoughupdates:core/toggle_1.png");
+ public static final ResourceLocation TWO = new ResourceLocation("notenoughupdates:core/toggle_2.png");
+ public static final ResourceLocation THREE = new ResourceLocation("notenoughupdates:core/toggle_3.png");
+ public static final ResourceLocation ON = new ResourceLocation("notenoughupdates:core/toggle_on.png");
+
+ public static final ResourceLocation slider_off_cap =
+ new ResourceLocation("notenoughupdates:core/slider/slider_off_cap.png");
+ public static final ResourceLocation slider_off_notch =
+ new ResourceLocation("notenoughupdates:core/slider/slider_off_notch.png");
+ public static final ResourceLocation slider_off_segment =
+ new ResourceLocation("notenoughupdates:core/slider/slider_off_segment.png");
+ public static final ResourceLocation slider_on_cap =
+ new ResourceLocation("notenoughupdates:core/slider/slider_on_cap.png");
+ public static final ResourceLocation slider_on_notch =
+ new ResourceLocation("notenoughupdates:core/slider/slider_on_notch.png");
+ public static final ResourceLocation slider_on_segment =
+ new ResourceLocation("notenoughupdates:core/slider/slider_on_segment.png");
+ public static final ResourceLocation slider_button_new =
+ new ResourceLocation("notenoughupdates:core/slider/slider_button.png");
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/HastebinUploader.java b/src/main/java/io/github/moulberry/notenoughupdates/util/HastebinUploader.java
index 70753e10..9cbad402 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/HastebinUploader.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/HastebinUploader.java
@@ -14,46 +14,52 @@ import java.nio.charset.StandardCharsets;
* @author ThatGravyBoat
*/
public class HastebinUploader {
+ private static final String UPLOAD_URL = "https://hst.sh/documents";
+ private static final String RETURN_URL = "https://hst.sh/";
+ private static final String RAW_RETURN_URL = "https://hst.sh/raw/";
- private static final String UPLOAD_URL = "https://hst.sh/documents";
- private static final String RETURN_URL = "https://hst.sh/";
- private static final String RAW_RETURN_URL = "https://hst.sh/raw/";
+ private static final Gson GSON = new Gson();
- private static final Gson GSON = new Gson();
+ /**
+ * @param data the data you want to upload
+ * @param mode the mode in which the thing should return NORMAL = returns the url, RAW = returns the raw url, NO_URL = returns the slug.
+ * @return The url if mode is NORMAL OR RAW, the slug if mode is NO_URL, and null if an error occurred.
+ */
+ public static String upload(String data, Mode mode) {
+ try {
+ byte[] bytes = data.getBytes(StandardCharsets.UTF_8);
+ HttpURLConnection connection = (HttpURLConnection) new URL(UPLOAD_URL).openConnection();
+ connection.setRequestMethod("POST");
+ connection.addRequestProperty(
+ "User-Agent",
+ "Minecraft Mod (" + NotEnoughUpdates.MODID + "/" + NotEnoughUpdates.VERSION + ")"
+ );
+ connection.addRequestProperty("Content-Length", String.valueOf(bytes.length));
+ connection.setReadTimeout(15000);
+ connection.setConnectTimeout(15000);
+ connection.setDoOutput(true);
+ connection.getOutputStream().write(bytes);
+ final JsonObject json =
+ GSON.fromJson(IOUtils.toString(connection.getInputStream(), Charsets.UTF_8), JsonObject.class);
+ if (!json.has("key")) return null;
+ final String key = json.get("key").getAsString();
+ switch (mode) {
+ case RAW:
+ return RAW_RETURN_URL + key;
+ case NORMAL:
+ return RETURN_URL + key;
+ case NO_URL:
+ return key;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
- /**
- * @param data the data you want to upload
- * @param mode the mode in which the thing should return NORMAL = returns the url, RAW = returns the raw url, NO_URL = returns the slug.
- * @return The url if mode is NORMAL OR RAW, the slug if mode is NO_URL, and null if an error occurred.
- */
- public static String upload(String data, Mode mode){
- try {
- byte[] bytes = data.getBytes(StandardCharsets.UTF_8);
- HttpURLConnection connection = (HttpURLConnection)new URL(UPLOAD_URL).openConnection();
- connection.setRequestMethod("POST");
- connection.addRequestProperty("User-Agent", "Minecraft Mod ("+ NotEnoughUpdates.MODID +"/"+NotEnoughUpdates.VERSION+")");
- connection.addRequestProperty("Content-Length", String.valueOf(bytes.length));
- connection.setReadTimeout(15000);
- connection.setConnectTimeout(15000);
- connection.setDoOutput(true);
- connection.getOutputStream().write(bytes);
- final JsonObject json = GSON.fromJson(IOUtils.toString(connection.getInputStream(), Charsets.UTF_8), JsonObject.class);
- if (!json.has("key")) return null;
- final String key = json.get("key").getAsString();
- switch (mode) {
- case RAW: return RAW_RETURN_URL + key;
- case NORMAL: return RETURN_URL + key;
- case NO_URL: return key;
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
-
- public enum Mode {
- NORMAL,
- RAW,
- NO_URL
- }
+ public enum Mode {
+ NORMAL,
+ RAW,
+ NO_URL
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/HotmInformation.java b/src/main/java/io/github/moulberry/notenoughupdates/util/HotmInformation.java
new file mode 100644
index 00000000..7258fe9f
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/HotmInformation.java
@@ -0,0 +1,194 @@
+package io.github.moulberry.notenoughupdates.util;
+
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.inventory.GuiChest;
+import net.minecraft.inventory.ContainerChest;
+import net.minecraftforge.client.event.ClientChatReceivedEvent;
+import net.minecraftforge.client.event.GuiOpenEvent;
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.event.world.WorldEvent;
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ConcurrentHashMap;
+
+public class HotmInformation {
+ private final NotEnoughUpdates neu;
+ public static final int[] EXPERIENCE_FOR_HOTM_LEVEL = {
+ // Taken from the wiki: https://hypixel-skyblock.fandom.com/wiki/Heart_of_the_Mountain#Experience_for_Each_Tier
+ 0,
+ 3000,
+ 12000,
+ 37000,
+ 97000,
+ 197000,
+ 347000
+ };
+ public static final int[] QUICK_FORGE_MULTIPLIERS = {
+ 985,
+ 970,
+ 955,
+ 940,
+ 925,
+ 910,
+ 895,
+ 880,
+ 865,
+ 850,
+ 845,
+ 840,
+ 835,
+ 830,
+ 825,
+ 820,
+ 815,
+ 810,
+ 805,
+ 700
+ };
+ private final Map<String, Tree> profiles = new ConcurrentHashMap<>();
+
+ public static class Tree {
+ private final Map<String, Integer> levels = new HashMap<>();
+ private int totalMithrilPowder;
+ private int totalGemstonePowder;
+ private int hotmExp;
+
+ public int getHotmExp() {
+ return hotmExp;
+ }
+
+ public int getTotalGemstonePowder() {
+ return totalGemstonePowder;
+ }
+
+ public int getTotalMithrilPowder() {
+ return totalMithrilPowder;
+ }
+
+ public Set<String> getAllUnlockedNodes() {
+ return levels.keySet();
+ }
+
+ public int getHotmLevel() {
+ for (int i = EXPERIENCE_FOR_HOTM_LEVEL.length - 1; i >= 0; i--) {
+ if (EXPERIENCE_FOR_HOTM_LEVEL[i] >= this.hotmExp)
+ return i;
+ }
+ return 0;
+ }
+
+ public int getLevel(String node) {
+ return levels.getOrDefault(node, 0);
+ }
+
+ }
+
+ private CompletableFuture<Void> updateTask = CompletableFuture.completedFuture(null);
+
+ private boolean shouldReloadSoon = false;
+
+ public HotmInformation(NotEnoughUpdates neu) {
+ this.neu = neu;
+ MinecraftForge.EVENT_BUS.register(this);
+ }
+
+ public Optional<Tree> getInformationOn(String profile) {
+ if (profile == null) {
+ return Optional.empty();
+ }
+ return Optional.ofNullable(this.profiles.get(profile));
+ }
+
+ public Optional<Tree> getInformationOnCurrentProfile() {
+ return getInformationOn(neu.manager.getCurrentProfile());
+ }
+
+ @SubscribeEvent
+ public synchronized void onLobbyJoin(WorldEvent.Load event) {
+ if (shouldReloadSoon) {
+ shouldReloadSoon = false;
+ requestUpdate(false);
+ }
+ }
+
+ @SubscribeEvent
+ public synchronized void onGuiOpen(GuiOpenEvent event) {
+ if (event.gui instanceof GuiChest) {
+ String containerName = ((ContainerChest) ((GuiChest) event.gui).inventorySlots)
+ .getLowerChestInventory()
+ .getDisplayName()
+ .getUnformattedText();
+ if (containerName.equals("Heart of the Mountain"))
+ shouldReloadSoon = true;
+ }
+ }
+
+ @SubscribeEvent
+ public synchronized void onChat(ClientChatReceivedEvent event) {
+ if (event.message.getUnformattedText().equals("Welcome to Hypixel SkyBlock!"))
+ requestUpdate(false);
+ }
+
+ public synchronized void requestUpdate(boolean force) {
+ if (updateTask.isDone() || force) {
+ updateTask = neu.manager.hypixelApi.getHypixelApiAsync(
+ neu.config.apiKey.apiKey,
+ "skyblock/profiles",
+ new HashMap<String, String>() {{
+ put("uuid", Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""));
+ }}
+ ).thenAccept(this::updateInformation);
+ }
+ }
+
+ /*
+ * 1000 = 100% of the time left
+ * 700 = 70% of the time left
+ * */
+ public static int getQuickForgeMultiplier(int level) {
+ if (level <= 0) return 1000;
+ if (level > 20) return -1;
+ return QUICK_FORGE_MULTIPLIERS[level - 1];
+ }
+
+ public void updateInformation(JsonObject entireApiResponse) {
+ if (!entireApiResponse.has("success") || !entireApiResponse.get("success").getAsBoolean()) return;
+ JsonArray profiles = entireApiResponse.getAsJsonArray("profiles");
+ for (JsonElement element : profiles) {
+ JsonObject profile = element.getAsJsonObject();
+ String profileName = profile.get("cute_name").getAsString();
+ JsonObject player = profile.getAsJsonObject("members").getAsJsonObject(Minecraft.getMinecraft().thePlayer
+ .getUniqueID()
+ .toString()
+ .replace("-", ""));
+ if (!player.has("mining_core"))
+ continue;
+ JsonObject miningCore = player.getAsJsonObject("mining_core");
+ Tree tree = new Tree();
+ JsonObject nodes = miningCore.getAsJsonObject("nodes");
+ for (Map.Entry<String, JsonElement> node : nodes.entrySet()) {
+ tree.levels.put(node.getKey(), node.getValue().getAsInt());
+ }
+ if (miningCore.has("powder_mithril_total")) {
+ tree.totalMithrilPowder = miningCore.get("powder_mithril_total").getAsInt();
+ }
+ if (miningCore.has("powder_gemstone_total")) {
+ tree.totalGemstonePowder = miningCore.get("powder_gemstone_total").getAsInt();
+ }
+ if (miningCore.has("experience")) {
+ tree.hotmExp = miningCore.get("experience").getAsInt();
+ }
+ this.profiles.put(profileName, tree);
+ }
+ }
+
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java b/src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java
index e75eaebb..2628eb7d 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java
@@ -5,151 +5,184 @@ import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import org.apache.commons.io.IOUtils;
-import java.io.BufferedReader;
import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
import java.net.ConnectException;
import java.net.URL;
import java.net.URLConnection;
+import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
import java.util.function.Consumer;
import java.util.zip.GZIPInputStream;
public class HypixelApi {
- private Gson gson = new Gson();
- private ExecutorService es = Executors.newFixedThreadPool(3);
-
- private static final int FAILS_BEFORE_SWITCH = 3;
- private int currentUrl = 0;
- private long lastPrimaryUrl = 0;
- private final String[] myApiURLs = {"https://moulberry.codes/"};//, "http://moulberry.codes/", "http://51.79.51.21/"};//, "http://51.75.78.252/" };
- private final Integer[] myApiSuccesses = {0, 0, 0, 0};
-
- public void getHypixelApiAsync(String apiKey, String method, HashMap<String, String> args, Consumer<JsonObject> consumer) {
- getHypixelApiAsync(apiKey, method, args, consumer, () -> {});
- }
-
- public void getHypixelApiAsync(String apiKey, String method, HashMap<String, String> args, Consumer<JsonObject> consumer, Runnable error) {
- getApiAsync(generateApiUrl(apiKey!=null?apiKey.trim():null, method, args), consumer, error);
- }
-
- private String getMyApiURL() {
- if(currentUrl == 0) {
- lastPrimaryUrl = System.currentTimeMillis();
- } else if(System.currentTimeMillis() - lastPrimaryUrl > 1000*60*30) { //Try switch back to main url after 30m
- currentUrl = 0;
- }
-
- myApiSuccesses[currentUrl] = Math.min(FAILS_BEFORE_SWITCH, myApiSuccesses[currentUrl] + 1);
- return myApiURLs[currentUrl];
- }
-
- private void myApiError(int index) {
- myApiSuccesses[index] = myApiSuccesses[index] - 2;
-
- if(myApiSuccesses[index] < 0) {
- myApiSuccesses[index] = 0;
-
- if(index == currentUrl) {
- currentUrl++;
- if(currentUrl >= myApiURLs.length) {
- currentUrl = 0;
- }
- }
- }
- }
-
- public void getApiAsync(String urlS, Consumer<JsonObject> consumer, Runnable error) {
- es.submit(() -> {
- try {
- consumer.accept(getApiSync(urlS));
- } catch(Exception e) {
- error.run();
- }
- });
- }
-
- public void getMyApiAsync(String urlS, Consumer<JsonObject> consumer, Runnable error) {
- es.submit(() -> {
- int current = currentUrl;
- try {
- consumer.accept(getApiSync(getMyApiURL()+urlS));
- } catch(Exception e) {
- if(NotEnoughUpdates.INSTANCE.config.hidden.dev) {
- e.printStackTrace();
- }
- myApiError(current);
- error.run();
- }
- });
- }
-
- public void getMyApiGZIPAsync(String urlS, Consumer<JsonObject> consumer, Runnable error) {
- es.submit(() -> {
- int current = currentUrl;
- try {
- consumer.accept(getApiGZIPSync(getMyApiURL()+urlS));
- } catch(Exception e) {
- myApiError(current);
- error.run();
- }
- });
- }
-
- public void getApiGZIPAsync(String urlS, Consumer<JsonObject> consumer, Runnable error) {
- es.submit(() -> {
- try {
- consumer.accept(getApiGZIPSync(urlS));
- } catch(Exception e) {
- error.run();
- }
- });
- }
-
- public JsonObject getApiSync(String urlS) throws IOException {
- URL url = new URL(urlS);
- URLConnection connection = url.openConnection();
- connection.setConnectTimeout(10000);
- connection.setReadTimeout(10000);
-
- String response = IOUtils.toString(connection.getInputStream(), StandardCharsets.UTF_8);
-
- JsonObject json = gson.fromJson(response, JsonObject.class);
- if(json == null) throw new ConnectException("Invalid JSON");
- return json;
- }
-
- public JsonObject getApiGZIPSync(String urlS) throws IOException {
- URL url = new URL(urlS);
- URLConnection connection = url.openConnection();
- connection.setConnectTimeout(10000);
- connection.setReadTimeout(10000);
-
- String response = IOUtils.toString(new GZIPInputStream(connection.getInputStream()), StandardCharsets.UTF_8);
-
- JsonObject json = gson.fromJson(response, JsonObject.class);
- return json;
- }
-
- public String generateApiUrl(String apiKey, String method, HashMap<String, String> args) {
- StringBuilder url = new StringBuilder("https://api.hypixel.net/" + method + (apiKey != null ? ("?key=" + apiKey.replace(" ", "")) : ""));
- boolean first = true;
- for(Map.Entry<String, String> entry : args.entrySet()) {
- if(first && apiKey == null) {
- url.append("?");
- first = false;
- } else {
- url.append("&");
- }
- url.append(entry.getKey()).append("=").append(entry.getValue());
- }
- return url.toString();
- }
-
+ private final Gson gson = new Gson();
+ private final ExecutorService es = Executors.newFixedThreadPool(3);
+
+ private static final int FAILS_BEFORE_SWITCH = 3;
+ private int currentUrl = 0;
+ private long lastPrimaryUrl = 0;
+ private final String[] myApiURLs = {"https://moulberry.codes/"};
+ //, "http://moulberry.codes/", "http://51.79.51.21/"};//, "http://51.75.78.252/" };
+ private final Integer[] myApiSuccesses = {0, 0, 0, 0};
+
+ public CompletableFuture<JsonObject> getHypixelApiAsync(String apiKey, String method, HashMap<String, String> args) {
+ return getApiAsync(generateApiUrl(apiKey, method, args));
+ }
+
+ public void getHypixelApiAsync(
+ String apiKey,
+ String method,
+ HashMap<String, String> args,
+ Consumer<JsonObject> consumer
+ ) {
+ getHypixelApiAsync(apiKey, method, args, consumer, () -> {
+ });
+ }
+
+ public void getHypixelApiAsync(
+ String apiKey,
+ String method,
+ HashMap<String, String> args,
+ Consumer<JsonObject> consumer,
+ Runnable error
+ ) {
+ getApiAsync(generateApiUrl(apiKey, method, args), consumer, error);
+ }
+
+ private String getMyApiURL() {
+ if (currentUrl == 0) {
+ lastPrimaryUrl = System.currentTimeMillis();
+ } else if (System.currentTimeMillis() - lastPrimaryUrl > 1000 * 60 * 30) { //Try switch back to main url after 30m
+ currentUrl = 0;
+ }
+
+ myApiSuccesses[currentUrl] = Math.min(FAILS_BEFORE_SWITCH, myApiSuccesses[currentUrl] + 1);
+ return myApiURLs[currentUrl];
+ }
+
+ private void myApiError(int index) {
+ myApiSuccesses[index] = myApiSuccesses[index] - 2;
+
+ if (myApiSuccesses[index] < 0) {
+ myApiSuccesses[index] = 0;
+
+ if (index == currentUrl) {
+ currentUrl++;
+ if (currentUrl >= myApiURLs.length) {
+ currentUrl = 0;
+ }
+ }
+ }
+ }
+
+ public CompletableFuture<JsonObject> getApiAsync(String urlS) {
+ CompletableFuture<JsonObject> result = new CompletableFuture<>();
+ es.submit(() -> {
+ try {
+ result.complete(getApiSync(urlS));
+ } catch (Exception e) {
+ result.completeExceptionally(e);
+ }
+ });
+ return result;
+ }
+
+ public void getApiAsync(String urlS, Consumer<JsonObject> consumer, Runnable error) {
+ es.submit(() -> {
+ try {
+ consumer.accept(getApiSync(urlS));
+ } catch (Exception e) {
+ error.run();
+ }
+ });
+ }
+
+ public void getMyApiAsync(String urlS, Consumer<JsonObject> consumer, Runnable error) {
+ es.submit(() -> {
+ int current = currentUrl;
+ try {
+ consumer.accept(getApiSync(getMyApiURL() + urlS));
+ } catch (Exception e) {
+ if (NotEnoughUpdates.INSTANCE.config.hidden.dev) {
+ e.printStackTrace();
+ }
+ myApiError(current);
+ error.run();
+ }
+ });
+ }
+
+ public void getMyApiGZIPAsync(String urlS, Consumer<JsonObject> consumer, Runnable error) {
+ es.submit(() -> {
+ int current = currentUrl;
+ try {
+ consumer.accept(getApiGZIPSync(getMyApiURL() + urlS));
+ } catch (Exception e) {
+ myApiError(current);
+ error.run();
+ }
+ });
+ }
+
+ public void getApiGZIPAsync(String urlS, Consumer<JsonObject> consumer, Runnable error) {
+ es.submit(() -> {
+ try {
+ consumer.accept(getApiGZIPSync(urlS));
+ } catch (Exception e) {
+ error.run();
+ }
+ });
+ }
+
+ public JsonObject getApiSync(String urlS) throws IOException {
+ URL url = new URL(urlS);
+ URLConnection connection = url.openConnection();
+ connection.setConnectTimeout(10000);
+ connection.setReadTimeout(10000);
+
+ String response = IOUtils.toString(connection.getInputStream(), StandardCharsets.UTF_8);
+
+ JsonObject json = gson.fromJson(response, JsonObject.class);
+ if (json == null) throw new ConnectException("Invalid JSON");
+ return json;
+ }
+
+ public JsonObject getApiGZIPSync(String urlS) throws IOException {
+ URL url = new URL(urlS);
+ URLConnection connection = url.openConnection();
+ connection.setConnectTimeout(10000);
+ connection.setReadTimeout(10000);
+
+ String response = IOUtils.toString(new GZIPInputStream(connection.getInputStream()), StandardCharsets.UTF_8);
+
+ JsonObject json = gson.fromJson(response, JsonObject.class);
+ return json;
+ }
+
+ public String generateApiUrl(String apiKey, String method, HashMap<String, String> args) {
+ if (apiKey != null)
+ args.put("key", apiKey.trim().replace("-", ""));
+ StringBuilder url = new StringBuilder("https://api.hypixel.net/" + method);
+ boolean first = true;
+ for (Map.Entry<String, String> entry : args.entrySet()) {
+ if (first) {
+ url.append("?");
+ first = false;
+ } else {
+ url.append("&");
+ }
+ try {
+ url.append(URLEncoder.encode(entry.getKey(), StandardCharsets.UTF_8.name())).append("=")
+ .append(URLEncoder.encode(entry.getValue(), StandardCharsets.UTF_8.name()));
+ } catch (UnsupportedEncodingException e) {
+ }
+ }
+ return url.toString();
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/LerpingFloat.java b/src/main/java/io/github/moulberry/notenoughupdates/util/LerpingFloat.java
index 83fa1a6d..a034fa8d 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/LerpingFloat.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/LerpingFloat.java
@@ -1,68 +1,67 @@
package io.github.moulberry.notenoughupdates.util;
public class LerpingFloat {
-
- private int timeSpent;
- private long lastMillis;
- private int timeToReachTarget;
-
- private float targetValue;
- private float lerpValue;
-
- public LerpingFloat(float initialValue, int timeToReachTarget) {
- this.targetValue = this.lerpValue = initialValue;
- this.timeToReachTarget = timeToReachTarget;
- }
-
- public LerpingFloat(int initialValue) {
- this(initialValue, 200);
- }
-
- public void tick() {
- int lastTimeSpent = timeSpent;
- this.timeSpent += System.currentTimeMillis() - lastMillis;
-
- float lastDistPercentToTarget = lastTimeSpent/(float)timeToReachTarget;
- float distPercentToTarget = timeSpent/(float)timeToReachTarget;
- float fac = (1-lastDistPercentToTarget)/lastDistPercentToTarget;
-
- float startValue = lerpValue - (targetValue - lerpValue)/fac;
-
- float dist = targetValue - startValue;
- if(dist == 0) return;
-
- float oldLerpValue = lerpValue;
- if(distPercentToTarget >= 1) {
- lerpValue = targetValue;
- } else {
- lerpValue = startValue + dist*distPercentToTarget;
- }
-
- if(lerpValue == oldLerpValue) {
- timeSpent = lastTimeSpent;
- } else {
- this.lastMillis = System.currentTimeMillis();
- }
- }
-
- public void resetTimer() {
- this.timeSpent = 0;
- this.lastMillis = System.currentTimeMillis();
- }
-
- public void setTarget(float targetValue) {
- this.targetValue = targetValue;
- }
-
- public void setValue(float value) {
- this.targetValue = this.lerpValue = value;
- }
-
- public float getValue() {
- return lerpValue;
- }
-
- public float getTarget() {
- return targetValue;
- }
+ private int timeSpent;
+ private long lastMillis;
+ private final int timeToReachTarget;
+
+ private float targetValue;
+ private float lerpValue;
+
+ public LerpingFloat(float initialValue, int timeToReachTarget) {
+ this.targetValue = this.lerpValue = initialValue;
+ this.timeToReachTarget = timeToReachTarget;
+ }
+
+ public LerpingFloat(int initialValue) {
+ this(initialValue, 200);
+ }
+
+ public void tick() {
+ int lastTimeSpent = timeSpent;
+ this.timeSpent += System.currentTimeMillis() - lastMillis;
+
+ float lastDistPercentToTarget = lastTimeSpent / (float) timeToReachTarget;
+ float distPercentToTarget = timeSpent / (float) timeToReachTarget;
+ float fac = (1 - lastDistPercentToTarget) / lastDistPercentToTarget;
+
+ float startValue = lerpValue - (targetValue - lerpValue) / fac;
+
+ float dist = targetValue - startValue;
+ if (dist == 0) return;
+
+ float oldLerpValue = lerpValue;
+ if (distPercentToTarget >= 1) {
+ lerpValue = targetValue;
+ } else {
+ lerpValue = startValue + dist * distPercentToTarget;
+ }
+
+ if (lerpValue == oldLerpValue) {
+ timeSpent = lastTimeSpent;
+ } else {
+ this.lastMillis = System.currentTimeMillis();
+ }
+ }
+
+ public void resetTimer() {
+ this.timeSpent = 0;
+ this.lastMillis = System.currentTimeMillis();
+ }
+
+ public void setTarget(float targetValue) {
+ this.targetValue = targetValue;
+ }
+
+ public void setValue(float value) {
+ this.targetValue = this.lerpValue = value;
+ }
+
+ public float getValue() {
+ return lerpValue;
+ }
+
+ public float getTarget() {
+ return targetValue;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/NEUResourceManager.java b/src/main/java/io/github/moulberry/notenoughupdates/util/NEUResourceManager.java
index 388fd4f6..3ef40567 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/NEUResourceManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/NEUResourceManager.java
@@ -1,6 +1,5 @@
package io.github.moulberry.notenoughupdates.util;
-import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.IResource;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.util.ResourceLocation;
@@ -10,29 +9,28 @@ import java.util.List;
import java.util.Set;
public class NEUResourceManager implements IResourceManager {
-
- private IResourceManager parentResourceManager;
-
- public NEUResourceManager(IResourceManager parentResourceManager) {
- this.parentResourceManager = parentResourceManager;
- }
-
- @Override
- public Set<String> getResourceDomains() {
- return parentResourceManager.getResourceDomains();
- }
-
- @Override
- public IResource getResource(ResourceLocation location) throws IOException {
- return parentResourceManager.getResource(forceNeuRL(location));
- }
-
- @Override
- public List<IResource> getAllResources(ResourceLocation location) throws IOException {
- return parentResourceManager.getAllResources(forceNeuRL(location));
- }
-
- private ResourceLocation forceNeuRL(ResourceLocation location) {
- return new ResourceLocation("notenoughupdates", location.getResourcePath());
- }
+ private final IResourceManager parentResourceManager;
+
+ public NEUResourceManager(IResourceManager parentResourceManager) {
+ this.parentResourceManager = parentResourceManager;
+ }
+
+ @Override
+ public Set<String> getResourceDomains() {
+ return parentResourceManager.getResourceDomains();
+ }
+
+ @Override
+ public IResource getResource(ResourceLocation location) throws IOException {
+ return parentResourceManager.getResource(forceNeuRL(location));
+ }
+
+ @Override
+ public List<IResource> getAllResources(ResourceLocation location) throws IOException {
+ return parentResourceManager.getAllResources(forceNeuRL(location));
+ }
+
+ private ResourceLocation forceNeuRL(ResourceLocation location) {
+ return new ResourceLocation("notenoughupdates", location.getResourcePath());
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/ProfileApiSyncer.java b/src/main/java/io/github/moulberry/notenoughupdates/util/ProfileApiSyncer.java
index 15482d0a..439ad571 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/ProfileApiSyncer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/ProfileApiSyncer.java
@@ -8,68 +8,71 @@ import java.util.HashMap;
import java.util.function.Consumer;
public class ProfileApiSyncer {
-
- private static ProfileApiSyncer INSTANCE = new ProfileApiSyncer();
-
- private HashMap<String, Long> resyncTimes = new HashMap<>();
- private HashMap<String, Runnable> syncingCallbacks = new HashMap<>();
- private HashMap<String, Consumer<ProfileViewer.Profile>> finishSyncCallbacks = new HashMap<>();
- private long lastResync;
-
- public static ProfileApiSyncer getInstance() {
- return INSTANCE;
- }
-
- public void requestResync(String id, long timeBetween) {
- requestResync(id, timeBetween, null);
- }
-
- public void requestResync(String id, long timeBetween, Runnable syncingCallback) {
- requestResync(id, timeBetween, null, null);
- }
-
- public void requestResync(String id, long timeBetween, Runnable syncingCallback, Consumer<ProfileViewer.Profile> finishSyncCallback) {
- resyncTimes.put(id, timeBetween);
- syncingCallbacks.put(id, syncingCallback);
- finishSyncCallbacks.put(id, finishSyncCallback);
- }
-
- public long getCurrentResyncTime() {
- long time = -1;
- for(long l : resyncTimes.values()) {
- if(l > 0 && (l < time || time == -1)) time = l;
- }
- return time;
- }
-
- public void tick() {
- if(Minecraft.getMinecraft().thePlayer == null) return;
-
- long resyncTime = getCurrentResyncTime();
-
- if(resyncTime < 0) return;
-
- long currentTime = System.currentTimeMillis();
-
- if(currentTime - lastResync > resyncTime) {
- lastResync = currentTime;
- resyncTimes.clear();
-
- for(Runnable r : syncingCallbacks.values()) r.run();
- syncingCallbacks.clear();
-
- forceResync();
- }
- }
-
- private void forceResync() {
- if(Minecraft.getMinecraft().thePlayer == null) return;
-
- String uuid = Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", "");
- NotEnoughUpdates.profileViewer.getProfileReset(uuid, (profile) -> {
- for(Consumer<ProfileViewer.Profile> c : finishSyncCallbacks.values()) c.accept(profile);
- finishSyncCallbacks.clear();
- });
- }
-
+ private static final ProfileApiSyncer INSTANCE = new ProfileApiSyncer();
+
+ private final HashMap<String, Long> resyncTimes = new HashMap<>();
+ private final HashMap<String, Runnable> syncingCallbacks = new HashMap<>();
+ private final HashMap<String, Consumer<ProfileViewer.Profile>> finishSyncCallbacks = new HashMap<>();
+ private long lastResync;
+
+ public static ProfileApiSyncer getInstance() {
+ return INSTANCE;
+ }
+
+ public void requestResync(String id, long timeBetween) {
+ requestResync(id, timeBetween, null);
+ }
+
+ public void requestResync(String id, long timeBetween, Runnable syncingCallback) {
+ requestResync(id, timeBetween, null, null);
+ }
+
+ public void requestResync(
+ String id,
+ long timeBetween,
+ Runnable syncingCallback,
+ Consumer<ProfileViewer.Profile> finishSyncCallback
+ ) {
+ resyncTimes.put(id, timeBetween);
+ syncingCallbacks.put(id, syncingCallback);
+ finishSyncCallbacks.put(id, finishSyncCallback);
+ }
+
+ public long getCurrentResyncTime() {
+ long time = -1;
+ for (long l : resyncTimes.values()) {
+ if (l > 0 && (l < time || time == -1)) time = l;
+ }
+ return time;
+ }
+
+ public void tick() {
+ if (Minecraft.getMinecraft().thePlayer == null) return;
+
+ long resyncTime = getCurrentResyncTime();
+
+ if (resyncTime < 0) return;
+
+ long currentTime = System.currentTimeMillis();
+
+ if (currentTime - lastResync > resyncTime) {
+ lastResync = currentTime;
+ resyncTimes.clear();
+
+ for (Runnable r : syncingCallbacks.values()) r.run();
+ syncingCallbacks.clear();
+
+ forceResync();
+ }
+ }
+
+ private void forceResync() {
+ if (Minecraft.getMinecraft().thePlayer == null) return;
+
+ String uuid = Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", "");
+ NotEnoughUpdates.profileViewer.getProfileReset(uuid, (profile) -> {
+ for (Consumer<ProfileViewer.Profile> c : finishSyncCallbacks.values()) c.accept(profile);
+ finishSyncCallbacks.clear();
+ });
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/RequestFocusListener.java b/src/main/java/io/github/moulberry/notenoughupdates/util/RequestFocusListener.java
index 2365b60b..3df5d9f1 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/RequestFocusListener.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/RequestFocusListener.java
@@ -1,63 +1,62 @@
package io.github.moulberry.notenoughupdates.util;
import javax.swing.*;
-import javax.swing.event.*;
+import javax.swing.event.AncestorEvent;
+import javax.swing.event.AncestorListener;
/**
- * Convenience class to request focus on a component.
- *
- * When the component is added to a realized Window then component will
- * request focus immediately, since the ancestorAdded event is fired
- * immediately.
- *
- * When the component is added to a non realized Window, then the focus
- * request will be made once the window is realized, since the
- * ancestorAdded event will not be fired until then.
- *
- * Using the default constructor will cause the listener to be removed
- * from the component once the AncestorEvent is generated. A second constructor
- * allows you to specify a boolean value of false to prevent the
- * AncestorListener from being removed when the event is generated. This will
- * allow you to reuse the listener each time the event is generated.
+ * Convenience class to request focus on a component.
+ * <p>
+ * When the component is added to a realized Window then component will
+ * request focus immediately, since the ancestorAdded event is fired
+ * immediately.
+ * <p>
+ * When the component is added to a non realized Window, then the focus
+ * request will be made once the window is realized, since the
+ * ancestorAdded event will not be fired until then.
+ * <p>
+ * Using the default constructor will cause the listener to be removed
+ * from the component once the AncestorEvent is generated. A second constructor
+ * allows you to specify a boolean value of false to prevent the
+ * AncestorListener from being removed when the event is generated. This will
+ * allow you to reuse the listener each time the event is generated.
*/
-public class RequestFocusListener implements AncestorListener
-{
- private boolean removeListener;
-
- /*
- * Convenience constructor. The listener is only used once and then it is
- * removed from the component.
- */
- public RequestFocusListener()
- {
- this(true);
- }
-
- /*
- * Constructor that controls whether this listen can be used once or
- * multiple times.
- *
- * @param removeListener when true this listener is only invoked once
- * otherwise it can be invoked multiple times.
- */
- public RequestFocusListener(boolean removeListener)
- {
- this.removeListener = removeListener;
- }
-
- @Override
- public void ancestorAdded(AncestorEvent e)
- {
- JComponent component = e.getComponent();
- component.requestFocusInWindow();
-
- if (removeListener)
- component.removeAncestorListener( this );
- }
-
- @Override
- public void ancestorMoved(AncestorEvent e) {}
-
- @Override
- public void ancestorRemoved(AncestorEvent e) {}
+public class RequestFocusListener implements AncestorListener {
+ private final boolean removeListener;
+
+ /*
+ * Convenience constructor. The listener is only used once, and then it is
+ * removed from the component.
+ */
+ public RequestFocusListener() {
+ this(true);
+ }
+
+ /*
+ * Constructor that controls whether this listen can be used once or
+ * multiple times.
+ *
+ * @param removeListener when true this listener is only invoked once
+ * otherwise it can be invoked multiple times.
+ */
+ public RequestFocusListener(boolean removeListener) {
+ this.removeListener = removeListener;
+ }
+
+ @Override
+ public void ancestorAdded(AncestorEvent e) {
+ JComponent component = e.getComponent();
+ component.requestFocusInWindow();
+
+ if (removeListener)
+ component.removeAncestorListener(this);
+ }
+
+ @Override
+ public void ancestorMoved(AncestorEvent e) {
+ }
+
+ @Override
+ public void ancestorRemoved(AncestorEvent e) {
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/ReverseWorldRenderer.java b/src/main/java/io/github/moulberry/notenoughupdates/util/ReverseWorldRenderer.java
index 12c9a380..c517bd08 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/ReverseWorldRenderer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/ReverseWorldRenderer.java
@@ -1,16 +1,6 @@
package io.github.moulberry.notenoughupdates.util;
import com.google.common.primitives.Floats;
-
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.nio.FloatBuffer;
-import java.nio.IntBuffer;
-import java.nio.ShortBuffer;
-import java.util.Arrays;
-import java.util.BitSet;
-import java.util.Comparator;
-
import net.minecraft.client.renderer.GLAllocation;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.client.renderer.vertex.VertexFormatElement;
@@ -19,534 +9,559 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.logging.log4j.LogManager;
+import java.nio.*;
+import java.util.Arrays;
+import java.util.BitSet;
+import java.util.Comparator;
+
@SideOnly(Side.CLIENT)
public class ReverseWorldRenderer {
- private ByteBuffer byteBuffer;
- private IntBuffer rawIntBuffer;
- private ShortBuffer rawShortBuffer;
- private FloatBuffer rawFloatBuffer;
- private int vertexCount;
- private VertexFormatElement vertexFormatElement;
- private int vertexFormatIndex;
- /**
- * None
- */
- private boolean noColor;
- private int drawMode;
- private double xOffset;
- private double yOffset;
- private double zOffset;
- private VertexFormat vertexFormat;
- private boolean isDrawing;
-
- public ReverseWorldRenderer(int bufferSizeIn) {
- this.byteBuffer = GLAllocation.createDirectByteBuffer(bufferSizeIn * 4);
- this.rawIntBuffer = this.byteBuffer.asIntBuffer();
- this.rawShortBuffer = this.byteBuffer.asShortBuffer();
- this.rawFloatBuffer = this.byteBuffer.asFloatBuffer();
- }
-
- private void growBuffer(int p_181670_1_) {
- if (p_181670_1_ > this.rawIntBuffer.remaining()) {
- int i = this.byteBuffer.capacity();
- int j = i % 2097152;
- int k = j + (((this.rawIntBuffer.position() + p_181670_1_) * 4 - j) / 2097152 + 1) * 2097152;
- LogManager.getLogger().warn("Needed to grow BufferBuilder buffer: Old size " + i + " bytes, new size " + k + " bytes.");
- int l = this.rawIntBuffer.position();
- ByteBuffer bytebuffer = GLAllocation.createDirectByteBuffer(k);
- this.byteBuffer.position(0);
- bytebuffer.put(this.byteBuffer);
- bytebuffer.rewind();
- this.byteBuffer = bytebuffer;
- this.rawFloatBuffer = this.byteBuffer.asFloatBuffer().asReadOnlyBuffer();
- this.rawIntBuffer = this.byteBuffer.asIntBuffer();
- this.rawIntBuffer.position(l);
- this.rawShortBuffer = this.byteBuffer.asShortBuffer();
- this.rawShortBuffer.position(l << 1);
- }
- }
-
- public void sortVertexData(float p_181674_1_, float p_181674_2_, float p_181674_3_) {
- int i = this.vertexCount / 4;
- final float[] afloat = new float[i];
-
- for (int j = 0; j < i; ++j) {
- afloat[j] = func_181665_a(this.rawFloatBuffer, (float) ((double) p_181674_1_ + this.xOffset), (float) ((double) p_181674_2_ + this.yOffset), (float) ((double) p_181674_3_ + this.zOffset), this.vertexFormat.getIntegerSize(), j * this.vertexFormat.getNextOffset());
- }
-
- Integer[] ainteger = new Integer[i];
-
- for (int k = 0; k < ainteger.length; ++k) {
- ainteger[k] = Integer.valueOf(k);
- }
-
- Arrays.sort(ainteger, new Comparator<Integer>() {
- public int compare(Integer p_compare_1_, Integer p_compare_2_) {
- return -Floats.compare(afloat[p_compare_2_.intValue()], afloat[p_compare_1_.intValue()]);
- }
- });
- BitSet bitset = new BitSet();
- int l = this.vertexFormat.getNextOffset();
- int[] aint = new int[l];
-
- for (int l1 = 0; (l1 = bitset.nextClearBit(l1)) < ainteger.length; ++l1) {
- int i1 = ainteger[l1].intValue();
-
- if (i1 != l1) {
- this.rawIntBuffer.limit(i1 * l + l);
- this.rawIntBuffer.position(i1 * l);
- this.rawIntBuffer.get(aint);
- int j1 = i1;
-
- for (int k1 = ainteger[i1].intValue(); j1 != l1; k1 = ainteger[k1].intValue()) {
- this.rawIntBuffer.limit(k1 * l + l);
- this.rawIntBuffer.position(k1 * l);
- IntBuffer intbuffer = this.rawIntBuffer.slice();
- this.rawIntBuffer.limit(j1 * l + l);
- this.rawIntBuffer.position(j1 * l);
- this.rawIntBuffer.put(intbuffer);
- bitset.set(j1);
- j1 = k1;
- }
-
- this.rawIntBuffer.limit(l1 * l + l);
- this.rawIntBuffer.position(l1 * l);
- this.rawIntBuffer.put(aint);
- }
-
- bitset.set(l1);
- }
- }
-
- public State getVertexState() {
- this.rawIntBuffer.rewind();
- int i = this.getBufferSize();
- this.rawIntBuffer.limit(i);
- int[] aint = new int[i];
- this.rawIntBuffer.get(aint);
- this.rawIntBuffer.limit(this.rawIntBuffer.capacity());
- this.rawIntBuffer.position(i);
- return new State(aint, new VertexFormat(this.vertexFormat));
- }
-
- private int getBufferSize() {
- return this.vertexCount * this.vertexFormat.getIntegerSize();
- }
-
- private static float func_181665_a(FloatBuffer p_181665_0_, float p_181665_1_, float p_181665_2_, float p_181665_3_, int p_181665_4_, int p_181665_5_) {
- float f = p_181665_0_.get(p_181665_5_ + p_181665_4_ * 0 + 0);
- float f1 = p_181665_0_.get(p_181665_5_ + p_181665_4_ * 0 + 1);
- float f2 = p_181665_0_.get(p_181665_5_ + p_181665_4_ * 0 + 2);
- float f3 = p_181665_0_.get(p_181665_5_ + p_181665_4_ * 1 + 0);
- float f4 = p_181665_0_.get(p_181665_5_ + p_181665_4_ * 1 + 1);
- float f5 = p_181665_0_.get(p_181665_5_ + p_181665_4_ * 1 + 2);
- float f6 = p_181665_0_.get(p_181665_5_ + p_181665_4_ * 2 + 0);
- float f7 = p_181665_0_.get(p_181665_5_ + p_181665_4_ * 2 + 1);
- float f8 = p_181665_0_.get(p_181665_5_ + p_181665_4_ * 2 + 2);
- float f9 = p_181665_0_.get(p_181665_5_ + p_181665_4_ * 3 + 0);
- float f10 = p_181665_0_.get(p_181665_5_ + p_181665_4_ * 3 + 1);
- float f11 = p_181665_0_.get(p_181665_5_ + p_181665_4_ * 3 + 2);
- float f12 = (f + f3 + f6 + f9) * 0.25F - p_181665_1_;
- float f13 = (f1 + f4 + f7 + f10) * 0.25F - p_181665_2_;
- float f14 = (f2 + f5 + f8 + f11) * 0.25F - p_181665_3_;
- return f12 * f12 + f13 * f13 + f14 * f14;
- }
-
- public void setVertexState(State state) {
- this.rawIntBuffer.clear();
- this.growBuffer(state.getRawBuffer().length);
- this.rawIntBuffer.put(state.getRawBuffer());
- this.vertexCount = state.getVertexCount();
- this.vertexFormat = new VertexFormat(state.getVertexFormat());
- }
-
- public void reset() {
- this.vertexCount = 0;
- this.vertexFormatElement = null;
- this.vertexFormatIndex = 0;
- }
-
- public void begin(int glMode, VertexFormat format) {
- if (this.isDrawing) {
- throw new IllegalStateException("Already building!");
- } else {
- this.isDrawing = true;
- this.reset();
- this.drawMode = glMode;
- this.vertexFormat = format;
- this.vertexFormatElement = format.getElement(this.vertexFormatIndex);
- this.noColor = false;
- this.byteBuffer.limit(this.byteBuffer.capacity());
- }
- }
-
- public ReverseWorldRenderer tex(double u, double v) {
- int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex);
-
- switch (this.vertexFormatElement.getType()) {
- case FLOAT:
- this.byteBuffer.putFloat(i, (float) u);
- this.byteBuffer.putFloat(i + 4, (float) v);
- break;
- case UINT:
- case INT:
- this.byteBuffer.putInt(i, (int) u);
- this.byteBuffer.putInt(i + 4, (int) v);
- break;
- case USHORT:
- case SHORT:
- this.byteBuffer.putShort(i, (short) ((int) v));
- this.byteBuffer.putShort(i + 2, (short) ((int) u));
- break;
- case UBYTE:
- case BYTE:
- this.byteBuffer.put(i, (byte) ((int) v));
- this.byteBuffer.put(i + 1, (byte) ((int) u));
- }
-
- this.nextVertexFormatIndex();
- return this;
- }
-
- public ReverseWorldRenderer lightmap(int p_181671_1_, int p_181671_2_) {
- int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex);
-
- switch (this.vertexFormatElement.getType()) {
- case FLOAT:
- this.byteBuffer.putFloat(i, (float) p_181671_1_);
- this.byteBuffer.putFloat(i + 4, (float) p_181671_2_);
- break;
- case UINT:
- case INT:
- this.byteBuffer.putInt(i, p_181671_1_);
- this.byteBuffer.putInt(i + 4, p_181671_2_);
- break;
- case USHORT:
- case SHORT:
- this.byteBuffer.putShort(i, (short) p_181671_2_);
- this.byteBuffer.putShort(i + 2, (short) p_181671_1_);
- break;
- case UBYTE:
- case BYTE:
- this.byteBuffer.put(i, (byte) p_181671_2_);
- this.byteBuffer.put(i + 1, (byte) p_181671_1_);
- }
-
- this.nextVertexFormatIndex();
- return this;
- }
-
- public void putBrightness4(int p_178962_1_, int p_178962_2_, int p_178962_3_, int p_178962_4_) {
- int i = (this.vertexCount - 4) * this.vertexFormat.getIntegerSize() + this.vertexFormat.getUvOffsetById(1) / 4;
- int j = this.vertexFormat.getNextOffset() >> 2;
- this.rawIntBuffer.put(i, p_178962_1_);
- this.rawIntBuffer.put(i + j, p_178962_2_);
- this.rawIntBuffer.put(i + j * 2, p_178962_3_);
- this.rawIntBuffer.put(i + j * 3, p_178962_4_);
- }
-
- public void putPosition(double x, double y, double z) {
- int i = this.vertexFormat.getIntegerSize();
- int j = (this.vertexCount - 4) * i;
-
- for (int k = 0; k < 4; ++k) {
- int l = j + k * i;
- int i1 = l + 1;
- int j1 = i1 + 1;
- this.rawIntBuffer.put(l, Float.floatToRawIntBits((float) (x + this.xOffset) + Float.intBitsToFloat(this.rawIntBuffer.get(l))));
- this.rawIntBuffer.put(i1, Float.floatToRawIntBits((float) (y + this.yOffset) + Float.intBitsToFloat(this.rawIntBuffer.get(i1))));
- this.rawIntBuffer.put(j1, Float.floatToRawIntBits((float) (z + this.zOffset) + Float.intBitsToFloat(this.rawIntBuffer.get(j1))));
- }
- }
-
- /**
- * Takes in the pass the call list is being requested for. Args: renderPass
- */
- public int getColorIndex(int p_78909_1_) {
- return ((this.vertexCount - p_78909_1_) * this.vertexFormat.getNextOffset() + this.vertexFormat.getColorOffset()) / 4;
- }
-
- public void putColorMultiplier(float red, float green, float blue, int p_178978_4_) {
- int i = this.getColorIndex(p_178978_4_);
- int j = -1;
-
- if (!this.noColor) {
- j = this.rawIntBuffer.get(i);
-
- if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) {
- int k = (int) ((float) (j & 255) * red);
- int l = (int) ((float) (j >> 8 & 255) * green);
- int i1 = (int) ((float) (j >> 16 & 255) * blue);
- j = j & -16777216;
- j = j | i1 << 16 | l << 8 | k;
- } else {
- int j1 = (int) ((float) (j >> 24 & 255) * red);
- int k1 = (int) ((float) (j >> 16 & 255) * green);
- int l1 = (int) ((float) (j >> 8 & 255) * blue);
- j = j & 255;
- j = j | j1 << 24 | k1 << 16 | l1 << 8;
- }
- }
-
- this.rawIntBuffer.put(i, j);
- }
-
- private void putColor(int argb, int p_178988_2_) {
- int i = this.getColorIndex(p_178988_2_);
- int j = argb >> 16 & 255;
- int k = argb >> 8 & 255;
- int l = argb & 255;
- int i1 = argb >> 24 & 255;
- this.putColorRGBA(i, j, k, l, i1);
- }
-
- public void putColorRGB_F(float red, float green, float blue, int p_178994_4_) {
- int i = this.getColorIndex(p_178994_4_);
- int j = MathHelper.clamp_int((int) (red * 255.0F), 0, 255);
- int k = MathHelper.clamp_int((int) (green * 255.0F), 0, 255);
- int l = MathHelper.clamp_int((int) (blue * 255.0F), 0, 255);
- this.putColorRGBA(i, j, k, l, 255);
- }
-
- public void putColorRGBA(int index, int red, int p_178972_3_, int p_178972_4_, int p_178972_5_) {
- if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) {
- this.rawIntBuffer.put(index, p_178972_5_ << 24 | p_178972_4_ << 16 | p_178972_3_ << 8 | red);
- } else {
- this.rawIntBuffer.put(index, red << 24 | p_178972_3_ << 16 | p_178972_4_ << 8 | p_178972_5_);
- }
- }
-
- /**
- * Disabels color processing.
- */
- public void noColor() {
- this.noColor = true;
- }
-
- public ReverseWorldRenderer color(float red, float green, float blue, float alpha) {
- return this.color((int) (red * 255.0F), (int) (green * 255.0F), (int) (blue * 255.0F), (int) (alpha * 255.0F));
- }
-
- public ReverseWorldRenderer color(int red, int green, int blue, int alpha) {
- if (this.noColor) {
- return this;
- } else {
- int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex);
-
- switch (this.vertexFormatElement.getType()) {
- case FLOAT:
- this.byteBuffer.putFloat(i, (float) red / 255.0F);
- this.byteBuffer.putFloat(i + 4, (float) green / 255.0F);
- this.byteBuffer.putFloat(i + 8, (float) blue / 255.0F);
- this.byteBuffer.putFloat(i + 12, (float) alpha / 255.0F);
- break;
- case UINT:
- case INT:
- this.byteBuffer.putFloat(i, (float) red);
- this.byteBuffer.putFloat(i + 4, (float) green);
- this.byteBuffer.putFloat(i + 8, (float) blue);
- this.byteBuffer.putFloat(i + 12, (float) alpha);
- break;
- case USHORT:
- case SHORT:
- this.byteBuffer.putShort(i, (short) red);
- this.byteBuffer.putShort(i + 2, (short) green);
- this.byteBuffer.putShort(i + 4, (short) blue);
- this.byteBuffer.putShort(i + 6, (short) alpha);
- break;
- case UBYTE:
- case BYTE:
-
- if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) {
- this.byteBuffer.put(i, (byte) red);
- this.byteBuffer.put(i + 1, (byte) green);
- this.byteBuffer.put(i + 2, (byte) blue);
- this.byteBuffer.put(i + 3, (byte) alpha);
- } else {
- this.byteBuffer.put(i, (byte) alpha);
- this.byteBuffer.put(i + 1, (byte) blue);
- this.byteBuffer.put(i + 2, (byte) green);
- this.byteBuffer.put(i + 3, (byte) red);
- }
- }
-
- this.nextVertexFormatIndex();
- return this;
- }
- }
-
- public void addVertexData(int[] vertexData) {
- this.growBuffer(vertexData.length);
- this.rawIntBuffer.position(this.getBufferSize());
- this.rawIntBuffer.put(vertexData);
- this.vertexCount += vertexData.length / this.vertexFormat.getIntegerSize();
- }
-
- public void endVertex() {
- ++this.vertexCount;
- this.growBuffer(this.vertexFormat.getIntegerSize());
- }
-
- public ReverseWorldRenderer pos(double x, double y, double z) {
- int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex);
-
- switch (this.vertexFormatElement.getType()) {
- case FLOAT:
- this.byteBuffer.putFloat(i, (float) (x + this.xOffset));
- this.byteBuffer.putFloat(i + 4, (float) (y + this.yOffset));
- this.byteBuffer.putFloat(i + 8, (float) (z + this.zOffset));
- break;
- case UINT:
- case INT:
- this.byteBuffer.putInt(i, Float.floatToRawIntBits((float) (x + this.xOffset)));
- this.byteBuffer.putInt(i + 4, Float.floatToRawIntBits((float) (y + this.yOffset)));
- this.byteBuffer.putInt(i + 8, Float.floatToRawIntBits((float) (z + this.zOffset)));
- break;
- case USHORT:
- case SHORT:
- this.byteBuffer.putShort(i, (short) ((int) (x + this.xOffset)));
- this.byteBuffer.putShort(i + 2, (short) ((int) (y + this.yOffset)));
- this.byteBuffer.putShort(i + 4, (short) ((int) (z + this.zOffset)));
- break;
- case UBYTE:
- case BYTE:
- this.byteBuffer.put(i, (byte) ((int) (x + this.xOffset)));
- this.byteBuffer.put(i + 1, (byte) ((int) (y + this.yOffset)));
- this.byteBuffer.put(i + 2, (byte) ((int) (z + this.zOffset)));
- }
-
- this.nextVertexFormatIndex();
- return this;
- }
-
- public void putNormal(float x, float y, float z) {
- int i = (byte) ((int) (x * 127.0F)) & 255;
- int j = (byte) ((int) (y * 127.0F)) & 255;
- int k = (byte) ((int) (z * 127.0F)) & 255;
- int l = i | j << 8 | k << 16;
- int i1 = this.vertexFormat.getNextOffset() >> 2;
- int j1 = (this.vertexCount - 4) * i1 + this.vertexFormat.getNormalOffset() / 4;
- this.rawIntBuffer.put(j1, l);
- this.rawIntBuffer.put(j1 + i1, l);
- this.rawIntBuffer.put(j1 + i1 * 2, l);
- this.rawIntBuffer.put(j1 + i1 * 3, l);
- }
-
- private void nextVertexFormatIndex() {
- ++this.vertexFormatIndex;
- this.vertexFormatIndex %= this.vertexFormat.getElementCount();
- this.vertexFormatElement = this.vertexFormat.getElement(this.vertexFormatIndex);
-
- if (this.vertexFormatElement.getUsage() == VertexFormatElement.EnumUsage.PADDING) {
- this.nextVertexFormatIndex();
- }
- }
-
- public ReverseWorldRenderer normal(float p_181663_1_, float p_181663_2_, float p_181663_3_) {
- int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex);
-
- switch (this.vertexFormatElement.getType()) {
- case FLOAT:
- this.byteBuffer.putFloat(i, p_181663_1_);
- this.byteBuffer.putFloat(i + 4, p_181663_2_);
- this.byteBuffer.putFloat(i + 8, p_181663_3_);
- break;
- case UINT:
- case INT:
- this.byteBuffer.putInt(i, (int) p_181663_1_);
- this.byteBuffer.putInt(i + 4, (int) p_181663_2_);
- this.byteBuffer.putInt(i + 8, (int) p_181663_3_);
- break;
- case USHORT:
- case SHORT:
- this.byteBuffer.putShort(i, (short) ((int) (p_181663_1_ * 32767) & 65535));
- this.byteBuffer.putShort(i + 2, (short) ((int) (p_181663_2_ * 32767) & 65535));
- this.byteBuffer.putShort(i + 4, (short) ((int) (p_181663_3_ * 32767) & 65535));
- break;
- case UBYTE:
- case BYTE:
- this.byteBuffer.put(i, (byte) ((int) (p_181663_1_ * 127) & 255));
- this.byteBuffer.put(i + 1, (byte) ((int) (p_181663_2_ * 127) & 255));
- this.byteBuffer.put(i + 2, (byte) ((int) (p_181663_3_ * 127) & 255));
- }
-
- this.nextVertexFormatIndex();
- return this;
- }
-
- public void setTranslation(double x, double y, double z) {
- this.xOffset = x;
- this.yOffset = y;
- this.zOffset = z;
- }
-
- public void finishDrawing() {
- if (!this.isDrawing) {
- throw new IllegalStateException("Not building!");
- } else {
- this.isDrawing = false;
- this.byteBuffer.position(0);
- this.byteBuffer.limit(this.getBufferSize() * 4);
- }
- }
-
- public ByteBuffer getByteBuffer() {
- return this.byteBuffer;
- }
-
- public VertexFormat getVertexFormat() {
- return this.vertexFormat;
- }
-
- public int getVertexCount() {
- return this.vertexCount;
- }
-
- public int getDrawMode() {
- return this.drawMode;
- }
-
- public void putColor4(int argb) {
- for (int i = 0; i < 4; ++i) {
- this.putColor(argb, i + 1);
- }
- }
-
- public void putColorRGB_F4(float red, float green, float blue) {
- for (int i = 0; i < 4; ++i) {
- this.putColorRGB_F(red, green, blue, i + 1);
- }
- }
-
- public void checkAndGrow() {
- this.growBuffer(vertexFormat.getNextOffset()/* / 4 * 4 */);
- }
-
- public boolean isColorDisabled() {
- /** None */
- return noColor;
- }
-
- @SideOnly(Side.CLIENT)
- public class State {
- private final int[] stateRawBuffer;
- private final VertexFormat stateVertexFormat;
-
- public State(int[] buffer, VertexFormat format) {
- this.stateRawBuffer = buffer;
- this.stateVertexFormat = format;
- }
-
- public int[] getRawBuffer() {
- return this.stateRawBuffer;
- }
-
- public int getVertexCount() {
- return this.stateRawBuffer.length / this.stateVertexFormat.getIntegerSize();
- }
-
- public VertexFormat getVertexFormat() {
- return this.stateVertexFormat;
- }
- }
+ private ByteBuffer byteBuffer;
+ private IntBuffer rawIntBuffer;
+ private ShortBuffer rawShortBuffer;
+ private FloatBuffer rawFloatBuffer;
+ private int vertexCount;
+ private VertexFormatElement vertexFormatElement;
+ private int vertexFormatIndex;
+ /**
+ * None
+ */
+ private boolean noColor;
+ private int drawMode;
+ private double xOffset;
+ private double yOffset;
+ private double zOffset;
+ private VertexFormat vertexFormat;
+ private boolean isDrawing;
+
+ public ReverseWorldRenderer(int bufferSizeIn) {
+ this.byteBuffer = GLAllocation.createDirectByteBuffer(bufferSizeIn * 4);
+ this.rawIntBuffer = this.byteBuffer.asIntBuffer();
+ this.rawShortBuffer = this.byteBuffer.asShortBuffer();
+ this.rawFloatBuffer = this.byteBuffer.asFloatBuffer();
+ }
+
+ private void growBuffer(int p_181670_1_) {
+ if (p_181670_1_ > this.rawIntBuffer.remaining()) {
+ int i = this.byteBuffer.capacity();
+ int j = i % 2097152;
+ int k = j + (((this.rawIntBuffer.position() + p_181670_1_) * 4 - j) / 2097152 + 1) * 2097152;
+ LogManager
+ .getLogger()
+ .warn("Needed to grow BufferBuilder buffer: Old size " + i + " bytes, new size " + k + " bytes.");
+ int l = this.rawIntBuffer.position();
+ ByteBuffer bytebuffer = GLAllocation.createDirectByteBuffer(k);
+ this.byteBuffer.position(0);
+ bytebuffer.put(this.byteBuffer);
+ bytebuffer.rewind();
+ this.byteBuffer = bytebuffer;
+ this.rawFloatBuffer = this.byteBuffer.asFloatBuffer().asReadOnlyBuffer();
+ this.rawIntBuffer = this.byteBuffer.asIntBuffer();
+ this.rawIntBuffer.position(l);
+ this.rawShortBuffer = this.byteBuffer.asShortBuffer();
+ this.rawShortBuffer.position(l << 1);
+ }
+ }
+
+ public void sortVertexData(float p_181674_1_, float p_181674_2_, float p_181674_3_) {
+ int i = this.vertexCount / 4;
+ final float[] afloat = new float[i];
+
+ for (int j = 0; j < i; ++j) {
+ afloat[j] = func_181665_a(
+ this.rawFloatBuffer,
+ (float) ((double) p_181674_1_ + this.xOffset),
+ (float) ((double) p_181674_2_ + this.yOffset),
+ (float) ((double) p_181674_3_ + this.zOffset),
+ this.vertexFormat.getIntegerSize(),
+ j * this.vertexFormat.getNextOffset()
+ );
+ }
+
+ Integer[] ainteger = new Integer[i];
+
+ for (int k = 0; k < ainteger.length; ++k) {
+ ainteger[k] = k;
+ }
+
+ Arrays.sort(ainteger, (p_compare_1_, p_compare_2_) -> -Floats.compare(afloat[p_compare_2_], afloat[p_compare_1_]));
+ BitSet bitset = new BitSet();
+ int l = this.vertexFormat.getNextOffset();
+ int[] aint = new int[l];
+
+ for (int l1 = 0; (l1 = bitset.nextClearBit(l1)) < ainteger.length; ++l1) {
+ int i1 = ainteger[l1];
+
+ if (i1 != l1) {
+ this.rawIntBuffer.limit(i1 * l + l);
+ this.rawIntBuffer.position(i1 * l);
+ this.rawIntBuffer.get(aint);
+ int j1 = i1;
+
+ for (int k1 = ainteger[i1]; j1 != l1; k1 = ainteger[k1]) {
+ this.rawIntBuffer.limit(k1 * l + l);
+ this.rawIntBuffer.position(k1 * l);
+ IntBuffer intbuffer = this.rawIntBuffer.slice();
+ this.rawIntBuffer.limit(j1 * l + l);
+ this.rawIntBuffer.position(j1 * l);
+ this.rawIntBuffer.put(intbuffer);
+ bitset.set(j1);
+ j1 = k1;
+ }
+
+ this.rawIntBuffer.limit(l1 * l + l);
+ this.rawIntBuffer.position(l1 * l);
+ this.rawIntBuffer.put(aint);
+ }
+
+ bitset.set(l1);
+ }
+ }
+
+ public State getVertexState() {
+ this.rawIntBuffer.rewind();
+ int i = this.getBufferSize();
+ this.rawIntBuffer.limit(i);
+ int[] aint = new int[i];
+ this.rawIntBuffer.get(aint);
+ this.rawIntBuffer.limit(this.rawIntBuffer.capacity());
+ this.rawIntBuffer.position(i);
+ return new State(aint, new VertexFormat(this.vertexFormat));
+ }
+
+ private int getBufferSize() {
+ return this.vertexCount * this.vertexFormat.getIntegerSize();
+ }
+
+ private static float func_181665_a(
+ FloatBuffer p_181665_0_,
+ float p_181665_1_,
+ float p_181665_2_,
+ float p_181665_3_,
+ int p_181665_4_,
+ int p_181665_5_
+ ) {
+ float f = p_181665_0_.get(p_181665_5_ + p_181665_4_ * 0 + 0);
+ float f1 = p_181665_0_.get(p_181665_5_ + p_181665_4_ * 0 + 1);
+ float f2 = p_181665_0_.get(p_181665_5_ + p_181665_4_ * 0 + 2);
+ float f3 = p_181665_0_.get(p_181665_5_ + p_181665_4_ * 1 + 0);
+ float f4 = p_181665_0_.get(p_181665_5_ + p_181665_4_ * 1 + 1);
+ float f5 = p_181665_0_.get(p_181665_5_ + p_181665_4_ * 1 + 2);
+ float f6 = p_181665_0_.get(p_181665_5_ + p_181665_4_ * 2 + 0);
+ float f7 = p_181665_0_.get(p_181665_5_ + p_181665_4_ * 2 + 1);
+ float f8 = p_181665_0_.get(p_181665_5_ + p_181665_4_ * 2 + 2);
+ float f9 = p_181665_0_.get(p_181665_5_ + p_181665_4_ * 3 + 0);
+ float f10 = p_181665_0_.get(p_181665_5_ + p_181665_4_ * 3 + 1);
+ float f11 = p_181665_0_.get(p_181665_5_ + p_181665_4_ * 3 + 2);
+ float f12 = (f + f3 + f6 + f9) * 0.25F - p_181665_1_;
+ float f13 = (f1 + f4 + f7 + f10) * 0.25F - p_181665_2_;
+ float f14 = (f2 + f5 + f8 + f11) * 0.25F - p_181665_3_;
+ return f12 * f12 + f13 * f13 + f14 * f14;
+ }
+
+ public void setVertexState(State state) {
+ this.rawIntBuffer.clear();
+ this.growBuffer(state.getRawBuffer().length);
+ this.rawIntBuffer.put(state.getRawBuffer());
+ this.vertexCount = state.getVertexCount();
+ this.vertexFormat = new VertexFormat(state.getVertexFormat());
+ }
+
+ public void reset() {
+ this.vertexCount = 0;
+ this.vertexFormatElement = null;
+ this.vertexFormatIndex = 0;
+ }
+
+ public void begin(int glMode, VertexFormat format) {
+ if (this.isDrawing) {
+ throw new IllegalStateException("Already building!");
+ } else {
+ this.isDrawing = true;
+ this.reset();
+ this.drawMode = glMode;
+ this.vertexFormat = format;
+ this.vertexFormatElement = format.getElement(this.vertexFormatIndex);
+ this.noColor = false;
+ this.byteBuffer.limit(this.byteBuffer.capacity());
+ }
+ }
+
+ public ReverseWorldRenderer tex(double u, double v) {
+ int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex);
+
+ switch (this.vertexFormatElement.getType()) {
+ case FLOAT:
+ this.byteBuffer.putFloat(i, (float) u);
+ this.byteBuffer.putFloat(i + 4, (float) v);
+ break;
+ case UINT:
+ case INT:
+ this.byteBuffer.putInt(i, (int) u);
+ this.byteBuffer.putInt(i + 4, (int) v);
+ break;
+ case USHORT:
+ case SHORT:
+ this.byteBuffer.putShort(i, (short) ((int) v));
+ this.byteBuffer.putShort(i + 2, (short) ((int) u));
+ break;
+ case UBYTE:
+ case BYTE:
+ this.byteBuffer.put(i, (byte) ((int) v));
+ this.byteBuffer.put(i + 1, (byte) ((int) u));
+ }
+
+ this.nextVertexFormatIndex();
+ return this;
+ }
+
+ public ReverseWorldRenderer lightmap(int p_181671_1_, int p_181671_2_) {
+ int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex);
+
+ switch (this.vertexFormatElement.getType()) {
+ case FLOAT:
+ this.byteBuffer.putFloat(i, (float) p_181671_1_);
+ this.byteBuffer.putFloat(i + 4, (float) p_181671_2_);
+ break;
+ case UINT:
+ case INT:
+ this.byteBuffer.putInt(i, p_181671_1_);
+ this.byteBuffer.putInt(i + 4, p_181671_2_);
+ break;
+ case USHORT:
+ case SHORT:
+ this.byteBuffer.putShort(i, (short) p_181671_2_);
+ this.byteBuffer.putShort(i + 2, (short) p_181671_1_);
+ break;
+ case UBYTE:
+ case BYTE:
+ this.byteBuffer.put(i, (byte) p_181671_2_);
+ this.byteBuffer.put(i + 1, (byte) p_181671_1_);
+ }
+
+ this.nextVertexFormatIndex();
+ return this;
+ }
+
+ public void putBrightness4(int p_178962_1_, int p_178962_2_, int p_178962_3_, int p_178962_4_) {
+ int i = (this.vertexCount - 4) * this.vertexFormat.getIntegerSize() + this.vertexFormat.getUvOffsetById(1) / 4;
+ int j = this.vertexFormat.getNextOffset() >> 2;
+ this.rawIntBuffer.put(i, p_178962_1_);
+ this.rawIntBuffer.put(i + j, p_178962_2_);
+ this.rawIntBuffer.put(i + j * 2, p_178962_3_);
+ this.rawIntBuffer.put(i + j * 3, p_178962_4_);
+ }
+
+ public void putPosition(double x, double y, double z) {
+ int i = this.vertexFormat.getIntegerSize();
+ int j = (this.vertexCount - 4) * i;
+
+ for (int k = 0; k < 4; ++k) {
+ int l = j + k * i;
+ int i1 = l + 1;
+ int j1 = i1 + 1;
+ this.rawIntBuffer.put(
+ l,
+ Float.floatToRawIntBits((float) (x + this.xOffset) + Float.intBitsToFloat(this.rawIntBuffer.get(l)))
+ );
+ this.rawIntBuffer.put(
+ i1,
+ Float.floatToRawIntBits((float) (y + this.yOffset) + Float.intBitsToFloat(this.rawIntBuffer.get(i1)))
+ );
+ this.rawIntBuffer.put(
+ j1,
+ Float.floatToRawIntBits((float) (z + this.zOffset) + Float.intBitsToFloat(this.rawIntBuffer.get(j1)))
+ );
+ }
+ }
+
+ /**
+ * Takes in the pass the call list is being requested for. Args: renderPass
+ */
+ public int getColorIndex(int p_78909_1_) {
+ return ((this.vertexCount - p_78909_1_) * this.vertexFormat.getNextOffset() + this.vertexFormat.getColorOffset()) /
+ 4;
+ }
+
+ public void putColorMultiplier(float red, float green, float blue, int p_178978_4_) {
+ int i = this.getColorIndex(p_178978_4_);
+ int j = -1;
+
+ if (!this.noColor) {
+ j = this.rawIntBuffer.get(i);
+
+ if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) {
+ int k = (int) ((float) (j & 255) * red);
+ int l = (int) ((float) (j >> 8 & 255) * green);
+ int i1 = (int) ((float) (j >> 16 & 255) * blue);
+ j = j & -16777216;
+ j = j | i1 << 16 | l << 8 | k;
+ } else {
+ int j1 = (int) ((float) (j >> 24 & 255) * red);
+ int k1 = (int) ((float) (j >> 16 & 255) * green);
+ int l1 = (int) ((float) (j >> 8 & 255) * blue);
+ j = j & 255;
+ j = j | j1 << 24 | k1 << 16 | l1 << 8;
+ }
+ }
+
+ this.rawIntBuffer.put(i, j);
+ }
+
+ private void putColor(int argb, int p_178988_2_) {
+ int i = this.getColorIndex(p_178988_2_);
+ int j = argb >> 16 & 255;
+ int k = argb >> 8 & 255;
+ int l = argb & 255;
+ int i1 = argb >> 24 & 255;
+ this.putColorRGBA(i, j, k, l, i1);
+ }
+
+ public void putColorRGB_F(float red, float green, float blue, int p_178994_4_) {
+ int i = this.getColorIndex(p_178994_4_);
+ int j = MathHelper.clamp_int((int) (red * 255.0F), 0, 255);
+ int k = MathHelper.clamp_int((int) (green * 255.0F), 0, 255);
+ int l = MathHelper.clamp_int((int) (blue * 255.0F), 0, 255);
+ this.putColorRGBA(i, j, k, l, 255);
+ }
+
+ public void putColorRGBA(int index, int red, int p_178972_3_, int p_178972_4_, int p_178972_5_) {
+ if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) {
+ this.rawIntBuffer.put(index, p_178972_5_ << 24 | p_178972_4_ << 16 | p_178972_3_ << 8 | red);
+ } else {
+ this.rawIntBuffer.put(index, red << 24 | p_178972_3_ << 16 | p_178972_4_ << 8 | p_178972_5_);
+ }
+ }
+
+ /**
+ * Disabels color processing.
+ */
+ public void noColor() {
+ this.noColor = true;
+ }
+
+ public ReverseWorldRenderer color(float red, float green, float blue, float alpha) {
+ return this.color((int) (red * 255.0F), (int) (green * 255.0F), (int) (blue * 255.0F), (int) (alpha * 255.0F));
+ }
+
+ public ReverseWorldRenderer color(int red, int green, int blue, int alpha) {
+ if (!this.noColor) {
+ int i =
+ this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex);
+
+ switch (this.vertexFormatElement.getType()) {
+ case FLOAT:
+ this.byteBuffer.putFloat(i, (float) red / 255.0F);
+ this.byteBuffer.putFloat(i + 4, (float) green / 255.0F);
+ this.byteBuffer.putFloat(i + 8, (float) blue / 255.0F);
+ this.byteBuffer.putFloat(i + 12, (float) alpha / 255.0F);
+ break;
+ case UINT:
+ case INT:
+ this.byteBuffer.putFloat(i, (float) red);
+ this.byteBuffer.putFloat(i + 4, (float) green);
+ this.byteBuffer.putFloat(i + 8, (float) blue);
+ this.byteBuffer.putFloat(i + 12, (float) alpha);
+ break;
+ case USHORT:
+ case SHORT:
+ this.byteBuffer.putShort(i, (short) red);
+ this.byteBuffer.putShort(i + 2, (short) green);
+ this.byteBuffer.putShort(i + 4, (short) blue);
+ this.byteBuffer.putShort(i + 6, (short) alpha);
+ break;
+ case UBYTE:
+ case BYTE:
+ if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) {
+ this.byteBuffer.put(i, (byte) red);
+ this.byteBuffer.put(i + 1, (byte) green);
+ this.byteBuffer.put(i + 2, (byte) blue);
+ this.byteBuffer.put(i + 3, (byte) alpha);
+ } else {
+ this.byteBuffer.put(i, (byte) alpha);
+ this.byteBuffer.put(i + 1, (byte) blue);
+ this.byteBuffer.put(i + 2, (byte) green);
+ this.byteBuffer.put(i + 3, (byte) red);
+ }
+ }
+
+ this.nextVertexFormatIndex();
+ }
+ return this;
+ }
+
+ public void addVertexData(int[] vertexData) {
+ this.growBuffer(vertexData.length);
+ this.rawIntBuffer.position(this.getBufferSize());
+ this.rawIntBuffer.put(vertexData);
+ this.vertexCount += vertexData.length / this.vertexFormat.getIntegerSize();
+ }
+
+ public void endVertex() {
+ ++this.vertexCount;
+ this.growBuffer(this.vertexFormat.getIntegerSize());
+ }
+
+ public ReverseWorldRenderer pos(double x, double y, double z) {
+ int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex);
+
+ switch (this.vertexFormatElement.getType()) {
+ case FLOAT:
+ this.byteBuffer.putFloat(i, (float) (x + this.xOffset));
+ this.byteBuffer.putFloat(i + 4, (float) (y + this.yOffset));
+ this.byteBuffer.putFloat(i + 8, (float) (z + this.zOffset));
+ break;
+ case UINT:
+ case INT:
+ this.byteBuffer.putInt(i, Float.floatToRawIntBits((float) (x + this.xOffset)));
+ this.byteBuffer.putInt(i + 4, Float.floatToRawIntBits((float) (y + this.yOffset)));
+ this.byteBuffer.putInt(i + 8, Float.floatToRawIntBits((float) (z + this.zOffset)));
+ break;
+ case USHORT:
+ case SHORT:
+ this.byteBuffer.putShort(i, (short) ((int) (x + this.xOffset)));
+ this.byteBuffer.putShort(i + 2, (short) ((int) (y + this.yOffset)));
+ this.byteBuffer.putShort(i + 4, (short) ((int) (z + this.zOffset)));
+ break;
+ case UBYTE:
+ case BYTE:
+ this.byteBuffer.put(i, (byte) ((int) (x + this.xOffset)));
+ this.byteBuffer.put(i + 1, (byte) ((int) (y + this.yOffset)));
+ this.byteBuffer.put(i + 2, (byte) ((int) (z + this.zOffset)));
+ }
+
+ this.nextVertexFormatIndex();
+ return this;
+ }
+
+ public void putNormal(float x, float y, float z) {
+ int i = (byte) ((int) (x * 127.0F)) & 255;
+ int j = (byte) ((int) (y * 127.0F)) & 255;
+ int k = (byte) ((int) (z * 127.0F)) & 255;
+ int l = i | j << 8 | k << 16;
+ int i1 = this.vertexFormat.getNextOffset() >> 2;
+ int j1 = (this.vertexCount - 4) * i1 + this.vertexFormat.getNormalOffset() / 4;
+ this.rawIntBuffer.put(j1, l);
+ this.rawIntBuffer.put(j1 + i1, l);
+ this.rawIntBuffer.put(j1 + i1 * 2, l);
+ this.rawIntBuffer.put(j1 + i1 * 3, l);
+ }
+
+ private void nextVertexFormatIndex() {
+ ++this.vertexFormatIndex;
+ this.vertexFormatIndex %= this.vertexFormat.getElementCount();
+ this.vertexFormatElement = this.vertexFormat.getElement(this.vertexFormatIndex);
+
+ if (this.vertexFormatElement.getUsage() == VertexFormatElement.EnumUsage.PADDING) {
+ this.nextVertexFormatIndex();
+ }
+ }
+
+ public ReverseWorldRenderer normal(float p_181663_1_, float p_181663_2_, float p_181663_3_) {
+ int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex);
+
+ switch (this.vertexFormatElement.getType()) {
+ case FLOAT:
+ this.byteBuffer.putFloat(i, p_181663_1_);
+ this.byteBuffer.putFloat(i + 4, p_181663_2_);
+ this.byteBuffer.putFloat(i + 8, p_181663_3_);
+ break;
+ case UINT:
+ case INT:
+ this.byteBuffer.putInt(i, (int) p_181663_1_);
+ this.byteBuffer.putInt(i + 4, (int) p_181663_2_);
+ this.byteBuffer.putInt(i + 8, (int) p_181663_3_);
+ break;
+ case USHORT:
+ case SHORT:
+ this.byteBuffer.putShort(i, (short) ((int) (p_181663_1_ * 32767) & 65535));
+ this.byteBuffer.putShort(i + 2, (short) ((int) (p_181663_2_ * 32767) & 65535));
+ this.byteBuffer.putShort(i + 4, (short) ((int) (p_181663_3_ * 32767) & 65535));
+ break;
+ case UBYTE:
+ case BYTE:
+ this.byteBuffer.put(i, (byte) ((int) (p_181663_1_ * 127) & 255));
+ this.byteBuffer.put(i + 1, (byte) ((int) (p_181663_2_ * 127) & 255));
+ this.byteBuffer.put(i + 2, (byte) ((int) (p_181663_3_ * 127) & 255));
+ }
+
+ this.nextVertexFormatIndex();
+ return this;
+ }
+
+ public void setTranslation(double x, double y, double z) {
+ this.xOffset = x;
+ this.yOffset = y;
+ this.zOffset = z;
+ }
+
+ public void finishDrawing() {
+ if (!this.isDrawing) {
+ throw new IllegalStateException("Not building!");
+ } else {
+ this.isDrawing = false;
+ this.byteBuffer.position(0);
+ this.byteBuffer.limit(this.getBufferSize() * 4);
+ }
+ }
+
+ public ByteBuffer getByteBuffer() {
+ return this.byteBuffer;
+ }
+
+ public VertexFormat getVertexFormat() {
+ return this.vertexFormat;
+ }
+
+ public int getVertexCount() {
+ return this.vertexCount;
+ }
+
+ public int getDrawMode() {
+ return this.drawMode;
+ }
+
+ public void putColor4(int argb) {
+ for (int i = 0; i < 4; ++i) {
+ this.putColor(argb, i + 1);
+ }
+ }
+
+ public void putColorRGB_F4(float red, float green, float blue) {
+ for (int i = 0; i < 4; ++i) {
+ this.putColorRGB_F(red, green, blue, i + 1);
+ }
+ }
+
+ public void checkAndGrow() {
+ this.growBuffer(vertexFormat.getNextOffset()/* / 4 * 4 */);
+ }
+
+ public boolean isColorDisabled() {
+ /* None */
+ return noColor;
+ }
+
+ @SideOnly(Side.CLIENT)
+ public static class State {
+ private final int[] stateRawBuffer;
+ private final VertexFormat stateVertexFormat;
+
+ public State(int[] buffer, VertexFormat format) {
+ this.stateRawBuffer = buffer;
+ this.stateVertexFormat = format;
+ }
+
+ public int[] getRawBuffer() {
+ return this.stateRawBuffer;
+ }
+
+ public int getVertexCount() {
+ return this.stateRawBuffer.length / this.stateVertexFormat.getIntegerSize();
+ }
+
+ public VertexFormat getVertexFormat() {
+ return this.stateVertexFormat;
+ }
+ }
} \ No newline at end of file
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java
index 9699f4ad..4bf1d6aa 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java
@@ -1,11 +1,19 @@
package io.github.moulberry.notenoughupdates.util;
+import com.google.common.reflect.TypeToken;
import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.LocationChangeEvent;
+import io.github.moulberry.notenoughupdates.overlays.SlayerOverlay;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.inventory.GuiChest;
import net.minecraft.client.network.NetworkPlayerInfo;
+import net.minecraft.init.Blocks;
import net.minecraft.inventory.ContainerChest;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
import net.minecraft.scoreboard.Score;
import net.minecraft.scoreboard.ScoreObjective;
import net.minecraft.scoreboard.ScorePlayerTeam;
@@ -13,207 +21,355 @@ import net.minecraft.scoreboard.Scoreboard;
import net.minecraft.util.IChatComponent;
import net.minecraftforge.client.event.ClientChatReceivedEvent;
import net.minecraftforge.client.event.GuiOpenEvent;
+import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+import net.minecraftforge.fml.common.gameevent.TickEvent;
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
import java.text.ParseException;
import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class SBInfo {
-
- private static final SBInfo INSTANCE = new SBInfo();
- public static SBInfo getInstance() {
- return INSTANCE;
- }
-
- private static final Pattern timePattern = Pattern.compile(".+(am|pm)");
-
- public IChatComponent footer;
- public IChatComponent header;
-
- public String location = "";
- public String date = "";
- public String time = "";
- public String objective = "";
-
- public String mode = "";
-
- public Date currentTimeDate = null;
-
- public String lastOpenContainerName = "";
-
- private long lastManualLocRaw = -1;
- private long lastLocRaw = -1;
- public long joinedWorld = -1;
- public long unloadedWorld = -1;
- private JsonObject locraw = null;
- public boolean isInDungeon = false;
-
- public String currentProfile = null;
-
- @SubscribeEvent
- public void onGuiOpen(GuiOpenEvent event) {
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
-
- if(event.gui instanceof GuiChest) {
- GuiChest chest = (GuiChest) event.gui;
- ContainerChest container = (ContainerChest) chest.inventorySlots;
- String containerName = container.getLowerChestInventory().getDisplayName().getUnformattedText();
-
- lastOpenContainerName = containerName;
- }
- }
-
- @SubscribeEvent
- public void onWorldLoad(WorldEvent.Load event) {
- lastLocRaw = -1;
- locraw = null;
- mode = null;
- joinedWorld = System.currentTimeMillis();
- lastOpenContainerName = "";
- }
-
- @SubscribeEvent
- public void onWorldUnload(WorldEvent.Unload event) {
- unloadedWorld = System.currentTimeMillis();
- }
-
- private static final Pattern JSON_BRACKET_PATTERN = Pattern.compile("\\{.+}");
-
- public void onSendChatMessage(String msg) {
- if(msg.trim().startsWith("/locraw") || msg.trim().startsWith("/locraw ")) {
- lastManualLocRaw = System.currentTimeMillis();
- }
- }
-
- @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true)
- public void onChatMessage(ClientChatReceivedEvent event) {
- Matcher matcher = JSON_BRACKET_PATTERN.matcher(event.message.getUnformattedText());
- if(matcher.find()) {
- try {
- JsonObject obj = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(matcher.group(), JsonObject.class);
- if(obj.has("server")) {
- if(System.currentTimeMillis() - lastManualLocRaw > 5000) event.setCanceled(true);
- if(obj.has("gametype") && obj.has("mode") && obj.has("map")) {
- locraw = obj;
- mode = locraw.get("mode").getAsString();
- }
- }
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
- }
-
- public String getLocation() {
- if(mode == null) {
- return null;
- }
- return mode;
- }
-
- private static final String profilePrefix = "\u00a7r\u00a7e\u00a7lProfile: \u00a7r\u00a7a";
- private static final String skillsPrefix = "\u00a7r\u00a7e\u00a7lSkills: \u00a7r\u00a7a";
-
- private static final Pattern SKILL_LEVEL_PATTERN = Pattern.compile("([^0-9:]+) (\\d{1,2})");
-
- public void tick() {
- Boolean tempIsInDungeon = false;
-
- long currentTime = System.currentTimeMillis();
-
- if(Minecraft.getMinecraft().thePlayer != null &&
- Minecraft.getMinecraft().theWorld != null &&
- locraw == null &&
- (currentTime - joinedWorld) > 1000 &&
- (currentTime - lastLocRaw) > 15000) {
- lastLocRaw = System.currentTimeMillis();
- NotEnoughUpdates.INSTANCE.sendChatMessage("/locraw");
- }
-
- try {
- for(NetworkPlayerInfo info : Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()) {
- String name = Minecraft.getMinecraft().ingameGUI.getTabList().getPlayerName(info);
- if(name.startsWith(profilePrefix)) {
- currentProfile = Utils.cleanColour(name.substring(profilePrefix.length()));
- } else if(name.startsWith(skillsPrefix)) {
- String levelInfo = name.substring(skillsPrefix.length()).trim();
- Matcher matcher = SKILL_LEVEL_PATTERN.matcher(Utils.cleanColour(levelInfo).split(":")[0]);
- if(matcher.find()) {
- try {
- int level = Integer.parseInt(matcher.group(2).trim());
- XPInformation.getInstance().updateLevel(matcher.group(1).toLowerCase().trim(), level);
- } catch(Exception ignored) {}
- }
- }
- }
- } catch(Exception e) {
- e.printStackTrace();
- }
-
- try {
- Scoreboard scoreboard = Minecraft.getMinecraft().thePlayer.getWorldScoreboard();
-
- ScoreObjective sidebarObjective = scoreboard.getObjectiveInDisplaySlot(1);
-
- List<Score> scores = new ArrayList<>(scoreboard.getSortedScores(sidebarObjective));
-
- List<String> lines = new ArrayList<>();
- for(int i=scores.size()-1; i>=0; i--) {
- Score score = scores.get(i);
- ScorePlayerTeam scoreplayerteam1 = scoreboard.getPlayersTeam(score.getPlayerName());
- String line = ScorePlayerTeam.formatPlayerName(scoreplayerteam1, score.getPlayerName());
- line = Utils.cleanDuplicateColourCodes(line);
-
- String cleanLine = Utils.cleanColour(line);
-
- if(cleanLine.contains("Dungeon") && cleanLine.contains("Cleared:") && cleanLine.contains("%")) {
- tempIsInDungeon = true;
- }
-
- lines.add(line);
- }
- isInDungeon= tempIsInDungeon;
-
- if(lines.size() >= 5) {
- date = Utils.cleanColour(lines.get(1)).trim();
- //§74:40am
- Matcher matcher = timePattern.matcher(lines.get(2));
- if(matcher.find()) {
- time = Utils.cleanColour(matcher.group()).trim();
- try {
- String timeSpace = time.replace("am", " am").replace("pm", " pm");
- SimpleDateFormat parseFormat = new SimpleDateFormat("hh:mm a");
- currentTimeDate = parseFormat.parse(timeSpace);
- } catch (ParseException e) {}
- }
- //Replaced with for loop because in crystal hollows with events the line it's on can shift.
- for (String line : lines){
- if (line.contains("⏣")) {
- location = Utils.cleanColour(line).replaceAll("[^A-Za-z0-9() ]", "").trim();
- break;
- }
- }
- }
- objective = null;
-
- boolean objTextLast = false;
- for(String line : lines) {
- if(objTextLast) {
- objective = line;
- }
-
- objTextLast = line.equals("Objective");
- }
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
-
+ private static final SBInfo INSTANCE = new SBInfo();
+
+ public static SBInfo getInstance() {
+ return INSTANCE;
+ }
+
+ private static final Pattern timePattern = Pattern.compile(".+(am|pm)");
+
+ public IChatComponent footer;
+ public IChatComponent header;
+
+ public String location = "";
+ public String date = "";
+ public String time = "";
+ public String objective = "";
+ public String slayer = "";
+ public boolean stranded = false;
+
+ public String mode = "";
+
+ public Date currentTimeDate = null;
+
+ public String lastOpenContainerName = "";
+
+ private long lastManualLocRaw = -1;
+ private long lastLocRaw = -1;
+ public long joinedWorld = -1;
+ public long unloadedWorld = -1;
+ private JsonObject locraw = null;
+ public boolean isInDungeon = false;
+ public boolean hasNewTab = false;
+
+ public enum Gamemode {
+ NORMAL("", ""), IRONMAN("Ironman", "♲"), STRANDED("Stranded", "☀");
+
+ private final String name;
+ private final String emoji;
+
+ Gamemode(String name, String emoji) {
+ this.name = name;
+ this.emoji = emoji;
+ }
+
+ public static Gamemode find(String type) {
+ for (Gamemode gamemode : values()) {
+ if (type.contains(gamemode.name))
+ return gamemode;
+ }
+ return null;
+ }
+ }
+
+ private Map<String, Gamemode> gamemodes = new HashMap<>();
+ private boolean areGamemodesLoaded = false;
+ private int tickCount = 0;
+ public String currentProfile = null;
+
+ @SubscribeEvent
+ public void onGuiOpen(GuiOpenEvent event) {
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
+
+ if (event.gui instanceof GuiChest) {
+ GuiChest chest = (GuiChest) event.gui;
+ ContainerChest container = (ContainerChest) chest.inventorySlots;
+
+ lastOpenContainerName = container.getLowerChestInventory().getDisplayName().getUnformattedText();
+ }
+ }
+
+ @SubscribeEvent
+ public void onGuiTick(TickEvent event) {
+ if (tickCount++ % 10 != 0) return;
+ GuiScreen currentScreen = Minecraft.getMinecraft().currentScreen;
+ if (currentScreen instanceof GuiChest) {
+ ContainerChest container = (ContainerChest) ((GuiChest) currentScreen).inventorySlots;
+ if ("Profile Management".equals(container.getLowerChestInventory().getDisplayName().getUnformattedText())) {
+ updateProfileInformation(container);
+ }
+ }
+ }
+
+ private static final Pattern PROFILE_PATTERN =
+ Pattern.compile("(?<type>(♲ Ironman)|(☀ Stranded)|()) *Profile: (?<name>[^ ]+)");
+
+ private void updateProfileInformation(ContainerChest container) {
+ for (int i = 11; i < 16; i = -~i) {
+ Slot slot = container.getSlot(i);
+ if (slot == null || !slot.getHasStack()) continue;
+ ItemStack item = slot.getStack();
+ if (item == null || item.getItem() == Item.getItemFromBlock(Blocks.bedrock)) continue;
+ String displayName = Utils.cleanColour(item.getDisplayName());
+ Matcher matcher = PROFILE_PATTERN.matcher(displayName);
+ if (!matcher.matches()) continue;
+ String type = matcher.group("type");
+ String name = matcher.group("name");
+ Gamemode gamemode = Gamemode.find(type);
+ gamemodes.put(name, gamemode);
+ }
+ areGamemodesLoaded = true;
+ saveGameModes();
+ }
+
+ private Path getProfilesFile() {
+ return new File(NotEnoughUpdates.INSTANCE.manager.configLocation, "profiles.json").toPath();
+ }
+
+ public Map<String, Gamemode> getAllGamemodes() {
+ if (!areGamemodesLoaded)
+ loadGameModes();
+ return gamemodes;
+ }
+
+ public void saveGameModes() {
+ try {
+ Files.write(
+ getProfilesFile(),
+ NotEnoughUpdates.INSTANCE.manager.gson.toJson(gamemodes).getBytes(StandardCharsets.UTF_8)
+ );
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public Gamemode getGamemodeForProfile(String profiles) {
+ return getAllGamemodes().get(profiles);
+ }
+
+ public Gamemode getCurrentMode() {
+ return getGamemodeForProfile(currentProfile);
+ }
+
+ public void loadGameModes() {
+ try {
+ gamemodes = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(
+ Files.newBufferedReader(getProfilesFile()),
+ new TypeToken<Map<String, Gamemode>>() {
+ }.getType()
+ );
+ areGamemodesLoaded = true;
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @SubscribeEvent
+ public void onWorldLoad(WorldEvent.Load event) {
+ lastLocRaw = -1;
+ locraw = null;
+ this.setLocation(null);
+ joinedWorld = System.currentTimeMillis();
+ lastOpenContainerName = "";
+ hasNewTab = false;
+ }
+
+ @SubscribeEvent
+ public void onWorldUnload(WorldEvent.Unload event) {
+ unloadedWorld = System.currentTimeMillis();
+ }
+
+ private static final Pattern JSON_BRACKET_PATTERN = Pattern.compile("^\\{.+}");
+
+ public void onSendChatMessage(String msg) {
+ if (msg.trim().startsWith("/locraw") || msg.trim().startsWith("/locraw ")) {
+ lastManualLocRaw = System.currentTimeMillis();
+ }
+ }
+
+ @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true)
+ public void onChatMessage(ClientChatReceivedEvent event) {
+ Matcher matcher = JSON_BRACKET_PATTERN.matcher(event.message.getUnformattedText());
+ if (matcher.find()) {
+ try {
+ JsonObject obj = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(matcher.group(), JsonObject.class);
+ if (obj.has("server")) {
+ if (System.currentTimeMillis() - lastManualLocRaw > 5000) event.setCanceled(true);
+ if (obj.has("gametype") && obj.has("mode") && obj.has("map")) {
+ locraw = obj;
+ setLocation(locraw.get("mode").getAsString());
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public String getLocation() {
+ return mode;
+ }
+
+ public void setLocation(String location) {
+ if (!Objects.equals(this.mode, location)) {
+ MinecraftForge.EVENT_BUS.post(new LocationChangeEvent(location, this.mode));
+ }
+ this.mode = location;
+ }
+
+ private static final String profilePrefix = "\u00a7r\u00a7e\u00a7lProfile: \u00a7r\u00a7a";
+ private static final String skillsPrefix = "\u00a7r\u00a7e\u00a7lSkills: \u00a7r\u00a7a";
+
+ private static final Pattern SKILL_LEVEL_PATTERN = Pattern.compile("([^0-9:]+) (\\d{1,2})");
+
+ public void tick() {
+ boolean tempIsInDungeon = false;
+
+ long currentTime = System.currentTimeMillis();
+
+ if (Minecraft.getMinecraft().thePlayer != null &&
+ Minecraft.getMinecraft().theWorld != null &&
+ locraw == null &&
+ (currentTime - joinedWorld) > 1000 &&
+ (currentTime - lastLocRaw) > 15000) {
+ lastLocRaw = System.currentTimeMillis();
+ NotEnoughUpdates.INSTANCE.sendChatMessage("/locraw");
+ }
+
+ try {
+ for (NetworkPlayerInfo info : Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()) {
+ String name = Minecraft.getMinecraft().ingameGUI.getTabList().getPlayerName(info);
+ if (name.startsWith(profilePrefix)) {
+ currentProfile = Utils.cleanColour(name.substring(profilePrefix.length()));
+ hasNewTab = true;
+ } else if (name.startsWith(skillsPrefix)) {
+ String levelInfo = name.substring(skillsPrefix.length()).trim();
+ Matcher matcher = SKILL_LEVEL_PATTERN.matcher(Utils.cleanColour(levelInfo).split(":")[0]);
+ if (matcher.find()) {
+ try {
+ int level = Integer.parseInt(matcher.group(2).trim());
+ XPInformation.getInstance().updateLevel(matcher.group(1).toLowerCase().trim(), level);
+ } catch (Exception ignored) {
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ try {
+ Scoreboard scoreboard = Minecraft.getMinecraft().thePlayer.getWorldScoreboard();
+
+ ScoreObjective sidebarObjective = scoreboard.getObjectiveInDisplaySlot(1);
+
+ List<Score> scores = new ArrayList<>(scoreboard.getSortedScores(sidebarObjective));
+
+ List<String> lines = new ArrayList<>();
+ for (int i = scores.size() - 1; i >= 0; i--) {
+ Score score = scores.get(i);
+ ScorePlayerTeam scoreplayerteam1 = scoreboard.getPlayersTeam(score.getPlayerName());
+ String line = ScorePlayerTeam.formatPlayerName(scoreplayerteam1, score.getPlayerName());
+ line = Utils.cleanDuplicateColourCodes(line);
+
+ String cleanLine = Utils.cleanColour(line);
+
+ if (cleanLine.contains("Dungeon") && cleanLine.contains("Cleared:") && cleanLine.contains("%")) {
+ tempIsInDungeon = true;
+ }
+
+ lines.add(line);
+ }
+ isInDungeon = tempIsInDungeon;
+
+ boolean containsStranded = false;
+ for (String line : lines) { //Slayer stuff
+ if (line.contains("Tarantula Broodfather")) {
+ slayer = "Tarantula";
+ } else if (line.contains("Revenant Horror")) {
+ slayer = "Revenant";
+ } else if (line.contains("Sven Packmaster")) {
+ slayer = "Sven";
+ } else if (line.contains("Voidgloom Seraph")) {
+ slayer = "Enderman";
+ }
+ if (lines.contains("Slayer Quest") && SlayerOverlay.unloadOverlayTimer == -1 ||
+ lines.contains("Slayer Quest") && System.currentTimeMillis() - SlayerOverlay.unloadOverlayTimer > 500) {
+ SlayerOverlay.slayerQuest = true;
+ }
+ if (SlayerOverlay.slayerQuest) {
+ if (line.contains(" I")) {
+ SlayerOverlay.slayerTier = 1;
+ }
+ if (line.contains(" II")) {
+ SlayerOverlay.slayerTier = 2;
+ }
+ if (line.contains(" III")) {
+ SlayerOverlay.slayerTier = 3;
+ }
+ if (line.contains(" IV")) {
+ SlayerOverlay.slayerTier = 4;
+ }
+ if (line.contains(" V")) {
+ SlayerOverlay.slayerTier = 5;
+ }
+ }
+ if (line.contains("☀ Stranded")) containsStranded = true;
+ }
+ stranded = containsStranded;
+
+ if (lines.size() >= 5) {
+ date = Utils.cleanColour(lines.get(1)).trim();
+ //§74:40am
+ Matcher matcher = timePattern.matcher(lines.get(2));
+ if (matcher.find()) {
+ time = Utils.cleanColour(matcher.group()).trim();
+ try {
+ String timeSpace = time.replace("am", " am").replace("pm", " pm");
+ SimpleDateFormat parseFormat = new SimpleDateFormat("hh:mm a");
+ currentTimeDate = parseFormat.parse(timeSpace);
+ } catch (ParseException ignored) {
+ }
+ }
+ //Replaced with for loop because in crystal hollows with events the line it's on can shift.
+ for (String line : lines) {
+ if (line.contains("⏣")) {
+ location = Utils.cleanColour(line).replaceAll("[^A-Za-z0-9() ]", "").trim();
+ break;
+ }
+ }
+ }
+ objective = null;
+
+ boolean objTextLast = false;
+ for (String line : lines) {
+ if (objTextLast) {
+ objective = line;
+ }
+
+ objTextLast = line.equals("Objective");
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/SpecialColour.java b/src/main/java/io/github/moulberry/notenoughupdates/util/SpecialColour.java
index 5bcd23c3..27a40565 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/SpecialColour.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/SpecialColour.java
@@ -3,93 +3,90 @@ package io.github.moulberry.notenoughupdates.util;
import java.awt.*;
public class SpecialColour {
-
- public static String special(int chromaSpeed, int alpha, int rgb) {
- return special(chromaSpeed, alpha, (rgb & 0xFF0000) >> 16, (rgb & 0x00FF00) >> 8, (rgb & 0x0000FF));
- }
-
- private static final int RADIX = 10;
-
- public static String special(int chromaSpeed, int alpha, int r, int g, int b) {
- StringBuilder sb = new StringBuilder();
- sb.append(Integer.toString(chromaSpeed, RADIX)).append(":");
- sb.append(Integer.toString(alpha, RADIX)).append(":");
- sb.append(Integer.toString(r, RADIX)).append(":");
- sb.append(Integer.toString(g, RADIX)).append(":");
- sb.append(Integer.toString(b, RADIX));
- return sb.toString();
- }
-
- private static int[] decompose(String csv) {
- String[] split = csv.split(":");
-
- int[] arr = new int[split.length];
-
-
- for(int i=0; i<split.length; i++) {
- arr[i] = Integer.parseInt(split[split.length-1-i], RADIX);
- }
- return arr;
- }
-
- public static int specialToSimpleRGB(String special) {
- int[] d = decompose(special);
- int r = d[2];
- int g = d[1];
- int b = d[0];
- int a = d[3];
- int chr = d[4];
-
- return (a & 0xFF) << 24 | (r & 0xFF) << 16 | (g & 0xFF) << 8 | (b & 0xFF);
- }
-
- public static int getSpeed(String special) {
- return decompose(special)[4];
- }
-
- public static float getSecondsForSpeed(int speed) {
- return (255-speed)/254f*(MAX_CHROMA_SECS-MIN_CHROMA_SECS)+MIN_CHROMA_SECS;
- }
-
- private static final int MIN_CHROMA_SECS = 1;
- private static final int MAX_CHROMA_SECS = 60;
-
- public static long startTime = -1;
- public static int specialToChromaRGB(String special) {
- if(startTime < 0) startTime = System.currentTimeMillis();
-
- int[] d = decompose(special);
- int chr = d[4];
- int a = d[3];
- int r = d[2];
- int g = d[1];
- int b = d[0];
-
- float[] hsv = Color.RGBtoHSB(r, g, b, null);
-
- if(chr > 0) {
- float seconds = getSecondsForSpeed(chr);
- hsv[0] += (System.currentTimeMillis()-startTime)/1000f/seconds;
- hsv[0] %= 1;
- if(hsv[0] < 0) hsv[0] += 1;
- }
-
- return (a & 0xFF) << 24 | (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF);
- }
-
- public static int rotateHue(int argb, int degrees) {
- int a = (argb >> 24) & 0xFF;
- int r = (argb >> 16) & 0xFF;
- int g = (argb >> 8) & 0xFF;
- int b = (argb) & 0xFF;
-
- float[] hsv = Color.RGBtoHSB(r, g, b, null);
-
- hsv[0] += degrees/360f;
- hsv[0] %= 1;
-
- return (a & 0xFF) << 24 | (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF);
- }
-
-
+ public static String special(int chromaSpeed, int alpha, int rgb) {
+ return special(chromaSpeed, alpha, (rgb & 0xFF0000) >> 16, (rgb & 0x00FF00) >> 8, (rgb & 0x0000FF));
+ }
+
+ private static final int RADIX = 10;
+
+ public static String special(int chromaSpeed, int alpha, int r, int g, int b) {
+ StringBuilder sb = new StringBuilder();
+ sb.append(Integer.toString(chromaSpeed, RADIX)).append(":");
+ sb.append(Integer.toString(alpha, RADIX)).append(":");
+ sb.append(Integer.toString(r, RADIX)).append(":");
+ sb.append(Integer.toString(g, RADIX)).append(":");
+ sb.append(Integer.toString(b, RADIX));
+ return sb.toString();
+ }
+
+ private static int[] decompose(String csv) {
+ String[] split = csv.split(":");
+
+ int[] arr = new int[split.length];
+
+ for (int i = 0; i < split.length; i++) {
+ arr[i] = Integer.parseInt(split[split.length - 1 - i], RADIX);
+ }
+ return arr;
+ }
+
+ public static int specialToSimpleRGB(String special) {
+ int[] d = decompose(special);
+ int r = d[2];
+ int g = d[1];
+ int b = d[0];
+ int a = d[3];
+ int chr = d[4];
+
+ return (a & 0xFF) << 24 | (r & 0xFF) << 16 | (g & 0xFF) << 8 | (b & 0xFF);
+ }
+
+ public static int getSpeed(String special) {
+ return decompose(special)[4];
+ }
+
+ public static float getSecondsForSpeed(int speed) {
+ return (255 - speed) / 254f * (MAX_CHROMA_SECS - MIN_CHROMA_SECS) + MIN_CHROMA_SECS;
+ }
+
+ private static final int MIN_CHROMA_SECS = 1;
+ private static final int MAX_CHROMA_SECS = 60;
+
+ public static long startTime = -1;
+
+ public static int specialToChromaRGB(String special) {
+ if (startTime < 0) startTime = System.currentTimeMillis();
+
+ int[] d = decompose(special);
+ int chr = d[4];
+ int a = d[3];
+ int r = d[2];
+ int g = d[1];
+ int b = d[0];
+
+ float[] hsv = Color.RGBtoHSB(r, g, b, null);
+
+ if (chr > 0) {
+ float seconds = getSecondsForSpeed(chr);
+ hsv[0] += (System.currentTimeMillis() - startTime) / 1000f / seconds;
+ hsv[0] %= 1;
+ if (hsv[0] < 0) hsv[0] += 1;
+ }
+
+ return (a & 0xFF) << 24 | (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF);
+ }
+
+ public static int rotateHue(int argb, int degrees) {
+ int a = (argb >> 24) & 0xFF;
+ int r = (argb >> 16) & 0xFF;
+ int g = (argb >> 8) & 0xFF;
+ int b = (argb) & 0xFF;
+
+ float[] hsv = Color.RGBtoHSB(r, g, b, null);
+
+ hsv[0] += degrees / 360f;
+ hsv[0] %= 1;
+
+ return (a & 0xFF) << 24 | (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF);
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/TexLoc.java b/src/main/java/io/github/moulberry/notenoughupdates/util/TexLoc.java
index 5e792cf5..b38db88f 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/TexLoc.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/TexLoc.java
@@ -6,52 +6,50 @@ import org.lwjgl.input.Keyboard;
* Utility used for positioning GUI elements during development.
*/
public class TexLoc {
+ public int x;
+ public int y;
+ private final int toggleKey;
+ private boolean toggled;
+ private boolean pressedLastTick;
+ private boolean dirPressed;
- public int x;
- public int y;
- private int toggleKey;
- private boolean toggled;
- private boolean pressedLastTick;
- private boolean dirPressed;
-
- public TexLoc(int x, int y, int toggleKey) {
- this.x = x;
- this.y = y;
- this.toggleKey = toggleKey;
- }
-
- public boolean handleKeyboardInput() {
- int mult=1;
- if(Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) mult=10;
- if(Keyboard.isKeyDown(toggleKey)) {
- if(!pressedLastTick) {
- toggled = !toggled;
- }
- pressedLastTick = true;
- } else {
- pressedLastTick = false;
- }
- if(toggled || toggleKey == 0) {
- if(Keyboard.isKeyDown(Keyboard.KEY_LEFT)) {
- if(!dirPressed) x-=mult;
- dirPressed = true;
- } else if(Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) {
- if(!dirPressed) x+=mult;
- dirPressed = true;
- } else if(Keyboard.isKeyDown(Keyboard.KEY_UP)) {
- if(!dirPressed) y-=mult;
- dirPressed = true;
- } else if(Keyboard.isKeyDown(Keyboard.KEY_DOWN)) {
- if(!dirPressed) y+=mult;
- dirPressed = true;
- } else {
- dirPressed = false;
- return false;
- }
- System.out.println("X: " + x + " ; Y: " + y);
- return true;
- }
- return false;
- }
+ public TexLoc(int x, int y, int toggleKey) {
+ this.x = x;
+ this.y = y;
+ this.toggleKey = toggleKey;
+ }
+ public boolean handleKeyboardInput() {
+ int mult = 1;
+ if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) mult = 10;
+ if (Keyboard.isKeyDown(toggleKey)) {
+ if (!pressedLastTick) {
+ toggled = !toggled;
+ }
+ pressedLastTick = true;
+ } else {
+ pressedLastTick = false;
+ }
+ if (toggled || toggleKey == 0) {
+ if (Keyboard.isKeyDown(Keyboard.KEY_LEFT)) {
+ if (!dirPressed) x -= mult;
+ dirPressed = true;
+ } else if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) {
+ if (!dirPressed) x += mult;
+ dirPressed = true;
+ } else if (Keyboard.isKeyDown(Keyboard.KEY_UP)) {
+ if (!dirPressed) y -= mult;
+ dirPressed = true;
+ } else if (Keyboard.isKeyDown(Keyboard.KEY_DOWN)) {
+ if (!dirPressed) y += mult;
+ dirPressed = true;
+ } else {
+ dirPressed = false;
+ return false;
+ }
+ System.out.println("X: " + x + " ; Y: " + y);
+ return true;
+ }
+ return false;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
index 7876776b..9b5f62e3 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
@@ -2,33 +2,24 @@ package io.github.moulberry.notenoughupdates.util;
import com.google.common.base.Splitter;
import com.google.common.collect.Lists;
-import com.google.common.collect.Multimap;
import com.google.gson.*;
-import com.mojang.authlib.Agent;
-import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
-import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.miscfeatures.SlotLocking;
-import io.github.moulberry.notenoughupdates.util.TexLoc;
-import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
-import net.minecraft.client.audio.SoundHandler;
+import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.gui.inventory.GuiContainer;
-import net.minecraft.client.renderer.*;
+import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.client.renderer.RenderHelper;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.entity.RenderItem;
-import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.resources.model.IBakedModel;
-import net.minecraft.enchantment.Enchantment;
-import net.minecraft.enchantment.EnchantmentHelper;
-import net.minecraft.entity.EnumCreatureAttribute;
-import net.minecraft.entity.ai.attributes.AttributeModifier;
-import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.event.ClickEvent;
import net.minecraft.event.HoverEvent;
import net.minecraft.init.Items;
@@ -38,1341 +29,1739 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
-import net.minecraft.potion.Potion;
-import net.minecraft.server.MinecraftServer;
+import net.minecraft.network.play.client.C0DPacketCloseWindow;
import net.minecraft.util.*;
import net.minecraftforge.fml.common.Loader;
import org.lwjgl.BufferUtils;
-import org.lwjgl.input.Keyboard;
+import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL14;
-import org.lwjgl.util.glu.Project;
-import javax.swing.*;
-import java.awt.*;
+import java.awt.Color;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.net.Proxy;
import java.nio.FloatBuffer;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.*;
-import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Utils {
-
- public static boolean hasEffectOverride = false;
- public static boolean disableCustomDungColours = false;
- private static LinkedList<Integer> guiScales = new LinkedList<>();
- private static ScaledResolution lastScale = new ScaledResolution(Minecraft.getMinecraft());
- //Labymod compatibility
- private static FloatBuffer projectionMatrixOld = BufferUtils.createFloatBuffer(16);
- private static FloatBuffer modelviewMatrixOld = BufferUtils.createFloatBuffer(16);
-
- public static <T> ArrayList<T> createList(T... values) {
- ArrayList<T> list = new ArrayList<>();
- for(T value : values)list.add(value);
- return list;
- }
-
- public static void resetGuiScale() {
- guiScales.clear();
- }
-
- public static ScaledResolution peekGuiScale() {
- return lastScale;
- }
-
- public static ScaledResolution pushGuiScale(int scale) {
- if(guiScales.size() == 0) {
- if(Loader.isModLoaded("labymod")) {
- GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, projectionMatrixOld);
- GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, modelviewMatrixOld);
- }
- }
-
- if(scale < 0) {
- if(guiScales.size() > 0) {
- guiScales.pop();
- }
- } else {
- if(scale == 0) {
- guiScales.push(Minecraft.getMinecraft().gameSettings.guiScale);
- } else {
- guiScales.push(scale);
- }
- }
-
- int newScale = guiScales.size() > 0 ? Math.max(0, Math.min(4, guiScales.peek())) : Minecraft.getMinecraft().gameSettings.guiScale;
- if(newScale == 0) newScale = Minecraft.getMinecraft().gameSettings.guiScale;
-
- int oldScale = Minecraft.getMinecraft().gameSettings.guiScale;
- Minecraft.getMinecraft().gameSettings.guiScale = newScale;
- ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
- Minecraft.getMinecraft().gameSettings.guiScale = oldScale;
-
- if(guiScales.size() > 0) {
- GlStateManager.viewport(0, 0, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight);
- GlStateManager.matrixMode(GL11.GL_PROJECTION);
- GlStateManager.loadIdentity();
- GlStateManager.ortho(0.0D,
- scaledresolution.getScaledWidth_double(),
- scaledresolution.getScaledHeight_double(), 0.0D, 1000.0D, 3000.0D);
- GlStateManager.matrixMode(GL11.GL_MODELVIEW);
- GlStateManager.loadIdentity();
- GlStateManager.translate(0.0F, 0.0F, -2000.0F);
- } else {
- if(Loader.isModLoaded("labymod") && projectionMatrixOld.limit() > 0 && modelviewMatrixOld.limit() > 0) {
- GlStateManager.matrixMode(GL11.GL_PROJECTION);
- GL11.glLoadMatrix(projectionMatrixOld);
- GlStateManager.matrixMode(GL11.GL_MODELVIEW);
- GL11.glLoadMatrix(modelviewMatrixOld);
- } else {
- GlStateManager.matrixMode(GL11.GL_PROJECTION);
- GlStateManager.loadIdentity();
- GlStateManager.ortho(0.0D,
- scaledresolution.getScaledWidth_double(),
- scaledresolution.getScaledHeight_double(), 0.0D, 1000.0D, 3000.0D);
- GlStateManager.matrixMode(GL11.GL_MODELVIEW);
- GlStateManager.loadIdentity();
- GlStateManager.translate(0.0F, 0.0F, -2000.0F);
- }
- }
-
- lastScale = scaledresolution;
- return scaledresolution;
- }
-
- public static boolean getHasEffectOverride() {
- return hasEffectOverride;
- }
-
- public static void drawItemStackWithoutGlint(ItemStack stack, int x, int y) {
- RenderItem itemRender = Minecraft.getMinecraft().getRenderItem();
-
- disableCustomDungColours = true;
- RenderHelper.enableGUIStandardItemLighting();
- itemRender.zLevel = -145; //Negates the z-offset of the below method.
- hasEffectOverride = true;
- try {
- itemRender.renderItemAndEffectIntoGUI(stack, x, y);
- } catch(Exception e) {e.printStackTrace();} //Catch exceptions to ensure that hasEffectOverride is set back to false.
- itemRender.renderItemOverlayIntoGUI(Minecraft.getMinecraft().fontRendererObj, stack, x, y, null);
- hasEffectOverride = false;
- itemRender.zLevel = 0;
- RenderHelper.disableStandardItemLighting();
- disableCustomDungColours = false;
- }
-
- public static void drawItemStackWithText(ItemStack stack, int x, int y, String text) {
- if(stack == null)return;
-
- RenderItem itemRender = Minecraft.getMinecraft().getRenderItem();
-
- disableCustomDungColours = true;
- RenderHelper.enableGUIStandardItemLighting();
- itemRender.zLevel = -145; //Negates the z-offset of the below method.
- itemRender.renderItemAndEffectIntoGUI(stack, x, y);
- itemRender.renderItemOverlayIntoGUI(Minecraft.getMinecraft().fontRendererObj, stack, x, y, text);
- itemRender.zLevel = 0;
- RenderHelper.disableStandardItemLighting();
- disableCustomDungColours = false;
- }
-
- public static void drawItemStack(ItemStack stack, int x, int y) {
- if(stack == null) return;
-
- drawItemStackWithText(stack, x, y, null);
- }
-
- private static final EnumChatFormatting[] rainbow = new EnumChatFormatting[]{
- EnumChatFormatting.RED,
- EnumChatFormatting.GOLD,
- EnumChatFormatting.YELLOW,
- EnumChatFormatting.GREEN,
- EnumChatFormatting.AQUA,
- EnumChatFormatting.LIGHT_PURPLE,
- EnumChatFormatting.DARK_PURPLE
- };
-
- public static String chromaString(String str) {
- return chromaString(str, 0, false);
- }
-
- private static final Pattern CHROMA_REPLACE_PATTERN = Pattern.compile("\u00a7z(.+?)(?=\u00a7|$)");
-
- public static String chromaStringByColourCode(String str) {
- if(str.contains("\u00a7z")) {
- Matcher matcher = CHROMA_REPLACE_PATTERN.matcher(str);
-
- StringBuffer sb = new StringBuffer();
-
- while(matcher.find()) {
- matcher.appendReplacement(sb,
- Utils.chromaString(matcher.group(1))
- .replace("\\", "\\\\")
- .replace("$", "\\$")
- );
- }
- matcher.appendTail(sb);
-
- str = sb.toString();
- }
- return str;
- }
-
- private static long startTime = 0;
- public static String chromaString(String str, float offset, boolean bold) {
- str = cleanColour(str);
-
- long currentTimeMillis = System.currentTimeMillis();
- if(startTime == 0) startTime = currentTimeMillis;
-
- int chromaSpeed = NotEnoughUpdates.INSTANCE.config.misc.chromaSpeed;
- if(chromaSpeed < 10) chromaSpeed = 10;
- if(chromaSpeed > 5000) chromaSpeed = 5000;
-
- StringBuilder rainbowText = new StringBuilder();
- int len = 0;
- for(int i=0; i<str.length(); i++) {
- char c = str.charAt(i);
- int index = ((int)(offset+len/12f-(currentTimeMillis-startTime)/chromaSpeed))%rainbow.length;
- len += Minecraft.getMinecraft().fontRendererObj.getCharWidth(c);
- if(bold) len++;
-
- if(index < 0) index += rainbow.length;
- rainbowText.append(rainbow[index]);
- if(bold) rainbowText.append(EnumChatFormatting.BOLD);
- rainbowText.append(c);
- }
- return rainbowText.toString();
- }
-
- private static char[] c = new char[]{'k', 'm', 'b', 't'};
- public static String shortNumberFormat(double n, int iteration) {
- double d = ((long) n / 100) / 10.0;
- boolean isRound = (d * 10) %10 == 0;
- return (d < 1000?
- ((d > 99.9 || isRound || (!isRound && d > 9.99)?
- (int) d * 10 / 10 : d + ""
- ) + "" + c[iteration])
- : shortNumberFormat(d, iteration+1));
- }
-
- public static String trimIgnoreColour(String str) {
- return trimIgnoreColourStart(trimIgnoreColourEnd(str));
- }
-
- public static String trimIgnoreColourStart(String str) {
- str = str.trim();
- boolean colourCodeLast = false;
- StringBuilder colours = new StringBuilder();
- for(int i=0; i<str.length(); i++) {
- char c = str.charAt(i);
- if(colourCodeLast) {
- colours.append('\u00a7').append(c);
- colourCodeLast = false;
- continue;
- }
- if(c == '\u00A7') {
- colourCodeLast = true;
- } else if(c != ' ') {
- return colours.append(str.substring(i)).toString();
- }
- }
-
- return "";
- }
-
- public static String trimIgnoreColourEnd(String str) {
- str = str.trim();
- for(int i=str.length()-1; i>=0; i--) {
- char c = str.charAt(i);
- if(c == ' ') {
- continue;
- } else if(i > 0 && str.charAt(i-1) == '\u00a7') {
- i--;
- continue;
- }
-
- return str.substring(0, i+1);
- }
-
- return "";
- }
-
- public static List<String> getRawTooltip(ItemStack stack) {
- List<String> list = Lists.<String>newArrayList();
- String s = stack.getDisplayName();
-
- if (stack.hasDisplayName()) {
- s = EnumChatFormatting.ITALIC + s;
- }
-
- s = s + EnumChatFormatting.RESET;
-
- if (!stack.hasDisplayName() && stack.getItem() == Items.filled_map) {
- s = s + " #" + stack.getItemDamage();
- }
-
- list.add(s);
-
- if (stack.hasTagCompound()) {
- if (stack.getTagCompound().hasKey("display", 10)) {
- NBTTagCompound nbttagcompound = stack.getTagCompound().getCompoundTag("display");
-
- if (nbttagcompound.hasKey("color", 3)) {
- list.add(EnumChatFormatting.ITALIC + StatCollector.translateToLocal("item.dyed"));
- }
-
- if (nbttagcompound.getTagId("Lore") == 9) {
- NBTTagList nbttaglist1 = nbttagcompound.getTagList("Lore", 8);
-
- if (nbttaglist1.tagCount() > 0) {
- for (int j1 = 0; j1 < nbttaglist1.tagCount(); ++j1) {
- list.add(EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + nbttaglist1.getStringTagAt(j1));
- }
- }
- }
- }
- }
-
- return list;
- }
-
- public static String floatToString(float f, int decimals) {
- if(decimals <= 0) {
- return String.valueOf(Math.round(f));
- } else {
- return String.format("%."+decimals+"f", f + 0.00001f);
- }
- }
-
- public static void drawItemStackLinear(ItemStack stack, int x, int y) {
- if(stack == null)return;
-
- RenderItem itemRender = Minecraft.getMinecraft().getRenderItem();
-
- RenderHelper.enableGUIStandardItemLighting();
- itemRender.zLevel = -145; //Negates the z-offset of the below method.
-
- IBakedModel ibakedmodel = itemRender.getItemModelMesher().getItemModel(stack);
- GlStateManager.pushMatrix();
- Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
- Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture).setBlurMipmap(true, true);
- GlStateManager.enableRescaleNormal();
- GlStateManager.enableAlpha();
- GlStateManager.alphaFunc(516, 0.1F);
- GlStateManager.enableBlend();
- GlStateManager.blendFunc(770, 771);
- GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
- setupGuiTransform(x, y, ibakedmodel.isGui3d());
- ibakedmodel = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(ibakedmodel, ItemCameraTransforms.TransformType.GUI);
- itemRender.renderItem(stack, ibakedmodel);
- GlStateManager.disableAlpha();
- GlStateManager.disableRescaleNormal();
- GlStateManager.disableLighting();
- GlStateManager.popMatrix();
- Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
- Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture).restoreLastBlurMipmap();
-
- itemRender.renderItemOverlays(Minecraft.getMinecraft().fontRendererObj, stack, x, y);
- itemRender.zLevel = 0;
- RenderHelper.disableStandardItemLighting();
- }
-
- private static void setupGuiTransform(int xPosition, int yPosition, boolean isGui3d) {
- GlStateManager.translate((float)xPosition, (float)yPosition, 5);
- GlStateManager.translate(8.0F, 8.0F, 0.0F);
- GlStateManager.scale(1.0F, 1.0F, -1.0F);
- GlStateManager.scale(0.5F, 0.5F, 0.5F);
-
- if (isGui3d) {
- GlStateManager.scale(40.0F, 40.0F, 40.0F);
- GlStateManager.rotate(210.0F, 1.0F, 0.0F, 0.0F);
- GlStateManager.rotate(-135.0F, 0.0F, 1.0F, 0.0F);
- GlStateManager.enableLighting();
- } else {
- GlStateManager.scale(64.0F, 64.0F, 64.0F);
- GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F);
- GlStateManager.disableLighting();
- }
- }
-
- public static Method getMethod(Class<?> clazz, Class<?>[] params, String... methodNames) {
- for(String methodName : methodNames) {
- try {
- return clazz.getDeclaredMethod(methodName, params);
- } catch(Exception e) {}
- }
- return null;
- }
-
- public static Object getField(Class<?> clazz, Object o, String... fieldNames) {
- Field field = null;
- for(String fieldName : fieldNames) {
- try {
- field = clazz.getDeclaredField(fieldName);
- break;
- } catch(Exception e) {}
- }
- if(field != null) {
- field.setAccessible(true);
- try {
- return field.get(o);
- } catch(IllegalAccessException e) {
- }
- }
- return null;
- }
-
- public static Slot getSlotUnderMouse(GuiContainer container) {
- Slot slot = (Slot) getField(GuiContainer.class, container, "theSlot", "field_147006_u");
- if(slot == null){
- slot = SlotLocking.getInstance().getRealSlot();
- }
- return slot;
- }
-
- public static void drawTexturedRect(float x, float y, float width, float height) {
- drawTexturedRect(x, y, width, height, 0, 1, 0 , 1);
- }
-
- public static void drawTexturedRect(float x, float y, float width, float height, int filter) {
- drawTexturedRect(x, y, width, height, 0, 1, 0 , 1, filter);
- }
-
- public static void drawTexturedRect(float x, float y, float width, float height, float uMin, float uMax, float vMin, float vMax) {
- drawTexturedRect(x, y, width, height, uMin, uMax, vMin , vMax, GL11.GL_LINEAR);
- }
-
- public static String cleanColour(String in) {
- return in.replaceAll("(?i)\\u00A7.", "");
- }
-
- public static String cleanColourNotModifiers(String in) {
- return in.replaceAll("(?i)\\u00A7[0-9a-f]", "");
- }
-
- public static String fixBrokenAPIColour(String in) {
- return in.replaceAll("(?i)\\u00C2(\\u00A7.)", "$1");
- }
-
- public static String prettyCase(String str) {
- return str.substring(0, 1).toUpperCase() + str.substring(1).toLowerCase();
- }
-
- public static String[] rarityArr = new String[] {
- "COMMON", "UNCOMMON", "RARE", "EPIC", "LEGENDARY", "MYTHIC", "SPECIAL", "VERY SPECIAL", "SUPREME", "DIVINE"
- };
-
- public static String[] rarityArrC = new String[] {
- EnumChatFormatting.WHITE+EnumChatFormatting.BOLD.toString()+"COMMON",
- EnumChatFormatting.GREEN+EnumChatFormatting.BOLD.toString()+"UNCOMMON",
- EnumChatFormatting.BLUE+EnumChatFormatting.BOLD.toString()+"RARE",
- EnumChatFormatting.DARK_PURPLE+EnumChatFormatting.BOLD.toString()+"EPIC",
- EnumChatFormatting.GOLD+EnumChatFormatting.BOLD.toString()+"LEGENDARY",
- EnumChatFormatting.LIGHT_PURPLE+EnumChatFormatting.BOLD.toString()+"MYTHIC",
- EnumChatFormatting.RED+EnumChatFormatting.BOLD.toString()+"SPECIAL",
- EnumChatFormatting.RED+EnumChatFormatting.BOLD.toString()+"VERY SPECIAL",
- EnumChatFormatting.DARK_RED+EnumChatFormatting.BOLD.toString()+"SUPREME",
- EnumChatFormatting.AQUA+EnumChatFormatting.BOLD.toString()+"DIVINE",
-
- };
- public static final HashMap<String, String> rarityArrMap = new HashMap<>();
- static {
- rarityArrMap.put("COMMON", rarityArrC[0]);
- rarityArrMap.put("UNCOMMON", rarityArrC[1]);
- rarityArrMap.put("RARE", rarityArrC[2]);
- rarityArrMap.put("EPIC", rarityArrC[3]);
- rarityArrMap.put("LEGENDARY", rarityArrC[4]);
- rarityArrMap.put("MYTHIC", rarityArrC[5]);
- rarityArrMap.put("SPECIAL", rarityArrC[6]);
- rarityArrMap.put("VERY SPECIAL", rarityArrC[7]);
- rarityArrMap.put("SUPREME", rarityArrC[8]);
- rarityArrMap.put("DIVINE", rarityArrC[9]);
-
- }
-
- public static String getRarityFromInt(int rarity){
- if(rarity < 0|| rarity >= rarityArr.length){ return rarityArr[0]; }
- return rarityArr[rarity];
- }
-
- public static int checkItemTypePet(List<String> lore){
- for(int i=lore.size()-1; i>=0; i--){
- String line = Utils.cleanColour(lore.get(i));
- for (int i1 = 0; i1 < rarityArr.length; i1++) {
- if(line.equals(rarityArr[i1])){
- return i1;
- }
- }
- }
- return -1;
- }
-
- public static int checkItemType(JsonArray lore, boolean contains, String... typeMatches) {
- for(int i=lore.size()-1; i>=0; i--) {
- String line = lore.get(i).getAsString();
-
- int returnType = checkItemType(line, contains, typeMatches);
- if(returnType != -1){
- return returnType;
- }
- }
- return -1;
- }
-
- public static int checkItemType(String[] lore, boolean contains, String... typeMatches) {
- for(int i=lore.length-1; i>=0; i--) {
- String line = lore[i];
-
- int returnType = checkItemType(line, contains, typeMatches);
- if(returnType != -1){
- return returnType;
- }
- }
- return -1;
- }
-
- public static int checkItemType(List<String> lore, boolean contains, String... typeMatches) {
- for(int i=lore.size()-1; i>=0; i--) {
- String line = lore.get(i);
-
- int returnType = checkItemType(line, contains, typeMatches);
- if(returnType != -1){
- return returnType;
- }
- }
- return -1;
- }
-
- private static int checkItemType(String line, boolean contains, String... typeMatches) {
- for (String rarity : rarityArr) {
- for (int j = 0; j < typeMatches.length; j++) {
- if (contains) {
- if (line.trim().contains(rarity + " " + typeMatches[j])) {
- return j;
- } else if (line.trim().contains(rarity + " DUNGEON " + typeMatches[j])) {
- return j;
- }
- } else {
- if (line.trim().endsWith(rarity + " " + typeMatches[j])) {
- return j;
- } else if (line.trim().endsWith(rarity + " DUNGEON " + typeMatches[j])) {
- return j;
- }
- }
- }
- }
- return -1;
- }
-
- public static float round (float value, int precision) {
- int scale = (int) Math.pow(10, precision);
- return (float) Math.round(value * scale) / scale;
- }
-
-
-
- public static void playPressSound() {
- playSound(new ResourceLocation("gui.button.press"), true);
- }
-
- public static void playSound(ResourceLocation sound, boolean gui) {
- if(NotEnoughUpdates.INSTANCE.config.misc.guiButtonClicks || !gui) {
- Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(sound, 1.0F));
- }
- }
-
- public static String cleanDuplicateColourCodes(String line) {
- StringBuilder sb = new StringBuilder();
- char currentColourCode = 'r';
- boolean sectionSymbolLast = false;
- for(char c : line.toCharArray()) {
- if((int)c > 50000) continue;
-
- if(c == '\u00a7') {
- sectionSymbolLast = true;
- } else {
- if(sectionSymbolLast) {
- if(currentColourCode != c) {
- sb.append('\u00a7');
- sb.append(c);
- currentColourCode = c;
- }
- sectionSymbolLast = false;
- } else {
- sb.append(c);
- }
- }
- }
- return sb.toString();
- }
-
- public static void drawTexturedRect(float x, float y, float width, float height, float uMin, float uMax, float vMin, float vMax, int filter) {
- GlStateManager.enableTexture2D();
- GlStateManager.enableBlend();
- GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
- GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
-
- GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, filter);
- GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, filter);
-
- Tessellator tessellator = Tessellator.getInstance();
- WorldRenderer worldrenderer = tessellator.getWorldRenderer();
- worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
- worldrenderer
- .pos(x, y+height, 0.0D)
- .tex(uMin, vMax).endVertex();
- worldrenderer
- .pos(x+width, y+height, 0.0D)
- .tex(uMax, vMax).endVertex();
- worldrenderer
- .pos(x+width, y, 0.0D)
- .tex(uMax, vMin).endVertex();
- worldrenderer
- .pos(x, y, 0.0D)
- .tex(uMin, vMin).endVertex();
- tessellator.draw();
-
- GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
- GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
-
- GlStateManager.disableBlend();
- }
-
- public static void drawTexturedRectNoBlend(float x, float y, float width, float height, float uMin, float uMax, float vMin, float vMax, int filter) {
- GlStateManager.enableTexture2D();
-
- GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, filter);
- GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, filter);
-
- Tessellator tessellator = Tessellator.getInstance();
- WorldRenderer worldrenderer = tessellator.getWorldRenderer();
- worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
- worldrenderer
- .pos(x, y+height, 0.0D)
- .tex(uMin, vMax).endVertex();
- worldrenderer
- .pos(x+width, y+height, 0.0D)
- .tex(uMax, vMax).endVertex();
- worldrenderer
- .pos(x+width, y, 0.0D)
- .tex(uMax, vMin).endVertex();
- worldrenderer
- .pos(x, y, 0.0D)
- .tex(uMin, vMin).endVertex();
- tessellator.draw();
-
- GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
- GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
- }
-
- public static ItemStack createItemStack(Item item, String displayname, String... lore) {
- return createItemStack(item, displayname, 0, lore);
- }
-
- public static ItemStack createItemStack(Item item, String displayname, int damage, String... lore) {
- ItemStack stack = new ItemStack(item, 1, damage);
- NBTTagCompound tag = new NBTTagCompound();
- NBTTagCompound display = new NBTTagCompound();
- NBTTagList Lore = new NBTTagList();
-
- for(String line : lore) {
- Lore.appendTag(new NBTTagString(line));
- }
-
- display.setString("Name", displayname);
- display.setTag("Lore", Lore);
-
- tag.setTag("display", display);
- tag.setInteger("HideFlags", 254);
-
- stack.setTagCompound(tag);
-
- return stack;
- }
-
- public static ItemStack editItemStackInfo(ItemStack itemStack, String displayName, boolean disableNeuToolTips, String... lore){
- NBTTagCompound tag = itemStack.getTagCompound();
- NBTTagCompound display = tag.getCompoundTag("display");
- NBTTagList Lore = new NBTTagList();
-
- for(String line : lore) {
- Lore.appendTag(new NBTTagString(line));
- }
-
- display.setString("Name", displayName);
- display.setTag("Lore", Lore);
-
- tag.setTag("display", display);
- tag.setInteger("HideFlags", 254);
- if(disableNeuToolTips){
- tag.setBoolean("disableNeuTooltip", true);
- }
-
- itemStack.setTagCompound(tag);
-
- return itemStack;
- }
-
- public static void drawStringF(String str, FontRenderer fr, float x, float y, boolean shadow, int colour) {
- fr.drawString(str, x, y, colour, shadow);
- }
-
- public static int getCharVertLen(char c) {
- if("acegmnopqrsuvwxyz".indexOf(c) >= 0) {
- return 5;
- } else {
- return 7;
- }
- }
-
- public static float getVerticalHeight(String str) {
- str = cleanColour(str);
- float height = 0;
- for(int i=0; i<str.length(); i++) {
- char c = str.charAt(i);
- int charHeight = getCharVertLen(c);
- height += charHeight + 1.5f;
- }
- return height;
- }
-
- public static void drawStringVertical(String str, FontRenderer fr, float x, float y, boolean shadow, int colour) {
- String format = FontRenderer.getFormatFromString(str);
- str = cleanColour(str);
- for(int i=0; i<str.length(); i++) {
- char c = str.charAt(i);
-
- int charHeight = getCharVertLen(c);
- int charWidth = fr.getCharWidth(c);
- fr.drawString(format+c, x+(5-charWidth)/2f, y-7+charHeight, colour, shadow);
-
- y += charHeight + 1.5f;
- }
- }
-
- public static void renderShadowedString(String str, float x, float y, int maxLength) {
- int strLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(str);
- float factor;
- if(maxLength < 0) {
- factor = 1;
- } else {
- factor = maxLength/(float)strLen;
- factor = Math.min(1, factor);
- }
-
- for(int xOff=-2; xOff<=2; xOff++) {
- for(int yOff=-2; yOff<=2; yOff++) {
- if(Math.abs(xOff) != Math.abs(yOff)) {
- Utils.drawStringCenteredScaledMaxWidth(Utils.cleanColourNotModifiers(str), Minecraft.getMinecraft().fontRendererObj,
- x+xOff/2f*factor, y+4+yOff/2f*factor, false, maxLength,
- new Color(0, 0, 0, 200/Math.max(Math.abs(xOff), Math.abs(yOff))).getRGB());
- }
- }
- }
-
- GlStateManager.color(1, 1, 1, 1);
- Utils.drawStringCenteredScaledMaxWidth(str, Minecraft.getMinecraft().fontRendererObj,
- x, y+4, false, maxLength, 4210752);
- }
-
- public static void renderAlignedString(String first, String second, float x, float y, int length) {
- FontRenderer fontRendererObj = Minecraft.getMinecraft().fontRendererObj;
- if(fontRendererObj.getStringWidth(first + " " + second) >= length) {
- renderShadowedString(first + " " + second, x+length/2f, y, length);
- } 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);
- }
- }
-
- public static void drawStringScaledMaxWidth(String str, FontRenderer fr, float x, float y, boolean shadow, int len, int colour) {
- int strLen = fr.getStringWidth(str);
- float factor = len/(float)strLen;
- factor = Math.min(1, factor);
-
- drawStringScaled(str, fr, x, y, shadow, colour, factor);
- }
-
- public static void drawStringCentered(String str, FontRenderer fr, float x, float y, boolean shadow, int colour) {
- int strLen = fr.getStringWidth(str);
-
- float x2 = x - strLen/2f;
- float y2 = y - fr.FONT_HEIGHT/2f;
-
- GL11.glTranslatef(x2, y2, 0);
- fr.drawString(str, 0, 0, colour, shadow);
- GL11.glTranslatef(-x2, -y2, 0);
- }
-
- public static void drawStringScaled(String str, FontRenderer fr, float x, float y, boolean shadow, int colour, float factor) {
- GlStateManager.scale(factor, factor, 1);
- fr.drawString(str, x/factor, y/factor, colour, shadow);
- GlStateManager.scale(1/factor, 1/factor, 1);
- }
-
- public static void drawStringCenteredScaledMaxWidth(String str, FontRenderer fr, float x, float y, boolean shadow, int len, int colour) {
- int strLen = fr.getStringWidth(str);
- float factor = len/(float)strLen;
- factor = Math.min(1, factor);
- int newLen = Math.min(strLen, len);
-
- float fontHeight = 8*factor;
-
- drawStringScaled(str, fr, x-newLen/2, y-fontHeight/2, shadow, colour, factor);
- }
-
- public static Matrix4f createProjectionMatrix(int width, int height) {
- Matrix4f projMatrix = new Matrix4f();
- projMatrix.setIdentity();
- projMatrix.m00 = 2.0F / (float)width;
- projMatrix.m11 = 2.0F / (float)(-height);
- projMatrix.m22 = -0.0020001999F;
- projMatrix.m33 = 1.0F;
- projMatrix.m03 = -1.0F;
- projMatrix.m13 = 1.0F;
- projMatrix.m23 = -1.0001999F;
- return projMatrix;
- }
-
- public static void drawStringCenteredScaled(String str, FontRenderer fr, float x, float y, boolean shadow, int len, int colour) {
- int strLen = fr.getStringWidth(str);
- float factor = len/(float)strLen;
- float fontHeight = 8*factor;
-
- drawStringScaled(str, fr, x-len/2, y-fontHeight/2, shadow, colour, factor);
- }
-
- public static void drawStringCenteredYScaled(String str, FontRenderer fr, float x, float y, boolean shadow, int len, int colour) {
- int strLen = fr.getStringWidth(str);
- float factor = len/(float)strLen;
- float fontHeight = 8*factor;
-
- drawStringScaled(str, fr, x, y-fontHeight/2, shadow, colour, factor);
- }
-
- public static void drawStringCenteredYScaledMaxWidth(String str, FontRenderer fr, float x, float y, boolean shadow, int len, int colour) {
- int strLen = fr.getStringWidth(str);
- float factor = len/(float)strLen;
- factor = Math.min(1, factor);
- float fontHeight = 8*factor;
-
- drawStringScaled(str, fr, x, y-fontHeight/2, shadow, colour, factor);
- }
-
- public static int renderStringTrimWidth(String str, FontRenderer fr, boolean shadow, int x, int y, int len, int colour, int maxLines) {
- return renderStringTrimWidth(str, fr, shadow, x, y, len, colour, maxLines, 1);
- }
-
- public static int renderStringTrimWidth(String str, FontRenderer fr, boolean shadow, int x, int y, int len, int colour, int maxLines, float scale) {
- len = (int)(len/scale);
-
- int yOff = 0;
- String excess;
- String trimmed = trimToWidth(str, len);
-
- String colourCodes = "";
- Pattern pattern = Pattern.compile("\\u00A7.");
- Matcher matcher = pattern.matcher(trimmed);
- while(matcher.find()) {
- colourCodes += matcher.group();
- }
-
- boolean firstLine = true;
- int trimmedCharacters = trimmed.length();
- int lines = 0;
- while((lines++<maxLines) || maxLines<0) {
- if(trimmed.length() == str.length()) {
- drawStringScaled(trimmed, fr, x, y+yOff, shadow, colour, scale);
- //fr.drawString(trimmed, x, y + yOff, colour, shadow);
- break;
- } else if(trimmed.isEmpty()) {
- yOff -= 12*scale;
- break;
- } else {
- if(firstLine) {
- drawStringScaled(trimmed, fr, x, y+yOff, shadow, colour, scale);
- firstLine = false;
- } else {
- if(trimmed.startsWith(" ")) {
- trimmed = trimmed.substring(1);
- }
- drawStringScaled(colourCodes + trimmed, fr, x, y+yOff, shadow, colour, scale);
- }
-
- excess = str.substring(trimmedCharacters);
- trimmed = trimToWidth(excess, len);
- trimmedCharacters += trimmed.length();
- yOff += 12*scale;
- }
- }
- return yOff;
- }
-
- public static String trimToWidth(String str, int len) {
- FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
- String trim = fr.trimStringToWidth(str, len);
-
- if(str.length() != trim.length() && !trim.endsWith(" ")) {
- char next = str.charAt(trim.length());
- if(next != ' ') {
- String[] split = trim.split(" ");
- String last = split[split.length-1];
- if(last.length() < 8) {
- trim = trim.substring(0, trim.length()-last.length());
- }
- }
- }
-
- return trim;
- }
-
- public static void drawGradientRect(int left, int top, int right, int bottom, int startColor, int endColor) {
- float f = (float)(startColor >> 24 & 255) / 255.0F;
- float f1 = (float)(startColor >> 16 & 255) / 255.0F;
- float f2 = (float)(startColor >> 8 & 255) / 255.0F;
- float f3 = (float)(startColor & 255) / 255.0F;
- float f4 = (float)(endColor >> 24 & 255) / 255.0F;
- float f5 = (float)(endColor >> 16 & 255) / 255.0F;
- float f6 = (float)(endColor >> 8 & 255) / 255.0F;
- float f7 = (float)(endColor & 255) / 255.0F;
- GlStateManager.disableTexture2D();
- GlStateManager.enableBlend();
- GlStateManager.disableAlpha();
- GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
- GlStateManager.shadeModel(7425);
- Tessellator tessellator = Tessellator.getInstance();
- WorldRenderer worldrenderer = tessellator.getWorldRenderer();
- worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
- worldrenderer.pos((double)right, (double)top, 0).color(f1, f2, f3, f).endVertex();
- worldrenderer.pos((double)left, (double)top, 0).color(f1, f2, f3, f).endVertex();
- worldrenderer.pos((double)left, (double)bottom, 0).color(f5, f6, f7, f4).endVertex();
- worldrenderer.pos((double)right, (double)bottom, 0).color(f5, f6, f7, f4).endVertex();
- tessellator.draw();
- GlStateManager.shadeModel(7424);
- GlStateManager.disableBlend();
- GlStateManager.enableAlpha();
- GlStateManager.enableTexture2D();
- }
-
- public static void drawGradientRectHorz(int left, int top, int right, int bottom, int startColor, int endColor) {
- float f = (float)(startColor >> 24 & 255) / 255.0F;
- float f1 = (float)(startColor >> 16 & 255) / 255.0F;
- float f2 = (float)(startColor >> 8 & 255) / 255.0F;
- float f3 = (float)(startColor & 255) / 255.0F;
- float f4 = (float)(endColor >> 24 & 255) / 255.0F;
- float f5 = (float)(endColor >> 16 & 255) / 255.0F;
- float f6 = (float)(endColor >> 8 & 255) / 255.0F;
- float f7 = (float)(endColor & 255) / 255.0F;
- GlStateManager.disableTexture2D();
- GlStateManager.enableBlend();
- GlStateManager.disableAlpha();
- GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
- GlStateManager.shadeModel(7425);
- Tessellator tessellator = Tessellator.getInstance();
- WorldRenderer worldrenderer = tessellator.getWorldRenderer();
- worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
- worldrenderer.pos((double)right, (double)top, 0).color(f5, f6, f7, f4).endVertex();
- worldrenderer.pos((double)left, (double)top, 0).color(f1, f2, f3, f).endVertex();
- worldrenderer.pos((double)left, (double)bottom, 0).color(f1, f2, f3, f).endVertex();
- worldrenderer.pos((double)right, (double)bottom, 0).color(f5, f6, f7, f4).endVertex();
- tessellator.draw();
- GlStateManager.shadeModel(7424);
- GlStateManager.disableBlend();
- GlStateManager.enableAlpha();
- GlStateManager.enableTexture2D();
- }
-
- public static void drawHoveringText(List<String> textLines, final int mouseX, final int mouseY, final int screenWidth, final int screenHeight, final int maxTextWidth, FontRenderer font) {
- drawHoveringText(textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth, font, true);
- }
-
- public static JsonObject getConstant(String constant, Gson gson) {
- return getConstant(constant, gson, JsonObject.class);
- }
-
- public static <T> T getConstant(String constant, Gson gson, Class<T> clazz) {
- File repo = NotEnoughUpdates.INSTANCE.manager.repoLocation;
- if(repo.exists()) {
- File jsonFile = new File(repo, "constants/"+constant+".json");
- try(BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(jsonFile), StandardCharsets.UTF_8))) {
- T obj = gson.fromJson(reader, clazz);
- return obj;
- } catch(Exception e) { return null; }
- }
- return null;
- }
-
- public static float getElementAsFloat(JsonElement element, float def) {
- if(element == null) return def;
- if(!element.isJsonPrimitive()) return def;
- JsonPrimitive prim = element.getAsJsonPrimitive();
- if(!prim.isNumber()) return def;
- return prim.getAsFloat();
- }
-
- public static String getElementAsString(JsonElement element, String def) {
- if(element == null) return def;
- if(!element.isJsonPrimitive()) return def;
- JsonPrimitive prim = element.getAsJsonPrimitive();
- if(!prim.isString()) return def;
- return prim.getAsString();
- }
-
- public static Splitter PATH_SPLITTER = Splitter.on(".").omitEmptyStrings().limit(2);
- public static JsonElement getElement(JsonElement element, String path) {
- List<String> path_split = PATH_SPLITTER.splitToList(path);
- if(element instanceof JsonObject) {
- JsonElement e = element.getAsJsonObject().get(path_split.get(0));
- if(path_split.size() > 1) {
- return getElement(e, path_split.get(1));
- } else {
- return e;
- }
- } else {
- return element;
- }
- }
-
- public static ChatStyle createClickStyle(ClickEvent.Action action, String value) {
- ChatStyle style = new ChatStyle();
- style.setChatClickEvent(new ClickEvent(action, value));
- style.setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(EnumChatFormatting.YELLOW+value)));
- return style;
- }
- public static ChatStyle createClickStyle(ClickEvent.Action action, String value, String message) {
- ChatStyle style = createClickStyle(action, value);
- style.setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(message)));
- return style;
- }
-
- public static void recursiveDelete(File file) {
- if(file.isDirectory() && !Files.isSymbolicLink(file.toPath())) {
- for(File child : file.listFiles()) {
- recursiveDelete(child);
- }
- }
- file.delete();
- }
-
- public static char getPrimaryColourCode(String displayname) {
- int lastColourCode = -99;
- int currentColour = 0;
- int[] mostCommon = new int[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
- for(int i=0; i<displayname.length(); i++) {
- char c = displayname.charAt(i);
- if(c == '\u00A7') {
- lastColourCode = i;
- } else if(lastColourCode == i-1) {
- int colIndex = "0123456789abcdef".indexOf(c);
- if(colIndex >= 0) {
- currentColour = colIndex;
- } else {
- currentColour = 0;
- }
- } else if("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".indexOf(c) >= 0){
- if(currentColour > 0) {
- mostCommon[currentColour]++;
- }
- }
- }
- int mostCommonCount = 0;
- for(int index=0; index<mostCommon.length; index++) {
- if(mostCommon[index] > mostCommonCount) {
- mostCommonCount = mostCommon[index];
- currentColour = index;
- }
- }
-
- return "0123456789abcdef".charAt(currentColour);
- }
-
- public static Color getPrimaryColour(String displayname) {
- int colourInt = Minecraft.getMinecraft().fontRendererObj.getColorCode(getPrimaryColourCode(displayname));
- return new Color(colourInt).darker();
- }
-
- public static void scrollTooltip(int dY) {
- scrollY.setTarget(scrollY.getTarget()+dY/10f);
- scrollY.resetTimer();
- }
-
- private static LerpingFloat scrollY = new LerpingFloat(0, 100);
- public static void drawHoveringText(List<String> textLines, final int mouseX, final int mouseY, final int screenWidth, final int screenHeight, final int maxTextWidth, FontRenderer font, boolean coloured) {
- if (!textLines.isEmpty())
- {
- GlStateManager.disableRescaleNormal();
- RenderHelper.disableStandardItemLighting();
- GlStateManager.disableLighting();
- GlStateManager.enableDepth();
- int tooltipTextWidth = 0;
-
- for (String textLine : textLines)
- {
- int textLineWidth = font.getStringWidth(textLine);
-
- if (textLineWidth > tooltipTextWidth)
- {
- tooltipTextWidth = textLineWidth;
- }
- }
-
- boolean needsWrap = false;
-
- int titleLinesCount = 1;
- int tooltipX = mouseX + 12;
- if (tooltipX + tooltipTextWidth + 4 > screenWidth)
- {
- tooltipX = mouseX - 16 - tooltipTextWidth;
- if (tooltipX < 4) // if the tooltip doesn't fit on the screen
- {
- if (mouseX > screenWidth / 2)
- {
- tooltipTextWidth = mouseX - 12 - 8;
- }
- else
- {
- tooltipTextWidth = screenWidth - 16 - mouseX;
- }
- needsWrap = true;
- }
- }
-
- if (maxTextWidth > 0 && tooltipTextWidth > maxTextWidth)
- {
- tooltipTextWidth = maxTextWidth;
- needsWrap = true;
- }
-
- if (needsWrap)
- {
- int wrappedTooltipWidth = 0;
- List<String> wrappedTextLines = new ArrayList<String>();
- for (int i = 0; i < textLines.size(); i++)
- {
- String textLine = textLines.get(i);
- List<String> wrappedLine = font.listFormattedStringToWidth(textLine, tooltipTextWidth);
- if (i == 0)
- {
- titleLinesCount = wrappedLine.size();
- }
-
- for (String line : wrappedLine)
- {
- int lineWidth = font.getStringWidth(line);
- if (lineWidth > wrappedTooltipWidth)
- {
- wrappedTooltipWidth = lineWidth;
- }
- wrappedTextLines.add(line);
- }
- }
- tooltipTextWidth = wrappedTooltipWidth;
- textLines = wrappedTextLines;
-
- if (mouseX > screenWidth / 2)
- {
- tooltipX = mouseX - 16 - tooltipTextWidth;
- }
- else
- {
- tooltipX = mouseX + 12;
- }
- }
-
- int tooltipY = mouseY - 12;
- int tooltipHeight = 8;
-
- if (textLines.size() > 1)
- {
- tooltipHeight += (textLines.size() - 1) * 10;
- if (textLines.size() > titleLinesCount) {
- tooltipHeight += 2; // gap between title lines and next lines
- }
- }
-
- //Scrollable tooltips
- if(tooltipHeight + 6 > screenHeight) {
- if(scrollY.getTarget() < 0) {
- scrollY.setTarget(0);
- scrollY.resetTimer();
- } else if(screenHeight - tooltipHeight - 12 + (int)scrollY.getTarget() > 0) {
- scrollY.setTarget(-screenHeight + tooltipHeight + 12);
- scrollY.resetTimer();
- }
- } else {
- scrollY.setValue(0);
- scrollY.resetTimer();
- }
- scrollY.tick();
-
- if (tooltipY + tooltipHeight + 6 > screenHeight)
- {
- tooltipY = screenHeight - tooltipHeight - 6 + (int)scrollY.getValue();
- }
-
- final int zLevel = 300;
- final int backgroundColor = 0xF0100010;
- drawGradientRect(zLevel, tooltipX - 3, tooltipY - 4, tooltipX + tooltipTextWidth + 3, tooltipY - 3, backgroundColor, backgroundColor);
- drawGradientRect(zLevel, tooltipX - 3, tooltipY + tooltipHeight + 3, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 4, backgroundColor, backgroundColor);
- drawGradientRect(zLevel, tooltipX - 3, tooltipY - 3, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3, backgroundColor, backgroundColor);
- drawGradientRect(zLevel, tooltipX - 4, tooltipY - 3, tooltipX - 3, tooltipY + tooltipHeight + 3, backgroundColor, backgroundColor);
- drawGradientRect(zLevel, tooltipX + tooltipTextWidth + 3, tooltipY - 3, tooltipX + tooltipTextWidth + 4, tooltipY + tooltipHeight + 3, backgroundColor, backgroundColor);
- //TODO: Coloured Borders
- int borderColorStart = 0x505000FF;
- if(NotEnoughUpdates.INSTANCE.config.tooltipTweaks.tooltipBorderColours && coloured) {
- if(textLines.size() > 0) {
- String first = textLines.get(0);
- borderColorStart = getPrimaryColour(first).getRGB() & 0x00FFFFFF |
- ((NotEnoughUpdates.INSTANCE.config.tooltipTweaks.tooltipBorderOpacity) << 24);
- }
- }
- final int borderColorEnd = (borderColorStart & 0xFEFEFE) >> 1 | borderColorStart & 0xFF000000;
- drawGradientRect(zLevel, tooltipX - 3, tooltipY - 3 + 1, tooltipX - 3 + 1, tooltipY + tooltipHeight + 3 - 1, borderColorStart, borderColorEnd);
- drawGradientRect(zLevel, tooltipX + tooltipTextWidth + 2, tooltipY - 3 + 1, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3 - 1, borderColorStart, borderColorEnd);
- drawGradientRect(zLevel, tooltipX - 3, tooltipY - 3, tooltipX + tooltipTextWidth + 3, tooltipY - 3 + 1, borderColorStart, borderColorStart);
- drawGradientRect(zLevel, tooltipX - 3, tooltipY + tooltipHeight + 2, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3, borderColorEnd, borderColorEnd);
-
- GlStateManager.disableDepth();
- for (int lineNumber = 0; lineNumber < textLines.size(); ++lineNumber)
- {
- String line = textLines.get(lineNumber);
- font.drawStringWithShadow(line, (float)tooltipX, (float)tooltipY, -1);
-
- if (lineNumber + 1 == titleLinesCount)
- {
- tooltipY += 2;
- }
-
- tooltipY += 10;
- }
-
- GlStateManager.enableLighting();
- GlStateManager.enableDepth();
- RenderHelper.enableStandardItemLighting();
- GlStateManager.enableRescaleNormal();
- }
- GlStateManager.disableLighting();
- }
-
- public static void drawGradientRect(int zLevel, int left, int top, int right, int bottom, int startColor, int endColor) {
- float startAlpha = (float)(startColor >> 24 & 255) / 255.0F;
- float startRed = (float)(startColor >> 16 & 255) / 255.0F;
- float startGreen = (float)(startColor >> 8 & 255) / 255.0F;
- float startBlue = (float)(startColor & 255) / 255.0F;
- float endAlpha = (float)(endColor >> 24 & 255) / 255.0F;
- float endRed = (float)(endColor >> 16 & 255) / 255.0F;
- float endGreen = (float)(endColor >> 8 & 255) / 255.0F;
- float endBlue = (float)(endColor & 255) / 255.0F;
-
- GlStateManager.disableTexture2D();
- GlStateManager.enableBlend();
- GlStateManager.disableAlpha();
- GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
- GlStateManager.shadeModel(7425);
-
- Tessellator tessellator = Tessellator.getInstance();
- WorldRenderer worldrenderer = tessellator.getWorldRenderer();
- worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
- worldrenderer.pos(right, top, zLevel).color(startRed, startGreen, startBlue, startAlpha).endVertex();
- worldrenderer.pos(left, top, zLevel).color(startRed, startGreen, startBlue, startAlpha).endVertex();
- worldrenderer.pos(left, bottom, zLevel).color(endRed, endGreen, endBlue, endAlpha).endVertex();
- worldrenderer.pos(right, bottom, zLevel).color(endRed, endGreen, endBlue, endAlpha).endVertex();
- tessellator.draw();
-
- GlStateManager.shadeModel(7424);
- GlStateManager.disableBlend();
- GlStateManager.enableAlpha();
- GlStateManager.enableTexture2D();
- }
-
- public static void drawRectNoBlend(int left, int top, int right, int bottom, int color) {
- if (left < right) {
- int i = left;
- left = right;
- right = i;
- }
-
- if (top < bottom) {
- int j = top;
- top = bottom;
- bottom = j;
- }
-
- float f3 = (float)(color >> 24 & 255) / 255.0F;
- float f = (float)(color >> 16 & 255) / 255.0F;
- float f1 = (float)(color >> 8 & 255) / 255.0F;
- float f2 = (float)(color & 255) / 255.0F;
- Tessellator tessellator = Tessellator.getInstance();
- WorldRenderer worldrenderer = tessellator.getWorldRenderer();
- GlStateManager.disableTexture2D();
- GlStateManager.color(f, f1, f2, f3);
- worldrenderer.begin(7, DefaultVertexFormats.POSITION);
- worldrenderer.pos((double)left, (double)bottom, 0.0D).endVertex();
- worldrenderer.pos((double)right, (double)bottom, 0.0D).endVertex();
- worldrenderer.pos((double)right, (double)top, 0.0D).endVertex();
- worldrenderer.pos((double)left, (double)top, 0.0D).endVertex();
- tessellator.draw();
- GlStateManager.enableTexture2D();
- }
-
- public static String prettyTime(long millis) {
- long seconds = millis / 1000 % 60;
- long minutes = (millis / 1000 / 60) % 60;
- long hours = (millis / 1000 / 60 / 60) % 24;
- long days = (millis / 1000 / 60 / 60 / 24);
-
- String endsIn = "";
- if(millis < 0) {
- endsIn += "Ended!";
- } else if(minutes == 0 && hours == 0 && days == 0) {
- endsIn += seconds + "s";
- } else if(hours==0 && days==0) {
- endsIn += minutes + "m" + seconds + "s";
- } else if(days==0) {
- if(hours <= 6) {
- endsIn += hours + "h" + minutes + "m" + seconds + "s";
- } else {
- endsIn += hours + "h";
- }
- } else {
- endsIn += days + "d" + hours + "h";
- }
-
- return endsIn;
- }
-
+ public static boolean hasEffectOverride = false;
+ public static boolean disableCustomDungColours = false;
+ private static final LinkedList<Integer> guiScales = new LinkedList<>();
+ private static ScaledResolution lastScale = new ScaledResolution(Minecraft.getMinecraft());
+ //Labymod compatibility
+ private static final FloatBuffer projectionMatrixOld = BufferUtils.createFloatBuffer(16);
+ private static final FloatBuffer modelviewMatrixOld = BufferUtils.createFloatBuffer(16);
+
+ public static <T> ArrayList<T> createList(T... values) {
+ ArrayList<T> list = new ArrayList<>();
+ Collections.addAll(list, values);
+ return list;
+ }
+
+ public static void resetGuiScale() {
+ guiScales.clear();
+ }
+
+ public static ScaledResolution peekGuiScale() {
+ return lastScale;
+ }
+
+ public static ScaledResolution pushGuiScale(int scale) {
+ if (guiScales.size() == 0) {
+ if (Loader.isModLoaded("labymod")) {
+ GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, projectionMatrixOld);
+ GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, modelviewMatrixOld);
+ }
+ }
+
+ if (scale < 0) {
+ if (guiScales.size() > 0) {
+ guiScales.pop();
+ }
+ } else {
+ if (scale == 0) {
+ guiScales.push(Minecraft.getMinecraft().gameSettings.guiScale);
+ } else {
+ guiScales.push(scale);
+ }
+ }
+
+ int newScale = guiScales.size() > 0
+ ? Math.max(0, Math.min(4, guiScales.peek()))
+ : Minecraft.getMinecraft().gameSettings.guiScale;
+ if (newScale == 0) newScale = Minecraft.getMinecraft().gameSettings.guiScale;
+
+ int oldScale = Minecraft.getMinecraft().gameSettings.guiScale;
+ Minecraft.getMinecraft().gameSettings.guiScale = newScale;
+ ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
+ Minecraft.getMinecraft().gameSettings.guiScale = oldScale;
+
+ if (guiScales.size() > 0) {
+ GlStateManager.viewport(0, 0, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight);
+ GlStateManager.matrixMode(GL11.GL_PROJECTION);
+ GlStateManager.loadIdentity();
+ GlStateManager.ortho(0.0D,
+ scaledresolution.getScaledWidth_double(),
+ scaledresolution.getScaledHeight_double(), 0.0D, 1000.0D, 3000.0D
+ );
+ GlStateManager.matrixMode(GL11.GL_MODELVIEW);
+ GlStateManager.loadIdentity();
+ GlStateManager.translate(0.0F, 0.0F, -2000.0F);
+ } else {
+ if (Loader.isModLoaded("labymod") && projectionMatrixOld.limit() > 0 && modelviewMatrixOld.limit() > 0) {
+ GlStateManager.matrixMode(GL11.GL_PROJECTION);
+ GL11.glLoadMatrix(projectionMatrixOld);
+ GlStateManager.matrixMode(GL11.GL_MODELVIEW);
+ GL11.glLoadMatrix(modelviewMatrixOld);
+ } else {
+ GlStateManager.matrixMode(GL11.GL_PROJECTION);
+ GlStateManager.loadIdentity();
+ GlStateManager.ortho(0.0D,
+ scaledresolution.getScaledWidth_double(),
+ scaledresolution.getScaledHeight_double(), 0.0D, 1000.0D, 3000.0D
+ );
+ GlStateManager.matrixMode(GL11.GL_MODELVIEW);
+ GlStateManager.loadIdentity();
+ GlStateManager.translate(0.0F, 0.0F, -2000.0F);
+ }
+ }
+
+ lastScale = scaledresolution;
+ return scaledresolution;
+ }
+
+ public static boolean getHasEffectOverride() {
+ return hasEffectOverride;
+ }
+
+ public static void drawItemStackWithoutGlint(ItemStack stack, int x, int y) {
+ RenderItem itemRender = Minecraft.getMinecraft().getRenderItem();
+
+ disableCustomDungColours = true;
+ RenderHelper.enableGUIStandardItemLighting();
+ itemRender.zLevel = -145; //Negates the z-offset of the below method.
+ hasEffectOverride = true;
+ try {
+ itemRender.renderItemAndEffectIntoGUI(stack, x, y);
+ } catch (Exception e) {
+ e.printStackTrace();
+ } //Catch exceptions to ensure that hasEffectOverride is set back to false.
+ itemRender.renderItemOverlayIntoGUI(Minecraft.getMinecraft().fontRendererObj, stack, x, y, null);
+ hasEffectOverride = false;
+ itemRender.zLevel = 0;
+ RenderHelper.disableStandardItemLighting();
+ disableCustomDungColours = false;
+ }
+
+ public static void drawItemStackWithText(ItemStack stack, int x, int y, String text) {
+ if (stack == null) return;
+
+ RenderItem itemRender = Minecraft.getMinecraft().getRenderItem();
+
+ disableCustomDungColours = true;
+ RenderHelper.enableGUIStandardItemLighting();
+ itemRender.zLevel = -145; //Negates the z-offset of the below method.
+ itemRender.renderItemAndEffectIntoGUI(stack, x, y);
+ itemRender.renderItemOverlayIntoGUI(Minecraft.getMinecraft().fontRendererObj, stack, x, y, text);
+ itemRender.zLevel = 0;
+ RenderHelper.disableStandardItemLighting();
+ disableCustomDungColours = false;
+ }
+
+ public static void drawItemStack(ItemStack stack, int x, int y) {
+ if (stack == null) return;
+
+ drawItemStackWithText(stack, x, y, null);
+ }
+
+ private static final EnumChatFormatting[] rainbow = new EnumChatFormatting[]{
+ EnumChatFormatting.RED,
+ EnumChatFormatting.GOLD,
+ EnumChatFormatting.YELLOW,
+ EnumChatFormatting.GREEN,
+ EnumChatFormatting.AQUA,
+ EnumChatFormatting.LIGHT_PURPLE,
+ EnumChatFormatting.DARK_PURPLE
+ };
+
+ public static String chromaString(String str) {
+ return chromaString(str, 0, false);
+ }
+
+ private static final Pattern CHROMA_REPLACE_PATTERN = Pattern.compile("\u00a7z(.+?)(?=\u00a7|$)");
+
+ public static String chromaStringByColourCode(String str) {
+ if (str.contains("\u00a7z")) {
+ Matcher matcher = CHROMA_REPLACE_PATTERN.matcher(str);
+
+ StringBuffer sb = new StringBuffer();
+
+ while (matcher.find()) {
+ matcher.appendReplacement(
+ sb,
+ Utils.chromaString(matcher.group(1))
+ .replace("\\", "\\\\")
+ .replace("$", "\\$")
+ );
+ }
+ matcher.appendTail(sb);
+
+ str = sb.toString();
+ }
+ return str;
+ }
+
+ private static long startTime = 0;
+
+ public static String chromaString(String str, float offset, boolean bold) {
+ str = cleanColour(str);
+
+ long currentTimeMillis = System.currentTimeMillis();
+ if (startTime == 0) startTime = currentTimeMillis;
+
+ int chromaSpeed = NotEnoughUpdates.INSTANCE.config.misc.chromaSpeed;
+ if (chromaSpeed < 10) chromaSpeed = 10;
+ if (chromaSpeed > 5000) chromaSpeed = 5000;
+
+ StringBuilder rainbowText = new StringBuilder();
+ int len = 0;
+ for (int i = 0; i < str.length(); i++) {
+ char c = str.charAt(i);
+ int index = ((int) (offset + len / 12f - (currentTimeMillis - startTime) / chromaSpeed)) % rainbow.length;
+ len += Minecraft.getMinecraft().fontRendererObj.getCharWidth(c);
+ if (bold) len++;
+
+ if (index < 0) index += rainbow.length;
+ rainbowText.append(rainbow[index]);
+ if (bold) rainbowText.append(EnumChatFormatting.BOLD);
+ rainbowText.append(c);
+ }
+ return rainbowText.toString();
+ }
+
+ private static final char[] c = new char[]{'k', 'm', 'b', 't'};
+
+ public static String shortNumberFormat(double n, int iteration) {
+ double d = ((long) n / 100) / 10.0;
+ boolean isRound = (d * 10) % 10 == 0;
+ return (d < 1000 ?
+ ((d > 99.9 || isRound || (!isRound && d > 9.99) ?
+ (int) d * 10 / 10 : d + ""
+ ) + "" + c[iteration])
+ : shortNumberFormat(d, iteration + 1));
+ }
+
+ public static String trimIgnoreColour(String str) {
+ return trimIgnoreColourStart(trimIgnoreColourEnd(str));
+ }
+
+ public static String trimIgnoreColourStart(String str) {
+ str = str.trim();
+ boolean colourCodeLast = false;
+ StringBuilder colours = new StringBuilder();
+ for (int i = 0; i < str.length(); i++) {
+ char c = str.charAt(i);
+ if (colourCodeLast) {
+ colours.append('\u00a7').append(c);
+ colourCodeLast = false;
+ continue;
+ }
+ if (c == '\u00A7') {
+ colourCodeLast = true;
+ } else if (c != ' ') {
+ return colours.append(str.substring(i)).toString();
+ }
+ }
+
+ return "";
+ }
+
+ public static String trimIgnoreColourEnd(String str) {
+ str = str.trim();
+ for (int i = str.length() - 1; i >= 0; i--) {
+ char c = str.charAt(i);
+ if (c == ' ') {
+ continue;
+ } else if (i > 0 && str.charAt(i - 1) == '\u00a7') {
+ i--;
+ continue;
+ }
+
+ return str.substring(0, i + 1);
+ }
+
+ return "";
+ }
+
+ public static List<String> getRawTooltip(ItemStack stack) {
+ List<String> list = Lists.newArrayList();
+ String s = stack.getDisplayName();
+
+ if (stack.hasDisplayName()) {
+ s = EnumChatFormatting.ITALIC + s;
+ }
+
+ s = s + EnumChatFormatting.RESET;
+
+ if (!stack.hasDisplayName() && stack.getItem() == Items.filled_map) {
+ s = s + " #" + stack.getItemDamage();
+ }
+
+ list.add(s);
+
+ if (stack.hasTagCompound()) {
+ if (stack.getTagCompound().hasKey("display", 10)) {
+ NBTTagCompound nbttagcompound = stack.getTagCompound().getCompoundTag("display");
+
+ if (nbttagcompound.hasKey("color", 3)) {
+ list.add(EnumChatFormatting.ITALIC + StatCollector.translateToLocal("item.dyed"));
+ }
+
+ if (nbttagcompound.getTagId("Lore") == 9) {
+ NBTTagList nbttaglist1 = nbttagcompound.getTagList("Lore", 8);
+
+ if (nbttaglist1.tagCount() > 0) {
+ for (int j1 = 0; j1 < nbttaglist1.tagCount(); ++j1) {
+ list.add(
+ EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + nbttaglist1.getStringTagAt(j1));
+ }
+ }
+ }
+ }
+ }
+
+ return list;
+ }
+
+ public static String floatToString(float f, int decimals) {
+ if (decimals <= 0) {
+ return String.valueOf(Math.round(f));
+ } else {
+ return String.format("%." + decimals + "f", f + 0.00001f);
+ }
+ }
+
+ public static void drawItemStackLinear(ItemStack stack, int x, int y) {
+ if (stack == null) return;
+
+ RenderItem itemRender = Minecraft.getMinecraft().getRenderItem();
+
+ RenderHelper.enableGUIStandardItemLighting();
+ itemRender.zLevel = -145; //Negates the z-offset of the below method.
+
+ IBakedModel ibakedmodel = itemRender.getItemModelMesher().getItemModel(stack);
+ GlStateManager.pushMatrix();
+ Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
+ Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture).setBlurMipmap(true, true);
+ GlStateManager.enableRescaleNormal();
+ GlStateManager.enableAlpha();
+ GlStateManager.alphaFunc(516, 0.1F);
+ GlStateManager.enableBlend();
+ GlStateManager.blendFunc(770, 771);
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ setupGuiTransform(x, y, ibakedmodel.isGui3d());
+ ibakedmodel = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(
+ ibakedmodel,
+ ItemCameraTransforms.TransformType.GUI
+ );
+ itemRender.renderItem(stack, ibakedmodel);
+ GlStateManager.disableAlpha();
+ GlStateManager.disableRescaleNormal();
+ GlStateManager.disableLighting();
+ GlStateManager.popMatrix();
+ Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
+ Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture).restoreLastBlurMipmap();
+
+ itemRender.renderItemOverlays(Minecraft.getMinecraft().fontRendererObj, stack, x, y);
+ itemRender.zLevel = 0;
+ RenderHelper.disableStandardItemLighting();
+ }
+
+ private static void setupGuiTransform(int xPosition, int yPosition, boolean isGui3d) {
+ GlStateManager.translate((float) xPosition, (float) yPosition, 5);
+ GlStateManager.translate(8.0F, 8.0F, 0.0F);
+ GlStateManager.scale(1.0F, 1.0F, -1.0F);
+ GlStateManager.scale(0.5F, 0.5F, 0.5F);
+
+ if (isGui3d) {
+ GlStateManager.scale(40.0F, 40.0F, 40.0F);
+ GlStateManager.rotate(210.0F, 1.0F, 0.0F, 0.0F);
+ GlStateManager.rotate(-135.0F, 0.0F, 1.0F, 0.0F);
+ GlStateManager.enableLighting();
+ } else {
+ GlStateManager.scale(64.0F, 64.0F, 64.0F);
+ GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F);
+ GlStateManager.disableLighting();
+ }
+ }
+
+ public static Method getMethod(Class<?> clazz, Class<?>[] params, String... methodNames) {
+ for (String methodName : methodNames) {
+ try {
+ return clazz.getDeclaredMethod(methodName, params);
+ } catch (Exception ignored) {
+ }
+ }
+ return null;
+ }
+
+ public static Object getField(Class<?> clazz, Object o, String... fieldNames) {
+ Field field = null;
+ for (String fieldName : fieldNames) {
+ try {
+ field = clazz.getDeclaredField(fieldName);
+ break;
+ } catch (Exception ignored) {
+ }
+ }
+ if (field != null) {
+ field.setAccessible(true);
+ try {
+ return field.get(o);
+ } catch (IllegalAccessException ignored) {
+ }
+ }
+ return null;
+ }
+
+ public static Slot getSlotUnderMouse(GuiContainer container) {
+ Slot slot = (Slot) getField(GuiContainer.class, container, "theSlot", "field_147006_u");
+ if (slot == null) {
+ slot = SlotLocking.getInstance().getRealSlot();
+ }
+ return slot;
+ }
+
+ public static void drawTexturedRect(float x, float y, float width, float height) {
+ drawTexturedRect(x, y, width, height, 0, 1, 0, 1);
+ }
+
+ public static void drawTexturedRect(float x, float y, float width, float height, int filter) {
+ drawTexturedRect(x, y, width, height, 0, 1, 0, 1, filter);
+ }
+
+ public static void drawTexturedRect(
+ float x,
+ float y,
+ float width,
+ float height,
+ float uMin,
+ float uMax,
+ float vMin,
+ float vMax
+ ) {
+ drawTexturedRect(x, y, width, height, uMin, uMax, vMin, vMax, GL11.GL_LINEAR);
+ }
+
+ public static String cleanColour(String in) {
+ return in.replaceAll("(?i)\\u00A7.", "");
+ }
+
+ public static String cleanColourNotModifiers(String in) {
+ return in.replaceAll("(?i)\\u00A7[0-9a-f]", "");
+ }
+
+ public static String fixBrokenAPIColour(String in) {
+ return in.replaceAll("(?i)\\u00C2(\\u00A7.)", "$1");
+ }
+
+ public static String prettyCase(String str) {
+ return str.substring(0, 1).toUpperCase() + str.substring(1).toLowerCase();
+ }
+
+ public static String[] rarityArr = new String[]{
+ "COMMON",
+ "UNCOMMON",
+ "RARE",
+ "EPIC",
+ "LEGENDARY",
+ "MYTHIC",
+ "SPECIAL",
+ "VERY SPECIAL",
+ "SUPREME",
+ "^^ THAT ONE IS DIVINE ^^"
+//, "DIVINE"
+ };
+
+ public static String[] rarityArrC = new String[]{
+ EnumChatFormatting.WHITE + EnumChatFormatting.BOLD.toString() + "COMMON",
+ EnumChatFormatting.GREEN + EnumChatFormatting.BOLD.toString() + "UNCOMMON",
+ EnumChatFormatting.BLUE + EnumChatFormatting.BOLD.toString() + "RARE",
+ EnumChatFormatting.DARK_PURPLE + EnumChatFormatting.BOLD.toString() + "EPIC",
+ EnumChatFormatting.GOLD + EnumChatFormatting.BOLD.toString() + "LEGENDARY",
+ EnumChatFormatting.LIGHT_PURPLE + EnumChatFormatting.BOLD.toString() + "MYTHIC",
+ EnumChatFormatting.RED + EnumChatFormatting.BOLD.toString() + "SPECIAL",
+ EnumChatFormatting.RED + EnumChatFormatting.BOLD.toString() + "VERY SPECIAL",
+ EnumChatFormatting.AQUA + EnumChatFormatting.BOLD.toString() + "DIVINE",
+ EnumChatFormatting.AQUA + EnumChatFormatting.BOLD.toString() + "DIVINE",
+ //EnumChatFormatting.AQUA+EnumChatFormatting.BOLD.toString()+"DIVINE",
+ };
+ public static final HashMap<String, String> rarityArrMap = new HashMap<String, String>() {{
+ put("COMMON", rarityArrC[0]);
+ put("UNCOMMON", rarityArrC[1]);
+ put("RARE", rarityArrC[2]);
+ put("EPIC", rarityArrC[3]);
+ put("LEGENDARY", rarityArrC[4]);
+ put("MYTHIC", rarityArrC[5]);
+ put("SPECIAL", rarityArrC[6]);
+ put("VERY SPECIAL", rarityArrC[7]);
+ put("DIVINE", rarityArrC[8]);
+ // put("DIVINE", rarityArrC[9]);
+ }};
+
+ public static String getRarityFromInt(int rarity) {
+ if (rarity < 0 || rarity >= rarityArr.length) {
+ return rarityArr[0];
+ }
+ return rarityArr[rarity];
+ }
+
+ public static int checkItemTypePet(List<String> lore) {
+ for (int i = lore.size() - 1; i >= 0; i--) {
+ String line = Utils.cleanColour(lore.get(i));
+ for (int i1 = 0; i1 < rarityArr.length; i1++) {
+ if (line.equals(rarityArr[i1])) {
+ return i1;
+ }
+ }
+ }
+ return -1;
+ }
+
+ public static int checkItemType(JsonArray lore, boolean contains, String... typeMatches) {
+ for (int i = lore.size() - 1; i >= 0; i--) {
+ String line = lore.get(i).getAsString();
+
+ int returnType = checkItemType(line, contains, typeMatches);
+ if (returnType != -1) {
+ return returnType;
+ }
+ }
+ return -1;
+ }
+
+ public static int checkItemType(String[] lore, boolean contains, String... typeMatches) {
+ for (int i = lore.length - 1; i >= 0; i--) {
+ String line = lore[i];
+
+ int returnType = checkItemType(line, contains, typeMatches);
+ if (returnType != -1) {
+ return returnType;
+ }
+ }
+ return -1;
+ }
+
+ public static int checkItemType(List<String> lore, boolean contains, String... typeMatches) {
+ for (int i = lore.size() - 1; i >= 0; i--) {
+ String line = lore.get(i);
+
+ int returnType = checkItemType(line, contains, typeMatches);
+ if (returnType != -1) {
+ return returnType;
+ }
+ }
+ return -1;
+ }
+
+ private static int checkItemType(String line, boolean contains, String... typeMatches) {
+ for (String rarity : rarityArr) {
+ for (int j = 0; j < typeMatches.length; j++) {
+ if (contains) {
+ if (line.trim().contains(rarity + " " + typeMatches[j])) {
+ return j;
+ } else if (line.trim().contains(rarity + " DUNGEON " + typeMatches[j])) {
+ return j;
+ }
+ } else {
+ if (line.trim().endsWith(rarity + " " + typeMatches[j])) {
+ return j;
+ } else if (line.trim().endsWith(rarity + " DUNGEON " + typeMatches[j])) {
+ return j;
+ }
+ }
+ }
+ }
+ return -1;
+ }
+
+ public static float round(float value, int precision) {
+ int scale = (int) Math.pow(10, precision);
+ return (float) Math.round(value * scale) / scale;
+ }
+
+ public static void playPressSound() {
+ playSound(new ResourceLocation("gui.button.press"), true);
+ }
+
+ public static void playSound(ResourceLocation sound, boolean gui) {
+ if (NotEnoughUpdates.INSTANCE.config.misc.guiButtonClicks || !gui) {
+ Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(sound, 1.0F));
+ }
+ }
+
+ public static String cleanDuplicateColourCodes(String line) {
+ StringBuilder sb = new StringBuilder();
+ char currentColourCode = 'r';
+ boolean sectionSymbolLast = false;
+ for (char c : line.toCharArray()) {
+ if ((int) c > 50000) continue;
+
+ if (c == '\u00a7') {
+ sectionSymbolLast = true;
+ } else {
+ if (sectionSymbolLast) {
+ if (currentColourCode != c) {
+ sb.append('\u00a7');
+ sb.append(c);
+ currentColourCode = c;
+ }
+ sectionSymbolLast = false;
+ } else {
+ sb.append(c);
+ }
+ }
+ }
+ return sb.toString();
+ }
+
+ public static void drawTexturedRect(
+ float x,
+ float y,
+ float width,
+ float height,
+ float uMin,
+ float uMax,
+ float vMin,
+ float vMax,
+ int filter
+ ) {
+ GlStateManager.enableTexture2D();
+ GlStateManager.enableBlend();
+ GlStateManager.tryBlendFuncSeparate(
+ GL11.GL_SRC_ALPHA,
+ GL11.GL_ONE_MINUS_SRC_ALPHA,
+ GL11.GL_ONE,
+ GL11.GL_ONE_MINUS_SRC_ALPHA
+ );
+ GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
+
+ GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, filter);
+ GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, filter);
+
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+ worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
+ worldrenderer
+ .pos(x, y + height, 0.0D)
+ .tex(uMin, vMax).endVertex();
+ worldrenderer
+ .pos(x + width, y + height, 0.0D)
+ .tex(uMax, vMax).endVertex();
+ worldrenderer
+ .pos(x + width, y, 0.0D)
+ .tex(uMax, vMin).endVertex();
+ worldrenderer
+ .pos(x, y, 0.0D)
+ .tex(uMin, vMin).endVertex();
+ tessellator.draw();
+
+ GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
+ GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
+
+ GlStateManager.disableBlend();
+ }
+
+ public static void drawTexturedRectNoBlend(
+ float x,
+ float y,
+ float width,
+ float height,
+ float uMin,
+ float uMax,
+ float vMin,
+ float vMax,
+ int filter
+ ) {
+ GlStateManager.enableTexture2D();
+
+ GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, filter);
+ GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, filter);
+
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+ worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
+ worldrenderer
+ .pos(x, y + height, 0.0D)
+ .tex(uMin, vMax).endVertex();
+ worldrenderer
+ .pos(x + width, y + height, 0.0D)
+ .tex(uMax, vMax).endVertex();
+ worldrenderer
+ .pos(x + width, y, 0.0D)
+ .tex(uMax, vMin).endVertex();
+ worldrenderer
+ .pos(x, y, 0.0D)
+ .tex(uMin, vMin).endVertex();
+ tessellator.draw();
+
+ GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
+ GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
+ }
+
+ public static ItemStack createItemStack(Item item, String displayname, String... lore) {
+ return createItemStack(item, displayname, 0, lore);
+ }
+
+ public static ItemStack createItemStack(Item item, String displayname, int damage, String... lore) {
+ ItemStack stack = new ItemStack(item, 1, damage);
+ NBTTagCompound tag = new NBTTagCompound();
+ NBTTagCompound display = new NBTTagCompound();
+ NBTTagList Lore = new NBTTagList();
+
+ for (String line : lore) {
+ Lore.appendTag(new NBTTagString(line));
+ }
+
+ display.setString("Name", displayname);
+ display.setTag("Lore", Lore);
+
+ tag.setTag("display", display);
+ tag.setInteger("HideFlags", 254);
+
+ stack.setTagCompound(tag);
+
+ return stack;
+ }
+
+ public static ItemStack editItemStackInfo(
+ ItemStack itemStack,
+ String displayName,
+ boolean disableNeuToolTips,
+ String... lore
+ ) {
+ NBTTagCompound tag = itemStack.getTagCompound();
+ NBTTagCompound display = tag.getCompoundTag("display");
+ NBTTagList Lore = new NBTTagList();
+
+ for (String line : lore) {
+ Lore.appendTag(new NBTTagString(line));
+ }
+
+ display.setString("Name", displayName);
+ display.setTag("Lore", Lore);
+
+ tag.setTag("display", display);
+ tag.setInteger("HideFlags", 254);
+ if (disableNeuToolTips) {
+ tag.setBoolean("disableNeuTooltip", true);
+ }
+
+ itemStack.setTagCompound(tag);
+
+ return itemStack;
+ }
+
+ public static ItemStack createSkull(String displayName, String uuid, String value) {
+ ItemStack render = new ItemStack(Items.skull, 1, 3);
+ NBTTagCompound tag = new NBTTagCompound();
+ NBTTagCompound skullOwner = new NBTTagCompound();
+ NBTTagCompound properties = new NBTTagCompound();
+ NBTTagList textures = new NBTTagList();
+ NBTTagCompound textures_0 = new NBTTagCompound();
+ NBTTagCompound display = new NBTTagCompound();
+
+ skullOwner.setString("Id", uuid);
+ skullOwner.setString("Name", uuid);
+
+ textures_0.setString("Value", value);
+ textures.appendTag(textures_0);
+
+ display.setString("Name", displayName);
+ tag.setTag("display", display);
+
+ properties.setTag("textures", textures);
+ skullOwner.setTag("Properties", properties);
+ tag.setTag("SkullOwner", skullOwner);
+ render.setTagCompound(tag);
+ return render;
+ }
+
+ public static void drawStringF(String str, FontRenderer fr, float x, float y, boolean shadow, int colour) {
+ fr.drawString(str, x, y, colour, shadow);
+ }
+
+ public static int getCharVertLen(char c) {
+ if ("acegmnopqrsuvwxyz".indexOf(c) >= 0) {
+ return 5;
+ } else {
+ return 7;
+ }
+ }
+
+ public static float getVerticalHeight(String str) {
+ str = cleanColour(str);
+ float height = 0;
+ for (int i = 0; i < str.length(); i++) {
+ char c = str.charAt(i);
+ int charHeight = getCharVertLen(c);
+ height += charHeight + 1.5f;
+ }
+ return height;
+ }
+
+ public static void drawStringVertical(String str, FontRenderer fr, float x, float y, boolean shadow, int colour) {
+ String format = FontRenderer.getFormatFromString(str);
+ str = cleanColour(str);
+ for (int i = 0; i < str.length(); i++) {
+ char c = str.charAt(i);
+
+ int charHeight = getCharVertLen(c);
+ int charWidth = fr.getCharWidth(c);
+ fr.drawString(format + c, x + (5 - charWidth) / 2f, y - 7 + charHeight, colour, shadow);
+
+ y += charHeight + 1.5f;
+ }
+ }
+
+ public static void renderShadowedString(String str, float x, float y, int maxLength) {
+ int strLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(str);
+ float factor;
+ if (maxLength < 0) {
+ factor = 1;
+ } else {
+ factor = maxLength / (float) strLen;
+ factor = Math.min(1, factor);
+ }
+
+ for (int xOff = -2; xOff <= 2; xOff++) {
+ for (int yOff = -2; yOff <= 2; yOff++) {
+ if (Math.abs(xOff) != Math.abs(yOff)) {
+ Utils.drawStringCenteredScaledMaxWidth(
+ Utils.cleanColourNotModifiers(str),
+ Minecraft.getMinecraft().fontRendererObj,
+ x + xOff / 2f * factor,
+ y + 4 + yOff / 2f * factor,
+ false,
+ maxLength,
+ new Color(0, 0, 0, 200 / Math.max(Math.abs(xOff), Math.abs(yOff))).getRGB()
+ );
+ }
+ }
+ }
+
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawStringCenteredScaledMaxWidth(str, Minecraft.getMinecraft().fontRendererObj,
+ x, y + 4, false, maxLength, 4210752
+ );
+ }
+
+ public static void renderAlignedString(String first, String second, float x, float y, int length) {
+ FontRenderer fontRendererObj = Minecraft.getMinecraft().fontRendererObj;
+ if (fontRendererObj.getStringWidth(first + " " + second) >= length) {
+ renderShadowedString(first + " " + second, x + length / 2f, y, length);
+ } 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);
+ }
+ }
+
+ public static void drawStringScaledMaxWidth(
+ String str,
+ FontRenderer fr,
+ float x,
+ float y,
+ boolean shadow,
+ int len,
+ int colour
+ ) {
+ int strLen = fr.getStringWidth(str);
+ float factor = len / (float) strLen;
+ factor = Math.min(1, factor);
+
+ drawStringScaled(str, fr, x, y, shadow, colour, factor);
+ }
+
+ public static void drawStringCentered(String str, FontRenderer fr, float x, float y, boolean shadow, int colour) {
+ int strLen = fr.getStringWidth(str);
+
+ float x2 = x - strLen / 2f;
+ float y2 = y - fr.FONT_HEIGHT / 2f;
+
+ GL11.glTranslatef(x2, y2, 0);
+ fr.drawString(str, 0, 0, colour, shadow);
+ GL11.glTranslatef(-x2, -y2, 0);
+ }
+
+ public static void drawStringScaled(
+ String str,
+ FontRenderer fr,
+ float x,
+ float y,
+ boolean shadow,
+ int colour,
+ float factor
+ ) {
+ GlStateManager.scale(factor, factor, 1);
+ fr.drawString(str, x / factor, y / factor, colour, shadow);
+ GlStateManager.scale(1 / factor, 1 / factor, 1);
+ }
+
+ public static void drawStringRightAligned(
+ String str,
+ FontRenderer fr,
+ float x,
+ float y,
+ boolean shadow,
+ int colour,
+ float factor
+ ) {
+ drawStringScaled(str, fr, x - fr.getStringWidth(str) * factor, y, shadow, colour, factor);
+ }
+
+ public static void drawStringScaledMax(
+ String str,
+ FontRenderer fr,
+ float x,
+ float y,
+ boolean shadow,
+ int colour,
+ float factor,
+ int len
+ ) {
+ int strLen = fr.getStringWidth(str);
+ float f = len / (float) strLen;
+ factor = Math.min(factor, f);
+
+ GlStateManager.scale(factor, factor, 1);
+ fr.drawString(str, x / factor, y / factor, colour, shadow);
+ GlStateManager.scale(1 / factor, 1 / factor, 1);
+ }
+
+ public static void drawStringCenteredScaledMaxWidth(
+ String str,
+ FontRenderer fr,
+ float x,
+ float y,
+ boolean shadow,
+ int len,
+ int colour
+ ) {
+ int strLen = fr.getStringWidth(str);
+ float factor = len / (float) strLen;
+ factor = Math.min(1, factor);
+ int newLen = Math.min(strLen, len);
+
+ float fontHeight = 8 * factor;
+
+ drawStringScaled(str, fr, x - newLen / 2, y - fontHeight / 2, shadow, colour, factor);
+ }
+
+ public static Matrix4f createProjectionMatrix(int width, int height) {
+ Matrix4f projMatrix = new Matrix4f();
+ projMatrix.setIdentity();
+ projMatrix.m00 = 2.0F / (float) width;
+ projMatrix.m11 = 2.0F / (float) (-height);
+ projMatrix.m22 = -0.0020001999F;
+ projMatrix.m33 = 1.0F;
+ projMatrix.m03 = -1.0F;
+ projMatrix.m13 = 1.0F;
+ projMatrix.m23 = -1.0001999F;
+ return projMatrix;
+ }
+
+ public static void drawStringCenteredScaled(
+ String str,
+ FontRenderer fr,
+ float x,
+ float y,
+ boolean shadow,
+ int len,
+ int colour
+ ) {
+ int strLen = fr.getStringWidth(str);
+ float factor = len / (float) strLen;
+ float fontHeight = 8 * factor;
+
+ drawStringScaled(str, fr, x - len / 2, y - fontHeight / 2, shadow, colour, factor);
+ }
+
+ public static void drawStringCenteredYScaled(
+ String str,
+ FontRenderer fr,
+ float x,
+ float y,
+ boolean shadow,
+ int len,
+ int colour
+ ) {
+ int strLen = fr.getStringWidth(str);
+ float factor = len / (float) strLen;
+ float fontHeight = 8 * factor;
+
+ drawStringScaled(str, fr, x, y - fontHeight / 2, shadow, colour, factor);
+ }
+
+ public static void drawStringCenteredYScaledMaxWidth(
+ String str,
+ FontRenderer fr,
+ float x,
+ float y,
+ boolean shadow,
+ int len,
+ int colour
+ ) {
+ int strLen = fr.getStringWidth(str);
+ float factor = len / (float) strLen;
+ factor = Math.min(1, factor);
+ float fontHeight = 8 * factor;
+
+ drawStringScaled(str, fr, x, y - fontHeight / 2, shadow, colour, factor);
+ }
+
+ public static int renderStringTrimWidth(
+ String str,
+ FontRenderer fr,
+ boolean shadow,
+ int x,
+ int y,
+ int len,
+ int colour,
+ int maxLines
+ ) {
+ return renderStringTrimWidth(str, fr, shadow, x, y, len, colour, maxLines, 1);
+ }
+
+ public static int renderStringTrimWidth(
+ String str,
+ FontRenderer fr,
+ boolean shadow,
+ int x,
+ int y,
+ int len,
+ int colour,
+ int maxLines,
+ float scale
+ ) {
+ len = (int) (len / scale);
+
+ int yOff = 0;
+ String excess;
+ String trimmed = trimToWidth(str, len);
+
+ String colourCodes = "";
+ Pattern pattern = Pattern.compile("\\u00A7.");
+ Matcher matcher = pattern.matcher(trimmed);
+ while (matcher.find()) {
+ colourCodes += matcher.group();
+ }
+
+ boolean firstLine = true;
+ int trimmedCharacters = trimmed.length();
+ int lines = 0;
+ while ((lines++ < maxLines) || maxLines < 0) {
+ if (trimmed.length() == str.length()) {
+ drawStringScaled(trimmed, fr, x, y + yOff, shadow, colour, scale);
+ //fr.drawString(trimmed, x, y + yOff, colour, shadow);
+ break;
+ } else if (trimmed.isEmpty()) {
+ yOff -= 12 * scale;
+ break;
+ } else {
+ if (firstLine) {
+ drawStringScaled(trimmed, fr, x, y + yOff, shadow, colour, scale);
+ firstLine = false;
+ } else {
+ if (trimmed.startsWith(" ")) {
+ trimmed = trimmed.substring(1);
+ }
+ drawStringScaled(colourCodes + trimmed, fr, x, y + yOff, shadow, colour, scale);
+ }
+
+ excess = str.substring(trimmedCharacters);
+ trimmed = trimToWidth(excess, len);
+ trimmedCharacters += trimmed.length();
+ yOff += 12 * scale;
+ }
+ }
+ return yOff;
+ }
+
+ public static String trimToWidth(String str, int len) {
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+ String trim = fr.trimStringToWidth(str, len);
+
+ if (str.length() != trim.length() && !trim.endsWith(" ")) {
+ char next = str.charAt(trim.length());
+ if (next != ' ') {
+ String[] split = trim.split(" ");
+ String last = split[split.length - 1];
+ if (last.length() < 8) {
+ trim = trim.substring(0, trim.length() - last.length());
+ }
+ }
+ }
+
+ return trim;
+ }
+
+ public static void drawGradientRect(int left, int top, int right, int bottom, int startColor, int endColor) {
+ float f = (float) (startColor >> 24 & 255) / 255.0F;
+ float f1 = (float) (startColor >> 16 & 255) / 255.0F;
+ float f2 = (float) (startColor >> 8 & 255) / 255.0F;
+ float f3 = (float) (startColor & 255) / 255.0F;
+ float f4 = (float) (endColor >> 24 & 255) / 255.0F;
+ float f5 = (float) (endColor >> 16 & 255) / 255.0F;
+ float f6 = (float) (endColor >> 8 & 255) / 255.0F;
+ float f7 = (float) (endColor & 255) / 255.0F;
+ GlStateManager.disableTexture2D();
+ GlStateManager.enableBlend();
+ GlStateManager.disableAlpha();
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+ GlStateManager.shadeModel(7425);
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+ worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
+ worldrenderer.pos(right, top, 0).color(f1, f2, f3, f).endVertex();
+ worldrenderer.pos(left, top, 0).color(f1, f2, f3, f).endVertex();
+ worldrenderer.pos(left, bottom, 0).color(f5, f6, f7, f4).endVertex();
+ worldrenderer.pos(right, bottom, 0).color(f5, f6, f7, f4).endVertex();
+ tessellator.draw();
+ GlStateManager.shadeModel(7424);
+ GlStateManager.disableBlend();
+ GlStateManager.enableAlpha();
+ GlStateManager.enableTexture2D();
+ }
+
+ public static void drawGradientRectHorz(int left, int top, int right, int bottom, int startColor, int endColor) {
+ float f = (float) (startColor >> 24 & 255) / 255.0F;
+ float f1 = (float) (startColor >> 16 & 255) / 255.0F;
+ float f2 = (float) (startColor >> 8 & 255) / 255.0F;
+ float f3 = (float) (startColor & 255) / 255.0F;
+ float f4 = (float) (endColor >> 24 & 255) / 255.0F;
+ float f5 = (float) (endColor >> 16 & 255) / 255.0F;
+ float f6 = (float) (endColor >> 8 & 255) / 255.0F;
+ float f7 = (float) (endColor & 255) / 255.0F;
+ GlStateManager.disableTexture2D();
+ GlStateManager.enableBlend();
+ GlStateManager.disableAlpha();
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+ GlStateManager.shadeModel(7425);
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+ worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
+ worldrenderer.pos(right, top, 0).color(f5, f6, f7, f4).endVertex();
+ worldrenderer.pos(left, top, 0).color(f1, f2, f3, f).endVertex();
+ worldrenderer.pos(left, bottom, 0).color(f1, f2, f3, f).endVertex();
+ worldrenderer.pos(right, bottom, 0).color(f5, f6, f7, f4).endVertex();
+ tessellator.draw();
+ GlStateManager.shadeModel(7424);
+ GlStateManager.disableBlend();
+ GlStateManager.enableAlpha();
+ GlStateManager.enableTexture2D();
+ }
+
+ public static void drawHoveringText(
+ List<String> textLines,
+ final int mouseX,
+ final int mouseY,
+ final int screenWidth,
+ final int screenHeight,
+ final int maxTextWidth,
+ FontRenderer font
+ ) {
+ drawHoveringText(textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth, font, true);
+ }
+
+ public static JsonObject getConstant(String constant, Gson gson) {
+ return getConstant(constant, gson, JsonObject.class);
+ }
+
+ public static <T> T getConstant(String constant, Gson gson, Class<T> clazz) {
+ File repo = NotEnoughUpdates.INSTANCE.manager.repoLocation;
+ if (repo.exists()) {
+ File jsonFile = new File(repo, "constants/" + constant + ".json");
+ try (
+ BufferedReader reader = new BufferedReader(new InputStreamReader(
+ new FileInputStream(jsonFile),
+ StandardCharsets.UTF_8
+ ))
+ ) {
+ T obj = gson.fromJson(reader, clazz);
+ return obj;
+ } catch (Exception e) {
+ return null;
+ }
+ }
+ return null;
+ }
+
+ public static float getElementAsFloat(JsonElement element, float def) {
+ if (element == null) return def;
+ if (!element.isJsonPrimitive()) return def;
+ JsonPrimitive prim = element.getAsJsonPrimitive();
+ if (!prim.isNumber()) return def;
+ return prim.getAsFloat();
+ }
+
+ public static int getElementAsInt(JsonElement element, int def) {
+ if (element == null) return def;
+ if (!element.isJsonPrimitive()) return def;
+ JsonPrimitive prim = element.getAsJsonPrimitive();
+ if (!prim.isNumber()) return def;
+ return prim.getAsInt();
+ }
+
+ public static String getElementAsString(JsonElement element, String def) {
+ if (element == null) return def;
+ if (!element.isJsonPrimitive()) return def;
+ JsonPrimitive prim = element.getAsJsonPrimitive();
+ if (!prim.isString()) return def;
+ return prim.getAsString();
+ }
+
+ public static Splitter PATH_SPLITTER = Splitter.on(".").omitEmptyStrings().limit(2);
+
+ public static JsonElement getElement(JsonElement element, String path) {
+ List<String> path_split = PATH_SPLITTER.splitToList(path);
+ if (element instanceof JsonObject) {
+ JsonElement e = element.getAsJsonObject().get(path_split.get(0));
+ if (path_split.size() > 1) {
+ return getElement(e, path_split.get(1));
+ } else {
+ return e;
+ }
+ } else {
+ return element;
+ }
+ }
+
+ public static ChatStyle createClickStyle(ClickEvent.Action action, String value) {
+ ChatStyle style = new ChatStyle();
+ style.setChatClickEvent(new ClickEvent(action, value));
+ style.setChatHoverEvent(new HoverEvent(
+ HoverEvent.Action.SHOW_TEXT,
+ new ChatComponentText(EnumChatFormatting.YELLOW + value)
+ ));
+ return style;
+ }
+
+ public static ChatStyle createClickStyle(ClickEvent.Action action, String value, String message) {
+ ChatStyle style = createClickStyle(action, value);
+ style.setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(message)));
+ return style;
+ }
+
+ public static void recursiveDelete(File file) {
+ if (file.isDirectory() && !Files.isSymbolicLink(file.toPath())) {
+ for (File child : file.listFiles()) {
+ recursiveDelete(child);
+ }
+ }
+ file.delete();
+ }
+
+ public static char getPrimaryColourCode(String displayname) {
+ int lastColourCode = -99;
+ int currentColour = 0;
+ int[] mostCommon = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ for (int i = 0; i < displayname.length(); i++) {
+ char c = displayname.charAt(i);
+ if (c == '\u00A7') {
+ lastColourCode = i;
+ } else if (lastColourCode == i - 1) {
+ int colIndex = "0123456789abcdef".indexOf(c);
+ if (colIndex >= 0) {
+ currentColour = colIndex;
+ } else {
+ currentColour = 0;
+ }
+ } else if ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".indexOf(c) >= 0) {
+ if (currentColour > 0) {
+ mostCommon[currentColour]++;
+ }
+ }
+ }
+ int mostCommonCount = 0;
+ for (int index = 0; index < mostCommon.length; index++) {
+ if (mostCommon[index] > mostCommonCount) {
+ mostCommonCount = mostCommon[index];
+ currentColour = index;
+ }
+ }
+
+ return "0123456789abcdef".charAt(currentColour);
+ }
+
+ public static Color getPrimaryColour(String displayname) {
+ int colourInt = Minecraft.getMinecraft().fontRendererObj.getColorCode(getPrimaryColourCode(displayname));
+ return new Color(colourInt).darker();
+ }
+
+ public static void scrollTooltip(int dY) {
+ scrollY.setTarget(scrollY.getTarget() + dY / 10f);
+ scrollY.resetTimer();
+ }
+
+ private static final LerpingFloat scrollY = new LerpingFloat(0, 100);
+
+ public static void drawHoveringText(
+ List<String> textLines,
+ final int mouseX,
+ final int mouseY,
+ final int screenWidth,
+ final int screenHeight,
+ final int maxTextWidth,
+ FontRenderer font,
+ boolean coloured
+ ) {
+ if (!textLines.isEmpty()) {
+ GlStateManager.disableRescaleNormal();
+ RenderHelper.disableStandardItemLighting();
+ GlStateManager.disableLighting();
+ GlStateManager.enableDepth();
+ int tooltipTextWidth = 0;
+
+ for (String textLine : textLines) {
+ int textLineWidth = font.getStringWidth(textLine);
+
+ if (textLineWidth > tooltipTextWidth) {
+ tooltipTextWidth = textLineWidth;
+ }
+ }
+
+ boolean needsWrap = false;
+
+ int titleLinesCount = 1;
+ int tooltipX = mouseX + 12;
+ if (tooltipX + tooltipTextWidth + 4 > screenWidth) {
+ tooltipX = mouseX - 16 - tooltipTextWidth;
+ if (tooltipX < 4) // if the tooltip doesn't fit on the screen
+ {
+ if (mouseX > screenWidth / 2) {
+ tooltipTextWidth = mouseX - 12 - 8;
+ } else {
+ tooltipTextWidth = screenWidth - 16 - mouseX;
+ }
+ needsWrap = true;
+ }
+ }
+
+ if (maxTextWidth > 0 && tooltipTextWidth > maxTextWidth) {
+ tooltipTextWidth = maxTextWidth;
+ needsWrap = true;
+ }
+
+ if (needsWrap) {
+ int wrappedTooltipWidth = 0;
+ List<String> wrappedTextLines = new ArrayList<>();
+ for (int i = 0; i < textLines.size(); i++) {
+ String textLine = textLines.get(i);
+ List<String> wrappedLine = font.listFormattedStringToWidth(textLine, tooltipTextWidth);
+ if (i == 0) {
+ titleLinesCount = wrappedLine.size();
+ }
+
+ for (String line : wrappedLine) {
+ int lineWidth = font.getStringWidth(line);
+ if (lineWidth > wrappedTooltipWidth) {
+ wrappedTooltipWidth = lineWidth;
+ }
+ wrappedTextLines.add(line);
+ }
+ }
+ tooltipTextWidth = wrappedTooltipWidth;
+ textLines = wrappedTextLines;
+
+ if (mouseX > screenWidth / 2) {
+ tooltipX = mouseX - 16 - tooltipTextWidth;
+ } else {
+ tooltipX = mouseX + 12;
+ }
+ }
+
+ int tooltipY = mouseY - 12;
+ int tooltipHeight = 8;
+
+ if (textLines.size() > 1) {
+ tooltipHeight += (textLines.size() - 1) * 10;
+ if (textLines.size() > titleLinesCount) {
+ tooltipHeight += 2; // gap between title lines and next lines
+ }
+ }
+
+ //Scrollable tooltips
+ if (tooltipHeight + 6 > screenHeight) {
+ if (scrollY.getTarget() < 0) {
+ scrollY.setTarget(0);
+ scrollY.resetTimer();
+ } else if (screenHeight - tooltipHeight - 12 + (int) scrollY.getTarget() > 0) {
+ scrollY.setTarget(-screenHeight + tooltipHeight + 12);
+ scrollY.resetTimer();
+ }
+ } else {
+ scrollY.setValue(0);
+ scrollY.resetTimer();
+ }
+ scrollY.tick();
+
+ if (tooltipY + tooltipHeight + 6 > screenHeight) {
+ tooltipY = screenHeight - tooltipHeight - 6 + (int) scrollY.getValue();
+ }
+
+ final int zLevel = 300;
+ final int backgroundColor = 0xF0100010;
+ drawGradientRect(
+ zLevel,
+ tooltipX - 3,
+ tooltipY - 4,
+ tooltipX + tooltipTextWidth + 3,
+ tooltipY - 3,
+ backgroundColor,
+ backgroundColor
+ );
+ drawGradientRect(
+ zLevel,
+ tooltipX - 3,
+ tooltipY + tooltipHeight + 3,
+ tooltipX + tooltipTextWidth + 3,
+ tooltipY + tooltipHeight + 4,
+ backgroundColor,
+ backgroundColor
+ );
+ drawGradientRect(
+ zLevel,
+ tooltipX - 3,
+ tooltipY - 3,
+ tooltipX + tooltipTextWidth + 3,
+ tooltipY + tooltipHeight + 3,
+ backgroundColor,
+ backgroundColor
+ );
+ drawGradientRect(
+ zLevel,
+ tooltipX - 4,
+ tooltipY - 3,
+ tooltipX - 3,
+ tooltipY + tooltipHeight + 3,
+ backgroundColor,
+ backgroundColor
+ );
+ drawGradientRect(
+ zLevel,
+ tooltipX + tooltipTextWidth + 3,
+ tooltipY - 3,
+ tooltipX + tooltipTextWidth + 4,
+ tooltipY + tooltipHeight + 3,
+ backgroundColor,
+ backgroundColor
+ );
+ //TODO: Coloured Borders
+ int borderColorStart = 0x505000FF;
+ if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.tooltipBorderColours && coloured) {
+ if (textLines.size() > 0) {
+ String first = textLines.get(0);
+ borderColorStart = getPrimaryColour(first).getRGB() & 0x00FFFFFF |
+ ((NotEnoughUpdates.INSTANCE.config.tooltipTweaks.tooltipBorderOpacity) << 24);
+ }
+ }
+ final int borderColorEnd = (borderColorStart & 0xFEFEFE) >> 1 | borderColorStart & 0xFF000000;
+ drawGradientRect(
+ zLevel,
+ tooltipX - 3,
+ tooltipY - 3 + 1,
+ tooltipX - 3 + 1,
+ tooltipY + tooltipHeight + 3 - 1,
+ borderColorStart,
+ borderColorEnd
+ );
+ drawGradientRect(
+ zLevel,
+ tooltipX + tooltipTextWidth + 2,
+ tooltipY - 3 + 1,
+ tooltipX + tooltipTextWidth + 3,
+ tooltipY + tooltipHeight + 3 - 1,
+ borderColorStart,
+ borderColorEnd
+ );
+ drawGradientRect(
+ zLevel,
+ tooltipX - 3,
+ tooltipY - 3,
+ tooltipX + tooltipTextWidth + 3,
+ tooltipY - 3 + 1,
+ borderColorStart,
+ borderColorStart
+ );
+ drawGradientRect(
+ zLevel,
+ tooltipX - 3,
+ tooltipY + tooltipHeight + 2,
+ tooltipX + tooltipTextWidth + 3,
+ tooltipY + tooltipHeight + 3,
+ borderColorEnd,
+ borderColorEnd
+ );
+
+ GlStateManager.disableDepth();
+ for (int lineNumber = 0; lineNumber < textLines.size(); ++lineNumber) {
+ String line = textLines.get(lineNumber);
+ font.drawStringWithShadow(line, (float) tooltipX, (float) tooltipY, -1);
+
+ if (lineNumber + 1 == titleLinesCount) {
+ tooltipY += 2;
+ }
+
+ tooltipY += 10;
+ }
+
+ GlStateManager.enableLighting();
+ GlStateManager.enableDepth();
+ RenderHelper.enableStandardItemLighting();
+ GlStateManager.enableRescaleNormal();
+ }
+ GlStateManager.disableLighting();
+ }
+
+ public static void drawGradientRect(
+ int zLevel,
+ int left,
+ int top,
+ int right,
+ int bottom,
+ int startColor,
+ int endColor
+ ) {
+ float startAlpha = (float) (startColor >> 24 & 255) / 255.0F;
+ float startRed = (float) (startColor >> 16 & 255) / 255.0F;
+ float startGreen = (float) (startColor >> 8 & 255) / 255.0F;
+ float startBlue = (float) (startColor & 255) / 255.0F;
+ float endAlpha = (float) (endColor >> 24 & 255) / 255.0F;
+ float endRed = (float) (endColor >> 16 & 255) / 255.0F;
+ float endGreen = (float) (endColor >> 8 & 255) / 255.0F;
+ float endBlue = (float) (endColor & 255) / 255.0F;
+
+ GlStateManager.disableTexture2D();
+ GlStateManager.enableBlend();
+ GlStateManager.disableAlpha();
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+ GlStateManager.shadeModel(7425);
+
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+ worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
+ worldrenderer.pos(right, top, zLevel).color(startRed, startGreen, startBlue, startAlpha).endVertex();
+ worldrenderer.pos(left, top, zLevel).color(startRed, startGreen, startBlue, startAlpha).endVertex();
+ worldrenderer.pos(left, bottom, zLevel).color(endRed, endGreen, endBlue, endAlpha).endVertex();
+ worldrenderer.pos(right, bottom, zLevel).color(endRed, endGreen, endBlue, endAlpha).endVertex();
+ tessellator.draw();
+
+ GlStateManager.shadeModel(7424);
+ GlStateManager.disableBlend();
+ GlStateManager.enableAlpha();
+ GlStateManager.enableTexture2D();
+ }
+
+ public static void drawRectNoBlend(int left, int top, int right, int bottom, int color) {
+ if (left < right) {
+ int i = left;
+ left = right;
+ right = i;
+ }
+
+ if (top < bottom) {
+ int j = top;
+ top = bottom;
+ bottom = j;
+ }
+
+ float f3 = (float) (color >> 24 & 255) / 255.0F;
+ float f = (float) (color >> 16 & 255) / 255.0F;
+ float f1 = (float) (color >> 8 & 255) / 255.0F;
+ float f2 = (float) (color & 255) / 255.0F;
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+ GlStateManager.disableTexture2D();
+ GlStateManager.color(f, f1, f2, f3);
+ worldrenderer.begin(7, DefaultVertexFormats.POSITION);
+ worldrenderer.pos(left, bottom, 0.0D).endVertex();
+ worldrenderer.pos(right, bottom, 0.0D).endVertex();
+ worldrenderer.pos(right, top, 0.0D).endVertex();
+ worldrenderer.pos(left, top, 0.0D).endVertex();
+ tessellator.draw();
+ GlStateManager.enableTexture2D();
+ }
+
+ public static String prettyTime(long millis) {
+ long seconds = millis / 1000 % 60;
+ long minutes = (millis / 1000 / 60) % 60;
+ long hours = (millis / 1000 / 60 / 60) % 24;
+ long days = (millis / 1000 / 60 / 60 / 24);
+
+ String endsIn = "";
+ if (millis < 0) {
+ endsIn += "Ended!";
+ } else if (minutes == 0 && hours == 0 && days == 0) {
+ endsIn += seconds + "s";
+ } else if (hours == 0 && days == 0) {
+ endsIn += minutes + "m" + seconds + "s";
+ } else if (days == 0) {
+ if (hours <= 6) {
+ endsIn += hours + "h" + minutes + "m" + seconds + "s";
+ } else {
+ endsIn += hours + "h";
+ }
+ } else {
+ endsIn += days + "d" + hours + "h";
+ }
+
+ return endsIn;
+ }
+
+ public static void drawLine(float sx, float sy, float ex, float ey, int width, int color) {
+ float f = (float) (color >> 24 & 255) / 255.0F;
+ float f1 = (float) (color >> 16 & 255) / 255.0F;
+ float f2 = (float) (color >> 8 & 255) / 255.0F;
+ float f3 = (float) (color & 255) / 255.0F;
+ GlStateManager.pushMatrix();
+ GlStateManager.disableTexture2D();
+ GlStateManager.enableBlend();
+ GlStateManager.disableAlpha();
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+ GlStateManager.color(f1, f2, f3, f);
+ GL11.glLineWidth(width);
+ GL11.glBegin(GL11.GL_LINES);
+ GL11.glVertex2d(sx, sy);
+ GL11.glVertex2d(ex, ey);
+ GL11.glEnd();
+ GlStateManager.disableBlend();
+ GlStateManager.enableAlpha();
+ GlStateManager.enableTexture2D();
+ GlStateManager.popMatrix();
+ }
+
+ public static void drawDottedLine(float sx, float sy, float ex, float ey, int width, int factor, int color) {
+ GlStateManager.pushMatrix();
+ GL11.glLineStipple(factor, (short) 0xAAAA);
+ GL11.glEnable(GL11.GL_LINE_STIPPLE);
+ drawLine(sx, sy, ex, ey, width, color);
+ GL11.glDisable(GL11.GL_LINE_STIPPLE);
+ GlStateManager.popMatrix();
+ }
+
+ public static void drawTexturedQuad(
+ float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4,
+ float uMin, float uMax, float vMin, float vMax, int filter
+ ) {
+ GlStateManager.enableTexture2D();
+ GlStateManager.enableBlend();
+ GlStateManager.tryBlendFuncSeparate(
+ GL11.GL_SRC_ALPHA,
+ GL11.GL_ONE_MINUS_SRC_ALPHA,
+ GL11.GL_ONE,
+ GL11.GL_ONE_MINUS_SRC_ALPHA
+ );
+ GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
+
+ GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, filter);
+ GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, filter);
+
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+ worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
+ worldrenderer
+ .pos(x1, y1, 0.0D)
+ .tex(uMin, vMax).endVertex();
+ worldrenderer
+ .pos(x2, y2, 0.0D)
+ .tex(uMax, vMax).endVertex();
+ worldrenderer
+ .pos(x3, y3, 0.0D)
+ .tex(uMax, vMin).endVertex();
+ worldrenderer
+ .pos(x4, y4, 0.0D)
+ .tex(uMin, vMin).endVertex();
+ tessellator.draw();
+
+ GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
+ GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
+
+ GlStateManager.disableBlend();
+ }
+
+ public static boolean sendCloseScreenPacket() {
+ EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer;
+ if (thePlayer.openContainer == null) return false;
+ thePlayer.sendQueue.addToSendQueue(new C0DPacketCloseWindow(
+ thePlayer.openContainer.windowId));
+ return true;
+ }
+
+ public static String formatNumberWithDots(long number) {
+ if (number == 0)
+ return "0";
+ String work = "";
+ boolean isNegative = false;
+ if (number < 0) {
+ isNegative = true;
+ number = -number;
+ }
+ while (number != 0) {
+ work = String.format("%03d.%s", number % 1000, work);
+ number /= 1000;
+ }
+ work = work.substring(0, work.length() - 1);
+ while (work.startsWith("0"))
+ work = work.substring(1);
+ if (isNegative)
+ return "-" + work;
+ return work;
+ }
+
+ public static int getMouseY() {
+ int height = peekGuiScale().getScaledHeight();
+ return height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
+ }
+
+ public static int getMouseX() {
+ return Mouse.getX() * peekGuiScale().getScaledWidth() / Minecraft.getMinecraft().displayWidth;
+ }
+
+ public static boolean isWithinRect(int x, int y, int left, int top, int width, int height) {
+ return left <= x && x <= left + width &&
+ top <= y && y <= top + height;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/XPInformation.java b/src/main/java/io/github/moulberry/notenoughupdates/util/XPInformation.java
index 68815fb8..aef2490e 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/XPInformation.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/XPInformation.java
@@ -2,6 +2,7 @@ package io.github.moulberry.notenoughupdates.util;
import com.google.common.base.Splitter;
import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.core.util.StringUtils;
import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer;
@@ -13,201 +14,243 @@ import java.util.HashMap;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import java.util.stream.StreamSupport;
public class XPInformation {
-
- private static XPInformation INSTANCE = new XPInformation();
-
- public static XPInformation getInstance() {
- return INSTANCE;
- }
-
- public static class SkillInfo {
- public int level;
- public float totalXp;
- public float currentXp;
- public float currentXpMax;
- public boolean fromApi = false;
- }
-
- private HashMap<String, SkillInfo> skillInfoMap = new HashMap<>();
- public HashMap<String, Float> updateWithPercentage = new HashMap<>();
-
- public int correctionCounter = 0;
-
- private static Splitter SPACE_SPLITTER = Splitter.on(" ").omitEmptyStrings().trimResults();
- private static Pattern SKILL_PATTERN = Pattern.compile("\\+(\\d+(?:,\\d+)*(?:\\.\\d+)?) (.+) \\((\\d+(?:,\\d+)*(?:\\.\\d+)?)/(\\d+(?:,\\d+)*(?:\\.\\d+)?)\\)");
- private static Pattern SKILL_PATTERN_MULTIPLIER = Pattern.compile("\\+(\\d+(?:,\\d+)*(?:\\.\\d+)?) (.+) \\((\\d+(?:,\\d+)*(?:\\.\\d+)?)/(\\d+(?:k|m|b))\\)");
- private static Pattern SKILL_PATTERN_PERCENTAGE = Pattern.compile("\\+(\\d+(?:,\\d+)*(?:\\.\\d+)?) (.+) \\((\\d\\d?(?:\\.\\d\\d?)?)%\\)");
-
- public HashMap<String, SkillInfo> getSkillInfoMap() {
- return skillInfoMap;
- }
-
- public SkillInfo getSkillInfo(String skillName) {
- return skillInfoMap.get(skillName.toLowerCase());
- }
-
- private String lastActionBar = null;
-
- @SubscribeEvent(priority = EventPriority.HIGHEST, receiveCanceled = true)
- public void onChatReceived(ClientChatReceivedEvent event) {
- if(event.type == 2) {
- JsonObject leveling = Constants.LEVELING;
- if(leveling == null) return;
-
- String actionBar = StringUtils.cleanColour(event.message.getUnformattedText());
-
- if(lastActionBar != null && lastActionBar.equalsIgnoreCase(actionBar)) {
- return;
- }
- lastActionBar = actionBar;
-
- List<String> components = SPACE_SPLITTER.splitToList(actionBar);
-
- for(String component : components) {
- Matcher matcher = SKILL_PATTERN.matcher(component);
- if(matcher.matches()) {
- String skillS = matcher.group(2);
- String currentXpS = matcher.group(3).replace(",","");
- String maxXpS = matcher.group(4).replace(",","");
-
- float currentXp = Float.parseFloat(currentXpS);
- float maxXp = Float.parseFloat(maxXpS);
-
- SkillInfo skillInfo = new SkillInfo();
- skillInfo.currentXp = currentXp;
- skillInfo.currentXpMax = maxXp;
- skillInfo.totalXp = currentXp;
-
- JsonArray levelingArray = leveling.getAsJsonArray("leveling_xp");
- for(int i=0; i<levelingArray.size(); i++) {
- float cap = levelingArray.get(i).getAsFloat();
- if(maxXp > 0 && maxXp <= cap) {
- break;
- }
-
- skillInfo.totalXp += cap;
- skillInfo.level++;
- }
-
- skillInfoMap.put(skillS.toLowerCase(), skillInfo);
- return;
- } else {
- matcher = SKILL_PATTERN_PERCENTAGE.matcher(component);
- if(matcher.matches()) {
- String skillS = matcher.group(2);
- String xpPercentageS = matcher.group(3).replace(",","");
-
- float xpPercentage = Float.parseFloat(xpPercentageS);
- updateWithPercentage.put(skillS.toLowerCase(), xpPercentage);
- } else {
- matcher = SKILL_PATTERN_MULTIPLIER.matcher(component);
-
- if(matcher.matches()) {
- String skillS = matcher.group(2);
- String currentXpS = matcher.group(3).replace(",","");
- String maxXpS = matcher.group(4).replace(",","");
-
- float maxMult = 1;
- if(maxXpS.endsWith("k")) {
- maxMult = 1000;
- maxXpS = maxXpS.substring(0, maxXpS.length()-1);
- } else if(maxXpS.endsWith("m")) {
- maxMult = 1000000;
- maxXpS = maxXpS.substring(0, maxXpS.length()-1);
- } else if(maxXpS.endsWith("b")) {
- maxMult = 1000000000;
- maxXpS = maxXpS.substring(0, maxXpS.length()-1);
- }
-
- float currentXp = Float.parseFloat(currentXpS);
- float maxXp = Float.parseFloat(maxXpS) * maxMult;
-
- SkillInfo skillInfo = new SkillInfo();
- skillInfo.currentXp = currentXp;
- skillInfo.currentXpMax = maxXp;
- skillInfo.totalXp = currentXp;
-
- JsonArray levelingArray = leveling.getAsJsonArray("leveling_xp");
- for(int i=0; i<levelingArray.size(); i++) {
- float cap = levelingArray.get(i).getAsFloat();
- if(maxXp > 0 && maxXp <= cap) {
- break;
- }
-
- skillInfo.totalXp += cap;
- skillInfo.level++;
- }
-
- skillInfoMap.put(skillS.toLowerCase(), skillInfo);
- return;
- }
- }
- }
- }
- }
- }
-
- public void updateLevel(String skill, int level) {
- if(updateWithPercentage.containsKey(skill)) {
- JsonObject leveling = Constants.LEVELING;
- if(leveling == null) return;
-
- SkillInfo skillInfo = new SkillInfo();
- skillInfo.totalXp = 0;
- skillInfo.level = level;
-
- JsonArray levelingArray = leveling.getAsJsonArray("leveling_xp");
- for(int i=0; i<levelingArray.size(); i++) {
- float cap = levelingArray.get(i).getAsFloat();
- if(i == level) {
- skillInfo.currentXp += updateWithPercentage.get(skill)/100f * cap;
- skillInfo.totalXp += skillInfo.currentXp;
- skillInfo.currentXpMax = cap;
- } else {
- skillInfo.totalXp += cap;
- }
- }
-
- SkillInfo old = skillInfoMap.get(skill.toLowerCase());
-
- if(old.totalXp <= skillInfo.totalXp) {
- correctionCounter--;
- if(correctionCounter < 0) correctionCounter = 0;
-
- skillInfoMap.put(skill.toLowerCase(), skillInfo);
- } else if(++correctionCounter >= 10) {
- correctionCounter = 0;
- skillInfoMap.put(skill.toLowerCase(), skillInfo);
- }
- }
- updateWithPercentage.clear();
- }
-
- public void tick() {
- ProfileApiSyncer.getInstance().requestResync("xpinformation", 5*60*1000,
- () -> {}, this::onApiUpdated);
- }
-
- private static final String[] skills = {"taming","mining","foraging","enchanting","carpentry","farming","combat","fishing","alchemy","runecrafting"};
-
- private void onApiUpdated(ProfileViewer.Profile profile) {
- JsonObject skillInfo = profile.getSkillInfo(null);
-
- for(String skill : skills) {
- SkillInfo info = new SkillInfo();
-
- float level = skillInfo.get("level_skill_"+skill).getAsFloat();
-
- info.totalXp = skillInfo.get("experience_skill_"+skill).getAsFloat();
- info.currentXpMax = skillInfo.get("maxxp_skill_"+skill).getAsFloat();
- info.level = (int)level;
- info.currentXp = (level%1)*info.currentXpMax;
- info.fromApi = true;
-
- skillInfoMap.put(skill.toLowerCase(), info);
- }
- }
+ private static final XPInformation INSTANCE = new XPInformation();
+
+ public static XPInformation getInstance() {
+ return INSTANCE;
+ }
+
+ public static class SkillInfo {
+ public int level;
+ public float totalXp;
+ public float currentXp;
+ public float currentXpMax;
+ public boolean fromApi = false;
+ }
+
+ private final HashMap<String, SkillInfo> skillInfoMap = new HashMap<>();
+ public HashMap<String, Float> updateWithPercentage = new HashMap<>();
+
+ public int correctionCounter = 0;
+
+ private static final Splitter SPACE_SPLITTER = Splitter.on(" ").omitEmptyStrings().trimResults();
+ private static final Pattern SKILL_PATTERN = Pattern.compile(
+ "\\+(\\d+(?:,\\d+)*(?:\\.\\d+)?) (.+) \\((\\d+(?:,\\d+)*(?:\\.\\d+)?)/(\\d+(?:,\\d+)*(?:\\.\\d+)?)\\)");
+ private static final Pattern SKILL_PATTERN_MULTIPLIER =
+ Pattern.compile("\\+(\\d+(?:,\\d+)*(?:\\.\\d+)?) (.+) \\((\\d+(?:,\\d+)*(?:\\.\\d+)?)/(\\d+(?:k|m|b))\\)");
+ private static final Pattern SKILL_PATTERN_PERCENTAGE =
+ Pattern.compile("\\+(\\d+(?:,\\d+)*(?:\\.\\d+)?) (.+) \\((\\d\\d?(?:\\.\\d\\d?)?)%\\)");
+
+ public HashMap<String, SkillInfo> getSkillInfoMap() {
+ return skillInfoMap;
+ }
+
+ public SkillInfo getSkillInfo(String skillName) {
+ return skillInfoMap.get(skillName.toLowerCase());
+ }
+
+ private String lastActionBar = null;
+
+ @SubscribeEvent(priority = EventPriority.HIGHEST, receiveCanceled = true)
+ public void onChatReceived(ClientChatReceivedEvent event) {
+ if (event.type == 2) {
+ JsonObject leveling = Constants.LEVELING;
+ if (leveling == null) return;
+
+ String actionBar = StringUtils.cleanColour(event.message.getUnformattedText());
+
+ if (lastActionBar != null && lastActionBar.equalsIgnoreCase(actionBar)) {
+ return;
+ }
+ lastActionBar = actionBar;
+
+ List<String> components = SPACE_SPLITTER.splitToList(actionBar);
+
+ for (String component : components) {
+ Matcher matcher = SKILL_PATTERN.matcher(component);
+ if (matcher.matches()) {
+ String skillS = matcher.group(2);
+ String currentXpS = matcher.group(3).replace(",", "");
+ String maxXpS = matcher.group(4).replace(",", "");
+
+ float currentXp = Float.parseFloat(currentXpS);
+ float maxXp = Float.parseFloat(maxXpS);
+
+ SkillInfo skillInfo = new SkillInfo();
+ skillInfo.currentXp = currentXp;
+ skillInfo.currentXpMax = maxXp;
+ skillInfo.totalXp = currentXp;
+
+ JsonArray levelingArray = leveling.getAsJsonArray("leveling_xp");
+ for (int i = 0; i < levelingArray.size(); i++) {
+ float cap = levelingArray.get(i).getAsFloat();
+ if (maxXp > 0 && maxXp <= cap) {
+ break;
+ }
+
+ skillInfo.totalXp += cap;
+ skillInfo.level++;
+ }
+
+ skillInfoMap.put(skillS.toLowerCase(), skillInfo);
+ return;
+ } else {
+ matcher = SKILL_PATTERN_PERCENTAGE.matcher(component);
+ if (matcher.matches()) {
+ String skillS = matcher.group(2);
+ String xpPercentageS = matcher.group(3).replace(",", "");
+
+ float xpPercentage = Float.parseFloat(xpPercentageS);
+ updateWithPercentage.put(skillS.toLowerCase(), xpPercentage);
+ } else {
+ matcher = SKILL_PATTERN_MULTIPLIER.matcher(component);
+
+ if (matcher.matches()) {
+ String skillS = matcher.group(2);
+ String currentXpS = matcher.group(3).replace(",", "");
+ String maxXpS = matcher.group(4).replace(",", "");
+
+ float maxMult = 1;
+ if (maxXpS.endsWith("k")) {
+ maxMult = 1000;
+ maxXpS = maxXpS.substring(0, maxXpS.length() - 1);
+ } else if (maxXpS.endsWith("m")) {
+ maxMult = 1000000;
+ maxXpS = maxXpS.substring(0, maxXpS.length() - 1);
+ } else if (maxXpS.endsWith("b")) {
+ maxMult = 1000000000;
+ maxXpS = maxXpS.substring(0, maxXpS.length() - 1);
+ }
+
+ float currentXp = Float.parseFloat(currentXpS);
+ float maxXp = Float.parseFloat(maxXpS) * maxMult;
+
+ SkillInfo skillInfo = new SkillInfo();
+ skillInfo.currentXp = currentXp;
+ skillInfo.currentXpMax = maxXp;
+ skillInfo.totalXp = currentXp;
+
+ JsonArray levelingArray = leveling.getAsJsonArray("leveling_xp");
+ for (int i = 0; i < levelingArray.size(); i++) {
+ float cap = levelingArray.get(i).getAsFloat();
+ if (maxXp > 0 && maxXp <= cap) {
+ break;
+ }
+
+ skillInfo.totalXp += cap;
+ skillInfo.level++;
+ }
+
+ skillInfoMap.put(skillS.toLowerCase(), skillInfo);
+ return;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public void updateLevel(String skill, int level) {
+ if (updateWithPercentage.containsKey(skill)) {
+ JsonObject leveling = Constants.LEVELING;
+ if (leveling == null) return;
+
+ SkillInfo skillInfo = new SkillInfo();
+ skillInfo.totalXp = 0;
+ skillInfo.level = level;
+
+ JsonArray levelingArray = leveling.getAsJsonArray("leveling_xp");
+ for (int i = 0; i < levelingArray.size(); i++) {
+ float cap = levelingArray.get(i).getAsFloat();
+ if (i == level) {
+ skillInfo.currentXp += updateWithPercentage.get(skill) / 100f * cap;
+ skillInfo.totalXp += skillInfo.currentXp;
+ skillInfo.currentXpMax = cap;
+ } else {
+ skillInfo.totalXp += cap;
+ }
+ }
+
+ SkillInfo old = skillInfoMap.get(skill.toLowerCase());
+
+ if (old.totalXp <= skillInfo.totalXp) {
+ correctionCounter--;
+ if (correctionCounter < 0) correctionCounter = 0;
+
+ skillInfoMap.put(skill.toLowerCase(), skillInfo);
+ } else if (++correctionCounter >= 10) {
+ correctionCounter = 0;
+ skillInfoMap.put(skill.toLowerCase(), skillInfo);
+ }
+ }
+ updateWithPercentage.clear();
+ }
+
+ public void tick() {
+ ProfileApiSyncer.getInstance().requestResync("xpinformation", 5 * 60 * 1000,
+ () -> {
+ }, this::onApiUpdated
+ );
+ }
+
+ private static final String[] skills = {
+ "taming",
+ "mining",
+ "foraging",
+ "enchanting",
+ "carpentry",
+ "farming",
+ "combat",
+ "fishing",
+ "alchemy",
+ "runecrafting"
+ };
+
+ private void onApiUpdated(ProfileViewer.Profile profile) {
+ JsonObject skillInfo = profile.getSkillInfo(null);
+
+ for (String skill : skills) {
+ SkillInfo info = new SkillInfo();
+
+ float level = skillInfo.get("level_skill_" + skill).getAsFloat();
+
+ info.totalXp = skillInfo.get("experience_skill_" + skill).getAsFloat();
+ info.currentXpMax = skillInfo.get("maxxp_skill_" + skill).getAsFloat();
+ info.level = (int) level;
+ info.currentXp = (level % 1) * info.currentXpMax;
+ info.fromApi = true;
+
+ skillInfoMap.put(skill.toLowerCase(), info);
+ }
+ }
+
+ public double getPetLevel(String petId, double exp, String rarity) {
+ Stream<JsonElement> pet_levels =
+ StreamSupport.stream(Constants.PETS.get("pet_levels").getAsJsonArray().spliterator(), false);
+ int pet_rarity_offset = Constants.PETS.getAsJsonObject("pet_rarity_offset").get(rarity).getAsInt();
+ JsonObject custom_pet_leveling = Constants.PETS.getAsJsonObject("custom_pet_leveling").getAsJsonObject(petId);
+ List<Integer> xpLevelsRequired =
+ pet_levels.skip(pet_rarity_offset).limit(100).map(JsonElement::getAsInt).collect(Collectors.toList());
+ if (custom_pet_leveling != null && custom_pet_leveling.get("type").getAsInt() == 1)
+ xpLevelsRequired.addAll(StreamSupport
+ .stream(custom_pet_leveling.getAsJsonArray("pet_levels").spliterator(), false)
+ .map(JsonElement::getAsInt)
+ .collect(Collectors.toList()));
+ double remainingExp = exp;
+ for (int i = 0; i < xpLevelsRequired.size(); i++) {
+ int xpForCurrentLevel = xpLevelsRequired.get(i);
+ if (remainingExp >= xpForCurrentLevel) {
+ remainingExp -= xpForCurrentLevel;
+ } else {
+ return i + 1 + remainingExp / xpForCurrentLevel;
+ }
+ }
+ return xpLevelsRequired.size();
+ }
}
diff --git a/src/main/resources/assets/notenoughupdates/FSR_do_not_texture_this_please.png b/src/main/resources/assets/notenoughupdates/FSR_do_not_texture_this_please.png
new file mode 100644
index 00000000..6c001940
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/FSR_do_not_texture_this_please.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/armordisplay/armordisplay.png b/src/main/resources/assets/notenoughupdates/armordisplay/armordisplay.png
new file mode 100644
index 00000000..56f6060a
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/armordisplay/armordisplay.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/armordisplay/armordisplay_fsr.png b/src/main/resources/assets/notenoughupdates/armordisplay/armordisplay_fsr.png
new file mode 100644
index 00000000..b4302903
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/armordisplay/armordisplay_fsr.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/armordisplay/armordisplay_grey.png b/src/main/resources/assets/notenoughupdates/armordisplay/armordisplay_grey.png
new file mode 100644
index 00000000..cb8d0b1b
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/armordisplay/armordisplay_grey.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/armordisplay/armordisplay_phq_dark.png b/src/main/resources/assets/notenoughupdates/armordisplay/armordisplay_phq_dark.png
new file mode 100644
index 00000000..ce36a0cc
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/armordisplay/armordisplay_phq_dark.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/armordisplay/armordisplay_transparent.png b/src/main/resources/assets/notenoughupdates/armordisplay/armordisplay_transparent.png
new file mode 100644
index 00000000..49f1ce4f
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/armordisplay/armordisplay_transparent.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/armordisplay/armordisplay_transparent_pet.png b/src/main/resources/assets/notenoughupdates/armordisplay/armordisplay_transparent_pet.png
new file mode 100644
index 00000000..aeb1b5ed
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/armordisplay/armordisplay_transparent_pet.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/capes/dg.png b/src/main/resources/assets/notenoughupdates/capes/dg.png
new file mode 100644
index 00000000..8625fbfc
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/capes/dg.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/capes/dg_preview.png b/src/main/resources/assets/notenoughupdates/capes/dg_preview.png
new file mode 100644
index 00000000..0ef73797
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/capes/dg_preview.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/capes/furf_preview.png b/src/main/resources/assets/notenoughupdates/capes/furf_preview.png
index 2b152b15..d65f8fbe 100644
--- a/src/main/resources/assets/notenoughupdates/capes/furf_preview.png
+++ b/src/main/resources/assets/notenoughupdates/capes/furf_preview.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/capes/space.png b/src/main/resources/assets/notenoughupdates/capes/space.png
index ba239e22..76d4a42c 100644
--- a/src/main/resources/assets/notenoughupdates/capes/space.png
+++ b/src/main/resources/assets/notenoughupdates/capes/space.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/collectionlog.png b/src/main/resources/assets/notenoughupdates/collectionlog.png
deleted file mode 100644
index c30a0b8f..00000000
--- a/src/main/resources/assets/notenoughupdates/collectionlog.png
+++ /dev/null
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/core/bar_1.png b/src/main/resources/assets/notenoughupdates/core/bar_1.png
new file mode 100644
index 00000000..664c0f32
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/core/bar_1.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/core/bar_2.png b/src/main/resources/assets/notenoughupdates/core/bar_2.png
new file mode 100644
index 00000000..664c0f32
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/core/bar_2.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/core/bar_3.png b/src/main/resources/assets/notenoughupdates/core/bar_3.png
new file mode 100644
index 00000000..664c0f32
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/core/bar_3.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/core/bar_on.png b/src/main/resources/assets/notenoughupdates/core/bar_on.png
new file mode 100644
index 00000000..664c0f32
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/core/bar_on.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/custom_enchant_gui.png b/src/main/resources/assets/notenoughupdates/custom_enchant_gui.png
index 06a1fb5d..735a3fb4 100644
--- a/src/main/resources/assets/notenoughupdates/custom_enchant_gui.png
+++ b/src/main/resources/assets/notenoughupdates/custom_enchant_gui.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/dreamskin.png b/src/main/resources/assets/notenoughupdates/dreamskin.png
new file mode 100644
index 00000000..067d396e
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/dreamskin.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/groundplane.png b/src/main/resources/assets/notenoughupdates/groundplane.png
deleted file mode 100644
index 99630d67..00000000
--- a/src/main/resources/assets/notenoughupdates/groundplane.png
+++ /dev/null
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/panoramas/crystal_hollows/panorama_0.jpg b/src/main/resources/assets/notenoughupdates/panoramas/crystal_hollows/panorama_0.jpg
new file mode 100644
index 00000000..55cf5d16
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/panoramas/crystal_hollows/panorama_0.jpg
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/panoramas/crystal_hollows/panorama_1.jpg b/src/main/resources/assets/notenoughupdates/panoramas/crystal_hollows/panorama_1.jpg
new file mode 100644
index 00000000..9ab86278
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/panoramas/crystal_hollows/panorama_1.jpg
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/panoramas/crystal_hollows/panorama_2.jpg b/src/main/resources/assets/notenoughupdates/panoramas/crystal_hollows/panorama_2.jpg
new file mode 100644
index 00000000..722b6500
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/panoramas/crystal_hollows/panorama_2.jpg
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/panoramas/crystal_hollows/panorama_3.jpg b/src/main/resources/assets/notenoughupdates/panoramas/crystal_hollows/panorama_3.jpg
new file mode 100644
index 00000000..c8f23175
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/panoramas/crystal_hollows/panorama_3.jpg
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/panoramas/crystal_hollows/panorama_4.jpg b/src/main/resources/assets/notenoughupdates/panoramas/crystal_hollows/panorama_4.jpg
new file mode 100644
index 00000000..29b0216f
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/panoramas/crystal_hollows/panorama_4.jpg
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/panoramas/crystal_hollows/panorama_5.jpg b/src/main/resources/assets/notenoughupdates/panoramas/crystal_hollows/panorama_5.jpg
new file mode 100644
index 00000000..c43d80de
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/panoramas/crystal_hollows/panorama_5.jpg
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/panoramas/mining_3/panorama_0.jpg b/src/main/resources/assets/notenoughupdates/panoramas/mining_3/panorama_0.jpg
new file mode 100644
index 00000000..4b7ce678
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/panoramas/mining_3/panorama_0.jpg
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/panoramas/mining_3/panorama_1.jpg b/src/main/resources/assets/notenoughupdates/panoramas/mining_3/panorama_1.jpg
new file mode 100644
index 00000000..689a6e5c
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/panoramas/mining_3/panorama_1.jpg
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/panoramas/mining_3/panorama_2.jpg b/src/main/resources/assets/notenoughupdates/panoramas/mining_3/panorama_2.jpg
new file mode 100644
index 00000000..f7bfa2c1
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/panoramas/mining_3/panorama_2.jpg
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/panoramas/mining_3/panorama_3.jpg b/src/main/resources/assets/notenoughupdates/panoramas/mining_3/panorama_3.jpg
new file mode 100644
index 00000000..403945d0
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/panoramas/mining_3/panorama_3.jpg
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/panoramas/mining_3/panorama_4.jpg b/src/main/resources/assets/notenoughupdates/panoramas/mining_3/panorama_4.jpg
new file mode 100644
index 00000000..b936aa51
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/panoramas/mining_3/panorama_4.jpg
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/panoramas/mining_3/panorama_5.jpg b/src/main/resources/assets/notenoughupdates/panoramas/mining_3/panorama_5.jpg
new file mode 100644
index 00000000..adcda786
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/panoramas/mining_3/panorama_5.jpg
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/petdisplay/petdisplayarmor.png b/src/main/resources/assets/notenoughupdates/petdisplay/petdisplayarmor.png
new file mode 100644
index 00000000..f6a873ea
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/petdisplay/petdisplayarmor.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/petdisplay/petdisplayarmor_dark.png b/src/main/resources/assets/notenoughupdates/petdisplay/petdisplayarmor_dark.png
new file mode 100644
index 00000000..27abd2d5
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/petdisplay/petdisplayarmor_dark.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/petdisplay/petdisplayarmor_fsr.png b/src/main/resources/assets/notenoughupdates/petdisplay/petdisplayarmor_fsr.png
new file mode 100644
index 00000000..39782b3f
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/petdisplay/petdisplayarmor_fsr.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/petdisplay/petdisplayarmor_phqdark.png b/src/main/resources/assets/notenoughupdates/petdisplay/petdisplayarmor_phqdark.png
new file mode 100644
index 00000000..83b78351
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/petdisplay/petdisplayarmor_phqdark.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/petdisplay/petdisplayarmor_transparent.png b/src/main/resources/assets/notenoughupdates/petdisplay/petdisplayarmor_transparent.png
new file mode 100644
index 00000000..f1bebc01
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/petdisplay/petdisplayarmor_transparent.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/petdisplay/petdisplaysolo.png b/src/main/resources/assets/notenoughupdates/petdisplay/petdisplaysolo.png
new file mode 100644
index 00000000..c047d5ad
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/petdisplay/petdisplaysolo.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/petdisplay/petdisplaysolo_dark.png b/src/main/resources/assets/notenoughupdates/petdisplay/petdisplaysolo_dark.png
new file mode 100644
index 00000000..6ad6216c
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/petdisplay/petdisplaysolo_dark.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/petdisplay/petdisplaysolo_fsr.png b/src/main/resources/assets/notenoughupdates/petdisplay/petdisplaysolo_fsr.png
new file mode 100644
index 00000000..f39235af
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/petdisplay/petdisplaysolo_fsr.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/petdisplay/petdisplaysolo_phqdark.png b/src/main/resources/assets/notenoughupdates/petdisplay/petdisplaysolo_phqdark.png
new file mode 100644
index 00000000..80566c92
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/petdisplay/petdisplaysolo_phqdark.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/petdisplay/petdisplaysolo_transparent.png b/src/main/resources/assets/notenoughupdates/petdisplay/petdisplaysolo_transparent.png
new file mode 100644
index 00000000..dfe92b74
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/petdisplay/petdisplaysolo_transparent.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/portal_panoramas/nether/pansc-1.png b/src/main/resources/assets/notenoughupdates/portal_panoramas/nether/pansc-1.png
deleted file mode 100644
index e6d34776..00000000
--- a/src/main/resources/assets/notenoughupdates/portal_panoramas/nether/pansc-1.png
+++ /dev/null
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/portal_panoramas/nether/pansc-2.png b/src/main/resources/assets/notenoughupdates/portal_panoramas/nether/pansc-2.png
deleted file mode 100644
index c94d88c1..00000000
--- a/src/main/resources/assets/notenoughupdates/portal_panoramas/nether/pansc-2.png
+++ /dev/null
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/portal_panoramas/nether/pansc-3.png b/src/main/resources/assets/notenoughupdates/portal_panoramas/nether/pansc-3.png
deleted file mode 100644
index 8ca52a12..00000000
--- a/src/main/resources/assets/notenoughupdates/portal_panoramas/nether/pansc-3.png
+++ /dev/null
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/portal_panoramas/nether/pansc-4.png b/src/main/resources/assets/notenoughupdates/portal_panoramas/nether/pansc-4.png
deleted file mode 100644
index d889fef5..00000000
--- a/src/main/resources/assets/notenoughupdates/portal_panoramas/nether/pansc-4.png
+++ /dev/null
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/portal_panoramas/nether/pansc-5.png b/src/main/resources/assets/notenoughupdates/portal_panoramas/nether/pansc-5.png
deleted file mode 100644
index 2e40a05b..00000000
--- a/src/main/resources/assets/notenoughupdates/portal_panoramas/nether/pansc-5.png
+++ /dev/null
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/portal_panoramas/nether/pansc-6.png b/src/main/resources/assets/notenoughupdates/portal_panoramas/nether/pansc-6.png
deleted file mode 100644
index 95e684f7..00000000
--- a/src/main/resources/assets/notenoughupdates/portal_panoramas/nether/pansc-6.png
+++ /dev/null
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/price_graph_gui/price_information_gui.png b/src/main/resources/assets/notenoughupdates/price_graph_gui/price_information_gui.png
new file mode 100644
index 00000000..633be870
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/price_graph_gui/price_information_gui.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/price_graph_gui/price_information_gui_dark.png b/src/main/resources/assets/notenoughupdates/price_graph_gui/price_information_gui_dark.png
new file mode 100644
index 00000000..0f7743e6
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/price_graph_gui/price_information_gui_dark.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/price_graph_gui/price_information_gui_fsr.png b/src/main/resources/assets/notenoughupdates/price_graph_gui/price_information_gui_fsr.png
new file mode 100644
index 00000000..e98bdb7d
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/price_graph_gui/price_information_gui_fsr.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/price_graph_gui/price_information_gui_phqdark.png b/src/main/resources/assets/notenoughupdates/price_graph_gui/price_information_gui_phqdark.png
new file mode 100644
index 00000000..f794319f
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/price_graph_gui/price_information_gui_phqdark.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/pv_bingo.png b/src/main/resources/assets/notenoughupdates/pv_bingo.png
new file mode 100644
index 00000000..5651dfce
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/pv_bingo.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/pv_mining.png b/src/main/resources/assets/notenoughupdates/pv_mining.png
new file mode 100644
index 00000000..a183fe88
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/pv_mining.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/pv_stranded.png b/src/main/resources/assets/notenoughupdates/pv_stranded.png
new file mode 100644
index 00000000..41b7a7cd
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/pv_stranded.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/pv_unknown.png b/src/main/resources/assets/notenoughupdates/pv_unknown.png
new file mode 100644
index 00000000..d6ce3a00
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/pv_unknown.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/social/twitch.png b/src/main/resources/assets/notenoughupdates/social/twitch.png
new file mode 100644
index 00000000..77a775d2
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/social/twitch.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/sounds.json b/src/main/resources/assets/notenoughupdates/sounds.json
index 47b0ba1b..6d827876 100644
--- a/src/main/resources/assets/notenoughupdates/sounds.json
+++ b/src/main/resources/assets/notenoughupdates/sounds.json
@@ -1,23 +1,111 @@
{
- "calendar_notif_jingle":{
+ "mithril.break": {
+ "category": "block",
+ "sounds": [
+ {
+ "name": "mithrilbreak",
+ "stream": false
+ }
+ ]
+ },
+ "gemstoneTopaz.break": {
+ "category": "block",
+ "sounds": [
+ {
+ "name": "gemstonebreaktopaz",
+ "stream": false
+ }
+ ]
+ },
+ "gemstoneRuby.break": {
+ "category": "block",
+ "sounds": [
+ {
+ "name": "gemstonebreakruby",
+ "stream": false
+ }
+ ]
+ },
+ "gemstoneAmber.break": {
+ "category": "block",
+ "sounds": [
+ {
+ "name": "gemstonebreakamber",
+ "stream": false
+ }
+ ]
+ },
+ "gemstoneAmethyst.break": {
+ "category": "block",
+ "sounds": [
+ {
+ "name": "gemstoneamethystbreak",
+ "stream": false
+ }
+ ]
+ },
+ "gemstoneSapphire.break": {
+ "category": "block",
+ "sounds": [
+ {
+ "name": "gemstonesapphirebreak",
+ "stream": false
+ }
+ ]
+ },
+ "gemstoneJade.break": {
+ "category": "block",
+ "sounds": [
+ {
+ "name": "gemstonejadebreak",
+ "stream": false
+ }
+ ]
+ },
+ "gemstoneJasper.break": {
+ "category": "block",
+ "sounds": [
+ {
+ "name": "gemstonejasperbreak",
+ "stream": false
+ }
+ ]
+ },
+
+ "titanium.break": {
+ "category": "block",
+ "sounds": [
+ {
+ "name": "titaniumbreak",
+ "stream": false
+ }
+ ]
+ },
+ "calendar_notif_jingle": {
"category": "master",
- "sounds": [{
- "name": "jingle",
- "stream": false
- }]
+ "sounds": [
+ {
+ "name": "jingle",
+ "stream": false
+ }
+ ]
},
- "calendar_notif_in":{
+ "calendar_notif_in": {
"category": "master",
- "sounds": [{
- "name": "in",
- "stream": false
- }]
+ "sounds": [
+ {
+ "name": "in",
+ "stream": false
+ }
+ ]
},
- "calendar_notif_out":{
+ "calendar_notif_out": {
"category": "master",
- "sounds": [{
- "name": "out",
- "stream": false
- }]
+ "sounds": [
+ {
+ "name": "out",
+ "stream": false
+ }
+ ]
}
-} \ No newline at end of file
+}
diff --git a/src/main/resources/assets/notenoughupdates/sounds/gemstoneamberbreak.json b/src/main/resources/assets/notenoughupdates/sounds/gemstoneamberbreak.json
new file mode 100644
index 00000000..b02ee0c7
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/sounds/gemstoneamberbreak.json
@@ -0,0 +1 @@
+{ "debouncer": 20 }
diff --git a/src/main/resources/assets/notenoughupdates/sounds/gemstoneamberbreak.ogg b/src/main/resources/assets/notenoughupdates/sounds/gemstoneamberbreak.ogg
new file mode 100644
index 00000000..a04e171a
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/sounds/gemstoneamberbreak.ogg
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/sounds/gemstoneamethystbreak.json b/src/main/resources/assets/notenoughupdates/sounds/gemstoneamethystbreak.json
new file mode 100644
index 00000000..b02ee0c7
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/sounds/gemstoneamethystbreak.json
@@ -0,0 +1 @@
+{ "debouncer": 20 }
diff --git a/src/main/resources/assets/notenoughupdates/sounds/gemstoneamethystbreak.ogg b/src/main/resources/assets/notenoughupdates/sounds/gemstoneamethystbreak.ogg
new file mode 100644
index 00000000..a04e171a
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/sounds/gemstoneamethystbreak.ogg
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/sounds/gemstonejadebreak.json b/src/main/resources/assets/notenoughupdates/sounds/gemstonejadebreak.json
new file mode 100644
index 00000000..b02ee0c7
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/sounds/gemstonejadebreak.json
@@ -0,0 +1 @@
+{ "debouncer": 20 }
diff --git a/src/main/resources/assets/notenoughupdates/sounds/gemstonejadebreak.ogg b/src/main/resources/assets/notenoughupdates/sounds/gemstonejadebreak.ogg
new file mode 100644
index 00000000..a04e171a
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/sounds/gemstonejadebreak.ogg
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/sounds/gemstonejasperbreak.json b/src/main/resources/assets/notenoughupdates/sounds/gemstonejasperbreak.json
new file mode 100644
index 00000000..b02ee0c7
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/sounds/gemstonejasperbreak.json
@@ -0,0 +1 @@
+{ "debouncer": 20 }
diff --git a/src/main/resources/assets/notenoughupdates/sounds/gemstonejasperbreak.ogg b/src/main/resources/assets/notenoughupdates/sounds/gemstonejasperbreak.ogg
new file mode 100644
index 00000000..a04e171a
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/sounds/gemstonejasperbreak.ogg
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/sounds/gemstonerubybreak.json b/src/main/resources/assets/notenoughupdates/sounds/gemstonerubybreak.json
new file mode 100644
index 00000000..b02ee0c7
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/sounds/gemstonerubybreak.json
@@ -0,0 +1 @@
+{ "debouncer": 20 }
diff --git a/src/main/resources/assets/notenoughupdates/sounds/gemstonerubybreak.ogg b/src/main/resources/assets/notenoughupdates/sounds/gemstonerubybreak.ogg
new file mode 100644
index 00000000..a04e171a
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/sounds/gemstonerubybreak.ogg
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/sounds/gemstonesapphirebreak.json b/src/main/resources/assets/notenoughupdates/sounds/gemstonesapphirebreak.json
new file mode 100644
index 00000000..b02ee0c7
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/sounds/gemstonesapphirebreak.json
@@ -0,0 +1 @@
+{ "debouncer": 20 }
diff --git a/src/main/resources/assets/notenoughupdates/sounds/gemstonesapphirebreak.ogg b/src/main/resources/assets/notenoughupdates/sounds/gemstonesapphirebreak.ogg
new file mode 100644
index 00000000..a04e171a
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/sounds/gemstonesapphirebreak.ogg
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/sounds/gemstonetopazbreak.json b/src/main/resources/assets/notenoughupdates/sounds/gemstonetopazbreak.json
new file mode 100644
index 00000000..b02ee0c7
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/sounds/gemstonetopazbreak.json
@@ -0,0 +1 @@
+{ "debouncer": 20 }
diff --git a/src/main/resources/assets/notenoughupdates/sounds/gemstonetopazbreak.ogg b/src/main/resources/assets/notenoughupdates/sounds/gemstonetopazbreak.ogg
new file mode 100644
index 00000000..a04e171a
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/sounds/gemstonetopazbreak.ogg
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/sounds/mithrilbreak.json b/src/main/resources/assets/notenoughupdates/sounds/mithrilbreak.json
new file mode 100644
index 00000000..b02ee0c7
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/sounds/mithrilbreak.json
@@ -0,0 +1 @@
+{ "debouncer": 20 }
diff --git a/src/main/resources/assets/notenoughupdates/sounds/mithrilbreak.ogg b/src/main/resources/assets/notenoughupdates/sounds/mithrilbreak.ogg
new file mode 100644
index 00000000..a04e171a
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/sounds/mithrilbreak.ogg
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/sounds/titaniumbreak.json b/src/main/resources/assets/notenoughupdates/sounds/titaniumbreak.json
new file mode 100644
index 00000000..b02ee0c7
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/sounds/titaniumbreak.json
@@ -0,0 +1 @@
+{ "debouncer": 20 }
diff --git a/src/main/resources/assets/notenoughupdates/sounds/titaniumbreak.ogg b/src/main/resources/assets/notenoughupdates/sounds/titaniumbreak.ogg
new file mode 100644
index 00000000..a04e171a
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/sounds/titaniumbreak.ogg
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/ss_border.jpg b/src/main/resources/assets/notenoughupdates/ss_border.jpg
deleted file mode 100644
index 28c1019f..00000000
--- a/src/main/resources/assets/notenoughupdates/ss_border.jpg
+++ /dev/null
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/storage_gui/storage_icons.png b/src/main/resources/assets/notenoughupdates/storage_gui/storage_icons.png
index 8e435046..be569369 100644
--- a/src/main/resources/assets/notenoughupdates/storage_gui/storage_icons.png
+++ b/src/main/resources/assets/notenoughupdates/storage_gui/storage_icons.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/textures/gui/forge_recipe.png b/src/main/resources/assets/notenoughupdates/textures/gui/forge_recipe.png
new file mode 100644
index 00000000..2c3d2eb1
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/textures/gui/forge_recipe.png
Binary files differ
diff --git a/src/main/resources/assets/notenoughupdates/textures/gui/villager_recipe.png b/src/main/resources/assets/notenoughupdates/textures/gui/villager_recipe.png
new file mode 100644
index 00000000..42b6241c
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/textures/gui/villager_recipe.png
Binary files differ
diff --git a/src/main/resources/mixins.notenoughupdates.json b/src/main/resources/mixins.notenoughupdates.json
index bec344ec..a566ee2e 100644
--- a/src/main/resources/mixins.notenoughupdates.json
+++ b/src/main/resources/mixins.notenoughupdates.json
@@ -3,40 +3,41 @@
"refmap": "mixins.notenoughupdates.refmap.json",
"compatibilityLevel": "JAVA_8",
"mixins": [
- "MixinMinecraft",
- "MixinAbstractClientPlayer",
- "MixinContainer",
- "MixinEffectRenderer",
- "MixinEntityPlayer",
- "MixinEntityPlayerSP",
- "MixinEntityRenderer",
- "MixinGuiChest",
- "MixinGuiContainer",
- "MixinGuiIngame",
- "MixinGuiInventory",
- "MixinGuiScreen",
- "MixinInventoryEffectRenderer",
- "MixinInventoryPlayer",
- "MixinItemCameraTransforms",
- "MixinItemRenderer",
- "MixinItemStack",
- "MixinLayerArmorBase",
- "MixinLayerCustomHead",
-
- "MixinMouseHelper",
- "MixinNetHandlerPlayClient",
- "MixinPlayerControllerMP",
- "MixinRender",
- "MixinRendererLivingEntity",
- "MixinRenderFish",
- "MixinRenderGlobal",
- "MixinRenderItem",
- "MixinRenderList",
- "MixinTextureManager",
- "MixinTileEntitySkullRenderer",
- "MixinTileEntitySpecialRenderer",
- "MixinVboRenderList",
- "MixinWorld",
- "MixinWorldClient"
+ "MixinAbstractClientPlayer",
+ "MixinContainer",
+ "MixinEffectRenderer",
+ "MixinEntity",
+ "MixinEntityAgeable",
+ "MixinEntityPlayer",
+ "MixinEntityPlayerSP",
+ "MixinEntityRenderer",
+ "MixinGuiChest",
+ "MixinGuiContainer",
+ "MixinGuiIngame",
+ "MixinGuiInventory",
+ "MixinGuiScreen",
+ "MixinInventoryEffectRenderer",
+ "MixinInventoryPlayer",
+ "MixinItemCameraTransforms",
+ "MixinItemRenderer",
+ "MixinItemStack",
+ "MixinLayerArmorBase",
+ "MixinLayerCustomHead",
+ "MixinMinecraft",
+ "MixinMouseHelper",
+ "MixinNetHandlerPlayClient",
+ "MixinPlayerControllerMP",
+ "MixinRender",
+ "MixinRendererLivingEntity",
+ "MixinRenderFish",
+ "MixinRenderGlobal",
+ "MixinRenderItem",
+ "MixinRenderList",
+ "MixinTextureManager",
+ "MixinTileEntitySkullRenderer",
+ "MixinTileEntitySpecialRenderer",
+ "MixinVboRenderList",
+ "MixinWorld",
+ "MixinWorldClient"
]
-} \ No newline at end of file
+}